completion: fix completion after 'git --option <TAB>'
[git/git-svn.git] / configure.ac
blob72f7958824dad94eb50abf7d99b264ff92b2ae88
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 AC_PREREQ(2.59)
5 AC_INIT([git], [@@GIT_VERSION@@], [git@vger.kernel.org])
7 AC_CONFIG_SRCDIR([git.c])
9 config_file=config.mak.autogen
10 config_append=config.mak.append
11 config_in=config.mak.in
13 echo "# ${config_append}.  Generated by configure." > "${config_append}"
16 ## Definitions of macros
17 # GIT_CONF_APPEND_LINE(LINE)
18 # --------------------------
19 # Append LINE to file ${config_append}
20 AC_DEFUN([GIT_CONF_APPEND_LINE],
21 [echo "$1" >> "${config_append}"])# GIT_CONF_APPEND_LINE
23 # GIT_ARG_SET_PATH(PROGRAM)
24 # -------------------------
25 # Provide --with-PROGRAM=PATH option to set PATH to PROGRAM
26 # Optional second argument allows setting NO_PROGRAM=YesPlease if
27 # --without-PROGRAM version used.
28 AC_DEFUN([GIT_ARG_SET_PATH],
29 [AC_ARG_WITH([$1],
30  [AS_HELP_STRING([--with-$1=PATH],
31                  [provide PATH to $1])],
32  [GIT_CONF_APPEND_PATH($1,$2)],[])
33 ])# GIT_ARG_SET_PATH
35 # GIT_CONF_APPEND_PATH(PROGRAM)
36 # ------------------------------
37 # Parse --with-PROGRAM=PATH option to set PROGRAM_PATH=PATH
38 # Used by GIT_ARG_SET_PATH(PROGRAM)
39 # Optional second argument allows setting NO_PROGRAM=YesPlease if
40 # --without-PROGRAM is used.
41 AC_DEFUN([GIT_CONF_APPEND_PATH],
42 [PROGRAM=m4_toupper($1); \
43 if test "$withval" = "no"; then \
44         if test -n "$2"; then \
45                 m4_toupper($1)_PATH=$withval; \
46                 AC_MSG_NOTICE([Disabling use of ${PROGRAM}]); \
47                 GIT_CONF_APPEND_LINE(NO_${PROGRAM}=YesPlease); \
48                 GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=); \
49         else \
50                 AC_MSG_ERROR([You cannot use git without $1]); \
51         fi; \
52 else \
53         if test "$withval" = "yes"; then \
54                 AC_MSG_WARN([You should provide path for --with-$1=PATH]); \
55         else \
56                 m4_toupper($1)_PATH=$withval; \
57                 AC_MSG_NOTICE([Setting m4_toupper($1)_PATH to $withval]); \
58                 GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=$withval); \
59         fi; \
60 fi; \
61 ]) # GIT_CONF_APPEND_PATH
63 # GIT_PARSE_WITH(PACKAGE)
64 # -----------------------
65 # For use in AC_ARG_WITH action-if-found, for packages default ON.
66 # * Set NO_PACKAGE=YesPlease for --without-PACKAGE
67 # * Set PACKAGEDIR=PATH for --with-PACKAGE=PATH
68 # * Unset NO_PACKAGE for --with-PACKAGE without ARG
69 AC_DEFUN([GIT_PARSE_WITH],
70 [PACKAGE=m4_toupper($1); \
71 if test "$withval" = "no"; then \
72         m4_toupper(NO_$1)=YesPlease; \
73 elif test "$withval" = "yes"; then \
74         m4_toupper(NO_$1)=; \
75 else \
76         m4_toupper(NO_$1)=; \
77         m4_toupper($1)DIR=$withval; \
78         AC_MSG_NOTICE([Setting m4_toupper($1)DIR to $withval]); \
79         GIT_CONF_APPEND_LINE(${PACKAGE}DIR=$withval); \
80 fi \
81 ])# GIT_PARSE_WITH
83 # GIT_PARSE_WITH_SET_MAKE_VAR(WITHNAME, VAR, HELP_TEXT)
84 # ---------------------
85 # Set VAR to the value specied by --with-WITHNAME.
86 # No verification of arguments is performed, but warnings are issued
87 # if either 'yes' or 'no' is specified.
88 # HELP_TEXT is presented when --help is called.
89 # This is a direct way to allow setting variables in the Makefile.
90 AC_DEFUN([GIT_PARSE_WITH_SET_MAKE_VAR],
91 [AC_ARG_WITH([$1],
92  [AS_HELP_STRING([--with-$1=VALUE], $3)],
93  if test -n "$withval"; then \
94   if test "$withval" = "yes" -o "$withval" = "no"; then \
95     AC_MSG_WARN([You likely do not want either 'yes' or 'no' as]
96                      [a value for $1 ($2).  Maybe you do...?]); \
97   fi; \
98   \
99   AC_MSG_NOTICE([Setting $2 to $withval]); \
100   GIT_CONF_APPEND_LINE($2=$withval); \
101  fi)])# GIT_PARSE_WITH_SET_MAKE_VAR
104 dnl GIT_CHECK_FUNC(FUNCTION, IFTRUE, IFFALSE)
105 dnl -----------------------------------------
106 dnl Similar to AC_CHECK_FUNC, but on systems that do not generate
107 dnl warnings for missing prototypes (e.g. FreeBSD when compiling without
108 dnl -Wall), it does not work.  By looking for function definition in
109 dnl libraries, this problem can be worked around.
110 AC_DEFUN([GIT_CHECK_FUNC],[AC_CHECK_FUNC([$1],[
111   AC_SEARCH_LIBS([$1],,
112   [$2],[$3])
113 ],[$3])])
116 dnl GIT_STASH_FLAGS(BASEPATH_VAR)
117 dnl -----------------------------
118 dnl Allow for easy stashing of LDFLAGS and CPPFLAGS before running
119 dnl tests that may want to take user settings into account.
120 AC_DEFUN([GIT_STASH_FLAGS],[
121 if test -n "$1"; then
122    old_CPPFLAGS="$CPPFLAGS"
123    old_LDFLAGS="$LDFLAGS"
124    CPPFLAGS="-I$1/include $CPPFLAGS"
125    LDFLAGS="-L$1/$lib $LDFLAGS"
130 dnl GIT_UNSTASH_FLAGS(BASEPATH_VAR)
131 dnl -----------------------------
132 dnl Restore the stashed *FLAGS values.
133 AC_DEFUN([GIT_UNSTASH_FLAGS],[
134 if test -n "$1"; then
135    CPPFLAGS="$old_CPPFLAGS"
136    LDFLAGS="$old_LDFLAGS"
140 # Directories holding "saner" versions of common or POSIX binaries.
141 AC_ARG_WITH([sane-tool-path],
142   [AS_HELP_STRING(
143     [--with-sane-tool-path=DIR-1[[:DIR-2...:DIR-n]]],
144     [Directories to prepend to PATH in build system and generated scripts])],
145   [if test "$withval" = "no"; then
146     withval=''
147   else
148     AC_MSG_NOTICE([Setting SANE_TOOL_PATH to '$withval'])
149   fi
150   GIT_CONF_APPEND_LINE([SANE_TOOL_PATH=$withval])],
151   [# If the "--with-sane-tool-path" option was not given, don't touch
152    # SANE_TOOL_PATH here, but let defaults in Makefile take care of it.
153    # This should minimize spurious differences in the behaviour of the
154    # Git build system when configure is used w.r.t. when it is not.
155    :])
157 ## Site configuration related to programs (before tests)
158 ## --with-PACKAGE[=ARG] and --without-PACKAGE
160 # Set lib to alternative name of lib directory (e.g. lib64)
161 AC_ARG_WITH([lib],
162  [AS_HELP_STRING([--with-lib=ARG],
163                  [ARG specifies alternative name for lib directory])],
164  [if test "$withval" = "no" || test "$withval" = "yes"; then \
165         AC_MSG_WARN([You should provide name for --with-lib=ARG]); \
166 else \
167         lib=$withval; \
168         AC_MSG_NOTICE([Setting lib to '$lib']); \
169         GIT_CONF_APPEND_LINE(lib=$withval); \
170 fi; \
171 ],[])
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_APPEND_LINE(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_APPEND_LINE(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_APPEND_LINE(LIBPCREDIR=$withval); \
258 fi \
261 # Define NO_CURL if you do not have curl installed.  git-http-pull and
262 # git-http-push are not built, and you cannot use http:// and https://
263 # transports.
265 # Define CURLDIR=/foo/bar if your curl header and library files are in
266 # /foo/bar/include and /foo/bar/lib directories.
267 AC_ARG_WITH(curl,
268 AS_HELP_STRING([--with-curl],[support http(s):// transports (default is YES)])
269 AS_HELP_STRING([],           [ARG can be also prefix for curl library and headers]),
270 GIT_PARSE_WITH(curl))
272 # Define NO_EXPAT if you do not have expat installed.  git-http-push is
273 # not built, and you cannot push using http:// and https:// transports.
275 # Define EXPATDIR=/foo/bar if your expat header and library files are in
276 # /foo/bar/include and /foo/bar/lib directories.
277 AC_ARG_WITH(expat,
278 AS_HELP_STRING([--with-expat],
279 [support git-push using http:// and https:// transports via WebDAV (default is YES)])
280 AS_HELP_STRING([],            [ARG can be also prefix for expat library and headers]),
281 GIT_PARSE_WITH(expat))
283 # Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
284 # installed in /sw, but don't want GIT to link against any libraries
285 # installed there.  If defined you may specify your own (or Fink's)
286 # include directories and library directories by defining CFLAGS
287 # and LDFLAGS appropriately.
289 # Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
290 # have DarwinPorts installed in /opt/local, but don't want GIT to
291 # link against any libraries installed there.  If defined you may
292 # specify your own (or DarwinPort's) include directories and
293 # library directories by defining CFLAGS and LDFLAGS appropriately.
295 # Define NO_MMAP if you want to avoid mmap.
297 # Define NO_ICONV if your libc does not properly support iconv.
298 AC_ARG_WITH(iconv,
299 AS_HELP_STRING([--without-iconv],
300 [if your architecture doesn't properly support iconv])
301 AS_HELP_STRING([--with-iconv=PATH],
302 [PATH is prefix for libiconv library and headers])
303 AS_HELP_STRING([],
304 [used only if you need linking with libiconv]),
305 GIT_PARSE_WITH(iconv))
307 ## --enable-FEATURE[=ARG] and --disable-FEATURE
309 # Define USE_NSEC below if you want git to care about sub-second file mtimes
310 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
311 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
312 # randomly break unless your underlying filesystem supports those sub-second
313 # times (my ext3 doesn't).
315 # Define USE_STDEV below if you want git to care about the underlying device
316 # change being considered an inode change from the update-index perspective.
319 # Allow user to set ETC_GITCONFIG variable
320 GIT_PARSE_WITH_SET_MAKE_VAR(gitconfig, ETC_GITCONFIG,
321                         Use VALUE instead of /etc/gitconfig as the
322                         global git configuration file.
323                         If VALUE is not fully qualified it will be interpreted
324                         as a path relative to the computed prefix at runtime.)
327 # Allow user to set ETC_GITATTRIBUTES variable
328 GIT_PARSE_WITH_SET_MAKE_VAR(gitattributes, ETC_GITATTRIBUTES,
329                         Use VALUE instead of /etc/gitattributes as the
330                         global git attributes file.
331                         If VALUE is not fully qualified it will be interpreted
332                         as a path relative to the computed prefix at runtime.)
335 # Allow user to set the default pager
336 GIT_PARSE_WITH_SET_MAKE_VAR(pager, DEFAULT_PAGER,
337                         Use VALUE as the fall-back pager instead of 'less'.
338                         This is used by things like 'git log' when the user
339                         does not specify a pager to use through alternate
340                         methods. eg: /usr/bin/pager)
342 # Allow user to set the default editor
343 GIT_PARSE_WITH_SET_MAKE_VAR(editor, DEFAULT_EDITOR,
344                         Use VALUE as the fall-back editor instead of 'vi'.
345                         This is used by things like 'git commit' when the user
346                         does not specify a preferred editor through other
347                         methods. eg: /usr/bin/editor)
350 # Define SHELL_PATH to provide path to shell.
351 GIT_ARG_SET_PATH(shell)
353 # Define PERL_PATH to provide path to Perl.
354 GIT_ARG_SET_PATH(perl)
356 # Define PYTHON_PATH to provide path to Python.
357 GIT_ARG_SET_PATH(python, allow-without)
359 # Define ZLIB_PATH to provide path to zlib.
360 GIT_ARG_SET_PATH(zlib)
362 # Declare the with-tcltk/without-tcltk options.
363 AC_ARG_WITH(tcltk,
364 AS_HELP_STRING([--with-tcltk],[use Tcl/Tk GUI (default is YES)])
365 AS_HELP_STRING([],[ARG is the full path to the Tcl/Tk interpreter.])
366 AS_HELP_STRING([],[Bare --with-tcltk will make the GUI part only if])
367 AS_HELP_STRING([],[Tcl/Tk interpreter will be found in a system.]),\
368 GIT_PARSE_WITH(tcltk))
372 ## Checks for programs.
373 AC_MSG_NOTICE([CHECKS for programs])
375 AC_PROG_CC([cc gcc])
376 AC_C_INLINE
377 case $ac_cv_c_inline in
378   inline | yes | no)    ;;
379   *)                    AC_SUBST([INLINE], [$ac_cv_c_inline]) ;;
380 esac
382 # which switch to pass runtime path to dynamic libraries to the linker
383 AC_CACHE_CHECK([if linker supports -R], git_cv_ld_dashr, [
384    SAVE_LDFLAGS="${LDFLAGS}"
385    LDFLAGS="${SAVE_LDFLAGS} -R /"
386    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [git_cv_ld_dashr=yes], [git_cv_ld_dashr=no])
387    LDFLAGS="${SAVE_LDFLAGS}"
389 if test "$git_cv_ld_dashr" = "yes"; then
390    AC_SUBST(CC_LD_DYNPATH, [-R])
391 else
392    AC_CACHE_CHECK([if linker supports -Wl,-rpath,], git_cv_ld_wl_rpath, [
393       SAVE_LDFLAGS="${LDFLAGS}"
394       LDFLAGS="${SAVE_LDFLAGS} -Wl,-rpath,/"
395       AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [git_cv_ld_wl_rpath=yes], [git_cv_ld_wl_rpath=no])
396       LDFLAGS="${SAVE_LDFLAGS}"
397    ])
398    if test "$git_cv_ld_wl_rpath" = "yes"; then
399       AC_SUBST(CC_LD_DYNPATH, [-Wl,-rpath,])
400    else
401       AC_CACHE_CHECK([if linker supports -rpath], git_cv_ld_rpath, [
402          SAVE_LDFLAGS="${LDFLAGS}"
403          LDFLAGS="${SAVE_LDFLAGS} -rpath /"
404          AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [git_cv_ld_rpath=yes], [git_cv_ld_rpath=no])
405          LDFLAGS="${SAVE_LDFLAGS}"
406       ])
407       if test "$git_cv_ld_rpath" = "yes"; then
408          AC_SUBST(CC_LD_DYNPATH, [-rpath])
409       else
410          AC_MSG_WARN([linker does not support runtime path to dynamic libraries])
411       fi
412    fi
414 #AC_PROG_INSTALL                # needs install-sh or install.sh in sources
415 AC_CHECK_TOOLS(AR, [gar ar], :)
416 AC_CHECK_PROGS(TAR, [gtar tar])
417 AC_CHECK_PROGS(DIFF, [gnudiff gdiff diff])
418 # TCLTK_PATH will be set to some value if we want Tcl/Tk
419 # or will be empty otherwise.
420 if test -z "$NO_TCLTK"; then
421   if test "$with_tcltk" = ""; then
422   # No Tcl/Tk switches given. Do not check for Tcl/Tk, use bare 'wish'.
423     TCLTK_PATH=wish
424     AC_SUBST(TCLTK_PATH)
425   elif test "$with_tcltk" = "yes"; then
426   # Tcl/Tk check requested.
427     AC_CHECK_PROGS(TCLTK_PATH, [wish], )
428   else
429     AC_MSG_RESULT([Using Tcl/Tk interpreter $with_tcltk])
430     TCLTK_PATH="$with_tcltk"
431     AC_SUBST(TCLTK_PATH)
432   fi
434 AC_CHECK_PROGS(ASCIIDOC, [asciidoc])
435 if test -n "$ASCIIDOC"; then
436         AC_MSG_CHECKING([for asciidoc version])
437         asciidoc_version=`$ASCIIDOC --version 2>/dev/null`
438         case "${asciidoc_version}" in
439         asciidoc' '7*)
440                 ASCIIDOC7=YesPlease
441                 AC_MSG_RESULT([${asciidoc_version} > 7])
442                 ;;
443         asciidoc' '8*)
444                 ASCIIDOC7=
445                 AC_MSG_RESULT([${asciidoc_version}])
446                 ;;
447         *)
448                 ASCIIDOC7=
449                 AC_MSG_RESULT([${asciidoc_version} (unknown)])
450                 ;;
451         esac
453 AC_SUBST(ASCIIDOC7)
456 ## Checks for libraries.
457 AC_MSG_NOTICE([CHECKS for libraries])
459 # Define NO_OPENSSL environment variable if you do not have OpenSSL.
460 # Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
462 GIT_STASH_FLAGS($OPENSSLDIR)
464 AC_CHECK_LIB([crypto], [SHA1_Init],
465 [NEEDS_SSL_WITH_CRYPTO=],
466 [AC_CHECK_LIB([ssl], [SHA1_Init],
467  [NEEDS_SSL_WITH_CRYPTO=YesPlease],
468  [NEEDS_SSL_WITH_CRYPTO= NO_OPENSSL=YesPlease])])
470 GIT_UNSTASH_FLAGS($OPENSSLDIR)
472 AC_SUBST(NEEDS_SSL_WITH_CRYPTO)
473 AC_SUBST(NO_OPENSSL)
476 # Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be
477 # able to use Perl-compatible regular expressions.
480 if test -n "$USE_LIBPCRE"; then
482 GIT_STASH_FLAGS($LIBPCREDIR)
484 AC_CHECK_LIB([pcre], [pcre_version],
485 [USE_LIBPCRE=YesPlease],
486 [USE_LIBPCRE=])
488 GIT_UNSTASH_FLAGS($LIBPCREDIR)
490 AC_SUBST(USE_LIBPCRE)
495 # Define NO_CURL if you do not have libcurl installed.  git-http-pull and
496 # git-http-push are not built, and you cannot use http:// and https://
497 # transports.
499 GIT_STASH_FLAGS($CURLDIR)
501 AC_CHECK_LIB([curl], [curl_global_init],
502 [NO_CURL=],
503 [NO_CURL=YesPlease])
505 GIT_UNSTASH_FLAGS($CURLDIR)
507 AC_SUBST(NO_CURL)
510 # Define NO_EXPAT if you do not have expat installed.  git-http-push is
511 # not built, and you cannot push using http:// and https:// transports.
513 GIT_STASH_FLAGS($EXPATDIR)
515 AC_CHECK_LIB([expat], [XML_ParserCreate],
516 [NO_EXPAT=],
517 [NO_EXPAT=YesPlease])
519 GIT_UNSTASH_FLAGS($EXPATDIR)
521 AC_SUBST(NO_EXPAT)
524 # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin and
525 # some Solaris installations).
526 # Define NO_ICONV if neither libc nor libiconv support iconv.
528 if test -z "$NO_ICONV"; then
530 GIT_STASH_FLAGS($ICONVDIR)
532 AC_DEFUN([ICONVTEST_SRC],
533 [AC_LANG_PROGRAM([#include <iconv.h>],
534  [iconv_open("", "");])])
536 if test -n "$ICONVDIR"; then
537    lib_order="-liconv -lc"
538 else
539    lib_order="-lc -liconv"
542 NO_ICONV=YesPlease
544 for l in $lib_order; do
545     if test "$l" = "-liconv"; then
546        NEEDS_LIBICONV=YesPlease
547     else
548        NEEDS_LIBICONV=
549     fi
551     old_LIBS="$LIBS"
552     LIBS="$LIBS $l"
553     AC_MSG_CHECKING([for iconv in $l])
554     AC_LINK_IFELSE([ICONVTEST_SRC],
555         [AC_MSG_RESULT([yes])
556         NO_ICONV=
557         break],
558         [AC_MSG_RESULT([no])])
559     LIBS="$old_LIBS"
560 done
562 #in case of break
563 LIBS="$old_LIBS"
565 GIT_UNSTASH_FLAGS($ICONVDIR)
567 AC_SUBST(NEEDS_LIBICONV)
568 AC_SUBST(NO_ICONV)
570 if test -n "$NO_ICONV"; then
571     NEEDS_LIBICONV=
577 # Define NO_DEFLATE_BOUND if deflateBound is missing from zlib.
579 GIT_STASH_FLAGS($ZLIB_PATH)
581 AC_DEFUN([ZLIBTEST_SRC], [
582 AC_LANG_PROGRAM([#include <zlib.h>],
583  [deflateBound(0, 0);])])
584 AC_MSG_CHECKING([for deflateBound in -lz])
585 old_LIBS="$LIBS"
586 LIBS="$LIBS -lz"
587 AC_LINK_IFELSE([ZLIBTEST_SRC],
588         [AC_MSG_RESULT([yes])],
589         [AC_MSG_RESULT([no])
590         NO_DEFLATE_BOUND=yes])
591 LIBS="$old_LIBS"
593 GIT_UNSTASH_FLAGS($ZLIB_PATH)
595 AC_SUBST(NO_DEFLATE_BOUND)
598 # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
599 # Patrick Mauritz).
600 AC_CHECK_LIB([c], [socket],
601 [NEEDS_SOCKET=],
602 [NEEDS_SOCKET=YesPlease])
603 AC_SUBST(NEEDS_SOCKET)
604 test -n "$NEEDS_SOCKET" && LIBS="$LIBS -lsocket"
607 # The next few tests will define NEEDS_RESOLV if linking with
608 # libresolv provides some of the functions we would normally get
609 # from libc.
610 NEEDS_RESOLV=
611 AC_SUBST(NEEDS_RESOLV)
613 # Define NO_INET_NTOP if linking with -lresolv is not enough.
614 # Solaris 2.7 in particular hos inet_ntop in -lresolv.
615 NO_INET_NTOP=
616 AC_SUBST(NO_INET_NTOP)
617 AC_CHECK_FUNC([inet_ntop],
618         [],
619     [AC_CHECK_LIB([resolv], [inet_ntop],
620             [NEEDS_RESOLV=YesPlease],
621         [NO_INET_NTOP=YesPlease])
624 # Define NO_INET_PTON if linking with -lresolv is not enough.
625 # Solaris 2.7 in particular hos inet_pton in -lresolv.
626 NO_INET_PTON=
627 AC_SUBST(NO_INET_PTON)
628 AC_CHECK_FUNC([inet_pton],
629         [],
630     [AC_CHECK_LIB([resolv], [inet_pton],
631             [NEEDS_RESOLV=YesPlease],
632         [NO_INET_PTON=YesPlease])
635 # Define NO_HSTRERROR if linking with -lresolv is not enough.
636 # Solaris 2.6 in particular has no hstrerror, even in -lresolv.
637 NO_HSTRERROR=
638 AC_CHECK_FUNC([hstrerror],
639         [],
640     [AC_CHECK_LIB([resolv], [hstrerror],
641             [NEEDS_RESOLV=YesPlease],
642         [NO_HSTRERROR=YesPlease])
644 AC_SUBST(NO_HSTRERROR)
646 # If any of the above tests determined that -lresolv is needed at
647 # build-time, also set it here for remaining configure-time checks.
648 test -n "$NEEDS_RESOLV" && LIBS="$LIBS -lresolv"
650 AC_CHECK_LIB([c], [basename],
651 [NEEDS_LIBGEN=],
652 [NEEDS_LIBGEN=YesPlease])
653 AC_SUBST(NEEDS_LIBGEN)
654 test -n "$NEEDS_LIBGEN" && LIBS="$LIBS -lgen"
656 AC_CHECK_LIB([c], [gettext],
657 [LIBC_CONTAINS_LIBINTL=YesPlease],
658 [LIBC_CONTAINS_LIBINTL=])
659 AC_SUBST(LIBC_CONTAINS_LIBINTL)
662 # Define NO_GETTEXT if you don't want Git output to be translated.
663 # A translated Git requires GNU libintl or another gettext implementation
664 AC_CHECK_HEADER([libintl.h],
665 [NO_GETTEXT=],
666 [NO_GETTEXT=YesPlease])
667 AC_SUBST(NO_GETTEXT)
669 if test -z "$NO_GETTEXT"; then
670     test -n "$LIBC_CONTAINS_LIBINTL" || LIBS="$LIBS -lintl"
673 ## Checks for header files.
674 AC_MSG_NOTICE([CHECKS for header files])
676 # Define NO_SYS_SELECT_H if you don't have sys/select.h.
677 AC_CHECK_HEADER([sys/select.h],
678 [NO_SYS_SELECT_H=],
679 [NO_SYS_SELECT_H=UnfortunatelyYes])
680 AC_SUBST(NO_SYS_SELECT_H)
682 # Define NO_SYS_POLL_H if you don't have sys/poll.h
683 AC_CHECK_HEADER([sys/poll.h],
684 [NO_SYS_POLL_H=],
685 [NO_SYS_POLL_H=UnfortunatelyYes])
686 AC_SUBST(NO_SYS_POLL_H)
688 # Define NO_INTTYPES_H if you don't have inttypes.h
689 AC_CHECK_HEADER([inttypes.h],
690 [NO_INTTYPES_H=],
691 [NO_INTTYPES_H=UnfortunatelyYes])
692 AC_SUBST(NO_INTTYPES_H)
694 # Define OLD_ICONV if your library has an old iconv(), where the second
695 # (input buffer pointer) parameter is declared with type (const char **).
696 AC_DEFUN([OLDICONVTEST_SRC], [
697 AC_LANG_PROGRAM([[
698 #include <iconv.h>
700 extern size_t iconv(iconv_t cd,
701                     char **inbuf, size_t *inbytesleft,
702                     char **outbuf, size_t *outbytesleft);
703 ]], [])])
705 GIT_STASH_FLAGS($ICONVDIR)
707 AC_MSG_CHECKING([for old iconv()])
708 AC_COMPILE_IFELSE([OLDICONVTEST_SRC],
709         [AC_MSG_RESULT([no])],
710         [AC_MSG_RESULT([yes])
711         OLD_ICONV=UnfortunatelyYes])
713 GIT_UNSTASH_FLAGS($ICONVDIR)
715 AC_SUBST(OLD_ICONV)
717 ## Checks for typedefs, structures, and compiler characteristics.
718 AC_MSG_NOTICE([CHECKS for typedefs, structures, and compiler characteristics])
720 TYPE_SOCKLEN_T
721 case $ac_cv_type_socklen_t in
722   yes)  ;;
723   *)    AC_SUBST([SOCKLEN_T], [$git_cv_socklen_t_equiv]) ;;
724 esac
726 # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
727 AC_CHECK_MEMBER(struct dirent.d_ino,
728 [NO_D_INO_IN_DIRENT=],
729 [NO_D_INO_IN_DIRENT=YesPlease],
730 [#include <dirent.h>])
731 AC_SUBST(NO_D_INO_IN_DIRENT)
733 # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
734 # d_type in struct dirent (latest Cygwin -- will be fixed soonish).
735 AC_CHECK_MEMBER(struct dirent.d_type,
736 [NO_D_TYPE_IN_DIRENT=],
737 [NO_D_TYPE_IN_DIRENT=YesPlease],
738 [#include <dirent.h>])
739 AC_SUBST(NO_D_TYPE_IN_DIRENT)
741 # Define NO_SOCKADDR_STORAGE if your platform does not have struct
742 # sockaddr_storage.
743 AC_CHECK_TYPE(struct sockaddr_storage,
744 [NO_SOCKADDR_STORAGE=],
745 [NO_SOCKADDR_STORAGE=YesPlease],[
746 #include <sys/types.h>
747 #include <sys/socket.h>
749 AC_SUBST(NO_SOCKADDR_STORAGE)
751 # Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
752 AC_CHECK_TYPE([struct addrinfo],[
753  GIT_CHECK_FUNC([getaddrinfo],
754   [NO_IPV6=],
755   [NO_IPV6=YesPlease])
756 ],[NO_IPV6=YesPlease],[
757 #include <sys/types.h>
758 #include <sys/socket.h>
759 #include <netdb.h>
761 AC_SUBST(NO_IPV6)
763 # Define NO_REGEX if you have no or inferior regex support in your C library.
764 AC_CACHE_CHECK([whether the platform regex can handle null bytes],
765  [ac_cv_c_excellent_regex], [
766 AC_EGREP_CPP(yippeeyeswehaveit,
767         AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
768 #include <regex.h>
770 [#ifdef REG_STARTEND
771 yippeeyeswehaveit
772 #endif
774         [ac_cv_c_excellent_regex=yes],
775         [ac_cv_c_excellent_regex=no])
777 if test $ac_cv_c_excellent_regex = yes; then
778         NO_REGEX=
779 else
780         NO_REGEX=YesPlease
782 AC_SUBST(NO_REGEX)
784 # Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
785 # when attempting to read from an fopen'ed directory.
786 AC_CACHE_CHECK([whether system succeeds to read fopen'ed directory],
787  [ac_cv_fread_reads_directories],
789 AC_RUN_IFELSE(
790         [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
791                 [[char c;
792                 FILE *f = fopen(".", "r");
793                 return f && fread(&c, 1, 1, f)]])],
794         [ac_cv_fread_reads_directories=no],
795         [ac_cv_fread_reads_directories=yes])
797 if test $ac_cv_fread_reads_directories = yes; then
798         FREAD_READS_DIRECTORIES=UnfortunatelyYes
799 else
800         FREAD_READS_DIRECTORIES=
802 AC_SUBST(FREAD_READS_DIRECTORIES)
804 # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
805 # or vsnprintf() return -1 instead of number of characters which would
806 # have been written to the final string if enough space had been available.
807 AC_CACHE_CHECK([whether snprintf() and/or vsnprintf() return bogus value],
808  [ac_cv_snprintf_returns_bogus],
810 AC_RUN_IFELSE(
811         [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
812                 #include "stdarg.h"
814                 int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
815                 {
816                   int ret;
817                   va_list ap;
818                   va_start(ap, format);
819                   ret = vsnprintf(str, maxsize, format, ap);
820                   va_end(ap);
821                   return ret;
822                 }],
823                 [[char buf[6];
824                   if (test_vsnprintf(buf, 3, "%s", "12345") != 5
825                       || strcmp(buf, "12")) return 1;
826                   if (snprintf(buf, 3, "%s", "12345") != 5
827                       || strcmp(buf, "12")) return 1]])],
828         [ac_cv_snprintf_returns_bogus=no],
829         [ac_cv_snprintf_returns_bogus=yes])
831 if test $ac_cv_snprintf_returns_bogus = yes; then
832         SNPRINTF_RETURNS_BOGUS=UnfortunatelyYes
833 else
834         SNPRINTF_RETURNS_BOGUS=
836 AC_SUBST(SNPRINTF_RETURNS_BOGUS)
839 ## Checks for library functions.
840 ## (in default C library and libraries checked by AC_CHECK_LIB)
841 AC_MSG_NOTICE([CHECKS for library functions])
843 # Define NO_LIBGEN_H if you don't have libgen.h.
844 AC_CHECK_HEADER([libgen.h],
845 [NO_LIBGEN_H=],
846 [NO_LIBGEN_H=YesPlease])
847 AC_SUBST(NO_LIBGEN_H)
849 # Define HAVE_PATHS_H if you have paths.h.
850 AC_CHECK_HEADER([paths.h],
851 [HAVE_PATHS_H=YesPlease],
852 [HAVE_PATHS_H=])
853 AC_SUBST(HAVE_PATHS_H)
855 # Define HAVE_LIBCHARSET_H if have libcharset.h
856 AC_CHECK_HEADER([libcharset.h],
857 [HAVE_LIBCHARSET_H=YesPlease],
858 [HAVE_LIBCHARSET_H=])
859 AC_SUBST(HAVE_LIBCHARSET_H)
860 # Define CHARSET_LIB if libiconv does not export the locale_charset symbol
861 # and libcharset does
862 CHARSET_LIB=
863 AC_CHECK_LIB([iconv], [locale_charset],
864        [],
865        [AC_CHECK_LIB([charset], [locale_charset],
866                      [CHARSET_LIB=-lcharset])
867        ]
869 AC_SUBST(CHARSET_LIB)
871 # Define NO_STRCASESTR if you don't have strcasestr.
872 GIT_CHECK_FUNC(strcasestr,
873 [NO_STRCASESTR=],
874 [NO_STRCASESTR=YesPlease])
875 AC_SUBST(NO_STRCASESTR)
877 # Define NO_STRTOK_R if you don't have strtok_r
878 GIT_CHECK_FUNC(strtok_r,
879 [NO_STRTOK_R=],
880 [NO_STRTOK_R=YesPlease])
881 AC_SUBST(NO_STRTOK_R)
883 # Define NO_FNMATCH if you don't have fnmatch
884 GIT_CHECK_FUNC(fnmatch,
885 [NO_FNMATCH=],
886 [NO_FNMATCH=YesPlease])
887 AC_SUBST(NO_FNMATCH)
889 # Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
890 # FNM_CASEFOLD GNU extension.
891 AC_CACHE_CHECK([whether the fnmatch function supports the FNMATCH_CASEFOLD GNU extension],
892  [ac_cv_c_excellent_fnmatch], [
893 AC_EGREP_CPP(yippeeyeswehaveit,
894         AC_LANG_PROGRAM([
895 #include <fnmatch.h>
897 [#ifdef FNM_CASEFOLD
898 yippeeyeswehaveit
899 #endif
901         [ac_cv_c_excellent_fnmatch=yes],
902         [ac_cv_c_excellent_fnmatch=no])
904 if test $ac_cv_c_excellent_fnmatch = yes; then
905         NO_FNMATCH_CASEFOLD=
906 else
907         NO_FNMATCH_CASEFOLD=YesPlease
909 AC_SUBST(NO_FNMATCH_CASEFOLD)
911 # Define NO_MEMMEM if you don't have memmem.
912 GIT_CHECK_FUNC(memmem,
913 [NO_MEMMEM=],
914 [NO_MEMMEM=YesPlease])
915 AC_SUBST(NO_MEMMEM)
917 # Define NO_STRLCPY if you don't have strlcpy.
918 GIT_CHECK_FUNC(strlcpy,
919 [NO_STRLCPY=],
920 [NO_STRLCPY=YesPlease])
921 AC_SUBST(NO_STRLCPY)
923 # Define NO_UINTMAX_T if your platform does not have uintmax_t
924 AC_CHECK_TYPE(uintmax_t,
925 [NO_UINTMAX_T=],
926 [NO_UINTMAX_T=YesPlease],[
927 #include <inttypes.h>
929 AC_SUBST(NO_UINTMAX_T)
931 # Define NO_STRTOUMAX if you don't have strtoumax in the C library.
932 GIT_CHECK_FUNC(strtoumax,
933 [NO_STRTOUMAX=],
934 [NO_STRTOUMAX=YesPlease])
935 AC_SUBST(NO_STRTOUMAX)
937 # Define NO_SETENV if you don't have setenv in the C library.
938 GIT_CHECK_FUNC(setenv,
939 [NO_SETENV=],
940 [NO_SETENV=YesPlease])
941 AC_SUBST(NO_SETENV)
943 # Define NO_UNSETENV if you don't have unsetenv in the C library.
944 GIT_CHECK_FUNC(unsetenv,
945 [NO_UNSETENV=],
946 [NO_UNSETENV=YesPlease])
947 AC_SUBST(NO_UNSETENV)
949 # Define NO_MKDTEMP if you don't have mkdtemp in the C library.
950 GIT_CHECK_FUNC(mkdtemp,
951 [NO_MKDTEMP=],
952 [NO_MKDTEMP=YesPlease])
953 AC_SUBST(NO_MKDTEMP)
955 # Define NO_MKSTEMPS if you don't have mkstemps in the C library.
956 GIT_CHECK_FUNC(mkstemps,
957 [NO_MKSTEMPS=],
958 [NO_MKSTEMPS=YesPlease])
959 AC_SUBST(NO_MKSTEMPS)
961 # Define NO_INITGROUPS if you don't have initgroups in the C library.
962 GIT_CHECK_FUNC(initgroups,
963 [NO_INITGROUPS=],
964 [NO_INITGROUPS=YesPlease])
965 AC_SUBST(NO_INITGROUPS)
968 # Define NO_MMAP if you want to avoid mmap.
970 # Define NO_ICONV if your libc does not properly support iconv.
973 ## Other checks.
974 # Define USE_PIC if you need the main git objects to be built with -fPIC
975 # in order to build and link perl/Git.so.  x86-64 seems to need this.
977 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
978 # Enable it on Windows.  By default, symrefs are still used.
980 # Define NO_PTHREADS if we do not have pthreads.
982 # Define PTHREAD_LIBS to the linker flag used for Pthread support.
983 AC_DEFUN([PTHREADTEST_SRC], [
984 AC_LANG_PROGRAM([[
985 #include <pthread.h>
986 ]], [[
987         pthread_mutex_t test_mutex;
988         pthread_key_t test_key;
989         int retcode = 0;
990         retcode |= pthread_key_create(&test_key, (void *)0);
991         retcode |= pthread_mutex_init(&test_mutex,(void *)0);
992         retcode |= pthread_mutex_lock(&test_mutex);
993         retcode |= pthread_mutex_unlock(&test_mutex);
994         return retcode;
995 ]])])
997 dnl AC_LANG_CONFTEST([AC_LANG_PROGRAM(
998 dnl   [[#include <pthread.h>]],
999 dnl   [[pthread_mutex_t test_mutex;]]
1000 dnl )])
1002 NO_PTHREADS=UnfortunatelyYes
1003 PTHREAD_LIBS=
1005 if test -n "$USER_NOPTHREAD"; then
1006    AC_MSG_NOTICE([Skipping POSIX Threads at user request.])
1007 # handle these separately since PTHREAD_CFLAGS could be '-lpthreads
1008 # -D_REENTRANT' or some such.
1009 elif test -z "$PTHREAD_CFLAGS"; then
1010   threads_found=no
1011   for opt in -mt -pthread -lpthread; do
1012      old_CFLAGS="$CFLAGS"
1013      CFLAGS="$opt $CFLAGS"
1014      AC_MSG_CHECKING([Checking for POSIX Threads with '$opt'])
1015      AC_LINK_IFELSE([PTHREADTEST_SRC],
1016         [AC_MSG_RESULT([yes])
1017                 NO_PTHREADS=
1018                 PTHREAD_LIBS="$opt"
1019                 PTHREAD_CFLAGS="$opt"
1020                 threads_found=yes
1021                 break
1022         ],
1023         [AC_MSG_RESULT([no])])
1024       CFLAGS="$old_CFLAGS"
1025   done
1026   if test $threads_found != yes; then
1027     AC_CHECK_LIB([pthread], [pthread_create],
1028         [PTHREAD_LIBS="-lpthread"],
1029         [NO_PTHREADS=UnfortunatelyYes])
1030   fi
1031 else
1032   old_CFLAGS="$CFLAGS"
1033   CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
1034   AC_MSG_CHECKING([Checking for POSIX Threads with '$PTHREAD_CFLAGS'])
1035   AC_LINK_IFELSE([PTHREADTEST_SRC],
1036         [AC_MSG_RESULT([yes])
1037                 NO_PTHREADS=
1038                 PTHREAD_LIBS="$PTHREAD_CFLAGS"
1039         ],
1040         [AC_MSG_RESULT([no])])
1042   CFLAGS="$old_CFLAGS"
1045 CFLAGS="$old_CFLAGS"
1047 AC_SUBST(PTHREAD_CFLAGS)
1048 AC_SUBST(PTHREAD_LIBS)
1049 AC_SUBST(NO_PTHREADS)
1051 ## Output files
1052 AC_CONFIG_FILES(["${config_file}":"${config_in}":"${config_append}"])
1053 AC_OUTPUT
1056 ## Cleanup
1057 rm -f "${config_append}"