dnl This file is in the public domain. dnl Process this file with Autoconf to produce a configure script. dnl Remove the datarootdir/docdir tests below if this is increased: AC_PREREQ([2.59]) AC_INIT([darcs], [2.1.2], [bugs@darcs.net]) AC_CONFIG_SRCDIR([src/darcs.hs]) dnl Write our invocation date/time and flags into a file so that dnl Darcs knows how it was built. ac_cmdline_args="$*" AC_CONFIG_COMMANDS([config.command], [ echo > config.command "# configured $date" echo >>config.command "./configure $args" chmod +x config.command ], [date="`date`"; args="$ac_cmdline_args"]) dnl The following is now the authoritative location of the version dnl number. All references to the darcs version number should dnl originate here. From Haskell this is easily done by importing dnl the module "Autoconf ( darcs_version )". dnl dnl The version string must not contain any spaces. The version dnl state will automatically be set to any of: dnl dnl "prerelease #n" dnl "release candidate #n" dnl "release" dnl "unstable branch" dnl "stable branch" dnl "unknown branch" dnl dnl The new darcs custom is to increase the version number dnl directly after a release, since the checking for a tag dnl indicates whether the number is really correct. DARCS_VERSION=$PACKAGE_VERSION AC_SUBST(DARCS_VERSION) dnl See if we are in a darcs repo and also have darcs available, dnl and whether we're in a repository... AC_CHECK_PROG(DARCS, darcs, darcs) AC_MSG_CHECKING([if we're in a darcs repository]) if test ! -z "$DARCS" && test -e "_darcs/hashed_inventory"; then I_AM_IN_REPO=yes else I_AM_IN_REPO=no fi AC_MSG_RESULT($I_AM_IN_REPO) AC_SUBST(I_AM_IN_REPO) dnl Get rid of the lousy '-g -O2' defaults CFLAGS=$CFLAGS dnl Compile with multi thread support. Required on Solaris at least. CPPFLAGS="$CPPFLAGS -D_REENTRANT" dnl Find gcc dnl AC_PROG_CC dnl AC_PROG_CPP dnl Make sure a decent "install" is installed. AC_PROG_INSTALL dnl Check to see if we are compiling under Windows AC_CHECK_HEADER(windows.h, [SYS=windows], [SYS=other]) AC_SUBST(SYS) 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) echo found `$GHC --version` AC_CHECK_PROG(GHC_PKG, ghc-pkg, ghc-pkg) if test -z "$GHC_PKG"; then AC_MSG_ERROR([Cannot find ghc-pkg in your path; please set the GHC_PKG environment variable!!]) fi dnl Use -hide-all-packages by default GHCFLAGS="$GHCFLAGS -hide-all-packages -package haskell98" dnl Check for the base package first AC_MSG_CHECKING([base package]) ghc_base_pkg=`$GHC_PKG list base --simple-output | sed -e 's/.*\(base-3\.[[0-9.]]*\).*/\1/'` if test -z "$ghc_base_pkg"; then AC_MSG_RESULT(unknown) GHCFLAGS="$GHCFLAGS -package base" else AC_MSG_RESULT($ghc_base_pkg) GHCFLAGS="$GHCFLAGS -package $ghc_base_pkg" fi dnl Make sure compiler actually works: TRY_COMPILE_GHC([main = putStr "Hello world!\n"],, AC_MSG_ERROR(Compile failed.)) dnl Before anything else, we need to decide what core compiler features to dnl use, becaues this affects all the tests below (e.g. some packages may dnl not be available with profiling) dnl Make default to not profile... AC_MSG_CHECKING([whether to profile]) AC_ARG_ENABLE(profile, AS_HELP_STRING([--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 -threaded to get more responsive progress reporting. AC_MSG_CHECKING([whether to use the threaded runtime]) AC_ARG_ENABLE(threaded,AS_HELP_STRING([--disable-threaded], [don't compile with threaded runtime]),[AC_MSG_RESULT([no])], [MYOLDGHCFLAGS=$GHCFLAGS GHCFLAGS="$GHCFLAGS -threaded" TRY_COMPILE_GHC([main = putStr "Hello world!\n"], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([failed, threaded runtime disabled]) AC_MSG_WARN([Unable to compile with threaded runtime!]) GHCFLAGS=$MYOLDGHCFLAGS])]) AC_CHECK_HEADERS([siginfo.h]) dnl Look for Text.Regex GHC_CHECK_MODULE(Text.Regex( mkRegex, matchRegex, Regex ), text, mkRegex undefined,, GHC_CHECK_MODULE(Text.Regex( mkRegex, matchRegex, Regex ), regex-compat, mkRegex undefined,, AC_MSG_ERROR(Cannot find Text.Regex; try installing the Haskell packages regex-compat or text?) ) ) dnl Look for Network.URI GHC_CHECK_MODULE(Network.URI, network, undefined,, AC_MSG_ERROR(Cannot find Network.URI; try installing the package network?)) dnl Look for native http library GHC_CHECK_MODULE(Network.HTTP( urlEncode ), HTTP, urlEncode undefined, [HAVE_HTTP=True AC_DEFINE([HAVE_HTTP])],[HAVE_HTTP=False]) dnl Look for utf8-string GHC_CHECK_MODULE(Codec.Binary.UTF8.String( encode ), utf8-string, encode undefined, [HAVE_UTF8STRING=True AC_DEFINE([HAVE_UTF8STRING])], [HAVE_UTF8STRING=False]) AC_SUBST(HAVE_HTTP) dnl Look for System.FilePath GHC_CHECK_MODULE(System.FilePath, filepath, isValid,, GHC_CHECK_MODULE(System.FilePath, FilePath, isValid,, AC_MSG_ERROR(Cannot find System.FilePath; try installing the Haskell package filepath?))) dnl See if we need a package for QuickCheck AC_MSG_CHECKING([whether to run unit tests]) AC_ARG_ENABLE(unit, AS_HELP_STRING([--disable-unit],[disable unit tests]), unit=$enableval,unit=yes) AC_MSG_RESULT($unit) if test $unit = "yes"; then GHC_CHECK_MODULE(Test.QuickCheck.Test ( quickCheck ), QuickCheck, quickCheck True,, AC_MSG_ERROR(Cannot find Test.QuickCheck.Test; try installing version 2.1 of the Haskell package quickcheck?)) fi dnl See if we have an adequate version of bytestring, first with the dnl the base package (GHC 6.6), then the actual bytestring package GHC_CHECK_MODULE(Data.ByteString ( cons ), bytestring, cons,, AC_MSG_ERROR(Cannot find Data.ByteString ; try installing the Haskell package bytestring?)) dnl Now that we have the flags for loading Data.ByteString, check to dnl see if we have version 0.9.1 or greater AC_MSG_CHECKING([if our bytestring is recent]) GHC_CHECK_ONE_MODULE(Data.ByteString ( breakByte ), breakByte, AC_MSG_RESULT(yes), [GHCFLAGS="$GHCFLAGS -DHAVE_OLD_BYTESTRING" AC_MSG_RESULT(no)]) dnl See if we have haskeline >= 0.3.1 GHC_CHECK_MODULE(System.Console.Haskeline( runInputT, defaultSettings, getInputLine, handleDyn), haskeline, runInputT defaultSettings (getInputLine "prompt: ") :: IO (Maybe String), [haskelinefound=yes], [haskelinefound=no]) if test $haskelinefound = "yes"; then AC_MSG_CHECKING([whether to use haskeline]) AC_ARG_ENABLE(haskeline, AS_HELP_STRING([--disable-haskeline], [do not use haskeline, even if it is present]), haskeline=$enableval, haskeline=yes) AC_MSG_RESULT($haskeline) if test $haskeline = "yes"; then GHCFLAGS="$GHCFLAGS -DHAVE_HASKELINE" fi fi dnl See if we need any packages from after the split base GHC_CHECK_MODULE(System.Random, random, randomRIO (0,10) :: IO Integer,, AC_MSG_ERROR(Cannot find System.Random; try installing the Haskell package random?)) GHC_CHECK_MODULE(System.Directory, directory, doesFileExist "foo" :: IO Bool,, AC_MSG_ERROR(Cannot find System.Directory; try installing the Haskell package directory?)) GHC_CHECK_MODULE(System.Time, old-time, getClockTime :: IO ClockTime,, AC_MSG_ERROR(Cannot find System.Time; try installing the Haskell package old-time?)) GHC_CHECK_MODULE(System.Process, process, runCommand "foo" :: IO ProcessHandle,, AC_MSG_ERROR(Cannot find System.Process; try installing the Haskell package process?)) dnl note that [[Int]] is for [Int] in Haskell GHC_CHECK_MODULE(Data.Array.Unboxed, array, listArray (0,0) :: [[Int]] -> UArray Int Int,, AC_MSG_ERROR(Cannot find Data.Array.Unboxed; try installing the Haskell package array?)) dnl for make_changelog only GHC_CHECK_MODULE(System.Locale, old-locale, rfc822DateFormat :: String,, AC_MSG_ERROR(Cannot find System.Locale; try installing the Haskell package old-locale?)) dnl See if we need the util or mtl packages for Control.Monad GHC_CHECK_MODULE(Control.Monad.Error, mtl, strMsg "foo" :: String,, AC_MSG_ERROR(Cannot find Control.Monad.Error; try installing the Haskell package mtl?)) dnl See if we need a package for parsec... GHC_CHECK_MODULE(Text.ParserCombinators.Parsec, parsec, errorPos undefined,, AC_MSG_ERROR(Cannot find Text.ParserCombinators.Parsec; try installing the Haskell package parsec?)) dnl Check if we need package html GHC_CHECK_MODULE(Text.Html, html, text "foo",, AC_MSG_ERROR(Cannot find Text.Html; try installing the Haskell package html?)) dnl Check if we need package containers GHC_CHECK_MODULE(Data.Map, containers, empty,, AC_MSG_ERROR(Cannot find Data.Map; try installing the Haskell package containers?)) dnl On windows see if we need a package for random if test "$SYS" = "windows"; then GHC_CHECK_MODULE(System.Random( randomIO ), random, randomIO :: IO Int,, AC_MSG_ERROR(Cannot find System.Random; try installing the Haskell package random?)) else dnl if we're not in windows, we need System.Posix.Files GHC_CHECK_MODULE(System.Posix.Files, unix, undefined,, AC_MSG_ERROR(Cannot find System.Posix.Files; try installing the Haskell package unix?)) dnl Check if we have System.Posix.Signals GHC_CHECK_MODULE(System.Posix.Signals, unix, installHandler, AC_DEFINE(HAVE_SIGNALS),AC_MSG_WARN(Cannot find System.Posix.Signals; interrupt handling disabled)) fi dnl Make default to have optimizations on... AC_MSG_CHECKING([whether to optimize]) AC_ARG_ENABLE(optimize, AS_HELP_STRING([--disable-optimize],[disable optimization]), optimize=$enableval, optimize=yes) AC_MSG_RESULT($optimize) if test "$optimize" = yes; then GHCFLAGS="$GHCFLAGS -O2 -funbox-strict-fields" if test "$CFLAGS" = ""; then CFLAGS="$CFLAGS -O2" fi fi dnl Make default to not use hpc AC_MSG_CHECKING([whether to use Haskell Program Coverage]) AC_ARG_ENABLE(hpc, AS_HELP_STRING([--enable-hpc],[enable Haskell Program Coverage]), hpc=$enableval,hpc=no) AC_MSG_RESULT($hpc) if test "$hpc" = yes; then GHCFLAGS="$GHCFLAGS -fhpc" fi dnl See if we want to use mmap... defaults to yes, except under dnl Windows, where this is always disabled. AC_MSG_CHECKING([whether to use mmap]) AC_ARG_ENABLE(mmap, AS_HELP_STRING([--disable-mmap], [do not use mmap (use this flag if you get bus errors)]), enable_mmap=$enableval,enable_mmap=yes) if test "$SYS" = "windows"; then AC_MSG_RESULT(no (Windows)) else AC_MSG_RESULT($enable_mmap) fi USE_MMAP="True" if test "$enable_mmap" = "no" || test "$SYS" = "windows" ; then USE_MMAP="False" fi AC_SUBST(USE_MMAP) TARGETS="darcs doc/darcs.1" INSTALLWHAT="" dnl Check whether to generate the AUTHORS file... if test -d "_darcs"; then TARGETS="$TARGETS AUTHORS" fi 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) if test "$debugps" = yes; then GHCFLAGS="$GHCFLAGS -DDEBUG_PS" fi dnl Find latex and friends AC_MSG_CHECKING([whether to build manual]) AC_ARG_WITH(manual, AS_HELP_STRING([--without-manual], [do not try to build manual]), ,with_manual=yes) AC_MSG_RESULT($with_manual) if test "$with_manual" = "yes"; then INSTALLWHAT="$INSTALLWHAT install-examples" AC_CHECK_PROG(PDFLATEX, pdflatex, pdflatex) if test -z "$PDFLATEX"; then AC_MSG_WARN([Unable to render user manual to PDF.]) fi AC_CHECK_PROG(LATEX, latex, latex) AC_CHECK_PROG(DVIPS, dvips, dvips) if test -z "$PDFLATEX" && test -z "$LATEX" -o -z "$DVIPS"; then AC_MSG_WARN([Unable to render user manual to PostScript.]) fi AC_CHECK_PROG(RUBBER, rubber, rubber) dnl Prefer PDF to PostScript; if we can build the former, don't dnl build nor install the latter by default. if test -n "$PDFLATEX"; then TARGETS="$TARGETS pdf" INSTALLWHAT="$INSTALLWHAT install-pdf" BUILDDOC="PDF" elif test -n "$LATEX" -a -n "$DVIPS"; then TARGETS="$TARGETS ps" INSTALLWHAT="$INSTALLWHAT install-ps" BUILDDOC="PostScript" fi AC_CHECK_PROG(LATEX2HTML, latex2html, latex2html) if test -z "$LATEX2HTML"; then PREPROCHTML="" AC_CHECK_PROG(HTLATEX, htlatex, htlatex) if test -z "$HTLATEX"; then AC_CHECK_PROG(HEVEA, hevea, hevea) if test -z "$HEVEA"; then AC_MSG_WARN([Unable to render user manual to HTML.]) MAKEMANUAL="touch doc/manual/index.html; echo Cannot make manual!" else TARGETS="$TARGETS html" INSTALLWHAT="$INSTALLWHAT install-html" BUILDDOC="$BUILDDOC and HTML" MAKEMANUAL="$HEVEA -o doc/manual/index.html doc/manual/darcs.tex" fi else TARGETS="$TARGETS html" INSTALLWHAT="$INSTALLWHAT install-html" BUILDDOC="$BUILDDOC and HTML" MAKEMANUAL="cd doc/manual && $HTLATEX darcs.tex && ln -sf darcs.html index.html" fi else TARGETS="$TARGETS html" INSTALLWHAT="$INSTALLWHAT install-html" BUILDDOC="$BUILDDOC and HTML" MAKEMANUAL="$LATEX2HTML -split +1 -dir doc/manual doc/manual/darcs.tex" dnl the following tells "preproc" to generate "rawhtml" sections for latex2html. PREPROCHTML="--html" fi fi AC_SUBST(TARGETS) AC_SUBST(MAKEMANUAL) AC_SUBST(INSTALLWHAT) AC_SUBST(PREPROCHTML) dnl Look for sendmail... AC_ARG_WITH(sendmail, [ --with-sendmail=PATHTOSENDMAIL], [ SENDMAIL=$with_sendmail HAVE_SENDMAIL="True" ], [ 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, AS_HELP_STRING([--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 Try to link with static versions of libraries. AC_ARG_WITH(static-libs, [ --with-static-libs link with static versions of libraries]) if test "x$with_static_libs" = "xyes"; then LDFLAGS="-static $LDFLAGS" fi dnl Check whether to use existential type witnesses AC_MSG_CHECKING([for gadt type witnesses]) AC_ARG_WITH(type-witnesses, AS_HELP_STRING([--with-type-witnesses], [use GADT type witnesses (EXPERIMENTAL!)]) ,with_typew=$withval ,with_typew=no) if test "$with_typew" = "yes"; then GHCFLAGS="$GHCFLAGS -fglasgow-exts" AC_DEFINE([GADT_WITNESSES]) AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi dnl look for zlib library and header. dnl Use GHC_CHECK_LIBRARY and not AC_CHECK_HEADER / AC_CHECK_LIB because GHC may dnl use a different library and header than the system GCC (on Windows, issue 813) GHC_CHECK_LIBRARY([z],[zlib.h deflate],[Int -> Int -> Int], [czlibfound=yes], [czlibfound=no]) if test $czlibfound = "yes"; then AC_MSG_CHECKING([whether to use the C zlib]) AC_ARG_ENABLE(c-zlib, AS_HELP_STRING([--disable-c-zlib], [do not use the C zlib, even if it is present]), czlib=$enableval, czlib=yes) AC_MSG_RESULT($czlib) fi if test "$czlib" != "yes"; then dnl See if we have an adequate version of the haskell zlib GHC_CHECK_MODULE(Codec.Compression.GZip( decompressWith, DecompressParams(decompressBufferSize), defaultDecompressParams ), zlib, decompressWith (defaultDecompressParams { decompressBufferSize = 10 }) undefined, [haskellzlibfound=yes], [haskellzlibfound=no]) if test "$haskellzlibfound" = "yes"; then AC_MSG_CHECKING([whether to use the Haskell zlib]) AC_ARG_ENABLE(haskell-zlib, AS_HELP_STRING([--disable-haskell-zlib], [do not use the Haskell zlib, even if it is present]), haskellzlib=$enableval, haskellzlib=yes) AC_MSG_RESULT($haskellzlib) fi if test "$haskellzlib" = "yes"; then CPPFLAGS="$CPPFLAGS -DHAVE_HASKELL_ZLIB" else AC_MSG_ERROR([Cannot find a suitable zlib library; for the C zlib please set the LDFLAGS environment variable, or for the Haskell zlib install at least version 0.5.0.0)]) fi fi dnl Find libwww and other libraries needed by hswww.c AC_ARG_WITH(libwww, AS_HELP_STRING([--with-libwww],[use libwww])) if test "$with_libwww" == "yes"; then AC_MSG_CHECKING([for libwww]) if eval libwww-config --version 2>/dev/null >/dev/null; then CPPFLAGS="$CPPFLAGS -DHAVE_LIBWWW" WWWVERSION=`libwww-config --version` LIBS="$LIBS `libwww-config --libs`" CFLAGS="$CFLAGS `libwww-config --cflags`" have_libwww=yes AC_MSG_RESULT($WWWVERSION) else AC_MSG_RESULT(FAILED) AC_MSG_WARN([libwww-config was not found]) fi fi dnl Find libcurl and other libraries needed by hscurl.c AC_ARG_WITH(libcurl, AS_HELP_STRING([--without-libcurl],[do not use libcurl])) AC_ARG_WITH(curl, AS_HELP_STRING([--with-curl=