configure: avoid some code repetitions thanks to m4_{push,pop}def
[git/debian.git] / configure.ac
blobe888601b1df8ba021ef566ecb5787573e3628156
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 ## Definitions of macros
5 # GIT_CONF_APPEND_LINE(LINE)
6 # --------------------------
7 # Append LINE to file ${config_append}
8 AC_DEFUN([GIT_CONF_APPEND_LINE],
9 [echo "$1" >> "${config_append}"])# GIT_CONF_APPEND_LINE
11 # GIT_ARG_SET_PATH(PROGRAM)
12 # -------------------------
13 # Provide --with-PROGRAM=PATH option to set PATH to PROGRAM
14 # Optional second argument allows setting NO_PROGRAM=YesPlease if
15 # --without-PROGRAM version used.
16 AC_DEFUN([GIT_ARG_SET_PATH],
17 [AC_ARG_WITH([$1],
18  [AS_HELP_STRING([--with-$1=PATH],
19                  [provide PATH to $1])],
20  [GIT_CONF_APPEND_PATH($1,$2)],[])
21 ])# GIT_ARG_SET_PATH
23 # GIT_CONF_APPEND_PATH(PROGRAM)
24 # ------------------------------
25 # Parse --with-PROGRAM=PATH option to set PROGRAM_PATH=PATH
26 # Used by GIT_ARG_SET_PATH(PROGRAM)
27 # Optional second argument allows setting NO_PROGRAM=YesPlease if
28 # --without-PROGRAM is used.
29 AC_DEFUN([GIT_CONF_APPEND_PATH],
30 [m4_pushdef([GIT_UC_PROGRAM], m4_toupper([$1]))dnl
31 PROGRAM=GIT_UC_PROGRAM; \
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 ${PROGRAM}]); \
36                 GIT_CONF_APPEND_LINE(NO_${PROGRAM}=YesPlease); \
37                 GIT_CONF_APPEND_LINE(${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_APPEND_LINE(${PROGRAM}_PATH=$withval); \
48         fi; \
49 fi; \
50 m4_popdef([GIT_UC_PROGRAM])]) # GIT_CONF_APPEND_PATH
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 PACKAGE=GIT_UC_PACKAGE; \
61 if test "$withval" = "no"; then \
62         NO_[]GIT_UC_PACKAGE=YesPlease; \
63 elif test "$withval" = "yes"; then \
64         NO_[]GIT_UC_PACKAGE=; \
65 else \
66         NO_[]GIT_UC_PACKAGE=; \
67         GIT_UC_PACKAGE[]DIR=$withval; \
68         AC_MSG_NOTICE([Setting GIT_UC_PACKAGE[]DIR to $withval]); \
69         GIT_CONF_APPEND_LINE(${PACKAGE}DIR=$withval); \
70 fi \
71 m4_popdef([GIT_UC_PACKAGE])]) # GIT_PARSE_WITH
73 # GIT_PARSE_WITH_SET_MAKE_VAR(WITHNAME, VAR, HELP_TEXT)
74 # ---------------------
75 # Set VAR to the value specied by --with-WITHNAME.
76 # No verification of arguments is performed, but warnings are issued
77 # if either 'yes' or 'no' is specified.
78 # HELP_TEXT is presented when --help is called.
79 # This is a direct way to allow setting variables in the Makefile.
80 AC_DEFUN([GIT_PARSE_WITH_SET_MAKE_VAR],
81 [AC_ARG_WITH([$1],
82  [AS_HELP_STRING([--with-$1=VALUE], $3)],
83  if test -n "$withval"; then \
84   if test "$withval" = "yes" -o "$withval" = "no"; then \
85     AC_MSG_WARN([You likely do not want either 'yes' or 'no' as]
86                      [a value for $1 ($2).  Maybe you do...?]); \
87   fi; \
88   \
89   AC_MSG_NOTICE([Setting $2 to $withval]); \
90   GIT_CONF_APPEND_LINE($2=$withval); \
91  fi)])# GIT_PARSE_WITH_SET_MAKE_VAR
93 dnl
94 dnl GIT_CHECK_FUNC(FUNCTION, IFTRUE, IFFALSE)
95 dnl -----------------------------------------
96 dnl Similar to AC_CHECK_FUNC, but on systems that do not generate
97 dnl warnings for missing prototypes (e.g. FreeBSD when compiling without
98 dnl -Wall), it does not work.  By looking for function definition in
99 dnl libraries, this problem can be worked around.
100 AC_DEFUN([GIT_CHECK_FUNC],[AC_CHECK_FUNC([$1],[
101   AC_SEARCH_LIBS([$1],,
102   [$2],[$3])
103 ],[$3])])
106 dnl GIT_STASH_FLAGS(BASEPATH_VAR)
107 dnl -----------------------------
108 dnl Allow for easy stashing of LDFLAGS and CPPFLAGS before running
109 dnl tests that may want to take user settings into account.
110 AC_DEFUN([GIT_STASH_FLAGS],[
111 if test -n "$1"; then
112    old_CPPFLAGS="$CPPFLAGS"
113    old_LDFLAGS="$LDFLAGS"
114    CPPFLAGS="-I$1/include $CPPFLAGS"
115    LDFLAGS="-L$1/$lib $LDFLAGS"
120 dnl GIT_UNSTASH_FLAGS(BASEPATH_VAR)
121 dnl -----------------------------
122 dnl Restore the stashed *FLAGS values.
123 AC_DEFUN([GIT_UNSTASH_FLAGS],[
124 if test -n "$1"; then
125    CPPFLAGS="$old_CPPFLAGS"
126    LDFLAGS="$old_LDFLAGS"
130 ## Configure body starts here.
132 AC_PREREQ(2.59)
133 AC_INIT([git], [@@GIT_VERSION@@], [git@vger.kernel.org])
135 AC_CONFIG_SRCDIR([git.c])
137 config_file=config.mak.autogen
138 config_append=config.mak.append
139 config_in=config.mak.in
141 echo "# ${config_append}.  Generated by configure." > "${config_append}"
143 # Directories holding "saner" versions of common or POSIX binaries.
144 AC_ARG_WITH([sane-tool-path],
145   [AS_HELP_STRING(
146     [--with-sane-tool-path=DIR-1[[:DIR-2...:DIR-n]]],
147     [Directories to prepend to PATH in build system and generated scripts])],
148   [if test "$withval" = "no"; then
149     withval=''
150   else
151     AC_MSG_NOTICE([Setting SANE_TOOL_PATH to '$withval'])
152   fi
153   GIT_CONF_APPEND_LINE([SANE_TOOL_PATH=$withval])],
154   [# If the "--with-sane-tool-path" option was not given, don't touch
155    # SANE_TOOL_PATH here, but let defaults in Makefile take care of it.
156    # This should minimize spurious differences in the behaviour of the
157    # Git build system when configure is used w.r.t. when it is not.
158    :])
160 ## Site configuration related to programs (before tests)
161 ## --with-PACKAGE[=ARG] and --without-PACKAGE
163 # Set lib to alternative name of lib directory (e.g. lib64)
164 AC_ARG_WITH([lib],
165  [AS_HELP_STRING([--with-lib=ARG],
166                  [ARG specifies alternative name for lib directory])],
167  [if test "$withval" = "no" || test "$withval" = "yes"; then \
168         AC_MSG_WARN([You should provide name for --with-lib=ARG]); \
169 else \
170         lib=$withval; \
171         AC_MSG_NOTICE([Setting lib to '$lib']); \
172         GIT_CONF_APPEND_LINE(lib=$withval); \
173 fi; \
174 ],[])
176 if test -z "$lib"; then
177    AC_MSG_NOTICE([Setting lib to 'lib' (the default)])
178    lib=lib
181 AC_ARG_ENABLE([pthreads],
182  [AS_HELP_STRING([--enable-pthreads=FLAGS],
183   [FLAGS is the value to pass to the compiler to enable POSIX Threads.]
184   [The default if FLAGS is not specified is to try first -pthread]
185   [and then -lpthread.]
186   [--without-pthreads will disable threading.])],
188 if test "x$enableval" = "xyes"; then
189    AC_MSG_NOTICE([Will try -pthread then -lpthread to enable POSIX Threads])
190 elif test "x$enableval" != "xno"; then
191    PTHREAD_CFLAGS=$enableval
192    AC_MSG_NOTICE([Setting '$PTHREAD_CFLAGS' as the FLAGS to enable POSIX Threads])
193 else
194    AC_MSG_NOTICE([POSIX Threads will be disabled.])
195    NO_PTHREADS=YesPlease
196    USER_NOPTHREAD=1
197 fi],
199    AC_MSG_NOTICE([Will try -pthread then -lpthread to enable POSIX Threads.])
202 # Define option to enable JavaScript minification
203 AC_ARG_ENABLE([jsmin],
204 [AS_HELP_STRING([--enable-jsmin=PATH],
205   [PATH is the name of a JavaScript minifier or the absolute path to one.])],
207   JSMIN=$enableval;
208   AC_MSG_NOTICE([Setting JSMIN to '$JSMIN' to enable JavaScript minifying])
209   GIT_CONF_APPEND_LINE(JSMIN=$enableval);
212 # Define option to enable CSS minification
213 AC_ARG_ENABLE([cssmin],
214 [AS_HELP_STRING([--enable-cssmin=PATH],
215   [PATH is the name of a CSS minifier or the absolute path to one.])],
217   CSSMIN=$enableval;
218   AC_MSG_NOTICE([Setting CSSMIN to '$CSSMIN' to enable CSS minifying])
219   GIT_CONF_APPEND_LINE(CSSMIN=$enableval);
222 ## Site configuration (override autodetection)
223 ## --with-PACKAGE[=ARG] and --without-PACKAGE
224 AC_MSG_NOTICE([CHECKS for site configuration])
226 # Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
227 # tests.  These tests take up a significant amount of the total test time
228 # but are not needed unless you plan to talk to SVN repos.
230 # Define PPC_SHA1 environment variable when running make to make use of
231 # a bundled SHA1 routine optimized for PowerPC.
233 # Define NO_OPENSSL environment variable if you do not have OpenSSL.
234 # This also implies BLK_SHA1.
236 # Define OPENSSLDIR=/foo/bar if your openssl header and library files are in
237 # /foo/bar/include and /foo/bar/lib directories.
238 AC_ARG_WITH(openssl,
239 AS_HELP_STRING([--with-openssl],[use OpenSSL library (default is YES)])
240 AS_HELP_STRING([],              [ARG can be prefix for openssl library and headers]),\
241 GIT_PARSE_WITH(openssl))
243 # Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be
244 # able to use Perl-compatible regular expressions.
246 # Define LIBPCREDIR=/foo/bar if your libpcre header and library files are in
247 # /foo/bar/include and /foo/bar/lib directories.
249 AC_ARG_WITH(libpcre,
250 AS_HELP_STRING([--with-libpcre],[support Perl-compatible regexes (default is NO)])
251 AS_HELP_STRING([],           [ARG can be also prefix for libpcre library and headers]),
252 if test "$withval" = "no"; then \
253         USE_LIBPCRE=; \
254 elif test "$withval" = "yes"; then \
255         USE_LIBPCRE=YesPlease; \
256 else
257         USE_LIBPCRE=YesPlease; \
258         LIBPCREDIR=$withval; \
259         AC_MSG_NOTICE([Setting LIBPCREDIR to $withval]); \
260         GIT_CONF_APPEND_LINE(LIBPCREDIR=$withval); \
261 fi \
264 # Define NO_CURL if you do not have curl installed.  git-http-pull and
265 # git-http-push are not built, and you cannot use http:// and https://
266 # transports.
268 # Define CURLDIR=/foo/bar if your curl header and library files are in
269 # /foo/bar/include and /foo/bar/lib directories.
270 AC_ARG_WITH(curl,
271 AS_HELP_STRING([--with-curl],[support http(s):// transports (default is YES)])
272 AS_HELP_STRING([],           [ARG can be also prefix for curl library and headers]),
273 GIT_PARSE_WITH(curl))
275 # Define NO_EXPAT if you do not have expat installed.  git-http-push is
276 # not built, and you cannot push using http:// and https:// transports.
278 # Define EXPATDIR=/foo/bar if your expat header and library files are in
279 # /foo/bar/include and /foo/bar/lib directories.
280 AC_ARG_WITH(expat,
281 AS_HELP_STRING([--with-expat],
282 [support git-push using http:// and https:// transports via WebDAV (default is YES)])
283 AS_HELP_STRING([],            [ARG can be also prefix for expat library and headers]),
284 GIT_PARSE_WITH(expat))
286 # Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
287 # installed in /sw, but don't want GIT to link against any libraries
288 # installed there.  If defined you may specify your own (or Fink's)
289 # include directories and library directories by defining CFLAGS
290 # and LDFLAGS appropriately.
292 # Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
293 # have DarwinPorts installed in /opt/local, but don't want GIT to
294 # link against any libraries installed there.  If defined you may
295 # specify your own (or DarwinPort's) include directories and
296 # library directories by defining CFLAGS and LDFLAGS appropriately.
298 # Define NO_MMAP if you want to avoid mmap.
300 # Define NO_ICONV if your libc does not properly support iconv.
301 AC_ARG_WITH(iconv,
302 AS_HELP_STRING([--without-iconv],
303 [if your architecture doesn't properly support iconv])
304 AS_HELP_STRING([--with-iconv=PATH],
305 [PATH is prefix for libiconv library and headers])
306 AS_HELP_STRING([],
307 [used only if you need linking with libiconv]),
308 GIT_PARSE_WITH(iconv))
310 ## --enable-FEATURE[=ARG] and --disable-FEATURE
312 # Define USE_NSEC below if you want git to care about sub-second file mtimes
313 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
314 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
315 # randomly break unless your underlying filesystem supports those sub-second
316 # times (my ext3 doesn't).
318 # Define USE_STDEV below if you want git to care about the underlying device
319 # change being considered an inode change from the update-index perspective.
322 # Allow user to set ETC_GITCONFIG variable
323 GIT_PARSE_WITH_SET_MAKE_VAR(gitconfig, ETC_GITCONFIG,
324                         Use VALUE instead of /etc/gitconfig as the
325                         global git configuration file.
326                         If VALUE is not fully qualified it will be interpreted
327                         as a path relative to the computed prefix at runtime.)
330 # Allow user to set ETC_GITATTRIBUTES variable
331 GIT_PARSE_WITH_SET_MAKE_VAR(gitattributes, ETC_GITATTRIBUTES,
332                         Use VALUE instead of /etc/gitattributes as the
333                         global git attributes file.
334                         If VALUE is not fully qualified it will be interpreted
335                         as a path relative to the computed prefix at runtime.)
338 # Allow user to set the default pager
339 GIT_PARSE_WITH_SET_MAKE_VAR(pager, DEFAULT_PAGER,
340                         Use VALUE as the fall-back pager instead of 'less'.
341                         This is used by things like 'git log' when the user
342                         does not specify a pager to use through alternate
343                         methods. eg: /usr/bin/pager)
345 # Allow user to set the default editor
346 GIT_PARSE_WITH_SET_MAKE_VAR(editor, DEFAULT_EDITOR,
347                         Use VALUE as the fall-back editor instead of 'vi'.
348                         This is used by things like 'git commit' when the user
349                         does not specify a preferred editor through other
350                         methods. eg: /usr/bin/editor)
353 # Define SHELL_PATH to provide path to shell.
354 GIT_ARG_SET_PATH(shell)
356 # Define PERL_PATH to provide path to Perl.
357 GIT_ARG_SET_PATH(perl)
359 # Define PYTHON_PATH to provide path to Python.
360 GIT_ARG_SET_PATH(python, allow-without)
362 # Define ZLIB_PATH to provide path to zlib.
363 GIT_ARG_SET_PATH(zlib)
365 # Declare the with-tcltk/without-tcltk options.
366 AC_ARG_WITH(tcltk,
367 AS_HELP_STRING([--with-tcltk],[use Tcl/Tk GUI (default is YES)])
368 AS_HELP_STRING([],[ARG is the full path to the Tcl/Tk interpreter.])
369 AS_HELP_STRING([],[Bare --with-tcltk will make the GUI part only if])
370 AS_HELP_STRING([],[Tcl/Tk interpreter will be found in a system.]),\
371 GIT_PARSE_WITH(tcltk))
375 ## Checks for programs.
376 AC_MSG_NOTICE([CHECKS for programs])
378 AC_PROG_CC([cc gcc])
379 AC_C_INLINE
380 case $ac_cv_c_inline in
381   inline | yes | no)    ;;
382   *)                    AC_SUBST([INLINE], [$ac_cv_c_inline]) ;;
383 esac
385 # which switch to pass runtime path to dynamic libraries to the linker
386 AC_CACHE_CHECK([if linker supports -R], git_cv_ld_dashr, [
387    SAVE_LDFLAGS="${LDFLAGS}"
388    LDFLAGS="${SAVE_LDFLAGS} -R /"
389    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [git_cv_ld_dashr=yes], [git_cv_ld_dashr=no])
390    LDFLAGS="${SAVE_LDFLAGS}"
392 if test "$git_cv_ld_dashr" = "yes"; then
393    AC_SUBST(CC_LD_DYNPATH, [-R])
394 else
395    AC_CACHE_CHECK([if linker supports -Wl,-rpath,], git_cv_ld_wl_rpath, [
396       SAVE_LDFLAGS="${LDFLAGS}"
397       LDFLAGS="${SAVE_LDFLAGS} -Wl,-rpath,/"
398       AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [git_cv_ld_wl_rpath=yes], [git_cv_ld_wl_rpath=no])
399       LDFLAGS="${SAVE_LDFLAGS}"
400    ])
401    if test "$git_cv_ld_wl_rpath" = "yes"; then
402       AC_SUBST(CC_LD_DYNPATH, [-Wl,-rpath,])
403    else
404       AC_CACHE_CHECK([if linker supports -rpath], git_cv_ld_rpath, [
405          SAVE_LDFLAGS="${LDFLAGS}"
406          LDFLAGS="${SAVE_LDFLAGS} -rpath /"
407          AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [git_cv_ld_rpath=yes], [git_cv_ld_rpath=no])
408          LDFLAGS="${SAVE_LDFLAGS}"
409       ])
410       if test "$git_cv_ld_rpath" = "yes"; then
411          AC_SUBST(CC_LD_DYNPATH, [-rpath])
412       else
413          AC_MSG_WARN([linker does not support runtime path to dynamic libraries])
414       fi
415    fi
417 #AC_PROG_INSTALL                # needs install-sh or install.sh in sources
418 AC_CHECK_TOOLS(AR, [gar ar], :)
419 AC_CHECK_PROGS(TAR, [gtar tar])
420 AC_CHECK_PROGS(DIFF, [gnudiff gdiff diff])
421 # TCLTK_PATH will be set to some value if we want Tcl/Tk
422 # or will be empty otherwise.
423 if test -z "$NO_TCLTK"; then
424   if test "$with_tcltk" = ""; then
425   # No Tcl/Tk switches given. Do not check for Tcl/Tk, use bare 'wish'.
426     TCLTK_PATH=wish
427     AC_SUBST(TCLTK_PATH)
428   elif test "$with_tcltk" = "yes"; then
429   # Tcl/Tk check requested.
430     AC_CHECK_PROGS(TCLTK_PATH, [wish], )
431   else
432     AC_MSG_RESULT([Using Tcl/Tk interpreter $with_tcltk])
433     TCLTK_PATH="$with_tcltk"
434     AC_SUBST(TCLTK_PATH)
435   fi
437 AC_CHECK_PROGS(ASCIIDOC, [asciidoc])
438 if test -n "$ASCIIDOC"; then
439         AC_MSG_CHECKING([for asciidoc version])
440         asciidoc_version=`$ASCIIDOC --version 2>/dev/null`
441         case "${asciidoc_version}" in
442         asciidoc' '7*)
443                 ASCIIDOC7=YesPlease
444                 AC_MSG_RESULT([${asciidoc_version} > 7])
445                 ;;
446         asciidoc' '8*)
447                 ASCIIDOC7=
448                 AC_MSG_RESULT([${asciidoc_version}])
449                 ;;
450         *)
451                 ASCIIDOC7=
452                 AC_MSG_RESULT([${asciidoc_version} (unknown)])
453                 ;;
454         esac
456 AC_SUBST(ASCIIDOC7)
459 ## Checks for libraries.
460 AC_MSG_NOTICE([CHECKS for libraries])
462 # Define NO_OPENSSL environment variable if you do not have OpenSSL.
463 # Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
465 GIT_STASH_FLAGS($OPENSSLDIR)
467 AC_CHECK_LIB([crypto], [SHA1_Init],
468 [NEEDS_SSL_WITH_CRYPTO=],
469 [AC_CHECK_LIB([ssl], [SHA1_Init],
470  [NEEDS_SSL_WITH_CRYPTO=YesPlease],
471  [NEEDS_SSL_WITH_CRYPTO= NO_OPENSSL=YesPlease])])
473 GIT_UNSTASH_FLAGS($OPENSSLDIR)
475 AC_SUBST(NEEDS_SSL_WITH_CRYPTO)
476 AC_SUBST(NO_OPENSSL)
479 # Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be
480 # able to use Perl-compatible regular expressions.
483 if test -n "$USE_LIBPCRE"; then
485 GIT_STASH_FLAGS($LIBPCREDIR)
487 AC_CHECK_LIB([pcre], [pcre_version],
488 [USE_LIBPCRE=YesPlease],
489 [USE_LIBPCRE=])
491 GIT_UNSTASH_FLAGS($LIBPCREDIR)
493 AC_SUBST(USE_LIBPCRE)
498 # Define NO_CURL if you do not have libcurl installed.  git-http-pull and
499 # git-http-push are not built, and you cannot use http:// and https://
500 # transports.
502 GIT_STASH_FLAGS($CURLDIR)
504 AC_CHECK_LIB([curl], [curl_global_init],
505 [NO_CURL=],
506 [NO_CURL=YesPlease])
508 GIT_UNSTASH_FLAGS($CURLDIR)
510 AC_SUBST(NO_CURL)
513 # Define NO_EXPAT if you do not have expat installed.  git-http-push is
514 # not built, and you cannot push using http:// and https:// transports.
516 GIT_STASH_FLAGS($EXPATDIR)
518 AC_CHECK_LIB([expat], [XML_ParserCreate],
519 [NO_EXPAT=],
520 [NO_EXPAT=YesPlease])
522 GIT_UNSTASH_FLAGS($EXPATDIR)
524 AC_SUBST(NO_EXPAT)
527 # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin and
528 # some Solaris installations).
529 # Define NO_ICONV if neither libc nor libiconv support iconv.
531 if test -z "$NO_ICONV"; then
533 GIT_STASH_FLAGS($ICONVDIR)
535 AC_DEFUN([ICONVTEST_SRC],
536 [AC_LANG_PROGRAM([#include <iconv.h>],
537  [iconv_open("", "");])])
539 if test -n "$ICONVDIR"; then
540    lib_order="-liconv -lc"
541 else
542    lib_order="-lc -liconv"
545 NO_ICONV=YesPlease
547 for l in $lib_order; do
548     if test "$l" = "-liconv"; then
549        NEEDS_LIBICONV=YesPlease
550     else
551        NEEDS_LIBICONV=
552     fi
554     old_LIBS="$LIBS"
555     LIBS="$LIBS $l"
556     AC_MSG_CHECKING([for iconv in $l])
557     AC_LINK_IFELSE([ICONVTEST_SRC],
558         [AC_MSG_RESULT([yes])
559         NO_ICONV=
560         break],
561         [AC_MSG_RESULT([no])])
562     LIBS="$old_LIBS"
563 done
565 #in case of break
566 LIBS="$old_LIBS"
568 GIT_UNSTASH_FLAGS($ICONVDIR)
570 AC_SUBST(NEEDS_LIBICONV)
571 AC_SUBST(NO_ICONV)
573 if test -n "$NO_ICONV"; then
574     NEEDS_LIBICONV=
580 # Define NO_DEFLATE_BOUND if deflateBound is missing from zlib.
582 GIT_STASH_FLAGS($ZLIB_PATH)
584 AC_DEFUN([ZLIBTEST_SRC], [
585 AC_LANG_PROGRAM([#include <zlib.h>],
586  [deflateBound(0, 0);])])
587 AC_MSG_CHECKING([for deflateBound in -lz])
588 old_LIBS="$LIBS"
589 LIBS="$LIBS -lz"
590 AC_LINK_IFELSE([ZLIBTEST_SRC],
591         [AC_MSG_RESULT([yes])],
592         [AC_MSG_RESULT([no])
593         NO_DEFLATE_BOUND=yes])
594 LIBS="$old_LIBS"
596 GIT_UNSTASH_FLAGS($ZLIB_PATH)
598 AC_SUBST(NO_DEFLATE_BOUND)
601 # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
602 # Patrick Mauritz).
603 AC_CHECK_LIB([c], [socket],
604 [NEEDS_SOCKET=],
605 [NEEDS_SOCKET=YesPlease])
606 AC_SUBST(NEEDS_SOCKET)
607 test -n "$NEEDS_SOCKET" && LIBS="$LIBS -lsocket"
610 # The next few tests will define NEEDS_RESOLV if linking with
611 # libresolv provides some of the functions we would normally get
612 # from libc.
613 NEEDS_RESOLV=
614 AC_SUBST(NEEDS_RESOLV)
616 # Define NO_INET_NTOP if linking with -lresolv is not enough.
617 # Solaris 2.7 in particular hos inet_ntop in -lresolv.
618 NO_INET_NTOP=
619 AC_SUBST(NO_INET_NTOP)
620 AC_CHECK_FUNC([inet_ntop],
621         [],
622     [AC_CHECK_LIB([resolv], [inet_ntop],
623             [NEEDS_RESOLV=YesPlease],
624         [NO_INET_NTOP=YesPlease])
627 # Define NO_INET_PTON if linking with -lresolv is not enough.
628 # Solaris 2.7 in particular hos inet_pton in -lresolv.
629 NO_INET_PTON=
630 AC_SUBST(NO_INET_PTON)
631 AC_CHECK_FUNC([inet_pton],
632         [],
633     [AC_CHECK_LIB([resolv], [inet_pton],
634             [NEEDS_RESOLV=YesPlease],
635         [NO_INET_PTON=YesPlease])
638 # Define NO_HSTRERROR if linking with -lresolv is not enough.
639 # Solaris 2.6 in particular has no hstrerror, even in -lresolv.
640 NO_HSTRERROR=
641 AC_CHECK_FUNC([hstrerror],
642         [],
643     [AC_CHECK_LIB([resolv], [hstrerror],
644             [NEEDS_RESOLV=YesPlease],
645         [NO_HSTRERROR=YesPlease])
647 AC_SUBST(NO_HSTRERROR)
649 # If any of the above tests determined that -lresolv is needed at
650 # build-time, also set it here for remaining configure-time checks.
651 test -n "$NEEDS_RESOLV" && LIBS="$LIBS -lresolv"
653 AC_CHECK_LIB([c], [basename],
654 [NEEDS_LIBGEN=],
655 [NEEDS_LIBGEN=YesPlease])
656 AC_SUBST(NEEDS_LIBGEN)
657 test -n "$NEEDS_LIBGEN" && LIBS="$LIBS -lgen"
659 AC_CHECK_LIB([c], [gettext],
660 [LIBC_CONTAINS_LIBINTL=YesPlease],
661 [LIBC_CONTAINS_LIBINTL=])
662 AC_SUBST(LIBC_CONTAINS_LIBINTL)
665 # Define NO_GETTEXT if you don't want Git output to be translated.
666 # A translated Git requires GNU libintl or another gettext implementation
667 AC_CHECK_HEADER([libintl.h],
668 [NO_GETTEXT=],
669 [NO_GETTEXT=YesPlease])
670 AC_SUBST(NO_GETTEXT)
672 if test -z "$NO_GETTEXT"; then
673     test -n "$LIBC_CONTAINS_LIBINTL" || LIBS="$LIBS -lintl"
676 ## Checks for header files.
677 AC_MSG_NOTICE([CHECKS for header files])
679 # Define NO_SYS_SELECT_H if you don't have sys/select.h.
680 AC_CHECK_HEADER([sys/select.h],
681 [NO_SYS_SELECT_H=],
682 [NO_SYS_SELECT_H=UnfortunatelyYes])
683 AC_SUBST(NO_SYS_SELECT_H)
685 # Define NO_SYS_POLL_H if you don't have sys/poll.h
686 AC_CHECK_HEADER([sys/poll.h],
687 [NO_SYS_POLL_H=],
688 [NO_SYS_POLL_H=UnfortunatelyYes])
689 AC_SUBST(NO_SYS_POLL_H)
691 # Define NO_INTTYPES_H if you don't have inttypes.h
692 AC_CHECK_HEADER([inttypes.h],
693 [NO_INTTYPES_H=],
694 [NO_INTTYPES_H=UnfortunatelyYes])
695 AC_SUBST(NO_INTTYPES_H)
697 # Define OLD_ICONV if your library has an old iconv(), where the second
698 # (input buffer pointer) parameter is declared with type (const char **).
699 AC_DEFUN([OLDICONVTEST_SRC], [
700 AC_LANG_PROGRAM([[
701 #include <iconv.h>
703 extern size_t iconv(iconv_t cd,
704                     char **inbuf, size_t *inbytesleft,
705                     char **outbuf, size_t *outbytesleft);
706 ]], [])])
708 GIT_STASH_FLAGS($ICONVDIR)
710 AC_MSG_CHECKING([for old iconv()])
711 AC_COMPILE_IFELSE([OLDICONVTEST_SRC],
712         [AC_MSG_RESULT([no])],
713         [AC_MSG_RESULT([yes])
714         OLD_ICONV=UnfortunatelyYes])
716 GIT_UNSTASH_FLAGS($ICONVDIR)
718 AC_SUBST(OLD_ICONV)
720 ## Checks for typedefs, structures, and compiler characteristics.
721 AC_MSG_NOTICE([CHECKS for typedefs, structures, and compiler characteristics])
723 TYPE_SOCKLEN_T
724 case $ac_cv_type_socklen_t in
725   yes)  ;;
726   *)    AC_SUBST([SOCKLEN_T], [$git_cv_socklen_t_equiv]) ;;
727 esac
729 # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
730 AC_CHECK_MEMBER(struct dirent.d_ino,
731 [NO_D_INO_IN_DIRENT=],
732 [NO_D_INO_IN_DIRENT=YesPlease],
733 [#include <dirent.h>])
734 AC_SUBST(NO_D_INO_IN_DIRENT)
736 # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
737 # d_type in struct dirent (latest Cygwin -- will be fixed soonish).
738 AC_CHECK_MEMBER(struct dirent.d_type,
739 [NO_D_TYPE_IN_DIRENT=],
740 [NO_D_TYPE_IN_DIRENT=YesPlease],
741 [#include <dirent.h>])
742 AC_SUBST(NO_D_TYPE_IN_DIRENT)
744 # Define NO_SOCKADDR_STORAGE if your platform does not have struct
745 # sockaddr_storage.
746 AC_CHECK_TYPE(struct sockaddr_storage,
747 [NO_SOCKADDR_STORAGE=],
748 [NO_SOCKADDR_STORAGE=YesPlease],[
749 #include <sys/types.h>
750 #include <sys/socket.h>
752 AC_SUBST(NO_SOCKADDR_STORAGE)
754 # Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
755 AC_CHECK_TYPE([struct addrinfo],[
756  GIT_CHECK_FUNC([getaddrinfo],
757   [NO_IPV6=],
758   [NO_IPV6=YesPlease])
759 ],[NO_IPV6=YesPlease],[
760 #include <sys/types.h>
761 #include <sys/socket.h>
762 #include <netdb.h>
764 AC_SUBST(NO_IPV6)
766 # Define NO_REGEX if you have no or inferior regex support in your C library.
767 AC_CACHE_CHECK([whether the platform regex can handle null bytes],
768  [ac_cv_c_excellent_regex], [
769 AC_EGREP_CPP(yippeeyeswehaveit,
770         AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
771 #include <regex.h>
773 [#ifdef REG_STARTEND
774 yippeeyeswehaveit
775 #endif
777         [ac_cv_c_excellent_regex=yes],
778         [ac_cv_c_excellent_regex=no])
780 if test $ac_cv_c_excellent_regex = yes; then
781         NO_REGEX=
782 else
783         NO_REGEX=YesPlease
785 AC_SUBST(NO_REGEX)
787 # Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
788 # when attempting to read from an fopen'ed directory.
789 AC_CACHE_CHECK([whether system succeeds to read fopen'ed directory],
790  [ac_cv_fread_reads_directories],
792 AC_RUN_IFELSE(
793         [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
794                 [[char c;
795                 FILE *f = fopen(".", "r");
796                 return f && fread(&c, 1, 1, f)]])],
797         [ac_cv_fread_reads_directories=no],
798         [ac_cv_fread_reads_directories=yes])
800 if test $ac_cv_fread_reads_directories = yes; then
801         FREAD_READS_DIRECTORIES=UnfortunatelyYes
802 else
803         FREAD_READS_DIRECTORIES=
805 AC_SUBST(FREAD_READS_DIRECTORIES)
807 # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
808 # or vsnprintf() return -1 instead of number of characters which would
809 # have been written to the final string if enough space had been available.
810 AC_CACHE_CHECK([whether snprintf() and/or vsnprintf() return bogus value],
811  [ac_cv_snprintf_returns_bogus],
813 AC_RUN_IFELSE(
814         [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
815                 #include "stdarg.h"
817                 int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
818                 {
819                   int ret;
820                   va_list ap;
821                   va_start(ap, format);
822                   ret = vsnprintf(str, maxsize, format, ap);
823                   va_end(ap);
824                   return ret;
825                 }],
826                 [[char buf[6];
827                   if (test_vsnprintf(buf, 3, "%s", "12345") != 5
828                       || strcmp(buf, "12")) return 1;
829                   if (snprintf(buf, 3, "%s", "12345") != 5
830                       || strcmp(buf, "12")) return 1]])],
831         [ac_cv_snprintf_returns_bogus=no],
832         [ac_cv_snprintf_returns_bogus=yes])
834 if test $ac_cv_snprintf_returns_bogus = yes; then
835         SNPRINTF_RETURNS_BOGUS=UnfortunatelyYes
836 else
837         SNPRINTF_RETURNS_BOGUS=
839 AC_SUBST(SNPRINTF_RETURNS_BOGUS)
842 ## Checks for library functions.
843 ## (in default C library and libraries checked by AC_CHECK_LIB)
844 AC_MSG_NOTICE([CHECKS for library functions])
846 # Define NO_LIBGEN_H if you don't have libgen.h.
847 AC_CHECK_HEADER([libgen.h],
848 [NO_LIBGEN_H=],
849 [NO_LIBGEN_H=YesPlease])
850 AC_SUBST(NO_LIBGEN_H)
852 # Define HAVE_PATHS_H if you have paths.h.
853 AC_CHECK_HEADER([paths.h],
854 [HAVE_PATHS_H=YesPlease],
855 [HAVE_PATHS_H=])
856 AC_SUBST(HAVE_PATHS_H)
858 # Define HAVE_LIBCHARSET_H if have libcharset.h
859 AC_CHECK_HEADER([libcharset.h],
860 [HAVE_LIBCHARSET_H=YesPlease],
861 [HAVE_LIBCHARSET_H=])
862 AC_SUBST(HAVE_LIBCHARSET_H)
863 # Define CHARSET_LIB if libiconv does not export the locale_charset symbol
864 # and libcharset does
865 CHARSET_LIB=
866 AC_CHECK_LIB([iconv], [locale_charset],
867        [],
868        [AC_CHECK_LIB([charset], [locale_charset],
869                      [CHARSET_LIB=-lcharset])
870        ]
872 AC_SUBST(CHARSET_LIB)
874 # Define NO_STRCASESTR if you don't have strcasestr.
875 GIT_CHECK_FUNC(strcasestr,
876 [NO_STRCASESTR=],
877 [NO_STRCASESTR=YesPlease])
878 AC_SUBST(NO_STRCASESTR)
880 # Define NO_STRTOK_R if you don't have strtok_r
881 GIT_CHECK_FUNC(strtok_r,
882 [NO_STRTOK_R=],
883 [NO_STRTOK_R=YesPlease])
884 AC_SUBST(NO_STRTOK_R)
886 # Define NO_FNMATCH if you don't have fnmatch
887 GIT_CHECK_FUNC(fnmatch,
888 [NO_FNMATCH=],
889 [NO_FNMATCH=YesPlease])
890 AC_SUBST(NO_FNMATCH)
892 # Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
893 # FNM_CASEFOLD GNU extension.
894 AC_CACHE_CHECK([whether the fnmatch function supports the FNMATCH_CASEFOLD GNU extension],
895  [ac_cv_c_excellent_fnmatch], [
896 AC_EGREP_CPP(yippeeyeswehaveit,
897         AC_LANG_PROGRAM([
898 #include <fnmatch.h>
900 [#ifdef FNM_CASEFOLD
901 yippeeyeswehaveit
902 #endif
904         [ac_cv_c_excellent_fnmatch=yes],
905         [ac_cv_c_excellent_fnmatch=no])
907 if test $ac_cv_c_excellent_fnmatch = yes; then
908         NO_FNMATCH_CASEFOLD=
909 else
910         NO_FNMATCH_CASEFOLD=YesPlease
912 AC_SUBST(NO_FNMATCH_CASEFOLD)
914 # Define NO_MEMMEM if you don't have memmem.
915 GIT_CHECK_FUNC(memmem,
916 [NO_MEMMEM=],
917 [NO_MEMMEM=YesPlease])
918 AC_SUBST(NO_MEMMEM)
920 # Define NO_STRLCPY if you don't have strlcpy.
921 GIT_CHECK_FUNC(strlcpy,
922 [NO_STRLCPY=],
923 [NO_STRLCPY=YesPlease])
924 AC_SUBST(NO_STRLCPY)
926 # Define NO_UINTMAX_T if your platform does not have uintmax_t
927 AC_CHECK_TYPE(uintmax_t,
928 [NO_UINTMAX_T=],
929 [NO_UINTMAX_T=YesPlease],[
930 #include <inttypes.h>
932 AC_SUBST(NO_UINTMAX_T)
934 # Define NO_STRTOUMAX if you don't have strtoumax in the C library.
935 GIT_CHECK_FUNC(strtoumax,
936 [NO_STRTOUMAX=],
937 [NO_STRTOUMAX=YesPlease])
938 AC_SUBST(NO_STRTOUMAX)
940 # Define NO_SETENV if you don't have setenv in the C library.
941 GIT_CHECK_FUNC(setenv,
942 [NO_SETENV=],
943 [NO_SETENV=YesPlease])
944 AC_SUBST(NO_SETENV)
946 # Define NO_UNSETENV if you don't have unsetenv in the C library.
947 GIT_CHECK_FUNC(unsetenv,
948 [NO_UNSETENV=],
949 [NO_UNSETENV=YesPlease])
950 AC_SUBST(NO_UNSETENV)
952 # Define NO_MKDTEMP if you don't have mkdtemp in the C library.
953 GIT_CHECK_FUNC(mkdtemp,
954 [NO_MKDTEMP=],
955 [NO_MKDTEMP=YesPlease])
956 AC_SUBST(NO_MKDTEMP)
958 # Define NO_MKSTEMPS if you don't have mkstemps in the C library.
959 GIT_CHECK_FUNC(mkstemps,
960 [NO_MKSTEMPS=],
961 [NO_MKSTEMPS=YesPlease])
962 AC_SUBST(NO_MKSTEMPS)
964 # Define NO_INITGROUPS if you don't have initgroups in the C library.
965 GIT_CHECK_FUNC(initgroups,
966 [NO_INITGROUPS=],
967 [NO_INITGROUPS=YesPlease])
968 AC_SUBST(NO_INITGROUPS)
971 # Define NO_MMAP if you want to avoid mmap.
973 # Define NO_ICONV if your libc does not properly support iconv.
976 ## Other checks.
977 # Define USE_PIC if you need the main git objects to be built with -fPIC
978 # in order to build and link perl/Git.so.  x86-64 seems to need this.
980 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
981 # Enable it on Windows.  By default, symrefs are still used.
983 # Define NO_PTHREADS if we do not have pthreads.
985 # Define PTHREAD_LIBS to the linker flag used for Pthread support.
986 AC_DEFUN([PTHREADTEST_SRC], [
987 AC_LANG_PROGRAM([[
988 #include <pthread.h>
989 ]], [[
990         pthread_mutex_t test_mutex;
991         pthread_key_t test_key;
992         int retcode = 0;
993         retcode |= pthread_key_create(&test_key, (void *)0);
994         retcode |= pthread_mutex_init(&test_mutex,(void *)0);
995         retcode |= pthread_mutex_lock(&test_mutex);
996         retcode |= pthread_mutex_unlock(&test_mutex);
997         return retcode;
998 ]])])
1000 dnl AC_LANG_CONFTEST([AC_LANG_PROGRAM(
1001 dnl   [[#include <pthread.h>]],
1002 dnl   [[pthread_mutex_t test_mutex;]]
1003 dnl )])
1005 NO_PTHREADS=UnfortunatelyYes
1006 PTHREAD_LIBS=
1008 if test -n "$USER_NOPTHREAD"; then
1009    AC_MSG_NOTICE([Skipping POSIX Threads at user request.])
1010 # handle these separately since PTHREAD_CFLAGS could be '-lpthreads
1011 # -D_REENTRANT' or some such.
1012 elif test -z "$PTHREAD_CFLAGS"; then
1013   threads_found=no
1014   for opt in -mt -pthread -lpthread; do
1015      old_CFLAGS="$CFLAGS"
1016      CFLAGS="$opt $CFLAGS"
1017      AC_MSG_CHECKING([Checking for POSIX Threads with '$opt'])
1018      AC_LINK_IFELSE([PTHREADTEST_SRC],
1019         [AC_MSG_RESULT([yes])
1020                 NO_PTHREADS=
1021                 PTHREAD_LIBS="$opt"
1022                 PTHREAD_CFLAGS="$opt"
1023                 threads_found=yes
1024                 break
1025         ],
1026         [AC_MSG_RESULT([no])])
1027       CFLAGS="$old_CFLAGS"
1028   done
1029   if test $threads_found != yes; then
1030     AC_CHECK_LIB([pthread], [pthread_create],
1031         [PTHREAD_LIBS="-lpthread"],
1032         [NO_PTHREADS=UnfortunatelyYes])
1033   fi
1034 else
1035   old_CFLAGS="$CFLAGS"
1036   CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
1037   AC_MSG_CHECKING([Checking for POSIX Threads with '$PTHREAD_CFLAGS'])
1038   AC_LINK_IFELSE([PTHREADTEST_SRC],
1039         [AC_MSG_RESULT([yes])
1040                 NO_PTHREADS=
1041                 PTHREAD_LIBS="$PTHREAD_CFLAGS"
1042         ],
1043         [AC_MSG_RESULT([no])])
1045   CFLAGS="$old_CFLAGS"
1048 CFLAGS="$old_CFLAGS"
1050 AC_SUBST(PTHREAD_CFLAGS)
1051 AC_SUBST(PTHREAD_LIBS)
1052 AC_SUBST(NO_PTHREADS)
1054 ## Output files
1055 AC_CONFIG_FILES(["${config_file}":"${config_in}":"${config_append}"])
1056 AC_OUTPUT
1059 ## Cleanup
1060 rm -f "${config_append}"