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:
7 AC_INIT([darcs], [2.0.1rc1], [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.
14 AC_CONFIG_COMMANDS([config.command],
15 [ echo > config.command "# configured $date"
16 echo >>config.command "./configure $args"
17 chmod +x config.command
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 )".
26 dnl The version string must not contain any spaces. The version
27 dnl state will automatically be set to any of:
30 dnl "release candidate #n"
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
42 dnl See if we are in a darcs repo and also have darcs available,
43 dnl in which case we can try to figure out the release state:
45 AC_CHECK_PROG(DARCS, darcs, darcs)
46 AC_MSG_CHECKING([the release state])
47 if test ! -z "$DARCS" && test -e "_darcs/hashed_inventory"; then
48 DARCS_VERSION_STATE=`perl release/determine_release_state.pl $DARCS_VERSION`;
52 if test -f "release/STATE"; then
53 DARCS_VERSION_STATE=`head -n 1 release/STATE`
55 DARCS_VERSION_STATE="unknown"
58 AC_MSG_RESULT($DARCS_VERSION_STATE)
60 AC_SUBST(DARCS_VERSION)
61 AC_SUBST(DARCS_VERSION_STATE)
62 AC_SUBST(I_AM_IN_REPO)
64 dnl Get rid of the lousy '-g -O2' defaults
73 dnl Make sure a decent "install" is installed.
77 dnl Check to see if we are compiling under Windows
79 AC_CHECK_HEADER(windows.h, [SYS=windows], [SYS=other])
84 AC_CHECK_PROG(GHC, ghc, ghc)
85 if test -z "$GHC"; then
86 AC_MSG_ERROR([Cannot find ghc in your path; please set the GHC environment variable!!])
89 echo found `$GHC --version`
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])])
126 dnl Figure out how to convert a file descriptor to a Handle
130 dnl Handle posix signals nicely:
132 WORKAROUND_POSIXSIGNALS([installHandler, raiseSignal, Handler(..), Signal,
133 sigINT, sigHUP, sigABRT, sigALRM, sigTERM, sigPIPE,])
135 AC_CHECK_HEADERS([siginfo.h])
137 dnl Look for Text.Regex
139 GHC_CHECK_MODULE(Text.Regex( mkRegex, matchRegex, Regex ), text, mkRegex undefined,,
140 GHC_CHECK_MODULE(Text.Regex( mkRegex, matchRegex, Regex ), regex-compat, mkRegex undefined,,
141 AC_MSG_ERROR(Cannot find Test.Regex; try installing the package text or regex-compat?)
145 dnl Look for native http library
147 GHC_CHECK_MODULE(Network.HTTP( urlEncode ), HTTP, urlEncode undefined,
149 AC_DEFINE([HAVE_HTTP])],[HAVE_HTTP=False])
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 package quickcheck?))
158 dnl See if we have an adequate version of bytestring
159 GHC_CHECK_MODULE(Data.ByteString.Internal( 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,
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"
177 dnl See if we need the util or mtl packages for Control.Monad
179 GHC_CHECK_MODULE(Control.Monad.Error, mtl, strMsg "foo" :: String,,
180 AC_MSG_ERROR(Cannot find Control.Monad.Error; try installing package mtl?))
182 dnl See if we need a package for parsec...
184 GHC_CHECK_MODULE(Text.ParserCombinators.Parsec, parsec, errorPos undefined,,
185 AC_MSG_ERROR(Cannot find Text.ParserCombinators.Parsec; try installing package parsec?))
187 dnl Check if we need package html
189 GHC_CHECK_MODULE(Text.Html, html, text "foo",,
190 AC_MSG_ERROR(Cannot find Text.Html; try installing package html?))
192 dnl Check if we need package containers
194 GHC_CHECK_MODULE(Data.Map, containers, empty,,
195 AC_MSG_ERROR(Cannot find Data.Map; try installing package containers?))
197 dnl Deal with systems on which getCurrentDirectory uses '\\' rather than '/':
199 WORKAROUND_getCurrentDirectory
200 AC_SUBST(GHC_SEPARATOR)
202 dnl Deal with systems without createLink
204 WORKAROUND_createLink
206 dnl Deal with GHCs without createDirectoryIfMissing
208 WORKAROUND_createDirectoryIfMissing
210 dnl Handle systems with a buggy renameFile
212 WORKAROUND_renameFile
214 dnl Deal with systems without bracketWithError
216 WORKAROUND_bracketOnError
218 dnl Handle systems that don't do POSIX file modes
222 WORKAROUND_executable
224 dnl Make default to have optimizations on...
226 AC_MSG_CHECKING([whether to optimize])
227 AC_ARG_ENABLE(optimize,
228 AS_HELP_STRING([--disable-optimize],[disable optimization]),
229 optimize=$enableval, optimize=yes)
230 AC_MSG_RESULT($optimize)
232 if test "$optimize" = yes; then
233 GHCFLAGS="$GHCFLAGS -O2 -funbox-strict-fields"
234 if test "$CFLAGS" = ""; then
239 dnl Make default to not use hpc
241 AC_MSG_CHECKING([whether to use Haskell Program Coverage])
243 AS_HELP_STRING([--enable-hpc],[enable Haskell Program Coverage]),
244 hpc=$enableval,hpc=no)
247 if test "$hpc" = yes; then
248 GHCFLAGS="$GHCFLAGS -fhpc"
251 dnl See if we want to use mmap... defaults to yes, except under
252 dnl Windows, where this is always disabled.
254 AC_MSG_CHECKING([whether to use mmap])
255 AC_ARG_ENABLE(mmap, AS_HELP_STRING([--disable-mmap],
256 [do not use mmap (use this flag if you get bus errors)]),
257 enable_mmap=$enableval,enable_mmap=yes)
258 if test "$SYS" = "windows"; then
259 AC_MSG_RESULT(no (Windows))
261 AC_MSG_RESULT($enable_mmap)
264 if test "$enable_mmap" = "no" || test "$SYS" = "windows" ; then
269 TARGETS="darcs doc/darcs.1"
270 INSTALLWHAT="installbin"
273 dnl Check whether to generate the AUTHORS and ChangeLog files...
274 if test -d "_darcs"; then
275 TARGETS="$TARGETS AUTHORS ChangeLog"
278 dnl Check whether to use crazy PackedString debugging...
280 AC_MSG_CHECKING([whether to do PackedString debugging])
281 AC_ARG_ENABLE(debug-ps,
282 [ --enable-debug-ps enable PackedString debug mode],
283 debugps=$enableval, debugps=no)
284 AC_MSG_RESULT($debugps)
287 if test "$debugps" = yes; then
288 GHCFLAGS="$GHCFLAGS -DDEBUG_PS"
291 dnl Find latex and friends
293 AC_MSG_CHECKING([whether to build docs])
295 AS_HELP_STRING([--without-docs],
296 [do not try to build docs]),
298 AC_MSG_RESULT($with_docs)
300 if test "$with_docs" = "yes"; then
301 AC_CHECK_PROG(LATEX, latex, latex)
302 if test -z "$LATEX"; then
303 AC_MSG_WARN([Cannot find latex in your path!])
305 AC_CHECK_PROG(PDFLATEX, pdflatex, pdflatex)
306 if test -z "$PDFLATEX"; then
307 AC_MSG_WARN([Cannot find pdflatex in your path!])
309 AC_CHECK_PROG(DVIPS, dvips, dvips)
310 if test -z "$DVIPS"; then
311 AC_MSG_WARN([Cannot find dvips in your path!])
313 if test ! '(' '(' -z "$LATEX" ')' -o '(' -z "$DVIPS" ')' ')'; then
314 TARGETS="$TARGETS doc/manual/darcs.ps"
315 INSTALLWHAT="$INSTALLWHAT installdocs"
318 if test ! '(' -z "$PDFLATEX" ')'; then
319 TARGETS="$TARGETS doc/manual/darcs.pdf doc/manual/patch-theory.pdf"
321 AC_CHECK_PROG(LATEX2HTML, latex2html, latex2html)
322 if test -z "$LATEX2HTML"; then
323 AC_MSG_WARN([Cannot find latex2html in your path!])
325 AC_CHECK_PROG(HTLATEX, htlatex, htlatex)
326 if test -z "$HTLATEX"; then
327 AC_MSG_WARN([Cannot find htlatex in your path either!])
328 AC_CHECK_PROG(HEVEA, hevea, hevea)
329 if test -z "$HEVEA"; then
330 AC_MSG_WARN([Cannot find hevea in your path either!])
331 MAKEMANUAL="touch doc/manual/index.html; echo Cannot make manual!"
333 TARGETS="$TARGETS doc/manual/index.html"
334 MAKEMANUAL="$HEVEA -o doc/manual/index.html src/darcs.tex"
337 TARGETS="$TARGETS doc/manual/index.html"
338 MAKEMANUAL="cd doc/manual && $HTLATEX ../../src/darcs.tex && ln -sf darcs.html index.html"
341 TARGETS="$TARGETS doc/manual/index.html"
342 MAKEMANUAL="$LATEX2HTML -split +1 -dir doc/manual src/darcs.tex"
343 dnl the following tells "preproc" to generate "rawhtml" sections for latex2html.
352 AC_SUBST(INSTALLWHAT)
353 AC_SUBST(PREPROCHTML)
355 dnl Look for sendmail...
357 AC_ARG_WITH(sendmail, [ --with-sendmail=PATHTOSENDMAIL],
359 SENDMAIL=$with_sendmail
362 STUPID_PATH=/usr/sbin:/usr/lib
363 AC_PATH_PROG(SENDMAIL, sendmail, "", $PATH:$STUPID_PATH)
364 if test -z "$SENDMAIL"; then
366 HAVE_SENDMAIL="False"
372 AC_SUBST(HAVE_SENDMAIL)
374 dnl Look for MAPISendMail
376 AC_CHECK_LIB(mapi32, MAPISendMail, HAVE_MAPI="True", HAVE_MAPI="False")
379 if test "$HAVE_SENDMAIL" = "False" -a "$HAVE_MAPI" = "False"; then
380 AC_MSG_WARN([Can't find sendmail or mapi so you won't be able to push by email!])
383 dnl Allow use of color in output to be disabled
385 AC_ARG_ENABLE(color, AS_HELP_STRING([--disable-color],[do not use ansi color escapes]))
387 dnl export color flag
389 if test "$enable_color" = "no"; then
394 dnl Try to link with static versions of libraries.
396 AC_ARG_WITH(static-libs, [ --with-static-libs link with static versions of libraries])
397 if test "x$with_static_libs" = "xyes"; then
398 LDFLAGS="-static $LDFLAGS"
401 dnl Check whether to use existential type witnesses
403 AC_MSG_CHECKING([for gadt type witnesses])
404 AC_ARG_WITH(type-witnesses,
405 AS_HELP_STRING([--with-type-witnesses],
406 [use GADT type witnesses (EXPERIMENTAL!)])
410 if test "$with_typew" = "yes"; then
411 GHCFLAGS="$GHCFLAGS -fglasgow-exts"
412 AC_DEFINE([GADT_WITNESSES])
418 dnl look for zlib library and header.
419 dnl Use GHC_CHECK_LIBRARY and not AC_CHECK_HEADER / AC_CHECK_LIB because GHC may
420 dnl use a different library and header than the system GCC (on Windows, issue 813)
422 GHC_CHECK_LIBRARY([z],[zlib.h deflate],[Int -> Int -> Int],[],
423 [AC_MSG_ERROR(Cannot find system's zlib library; please set the LDFLAGS environment variable!)])
425 dnl Find libcurl and other libraries needed by hscurl.c
428 AS_HELP_STRING([--without-libcurl],[do not use libcurl]))
430 AC_ARG_WITH(curl, AS_HELP_STRING([--with-curl=<DIR>],[use curl installed in directory <DIR>]))
433 CURL_CONFIG="curl-config"
435 if test "$with_libcurl" != "no"; then
436 if test "$with_curl" != ""; then
437 CURL_CONFIG="$with_curl/bin/curl-config"
440 AC_MSG_CHECKING([for libcurl])
441 if eval $CURL_CONFIG --version 2>/dev/null >/dev/null; then
442 ver=`$CURL_CONFIG --version | sed -e "s/libcurl //g"`
444 CURLCFLAGS=`$CURL_CONFIG --cflags`
445 if test "x$with_static_libs" = "xyes"; then
446 CURLCFLAGS="$CURLFLAGS -DCURL_STATICLIB"
449 CURLLIBS=`$CURL_CONFIG $opt | sed "s_-arch @<:@^ @:>@@<:@^ @:>@*__"`
452 AC_MSG_RESULT(FAILED)
453 AC_MSG_WARN([curl-config was not found])
457 if test "$CURLLIBS" != ""; then
459 CPPFLAGS="$CPPFLAGS -DHAVE_CURL"
461 CFLAGS="$CFLAGS $CURLCFLAGS"
462 LIBS="$LIBS $CURLLIBS"
464 AC_CHECK_LIB(curl, curl_global_init,
466 AC_MSG_ERROR(Cannot actually use libcurl; try specifying --without-libcurl.))
467 AC_CHECK_LIB(curl, curl_multi_timeout,
468 CPPFLAGS="$CPPFLAGS -DCURL_MULTI_TIMEOUT")
471 # Check if we want pipelining enabled...
472 AC_ARG_WITH(curl_pipelining,
473 AS_HELP_STRING([--with-curl-pipelining],[use curl pipelining (requires libcurl >= 7.18.0)]))
475 if test "$with_curl_pipelining" == "yes"; then
476 AC_MSG_CHECKING([for libcurl pipelining])
477 let vernum=0x0`$CURL_CONFIG --vernum`
479 if test $vernum -ge $minver; then
480 CPPFLAGS="$CPPFLAGS -DCURL_PIPELINING"
485 AC_MSG_WARN([Requires libcurl version >= 7.18.0])
490 dnl Find libwww and other libraries needed by hswww.c
493 AS_HELP_STRING([--with-libwww],[use libwww]))
495 if test "$with_libwww" == "yes"; then
496 AC_MSG_CHECKING([for libwww])
497 if eval libwww-config --version 2>/dev/null >/dev/null; then
498 CPPFLAGS="$CPPFLAGS -DHAVE_LIBWWW"
499 WWWVERSION=`libwww-config --version`
500 LIBS="$LIBS `libwww-config --libs`"
501 CFLAGS="$CFLAGS `libwww-config --cflags`"
502 AC_MSG_RESULT($WWWVERSION)
504 AC_MSG_RESULT(FAILED)
505 AC_MSG_WARN([libwww-config was not found])
509 dnl Check for libcurses...
511 AC_ARG_ENABLE(libcurses, [ --without-curses do not use libcurses])
514 if test "$with_libcurses" != "no"; then
515 # term.h is documented to require curses.h and actually needs it on
516 # Solaris, for instance, though not on GNU/Linux.
517 AC_CHECK_HEADER(term.h,
518 [AC_SEARCH_LIBS(tgetent, [curses ncurses], [HAVE_CURSES=True])], ,
521 if test "$HAVE_CURSES" != "True"; then
522 AC_MSG_WARN([Cannot find term.h, disabling color.])
524 # The precondition for this is: we both have curses available and not disabled
525 CPPFLAGS="$CPPFLAGS -DHAVE_CURSES"
528 AC_SUBST(HAVE_CURSES)
530 dnl Look for a suitable diff command
532 AC_CHECK_PROGS(DIFF, [gdiff gnudiff diff])
534 dnl Look for NullSoft Installer System
536 AC_PATH_PROGS(MAKENSIS, [makensis.exe])
540 AC_C_BIGENDIAN([BIGENDIAN="True"],[BIGENDIAN="False"])
543 dnl Check for a haddock 2.0.0 or more recent
545 AC_CHECK_PROG(HADDOCK, haddock, haddock)
546 AC_MSG_CHECKING([haddock version])
547 if test "$HADDOCK" = ""; then
550 HADDOCK_VERSION=`haddock --version | head -n 1 | sed 's/^.* \(@<:@0-9@:>@@<:@0-9@:>@*\)\..*/\1/g'`
552 AC_SUBST(HADDOCK_VERSION)
553 AC_MSG_RESULT(version $HADDOCK_VERSION)
554 if test "$HADDOCK_VERSION" -lt 2; then
555 AC_MSG_WARN([You need haddock 2.0.0 or later to build API docs])
560 dnl Remove these two tests when autoconf >2.59 can be required.
561 if test -z "${datarootdir}"; then
562 datarootdir=${datarootdir:-'${prefix}/share'}
563 AC_SUBST(datarootdir)
565 if test -z "${docdir}"; then
566 docdir=${docdir:-'${datarootdir}/doc/${PACKAGE_TARNAME}'}
570 AC_DEFUN([AC_DATAROOTDIR_CHECKED])
572 AC_CONFIG_FILES([autoconf.mk src/Autoconf.lhs src/ThisVersion.lhs
573 tools/cgi/darcs.cgi tools/cgi/README tools/cgi/cgi.conf])
578 The build is configured as follows:
584 sysconfdir = $sysconfdir
585 libexecdir = $libexecdir
587 Build Manual = $BUILDDOC
589 If you want to adjust any of these values, edit autoconf.mk and
590 src/Autoconf.lhs -- or run configure with appropriate settings.
594 dnl Responsibility shifts to the user after this point.