configure.in 11.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
#
# autoconf input for Objective Caml programs
# Modified by the lablgtk2 development team
# Original copyright (C) 2001 Jean-Christophe Fillitre
#   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 | tr -d '\\r'`
echo "ocaml library path is $OCAMLLIB"
LIBDIR=$OCAMLLIB

AC_ARG_WITH(libdir,
	[  --with-libdir=/path     install libs in /path/lablgtk3 and /path/stublibs],
	LIBDIR=$withval
	echo "Install dirs are : $LIBDIR/lablgtk3 and $LIBDIR/stublibs"
	echo "	Compile with
		ocamlc -I $LIBDIR/lablgtk3
	and add $LIBDIR/stublibs either to OCAMLLIB/ld.conf or
	to CAML_LD_LIBRARY_PATH",
	echo "Default install dirs are : $LIBDIR/lablgtk3 and $LIBDIR/stublibs"
	echo "Compile with ocamlc -I +lablgtk3"
	)

# 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_WARN(Cannot find camlp4o; please do not modify .ml4 files.)
fi

AC_CHECK_PROG(OCAMLFIND,ocamlfind,ocamlfind,no)
if test "`$OCAMLFIND printconf stdlib`" != "`$CAMLC -where`"; then
  AC_MSG_WARN(Ignoring ocamlfind, it uses a different OCaml installation.)
  OCAMLFIND=no
fi

if test "$OCAMLFIND" = no; then
FINDLIBDIR=""
OCAMLLDCONF=""
else
FINDLIBDIR="`ocamlfind printconf destdir | tr -d '\\r'`"
echo "$OCAMLFIND library path is $FINDLIBDIR"
OCAMLLDCONF="`ocamlfind printconf ldconf | tr -d '\\r'`"
echo "$OCAMLFIND ldconf path is $OCAMLLDCONF"
fi

if expr "$OCAMLVERSION" '>=' '4' > /dev/null ; then
   ODOC_DEF="-D OCAML_400"
fi
AC_SUBST(ODOC_DEF)

if expr "$OCAMLVERSION" '>=' '3.11' > /dev/null ; then
   HAS_PRINTEXC_BACKTRACE="-D HAS_PRINTEXC_BACKTRACE"
fi
AC_SUBST(HAS_PRINTEXC_BACKTRACE)

# 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)

RANLIB=`$CAMLC -config | grep ranlib | sed -e "s/ranlib: \(.*\)/\1/" `

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 | head -1 | sed ['s/^+ \([^ ]*\) .*$/\1/'])
  echo [OCaml uses $CC to compile C files]
fi
AC_PROG_CC

AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
  ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
  _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
  AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
    [AS_VAR_SET(CACHEVAR,[yes])],
    [AS_VAR_SET(CACHEVAR,[no])])
  _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
  [m4_default([$2], :)],
  [m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS
OCAML_CC_EXTRA_FLAGS=
AX_CHECK_COMPILE_FLAG(-fno-unwind-tables,[OCAML_CC_EXTRA_FLAGS=-fno-unwind-tables])

# platform
AC_MSG_CHECKING(platform)
echo "print_endline Sys.os_type ;;" > conftest.ml
ac_ocaml_platform=$(ocaml conftest.ml | tr -d '\r')
AC_MSG_RESULT($ac_ocaml_platform)
if test $ac_ocaml_platform = Win32 ; then
    OCAMLWIN32=yes
    EXE=.exe
    XS=.dll
else
    OCAMLWIN32=no
    EXE=
    XS=.so
fi

# Working native Dynlink
AC_MSG_CHECKING(native dynlink)
echo "Dynlink.loadfile \"foo\";;" > test_dynlink.ml
if ($CAMLOPT -shared -o test_dynlink.cmxs test_dynlink.ml) 2> /dev/null ; then
   HAS_NATIVE_DYNLINK=yes
else
   HAS_NATIVE_DYNLINK=no
fi
rm test_dynlink.*

# GTK 3 auto configuration

GTKPKG=gtk+-3.0
AM_PATH_GTK_3_0(3.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
          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-3.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-3.0)

LABLGTK_PKG(RSVG, rsvg,
            [  --without-rsvg          override autodetected librsvg support],
            librsvg-3.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])
    # this tests seems broken on my ubuntu FF
    unset HAVE_SVGZ
    LIBS="$ac_ocaml_libs"
else
    unset HAVE_SVGZ
fi

LABLGTK_PKG(GTKSPELL, gtkspell,
            [  --without-gtkspell      override autodetected gtkspell support],
            gtkspell3-3.0)

LABLGTK_PKG(GTKSOURCEVIEW3, gtksourceview3,
            [  --without-gtksourceview3      override autodetected gtksourceview 3 support],
            gtksourceview-3.0)

LABLGTK_PKG(GTKQUARTZ, quartz,
            [  --without-quartz      override autodetected quartz support],
            gtk+-quartz-3.0)

PKG_CHECK_MODULES(GTKALL,$GTKPKG $GTKGLPKG $GLADEPKG $RSVGPKG $GNOMECANVASPKG $GNOMEUIPKG $PANELPKG $GTKSPELLPKG $GTKSOURCEVIEW2PKG $GTKQUARTZPKG)

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(XS)
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(HAS_NATIVE_DYNLINK)
AC_SUBST(OCAML_CC_EXTRA_FLAGS)

AC_SUBST(CAMLC)
AC_SUBST(CAMLOPT)
AC_SUBST(OCAMLDOC)
AC_SUBST(CAMLMKTOP)
AC_SUBST(CAMLMKLIB)
AC_SUBST(CAMLP4O)
AC_SUBST(OCAMLFIND)
AC_SUBST(FINDLIBDIR)
AC_SUBST(OCAMLLDCONF)
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 $ECHO_N "	$1 $ECHO_C"
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"
echo "	native dynlink 	$HAS_NATIVE_DYNLINK"
CONF_SUMMARY(GtkGLArea, GTKGL)
CONF_SUMMARY(libglade, GLADE)
CONF_SUMMARY(librsvg , RSVG)
CONF_SUMMARY(libpanelapplet, PANEL)
CONF_SUMMARY(gtkspell, GTKSPELL)
CONF_SUMMARY(gtksourceview3, GTKSOURCEVIEW3)
CONF_SUMMARY(quartz   , GTKQUARTZ)
echo
echo $ECHO_N "	debug   $ECHO_C"
if test -n "$DEBUG" ; then echo "	yes" ; else echo "	no" ; fi
echo  "	C compiler	$CC"
echo  "	Camlp4		$CAMLP4O"