dnl Process this file with Autoconf to produce a configure script. dnl dnl Written and maintained by Peter Simons . dnl This is in the public domain. dnl We require autoconf 2.50 or later... AC_PREREQ(2.50) AC_INIT(darcs.lhs) dnl The following is now the authoritative location of the version numer. dnl All references to the darcs version number should originate here. From dnl haskell this is easily done by importing Autoconf ( darcs_version ) DARCS_VERSION=1.0.0rc1 AC_SUBST(DARCS_VERSION) dnl Perform some incredibly experimental magic to guess installation dnl paths in an unexpectedly clever way. Henceforth evaluate the paths dnl right away so that we can guarantee _absolute_ paths for our dnl customers. echo "Setting config.command to 'sh ./configure $*" echo sh ./configure "$*" > config.command if test "$prefix" = "NONE"; then prefix=/usr/local if test "$exec_prefix" = "NONE"; then exec_prefix=/usr/local fi if test "$sysconfdir" = '${prefix}/etc'; then sysconfdir=/etc fi fi if test "$exec_prefix" = "NONE"; then exec_prefix=$prefix fi case $prefix in *darcs*) ;; *) if test "$sysconfdir" = '${prefix}/etc'; then sysconfdir=$sysconfdir/darcs fi ;; esac bindir=`eval echo $bindir` sbindir=`eval echo $sbindir` mandir=`eval echo $mandir` datadir=`eval echo $datadir` sysconfdir=`eval echo $sysconfdir` dnl Get rid of the lousy '-g -O2' defaults CFLAGS=$CFLAGS dnl Find gcc AC_PROG_CC AC_PROG_CPP dnl Find ghc AC_CHECK_PROG(GHC, ghc, ghc) if test -z "$GHC"; then AC_MSG_ERROR([Cannot find ghc in your path; please set the GHC environment variable!!]) fi AC_SUBST(GHCFLAGS) dnl Make sure compiler actually works: TRY_COMPILE_GHC([main = putStr "Hello world!\n"],, AC_MSG_ERROR(Compile failed.)) INIT_WORKAROUND dnl Deal with systems that don't have handleToFd WORKAROUND_handleToFd dnl Handle posix signals nicely: WORKAROUND_POSIXSIGNALS([installHandler, Handler(..), Signal, sigINT, sigHUP, sigABRT, sigALRM, sigTERM, sigPIPE,]) dnl Deal with possibly broken Text.Regex WORKAROUND_Regex dnl See if we need a package for parsec... GHC_CHECK_MODULE(Text.ParserCombinators.Parsec, parsec) dnl Deal with systems on which getCurrentDirectory uses '\\' rather than '/': WORKAROUND_getCurrentDirectory AC_SUBST(GHC_SEPARATOR) dnl Deal with systems without createLink WORKAROUND_createLink dnl Handle systems with a buggy renameFile WORKAROUND_renameFile dnl Handle systems that don't do POSIX file modes WORKAROUND_fileModes dnl Make default to have optimizations on... AC_MSG_CHECKING([whether to optimize]) AC_ARG_ENABLE(optimize, [ --disable-optimize disable optimization], optimize=$enableval, optimize=yes) AC_MSG_RESULT($optimize) if test "$optimize" = yes; then GHCFLAGS="$GHCFLAGS -O -funbox-strict-fields" if test "$CFLAGS" = ""; then CFLAGS="$CFLAGS -O2" fi fi dnl Handle CPPFLAGS... GHCFLAGS="$GHCFLAGS $CPPFLAGS" dnl Make default to not profile... AC_MSG_CHECKING([whether to profile]) AC_ARG_ENABLE(profile, [ --enable-profile enable profiling], profile=$enableval,profile=no) AC_MSG_RESULT($profile) if test "$profile" = yes; then GHCFLAGS="$GHCFLAGS -prof -auto-all" fi dnl See if we want to use mmap... for the moment just default to no. AC_MSG_CHECKING([whether to use mmap]) AC_ARG_ENABLE(mmap, [ --disable-mmap do not use mmap (use this flag if you get bus errors)],,enable_mmap=yes) AC_MSG_RESULT($enable_mmap) USE_MMAP="True" if test "$enable_mmap" = "no"; then USE_MMAP="False" fi AC_SUBST(USE_MMAP) TARGETS="darcs darcs_cgi darcs-createrepo darcs.1" INSTALLWHAT="installbin" BUILDDOC="no" dnl Check whether to use crazy PackedString debugging... AC_MSG_CHECKING([whether to do PackedString debugging]) AC_ARG_ENABLE(debug-ps, [ --enable-debug-ps enable PackedString debug mode], debugps=$enableval, debugps=no) AC_MSG_RESULT($debugps) FPSTRINGSTUFF="-fffi" if test "$debugps" = yes; then FPSTRINGSTUFF="$FPSTRINGSTUFF -DDEBUG_PS" fi AC_SUBST(FPSTRINGSTUFF) dnl See if we want to use wxhaskell... AC_MSG_CHECKING([whether to use wxhaskell]) AC_ARG_WITH(wx, [ --with-wx use wxhaskell to provide a GUI interface)], ,with_wx=no) AC_MSG_RESULT($with_wx) if test "$with_wx" = "yes"; then GHC_CHECK_MODULE(Graphics.UI.WX, wx, GHCFLAGS="$GHCFLAGS -DHAVEWX -package wx", AC_MSG_WARN([Couldn't find wx package])) fi dnl See if we want to use antimemoization... AC_MSG_CHECKING([whether to use antimemoization]) AC_ARG_WITH(antimemoization, [ --with-antimemoization use antimemoization to reduce memory usage], ,with_antimemoization=no) AC_MSG_RESULT($with_antimemoization) if test "$with_antimemoization" = "yes"; then GHCFLAGS="$GHCFLAGS -DANTIMEMOIZE" fi dnl Find latex and friends AC_CHECK_PROG(LATEX, latex, latex) if test -z "$LATEX"; then AC_MSG_WARN([Cannot find latex in your path!]) fi AC_CHECK_PROG(DVIPS, dvips, dvips) if test -z "$DVIPS"; then AC_MSG_WARN([Cannot find dvips in your path!]) fi if test ! '(' '(' -z "$LATEX" ')' -o '(' -z "$DVIPS" ')' ')'; then TARGETS="$TARGETS darcs.ps" INSTALLWHAT="$INSTALLWHAT installdocs" BUILDDOC="yes" fi AC_CHECK_PROG(LATEX2HTML, latex2html, latex2html) if test -z "$LATEX2HTML"; then AC_MSG_WARN([Cannot find latex2html in your path!]) AC_CHECK_PROG(HTLATEX, htlatex, htlatex) if test -z "$HTLATEX"; then AC_MSG_WARN([Cannot find htlatex in your path either!]) AC_CHECK_PROG(HEVEA, hevea, hevea) if test -z "$HEVEA"; then AC_MSG_WARN([Cannot find hevea in your path either!]) else TARGETS="$TARGETS manual/index.html" MAKEMANUAL="$HEVEA -o manual/index.html darcs.tex" fi else TARGETS="$TARGETS manual/index.html" MAKEMANUAL="$HTLATEX darcs.tex \"\" \"\" \"-dmanual/\" && ln -sf darcs.html manual/index.html" fi else TARGETS="$TARGETS manual/index.html" MAKEMANUAL="$LATEX2HTML -split +1 -local_icons -dir manual darcs.tex" fi AC_SUBST(TARGETS) AC_SUBST(MAKEMANUAL) AC_SUBST(INSTALLWHAT) dnl Look for sendmail... STUPID_PATH=/usr/sbin:/usr/lib AC_PATH_PROG(SENDMAIL, sendmail, "", $PATH:$STUPID_PATH) if test -z "$SENDMAIL"; then SENDMAIL="" HAVE_SENDMAIL="False" else HAVE_SENDMAIL="True" fi AC_SUBST(SENDMAIL) AC_SUBST(HAVE_SENDMAIL) dnl Look for MAPISendMail AC_CHECK_LIB(mapi32, MAPISendMail, HAVE_MAPI="True", HAVE_MAPI="False") AC_SUBST(HAVE_MAPI) if test "$HAVE_SENDMAIL" = "False" -a "$HAVE_MAPI" = "False"; then AC_MSG_WARN([Can't find sendmail or mapi so you won't be able to push by email!]) fi dnl Allow use of color in output to be disabled AC_ARG_ENABLE(color, [ --disable-color do not use ansi color escapes]) dnl export color flag USE_COLOR="True" if test "$enable_color" = "no"; then USE_COLOR="False" fi AC_SUBST(USE_COLOR) dnl Allow use of hideous malloc hack which can halve memory usage bug makes dnl no sense and causes trouble on some platforms AC_ARG_ENABLE(malloc-hack, [ --enable-malloc-hack use the hideous malloc hack]) USE_HIDEOUS_MALLOC_HACK="False" if test "$enable_mallock-hack" = "yes"; then USE_HIDEOUS_MALLOC_HACK="True" fi AC_SUBST(USE_HIDEOUS_MALLOC_HACK) dnl Find awk AC_PROG_AWK dnl Find libcurl and other libraries needed by hscurl.c AC_ARG_WITH(libcurl, [ --without-libcurl do not use libcurl]) CURLFLAGS= if test "$with_libcurl" != "no"; then AC_MSG_CHECKING([for libcurl]) if eval curl-config --version 2>/dev/null >/dev/null; then ver=`curl-config --version | sed -e "s/libcurl //g"` if test -z "$AWK"; then CURLFLAGS=`curl-config --libs | sed "s_-arch @<:@^ @:>@+__"` else CURLFLAGS=`curl-config --libs | $AWK '{sub(/-arch @<:@^ @:>@+/,""); print}'` fi AC_MSG_RESULT($ver) else AC_MSG_RESULT(FAILED) AC_MSG_WARN([curl-config was not found]) fi fi if test "$CURLFLAGS" = ""; then HAVE_LIBCURL=False else HAVE_LIBCURL=True LDFLAGS="$LDFLAGS $CURLFLAGS" fi AC_SUBST(HAVE_LIBCURL) case $target in *msys*|*mingw*) SYS=windows ;; esac AC_SUBST(SYS) dnl Check for libcurses... AC_ARG_ENABLE(libcurses, [ --without-curses do not use libcurses]) HAVE_CURSES=False if test "$with_libcurses" != "no"; then AC_CHECK_HEADER(term.h, [AC_CHECK_LIB(curses, tgetent, [HAVE_CURSES=True LDFLAGS="$LDFLAGS -lcurses"], [AC_MSG_WARN(Cannot find libcurses, disabling color.)])], [AC_MSG_WARN([Cannot find term.h, disabling color.])] ) fi AC_SUBST(HAVE_CURSES) dnl look for zlib library and header. AC_CHECK_HEADER(zlib.h, :, AC_MSG_ERROR([Cannot find zlib.h; please set the CPPFLAGS environment variable!])) AC_CHECK_FUNC(gzopen, [], [ AC_CHECK_LIB(z, gzopen, LDFLAGS="$LDFLAGS -lz", [ AC_MSG_ERROR(Cannot find system's zlib library; please set the LDFLAGS environment variable!) ]) ]) dnl Look for pthread library and header. AC_CHECK_HEADER(pthread.h, :, AC_MSG_WARN([Cannot find pthread.h; please set the CPPFLAGS environment variable!])) AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[#include ]], [[&CreateThread]]), [CFLAGS="$CFLAGS -DWIN32THREADS", SYS=windows], [AC_CHECK_FUNC(pthread_create, [], [AC_CHECK_LIB(pthread, pthread_create, LDFLAGS="$LDFLAGS -lpthread", [AC_CHECK_LIB(c_r, pthread_create, LDFLAGS="$LDFLAGS -lc_r", [AC_MSG_ERROR(Cannot find system's pthread library; please set the LDFLAGS environment variable!) ]) ]) ]) ]) dnl Look for a suitable diff command AC_CHECK_PROGS(DIFF, [gdiff gnudiff diff]) dnl Look for NullSoft Installer System AC_PATH_PROGS(MAKENSIS, [makensis.exe]) dnl See if we are in a darcs repo and also have darcs available AC_CHECK_PROG(DARCS, darcs, darcs) if test -z "$DARCS" || test ! -d "_darcs"; then CONTEXT_CMD="c_context.c: stringify" CONTEXT_CMD2=" test -f Context.c || echo unknown |./stringify context_string > \$@" else CONTEXT_CMD="c_context.c: _darcs/inventory stringify" CONTEXT_CMD2=" PATH=".:$PATH" darcs changes --context |./stringify context_string > \$@" fi AC_SUBST(CONTEXT_CMD) AC_SUBST(CONTEXT_CMD2) dnl Write results OUTPUT_WORKAROUND AC_OUTPUT(autoconf.mk Autoconf.lhs cgi/darcs.cgi cgi/README cgi/cgi.conf) cat <<[EOF] The build is configured as follows: bindir = $bindir sbindir = $sbindir mandir = $mandir datadir = $datadir sysconfdir = $sysconfdir Build Manual = $BUILDDOC If you want to adjust any of these values, edit autoconf.mk and Autoconf.lhs -- or run configure with appropriate settings. [EOF] dnl Responsibility shifts to the user after this point.