Find git executable at run time
[git-darcs-import.git] / configure.ac
blob96d22236a77d05eb2ed80399e4d6c77d8728daf4
1 dnl This file is in the public domain.
3 dnl Process this file with Autoconf to produce a configure script.
5 dnl Remove the datarootdir/docdir tests below if this is increased:
6 AC_PREREQ([2.59])
7 AC_INIT([darcs], [2.1.0], [bugs@darcs.net])
8 AC_CONFIG_SRCDIR([src/darcs.lhs])
10 dnl Write our invocation date/time and flags into a file so that
11 dnl Darcs knows how it was built.
13 ac_cmdline_args="$*"
14 AC_CONFIG_COMMANDS([config.command],
15                    [ echo > config.command "# configured $date"
16                      echo >>config.command "./configure $args"
17                      chmod +x config.command
18                    ],
19                    [date="`date`"; args="$ac_cmdline_args"])
21 dnl The following is now the authoritative location of the version
22 dnl number. All references to the darcs version number should
23 dnl originate here. From Haskell this is easily done by importing
24 dnl the module "Autoconf ( darcs_version )".
25 dnl
26 dnl The version string must not contain any spaces. The version
27 dnl state will automatically be set to any of:
28 dnl
29 dnl    "prerelease #n"
30 dnl    "release candidate #n"
31 dnl    "release"
32 dnl    "unstable branch"
33 dnl    "stable branch"
34 dnl    "unknown branch"
35 dnl
36 dnl The new darcs custom is to increase the version number
37 dnl directly after a release, since the checking for a tag
38 dnl indicates whether the number is really correct.
40 DARCS_VERSION=$PACKAGE_VERSION
41 AC_SUBST(DARCS_VERSION)
43 dnl See if we are in a darcs repo and also have darcs available,
44 dnl and whether we're in a repository...
46 AC_CHECK_PROG(DARCS, darcs, darcs)
47 AC_MSG_CHECKING([if we're in a darcs repository])
48 if test ! -z "$DARCS" && test -e "_darcs/hashed_inventory"; then
49   I_AM_IN_REPO=yes
50 else
51   I_AM_IN_REPO=no
53 AC_MSG_RESULT($I_AM_IN_REPO)
54 AC_SUBST(I_AM_IN_REPO)
56 dnl Get rid of the lousy '-g -O2' defaults
58 CFLAGS=$CFLAGS
60 dnl Compile with multi thread support. Required on Solaris at least.
62 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
64 dnl Find gcc
66 dnl AC_PROG_CC
67 dnl AC_PROG_CPP
69 dnl Make sure a decent "install" is installed.
71 AC_PROG_INSTALL
73 dnl Check to see if we are compiling under Windows
75 AC_CHECK_HEADER(windows.h, [SYS=windows], [SYS=other])
76 AC_SUBST(SYS)
78 dnl Find ghc
80 AC_CHECK_PROG(GHC, ghc, ghc)
81 if test -z "$GHC"; then
82   AC_MSG_ERROR([Cannot find ghc in your path; please set the GHC environment variable!!])
84 AC_SUBST(GHCFLAGS)
85 echo found `$GHC --version`
87 dnl Use -hide-all-packages by default
89 GHCFLAGS="$GHCFLAGS -hide-all-packages -package base -package haskell98"
91 dnl Make sure compiler actually works:
93 TRY_COMPILE_GHC([main = putStr "Hello world!\n"],,
94                 AC_MSG_ERROR(Compile failed.))
96 dnl Before anything else, we need to decide what core compiler features to
97 dnl use, becaues this affects all the tests below (e.g. some packages may
98 dnl not be available with profiling)
100 dnl Make default to not profile...
102 AC_MSG_CHECKING([whether to profile])
103 AC_ARG_ENABLE(profile,
104               AS_HELP_STRING([--enable-profile],[enable profiling]),
105               profile=$enableval,profile=no)
106 AC_MSG_RESULT($profile)
108 if test "$profile" = yes; then
109   GHCFLAGS="$GHCFLAGS -prof -auto-all"
112 dnl See if we want to use -threaded to get more responsive progress reporting.
113 AC_MSG_CHECKING([whether to use the threaded runtime])
114 AC_ARG_ENABLE(threaded,AS_HELP_STRING([--disable-threaded],
115               [don't compile with threaded runtime]),[AC_MSG_RESULT([no])],
116               [MYOLDGHCFLAGS=$GHCFLAGS
117                GHCFLAGS="$GHCFLAGS -threaded"
118                TRY_COMPILE_GHC([main = putStr "Hello world!\n"],
119                 [AC_MSG_RESULT([yes])],
120                 [AC_MSG_RESULT([failed, threaded runtime disabled])
121                  AC_MSG_WARN([Unable to compile with threaded runtime!])
122                  GHCFLAGS=$MYOLDGHCFLAGS])])
124 AC_CHECK_HEADERS([siginfo.h])
126 dnl Look for Text.Regex
128 GHC_CHECK_MODULE(Text.Regex( mkRegex, matchRegex, Regex ), text, mkRegex undefined,,
129   GHC_CHECK_MODULE(Text.Regex( mkRegex, matchRegex, Regex ), regex-compat, mkRegex undefined,,
130     AC_MSG_ERROR(Cannot find Text.Regex; try installing the Haskell packages regex-compat or text?)
131   )
134 dnl Look for Network.URI
136 GHC_CHECK_MODULE(Network.URI, network, undefined,,
137                  AC_MSG_ERROR(Cannot find Network.URI; try installing the package network?))
139 dnl Look for native http library
141 GHC_CHECK_MODULE(Network.HTTP( urlEncode ), HTTP, urlEncode undefined,
142                  [HAVE_HTTP=True
143                   AC_DEFINE([HAVE_HTTP])],[HAVE_HTTP=False])
145 AC_SUBST(HAVE_HTTP)
147 dnl Look for System.FilePath
149 GHC_CHECK_MODULE(System.FilePath, filepath, isValid,,
150     GHC_CHECK_MODULE(System.FilePath, FilePath, isValid,,
151                  AC_MSG_ERROR(Cannot find System.FilePath; try installing the Haskell package filepath?)))
153 dnl See if we need a package for QuickCheck
155 GHC_CHECK_MODULE(Test.QuickCheck( quickCheck ), QuickCheck, quickCheck True,,
156                  AC_MSG_ERROR(Cannot find Test.QuickCheck; try installing the Haskell package quickcheck?))
158 dnl See if we have an adequate version of bytestring
159 GHC_CHECK_MODULE(Data.ByteString.Internal( fromForeignPtr ),
160                  bytestring,
161                  fromForeignPtr,
162                  [bytestringfound=yes],
163                  [bytestringfound=no])
164 if test $bytestringfound = "yes"; then
165   AC_MSG_CHECKING([whether to use ByteString])
166   AC_ARG_ENABLE(bytestring,
167                 AS_HELP_STRING([--disable-bytestring], [do not use bytestring, even if it is present]),
168                 bytestring=$enableval,
169                 bytestring=yes)
170   AC_MSG_RESULT($bytestring)
171   # If we aren't instructed to avoid bytestring, and we did successfully find bytestring...
172   if test $bytestring = "yes"; then
173     CPPFLAGS="$CPPFLAGS -DHAVE_BYTESTRING"
174   fi
177 dnl See if we have haskeline >= 0.3.1
178 GHC_CHECK_MODULE(System.Console.Haskeline( runInputT, defaultSettings, getInputLine, handleDyn),
179                  haskeline,
180                  runInputT defaultSettings (getInputLine "prompt: ") :: IO (Maybe String),
181                  [haskelinefound=yes],
182                  [haskelinefound=no])
183 if test $haskelinefound = "yes"; then
184   AC_MSG_CHECKING([whether to use haskeline])
185   AC_ARG_ENABLE(haskeline,
186                 AS_HELP_STRING([--disable-haskeline], [do not use haskeline, even if it is present]),
187                 haskeline=$enableval,
188                 haskeline=yes)
189   AC_MSG_RESULT($haskeline)
190   if test $haskeline = "yes"; then
191     GHCFLAGS="$GHCFLAGS -DHAVE_HASKELINE"
192   fi
195 dnl See if we need any packages from after the split base
197 GHC_CHECK_MODULE(System.Random, random, randomRIO (0,10) :: IO Integer,,
198                  AC_MSG_ERROR(Cannot find System.Random; try installing the Haskell package random?))
200 GHC_CHECK_MODULE(System.Directory, directory, doesFileExist "foo" :: IO Bool,,
201                  AC_MSG_ERROR(Cannot find System.Directory; try installing the Haskell package directory?))
202 GHC_CHECK_MODULE(System.Time, old-time, getClockTime :: IO ClockTime,,
203                  AC_MSG_ERROR(Cannot find System.Time; try installing the Haskell package old-time?))
204 GHC_CHECK_MODULE(System.Process, process, runCommand "foo" :: IO ProcessHandle,,
205                  AC_MSG_ERROR(Cannot find System.Process; try installing the Haskell package process?))
206 dnl note that [[Int]] is for [Int] in Haskell
207 GHC_CHECK_MODULE(Data.Array.Unboxed, array, listArray (0,0) :: [[Int]] -> UArray Int Int,,
208                  AC_MSG_ERROR(Cannot find Data.Array.Unboxed; try installing the Haskell package array?))
209 dnl for make_changelog only
210 GHC_CHECK_MODULE(System.Locale, old-locale, rfc822DateFormat :: String,,
211                  AC_MSG_ERROR(Cannot find System.Locale; try installing the Haskell package old-locale?))
213 dnl See if we need the util or mtl packages for Control.Monad
215 GHC_CHECK_MODULE(Control.Monad.Error, mtl, strMsg "foo" :: String,,
216                  AC_MSG_ERROR(Cannot find Control.Monad.Error; try installing the Haskell package mtl?))
218 dnl See if we need a package for parsec...
220 GHC_CHECK_MODULE(Text.ParserCombinators.Parsec, parsec, errorPos undefined,,
221                  AC_MSG_ERROR(Cannot find Text.ParserCombinators.Parsec; try installing the Haskell package parsec?))
223 dnl Check if we need package html
225 GHC_CHECK_MODULE(Text.Html, html, text "foo",,
226                  AC_MSG_ERROR(Cannot find Text.Html; try installing the Haskell package html?))
228 dnl Check if we need package containers
230 GHC_CHECK_MODULE(Data.Map, containers, empty,,
231                  AC_MSG_ERROR(Cannot find Data.Map; try installing the Haskell package containers?))
233 dnl On windows see if we need a package for random
235 if test "$SYS" = "windows"; then
236   GHC_CHECK_MODULE(System.Random( randomIO ), random, randomIO :: IO Int,,
237                    AC_MSG_ERROR(Cannot find System.Random; try installing the Haskell package random?))
238 else
239   dnl if we're not in windows, we need System.Posix.Files
240   GHC_CHECK_MODULE(System.Posix.Files, unix, undefined,,
241                    AC_MSG_ERROR(Cannot find System.Posix.Files; try installing the Haskell package unix?))
242   dnl Check if we have System.Posix.Signals
243   GHC_CHECK_MODULE(System.Posix.Signals, unix, installHandler,
244                    AC_DEFINE(HAVE_SIGNALS),AC_MSG_WARN(Cannot find System.Posix.Signals; interrupt handling disabled))
247 dnl Make default to have optimizations on...
249 AC_MSG_CHECKING([whether to optimize])
250 AC_ARG_ENABLE(optimize,
251               AS_HELP_STRING([--disable-optimize],[disable optimization]),
252               optimize=$enableval, optimize=yes)
253 AC_MSG_RESULT($optimize)
255 if test "$optimize" = yes; then
256   GHCFLAGS="$GHCFLAGS -O2 -funbox-strict-fields"
257   if test "$CFLAGS" = ""; then
258     CFLAGS="$CFLAGS -O2"
259   fi
262 dnl Make default to not use hpc
264 AC_MSG_CHECKING([whether to use Haskell Program Coverage])
265 AC_ARG_ENABLE(hpc,
266               AS_HELP_STRING([--enable-hpc],[enable Haskell Program Coverage]),
267               hpc=$enableval,hpc=no)
268 AC_MSG_RESULT($hpc)
270 if test "$hpc" = yes; then
271   GHCFLAGS="$GHCFLAGS -fhpc"
274 dnl See if we want to use mmap... defaults to yes, except under
275 dnl Windows, where this is always disabled.
277 AC_MSG_CHECKING([whether to use mmap])
278 AC_ARG_ENABLE(mmap, AS_HELP_STRING([--disable-mmap],
279               [do not use mmap (use this flag if you get bus errors)]),
280               enable_mmap=$enableval,enable_mmap=yes)
281 if test "$SYS" = "windows"; then
282   AC_MSG_RESULT(no (Windows))
283 else
284   AC_MSG_RESULT($enable_mmap)
286 USE_MMAP="True"
287 if test "$enable_mmap" = "no" || test "$SYS" = "windows" ; then
288   USE_MMAP="False"
290 AC_SUBST(USE_MMAP)
292 TARGETS="darcs doc/darcs.1"
293 INSTALLWHAT="installbin"
294 BUILDDOC="no"
296 dnl Check whether to generate the AUTHORS file...
297 if test -d "_darcs"; then
298   TARGETS="$TARGETS AUTHORS"
301 dnl Check whether to use crazy PackedString debugging...
303 AC_MSG_CHECKING([whether to do PackedString debugging])
304 AC_ARG_ENABLE(debug-ps,
305               [  --enable-debug-ps       enable PackedString debug mode],
306                debugps=$enableval, debugps=no)
307 AC_MSG_RESULT($debugps)
310 if test "$debugps" = yes; then
311   GHCFLAGS="$GHCFLAGS -DDEBUG_PS"
314 dnl Find latex and friends
316 AC_MSG_CHECKING([whether to build manual])
317 AC_ARG_WITH(manual,
318         AS_HELP_STRING([--without-manual],
319                            [do not try to build manual]),
320            ,with_manual=yes)
321 AC_MSG_RESULT($with_manual)
323 if test "$with_manual" = "yes"; then
324   AC_CHECK_PROG(LATEX, latex, latex)
325   if test -z "$LATEX"; then
326     AC_MSG_WARN([Cannot find latex in your path!])
327   fi
328   AC_CHECK_PROG(PDFLATEX, pdflatex, pdflatex)
329   if test -z "$PDFLATEX"; then
330     AC_MSG_WARN([Cannot find pdflatex in your path!])
331   fi
332   AC_CHECK_PROG(DVIPS, dvips, dvips)
333   if test -z "$DVIPS"; then
334   AC_MSG_WARN([Cannot find dvips in your path!])
335   fi
336   if test ! '(' '(' -z "$LATEX" ')' -o '(' -z "$DVIPS" ')' ')'; then
337     TARGETS="$TARGETS doc/manual/darcs.ps"
338     INSTALLWHAT="$INSTALLWHAT installdocs"
339     BUILDDOC="yes"
340   fi
341   if test ! '(' -z "$PDFLATEX" ')'; then
342     TARGETS="$TARGETS doc/manual/darcs.pdf doc/manual/patch-theory.pdf"
343   fi
344   AC_CHECK_PROG(LATEX2HTML, latex2html, latex2html)
345   if test -z "$LATEX2HTML"; then
346     AC_MSG_WARN([Cannot find latex2html in your path!])
347     PREPROCHTML=""
348     AC_CHECK_PROG(HTLATEX, htlatex, htlatex)
349     if test -z "$HTLATEX"; then
350       AC_MSG_WARN([Cannot find htlatex in your path either!])
351       AC_CHECK_PROG(HEVEA, hevea, hevea)
352       if test -z "$HEVEA"; then
353         AC_MSG_WARN([Cannot find hevea in your path either!])
354         MAKEMANUAL="touch doc/manual/index.html; echo Cannot make manual!"
355       else
356         TARGETS="$TARGETS doc/manual/index.html"
357         MAKEMANUAL="$HEVEA -o doc/manual/index.html src/darcs.tex"
358       fi
359     else
360       TARGETS="$TARGETS doc/manual/index.html"
361       MAKEMANUAL="cd doc/manual && $HTLATEX ../../src/darcs.tex && ln -sf darcs.html index.html"
362     fi
363   else
364     TARGETS="$TARGETS doc/manual/index.html"
365     MAKEMANUAL="$LATEX2HTML -split +1 -dir doc/manual src/darcs.tex"
366     dnl the following tells "preproc" to generate "rawhtml" sections for latex2html.
367     PREPROCHTML="--html"
368   fi
369 else
370   BUILDDOC="no"
373 AC_SUBST(TARGETS)
374 AC_SUBST(MAKEMANUAL)
375 AC_SUBST(INSTALLWHAT)
376 AC_SUBST(PREPROCHTML)
378 dnl Look for sendmail...
380 AC_ARG_WITH(sendmail, [  --with-sendmail=PATHTOSENDMAIL],
381             [ SENDMAIL=$with_sendmail
382               HAVE_SENDMAIL="True" ],
383             [ STUPID_PATH=/usr/sbin:/usr/lib
384               AC_PATH_PROG(SENDMAIL, sendmail, "", $PATH:$STUPID_PATH)
385               if test -z "$SENDMAIL"; then
386                 SENDMAIL=""
387                 HAVE_SENDMAIL="False"
388               else
389                 HAVE_SENDMAIL="True"
390               fi ])
391 AC_SUBST(SENDMAIL)
392 AC_SUBST(HAVE_SENDMAIL)
394 dnl Look for MAPISendMail
396 AC_CHECK_LIB(mapi32, MAPISendMail, HAVE_MAPI="True", HAVE_MAPI="False")
397 AC_SUBST(HAVE_MAPI)
399 if test "$HAVE_SENDMAIL" = "False" -a "$HAVE_MAPI" = "False"; then
400   AC_MSG_WARN([Can't find sendmail or mapi so you won't be able to push by email!])
403 dnl Allow use of color in output to be disabled
405 AC_ARG_ENABLE(color, AS_HELP_STRING([--disable-color],[do not use ansi color escapes]))
407 dnl export color flag
408 USE_COLOR="True"
409 if test "$enable_color" = "no"; then
410   USE_COLOR="False"
412 AC_SUBST(USE_COLOR)
414 dnl Try to link with static versions of libraries.
416 AC_ARG_WITH(static-libs, [  --with-static-libs      link with static versions of libraries])
417 if test "x$with_static_libs" = "xyes"; then
418   LDFLAGS="-static $LDFLAGS"
421 dnl Check whether to use existential type witnesses
423 AC_MSG_CHECKING([for gadt type witnesses])
424 AC_ARG_WITH(type-witnesses,
425             AS_HELP_STRING([--with-type-witnesses],
426                            [use GADT type witnesses (EXPERIMENTAL!)])
427             ,with_typew=$withval
428             ,with_typew=no)
430 if test "$with_typew" = "yes"; then
431   GHCFLAGS="$GHCFLAGS -fglasgow-exts"
432   AC_DEFINE([GADT_WITNESSES])
433   AC_MSG_RESULT([yes])
434 else
435   AC_MSG_RESULT([no])
438 dnl look for zlib library and header.
439 dnl Use GHC_CHECK_LIBRARY and not AC_CHECK_HEADER / AC_CHECK_LIB because GHC may
440 dnl use a different library and header than the system GCC (on Windows, issue 813)
442 GHC_CHECK_LIBRARY([z],[zlib.h deflate],[Int -> Int -> Int],
443                   [czlibfound=yes], [czlibfound=no])
445 if test $czlibfound = "yes"; then
446   AC_MSG_CHECKING([whether to use the C zlib])
447   AC_ARG_ENABLE(c-zlib,
448                 AS_HELP_STRING([--disable-c-zlib], [do not use the C zlib, even if it is present]),
449                 czlib=$enableval,
450                 czlib=yes)
451   AC_MSG_RESULT($czlib)
454 if test "$czlib" != "yes"; then
455   dnl See if we have an adequate version of the haskell zlib
456   GHC_CHECK_MODULE(Codec.Compression.GZip( decompress ),
457                    zlib,
458                    decompress undefined,
459                    [haskellzlibfound=yes],
460                    [haskellzlibfound=no])
462   if test $bytestring = "yes" -a $haskellzlibfound = "yes"; then
463     AC_MSG_CHECKING([whether to use the Haskell zlib])
464     AC_ARG_ENABLE(haskell-zlib,
465                   AS_HELP_STRING([--disable-haskell-zlib], [do not use the Haskell zlib, even if it is present (note that currently the interface is somewhat inefficient at reading large files, so you should be cautious of using the Haskell zlib)]),
466                   haskellzlib=$enableval,
467                   haskellzlib=yes)
468     AC_MSG_RESULT($haskellzlib)
469   fi
471   if test "$haskellzlib" = "yes"; then
472     CPPFLAGS="$CPPFLAGS -DHAVE_HASKELL_ZLIB"
473   else
474     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.4.0.4, and don't disable bytestring!)])
475   fi
478 dnl Find libwww and other libraries needed by hswww.c
480 AC_ARG_WITH(libwww,
481             AS_HELP_STRING([--with-libwww],[use libwww]))
483 if test "$with_libwww" == "yes"; then
484   AC_MSG_CHECKING([for libwww])
485   if eval libwww-config --version 2>/dev/null >/dev/null; then
486     CPPFLAGS="$CPPFLAGS -DHAVE_LIBWWW"
487     WWWVERSION=`libwww-config --version`
488     LIBS="$LIBS `libwww-config --libs`"
489     CFLAGS="$CFLAGS `libwww-config --cflags`"
490     have_libwww=yes
491     AC_MSG_RESULT($WWWVERSION)
492   else
493     AC_MSG_RESULT(FAILED)
494     AC_MSG_WARN([libwww-config was not found])
495   fi
498 dnl Find libcurl and other libraries needed by hscurl.c
500 AC_ARG_WITH(libcurl,
501             AS_HELP_STRING([--without-libcurl],[do not use libcurl]))
503 AC_ARG_WITH(curl, AS_HELP_STRING([--with-curl=<DIR>],[use curl installed in directory <DIR>]))
505 CURLLIBS=
506 CURL_CONFIG="curl-config"
508 if test "$with_libcurl" != "no" -a "$have_libwww" != "yes"; then
509   if test "$with_curl" != ""; then
510     CURL_CONFIG="$with_curl/bin/curl-config"
511   fi
513   AC_MSG_CHECKING([for libcurl])
514   if eval $CURL_CONFIG --version 2>/dev/null >/dev/null; then
515     ver=`$CURL_CONFIG --version | sed -e "s/libcurl //g"`
516     opt="--libs"
517     CURLCFLAGS=`$CURL_CONFIG --cflags`
518     if test "x$with_static_libs" = "xyes"; then
519       CURLCFLAGS="$CURLFLAGS -DCURL_STATICLIB"
520       opt="--static-libs"
521     fi
522     CURLLIBS=`$CURL_CONFIG $opt | sed "s_-arch @<:@^ @:>@@<:@^ @:>@*__"`
523     AC_MSG_RESULT($ver)
524   else
525     AC_MSG_RESULT(FAILED)
526     AC_MSG_WARN([curl-config was not found])
527   fi
530 if test "$CURLLIBS" != ""; then
531   # we enable curl
532   CPPFLAGS="$CPPFLAGS -DHAVE_CURL"
534   CFLAGS="$CFLAGS $CURLCFLAGS"
535   LIBS="$LIBS $CURLLIBS"
536   old_LIBS="$LIBS"
537   AC_CHECK_LIB(curl, curl_global_init,
538                [],
539                AC_MSG_ERROR(Cannot actually use libcurl; try specifying --without-libcurl.))
540   AC_CHECK_LIB(curl, curl_multi_timeout,
541                CPPFLAGS="$CPPFLAGS -DCURL_MULTI_TIMEOUT")
542   LIBS="$old_LIBS"
544   # enable pipelining for curl >= 7.18.0
545   AC_MSG_CHECKING([for libcurl pipelining])
546   let vernum=0x0`$CURL_CONFIG --vernum`
547   let minver=0x071200 # 7.18.0
548   if test $vernum -ge $minver; then
549     CPPFLAGS="$CPPFLAGS -DCURL_PIPELINING"
550     AC_MSG_RESULT([yes])
551     # enable pipelining by default for curl >= 7.19.1
552     let minver=0x071301 # 7.19.1
553     if test $vernum -ge $minver; then
554       CPPFLAGS="$CPPFLAGS -DCURL_PIPELINING_DEFAULT"
555     fi
556   else
557     AC_MSG_RESULT([no])
558     AC_MSG_WARN([Requires libcurl version >= 7.18.0])
559   fi
562 dnl Check for libcurses/terminfo...
564 AC_ARG_ENABLE(libcurses, [  --without-curses        do not use libcurses])
565 AC_ARG_ENABLE(terminfo, [  --without-terminfo        do not use Haskell terminfo])
567 HAVE_CURSES=False
568 HAVE_TERMINFO=False
569 if test "$with_libcurses" != "no"; then
570   # term.h is documented to require curses.h and actually needs it on
571   # Solaris, for instance, though not on GNU/Linux.
572   AC_CHECK_HEADER(term.h,
573       [AC_SEARCH_LIBS(tgetent, [curses ncurses], [HAVE_CURSES=True])], ,
574       [#include <curses.h>
575       ])
578 if test "$HAVE_CURSES" != "True"; then
579   if test "$with_terminfo" != "no"; then
580     GHC_CHECK_MODULE(System.Console.Terminfo ( setupTermFromEnv ),
581                      terminfo,
582                      setupTermFromEnv,
583                      [HAVE_TERMINFO=True],)
584   fi
586   if test "$HAVE_TERMINFO" != "True"; then
587     AC_MSG_WARN([Cannot find libcurses or Haskell terminfo, disabling color.])
588   else
589     CPPFLAGS="$CPPFLAGS -DHAVE_TERMINFO"
590   fi
591 else
592   # The precondition for this is: we both have curses available and not disabled
593   CPPFLAGS="$CPPFLAGS -DHAVE_CURSES"
595 AC_SUBST(HAVE_CURSES)
597 dnl Look for a suitable diff command
599 AC_CHECK_PROGS(DIFF, [gdiff gnudiff diff])
601 dnl Look for NullSoft Installer System
603 AC_PATH_PROGS(MAKENSIS, [makensis.exe])
605 dnl Check endianness
607 AC_C_BIGENDIAN([BIGENDIAN="True"],[BIGENDIAN="False"])
608 AC_SUBST(BIGENDIAN)
610 dnl Check for a haddock 2.0.0 or more recent
612 AC_CHECK_PROG(HADDOCK, haddock, haddock)
613 AC_MSG_CHECKING([haddock version])
614 if test "$HADDOCK" = ""; then
615   HADDOCK_VERSION=0
616 else
617   HADDOCK_VERSION=`haddock --version | head -n 1 | sed 's/^.* \(@<:@0-9@:>@@<:@0-9@:>@*\)\..*/\1/g'`
619 AC_SUBST(HADDOCK_VERSION)
620 AC_MSG_RESULT(version $HADDOCK_VERSION)
621 if test "$HADDOCK_VERSION" -lt 2; then
622   AC_MSG_WARN([You need haddock 2.0.0 or later to build API docs])
625 dnl Write results
627 dnl Remove these two tests when autoconf >2.59 can be required.
628 if test -z "${datarootdir}"; then
629   datarootdir=${datarootdir:-'${prefix}/share'}
630   AC_SUBST(datarootdir)
632 if test -z "${docdir}"; then
633   docdir=${docdir:-'${datarootdir}/doc/${PACKAGE_TARNAME}'}
634   AC_SUBST(docdir)
637 AC_DEFUN([AC_DATAROOTDIR_CHECKED])
639 AC_CONFIG_FILES([autoconf.mk src/Autoconf.lhs
640            tools/cgi/darcs.cgi tools/cgi/README tools/cgi/cgi.conf
641            release/darcs.spec])
642 AC_OUTPUT
644 cat <<[EOF]
646 The build is configured as follows:
648     bindir          = $bindir
649     sbindir         = $sbindir
650     mandir          = $mandir
651     datadir         = $datadir
652     sysconfdir      = $sysconfdir
653     libexecdir      = $libexecdir
655     Build Manual    = $BUILDDOC
657 If you want to adjust any of these values, edit autoconf.mk and
658 src/Autoconf.lhs -- or run configure with appropriate settings.
660 [EOF]
662 dnl Responsibility shifts to the user after this point.