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