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