From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=UPPERCASE_25_50 autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id DC311BC4F for ; Fri, 8 Sep 2006 17:08:36 +0200 (CEST) Received: from [128.93.8.195] (alceste.inria.fr [128.93.8.195]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k88F8aO8003979 for ; Fri, 8 Sep 2006 17:08:36 +0200 Message-ID: <45018774.9040903@inria.fr> Date: Fri, 08 Sep 2006 17:08:36 +0200 From: Guillaume Rousse User-Agent: Thunderbird 1.5.0.5 (X11/20060804) MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: autoconf macros, first round X-Enigmail-Version: 0.94.0.0 Content-Type: multipart/mixed; boundary="------------090108000109010405030601" X-Miltered: at concorde with ID 45018774.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; guillaume:01 guillaume:01 autoconf:01 compilation:01 flags:01 ocaml:01 camlp:01 caching:01 ocaml:01 compiler:01 camlp:01 granularity:01 ocamllex:01 ocamlyacc:01 prefered:01 X-Attachments: name="aclocal.m4" name="aclocal.m4" This is a multi-part message in MIME format. --------------090108000109010405030601 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Following discussion from last month, I started to work on three sets of macros: - macros checking install caml system - macros trying to determine caml module compilation flags - macros trying to actually compile some code using a caml module Here is a prototype implementation for the first set, bringing AC_PROG_OCAML and AC_PROG_CAMLP4. I didn't really tested portability yet, and didn't implemented caching either, I'm rather getting opinions about their interfaces and behaviour. Features: - minimal ocaml version checking - strict version checking for all tools - minimal working test for native compiler - user-selectable use of optimized versions Those macros are fatal if ocaml is not found for the first one, and if camlp4 is not found for the second. Otherwise, they just set variables, and issues warnings for missing tools or version mismatches. I'm not really sure, however, for the granularity. Grigory used to have another AC_PROG_OCAML_TOOL for ocamllex and ocamlyacc only, but I don't really see what criteria could be used for distinguishing what should be in AC_PROG_OCAML and what should be kept in AC_PROG_OCAML_TOOL, so I prefered to merge them. I know however camlp4 is installable separatly (at least on mandriva), moreover keeping it separated allows to make it fatal if not found. Comments welcomes. -- Guillaume Rousse Projet Estime, INRIA Domaine de Voluceau Rocquencourt - B.P. 105 78153 Le Chesnay Cedex - France --------------090108000109010405030601 Content-Type: text/plain; name="aclocal.m4" Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename="aclocal.m4" # OCaml macros for autoconf # # Guillaume Rousse # inspired by previous work from: # Georges Mariano # Jean-Christophe Filliātre # Olivier Andrieu # Grigory Batalov # AC_PROG_OCAML([MINIMUM VERSION]) # -------------------------------- # check OCaml base system, and set the following variables: # OCAMLC OCaml compiler # OCAMLC_OPT OCaml optimized compiler # OCAMLOPT OCaml native compiler # OCAMLOPT_OPT OCaml optimized native compiler # OCAMLDEP OCaml dependency generator # OCAMLDEP_OPT OCaml optimized dependency generator # OCAMLMKTOP OCaml toplevel system builder # OCAMLMKLIB OCaml library builder # OCAMLDOC OCaml documentation generator # OCAMLDOC_OPT OCaml optimized documentation generator # OCAMLLIB OCaml library path # OCAMLVERSION OCaml version number # OCAMLLEX OCaml lexer # OCAMLLEX_OPT OCaml optimized lexer # OCAMLYACC OCaml parser # Fails if ocaml compiler is not found. AC_DEFUN([AC_PROG_OCAML], [ # allow the user to disable the use of optimized versions AC_ARG_ENABLE( [opt], AC_HELP_STRING( [--enable-opt], [use optimized versions of ocaml tools (default)] ), [case "$enableval" in yes) ac_ocaml_enable_opt=$enableval;; no) ac_ocaml_enable_opt=$enableval;; *) AC_MSG_ERROR([bad value $enableval for --enable-opt]);; esac], [ac_ocaml_enable_opt="yes"] ) # Checking for OCaml compiler _AC_OCAML_PATH_PROG_FATAL(OCAMLC, ocamlc) # Checking for OCaml version AC_MSG_CHECKING([for OCaml version]) OCAMLVERSION=`$OCAMLC -version` AC_MSG_RESULT([$OCAMLVERSION]) if test -n ["$1"]; then ac_ocaml_min_version=["$1"]; # Checking for OCaml minimum version AC_MSG_CHECKING([whether OCaml version >= $ac_ocaml_min_version]) ac_ocaml_min_major_version=`echo $ac_ocaml_min_version | cut -d. -f1` ac_ocaml_min_minor_version=`echo $ac_ocaml_min_version | cut -d. -f2` ac_ocaml_min_micro_version=`echo $ac_ocaml_min_version | cut -d. -f3` ac_ocaml_major_version=`echo $OCAMLVERSION | cut -d. -f1` ac_ocaml_minor_version=`echo $OCAMLVERSION | cut -d. -f2` ac_ocaml_micro_version=`echo $OCAMLVERSION | cut -d. -f3` if expr \ \( \ $ac_ocaml_major_version \> $ac_ocaml_min_major_version \ \) \| \ \( \ $ac_ocaml_major_version \= $ac_ocaml_min_major_version \& \ $ac_ocaml_minor_version \> $ac_ocaml_min_minor_version \ \) \| \ \( \ $ac_ocaml_major_version \= $ac_ocaml_min_major_version \& \ $ac_ocaml_minor_version \= $ac_ocaml_min_minor_version \& \ $ac_ocaml_micro_version \>= $ac_ocaml_min_micro_version \ \) > /dev/null; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) AC_MSG_ERROR([OCaml version unsufficient]) fi fi # Checking for OCaml library path AC_MSG_CHECKING([for OCaml library path]) OCAMLLIB=`$OCAMLC -where` AC_MSG_RESULT([$OCAMLLIB]) if test "$ac_ocaml_enable_opt" = "yes"; then # Checking for ocamlc.opt _AC_OCAML_PATH_PROG_NONFATAL(OCAMLC_OPT, ocamlc.opt) if test -n "$OCAMLC_OPT"; then _AC_OCAML_CHECK_VERSION_NONFATAL(OCAMLC_OPT, ocamlc.opt) fi if test -n "$OCAMLC_OPT"; then OCAMLC=$OCAMLC_OPT fi fi # Checking for OCaml native compiler _AC_OCAML_PATH_PROG_NONFATAL(OCAMLOPT, ocamlopt, [Cannot find ocamlopt; bytecode compilation only]) if test -n "$OCAMLOPT"; then _AC_OCAML_CHECK_VERSION_NONFATAL(OCAMLOPT, ocamlopt) fi if test -n "$OCAMLOPT"; then touch conftest.c AC_MSG_CHECKING([if OCaml C compiler works]) if $OCAMLC conftest.c >/dev/null 2>&1; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) AC_MSG_WARN([bytecode compilation only]) unset OCAMLOPT fi rm -f conftest.c fi if test "$ac_ocaml_enable_opt" = "yes"; then # Checking for ocamlopt.opt _AC_OCAML_PATH_PROG_NONFATAL(OCAMLOPT_OPT, ocamlopt.opt) if test -n "$OCAMLOPT_OPT"; then _AC_OCAML_CHECK_VERSION_NONFATAL(OCAMLOPT_OPT, ocamlopt.opt) fi if test -n "$OCAMLOPT_OPT"; then OCAMLOPT=$OCAMLOPT_OPT fi fi # Checking for ocamldep _AC_OCAML_PATH_PROG_NONFATAL(OCAMLDEP, ocamldep) if test "$ac_ocaml_enable_opt" = "yes"; then # Checking for ocamldep.opt _AC_OCAML_PATH_PROG_NONFATAL(OCAMLDEP_OPT, ocamldep.opt) if test -n "$OCAMLDEP_OPT"; then OCAMLDEP=$OCAMLDEP_OPT fi fi # Checking for ocamlmktop _AC_OCAML_PATH_PROG_NONFATAL(OCAMLMKTOP, ocamlmktop) # Checking for ocamlmktop _AC_OCAML_PATH_PROG_NONFATAL(OCAMLMKLIB, ocamlmklib) # Checking for ocamldoc _AC_OCAML_PATH_PROG_NONFATAL(OCAMLDOC, ocamldoc) if test "$ac_ocaml_enable_opt" = "yes"; then # Checking for ocamldoc.opt _AC_OCAML_PATH_PROG_NONFATAL(OCAMLDOC_OPT, ocamldoc.opt) if test -n "$OCAMLDOC_OPT"; then OCAMLDOC=$OCAMLDOC_OPT fi fi # Checking for ocamllex _AC_OCAML_PATH_PROG_NONFATAL(OCAMLLEX, ocamllex) if test "$ac_ocaml_enable_opt" = "yes"; then # Checking for ocamllex.opt _AC_OCAML_PATH_PROG_NONFATAL(OCAMLLEX_OPT, ocamllex.opt) if test -n "$OCAMLLEX_OPT"; then OCAMLLEX=$OCAMLLEX_OPT fi fi # Checking for ocamlyacc _AC_OCAML_PATH_PROG_NONFATAL(OCAMLYACC, ocamlyacc) ]) # AC_PROG_OCAML # AC_PROG_CAMLP4 # -------------- # Check CamlP4 and set the following variables: # CAMLP4 camlp4 # CAMLP4O camlp4o # CAMLP4R camlp4r # CAMLP4LIB parser library path # Fails if camlp4 is not found AC_DEFUN([AC_PROG_CAMLP4], [ AC_REQUIRE([AC_PROG_OCAML]) # Checking for camlp4 _AC_OCAML_PATH_PROG_FATAL(CAMLP4, camlp4) _AC_OCAML_CHECK_VERSION_FATAL(CAMLP4, camlp4) # Checking for Camlp4o _AC_OCAML_PATH_PROG_NONFATAL(CAMLP4O, camlp4o) # Checking for Camlp4r _AC_OCAML_PATH_PROG_NONFATAL(CAMLP4R, camlp4r) # Searching for parser library path AC_MSG_CHECKING([for CamlP4 library path]) CAMLP4LIB=`$CAMLP4 -where` AC_MSG_RESULT([$CAMLP4LIB]) ]) # AC_PROG_CAMLP4 # _AC_OCAML_PATH_PROG_FATAL(VARIABLE, PROGRAM, [MESSAGE]) # ------------------------------------------------------- # wraps AC_PATH_PROG, issuing an error if PROGRAM # is not found, otherwise affects its path to VARIABLE AC_DEFUN([_AC_OCAML_PATH_PROG_FATAL], [ AC_PATH_PROG([$1], [$2]) if test -z "[$$1]"; then AC_MSG_ERROR([m4_default([$3], [Cannot find [$2]])]) fi ]) # _AC_OCAML_PATH_PROG_FATAL # _AC_OCAML_PATH_PROG_NONFATAL(VARIABLE, PROGRAM, [MESSAGE]) # ---------------------------------------------------------- # wraps AC_PATH_PROG, issuing a warning if PROGRAM # is not found, otherwise affects its path to VARIABLE AC_DEFUN([_AC_OCAML_PATH_PROG_NONFATAL], [ AC_PATH_PROG([$1], [$2]) if test -z "[$$1]"; then AC_MSG_WARN([m4_default([$3], [Cannot find [$2]])]) fi ]) # _AC_OCAML_PATH_PROG_NONFATAL # _AC_OCAML_CHECK_VERSION(VARIABLE, PROGRAM) # ------------------------------------------ # check than PROGRAM version is the same as the OCaml compiler, # otherwise unset VARIABLE AC_DEFUN([_AC_OCAML_CHECK_VERSION], [ AC_MSG_CHECKING([for [$2] version]) ac_ocaml_check_version=`$[$1] -version` AC_MSG_RESULT([$ac_ocaml_check_version]) if test "$ac_ocaml_check_version" != "$OCAMLVERSION"; then unset [$1] fi ]) # _AC_OCAML_CHECK_VERSION # _AC_OCAML_CHECK_VERSION_NONFATAL(VARIABLE, PROGRAM) # ------------------------------------------ # wraps _AC_OCAML_CHECK_VERSION, issuing a warning if it fails AC_DEFUN([_AC_OCAML_CHECK_VERSION_NONFATAL], [ _AC_OCAML_CHECK_VERSION([$1], [$2]) if test -z ["$$1"]; then AC_MSG_WARN([[$2] version differs from ocamlc, discarding]) fi ]) # _AC_OCAML_CHECK_VERSION_NONFATAL # _AC_OCAML_CHECK_VERSION_FATAL(VARIABLE, PROGRAM) # ------------------------------------------ # wraps _AC_OCAML_CHECK_VERSION, issuing an error if it fails AC_DEFUN([_AC_OCAML_CHECK_VERSION_FATAL], [ _AC_OCAML_CHECK_VERSION([$1], [$2]) if test -z ["$$1"]; then AC_MSG_ERROR([[$2] version differs from ocamlc, aborting]) fi ]) # _AC_OCAML_CHECK_VERSION_FATAL --------------090108000109010405030601--