autoconf: remove few redundant semicolons
[git/jrn.git] / configure.ac
blobb453ba5eb9d299d9539343703c0b021f0b9150f2
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 ## Definitions of private macros.
6 # GIT_CONF_SUBST(VAL, VAR)
7 # ------------------------
8 # Append the line "VAR=VAL" to file ${config_append}
9 AC_DEFUN([GIT_CONF_APPEND_LINE],
10          [echo "$1=$2" >> "${config_append}"])
12 # GIT_ARG_SET_PATH(PROGRAM)
13 # -------------------------
14 # Provide --with-PROGRAM=PATH option to set PATH to PROGRAM
15 # Optional second argument allows setting NO_PROGRAM=YesPlease if
16 # --without-PROGRAM version used.
17 AC_DEFUN([GIT_ARG_SET_PATH],
18     [AC_ARG_WITH([$1],
19         [AS_HELP_STRING([--with-$1=PATH],
20                         [provide PATH to $1])],
21         [GIT_CONF_APPEND_PATH([$1], [$2])],
22         [])])
24 # GIT_CONF_APPEND_PATH(PROGRAM)
25 # -----------------------------
26 # Parse --with-PROGRAM=PATH option to set PROGRAM_PATH=PATH
27 # Used by GIT_ARG_SET_PATH(PROGRAM)
28 # Optional second argument allows setting NO_PROGRAM=YesPlease if
29 # --without-PROGRAM is used.
30 AC_DEFUN([GIT_CONF_APPEND_PATH],
31     [m4_pushdef([GIT_UC_PROGRAM], m4_toupper([$1]))dnl
32     if test "$withval" = "no"; then
33         if test -n "$2"; then
34                 GIT_UC_PROGRAM[]_PATH=$withval
35                 AC_MSG_NOTICE([Disabling use of GIT_UC_PROGRAM])
36                 GIT_CONF_SUBST([NO_]GIT_UC_PROGRAM, [YesPlease])
37                 GIT_CONF_SUBST(GIT_UC_PROGRAM[]_PATH, [])
38         else
39                 AC_MSG_ERROR([You cannot use git without $1])
40         fi
41     else
42         if test "$withval" = "yes"; then
43                 AC_MSG_WARN([You should provide path for --with-$1=PATH])
44         else
45                 GIT_UC_PROGRAM[]_PATH=$withval
46                 AC_MSG_NOTICE([Setting GIT_UC_PROGRAM[]_PATH to $withval])
47                 GIT_CONF_SUBST(GIT_UC_PROGRAM[]_PATH, [$withval])
48         fi
49     fi
50     m4_popdef([GIT_UC_PROGRAM])])
52 # GIT_PARSE_WITH(PACKAGE)
53 # -----------------------
54 # For use in AC_ARG_WITH action-if-found, for packages default ON.
55 # * Set NO_PACKAGE=YesPlease for --without-PACKAGE
56 # * Set PACKAGEDIR=PATH for --with-PACKAGE=PATH
57 # * Unset NO_PACKAGE for --with-PACKAGE without ARG
58 AC_DEFUN([GIT_PARSE_WITH],
59     [m4_pushdef([GIT_UC_PACKAGE], m4_toupper([$1]))dnl
60     if test "$withval" = "no"; then
61         NO_[]GIT_UC_PACKAGE=YesPlease
62     elif test "$withval" = "yes"; then
63         NO_[]GIT_UC_PACKAGE=
64     else
65         NO_[]GIT_UC_PACKAGE=
66         GIT_UC_PACKAGE[]DIR=$withval
67         AC_MSG_NOTICE([Setting GIT_UC_PACKAGE[]DIR to $withval])
68         GIT_CONF_SUBST(GIT_UC_PACKAGE[DIR], [$withval])
69     fi
70     m4_popdef([GIT_UC_PACKAGE])])
72 # GIT_PARSE_WITH_SET_MAKE_VAR(WITHNAME, VAR, HELP_TEXT)
73 # -----------------------------------------------------
74 # Set VAR to the value specied by --with-WITHNAME.
75 # No verification of arguments is performed, but warnings are issued
76 # if either 'yes' or 'no' is specified.
77 # HELP_TEXT is presented when --help is called.
78 # This is a direct way to allow setting variables in the Makefile.
79 AC_DEFUN([GIT_PARSE_WITH_SET_MAKE_VAR],
80 [AC_ARG_WITH([$1],
81  [AS_HELP_STRING([--with-$1=VALUE], $3)],
82  if test -n "$withval"; then
83   if test "$withval" = "yes" -o "$withval" = "no"; then
84     AC_MSG_WARN([You likely do not want either 'yes' or 'no' as]
85                      [a value for $1 ($2).  Maybe you do...?])
86   fi
87   AC_MSG_NOTICE([Setting $2 to $withval])
88   GIT_CONF_SUBST([$2], [$withval])
89  fi)])# GIT_PARSE_WITH_SET_MAKE_VAR
92 # GIT_CHECK_FUNC(FUNCTION, IFTRUE, IFFALSE)
93 # -----------------------------------------
94 # Similar to AC_CHECK_FUNC, but on systems that do not generate
95 # warnings for missing prototypes (e.g. FreeBSD when compiling without
96 # -Wall), it does not work.  By looking for function definition in
97 # libraries, this problem can be worked around.
98 AC_DEFUN([GIT_CHECK_FUNC],[AC_CHECK_FUNC([$1],[
99   AC_SEARCH_LIBS([$1],,
100   [$2],[$3])
101 ],[$3])])
104 # GIT_STASH_FLAGS(BASEPATH_VAR)
105 # -----------------------------
106 # Allow for easy stashing of LDFLAGS and CPPFLAGS before running
107 # tests that may want to take user settings into account.
108 AC_DEFUN([GIT_STASH_FLAGS],[
109 if test -n "$1"; then
110    old_CPPFLAGS="$CPPFLAGS"
111    old_LDFLAGS="$LDFLAGS"
112    CPPFLAGS="-I$1/include $CPPFLAGS"
113    LDFLAGS="-L$1/$lib $LDFLAGS"
118 dnl GIT_UNSTASH_FLAGS(BASEPATH_VAR)
119 dnl -----------------------------
120 dnl Restore the stashed *FLAGS values.
121 AC_DEFUN([GIT_UNSTASH_FLAGS],[
122 if test -n "$1"; then
123    CPPFLAGS="$old_CPPFLAGS"
124    LDFLAGS="$old_LDFLAGS"
128 ## Configure body starts here.
130 AC_PREREQ(2.59)
131 AC_INIT([git], [@@GIT_VERSION@@], [git@vger.kernel.org])
133 AC_CONFIG_SRCDIR([git.c])
135 config_file=config.mak.autogen
136 config_append=config.mak.append
137 config_in=config.mak.in
139 echo "# ${config_append}.  Generated by configure." > "${config_append}"
141 # Directories holding "saner" versions of common or POSIX binaries.
142 AC_ARG_WITH([sane-tool-path],
143   [AS_HELP_STRING(
144     [--with-sane-tool-path=DIR-1[[:DIR-2...:DIR-n]]],
145     [Directories to prepend to PATH in build system and generated scripts])],
146   [if test "$withval" = "no"; then
147     withval=''
148   else
149     AC_MSG_NOTICE([Setting SANE_TOOL_PATH to '$withval'])
150   fi
151   GIT_CONF_SUBST([SANE_TOOL_PATH], [$withval])],
152   [# If the "--with-sane-tool-path" option was not given, don't touch
153    # SANE_TOOL_PATH here, but let defaults in Makefile take care of it.
154    # This should minimize spurious differences in the behaviour of the
155    # Git build system when configure is used w.r.t. when it is not.
156    :])
158 ## Site configuration related to programs (before tests)
159 ## --with-PACKAGE[=ARG] and --without-PACKAGE
161 # Set lib to alternative name of lib directory (e.g. lib64)
162 AC_ARG_WITH([lib],
163  [AS_HELP_STRING([--with-lib=ARG],
164                  [ARG specifies alternative name for lib directory])],
165  [if test "$withval" = "no" || test "$withval" = "yes"; then
166         AC_MSG_WARN([You should provide name for --with-lib=ARG])
167   else
168         lib=$withval
169         AC_MSG_NOTICE([Setting lib to '$lib'])
170         GIT_CONF_SUBST([lib], [$withval])
171   fi])
173 if test -z "$lib"; then
174    AC_MSG_NOTICE([Setting lib to 'lib' (the default)])
175    lib=lib
178 AC_ARG_ENABLE([pthreads],
179  [AS_HELP_STRING([--enable-pthreads=FLAGS],
180   [FLAGS is the value to pass to the compiler to enable POSIX Threads.]
181   [The default if FLAGS is not specified is to try first -pthread]
182   [and then -lpthread.]
183   [--without-pthreads will disable threading.])],
185 if test "x$enableval" = "xyes"; then
186    AC_MSG_NOTICE([Will try -pthread then -lpthread to enable POSIX Threads])
187 elif test "x$enableval" != "xno"; then
188    PTHREAD_CFLAGS=$enableval
189    AC_MSG_NOTICE([Setting '$PTHREAD_CFLAGS' as the FLAGS to enable POSIX Threads])
190 else
191    AC_MSG_NOTICE([POSIX Threads will be disabled.])
192    NO_PTHREADS=YesPlease
193    USER_NOPTHREAD=1
194 fi],
196    AC_MSG_NOTICE([Will try -pthread then -lpthread to enable POSIX Threads.])
199 # Define option to enable JavaScript minification
200 AC_ARG_ENABLE([jsmin],
201 [AS_HELP_STRING([--enable-jsmin=PATH],
202   [PATH is the name of a JavaScript minifier or the absolute path to one.])],
204   JSMIN=$enableval;
205   AC_MSG_NOTICE([Setting JSMIN to '$JSMIN' to enable JavaScript minifying])
206   GIT_CONF_SUBST([JSMIN], [$enableval])
209 # Define option to enable CSS minification
210 AC_ARG_ENABLE([cssmin],
211 [AS_HELP_STRING([--enable-cssmin=PATH],
212   [PATH is the name of a CSS minifier or the absolute path to one.])],
214   CSSMIN=$enableval;
215   AC_MSG_NOTICE([Setting CSSMIN to '$CSSMIN' to enable CSS minifying])
216   GIT_CONF_SUBST([CSSMIN], [$enableval])
219 ## Site configuration (override autodetection)
220 ## --with-PACKAGE[=ARG] and --without-PACKAGE
221 AC_MSG_NOTICE([CHECKS for site configuration])
223 # Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
224 # tests.  These tests take up a significant amount of the total test time
225 # but are not needed unless you plan to talk to SVN repos.
227 # Define PPC_SHA1 environment variable when running make to make use of
228 # a bundled SHA1 routine optimized for PowerPC.
230 # Define NO_OPENSSL environment variable if you do not have OpenSSL.
231 # This also implies BLK_SHA1.
233 # Define OPENSSLDIR=/foo/bar if your openssl header and library files are in
234 # /foo/bar/include and /foo/bar/lib directories.
235 AC_ARG_WITH(openssl,
236 AS_HELP_STRING([--with-openssl],[use OpenSSL library (default is YES)])
237 AS_HELP_STRING([],              [ARG can be prefix for openssl library and headers]),
238 GIT_PARSE_WITH([openssl]))
240 # Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be
241 # able to use Perl-compatible regular expressions.
243 # Define LIBPCREDIR=/foo/bar if your libpcre header and library files are in
244 # /foo/bar/include and /foo/bar/lib directories.
246 AC_ARG_WITH(libpcre,
247 AS_HELP_STRING([--with-libpcre],[support Perl-compatible regexes (default is NO)])
248 AS_HELP_STRING([],           [ARG can be also prefix for libpcre library and headers]),
249     if test "$withval" = "no"; then
250         USE_LIBPCRE=
251     elif test "$withval" = "yes"; then
252         USE_LIBPCRE=YesPlease
253     else
254         USE_LIBPCRE=YesPlease
255         LIBPCREDIR=$withval
256         AC_MSG_NOTICE([Setting LIBPCREDIR to $withval])
257         GIT_CONF_SUBST([LIBPCREDIR], [$withval])
258     fi)
260 # Define NO_CURL if you do not have curl installed.  git-http-pull and
261 # git-http-push are not built, and you cannot use http:// and https://
262 # transports.
264 # Define CURLDIR=/foo/bar if your curl header and library files are in
265 # /foo/bar/include and /foo/bar/lib directories.
266 AC_ARG_WITH(curl,
267 AS_HELP_STRING([--with-curl],[support http(s):// transports (default is YES)])
268 AS_HELP_STRING([],           [ARG can be also prefix for curl library and headers]),
269 GIT_PARSE_WITH(curl))
271 # Define NO_EXPAT if you do not have expat installed.  git-http-push is
272 # not built, and you cannot push using http:// and https:// transports.
274 # Define EXPATDIR=/foo/bar if your expat header and library files are in
275 # /foo/bar/include and /foo/bar/lib directories.
276 AC_ARG_WITH(expat,
277 AS_HELP_STRING([--with-expat],
278 [support git-push using http:// and https:// transports via WebDAV (default is YES)])
279 AS_HELP_STRING([],            [ARG can be also prefix for expat library and headers]),
280 GIT_PARSE_WITH(expat))
282 # Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
283 # installed in /sw, but don't want GIT to link against any libraries
284 # installed there.  If defined you may specify your own (or Fink's)
285 # include directories and library directories by defining CFLAGS
286 # and LDFLAGS appropriately.
288 # Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
289 # have DarwinPorts installed in /opt/local, but don't want GIT to
290 # link against any libraries installed there.  If defined you may
291 # specify your own (or DarwinPort's) include directories and
292 # library directories by defining CFLAGS and LDFLAGS appropriately.
294 # Define NO_MMAP if you want to avoid mmap.
296 # Define NO_ICONV if your libc does not properly support iconv.
297 AC_ARG_WITH(iconv,
298 AS_HELP_STRING([--without-iconv],
299 [if your architecture doesn't properly support iconv])
300 AS_HELP_STRING([--with-iconv=PATH],
301 [PATH is prefix for libiconv library and headers])
302 AS_HELP_STRING([],
303 [used only if you need linking with libiconv]),
304 GIT_PARSE_WITH(iconv))
306 ## --enable-FEATURE[=ARG] and --disable-FEATURE
308 # Define USE_NSEC below if you want git to care about sub-second file mtimes
309 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
310 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
311 # randomly break unless your underlying filesystem supports those sub-second
312 # times (my ext3 doesn't).
314 # Define USE_STDEV below if you want git to care about the underlying device
315 # change being considered an inode change from the update-index perspective.
318 # Allow user to set ETC_GITCONFIG variable
319 GIT_PARSE_WITH_SET_MAKE_VAR(gitconfig, ETC_GITCONFIG,
320                         Use VALUE instead of /etc/gitconfig as the
321                         global git configuration file.
322                         If VALUE is not fully qualified it will be interpreted
323                         as a path relative to the computed prefix at runtime.)
326 # Allow user to set ETC_GITATTRIBUTES variable
327 GIT_PARSE_WITH_SET_MAKE_VAR(gitattributes, ETC_GITATTRIBUTES,
328                         Use VALUE instead of /etc/gitattributes as the
329                         global git attributes file.
330                         If VALUE is not fully qualified it will be interpreted
331                         as a path relative to the computed prefix at runtime.)
334 # Allow user to set the default pager
335 GIT_PARSE_WITH_SET_MAKE_VAR(pager, DEFAULT_PAGER,
336                         Use VALUE as the fall-back pager instead of 'less'.
337                         This is used by things like 'git log' when the user
338                         does not specify a pager to use through alternate
339                         methods. eg: /usr/bin/pager)
341 # Allow user to set the default editor
342 GIT_PARSE_WITH_SET_MAKE_VAR(editor, DEFAULT_EDITOR,
343                         Use VALUE as the fall-back editor instead of 'vi'.
344                         This is used by things like 'git commit' when the user
345                         does not specify a preferred editor through other
346                         methods. eg: /usr/bin/editor)
349 # Define SHELL_PATH to provide path to shell.
350 GIT_ARG_SET_PATH(shell)
352 # Define PERL_PATH to provide path to Perl.
353 GIT_ARG_SET_PATH(perl)
355 # Define PYTHON_PATH to provide path to Python.
356 GIT_ARG_SET_PATH(python, allow-without)
358 # Define ZLIB_PATH to provide path to zlib.
359 GIT_ARG_SET_PATH(zlib)
361 # Declare the with-tcltk/without-tcltk options.
362 AC_ARG_WITH(tcltk,
363 AS_HELP_STRING([--with-tcltk],[use Tcl/Tk GUI (default is YES)])
364 AS_HELP_STRING([],[ARG is the full path to the Tcl/Tk interpreter.])
365 AS_HELP_STRING([],[Bare --with-tcltk will make the GUI part only if])
366 AS_HELP_STRING([],[Tcl/Tk interpreter will be found in a system.]),
367 GIT_PARSE_WITH(tcltk))
371 ## Checks for programs.
372 AC_MSG_NOTICE([CHECKS for programs])
374 AC_PROG_CC([cc gcc])
375 AC_C_INLINE
376 case $ac_cv_c_inline in
377   inline | yes | no)    ;;
378   *)                    AC_SUBST([INLINE], [$ac_cv_c_inline]) ;;
379 esac
381 # which switch to pass runtime path to dynamic libraries to the linker
382 AC_CACHE_CHECK([if linker supports -R], git_cv_ld_dashr, [
383    SAVE_LDFLAGS="${LDFLAGS}"
384    LDFLAGS="${SAVE_LDFLAGS} -R /"
385    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [git_cv_ld_dashr=yes], [git_cv_ld_dashr=no])
386    LDFLAGS="${SAVE_LDFLAGS}"
388 if test "$git_cv_ld_dashr" = "yes"; then
389    AC_SUBST(CC_LD_DYNPATH, [-R])
390 else
391    AC_CACHE_CHECK([if linker supports -Wl,-rpath,], git_cv_ld_wl_rpath, [
392       SAVE_LDFLAGS="${LDFLAGS}"
393       LDFLAGS="${SAVE_LDFLAGS} -Wl,-rpath,/"
394       AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [git_cv_ld_wl_rpath=yes], [git_cv_ld_wl_rpath=no])
395       LDFLAGS="${SAVE_LDFLAGS}"
396    ])
397    if test "$git_cv_ld_wl_rpath" = "yes"; then
398       AC_SUBST(CC_LD_DYNPATH, [-Wl,-rpath,])
399    else
400       AC_CACHE_CHECK([if linker supports -rpath], git_cv_ld_rpath, [
401          SAVE_LDFLAGS="${LDFLAGS}"
402          LDFLAGS="${SAVE_LDFLAGS} -rpath /"
403          AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [git_cv_ld_rpath=yes], [git_cv_ld_rpath=no])
404          LDFLAGS="${SAVE_LDFLAGS}"
405       ])
406       if test "$git_cv_ld_rpath" = "yes"; then
407          AC_SUBST(CC_LD_DYNPATH, [-rpath])
408       else
409          AC_MSG_WARN([linker does not support runtime path to dynamic libraries])
410       fi
411    fi
413 #AC_PROG_INSTALL                # needs install-sh or install.sh in sources
414 AC_CHECK_TOOLS(AR, [gar ar], :)
415 AC_CHECK_PROGS(TAR, [gtar tar])
416 AC_CHECK_PROGS(DIFF, [gnudiff gdiff diff])
417 # TCLTK_PATH will be set to some value if we want Tcl/Tk
418 # or will be empty otherwise.
419 if test -z "$NO_TCLTK"; then
420   if test "$with_tcltk" = ""; then
421   # No Tcl/Tk switches given. Do not check for Tcl/Tk, use bare 'wish'.
422     TCLTK_PATH=wish
423     AC_SUBST(TCLTK_PATH)
424   elif test "$with_tcltk" = "yes"; then
425   # Tcl/Tk check requested.
426     AC_CHECK_PROGS(TCLTK_PATH, [wish], )
427   else
428     AC_MSG_RESULT([Using Tcl/Tk interpreter $with_tcltk])
429     TCLTK_PATH="$with_tcltk"
430     AC_SUBST(TCLTK_PATH)
431   fi
433 AC_CHECK_PROGS(ASCIIDOC, [asciidoc])
434 if test -n "$ASCIIDOC"; then
435         AC_MSG_CHECKING([for asciidoc version])
436         asciidoc_version=`$ASCIIDOC --version 2>/dev/null`
437         case "${asciidoc_version}" in
438         asciidoc' '8*)
439                 AC_MSG_RESULT([${asciidoc_version}])
440                 ;;
441         *)
442                 AC_MSG_RESULT([${asciidoc_version} (unknown)])
443                 ;;
444         esac
448 ## Checks for libraries.
449 AC_MSG_NOTICE([CHECKS for libraries])
451 # Define NO_OPENSSL environment variable if you do not have OpenSSL.
452 # Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
454 GIT_STASH_FLAGS($OPENSSLDIR)
456 AC_CHECK_LIB([crypto], [SHA1_Init],
457 [NEEDS_SSL_WITH_CRYPTO=],
458 [AC_CHECK_LIB([ssl], [SHA1_Init],
459  [NEEDS_SSL_WITH_CRYPTO=YesPlease],
460  [NEEDS_SSL_WITH_CRYPTO= NO_OPENSSL=YesPlease])])
462 GIT_UNSTASH_FLAGS($OPENSSLDIR)
464 AC_SUBST(NEEDS_SSL_WITH_CRYPTO)
465 AC_SUBST(NO_OPENSSL)
468 # Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be
469 # able to use Perl-compatible regular expressions.
472 if test -n "$USE_LIBPCRE"; then
474 GIT_STASH_FLAGS($LIBPCREDIR)
476 AC_CHECK_LIB([pcre], [pcre_version],
477 [USE_LIBPCRE=YesPlease],
478 [USE_LIBPCRE=])
480 GIT_UNSTASH_FLAGS($LIBPCREDIR)
482 AC_SUBST(USE_LIBPCRE)
487 # Define NO_CURL if you do not have libcurl installed.  git-http-pull and
488 # git-http-push are not built, and you cannot use http:// and https://
489 # transports.
491 GIT_STASH_FLAGS($CURLDIR)
493 AC_CHECK_LIB([curl], [curl_global_init],
494 [NO_CURL=],
495 [NO_CURL=YesPlease])
497 GIT_UNSTASH_FLAGS($CURLDIR)
499 AC_SUBST(NO_CURL)
502 # Define NO_EXPAT if you do not have expat installed.  git-http-push is
503 # not built, and you cannot push using http:// and https:// transports.
505 GIT_STASH_FLAGS($EXPATDIR)
507 AC_CHECK_LIB([expat], [XML_ParserCreate],
508 [NO_EXPAT=],
509 [NO_EXPAT=YesPlease])
511 GIT_UNSTASH_FLAGS($EXPATDIR)
513 AC_SUBST(NO_EXPAT)
516 # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin and
517 # some Solaris installations).
518 # Define NO_ICONV if neither libc nor libiconv support iconv.
520 if test -z "$NO_ICONV"; then
522 GIT_STASH_FLAGS($ICONVDIR)
524 AC_DEFUN([ICONVTEST_SRC],
525 [AC_LANG_PROGRAM([#include <iconv.h>],
526  [iconv_open("", "");])])
528 if test -n "$ICONVDIR"; then
529    lib_order="-liconv -lc"
530 else
531    lib_order="-lc -liconv"
534 NO_ICONV=YesPlease
536 for l in $lib_order; do
537     if test "$l" = "-liconv"; then
538        NEEDS_LIBICONV=YesPlease
539     else
540        NEEDS_LIBICONV=
541     fi
543     old_LIBS="$LIBS"
544     LIBS="$LIBS $l"
545     AC_MSG_CHECKING([for iconv in $l])
546     AC_LINK_IFELSE([ICONVTEST_SRC],
547         [AC_MSG_RESULT([yes])
548         NO_ICONV=
549         break],
550         [AC_MSG_RESULT([no])])
551     LIBS="$old_LIBS"
552 done
554 #in case of break
555 LIBS="$old_LIBS"
557 GIT_UNSTASH_FLAGS($ICONVDIR)
559 AC_SUBST(NEEDS_LIBICONV)
560 AC_SUBST(NO_ICONV)
562 if test -n "$NO_ICONV"; then
563     NEEDS_LIBICONV=
569 # Define NO_DEFLATE_BOUND if deflateBound is missing from zlib.
571 GIT_STASH_FLAGS($ZLIB_PATH)
573 AC_DEFUN([ZLIBTEST_SRC], [
574 AC_LANG_PROGRAM([#include <zlib.h>],
575  [deflateBound(0, 0);])])
576 AC_MSG_CHECKING([for deflateBound in -lz])
577 old_LIBS="$LIBS"
578 LIBS="$LIBS -lz"
579 AC_LINK_IFELSE([ZLIBTEST_SRC],
580         [AC_MSG_RESULT([yes])],
581         [AC_MSG_RESULT([no])
582         NO_DEFLATE_BOUND=yes])
583 LIBS="$old_LIBS"
585 GIT_UNSTASH_FLAGS($ZLIB_PATH)
587 AC_SUBST(NO_DEFLATE_BOUND)
590 # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
591 # Patrick Mauritz).
592 AC_CHECK_LIB([c], [socket],
593 [NEEDS_SOCKET=],
594 [NEEDS_SOCKET=YesPlease])
595 AC_SUBST(NEEDS_SOCKET)
596 test -n "$NEEDS_SOCKET" && LIBS="$LIBS -lsocket"
599 # The next few tests will define NEEDS_RESOLV if linking with
600 # libresolv provides some of the functions we would normally get
601 # from libc.
602 NEEDS_RESOLV=
603 AC_SUBST(NEEDS_RESOLV)
605 # Define NO_INET_NTOP if linking with -lresolv is not enough.
606 # Solaris 2.7 in particular hos inet_ntop in -lresolv.
607 NO_INET_NTOP=
608 AC_SUBST(NO_INET_NTOP)
609 AC_CHECK_FUNC([inet_ntop],
610         [],
611     [AC_CHECK_LIB([resolv], [inet_ntop],
612             [NEEDS_RESOLV=YesPlease],
613         [NO_INET_NTOP=YesPlease])
616 # Define NO_INET_PTON if linking with -lresolv is not enough.
617 # Solaris 2.7 in particular hos inet_pton in -lresolv.
618 NO_INET_PTON=
619 AC_SUBST(NO_INET_PTON)
620 AC_CHECK_FUNC([inet_pton],
621         [],
622     [AC_CHECK_LIB([resolv], [inet_pton],
623             [NEEDS_RESOLV=YesPlease],
624         [NO_INET_PTON=YesPlease])
627 # Define NO_HSTRERROR if linking with -lresolv is not enough.
628 # Solaris 2.6 in particular has no hstrerror, even in -lresolv.
629 NO_HSTRERROR=
630 AC_CHECK_FUNC([hstrerror],
631         [],
632     [AC_CHECK_LIB([resolv], [hstrerror],
633             [NEEDS_RESOLV=YesPlease],
634         [NO_HSTRERROR=YesPlease])
636 AC_SUBST(NO_HSTRERROR)
638 # If any of the above tests determined that -lresolv is needed at
639 # build-time, also set it here for remaining configure-time checks.
640 test -n "$NEEDS_RESOLV" && LIBS="$LIBS -lresolv"
642 AC_CHECK_LIB([c], [basename],
643 [NEEDS_LIBGEN=],
644 [NEEDS_LIBGEN=YesPlease])
645 AC_SUBST(NEEDS_LIBGEN)
646 test -n "$NEEDS_LIBGEN" && LIBS="$LIBS -lgen"
648 AC_CHECK_LIB([c], [gettext],
649 [LIBC_CONTAINS_LIBINTL=YesPlease],
650 [LIBC_CONTAINS_LIBINTL=])
651 AC_SUBST(LIBC_CONTAINS_LIBINTL)
654 # Define NO_GETTEXT if you don't want Git output to be translated.
655 # A translated Git requires GNU libintl or another gettext implementation
656 AC_CHECK_HEADER([libintl.h],
657 [NO_GETTEXT=],
658 [NO_GETTEXT=YesPlease])
659 AC_SUBST(NO_GETTEXT)
661 if test -z "$NO_GETTEXT"; then
662     test -n "$LIBC_CONTAINS_LIBINTL" || LIBS="$LIBS -lintl"
665 ## Checks for header files.
666 AC_MSG_NOTICE([CHECKS for header files])
668 # Define NO_SYS_SELECT_H if you don't have sys/select.h.
669 AC_CHECK_HEADER([sys/select.h],
670 [NO_SYS_SELECT_H=],
671 [NO_SYS_SELECT_H=UnfortunatelyYes])
672 AC_SUBST(NO_SYS_SELECT_H)
674 # Define NO_SYS_POLL_H if you don't have sys/poll.h
675 AC_CHECK_HEADER([sys/poll.h],
676 [NO_SYS_POLL_H=],
677 [NO_SYS_POLL_H=UnfortunatelyYes])
678 AC_SUBST(NO_SYS_POLL_H)
680 # Define NO_INTTYPES_H if you don't have inttypes.h
681 AC_CHECK_HEADER([inttypes.h],
682 [NO_INTTYPES_H=],
683 [NO_INTTYPES_H=UnfortunatelyYes])
684 AC_SUBST(NO_INTTYPES_H)
686 # Define OLD_ICONV if your library has an old iconv(), where the second
687 # (input buffer pointer) parameter is declared with type (const char **).
688 AC_DEFUN([OLDICONVTEST_SRC], [
689 AC_LANG_PROGRAM([[
690 #include <iconv.h>
692 extern size_t iconv(iconv_t cd,
693                     char **inbuf, size_t *inbytesleft,
694                     char **outbuf, size_t *outbytesleft);
695 ]], [])])
697 GIT_STASH_FLAGS($ICONVDIR)
699 AC_MSG_CHECKING([for old iconv()])
700 AC_COMPILE_IFELSE([OLDICONVTEST_SRC],
701         [AC_MSG_RESULT([no])],
702         [AC_MSG_RESULT([yes])
703         OLD_ICONV=UnfortunatelyYes])
705 GIT_UNSTASH_FLAGS($ICONVDIR)
707 AC_SUBST(OLD_ICONV)
709 ## Checks for typedefs, structures, and compiler characteristics.
710 AC_MSG_NOTICE([CHECKS for typedefs, structures, and compiler characteristics])
712 TYPE_SOCKLEN_T
713 case $ac_cv_type_socklen_t in
714   yes)  ;;
715   *)    AC_SUBST([SOCKLEN_T], [$git_cv_socklen_t_equiv]) ;;
716 esac
718 # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
719 AC_CHECK_MEMBER(struct dirent.d_ino,
720 [NO_D_INO_IN_DIRENT=],
721 [NO_D_INO_IN_DIRENT=YesPlease],
722 [#include <dirent.h>])
723 AC_SUBST(NO_D_INO_IN_DIRENT)
725 # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
726 # d_type in struct dirent (latest Cygwin -- will be fixed soonish).
727 AC_CHECK_MEMBER(struct dirent.d_type,
728 [NO_D_TYPE_IN_DIRENT=],
729 [NO_D_TYPE_IN_DIRENT=YesPlease],
730 [#include <dirent.h>])
731 AC_SUBST(NO_D_TYPE_IN_DIRENT)
733 # Define NO_SOCKADDR_STORAGE if your platform does not have struct
734 # sockaddr_storage.
735 AC_CHECK_TYPE(struct sockaddr_storage,
736 [NO_SOCKADDR_STORAGE=],
737 [NO_SOCKADDR_STORAGE=YesPlease],[
738 #include <sys/types.h>
739 #include <sys/socket.h>
741 AC_SUBST(NO_SOCKADDR_STORAGE)
743 # Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
744 AC_CHECK_TYPE([struct addrinfo],[
745  GIT_CHECK_FUNC([getaddrinfo],
746   [NO_IPV6=],
747   [NO_IPV6=YesPlease])
748 ],[NO_IPV6=YesPlease],[
749 #include <sys/types.h>
750 #include <sys/socket.h>
751 #include <netdb.h>
753 AC_SUBST(NO_IPV6)
755 # Define NO_REGEX if you have no or inferior regex support in your C library.
756 AC_CACHE_CHECK([whether the platform regex can handle null bytes],
757  [ac_cv_c_excellent_regex], [
758 AC_EGREP_CPP(yippeeyeswehaveit,
759         AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
760 #include <regex.h>
762 [#ifdef REG_STARTEND
763 yippeeyeswehaveit
764 #endif
766         [ac_cv_c_excellent_regex=yes],
767         [ac_cv_c_excellent_regex=no])
769 if test $ac_cv_c_excellent_regex = yes; then
770         NO_REGEX=
771 else
772         NO_REGEX=YesPlease
774 AC_SUBST(NO_REGEX)
776 # Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
777 # when attempting to read from an fopen'ed directory.
778 AC_CACHE_CHECK([whether system succeeds to read fopen'ed directory],
779  [ac_cv_fread_reads_directories],
781 AC_RUN_IFELSE(
782         [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
783                 [[char c;
784                 FILE *f = fopen(".", "r");
785                 return f && fread(&c, 1, 1, f)]])],
786         [ac_cv_fread_reads_directories=no],
787         [ac_cv_fread_reads_directories=yes])
789 if test $ac_cv_fread_reads_directories = yes; then
790         FREAD_READS_DIRECTORIES=UnfortunatelyYes
791 else
792         FREAD_READS_DIRECTORIES=
794 AC_SUBST(FREAD_READS_DIRECTORIES)
796 # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
797 # or vsnprintf() return -1 instead of number of characters which would
798 # have been written to the final string if enough space had been available.
799 AC_CACHE_CHECK([whether snprintf() and/or vsnprintf() return bogus value],
800  [ac_cv_snprintf_returns_bogus],
802 AC_RUN_IFELSE(
803         [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
804                 #include "stdarg.h"
806                 int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
807                 {
808                   int ret;
809                   va_list ap;
810                   va_start(ap, format);
811                   ret = vsnprintf(str, maxsize, format, ap);
812                   va_end(ap);
813                   return ret;
814                 }],
815                 [[char buf[6];
816                   if (test_vsnprintf(buf, 3, "%s", "12345") != 5
817                       || strcmp(buf, "12")) return 1;
818                   if (snprintf(buf, 3, "%s", "12345") != 5
819                       || strcmp(buf, "12")) return 1]])],
820         [ac_cv_snprintf_returns_bogus=no],
821         [ac_cv_snprintf_returns_bogus=yes])
823 if test $ac_cv_snprintf_returns_bogus = yes; then
824         SNPRINTF_RETURNS_BOGUS=UnfortunatelyYes
825 else
826         SNPRINTF_RETURNS_BOGUS=
828 AC_SUBST(SNPRINTF_RETURNS_BOGUS)
831 ## Checks for library functions.
832 ## (in default C library and libraries checked by AC_CHECK_LIB)
833 AC_MSG_NOTICE([CHECKS for library functions])
835 # Define NO_LIBGEN_H if you don't have libgen.h.
836 AC_CHECK_HEADER([libgen.h],
837 [NO_LIBGEN_H=],
838 [NO_LIBGEN_H=YesPlease])
839 AC_SUBST(NO_LIBGEN_H)
841 # Define HAVE_PATHS_H if you have paths.h.
842 AC_CHECK_HEADER([paths.h],
843 [HAVE_PATHS_H=YesPlease],
844 [HAVE_PATHS_H=])
845 AC_SUBST(HAVE_PATHS_H)
847 # Define HAVE_LIBCHARSET_H if have libcharset.h
848 AC_CHECK_HEADER([libcharset.h],
849 [HAVE_LIBCHARSET_H=YesPlease],
850 [HAVE_LIBCHARSET_H=])
851 AC_SUBST(HAVE_LIBCHARSET_H)
852 # Define CHARSET_LIB if libiconv does not export the locale_charset symbol
853 # and libcharset does
854 CHARSET_LIB=
855 AC_CHECK_LIB([iconv], [locale_charset],
856        [],
857        [AC_CHECK_LIB([charset], [locale_charset],
858                      [CHARSET_LIB=-lcharset])
859        ]
861 AC_SUBST(CHARSET_LIB)
863 # Define NO_STRCASESTR if you don't have strcasestr.
864 GIT_CHECK_FUNC(strcasestr,
865 [NO_STRCASESTR=],
866 [NO_STRCASESTR=YesPlease])
867 AC_SUBST(NO_STRCASESTR)
869 # Define NO_STRTOK_R if you don't have strtok_r
870 GIT_CHECK_FUNC(strtok_r,
871 [NO_STRTOK_R=],
872 [NO_STRTOK_R=YesPlease])
873 AC_SUBST(NO_STRTOK_R)
875 # Define NO_FNMATCH if you don't have fnmatch
876 GIT_CHECK_FUNC(fnmatch,
877 [NO_FNMATCH=],
878 [NO_FNMATCH=YesPlease])
879 AC_SUBST(NO_FNMATCH)
881 # Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
882 # FNM_CASEFOLD GNU extension.
883 AC_CACHE_CHECK([whether the fnmatch function supports the FNMATCH_CASEFOLD GNU extension],
884  [ac_cv_c_excellent_fnmatch], [
885 AC_EGREP_CPP(yippeeyeswehaveit,
886         AC_LANG_PROGRAM([
887 #include <fnmatch.h>
889 [#ifdef FNM_CASEFOLD
890 yippeeyeswehaveit
891 #endif
893         [ac_cv_c_excellent_fnmatch=yes],
894         [ac_cv_c_excellent_fnmatch=no])
896 if test $ac_cv_c_excellent_fnmatch = yes; then
897         NO_FNMATCH_CASEFOLD=
898 else
899         NO_FNMATCH_CASEFOLD=YesPlease
901 AC_SUBST(NO_FNMATCH_CASEFOLD)
903 # Define NO_MEMMEM if you don't have memmem.
904 GIT_CHECK_FUNC(memmem,
905 [NO_MEMMEM=],
906 [NO_MEMMEM=YesPlease])
907 AC_SUBST(NO_MEMMEM)
909 # Define NO_STRLCPY if you don't have strlcpy.
910 GIT_CHECK_FUNC(strlcpy,
911 [NO_STRLCPY=],
912 [NO_STRLCPY=YesPlease])
913 AC_SUBST(NO_STRLCPY)
915 # Define NO_UINTMAX_T if your platform does not have uintmax_t
916 AC_CHECK_TYPE(uintmax_t,
917 [NO_UINTMAX_T=],
918 [NO_UINTMAX_T=YesPlease],[
919 #include <inttypes.h>
921 AC_SUBST(NO_UINTMAX_T)
923 # Define NO_STRTOUMAX if you don't have strtoumax in the C library.
924 GIT_CHECK_FUNC(strtoumax,
925 [NO_STRTOUMAX=],
926 [NO_STRTOUMAX=YesPlease])
927 AC_SUBST(NO_STRTOUMAX)
929 # Define NO_SETENV if you don't have setenv in the C library.
930 GIT_CHECK_FUNC(setenv,
931 [NO_SETENV=],
932 [NO_SETENV=YesPlease])
933 AC_SUBST(NO_SETENV)
935 # Define NO_UNSETENV if you don't have unsetenv in the C library.
936 GIT_CHECK_FUNC(unsetenv,
937 [NO_UNSETENV=],
938 [NO_UNSETENV=YesPlease])
939 AC_SUBST(NO_UNSETENV)
941 # Define NO_MKDTEMP if you don't have mkdtemp in the C library.
942 GIT_CHECK_FUNC(mkdtemp,
943 [NO_MKDTEMP=],
944 [NO_MKDTEMP=YesPlease])
945 AC_SUBST(NO_MKDTEMP)
947 # Define NO_MKSTEMPS if you don't have mkstemps in the C library.
948 GIT_CHECK_FUNC(mkstemps,
949 [NO_MKSTEMPS=],
950 [NO_MKSTEMPS=YesPlease])
951 AC_SUBST(NO_MKSTEMPS)
953 # Define NO_INITGROUPS if you don't have initgroups in the C library.
954 GIT_CHECK_FUNC(initgroups,
955 [NO_INITGROUPS=],
956 [NO_INITGROUPS=YesPlease])
957 AC_SUBST(NO_INITGROUPS)
960 # Define NO_MMAP if you want to avoid mmap.
962 # Define NO_ICONV if your libc does not properly support iconv.
965 ## Other checks.
966 # Define USE_PIC if you need the main git objects to be built with -fPIC
967 # in order to build and link perl/Git.so.  x86-64 seems to need this.
969 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
970 # Enable it on Windows.  By default, symrefs are still used.
972 # Define NO_PTHREADS if we do not have pthreads.
974 # Define PTHREAD_LIBS to the linker flag used for Pthread support.
975 AC_DEFUN([PTHREADTEST_SRC], [
976 AC_LANG_PROGRAM([[
977 #include <pthread.h>
978 ]], [[
979         pthread_mutex_t test_mutex;
980         pthread_key_t test_key;
981         int retcode = 0;
982         retcode |= pthread_key_create(&test_key, (void *)0);
983         retcode |= pthread_mutex_init(&test_mutex,(void *)0);
984         retcode |= pthread_mutex_lock(&test_mutex);
985         retcode |= pthread_mutex_unlock(&test_mutex);
986         return retcode;
987 ]])])
989 dnl AC_LANG_CONFTEST([AC_LANG_PROGRAM(
990 dnl   [[#include <pthread.h>]],
991 dnl   [[pthread_mutex_t test_mutex;]]
992 dnl )])
994 NO_PTHREADS=UnfortunatelyYes
995 PTHREAD_LIBS=
997 if test -n "$USER_NOPTHREAD"; then
998    AC_MSG_NOTICE([Skipping POSIX Threads at user request.])
999 # handle these separately since PTHREAD_CFLAGS could be '-lpthreads
1000 # -D_REENTRANT' or some such.
1001 elif test -z "$PTHREAD_CFLAGS"; then
1002   threads_found=no
1003   for opt in -mt -pthread -lpthread; do
1004      old_CFLAGS="$CFLAGS"
1005      CFLAGS="$opt $CFLAGS"
1006      AC_MSG_CHECKING([Checking for POSIX Threads with '$opt'])
1007      AC_LINK_IFELSE([PTHREADTEST_SRC],
1008         [AC_MSG_RESULT([yes])
1009                 NO_PTHREADS=
1010                 PTHREAD_LIBS="$opt"
1011                 PTHREAD_CFLAGS="$opt"
1012                 threads_found=yes
1013                 break
1014         ],
1015         [AC_MSG_RESULT([no])])
1016       CFLAGS="$old_CFLAGS"
1017   done
1018   if test $threads_found != yes; then
1019     AC_CHECK_LIB([pthread], [pthread_create],
1020         [PTHREAD_LIBS="-lpthread"],
1021         [NO_PTHREADS=UnfortunatelyYes])
1022   fi
1023 else
1024   old_CFLAGS="$CFLAGS"
1025   CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
1026   AC_MSG_CHECKING([Checking for POSIX Threads with '$PTHREAD_CFLAGS'])
1027   AC_LINK_IFELSE([PTHREADTEST_SRC],
1028         [AC_MSG_RESULT([yes])
1029                 NO_PTHREADS=
1030                 PTHREAD_LIBS="$PTHREAD_CFLAGS"
1031         ],
1032         [AC_MSG_RESULT([no])])
1034   CFLAGS="$old_CFLAGS"
1037 CFLAGS="$old_CFLAGS"
1039 AC_SUBST(PTHREAD_CFLAGS)
1040 AC_SUBST(PTHREAD_LIBS)
1041 AC_SUBST(NO_PTHREADS)
1043 ## Output files
1044 AC_CONFIG_FILES(["${config_file}":"${config_in}":"${config_append}"])
1045 AC_OUTPUT
1048 ## Cleanup
1049 rm -f "${config_append}"