Fix truncated usage messages
[git/dscho.git] / configure.ac
blob4625b8672bf5b0dcc977737c2c5086c5c1aa54a6
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 AC_DEFUN([GIT_ARG_SET_PATH],
27 [AC_ARG_WITH([$1],
28  [AS_HELP_STRING([--with-$1=PATH],
29                  [provide PATH to $1])],
30  [GIT_CONF_APPEND_PATH($1)],[])
31 ])# GIT_ARG_SET_PATH
33 # GIT_CONF_APPEND_PATH(PROGRAM)
34 # ------------------------------
35 # Parse --with-PROGRAM=PATH option to set PROGRAM_PATH=PATH
36 # Used by GIT_ARG_SET_PATH(PROGRAM)
37 AC_DEFUN([GIT_CONF_APPEND_PATH],
38 [PROGRAM=m4_toupper($1); \
39 if test "$withval" = "no"; then \
40         AC_MSG_ERROR([You cannot use git without $1]); \
41 else \
42         if test "$withval" = "yes"; then \
43                 AC_MSG_WARN([You should provide path for --with-$1=PATH]); \
44         else \
45                 m4_toupper($1)_PATH=$withval; \
46                 AC_MSG_NOTICE([Setting m4_toupper($1)_PATH to $withval]); \
47                 GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=$withval); \
48         fi; \
49 fi; \
50 ]) # 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 [PACKAGE=m4_toupper($1); \
60 if test "$withval" = "no"; then \
61         m4_toupper(NO_$1)=YesPlease; \
62 elif test "$withval" = "yes"; then \
63         m4_toupper(NO_$1)=; \
64 else \
65         m4_toupper(NO_$1)=; \
66         m4_toupper($1)DIR=$withval; \
67         AC_MSG_NOTICE([Setting m4_toupper($1)DIR to $withval]); \
68         GIT_CONF_APPEND_LINE(${PACKAGE}DIR=$withval); \
69 fi \
70 ])# GIT_PARSE_WITH
72 # GIT_PARSE_WITH_SET_MAKE_VAR(WITHNAME, VAR, HELP_TEXT)
73 # ---------------------
74 # Set VAR to the value specied by --with-WITHNAME.
75 # No verification of arguments is performed, but warnings are issued
76 # if either 'yes' or 'no' is specified.
77 # HELP_TEXT is presented when --help is called.
78 # This is a direct way to allow setting variables in the Makefile.
79 AC_DEFUN([GIT_PARSE_WITH_SET_MAKE_VAR],
80 [AC_ARG_WITH([$1],
81  [AS_HELP_STRING([--with-$1=VALUE], $3)],
82  if test -n "$withval"; then \
83   if test "$withval" = "yes" -o "$withval" = "no"; then \
84     AC_MSG_WARN([You likely do not want either 'yes' or 'no' as]
85                      [a value for $1 ($2).  Maybe you do...?]); \
86   fi; \
87   \
88   AC_MSG_NOTICE([Setting $2 to $withval]); \
89   GIT_CONF_APPEND_LINE($2=$withval); \
90  fi)])# GIT_PARSE_WITH_SET_MAKE_VAR
92 dnl
93 dnl GIT_CHECK_FUNC(FUNCTION, IFTRUE, IFFALSE)
94 dnl -----------------------------------------
95 dnl Similar to AC_CHECK_FUNC, but on systems that do not generate
96 dnl warnings for missing prototypes (e.g. FreeBSD when compiling without
97 dnl -Wall), it does not work.  By looking for function definition in
98 dnl libraries, this problem can be worked around.
99 AC_DEFUN([GIT_CHECK_FUNC],[AC_CHECK_FUNC([$1],[
100   AC_SEARCH_LIBS([$1],,
101   [$2],[$3])
102 ],[$3])])
105 dnl GIT_STASH_FLAGS(BASEPATH_VAR)
106 dnl -----------------------------
107 dnl Allow for easy stashing of LDFLAGS and CPPFLAGS before running
108 dnl tests that may want to take user settings into account.
109 AC_DEFUN([GIT_STASH_FLAGS],[
110 if test -n "$1"; then
111    old_CPPFLAGS="$CPPFLAGS"
112    old_LDFLAGS="$LDFLAGS"
113    CPPFLAGS="-I$1/include $CPPFLAGS"
114    LDFLAGS="-L$1/$lib $LDFLAGS"
119 dnl GIT_UNSTASH_FLAGS(BASEPATH_VAR)
120 dnl -----------------------------
121 dnl Restore the stashed *FLAGS values.
122 AC_DEFUN([GIT_UNSTASH_FLAGS],[
123 if test -n "$1"; then
124    CPPFLAGS="$old_CPPFLAGS"
125    LDFLAGS="$old_LDFLAGS"
129 ## Site configuration related to programs (before tests)
130 ## --with-PACKAGE[=ARG] and --without-PACKAGE
132 # Set lib to alternative name of lib directory (e.g. lib64)
133 AC_ARG_WITH([lib],
134  [AS_HELP_STRING([--with-lib=ARG],
135                  [ARG specifies alternative name for lib directory])],
136  [if test "$withval" = "no" || test "$withval" = "yes"; then \
137         AC_MSG_WARN([You should provide name for --with-lib=ARG]); \
138 else \
139         lib=$withval; \
140         AC_MSG_NOTICE([Setting lib to '$lib']); \
141         GIT_CONF_APPEND_LINE(lib=$withval); \
142 fi; \
143 ],[])
145 if test -z "$lib"; then
146    AC_MSG_NOTICE([Setting lib to 'lib' (the default)])
147    lib=lib
150 AC_ARG_ENABLE([pthreads],
151  [AS_HELP_STRING([--enable-pthreads=FLAGS],
152   [FLAGS is the value to pass to the compiler to enable POSIX Threads.]
153   [The default if FLAGS is not specified is to try first -pthread]
154   [and then -lpthread.]
155   [--without-pthreads will disable threading.])],
157 if test "x$enableval" = "xyes"; then
158    AC_MSG_NOTICE([Will try -pthread then -lpthread to enable POSIX Threads])
159 elif test "x$enableval" != "xno"; then
160    PTHREAD_CFLAGS=$enableval
161    AC_MSG_NOTICE([Setting '$PTHREAD_CFLAGS' as the FLAGS to enable POSIX Threads])
162 else
163    AC_MSG_NOTICE([POSIX Threads will be disabled.])
164    NO_PTHREADS=YesPlease
165    USER_NOPTHREAD=1
166 fi],
168    AC_MSG_NOTICE([Will try -pthread then -lpthread to enable POSIX Threads.])
171 ## Site configuration (override autodetection)
172 ## --with-PACKAGE[=ARG] and --without-PACKAGE
173 AC_MSG_NOTICE([CHECKS for site configuration])
175 # Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
176 # tests.  These tests take up a significant amount of the total test time
177 # but are not needed unless you plan to talk to SVN repos.
179 # Define PPC_SHA1 environment variable when running make to make use of
180 # a bundled SHA1 routine optimized for PowerPC.
182 # Define NO_OPENSSL environment variable if you do not have OpenSSL.
183 # This also implies BLK_SHA1.
185 # Define OPENSSLDIR=/foo/bar if your openssl header and library files are in
186 # /foo/bar/include and /foo/bar/lib directories.
187 AC_ARG_WITH(openssl,
188 AS_HELP_STRING([--with-openssl],[use OpenSSL library (default is YES)])
189 AS_HELP_STRING([],              [ARG can be prefix for openssl library and headers]),\
190 GIT_PARSE_WITH(openssl))
192 # Define NO_CURL if you do not have curl installed.  git-http-pull and
193 # git-http-push are not built, and you cannot use http:// and https://
194 # transports.
196 # Define CURLDIR=/foo/bar if your curl header and library files are in
197 # /foo/bar/include and /foo/bar/lib directories.
198 AC_ARG_WITH(curl,
199 AS_HELP_STRING([--with-curl],[support http(s):// transports (default is YES)])
200 AS_HELP_STRING([],           [ARG can be also prefix for curl library and headers]),
201 GIT_PARSE_WITH(curl))
203 # Define NO_EXPAT if you do not have expat installed.  git-http-push is
204 # not built, and you cannot push using http:// and https:// transports.
206 # Define EXPATDIR=/foo/bar if your expat header and library files are in
207 # /foo/bar/include and /foo/bar/lib directories.
208 AC_ARG_WITH(expat,
209 AS_HELP_STRING([--with-expat],
210 [support git-push using http:// and https:// transports via WebDAV (default is YES)])
211 AS_HELP_STRING([],            [ARG can be also prefix for expat library and headers]),
212 GIT_PARSE_WITH(expat))
214 # Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
215 # installed in /sw, but don't want GIT to link against any libraries
216 # installed there.  If defined you may specify your own (or Fink's)
217 # include directories and library directories by defining CFLAGS
218 # and LDFLAGS appropriately.
220 # Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
221 # have DarwinPorts installed in /opt/local, but don't want GIT to
222 # link against any libraries installed there.  If defined you may
223 # specify your own (or DarwinPort's) include directories and
224 # library directories by defining CFLAGS and LDFLAGS appropriately.
226 # Define NO_MMAP if you want to avoid mmap.
228 # Define NO_ICONV if your libc does not properly support iconv.
229 AC_ARG_WITH(iconv,
230 AS_HELP_STRING([--without-iconv],
231 [if your architecture doesn't properly support iconv])
232 AS_HELP_STRING([--with-iconv=PATH],
233 [PATH is prefix for libiconv library and headers])
234 AS_HELP_STRING([],
235 [used only if you need linking with libiconv]),
236 GIT_PARSE_WITH(iconv))
238 ## --enable-FEATURE[=ARG] and --disable-FEATURE
240 # Define USE_NSEC below if you want git to care about sub-second file mtimes
241 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
242 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
243 # randomly break unless your underlying filesystem supports those sub-second
244 # times (my ext3 doesn't).
246 # Define USE_STDEV below if you want git to care about the underlying device
247 # change being considered an inode change from the update-index perspective.
250 # Allow user to set ETC_GITCONFIG variable
251 GIT_PARSE_WITH_SET_MAKE_VAR(gitconfig, ETC_GITCONFIG,
252                         Use VALUE instead of /etc/gitconfig as the
253                         global git configuration file.
254                         If VALUE is not fully qualified it will be interpretted
255                         as a path relative to the computed prefix at runtime.)
258 # Allow user to set the default pager
259 GIT_PARSE_WITH_SET_MAKE_VAR(pager, DEFAULT_PAGER,
260                         Use VALUE as the fall-back pager instead of 'less'.
261                         This is used by things like 'git log' when the user
262                         does not specify a pager to use through alternate
263                         methods. eg: /usr/bin/pager)
265 # Allow user to set the default editor
266 GIT_PARSE_WITH_SET_MAKE_VAR(editor, DEFAULT_EDITOR,
267                         Use VALUE as the fall-back editor instead of 'vi'.
268                         This is used by things like 'git commit' when the user
269                         does not specify a preferred editor through other
270                         methods. eg: /usr/bin/editor)
273 # Define SHELL_PATH to provide path to shell.
274 GIT_ARG_SET_PATH(shell)
276 # Define PERL_PATH to provide path to Perl.
277 GIT_ARG_SET_PATH(perl)
279 # Define ZLIB_PATH to provide path to zlib.
280 GIT_ARG_SET_PATH(zlib)
282 # Declare the with-tcltk/without-tcltk options.
283 AC_ARG_WITH(tcltk,
284 AS_HELP_STRING([--with-tcltk],[use Tcl/Tk GUI (default is YES)])
285 AS_HELP_STRING([],[ARG is the full path to the Tcl/Tk interpreter.])
286 AS_HELP_STRING([],[Bare --with-tcltk will make the GUI part only if])
287 AS_HELP_STRING([],[Tcl/Tk interpreter will be found in a system.]),\
288 GIT_PARSE_WITH(tcltk))
292 ## Checks for programs.
293 AC_MSG_NOTICE([CHECKS for programs])
295 AC_PROG_CC([cc gcc])
296 # which switch to pass runtime path to dynamic libraries to the linker
297 AC_CACHE_CHECK([if linker supports -R], git_cv_ld_dashr, [
298    SAVE_LDFLAGS="${LDFLAGS}"
299    LDFLAGS="${SAVE_LDFLAGS} -R /"
300    AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [git_cv_ld_dashr=yes], [git_cv_ld_dashr=no])
301    LDFLAGS="${SAVE_LDFLAGS}"
303 if test "$git_cv_ld_dashr" = "yes"; then
304    AC_SUBST(CC_LD_DYNPATH, [-R])
305 else
306    AC_CACHE_CHECK([if linker supports -Wl,-rpath,], git_cv_ld_wl_rpath, [
307       SAVE_LDFLAGS="${LDFLAGS}"
308       LDFLAGS="${SAVE_LDFLAGS} -Wl,-rpath,/"
309       AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [git_cv_ld_wl_rpath=yes], [git_cv_ld_wl_rpath=no])
310       LDFLAGS="${SAVE_LDFLAGS}"
311    ])
312    if test "$git_cv_ld_wl_rpath" = "yes"; then
313       AC_SUBST(CC_LD_DYNPATH, [-Wl,-rpath,])
314    else
315       AC_CACHE_CHECK([if linker supports -rpath], git_cv_ld_rpath, [
316          SAVE_LDFLAGS="${LDFLAGS}"
317          LDFLAGS="${SAVE_LDFLAGS} -rpath /"
318          AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [git_cv_ld_rpath=yes], [git_cv_ld_rpath=no])
319          LDFLAGS="${SAVE_LDFLAGS}"
320       ])
321       if test "$git_cv_ld_rpath" = "yes"; then
322          AC_SUBST(CC_LD_DYNPATH, [-rpath])
323       else
324          AC_MSG_WARN([linker does not support runtime path to dynamic libraries])
325       fi
326    fi
328 #AC_PROG_INSTALL                # needs install-sh or install.sh in sources
329 AC_CHECK_TOOLS(AR, [gar ar], :)
330 AC_CHECK_PROGS(TAR, [gtar tar])
331 # TCLTK_PATH will be set to some value if we want Tcl/Tk
332 # or will be empty otherwise.
333 if test -z "$NO_TCLTK"; then
334   if test "$with_tcltk" = ""; then
335   # No Tcl/Tk switches given. Do not check for Tcl/Tk, use bare 'wish'.
336     TCLTK_PATH=wish
337     AC_SUBST(TCLTK_PATH)
338   elif test "$with_tcltk" = "yes"; then
339   # Tcl/Tk check requested.
340     AC_CHECK_PROGS(TCLTK_PATH, [wish], )
341   else
342     AC_MSG_RESULT([Using Tcl/Tk interpreter $with_tcltk])
343     TCLTK_PATH="$with_tcltk"
344     AC_SUBST(TCLTK_PATH)
345   fi
347 AC_CHECK_PROGS(ASCIIDOC, [asciidoc])
348 if test -n "$ASCIIDOC"; then
349         AC_MSG_CHECKING([for asciidoc version])
350         asciidoc_version=`$ASCIIDOC --version 2>/dev/null`
351         case "${asciidoc_version}" in
352         asciidoc' '8*)
353                 ASCIIDOC8=YesPlease
354                 AC_MSG_RESULT([${asciidoc_version} > 7])
355                 ;;
356         asciidoc' '7*)
357                 ASCIIDOC8=
358                 AC_MSG_RESULT([${asciidoc_version}])
359                 ;;
360         *)
361                 ASCIIDOC8=
362                 AC_MSG_RESULT([${asciidoc_version} (unknown)])
363                 ;;
364         esac
366 AC_SUBST(ASCIIDOC8)
369 ## Checks for libraries.
370 AC_MSG_NOTICE([CHECKS for libraries])
372 # Define NO_OPENSSL environment variable if you do not have OpenSSL.
373 # Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
375 GIT_STASH_FLAGS($OPENSSLDIR)
377 AC_CHECK_LIB([crypto], [SHA1_Init],
378 [NEEDS_SSL_WITH_CRYPTO=],
379 [AC_CHECK_LIB([ssl], [SHA1_Init],
380  [NEEDS_SSL_WITH_CRYPTO=YesPlease],
381  [NEEDS_SSL_WITH_CRYPTO= NO_OPENSSL=YesPlease])])
383 GIT_UNSTASH_FLAGS($OPENSSLDIR)
385 AC_SUBST(NEEDS_SSL_WITH_CRYPTO)
386 AC_SUBST(NO_OPENSSL)
389 # Define NO_CURL if you do not have libcurl installed.  git-http-pull and
390 # git-http-push are not built, and you cannot use http:// and https://
391 # transports.
393 GIT_STASH_FLAGS($CURLDIR)
395 AC_CHECK_LIB([curl], [curl_global_init],
396 [NO_CURL=],
397 [NO_CURL=YesPlease])
399 GIT_UNSTASH_FLAGS($CURLDIR)
401 AC_SUBST(NO_CURL)
404 # Define NO_EXPAT if you do not have expat installed.  git-http-push is
405 # not built, and you cannot push using http:// and https:// transports.
407 GIT_STASH_FLAGS($EXPATDIR)
409 AC_CHECK_LIB([expat], [XML_ParserCreate],
410 [NO_EXPAT=],
411 [NO_EXPAT=YesPlease])
413 GIT_UNSTASH_FLAGS($EXPATDIR)
415 AC_SUBST(NO_EXPAT)
418 # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin and
419 # some Solaris installations).
420 # Define NO_ICONV if neither libc nor libiconv support iconv.
422 if test -z "$NO_ICONV"; then
424 GIT_STASH_FLAGS($ICONVDIR)
426 AC_DEFUN([ICONVTEST_SRC], [
427 #include <iconv.h>
429 int main(void)
431         iconv_open("", "");
432         return 0;
436 if test -n "$ICONVDIR"; then
437    lib_order="-liconv -lc"
438 else
439    lib_order="-lc -liconv"
442 NO_ICONV=YesPlease
444 for l in $lib_order; do
445     if test "$l" = "-liconv"; then
446        NEEDS_LIBICONV=YesPlease
447     else
448        NEEDS_LIBICONV=
449     fi
451     old_LIBS="$LIBS"
452     LIBS="$LIBS $l"
453     AC_MSG_CHECKING([for iconv in $l])
454     AC_LINK_IFELSE(ICONVTEST_SRC,
455         [AC_MSG_RESULT([yes])
456         NO_ICONV=
457         break],
458         [AC_MSG_RESULT([no])])
459     LIBS="$old_LIBS"
460 done
462 #in case of break
463 LIBS="$old_LIBS"
465 GIT_UNSTASH_FLAGS($ICONVDIR)
467 AC_SUBST(NEEDS_LIBICONV)
468 AC_SUBST(NO_ICONV)
470 if test -n "$NO_ICONV"; then
471     NEEDS_LIBICONV=
477 # Define NO_DEFLATE_BOUND if deflateBound is missing from zlib.
479 GIT_STASH_FLAGS($ZLIB_PATH)
481 AC_DEFUN([ZLIBTEST_SRC], [
482 #include <zlib.h>
484 int main(void)
486         deflateBound(0, 0);
487         return 0;
490 AC_MSG_CHECKING([for deflateBound in -lz])
491 old_LIBS="$LIBS"
492 LIBS="$LIBS -lz"
493 AC_LINK_IFELSE(ZLIBTEST_SRC,
494         [AC_MSG_RESULT([yes])],
495         [AC_MSG_RESULT([no])
496         NO_DEFLATE_BOUND=yes])
497 LIBS="$old_LIBS"
499 GIT_UNSTASH_FLAGS($ZLIB_PATH)
501 AC_SUBST(NO_DEFLATE_BOUND)
504 # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
505 # Patrick Mauritz).
506 AC_CHECK_LIB([c], [socket],
507 [NEEDS_SOCKET=],
508 [NEEDS_SOCKET=YesPlease])
509 AC_SUBST(NEEDS_SOCKET)
510 test -n "$NEEDS_SOCKET" && LIBS="$LIBS -lsocket"
513 # Define NEEDS_RESOLV if linking with -lnsl and/or -lsocket is not enough.
514 # Notably on Solaris hstrerror resides in libresolv and on Solaris 7
515 # inet_ntop and inet_pton additionally reside there.
516 AC_CHECK_LIB([c], [hstrerror],
517 [NEEDS_RESOLV=],
518 [NEEDS_RESOLV=YesPlease])
519 AC_SUBST(NEEDS_RESOLV)
520 test -n "$NEEDS_RESOLV" && LIBS="$LIBS -lresolv"
522 AC_CHECK_LIB([c], [basename],
523 [NEEDS_LIBGEN=],
524 [NEEDS_LIBGEN=YesPlease])
525 AC_SUBST(NEEDS_LIBGEN)
526 test -n "$NEEDS_LIBGEN" && LIBS="$LIBS -lgen"
528 ## Checks for header files.
529 AC_MSG_NOTICE([CHECKS for header files])
531 # Define NO_SYS_SELECT_H if you don't have sys/select.h.
532 AC_CHECK_HEADER([sys/select.h],
533 [NO_SYS_SELECT_H=],
534 [NO_SYS_SELECT_H=UnfortunatelyYes])
535 AC_SUBST(NO_SYS_SELECT_H)
537 # Define OLD_ICONV if your library has an old iconv(), where the second
538 # (input buffer pointer) parameter is declared with type (const char **).
539 AC_DEFUN([OLDICONVTEST_SRC], [[
540 #include <iconv.h>
542 extern size_t iconv(iconv_t cd,
543                     char **inbuf, size_t *inbytesleft,
544                     char **outbuf, size_t *outbytesleft);
546 int main(void)
548         return 0;
552 GIT_STASH_FLAGS($ICONVDIR)
554 AC_MSG_CHECKING([for old iconv()])
555 AC_COMPILE_IFELSE(OLDICONVTEST_SRC,
556         [AC_MSG_RESULT([no])],
557         [AC_MSG_RESULT([yes])
558         OLD_ICONV=UnfortunatelyYes])
560 GIT_UNSTASH_FLAGS($ICONVDIR)
562 AC_SUBST(OLD_ICONV)
564 ## Checks for typedefs, structures, and compiler characteristics.
565 AC_MSG_NOTICE([CHECKS for typedefs, structures, and compiler characteristics])
567 # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
568 AC_CHECK_MEMBER(struct dirent.d_ino,
569 [NO_D_INO_IN_DIRENT=],
570 [NO_D_INO_IN_DIRENT=YesPlease],
571 [#include <dirent.h>])
572 AC_SUBST(NO_D_INO_IN_DIRENT)
574 # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
575 # d_type in struct dirent (latest Cygwin -- will be fixed soonish).
576 AC_CHECK_MEMBER(struct dirent.d_type,
577 [NO_D_TYPE_IN_DIRENT=],
578 [NO_D_TYPE_IN_DIRENT=YesPlease],
579 [#include <dirent.h>])
580 AC_SUBST(NO_D_TYPE_IN_DIRENT)
582 # Define NO_SOCKADDR_STORAGE if your platform does not have struct
583 # sockaddr_storage.
584 AC_CHECK_TYPE(struct sockaddr_storage,
585 [NO_SOCKADDR_STORAGE=],
586 [NO_SOCKADDR_STORAGE=YesPlease],[
587 #include <sys/types.h>
588 #include <sys/socket.h>
590 AC_SUBST(NO_SOCKADDR_STORAGE)
592 # Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
593 AC_CHECK_TYPE([struct addrinfo],[
594  GIT_CHECK_FUNC([getaddrinfo],
595   [NO_IPV6=],
596   [NO_IPV6=YesPlease])
597 ],[NO_IPV6=YesPlease],[
598 #include <sys/types.h>
599 #include <sys/socket.h>
600 #include <netdb.h>
602 AC_SUBST(NO_IPV6)
604 # Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
605 # do not support the 'size specifiers' introduced by C99, namely ll, hh,
606 # j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
607 # some C compilers supported these specifiers prior to C99 as an extension.
608 AC_CACHE_CHECK([whether formatted IO functions support C99 size specifiers],
609  [ac_cv_c_c99_format],
610 [# Actually git uses only %z (%zu) in alloc.c, and %t (%td) in mktag.c
611 AC_RUN_IFELSE(
612         [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
613                 [[char buf[64];
614                 if (sprintf(buf, "%lld%hhd%jd%zd%td", (long long int)1, (char)2, (intmax_t)3, (size_t)4, (ptrdiff_t)5) != 5)
615                   return 1;
616                 else if (strcmp(buf, "12345"))
617                   return 2;]])],
618         [ac_cv_c_c99_format=yes],
619         [ac_cv_c_c99_format=no])
621 if test $ac_cv_c_c99_format = no; then
622         NO_C99_FORMAT=YesPlease
623 else
624         NO_C99_FORMAT=
626 AC_SUBST(NO_C99_FORMAT)
628 # Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
629 # when attempting to read from an fopen'ed directory.
630 AC_CACHE_CHECK([whether system succeeds to read fopen'ed directory],
631  [ac_cv_fread_reads_directories],
633 AC_RUN_IFELSE(
634         [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
635                 [[char c;
636                 FILE *f = fopen(".", "r");
637                 return f && fread(&c, 1, 1, f)]])],
638         [ac_cv_fread_reads_directories=no],
639         [ac_cv_fread_reads_directories=yes])
641 if test $ac_cv_fread_reads_directories = yes; then
642         FREAD_READS_DIRECTORIES=UnfortunatelyYes
643 else
644         FREAD_READS_DIRECTORIES=
646 AC_SUBST(FREAD_READS_DIRECTORIES)
648 # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
649 # or vsnprintf() return -1 instead of number of characters which would
650 # have been written to the final string if enough space had been available.
651 AC_CACHE_CHECK([whether snprintf() and/or vsnprintf() return bogus value],
652  [ac_cv_snprintf_returns_bogus],
654 AC_RUN_IFELSE(
655         [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
656                 #include "stdarg.h"
658                 int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
659                 {
660                   int ret;
661                   va_list ap;
662                   va_start(ap, format);
663                   ret = vsnprintf(str, maxsize, format, ap);
664                   va_end(ap);
665                   return ret;
666                 }],
667                 [[char buf[6];
668                   if (test_vsnprintf(buf, 3, "%s", "12345") != 5
669                       || strcmp(buf, "12")) return 1;
670                   if (snprintf(buf, 3, "%s", "12345") != 5
671                       || strcmp(buf, "12")) return 1]])],
672         [ac_cv_snprintf_returns_bogus=no],
673         [ac_cv_snprintf_returns_bogus=yes])
675 if test $ac_cv_snprintf_returns_bogus = yes; then
676         SNPRINTF_RETURNS_BOGUS=UnfortunatelyYes
677 else
678         SNPRINTF_RETURNS_BOGUS=
680 AC_SUBST(SNPRINTF_RETURNS_BOGUS)
683 ## Checks for library functions.
684 ## (in default C library and libraries checked by AC_CHECK_LIB)
685 AC_MSG_NOTICE([CHECKS for library functions])
687 # Define NO_LIBGEN_H if you don't have libgen.h.
688 AC_CHECK_HEADER([libgen.h],
689 [NO_LIBGEN_H=],
690 [NO_LIBGEN_H=YesPlease])
691 AC_SUBST(NO_LIBGEN_H)
693 # Define NO_STRCASESTR if you don't have strcasestr.
694 GIT_CHECK_FUNC(strcasestr,
695 [NO_STRCASESTR=],
696 [NO_STRCASESTR=YesPlease])
697 AC_SUBST(NO_STRCASESTR)
699 # Define NO_MEMMEM if you don't have memmem.
700 GIT_CHECK_FUNC(memmem,
701 [NO_MEMMEM=],
702 [NO_MEMMEM=YesPlease])
703 AC_SUBST(NO_MEMMEM)
705 # Define NO_STRLCPY if you don't have strlcpy.
706 GIT_CHECK_FUNC(strlcpy,
707 [NO_STRLCPY=],
708 [NO_STRLCPY=YesPlease])
709 AC_SUBST(NO_STRLCPY)
711 # Define NO_UINTMAX_T if your platform does not have uintmax_t
712 AC_CHECK_TYPE(uintmax_t,
713 [NO_UINTMAX_T=],
714 [NO_UINTMAX_T=YesPlease],[
715 #include <inttypes.h>
717 AC_SUBST(NO_UINTMAX_T)
719 # Define NO_STRTOUMAX if you don't have strtoumax in the C library.
720 GIT_CHECK_FUNC(strtoumax,
721 [NO_STRTOUMAX=],
722 [NO_STRTOUMAX=YesPlease])
723 AC_SUBST(NO_STRTOUMAX)
725 # Define NO_SETENV if you don't have setenv in the C library.
726 GIT_CHECK_FUNC(setenv,
727 [NO_SETENV=],
728 [NO_SETENV=YesPlease])
729 AC_SUBST(NO_SETENV)
731 # Define NO_UNSETENV if you don't have unsetenv in the C library.
732 GIT_CHECK_FUNC(unsetenv,
733 [NO_UNSETENV=],
734 [NO_UNSETENV=YesPlease])
735 AC_SUBST(NO_UNSETENV)
737 # Define NO_MKDTEMP if you don't have mkdtemp in the C library.
738 GIT_CHECK_FUNC(mkdtemp,
739 [NO_MKDTEMP=],
740 [NO_MKDTEMP=YesPlease])
741 AC_SUBST(NO_MKDTEMP)
743 # Define NO_MKSTEMPS if you don't have mkstemps in the C library.
744 GIT_CHECK_FUNC(mkstemps,
745 [NO_MKSTEMPS=],
746 [NO_MKSTEMPS=YesPlease])
747 AC_SUBST(NO_MKSTEMPS)
750 # Define NO_MMAP if you want to avoid mmap.
752 # Define NO_ICONV if your libc does not properly support iconv.
755 ## Other checks.
756 # Define USE_PIC if you need the main git objects to be built with -fPIC
757 # in order to build and link perl/Git.so.  x86-64 seems to need this.
759 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
760 # Enable it on Windows.  By default, symrefs are still used.
762 # Define NO_PTHREADS if we do not have pthreads
764 # Define PTHREAD_LIBS to the linker flag used for Pthread support and define
765 # THREADED_DELTA_SEARCH if Pthreads are available.
766 AC_DEFUN([PTHREADTEST_SRC], [
767 #include <pthread.h>
769 int main(void)
771         pthread_mutex_t test_mutex;
772         return (0);
776 dnl AC_LANG_CONFTEST([AC_LANG_PROGRAM(
777 dnl   [[#include <pthread.h>]],
778 dnl   [[pthread_mutex_t test_mutex;]]
779 dnl )])
781 NO_PTHREADS=UnfortunatelyYes
782 THREADED_DELTA_SEARCH=
783 PTHREAD_LIBS=
785 if test -n "$USER_NOPTHREAD"; then
786    AC_MSG_NOTICE([Skipping POSIX Threads at user request.])
787 # handle these separately since PTHREAD_CFLAGS could be '-lpthreads
788 # -D_REENTRANT' or some such.
789 elif test -z "$PTHREAD_CFLAGS"; then
790   for opt in -pthread -lpthread; do
791      old_CFLAGS="$CFLAGS"
792      CFLAGS="$opt $CFLAGS"
793      AC_MSG_CHECKING([Checking for POSIX Threads with '$opt'])
794      AC_LINK_IFELSE(PTHREADTEST_SRC,
795         [AC_MSG_RESULT([yes])
796                 NO_PTHREADS=
797                 PTHREAD_LIBS="$opt"
798                 THREADED_DELTA_SEARCH=YesPlease
799                 break
800         ],
801         [AC_MSG_RESULT([no])])
802       CFLAGS="$old_CFLAGS"
803   done
804 else
805   old_CFLAGS="$CFLAGS"
806   CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
807   AC_MSG_CHECKING([Checking for POSIX Threads with '$PTHREAD_CFLAGS'])
808   AC_LINK_IFELSE(PTHREADTEST_SRC,
809         [AC_MSG_RESULT([yes])
810                 NO_PTHREADS=
811                 PTHREAD_LIBS="$PTHREAD_CFLAGS"
812                 THREADED_DELTA_SEARCH=YesPlease
813         ],
814         [AC_MSG_RESULT([no])])
816   CFLAGS="$old_CFLAGS"
819 CFLAGS="$old_CFLAGS"
821 AC_SUBST(PTHREAD_LIBS)
822 AC_SUBST(NO_PTHREADS)
823 AC_SUBST(THREADED_DELTA_SEARCH)
825 ## Output files
826 AC_CONFIG_FILES(["${config_file}":"${config_in}":"${config_append}"])
827 AC_OUTPUT
830 ## Cleanup
831 rm -f "${config_append}"