1# 2# autoconf input for Objective Caml programs 3# Copyright (C) 2001 Jean-Christophe Filli�tre 4# from a first script by Georges Mariano 5# 6# This library is free software; you can redistribute it and/or 7# modify it under the terms of the GNU Library General Public 8# License version 2, as published by the Free Software Foundation. 9# 10# This library is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13# 14# See the GNU Library General Public License version 2 for more details 15# (enclosed in the file LGPL). 16 17# the script generated by autoconf from this input will set the following 18# variables: 19# OCAMLC "ocamlc" if present in the path, or a failure 20# or "ocamlc.opt" if present with same version number as ocamlc 21# OCAMLOPT "ocamlopt" (or "ocamlopt.opt" if present), or "no" 22# OCAMLBEST either "byte" if no native compiler was found, 23# or "opt" otherwise 24# OCAMLDEP "ocamldep" 25# OCAMLLEX "ocamllex" (or "ocamllex.opt" if present) 26# OCAMLYACC "ocamlyac" 27# OCAMLLIB the path to the ocaml standard library 28# OCAMLVERSION the ocaml version number 29# OCAMLWEB "ocamlweb" (not mandatory) 30 31# check for one particular file of the sources 32# ADAPT THE FOLLOWING LINE TO YOUR SOURCES! 33AC_INIT(unescape.ml) 34 35# Check for Ocaml compilers 36 37# we first look for ocamlc in the path; if not present, we fail 38AC_CHECK_PROG(OCAMLC,ocamlc,ocamlc,no) 39if test "$OCAMLC" = no ; then 40 AC_MSG_ERROR(Cannot find ocamlc.) 41fi 42 43# we extract Ocaml version number and library path 44OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` 45echo "ocaml version is $OCAMLVERSION" 46OCAMLLIB=`$OCAMLC -v | tail -1 | cut -f 4 -d " "` 47echo "ocaml library path is $OCAMLLIB" 48 49# then we look for ocamlopt; if not present, we issue a warning 50# if the version is not the same, we also discard it 51# we set OCAMLBEST to "opt" or "byte", whether ocamlopt is available or not 52AC_CHECK_PROG(OCAMLOPT,ocamlopt,ocamlopt,no) 53OCAMLBEST=byte 54if test "$OCAMLOPT" = no ; then 55 AC_MSG_WARN(Cannot find ocamlopt; bytecode compilation only.) 56else 57 AC_MSG_CHECKING(ocamlopt version) 58 TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` 59 if test "$TMPVERSION" != $OCAMLVERSION ; then 60 AC_MSG_RESULT(differs from ocamlc; ocamlopt discarded.) 61 OCAMLOPT=no 62 else 63 AC_MSG_RESULT(ok) 64 OCAMLBEST=opt 65 fi 66fi 67 68# checking for ocamlc.opt 69AC_CHECK_PROG(OCAMLCDOTOPT,ocamlc.opt,ocamlc.opt,no) 70if test "$OCAMLCDOTOPT" != no ; then 71 AC_MSG_CHECKING(ocamlc.opt version) 72 TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` 73 if test "$TMPVERSION" != $OCAMLVERSION ; then 74 AC_MSG_RESULT(differs from ocamlc; ocamlc.opt discarded.) 75 else 76 AC_MSG_RESULT(ok) 77 OCAMLC=$OCAMLCDOTOPT 78 fi 79fi 80 81# checking for ocamlopt.opt 82if test "$OCAMLOPT" != no ; then 83 AC_CHECK_PROG(OCAMLOPTDOTOPT,ocamlopt.opt,ocamlopt.opt,no) 84 if test "$OCAMLOPTDOTOPT" != no ; then 85 AC_MSG_CHECKING(ocamlc.opt version) 86 TMPVER=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` 87 if test "$TMPVER" != $OCAMLVERSION ; then 88 AC_MSG_RESULT(differs from ocamlc; ocamlopt.opt discarded.) 89 else 90 AC_MSG_RESULT(ok) 91 OCAMLOPT=$OCAMLOPTDOTOPT 92 fi 93 fi 94fi 95 96# ocamldep, ocamllex and ocamlyacc should also be present in the path 97AC_CHECK_PROG(OCAMLDEP,ocamldep,ocamldep,no) 98if test "$OCAMLDEP" = no ; then 99 AC_MSG_ERROR(Cannot find ocamldep.) 100fi 101 102AC_CHECK_PROG(OCAMLLEX,ocamllex,ocamllex,no) 103if test "$OCAMLLEX" = no ; then 104 AC_MSG_ERROR(Cannot find ocamllex.) 105else 106 AC_CHECK_PROG(OCAMLLEXDOTOPT,ocamllex.opt,ocamllex.opt,no) 107 if test "$OCAMLLEXDOTOPT" != no ; then 108 OCAMLLEX=$OCAMLLEXDOTOPT 109 fi 110fi 111 112AC_CHECK_PROG(OCAMLYACC,ocamlyacc,ocamlyacc,no) 113if test "$OCAMLYACC" = no ; then 114 AC_MSG_ERROR(Cannot find ocamlyacc.) 115fi 116 117AC_CHECK_PROG(OCAMLWEB,ocamlweb,ocamlweb,true) 118 119# Checks for C headers, functions 120 121AC_CHECK_HEADER([langinfo.h], 122 [true], 123 [AC_MSG_ERROR([cannot find langinfo.h])]) 124 125AC_CHECK_FUNC([nl_langinfo], 126 [true], 127 [AC_MSG_ERROR([cannot find nl_langinfo])]) 128 129# substitutions to perform 130AC_SUBST(OCAMLC) 131AC_SUBST(OCAMLOPT) 132AC_SUBST(OCAMLDEP) 133AC_SUBST(OCAMLLEX) 134AC_SUBST(OCAMLYACC) 135AC_SUBST(OCAMLBEST) 136AC_SUBST(OCAMLVERSION) 137AC_SUBST(OCAMLLIB) 138AC_SUBST(OCAMLWEB) 139 140# Finally create the Makefile from Makefile.in 141AC_OUTPUT(Makefile) 142chmod a-w Makefile 143