git-multimail: update to release 1.3.0
[git.git] / configure.ac
blob0cd9f4680b84bccd0a98193c401b13749b05b833
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 # Cause the line "VAR=VAL" to be eventually appended to ${config_file}.
9 AC_DEFUN([GIT_CONF_SUBST],
10 [AC_REQUIRE([GIT_CONF_SUBST_INIT])
11 config_appended_defs="$config_appended_defs${newline}dnl
12 $1=m4_if([$#],[1],[${$1}],[$2])"])
14 # GIT_CONF_SUBST_INIT
15 # -------------------
16 # Prepare shell variables and autoconf machine required by later calls
17 # to GIT_CONF_SUBST.
18 AC_DEFUN([GIT_CONF_SUBST_INIT],
19     [config_appended_defs=; newline='
21     AC_CONFIG_COMMANDS([$config_file],
22                        [echo "$config_appended_defs" >> "$config_file"],
23                        [config_file=$config_file
24                         config_appended_defs="$config_appended_defs"])])
26 # GIT_ARG_SET_PATH(PROGRAM)
27 # -------------------------
28 # Provide --with-PROGRAM=PATH option to set PATH to PROGRAM
29 # Optional second argument allows setting NO_PROGRAM=YesPlease if
30 # --without-PROGRAM version used.
31 AC_DEFUN([GIT_ARG_SET_PATH],
32     [AC_ARG_WITH([$1],
33         [AS_HELP_STRING([--with-$1=PATH],
34                         [provide PATH to $1])],
35         [GIT_CONF_APPEND_PATH([$1], [$2])],
36         [])])
38 # GIT_CONF_APPEND_PATH(PROGRAM)
39 # -----------------------------
40 # Parse --with-PROGRAM=PATH option to set PROGRAM_PATH=PATH
41 # Used by GIT_ARG_SET_PATH(PROGRAM)
42 # Optional second argument allows setting NO_PROGRAM=YesPlease if
43 # --without-PROGRAM is used.
44 AC_DEFUN([GIT_CONF_APPEND_PATH],
45     [m4_pushdef([GIT_UC_PROGRAM], m4_toupper([$1]))dnl
46     if test "$withval" = "no"; then
47         if test -n "$2"; then
48                 GIT_UC_PROGRAM[]_PATH=$withval
49                 AC_MSG_NOTICE([Disabling use of GIT_UC_PROGRAM])
50                 GIT_CONF_SUBST([NO_]GIT_UC_PROGRAM, [YesPlease])
51                 GIT_CONF_SUBST(GIT_UC_PROGRAM[]_PATH, [])
52         else
53                 AC_MSG_ERROR([You cannot use git without $1])
54         fi
55     else
56         if test "$withval" = "yes"; then
57                 AC_MSG_WARN([You should provide path for --with-$1=PATH])
58         else
59                 GIT_UC_PROGRAM[]_PATH=$withval
60                 AC_MSG_NOTICE([Setting GIT_UC_PROGRAM[]_PATH to $withval])
61                 GIT_CONF_SUBST(GIT_UC_PROGRAM[]_PATH, [$withval])
62         fi
63     fi
64     m4_popdef([GIT_UC_PROGRAM])])
66 # GIT_PARSE_WITH(PACKAGE)
67 # -----------------------
68 # For use in AC_ARG_WITH action-if-found, for packages default ON.
69 # * Set NO_PACKAGE=YesPlease for --without-PACKAGE
70 # * Set PACKAGEDIR=PATH for --with-PACKAGE=PATH
71 # * Unset NO_PACKAGE for --with-PACKAGE without ARG
72 AC_DEFUN([GIT_PARSE_WITH],
73     [m4_pushdef([GIT_UC_PACKAGE], m4_toupper([$1]))dnl
74     if test "$withval" = "no"; then
75         NO_[]GIT_UC_PACKAGE=YesPlease
76     elif test "$withval" = "yes"; then
77         NO_[]GIT_UC_PACKAGE=
78     else
79         NO_[]GIT_UC_PACKAGE=
80         GIT_UC_PACKAGE[]DIR=$withval
81         AC_MSG_NOTICE([Setting GIT_UC_PACKAGE[]DIR to $withval])
82         GIT_CONF_SUBST(GIT_UC_PACKAGE[DIR], [$withval])
83     fi
84     m4_popdef([GIT_UC_PACKAGE])])
86 # GIT_PARSE_WITH_SET_MAKE_VAR(WITHNAME, VAR, HELP_TEXT)
87 # -----------------------------------------------------
88 # Set VAR to the value specied by --with-WITHNAME.
89 # No verification of arguments is performed, but warnings are issued
90 # if either 'yes' or 'no' is specified.
91 # HELP_TEXT is presented when --help is called.
92 # This is a direct way to allow setting variables in the Makefile.
93 AC_DEFUN([GIT_PARSE_WITH_SET_MAKE_VAR],
94 [AC_ARG_WITH([$1],
95  [AS_HELP_STRING([--with-$1=VALUE], $3)],
96  if test -n "$withval"; then
97   if test "$withval" = "yes" -o "$withval" = "no"; then
98     AC_MSG_WARN([You likely do not want either 'yes' or 'no' as]
99                      [a value for $1 ($2).  Maybe you do...?])
100   fi
101   AC_MSG_NOTICE([Setting $2 to $withval])
102   GIT_CONF_SUBST([$2], [$withval])
103  fi)])# GIT_PARSE_WITH_SET_MAKE_VAR
106 # GIT_CHECK_FUNC(FUNCTION, IFTRUE, IFFALSE)
107 # -----------------------------------------
108 # Similar to AC_CHECK_FUNC, but on systems that do not generate
109 # warnings for missing prototypes (e.g. FreeBSD when compiling without
110 # -Wall), it does not work.  By looking for function definition in
111 # libraries, this problem can be worked around.
112 AC_DEFUN([GIT_CHECK_FUNC],[AC_CHECK_FUNC([$1],[
113   AC_SEARCH_LIBS([$1],,
114   [$2],[$3])
115 ],[$3])])
118 # GIT_STASH_FLAGS(BASEPATH_VAR)
119 # -----------------------------
120 # Allow for easy stashing of LDFLAGS and CPPFLAGS before running
121 # tests that may want to take user settings into account.
122 AC_DEFUN([GIT_STASH_FLAGS],[
123 if test -n "$1"; then
124    old_CPPFLAGS="$CPPFLAGS"
125    old_LDFLAGS="$LDFLAGS"
126    CPPFLAGS="-I$1/include $CPPFLAGS"
127    LDFLAGS="-L$1/$lib $LDFLAGS"
132 dnl GIT_UNSTASH_FLAGS(BASEPATH_VAR)
133 dnl -----------------------------
134 dnl Restore the stashed *FLAGS values.
135 AC_DEFUN([GIT_UNSTASH_FLAGS],[
136 if test -n "$1"; then
137    CPPFLAGS="$old_CPPFLAGS"
138    LDFLAGS="$old_LDFLAGS"
142 ## Configure body starts here.
144 AC_PREREQ(2.59)
145 AC_INIT([git], [@@GIT_VERSION@@], [git@vger.kernel.org])
147 AC_CONFIG_SRCDIR([git.c])
149 config_file=config.mak.autogen
150 config_in=config.mak.in
152 GIT_CONF_SUBST([AUTOCONFIGURED], [YesPlease])
154 # Directories holding "saner" versions of common or POSIX binaries.
155 AC_ARG_WITH([sane-tool-path],
156   [AS_HELP_STRING(
157     [--with-sane-tool-path=DIR-1[[:DIR-2...:DIR-n]]],
158     [Directories to prepend to PATH in build system and generated scripts])],
159   [if test "$withval" = "no"; then
160     withval=''
161   else
162     AC_MSG_NOTICE([Setting SANE_TOOL_PATH to '$withval'])
163   fi
164   GIT_CONF_SUBST([SANE_TOOL_PATH], [$withval])],
165   [# If the "--with-sane-tool-path" option was not given, don't touch
166    # SANE_TOOL_PATH here, but let defaults in Makefile take care of it.
167    # This should minimize spurious differences in the behaviour of the
168    # Git build system when configure is used w.r.t. when it is not.
169    :])
171 ## Site configuration related to programs (before tests)
172 ## --with-PACKAGE[=ARG] and --without-PACKAGE
174 # Set lib to alternative name of lib directory (e.g. lib64)
175 AC_ARG_WITH([lib],
176  [AS_HELP_STRING([--with-lib=ARG],
177                  [ARG specifies alternative name for lib directory])],
178  [if test "$withval" = "no" || test "$withval" = "yes"; then
179         AC_MSG_WARN([You should provide name for --with-lib=ARG])
180   else
181         lib=$withval
182         AC_MSG_NOTICE([Setting lib to '$lib'])
183         GIT_CONF_SUBST([lib])
184   fi])
186 if test -z "$lib"; then
187    AC_MSG_NOTICE([Setting lib to 'lib' (the default)])
188    lib=lib
191 AC_ARG_ENABLE([pthreads],
192  [AS_HELP_STRING([--enable-pthreads=FLAGS],
193   [FLAGS is the value to pass to the compiler to enable POSIX Threads.]
194   [The default if FLAGS is not specified is to try first -pthread]
195   [and then -lpthread.]
196   [--disable-pthreads will disable threading.])],
198 if test "x$enableval" = "xyes"; then
199    AC_MSG_NOTICE([Will try -pthread then -lpthread to enable POSIX Threads])
200 elif test "x$enableval" != "xno"; then
201    PTHREAD_CFLAGS=$enableval
202    AC_MSG_NOTICE([Setting '$PTHREAD_CFLAGS' as the FLAGS to enable POSIX Threads])
203 else
204    AC_MSG_NOTICE([POSIX Threads will be disabled.])
205    NO_PTHREADS=YesPlease
206    USER_NOPTHREAD=1
207 fi],
209    AC_MSG_NOTICE([Will try -pthread then -lpthread to enable POSIX Threads.])
212 # Define option to enable JavaScript minification
213 AC_ARG_ENABLE([jsmin],
214 [AS_HELP_STRING([--enable-jsmin=PATH],
215   [PATH is the name of a JavaScript minifier or the absolute path to one.])],
217   JSMIN=$enableval;
218   AC_MSG_NOTICE([Setting JSMIN to '$JSMIN' to enable JavaScript minifying])
219   GIT_CONF_SUBST([JSMIN])
222 # Define option to enable CSS minification
223 AC_ARG_ENABLE([cssmin],
224 [AS_HELP_STRING([--enable-cssmin=PATH],
225   [PATH is the name of a CSS minifier or the absolute path to one.])],
227   CSSMIN=$enableval;
228   AC_MSG_NOTICE([Setting CSSMIN to '$CSSMIN' to enable CSS minifying])
229   GIT_CONF_SUBST([CSSMIN])
232 ## Site configuration (override autodetection)
233 ## --with-PACKAGE[=ARG] and --without-PACKAGE
234 AC_MSG_NOTICE([CHECKS for site configuration])
236 # Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
237 # tests.  These tests take up a significant amount of the total test time
238 # but are not needed unless you plan to talk to SVN repos.
240 # Define PPC_SHA1 environment variable when running make to make use of
241 # a bundled SHA1 routine optimized for PowerPC.
243 # Define NO_OPENSSL environment variable if you do not have OpenSSL.
244 # This also implies BLK_SHA1.
246 # Define OPENSSLDIR=/foo/bar if your openssl header and library files are in
247 # /foo/bar/include and /foo/bar/lib directories.
248 AC_ARG_WITH(openssl,
249 AS_HELP_STRING([--with-openssl],[use OpenSSL library (default is YES)])
250 AS_HELP_STRING([],              [ARG can be prefix for openssl library and headers]),
251 GIT_PARSE_WITH([openssl]))
253 # Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be
254 # able to use Perl-compatible regular expressions.
256 # Define LIBPCREDIR=/foo/bar if your libpcre header and library files are in
257 # /foo/bar/include and /foo/bar/lib directories.
259 AC_ARG_WITH(libpcre,
260 AS_HELP_STRING([--with-libpcre],[support Perl-compatible regexes (default is NO)])
261 AS_HELP_STRING([],           [ARG can be also prefix for libpcre library and headers]),
262     if test "$withval" = "no"; then
263         USE_LIBPCRE=
264     elif test "$withval" = "yes"; then
265         USE_LIBPCRE=YesPlease
266     else
267         USE_LIBPCRE=YesPlease
268         LIBPCREDIR=$withval
269         AC_MSG_NOTICE([Setting LIBPCREDIR to $LIBPCREDIR])
270         dnl USE_LIBPCRE can still be modified below, so don't substitute
271         dnl it yet.
272         GIT_CONF_SUBST([LIBPCREDIR])
273     fi)
275 # Define HAVE_ALLOCA_H if you have working alloca(3) defined in that header.
276 AC_FUNC_ALLOCA
277 case $ac_cv_working_alloca_h in
278     yes)    HAVE_ALLOCA_H=YesPlease;;
279     *)      HAVE_ALLOCA_H='';;
280 esac
281 GIT_CONF_SUBST([HAVE_ALLOCA_H])
283 # Define NO_CURL if you do not have curl installed.  git-http-pull and
284 # git-http-push are not built, and you cannot use http:// and https://
285 # transports.
287 # Define CURLDIR=/foo/bar if your curl header and library files are in
288 # /foo/bar/include and /foo/bar/lib directories.
289 AC_ARG_WITH(curl,
290 AS_HELP_STRING([--with-curl],[support http(s):// transports (default is YES)])
291 AS_HELP_STRING([],           [ARG can be also prefix for curl library and headers]),
292 GIT_PARSE_WITH(curl))
294 # Define NO_EXPAT if you do not have expat installed.  git-http-push is
295 # not built, and you cannot push using http:// and https:// transports.
297 # Define EXPATDIR=/foo/bar if your expat header and library files are in
298 # /foo/bar/include and /foo/bar/lib directories.
299 AC_ARG_WITH(expat,
300 AS_HELP_STRING([--with-expat],
301 [support git-push using http:// and https:// transports via WebDAV (default is YES)])
302 AS_HELP_STRING([],            [ARG can be also prefix for expat library and headers]),
303 GIT_PARSE_WITH(expat))
305 # Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
306 # installed in /sw, but don't want GIT to link against any libraries
307 # installed there.  If defined you may specify your own (or Fink's)
308 # include directories and library directories by defining CFLAGS
309 # and LDFLAGS appropriately.
311 # Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
312 # have DarwinPorts installed in /opt/local, but don't want GIT to
313 # link against any libraries installed there.  If defined you may
314 # specify your own (or DarwinPort's) include directories and
315 # library directories by defining CFLAGS and LDFLAGS appropriately.
317 # Define NO_MMAP if you want to avoid mmap.
319 # Define NO_ICONV if your libc does not properly support iconv.
320 AC_ARG_WITH(iconv,
321 AS_HELP_STRING([--without-iconv],
322 [if your architecture doesn't properly support iconv])
323 AS_HELP_STRING([--with-iconv=PATH],
324 [PATH is prefix for libiconv library and headers])
325 AS_HELP_STRING([],
326 [used only if you need linking with libiconv]),
327 GIT_PARSE_WITH(iconv))
329 ## --enable-FEATURE[=ARG] and --disable-FEATURE
331 # Define USE_NSEC below if you want git to care about sub-second file mtimes
332 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
333 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
334 # randomly break unless your underlying filesystem supports those sub-second
335 # times (my ext3 doesn't).
337 # Define USE_STDEV below if you want git to care about the underlying device
338 # change being considered an inode change from the update-index perspective.
341 # Allow user to set ETC_GITCONFIG variable
342 GIT_PARSE_WITH_SET_MAKE_VAR(gitconfig, ETC_GITCONFIG,
343                         Use VALUE instead of /etc/gitconfig as the
344                         global git configuration file.
345                         If VALUE is not fully qualified it will be interpreted
346                         as a path relative to the computed prefix at runtime.)
349 # Allow user to set ETC_GITATTRIBUTES variable
350 GIT_PARSE_WITH_SET_MAKE_VAR(gitattributes, ETC_GITATTRIBUTES,
351                         Use VALUE instead of /etc/gitattributes as the
352                         global git attributes file.
353                         If VALUE is not fully qualified it will be interpreted
354                         as a path relative to the computed prefix at runtime.)
357 # Allow user to set the default pager
358 GIT_PARSE_WITH_SET_MAKE_VAR(pager, DEFAULT_PAGER,
359                         Use VALUE as the fall-back pager instead of 'less'.
360                         This is used by things like 'git log' when the user
361                         does not specify a pager to use through alternate
362                         methods. eg: /usr/bin/pager)
364 # Allow user to set the default editor
365 GIT_PARSE_WITH_SET_MAKE_VAR(editor, DEFAULT_EDITOR,
366                         Use VALUE as the fall-back editor instead of 'vi'.
367                         This is used by things like 'git commit' when the user
368                         does not specify a preferred editor through other
369                         methods. eg: /usr/bin/editor)
372 # Define SHELL_PATH to provide path to shell.
373 GIT_ARG_SET_PATH(shell)
375 # Define PERL_PATH to provide path to Perl.
376 GIT_ARG_SET_PATH(perl)
378 # Define PYTHON_PATH to provide path to Python.
379 GIT_ARG_SET_PATH(python, allow-without)
381 # Define ZLIB_PATH to provide path to zlib.
382 GIT_ARG_SET_PATH(zlib)
384 # Declare the with-tcltk/without-tcltk options.
385 AC_ARG_WITH(tcltk,
386 AS_HELP_STRING([--with-tcltk],[use Tcl/Tk GUI (default is YES)])
387 AS_HELP_STRING([],[ARG is the full path to the Tcl/Tk interpreter.])
388 AS_HELP_STRING([],[Bare --with-tcltk will make the GUI part only if])
389 AS_HELP_STRING([],[Tcl/Tk interpreter will be found in a system.]),
390 GIT_PARSE_WITH(tcltk))
394 ## Checks for programs.
395 AC_MSG_NOTICE([CHECKS for programs])
397 AC_PROG_CC([cc gcc])
398 AC_C_INLINE
399 case $ac_cv_c_inline in
400   inline | yes | no) INLINE='';;
401   *)                 INLINE=$ac_cv_c_inline ;;
402 esac
403 GIT_CONF_SUBST([INLINE])
405 # which switch to pass runtime path to dynamic libraries to the linker
406 AC_CACHE_CHECK([if linker supports -R], git_cv_ld_dashr, [
407    SAVE_LDFLAGS="${LDFLAGS}"
408    LDFLAGS="${SAVE_LDFLAGS} -R /"
409    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [git_cv_ld_dashr=yes], [git_cv_ld_dashr=no])
410    LDFLAGS="${SAVE_LDFLAGS}"
412 if test "$git_cv_ld_dashr" = "yes"; then
413    CC_LD_DYNPATH=-R
414 else
415    AC_CACHE_CHECK([if linker supports -Wl,-rpath,], git_cv_ld_wl_rpath, [
416       SAVE_LDFLAGS="${LDFLAGS}"
417       LDFLAGS="${SAVE_LDFLAGS} -Wl,-rpath,/"
418       AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [git_cv_ld_wl_rpath=yes], [git_cv_ld_wl_rpath=no])
419       LDFLAGS="${SAVE_LDFLAGS}"
420    ])
421    if test "$git_cv_ld_wl_rpath" = "yes"; then
422       CC_LD_DYNPATH=-Wl,-rpath,
423    else
424       AC_CACHE_CHECK([if linker supports -rpath], git_cv_ld_rpath, [
425          SAVE_LDFLAGS="${LDFLAGS}"
426          LDFLAGS="${SAVE_LDFLAGS} -rpath /"
427          AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [git_cv_ld_rpath=yes], [git_cv_ld_rpath=no])
428          LDFLAGS="${SAVE_LDFLAGS}"
429       ])
430       if test "$git_cv_ld_rpath" = "yes"; then
431          CC_LD_DYNPATH=-rpath
432       else
433          CC_LD_DYNPATH=
434          AC_MSG_WARN([linker does not support runtime path to dynamic libraries])
435       fi
436    fi
438 GIT_CONF_SUBST([CC_LD_DYNPATH])
439 #AC_PROG_INSTALL                # needs install-sh or install.sh in sources
440 AC_CHECK_TOOLS(AR, [gar ar], :)
441 AC_CHECK_PROGS(TAR, [gtar tar])
442 AC_CHECK_PROGS(DIFF, [gnudiff gdiff diff])
443 # TCLTK_PATH will be set to some value if we want Tcl/Tk
444 # or will be empty otherwise.
445 if test -n "$NO_TCLTK"; then
446   TCLTK_PATH=
447 else
448   if test "$with_tcltk" = ""; then
449   # No Tcl/Tk switches given. Do not check for Tcl/Tk, use bare 'wish'.
450     TCLTK_PATH=wish
451   elif test "$with_tcltk" = "yes"; then
452   # Tcl/Tk check requested.
453     AC_CHECK_PROGS(TCLTK_PATH, [wish], )
454   else
455     AC_MSG_RESULT([Using Tcl/Tk interpreter $with_tcltk])
456     TCLTK_PATH="$with_tcltk"
457   fi
459 GIT_CONF_SUBST([TCLTK_PATH])
460 AC_CHECK_PROGS(ASCIIDOC, [asciidoc])
461 if test -n "$ASCIIDOC"; then
462         AC_MSG_CHECKING([for asciidoc version])
463         asciidoc_version=`$ASCIIDOC --version 2>/dev/null`
464         case "${asciidoc_version}" in
465         asciidoc' '8*)
466                 AC_MSG_RESULT([${asciidoc_version}])
467                 ;;
468         *)
469                 AC_MSG_RESULT([${asciidoc_version} (unknown)])
470                 ;;
471         esac
474 if grep -a ascii configure.ac >/dev/null; then
475   AC_MSG_RESULT([Using 'grep -a' for sane_grep])
476   SANE_TEXT_GREP=-a
477 else
478   SANE_TEXT_GREP=
480 GIT_CONF_SUBST([SANE_TEXT_GREP])
482 ## Checks for libraries.
483 AC_MSG_NOTICE([CHECKS for libraries])
485 # Define NO_OPENSSL environment variable if you do not have OpenSSL.
486 # Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
488 GIT_STASH_FLAGS($OPENSSLDIR)
490 AC_CHECK_LIB([crypto], [SHA1_Init],
491 [NEEDS_SSL_WITH_CRYPTO=],
492 [AC_CHECK_LIB([ssl], [SHA1_Init],
493  [NEEDS_SSL_WITH_CRYPTO=YesPlease NO_OPENSSL=],
494  [NEEDS_SSL_WITH_CRYPTO=          NO_OPENSSL=YesPlease])])
496 GIT_UNSTASH_FLAGS($OPENSSLDIR)
498 GIT_CONF_SUBST([NEEDS_SSL_WITH_CRYPTO])
499 GIT_CONF_SUBST([NO_OPENSSL])
502 # Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be
503 # able to use Perl-compatible regular expressions.
506 if test -n "$USE_LIBPCRE"; then
508 GIT_STASH_FLAGS($LIBPCREDIR)
510 AC_CHECK_LIB([pcre], [pcre_version],
511 [USE_LIBPCRE=YesPlease],
512 [USE_LIBPCRE=])
514 GIT_UNSTASH_FLAGS($LIBPCREDIR)
516 GIT_CONF_SUBST([USE_LIBPCRE])
521 # Define NO_CURL if you do not have libcurl installed.  git-http-pull and
522 # git-http-push are not built, and you cannot use http:// and https://
523 # transports.
525 GIT_STASH_FLAGS($CURLDIR)
527 AC_CHECK_LIB([curl], [curl_global_init],
528 [NO_CURL=],
529 [NO_CURL=YesPlease])
531 if test -z "${NO_CURL}" && test -z "${NO_OPENSSL}"; then
533 AC_CHECK_LIB([curl], [Curl_ssl_init],
534 [NEEDS_SSL_WITH_CURL=YesPlease],
535 [NEEDS_SSL_WITH_CURL=])
537 GIT_CONF_SUBST([NEEDS_SSL_WITH_CURL])
541 GIT_UNSTASH_FLAGS($CURLDIR)
543 GIT_CONF_SUBST([NO_CURL])
545 if test -z "$NO_CURL"; then
547 AC_CHECK_PROG([CURL_CONFIG], [curl-config],
548 [curl-config],
549 [no])
551 if test $CURL_CONFIG != no; then
552     GIT_CONF_SUBST([CURL_CONFIG])
559 # Define NO_EXPAT if you do not have expat installed.  git-http-push is
560 # not built, and you cannot push using http:// and https:// transports.
562 GIT_STASH_FLAGS($EXPATDIR)
564 AC_CHECK_LIB([expat], [XML_ParserCreate],
565 [NO_EXPAT=],
566 [NO_EXPAT=YesPlease])
568 GIT_UNSTASH_FLAGS($EXPATDIR)
570 GIT_CONF_SUBST([NO_EXPAT])
573 # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin and
574 # some Solaris installations).
575 # Define NO_ICONV if neither libc nor libiconv support iconv.
577 if test -z "$NO_ICONV"; then
579 GIT_STASH_FLAGS($ICONVDIR)
581 AC_DEFUN([ICONVTEST_SRC],
582 [AC_LANG_PROGRAM([#include <iconv.h>],
583  [iconv_open("", "");])])
585 if test -n "$ICONVDIR"; then
586    lib_order="-liconv -lc"
587 else
588    lib_order="-lc -liconv"
591 NO_ICONV=YesPlease
593 for l in $lib_order; do
594     if test "$l" = "-liconv"; then
595        NEEDS_LIBICONV=YesPlease
596     else
597        NEEDS_LIBICONV=
598     fi
600     old_LIBS="$LIBS"
601     LIBS="$LIBS $l"
602     AC_MSG_CHECKING([for iconv in $l])
603     AC_LINK_IFELSE([ICONVTEST_SRC],
604         [AC_MSG_RESULT([yes])
605         NO_ICONV=
606         break],
607         [AC_MSG_RESULT([no])])
608     LIBS="$old_LIBS"
609 done
611 #in case of break
612 LIBS="$old_LIBS"
614 GIT_UNSTASH_FLAGS($ICONVDIR)
616 GIT_CONF_SUBST([NEEDS_LIBICONV])
617 GIT_CONF_SUBST([NO_ICONV])
619 if test -n "$NO_ICONV"; then
620     NEEDS_LIBICONV=
626 # Define NO_DEFLATE_BOUND if deflateBound is missing from zlib.
628 GIT_STASH_FLAGS($ZLIB_PATH)
630 AC_DEFUN([ZLIBTEST_SRC], [
631 AC_LANG_PROGRAM([#include <zlib.h>],
632  [deflateBound(0, 0);])])
633 AC_MSG_CHECKING([for deflateBound in -lz])
634 old_LIBS="$LIBS"
635 LIBS="$LIBS -lz"
636 AC_LINK_IFELSE([ZLIBTEST_SRC],
637         [AC_MSG_RESULT([yes])],
638         [AC_MSG_RESULT([no])
639         NO_DEFLATE_BOUND=yes])
640 LIBS="$old_LIBS"
642 GIT_UNSTASH_FLAGS($ZLIB_PATH)
644 GIT_CONF_SUBST([NO_DEFLATE_BOUND])
647 # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
648 # Patrick Mauritz).
649 AC_CHECK_LIB([c], [socket],
650 [NEEDS_SOCKET=],
651 [NEEDS_SOCKET=YesPlease])
652 GIT_CONF_SUBST([NEEDS_SOCKET])
653 test -n "$NEEDS_SOCKET" && LIBS="$LIBS -lsocket"
656 # The next few tests will define NEEDS_RESOLV if linking with
657 # libresolv provides some of the functions we would normally get
658 # from libc.
659 NEEDS_RESOLV=
661 # Define NO_INET_NTOP if linking with -lresolv is not enough.
662 # Solaris 2.7 in particular hos inet_ntop in -lresolv.
663 NO_INET_NTOP=
664 AC_CHECK_FUNC([inet_ntop],
665     [],
666     [AC_CHECK_LIB([resolv], [inet_ntop],
667         [NEEDS_RESOLV=YesPlease],
668         [NO_INET_NTOP=YesPlease])
670 GIT_CONF_SUBST([NO_INET_NTOP])
672 # Define NO_INET_PTON if linking with -lresolv is not enough.
673 # Solaris 2.7 in particular hos inet_pton in -lresolv.
674 NO_INET_PTON=
675 AC_CHECK_FUNC([inet_pton],
676     [],
677     [AC_CHECK_LIB([resolv], [inet_pton],
678         [NEEDS_RESOLV=YesPlease],
679         [NO_INET_PTON=YesPlease])
681 GIT_CONF_SUBST([NO_INET_PTON])
683 # Define NO_HSTRERROR if linking with -lresolv is not enough.
684 # Solaris 2.6 in particular has no hstrerror, even in -lresolv.
685 NO_HSTRERROR=
686 AC_CHECK_FUNC([hstrerror],
687     [],
688     [AC_CHECK_LIB([resolv], [hstrerror],
689         [NEEDS_RESOLV=YesPlease],
690         [NO_HSTRERROR=YesPlease])
692 GIT_CONF_SUBST([NO_HSTRERROR])
694 dnl This must go after all the possible places for its initialization,
695 dnl in the AC_CHECK_FUNC invocations above.
696 GIT_CONF_SUBST([NEEDS_RESOLV])
698 # If any of the above tests determined that -lresolv is needed at
699 # build-time, also set it here for remaining configure-time checks.
700 test -n "$NEEDS_RESOLV" && LIBS="$LIBS -lresolv"
702 AC_CHECK_LIB([c], [basename],
703 [NEEDS_LIBGEN=],
704 [NEEDS_LIBGEN=YesPlease])
705 GIT_CONF_SUBST([NEEDS_LIBGEN])
706 test -n "$NEEDS_LIBGEN" && LIBS="$LIBS -lgen"
708 AC_CHECK_LIB([c], [gettext],
709 [LIBC_CONTAINS_LIBINTL=YesPlease],
710 [LIBC_CONTAINS_LIBINTL=])
711 GIT_CONF_SUBST([LIBC_CONTAINS_LIBINTL])
714 # Define NO_GETTEXT if you don't want Git output to be translated.
715 # A translated Git requires GNU libintl or another gettext implementation
716 AC_CHECK_HEADER([libintl.h],
717 [NO_GETTEXT=],
718 [NO_GETTEXT=YesPlease])
719 GIT_CONF_SUBST([NO_GETTEXT])
721 if test -z "$NO_GETTEXT"; then
722     test -n "$LIBC_CONTAINS_LIBINTL" || LIBS="$LIBS -lintl"
725 ## Checks for header files.
726 AC_MSG_NOTICE([CHECKS for header files])
728 # Define NO_SYS_SELECT_H if you don't have sys/select.h.
729 AC_CHECK_HEADER([sys/select.h],
730 [NO_SYS_SELECT_H=],
731 [NO_SYS_SELECT_H=UnfortunatelyYes])
732 GIT_CONF_SUBST([NO_SYS_SELECT_H])
734 # Define NO_SYS_POLL_H if you don't have sys/poll.h
735 AC_CHECK_HEADER([sys/poll.h],
736 [NO_SYS_POLL_H=],
737 [NO_SYS_POLL_H=UnfortunatelyYes])
738 GIT_CONF_SUBST([NO_SYS_POLL_H])
740 # Define NO_INTTYPES_H if you don't have inttypes.h
741 AC_CHECK_HEADER([inttypes.h],
742 [NO_INTTYPES_H=],
743 [NO_INTTYPES_H=UnfortunatelyYes])
744 GIT_CONF_SUBST([NO_INTTYPES_H])
746 # Define OLD_ICONV if your library has an old iconv(), where the second
747 # (input buffer pointer) parameter is declared with type (const char **).
748 AC_DEFUN([OLDICONVTEST_SRC], [
749 AC_LANG_PROGRAM([[
750 #include <iconv.h>
752 extern size_t iconv(iconv_t cd,
753                     char **inbuf, size_t *inbytesleft,
754                     char **outbuf, size_t *outbytesleft);
755 ]], [])])
757 GIT_STASH_FLAGS($ICONVDIR)
759 AC_MSG_CHECKING([for old iconv()])
760 AC_COMPILE_IFELSE([OLDICONVTEST_SRC],
761         [AC_MSG_RESULT([no])],
762         [AC_MSG_RESULT([yes])
763         OLD_ICONV=UnfortunatelyYes])
765 GIT_UNSTASH_FLAGS($ICONVDIR)
767 GIT_CONF_SUBST([OLD_ICONV])
769 ## Checks for typedefs, structures, and compiler characteristics.
770 AC_MSG_NOTICE([CHECKS for typedefs, structures, and compiler characteristics])
772 TYPE_SOCKLEN_T
773 case $ac_cv_type_socklen_t in
774   yes)  SOCKLEN_T='';;
775   *)    SOCKLEN_T=$git_cv_socklen_t_equiv;;
776 esac
777 GIT_CONF_SUBST([SOCKLEN_T])
780 # Define NO_STRUCT_ITIMERVAL if you don't have struct itimerval.
781 AC_CHECK_TYPES([struct itimerval],
782 [NO_STRUCT_ITIMERVAL=],
783 [NO_STRUCT_ITIMERVAL=UnfortunatelyYes],
784 [#include <sys/time.h>])
785 GIT_CONF_SUBST([NO_STRUCT_ITIMERVAL])
787 # Define USE_ST_TIMESPEC=YesPlease when stat.st_mtimespec.tv_nsec exists.
788 # Define NO_NSEC=YesPlease when neither stat.st_mtim.tv_nsec nor
789 # stat.st_mtimespec.tv_nsec exists.
790 AC_CHECK_MEMBER([struct stat.st_mtimespec.tv_nsec])
791 AC_CHECK_MEMBER([struct stat.st_mtim.tv_nsec])
792 if test x$ac_cv_member_struct_stat_st_mtimespec_tv_nsec = xyes; then
793         USE_ST_TIMESPEC=YesPlease
794         GIT_CONF_SUBST([USE_ST_TIMESPEC])
795 elif test x$ac_cv_member_struct_stat_st_mtim_tv_nsec != xyes; then
796         NO_NSEC=YesPlease
797         GIT_CONF_SUBST([NO_NSEC])
800 # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
801 # d_type in struct dirent (latest Cygwin -- will be fixed soonish).
802 AC_CHECK_MEMBER(struct dirent.d_type,
803 [NO_D_TYPE_IN_DIRENT=],
804 [NO_D_TYPE_IN_DIRENT=YesPlease],
805 [#include <dirent.h>])
806 GIT_CONF_SUBST([NO_D_TYPE_IN_DIRENT])
808 # Define NO_GECOS_IN_PWENT if you don't have pw_gecos in struct passwd
809 # in the C library.
810 AC_CHECK_MEMBER(struct passwd.pw_gecos,
811 [NO_GECOS_IN_PWENT=],
812 [NO_GECOS_IN_PWENT=YesPlease],
813 [#include <pwd.h>])
814 GIT_CONF_SUBST([NO_GECOS_IN_PWENT])
816 # Define NO_SOCKADDR_STORAGE if your platform does not have struct
817 # sockaddr_storage.
818 AC_CHECK_TYPE(struct sockaddr_storage,
819 [NO_SOCKADDR_STORAGE=],
820 [NO_SOCKADDR_STORAGE=YesPlease],[
821 #include <sys/types.h>
822 #include <sys/socket.h>
824 GIT_CONF_SUBST([NO_SOCKADDR_STORAGE])
826 # Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
827 AC_CHECK_TYPE([struct addrinfo],[
828  GIT_CHECK_FUNC([getaddrinfo],
829   [NO_IPV6=],
830   [NO_IPV6=YesPlease])
831 ],[NO_IPV6=YesPlease],[
832 #include <sys/types.h>
833 #include <sys/socket.h>
834 #include <netdb.h>
836 GIT_CONF_SUBST([NO_IPV6])
838 # Define NO_REGEX if you have no or inferior regex support in your C library.
839 AC_CACHE_CHECK([whether the platform regex can handle null bytes],
840  [ac_cv_c_excellent_regex], [
841 AC_EGREP_CPP(yippeeyeswehaveit,
842         AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
843 #include <regex.h>
845 [#ifdef REG_STARTEND
846 yippeeyeswehaveit
847 #endif
849         [ac_cv_c_excellent_regex=yes],
850         [ac_cv_c_excellent_regex=no])
852 if test $ac_cv_c_excellent_regex = yes; then
853         NO_REGEX=
854 else
855         NO_REGEX=YesPlease
857 GIT_CONF_SUBST([NO_REGEX])
859 # Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
860 # when attempting to read from an fopen'ed directory.
861 AC_CACHE_CHECK([whether system succeeds to read fopen'ed directory],
862  [ac_cv_fread_reads_directories],
864 AC_RUN_IFELSE(
865         [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
866                 [[char c;
867                 FILE *f = fopen(".", "r");
868                 return f && fread(&c, 1, 1, f)]])],
869         [ac_cv_fread_reads_directories=no],
870         [ac_cv_fread_reads_directories=yes])
872 if test $ac_cv_fread_reads_directories = yes; then
873         FREAD_READS_DIRECTORIES=UnfortunatelyYes
874 else
875         FREAD_READS_DIRECTORIES=
877 GIT_CONF_SUBST([FREAD_READS_DIRECTORIES])
879 # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
880 # or vsnprintf() return -1 instead of number of characters which would
881 # have been written to the final string if enough space had been available.
882 AC_CACHE_CHECK([whether snprintf() and/or vsnprintf() return bogus value],
883  [ac_cv_snprintf_returns_bogus],
885 AC_RUN_IFELSE(
886         [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
887                 #include "stdarg.h"
889                 int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
890                 {
891                   int ret;
892                   va_list ap;
893                   va_start(ap, format);
894                   ret = vsnprintf(str, maxsize, format, ap);
895                   va_end(ap);
896                   return ret;
897                 }],
898                 [[char buf[6];
899                   if (test_vsnprintf(buf, 3, "%s", "12345") != 5
900                       || strcmp(buf, "12")) return 1;
901                   if (snprintf(buf, 3, "%s", "12345") != 5
902                       || strcmp(buf, "12")) return 1]])],
903         [ac_cv_snprintf_returns_bogus=no],
904         [ac_cv_snprintf_returns_bogus=yes])
906 if test $ac_cv_snprintf_returns_bogus = yes; then
907         SNPRINTF_RETURNS_BOGUS=UnfortunatelyYes
908 else
909         SNPRINTF_RETURNS_BOGUS=
911 GIT_CONF_SUBST([SNPRINTF_RETURNS_BOGUS])
913 # Define NEEDS_MODE_TRANSLATION if your OS strays from the typical file type
914 # bits in mode values.
915 AC_CACHE_CHECK([whether the platform uses typical file type bits],
916  [ac_cv_sane_mode_bits], [
917 AC_EGREP_CPP(yippeeyeswehaveit,
918         AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
919 [#if S_IFMT == 0170000 && \
920         S_IFREG == 0100000 && S_IFDIR == 0040000 && S_IFLNK == 0120000 && \
921         S_IFBLK == 0060000 && S_IFCHR == 0020000 && \
922         S_IFIFO == 0010000 && S_IFSOCK == 0140000
923 yippeeyeswehaveit
924 #endif
926         [ac_cv_sane_mode_bits=yes],
927         [ac_cv_sane_mode_bits=no])
929 if test $ac_cv_sane_mode_bits = yes; then
930         NEEDS_MODE_TRANSLATION=
931 else
932         NEEDS_MODE_TRANSLATION=UnfortunatelyYes
934 GIT_CONF_SUBST([NEEDS_MODE_TRANSLATION])
937 ## Checks for library functions.
938 ## (in default C library and libraries checked by AC_CHECK_LIB)
939 AC_MSG_NOTICE([CHECKS for library functions])
941 # Define NO_LIBGEN_H if you don't have libgen.h.
942 AC_CHECK_HEADER([libgen.h],
943 [NO_LIBGEN_H=],
944 [NO_LIBGEN_H=YesPlease])
945 GIT_CONF_SUBST([NO_LIBGEN_H])
947 # Define HAVE_PATHS_H if you have paths.h.
948 AC_CHECK_HEADER([paths.h],
949 [HAVE_PATHS_H=YesPlease],
950 [HAVE_PATHS_H=])
951 GIT_CONF_SUBST([HAVE_PATHS_H])
953 # Define HAVE_LIBCHARSET_H if have libcharset.h
954 AC_CHECK_HEADER([libcharset.h],
955 [HAVE_LIBCHARSET_H=YesPlease],
956 [HAVE_LIBCHARSET_H=])
957 GIT_CONF_SUBST([HAVE_LIBCHARSET_H])
959 # Define HAVE_STRINGS_H if you have strings.h
960 AC_CHECK_HEADER([strings.h],
961 [HAVE_STRINGS_H=YesPlease],
962 [HAVE_STRINGS_H=])
963 GIT_CONF_SUBST([HAVE_STRINGS_H])
964 # Define CHARSET_LIB if libiconv does not export the locale_charset symbol
965 # and libcharset does
966 CHARSET_LIB=
967 AC_CHECK_LIB([iconv], [locale_charset],
968        [CHARSET_LIB=-liconv],
969        [AC_CHECK_LIB([charset], [locale_charset],
970                      [CHARSET_LIB=-lcharset])])
971 GIT_CONF_SUBST([CHARSET_LIB])
973 # Define NO_HMAC_CTX_CLEANUP=YesPlease if HMAC_CTX_cleanup is missing.
974 AC_CHECK_LIB([crypto], [HMAC_CTX_cleanup],
975         [], [GIT_CONF_SUBST([NO_HMAC_CTX_CLEANUP], [YesPlease])])
977 # Define HAVE_CLOCK_GETTIME=YesPlease if clock_gettime is available.
978 GIT_CHECK_FUNC(clock_gettime,
979         [HAVE_CLOCK_GETTIME=YesPlease],
980         [HAVE_CLOCK_GETTIME=])
981 GIT_CONF_SUBST([HAVE_CLOCK_GETTIME])
983 AC_DEFUN([CLOCK_MONOTONIC_SRC], [
984 AC_LANG_PROGRAM([[
985 #include <time.h>
986 clockid_t id = CLOCK_MONOTONIC;
987 ]])])
990 # Define HAVE_CLOCK_MONOTONIC=YesPlease if CLOCK_MONOTONIC is available.
991 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
992 AC_COMPILE_IFELSE([CLOCK_MONOTONIC_SRC],
993         [AC_MSG_RESULT([yes])
994         HAVE_CLOCK_MONOTONIC=YesPlease],
995         [AC_MSG_RESULT([no])
996         HAVE_CLOCK_MONOTONIC=])
997 GIT_CONF_SUBST([HAVE_CLOCK_MONOTONIC])
999 # Define NO_SETITIMER if you don't have setitimer.
1000 GIT_CHECK_FUNC(setitimer,
1001 [NO_SETITIMER=],
1002 [NO_SETITIMER=YesPlease])
1003 GIT_CONF_SUBST([NO_SETITIMER])
1005 # Define NO_STRCASESTR if you don't have strcasestr.
1006 GIT_CHECK_FUNC(strcasestr,
1007 [NO_STRCASESTR=],
1008 [NO_STRCASESTR=YesPlease])
1009 GIT_CONF_SUBST([NO_STRCASESTR])
1011 # Define NO_MEMMEM if you don't have memmem.
1012 GIT_CHECK_FUNC(memmem,
1013 [NO_MEMMEM=],
1014 [NO_MEMMEM=YesPlease])
1015 GIT_CONF_SUBST([NO_MEMMEM])
1017 # Define NO_STRLCPY if you don't have strlcpy.
1018 GIT_CHECK_FUNC(strlcpy,
1019 [NO_STRLCPY=],
1020 [NO_STRLCPY=YesPlease])
1021 GIT_CONF_SUBST([NO_STRLCPY])
1023 # Define NO_UINTMAX_T if your platform does not have uintmax_t
1024 AC_CHECK_TYPE(uintmax_t,
1025 [NO_UINTMAX_T=],
1026 [NO_UINTMAX_T=YesPlease],[
1027 #include <inttypes.h>
1029 GIT_CONF_SUBST([NO_UINTMAX_T])
1031 # Define NO_STRTOUMAX if you don't have strtoumax in the C library.
1032 GIT_CHECK_FUNC(strtoumax,
1033 [NO_STRTOUMAX=],
1034 [NO_STRTOUMAX=YesPlease])
1035 GIT_CONF_SUBST([NO_STRTOUMAX])
1037 # Define NO_SETENV if you don't have setenv in the C library.
1038 GIT_CHECK_FUNC(setenv,
1039 [NO_SETENV=],
1040 [NO_SETENV=YesPlease])
1041 GIT_CONF_SUBST([NO_SETENV])
1043 # Define NO_UNSETENV if you don't have unsetenv in the C library.
1044 GIT_CHECK_FUNC(unsetenv,
1045 [NO_UNSETENV=],
1046 [NO_UNSETENV=YesPlease])
1047 GIT_CONF_SUBST([NO_UNSETENV])
1049 # Define NO_MKDTEMP if you don't have mkdtemp in the C library.
1050 GIT_CHECK_FUNC(mkdtemp,
1051 [NO_MKDTEMP=],
1052 [NO_MKDTEMP=YesPlease])
1053 GIT_CONF_SUBST([NO_MKDTEMP])
1055 # Define NO_MKSTEMPS if you don't have mkstemps in the C library.
1056 GIT_CHECK_FUNC(mkstemps,
1057 [NO_MKSTEMPS=],
1058 [NO_MKSTEMPS=YesPlease])
1059 GIT_CONF_SUBST([NO_MKSTEMPS])
1061 # Define NO_INITGROUPS if you don't have initgroups in the C library.
1062 GIT_CHECK_FUNC(initgroups,
1063 [NO_INITGROUPS=],
1064 [NO_INITGROUPS=YesPlease])
1065 GIT_CONF_SUBST([NO_INITGROUPS])
1067 # Define HAVE_GETDELIM if you have getdelim in the C library.
1068 GIT_CHECK_FUNC(getdelim,
1069 [HAVE_GETDELIM=YesPlease],
1070 [HAVE_GETDELIM=])
1071 GIT_CONF_SUBST([HAVE_GETDELIM])
1074 # Define NO_MMAP if you want to avoid mmap.
1076 # Define NO_ICONV if your libc does not properly support iconv.
1078 AC_DEFUN([BSD_SYSCTL_SRC], [
1079 AC_LANG_PROGRAM([[
1080 #include <stddef.h>
1081 #include <sys/types.h>
1082 #include <sys/sysctl.h>
1083 ]],[[
1084 int val, mib[2];
1085 size_t len;
1086 mib[0] = CTL_HW;
1087 mib[1] = 1;
1088 len = sizeof(val);
1089 return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;
1090 ]])])
1093 # Define HAVE_BSD_SYSCTL=YesPlease if a BSD-compatible sysctl function is available.
1094 AC_MSG_CHECKING([for BSD sysctl])
1095 AC_COMPILE_IFELSE([BSD_SYSCTL_SRC],
1096         [AC_MSG_RESULT([yes])
1097         HAVE_BSD_SYSCTL=YesPlease],
1098         [AC_MSG_RESULT([no])
1099         HAVE_BSD_SYSCTL=])
1100 GIT_CONF_SUBST([HAVE_BSD_SYSCTL])
1102 ## Other checks.
1103 # Define USE_PIC if you need the main git objects to be built with -fPIC
1104 # in order to build and link perl/Git.so.  x86-64 seems to need this.
1106 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
1107 # Enable it on Windows.  By default, symrefs are still used.
1109 # Define NO_PTHREADS if we do not have pthreads.
1111 # Define PTHREAD_LIBS to the linker flag used for Pthread support.
1112 AC_DEFUN([PTHREADTEST_SRC], [
1113 AC_LANG_PROGRAM([[
1114 #include <pthread.h>
1115 ]], [[
1116         pthread_mutex_t test_mutex;
1117         pthread_key_t test_key;
1118         int retcode = 0;
1119         retcode |= pthread_key_create(&test_key, (void *)0);
1120         retcode |= pthread_mutex_init(&test_mutex,(void *)0);
1121         retcode |= pthread_mutex_lock(&test_mutex);
1122         retcode |= pthread_mutex_unlock(&test_mutex);
1123         return retcode;
1124 ]])])
1126 dnl AC_LANG_CONFTEST([AC_LANG_PROGRAM(
1127 dnl   [[#include <pthread.h>]],
1128 dnl   [[pthread_mutex_t test_mutex;]]
1129 dnl )])
1131 NO_PTHREADS=UnfortunatelyYes
1132 PTHREAD_LIBS=
1134 if test -n "$USER_NOPTHREAD"; then
1135    AC_MSG_NOTICE([Skipping POSIX Threads at user request.])
1136 # handle these separately since PTHREAD_CFLAGS could be '-lpthreads
1137 # -D_REENTRANT' or some such.
1138 elif test -z "$PTHREAD_CFLAGS"; then
1139   threads_found=no
1140   # Attempt to compile and link some code using pthreads to determine
1141   # required linker flags. The order is somewhat important here: We
1142   # first try it without any extra flags, to catch systems where
1143   # pthreads are part of the C library, then go on testing various other
1144   # flags. We do so to avoid false positives. For example, on Mac OS X
1145   # pthreads are part of the C library; moreover, the compiler allows us
1146   # to add "-mt" to the CFLAGS (although it will do nothing except
1147   # trigger a warning about an unused flag). Hence if we checked for
1148   # "-mt" before "" we would end up picking it. But unfortunately this
1149   # would then trigger compiler warnings on every single file we compile.
1150   for opt in "" -mt -pthread -lpthread; do
1151      old_CFLAGS="$CFLAGS"
1152      old_LIBS="$LIBS"
1153      case "$opt" in
1154         -l*)  LIBS="$opt $LIBS" ;;
1155         *)    CFLAGS="$opt $CFLAGS" ;;
1156      esac
1158      AC_MSG_CHECKING([for POSIX Threads with '$opt'])
1159      AC_LINK_IFELSE([PTHREADTEST_SRC],
1160         [AC_MSG_RESULT([yes])
1161                 NO_PTHREADS=
1162                 PTHREAD_LIBS="$opt"
1163                 PTHREAD_CFLAGS="$opt"
1164                 threads_found=yes
1165                 break
1166         ],
1167         [AC_MSG_RESULT([no])])
1168       CFLAGS="$old_CFLAGS"
1169       LIBS="$old_LIBS"
1170   done
1171   if test $threads_found != yes; then
1172     AC_CHECK_LIB([pthread], [pthread_create],
1173         [PTHREAD_LIBS="-lpthread"],
1174         [NO_PTHREADS=UnfortunatelyYes])
1175   fi
1176 else
1177   old_CFLAGS="$CFLAGS"
1178   CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
1179   AC_MSG_CHECKING([for POSIX Threads with '$PTHREAD_CFLAGS'])
1180   AC_LINK_IFELSE([PTHREADTEST_SRC],
1181         [AC_MSG_RESULT([yes])
1182                 NO_PTHREADS=
1183                 PTHREAD_LIBS="$PTHREAD_CFLAGS"
1184         ],
1185         [AC_MSG_RESULT([no])])
1187   CFLAGS="$old_CFLAGS"
1190 CFLAGS="$old_CFLAGS"
1192 GIT_CONF_SUBST([PTHREAD_CFLAGS])
1193 GIT_CONF_SUBST([PTHREAD_LIBS])
1194 GIT_CONF_SUBST([NO_PTHREADS])
1196 ## Output files
1197 AC_CONFIG_FILES(["${config_file}":"${config_in}"])
1198 AC_OUTPUT