AC_INIT([TAToo], [0.0.1], [Kim Nguyễn ], [tatoo]) #detect ocamlfind OCAMLFIND=ocamlfind AC_ARG_WITH([ocamlfind], AS_HELP_STRING([--with-ocamlfind=PATH], [location of the ocamlfind binary]), [OCAMLFIND="$withval"]) AC_MSG_CHECKING([for ocamlfind ($OCAMLFIND)]) $OCAMLFIND list >/dev/null 2>&1 if test $? ; then AC_MSG_RESULT([found]) OCAMLC="$OCAMLFIND ocamlc" OCAMLOPT="$OCAMLFIND ocamlopt" OCAMLDEP="$OCAMLFIND ocamldep" else AC_MSG_RESULT([not found]) AC_MSG_ERROR([Cannot find ocamlfind.]) fi AC_SUBST([OCAMLFIND]) #check ocamlc AC_MSG_CHECKING([for $OCAMLC]) $OCAMLC >/dev/null 2>&1 if test $? ; then AC_MSG_RESULT([ok]) else AC_MSG_RESULT([failed]) AC_MSG_ERROR(Cannot find ocamlc.) fi AC_SUBST([OCAMLC]) #check ocamlopt AC_MSG_CHECKING([for $OCAMLOPT]) $OCAMLOPT >/dev/null 2>&1 if test $? ; then AC_MSG_RESULT([ok]) else AC_MSG_RESULT([failed]) AC_MSG_ERROR(Cannot find ocamlopt.) fi AC_SUBST([OCAMLOPT]) #check ocamldep AC_MSG_CHECKING([for $OCAMLDEP]) $OCAMLDEP >/dev/null 2>&1 if test $? ; then AC_MSG_RESULT([ok]) else AC_MSG_RESULT([failed]) AC_MSG_ERROR(Cannot find ocamldep.) fi AC_SUBST([OCAMLDEP]) #ocaml version OCAMLVERSION=$($OCAMLC -version) AC_MSG_CHECKING([ocaml version]) AC_MSG_RESULT([$OCAMLVERSION]) case "$OCAMLVERSION" in 3.12.*) ;; 4.*) ;; *) AC_MSG_ERROR([OCaml $OCAMLVERSION is too old]) ;; esac AC_SUBST(OCAMLVERSION) #detect ocamlyacc OCAMLYACC=ocamlyacc AC_ARG_WITH([ocamlyacc], AS_HELP_STRING([--with-ocamlyacc=PATH], [location of the ocamlyacc binary]), [OCAMLYACC="$withval"]) AC_MSG_CHECKING([for ocamlyacc ($OCAMLYACC)]) OCAMLYACC_VERSION=$($OCAMLYACC -version 2>/dev/null || echo foo) case "$OCAMLYACC_VERSION" in *$OCAMLVERSION) AC_MSG_RESULT([ok]) ;; foo) AC_MSG_RESULT([failed]) AC_MSG_ERROR([Cannot find ocamlyacc]) ;; *) AC_MSG_RESULT([failed]) AC_MSG_ERROR([Bad ocamlyacc version]) ;; esac AC_SUBST([OCAMLYACC]) #detect ocamllex OCAMLLEX=ocamllex AC_ARG_WITH([ocamllex], AS_HELP_STRING([--with-ocamllex=PATH], [location of the ocamllex binary]), [OCAMLLEX="$withval"]) AC_MSG_CHECKING([for ocamllex ($OCAMLLEX)]) OCAMLLEX_VERSION=$($OCAMLLEX -version 2>/dev/null || echo foo) case "$OCAMLLEX_VERSION" in *$OCAMLVERSION) AC_MSG_RESULT([ok]) ;; foo) AC_MSG_RESULT([failed]) AC_MSG_ERROR([Cannot find ocamllex]) ;; *) AC_MSG_RESULT([failed]) AC_MSG_ERROR([Bad ocamllex version]) ;; esac AC_SUBST([OCAMLLEX]) #detect camlp4 CAMLP4=camlp4 AC_ARG_WITH([camlp4], AS_HELP_STRING([--with-camlp4=PATH], [location of the camlp4 binary]), [CAMLP4="$withval"]) AC_MSG_CHECKING([for camlp4 ($CAMLP4)]) CAMLP4_VERSION=$($CAMLP4 -version 2>/dev/null || echo foo) case "$CAMLP4_VERSION" in *$OCAMLVERSION) AC_MSG_RESULT([ok]) ;; foo) AC_MSG_RESULT([failed]) AC_MSG_ERROR([Cannot find camlp4]) ;; *) AC_MSG_RESULT([failed]) AC_MSG_ERROR([Bad camlp4 version]) ;; esac AC_SUBST([CAMLP4]) # platform AC_MSG_CHECKING([platform]) OCAML_PLATFORM=$(echo 'print_endline Sys.os_type;;' | ocaml -noprompt | grep '^@<:@A-Z@:>@') AC_MSG_RESULT([$OCAML_PLATFORM]) if test "$OCAML_PLATFORM" = "Win32"; then EXE=.exe else EXE= fi AC_SUBST(OCAML_PLATFORM) AC_SUBST(EXE) # required libraries AC_MSG_CHECKING([for ulex]) ulex_path=`$OCAMLFIND query ulex 2>/dev/null` if test "$ulex_path" ; then AC_MSG_RESULT([found]) else AC_MSG_RESULT([not found]) AC_MSG_ERROR([Cannot find ulex.]) fi AC_MSG_CHECKING([for expat]) expat_path=`$OCAMLFIND query expat 2>/dev/null` if test "$expat_path" ; then AC_MSG_RESULT([found]) else AC_MSG_RESULT([not found]) AC_MSG_ERROR([Cannot find expat.]) fi #compilation options #debugging mode OCAMLFLAGS=$OCAMLFLAGS CAMLP4FLAGS=$CAMLP4FLAGS OCAMLCFLAGS=$OCAMLCFLAGS OCAMLOPTFLAGS=$OCAMLOPTFLAGS AC_ARG_ENABLE([debug], [ --enable-debug build in debug mode], [DEBUG=$enableval], [DEBUG=no]) if test "x$DEBUG" = "xyes"; then OCAMLFLAGS="$OCAMLFLAGS -g" CAMLP4FLAGS="$CAMLP4FLAGS -DDEBUG" fi #profiling AC_ARG_ENABLE([profile], [ --enable-profile compile in profiling code], [PROFILE=$enableval], [PROFILE=no]) if test "x$PROFILE" = "xyes"; then OCAMLOPTFLAGS="$OCAMLOPTFLAGS -p" OCAMLC="$OCAMLFIND ocamlcp" fi #tracing code AC_ARG_ENABLE([trace], [ --enable-trace add tracing code], [TRACE=$enableval], [TRACE=no]) if test "x$TRACE" = "xyes"; then CAMLP4FLAGS="$CAMLP4FLAGS -DHTMLTRACE" fi #inlining AC_ARG_ENABLE([inline], [ --enable-inline set OCaml inlining level (default=100)], [INLINE=$enableval], [INLINE=100]) #unsafe AC_ARG_ENABLE([unsafe], [ --enable-unsafe use unsafe array and string accesses], [UNSAFE=1], [UNSAFE=0]) if test "x$UNSAFE" = "xyes"; then CAMLP4FLAGS="$CAMLP4FLAGS -unsafe" fi AC_PROG_CXX() AC_SUBST([REMAKE], [./remake$EXE]) if test ! -x "$REMAKE" -o "$REMAKE" -ot remake.cpp; then AC_MSG_NOTICE([creating $REMAKE]) case $(uname -s) in MINGW*) $CXX -Wall -O2 -o remake.exe remake.cpp -lws2_32 if test $? != 0; then AC_MSG_FAILURE([failed]); fi ;; *) $CXX -Wall -O2 -o remake remake.cpp if test $? != 0; then AC_MSG_FAILURE([failed]); fi ;; esac else AC_MSG_NOTICE([$REMAKE exists, not rebuilding]) fi AC_SUBST(INLINE) AC_SUBST(OCAMLFLAGS) AC_SUBST(OCAMLCFLAGS) AC_SUBST(OCAMLOPTFLAGS) AC_SUBST(CAMLP4FLAGS) AC_CONFIG_FILES(Remakefile) AC_OUTPUT