# # autoconf input for Objective Caml programs # Modified by the lablgtk2 development team # Original copyright (C) 2001 Jean-Christophe Filliātre # from a first script by Georges Mariano # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License version 2, as published by the Free Software Foundation. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # See the GNU Library General Public License version 2 for more details # (enclosed in the file LGPL). # the script generated by autoconf from this input will set the following # variables: # CAMLC "ocamlc" if present in the path, or a failure # or "ocamlc.opt" if present with same version number as ocamlc # CAMLOPT "ocamlopt" (or "ocamlopt.opt" if present), or "no" # OCAMLBEST either "byte" if no native compiler was found, # or "opt" otherwise # OCAMLDEP "ocamldep" # OCAMLLEX "ocamllex" (or "ocamllex.opt" if present) # OCAMLYACC "ocamlyac" # OCAMLLIB the path to the ocaml standard library # OCAMLVERSION the ocaml version number # OCAMLWIN32 "yes"/"no" depending on Sys.os_type = "Win32" # EXE ".exe" if OCAMLWIN32=yes, "" otherwise # check for one particular file of the sources # ADAPT THE FOLLOWING LINE TO YOUR SOURCES! AC_INIT(src/gtk.ml) # Check for Ocaml compilers # we first look for ocamlc in the path; if not present, we fail AC_CHECK_PROG(CAMLC,ocamlc,ocamlc,no) if test "$CAMLC" = no ; then AC_MSG_ERROR(Cannot find ocamlc.) fi # we extract Ocaml version number and library path OCAMLVERSION=`$CAMLC -version` echo "ocaml version is $OCAMLVERSION" OCAMLLIB=`$CAMLC -where` echo "ocaml library path is $OCAMLLIB" LIBDIR=$OCAMLLIB AC_ARG_WITH(libdir, [ --with-libdir=/path install libs in /path/lablgtk2 and /path/stublibs], LIBDIR=$withval echo "Install dirs are : $LIBDIR/lablgtk2 and $LIBDIR/stublibs" echo " Compile with ocamlc -I $LIBDIR/lablgtk2 and add $LIBDIR/stublibs either to OCAMLLIB/ld.conf or to CAML_LD_LIBRARY_PATH", echo "Default install dirs are : $LIBDIR/lablgtk2 and $LIBDIR/stublibs" echo "Compile with ocamlc -I +lablgtk2" ) # then we look for ocamlopt; if not present, we issue a warning # if the version is not the same, we also discard it # we set OCAMLBEST to "opt" or "byte", whether ocamlopt is available or not AC_CHECK_PROG(CAMLOPT,ocamlopt,ocamlopt,no) OCAMLBEST=byte if test "$CAMLOPT" = no ; then AC_MSG_WARN(Cannot find ocamlopt; bytecode compilation only.) else AC_MSG_CHECKING(ocamlopt version) TMPVERSION=`$CAMLOPT -version` if test "$TMPVERSION" != "$OCAMLVERSION" ; then AC_MSG_RESULT(differs from ocamlc; ocamlopt discarded.) CAMLOPT=no else AC_MSG_RESULT(ok) OCAMLBEST=opt fi fi # checking for ocamlc.opt AC_CHECK_PROG(OCAMLCDOTOPT,ocamlc.opt,ocamlc.opt,no) if test "$OCAMLCDOTOPT" != no ; then AC_MSG_CHECKING(ocamlc.opt version) TMPVERSION=`$OCAMLCDOTOPT -version` if test "$TMPVERSION" != "$OCAMLVERSION" ; then AC_MSG_RESULT(differs from ocamlc; ocamlc.opt discarded.) else AC_MSG_RESULT(ok) CAMLC=$OCAMLCDOTOPT fi fi # checking for ocamlopt.opt if test "$CAMLOPT" != no ; then AC_CHECK_PROG(OCAMLOPTDOTOPT,ocamlopt.opt,ocamlopt.opt,no) if test "$OCAMLOPTDOTOPT" != no ; then AC_MSG_CHECKING(ocamlc.opt version) TMPVER=`$OCAMLOPTDOTOPT -version` if test "$TMPVER" != "$OCAMLVERSION" ; then AC_MSG_RESULT(differs from ocamlc; ocamlopt.opt discarded.) else AC_MSG_RESULT(ok) CAMLOPT=$OCAMLOPTDOTOPT fi fi fi # ocamlrun, ocamldep, ocamllex and ocamlyacc should also be present in the path AC_CHECK_PROG(OCAMLRUN,ocamlrun,ocamlrun,no) if test "$OCAMLRUN" = no ; then AC_MSG_ERROR(Cannot find ocamlrun.) fi AC_CHECK_PROG(OCAMLDEP,ocamldep,ocamldep,no) if test "$OCAMLDEP" = no ; then AC_MSG_ERROR(Cannot find ocamldep.) fi AC_CHECK_PROG(OCAMLDOC,ocamldoc,ocamldoc,no) if test "$OCAMLDOC" = no ; then AC_MSG_RESULT(Cannot find ocamldoc.) fi AC_CHECK_PROG(OCAMLLEX,ocamllex,ocamllex,no) if test "$OCAMLLEX" = no ; then AC_MSG_ERROR(Cannot find ocamllex.) #else # AC_CHECK_PROG(OCAMLLEXDOTOPT,ocamllex.opt,ocamllex.opt,no) # if test "$OCAMLLEXDOTOPT" != no ; then # OCAMLLEX=$OCAMLLEXDOTOPT # fi fi AC_CHECK_PROG(OCAMLYACC,ocamlyacc,ocamlyacc,no) if test "$OCAMLYACC" = no ; then AC_MSG_ERROR(Cannot find ocamlyacc.) fi AC_CHECK_PROG(CAMLMKTOP,ocamlmktop,ocamlmktop,no) if test "$CAMLMKTOP" = no ; then AC_MSG_ERROR(Cannot find ocamlmktop.) fi AC_CHECK_PROG(CAMLMKLIB,ocamlmklib,ocamlmklib,no) if test "$CAMLMKLIB" = no ; then AC_MSG_ERROR(Cannot find ocamlmklib.) fi AC_CHECK_PROG(CAMLP4O,camlp4o,camlp4o,no) if test "$CAMLP4O" = no ; then AC_MSG_ERROR(Cannot find camlp4o.) fi if expr "$OCAMLVERSION" '>=' '3.08' > /dev/null ; then ODOC_DEF="-D OCAML_308" fi AC_SUBST(ODOC_DEF) # Check for which kind of threads is used AC_MSG_CHECKING(for ocaml threads) AC_ARG_WITH(threads, [ --with-threads=(yes|system|vm|no) which threads to use ], THREADS_LIB="$withval", THREADS_LIB="yes") if (test "$THREADS_LIB" = yes || test "$THREADS_LIB" = system) && \ test -r "$OCAMLLIB/threads/threads.cma"; then THREADS_LIB="system" elif (test "$THREADS_LIB" = yes || test "$THREADS_LIB" = vm) && \ test -r "$OCAMLLIB/vmthreads/stdlib.cma"; then THREADS_LIB="vm" elif test "$THREADS_LIB" = yes || test "$THREADS_LIB" = no; then THREADS_LIB="no" else echo; AC_MSG_ERROR(Cannot use $THREADS_LIB threads) fi AC_MSG_RESULT(use $THREADS_LIB threads) # Check for dll support HAS_DLL_SUPPORT="no" AC_MSG_CHECKING(for ocaml dll support) if test -r "$OCAMLLIB/stublibs/dllunix.so" || test -r "$OCAMLLIB/stublibs/dllunix.dll" then HAS_DLL_SUPPORT="yes" fi AC_MSG_RESULT($HAS_DLL_SUPPORT) AC_PROG_RANLIB # get the C compiler used by ocamlc if test -z "$CC" ; then touch conftest.c CC=$($CAMLC -verbose -c conftest.c 2>&1 | sed ['s/^+ \([^ ]*\) .*$/\1/']) echo [OCaml uses $CC to compile C files] fi AC_PROG_CC # platform AC_MSG_CHECKING(platform) echo "print_endline Sys.os_type ;;" > conftest.ml ac_ocaml_platform=$(ocaml conftest.ml) AC_MSG_RESULT($ac_ocaml_platform) if test $ac_ocaml_platform = Win32 ; then OCAMLWIN32=yes EXE=.exe else OCAMLWIN32=no EXE= fi # GTK 2 auto configuration GTKPKG=gtk+-2.0 AM_PATH_GTK_2_0(2.0.0, :, AC_MSG_ERROR(GTK+ is required)) dnl LABLGTK_PKG(variable, autoconf package, help string, pkgconfig package) AC_DEFUN([LABLGTK_PKG], [ AC_ARG_WITH($2,[$3],USE_$1=$withval; FORCE_$1=yes, USE_$1=yes; FORCE_$1=no) if test $USE_$1 = yes ; then PKG_CHECK_MODULES($1,$4,,[ if test $FORCE_$1 = yes ; then AC_MSG_ERROR($2 enforced but no support found) else AC_MSG_RESULT(no) USE_$1=no fi]) fi if test $USE_$1 = yes ; then USE_$1=1 $1[]PKG=$4 else unset USE_$1 fi AC_SUBST(USE_$1)]) LABLGTK_PKG(GTKGL, gl, [ --without-gl override autodetected GtkGLArea support. Requires LablGL], gtkgl-2.0) # Check for LablGL if test -n "$USE_GTKGL" ; then AC_MSG_CHECKING(lablGL directory) cat > conftest.ml << EOF open Raw EOF if $CAMLC -c -I "${LABLGLDIR:=+lablGL}" conftest.ml > /dev/null 2>&1 ; then AC_MSG_RESULT($LABLGLDIR) else if test $FORCE_GTKGL = yes ; then AC_MSG_ERROR(gtkgl enforced but lablGL not found) else AC_MSG_RESULT(no) unset USE_GTKGL unset GTKGLPKG unset LABLGLDIR fi fi fi LABLGTK_PKG(GLADE, glade, [ --without-glade override autodetected libglade support], libglade-2.0) LABLGTK_PKG(RSVG, rsvg, [ --without-rsvg override autodetected librsvg support], librsvg-2.0) # Check for SVGZ support if test -n "$USE_RSVG" ; then ac_ocaml_libs="$LIBS" LIBS="$LIBS $RSVG_LIBS" AC_CHECK_FUNC(rsvg_handle_new_gz, [HAVE_SVGZ=-DHAVE_SVGZ], [unset HAVE_SVGZ]) LIBS="$ac_ocaml_libs" else unset HAVE_SVGZ fi LABLGTK_PKG(GNOMECANVAS, gnomecanvas, [ --without-gnomecanvas override autodetected libgnomecanvas support], libgnomecanvas-2.0) LABLGTK_PKG(GNOMEUI, gnomeui, [ --without-gnomeui override autodetected libgnomeui support], libgnomeui-2.0) LABLGTK_PKG(PANEL, panel, [ --without-panel override autodetected libpanelapplet support], libpanelapplet-2.0) LABLGTK_PKG(GTKSPELL, gtkspell, [ --without-gtkspell override autodetected gtkspell support], gtkspell-2.0) PKG_CHECK_MODULES(GTKALL,$GTKPKG $GTKGLPKG $GLADEPKG $RSVGPKG $GNOMECANVASPKG $GNOMEUIPKG $PANELPKG $GTKSPELLPKG) AC_ARG_ENABLE(debug, [ --enable-debug enable debug mode], AC_MSG_RESULT(Debug mode enabled) ; DEBUG=1, DEBUG=) # substitutions to perform AC_SUBST(EXE) AC_SUBST(LIBDIR) AC_SUBST(OCAMLBEST) AC_SUBST(OCAMLWIN32) AC_SUBST(OCAMLDEP) AC_SUBST(OCAMLRUN) AC_SUBST(OCAMLLEX) AC_SUBST(OCAMLYACC) AC_SUBST(THREADS_LIB) AC_SUBST(HAS_DLL_SUPPORT) AC_SUBST(CAMLC) AC_SUBST(CAMLOPT) AC_SUBST(OCAMLDOC) AC_SUBST(CAMLMKTOP) AC_SUBST(CAMLMKLIB) AC_SUBST(CAMLP4O) AC_SUBST(LABLGLDIR) AC_SUBST(HAVE_SVGZ) AC_SUBST(USE_CC) AC_SUBST(DEBUG) # Finally create the config.make from config.make.in AC_OUTPUT(config.make) chmod a-w config.make AC_DEFUN([CONF_SUMMARY], [ echo -n " $1 " if test -n "$USE_$2" then echo "yes" else if test "$FORCE_$2" = "yes" then echo "disabled" else echo "not found" fi fi]) echo ; echo "LablGTK configuration:" echo " threads $THREADS_LIB" CONF_SUMMARY(GtkGLArea, GTKGL) CONF_SUMMARY(libglade, GLADE) CONF_SUMMARY(librsvg , RSVG) CONF_SUMMARY(libgnomecanvas, GNOMECANVAS) CONF_SUMMARY(libgnomeui, GNOMEUI) CONF_SUMMARY(libpanelapplet, PANEL) CONF_SUMMARY(gtkspell, GTKSPELL) echo echo -n " debug " if test -n "$DEBUG" ; then echo "yes" ; else echo "no" ; fi echo -e " C compiler $CC"