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