configure.ac 24.0 KB
Newer Older
1 2 3 4
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
5
AC_INIT([git], [@@GIT_VERSION@@], [git@vger.kernel.org])
6 7 8 9

AC_CONFIG_SRCDIR([git.c])

config_file=config.mak.autogen
10
config_append=config.mak.append
11 12
config_in=config.mak.in

13 14 15 16 17 18 19 20 21
echo "# ${config_append}.  Generated by configure." > "${config_append}"


## Definitions of macros
# GIT_CONF_APPEND_LINE(LINE)
# --------------------------
# Append LINE to file ${config_append}
AC_DEFUN([GIT_CONF_APPEND_LINE],
[echo "$1" >> "${config_append}"])# GIT_CONF_APPEND_LINE
22 23 24 25
#
# GIT_ARG_SET_PATH(PROGRAM)
# -------------------------
# Provide --with-PROGRAM=PATH option to set PATH to PROGRAM
26 27
# Optional second argument allows setting NO_PROGRAM=YesPlease if
# --without-PROGRAM version used.
28 29 30 31
AC_DEFUN([GIT_ARG_SET_PATH],
[AC_ARG_WITH([$1],
 [AS_HELP_STRING([--with-$1=PATH],
                 [provide PATH to $1])],
32
 [GIT_CONF_APPEND_PATH($1,$2)],[])
33 34 35 36 37 38
])# GIT_ARG_SET_PATH
#
# GIT_CONF_APPEND_PATH(PROGRAM)
# ------------------------------
# Parse --with-PROGRAM=PATH option to set PROGRAM_PATH=PATH
# Used by GIT_ARG_SET_PATH(PROGRAM)
39 40
# Optional second argument allows setting NO_PROGRAM=YesPlease if
# --without-PROGRAM is used.
41 42 43
AC_DEFUN([GIT_CONF_APPEND_PATH],
[PROGRAM=m4_toupper($1); \
if test "$withval" = "no"; then \
44 45 46 47 48 49 50 51
	if test -n "$2"; then \
		m4_toupper($1)_PATH=$withval; \
		AC_MSG_NOTICE([Disabling use of ${PROGRAM}]); \
		GIT_CONF_APPEND_LINE(NO_${PROGRAM}=YesPlease); \
		GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=); \
	else \
		AC_MSG_ERROR([You cannot use git without $1]); \
	fi; \
52 53 54 55
else \
	if test "$withval" = "yes"; then \
		AC_MSG_WARN([You should provide path for --with-$1=PATH]); \
	else \
56 57
		m4_toupper($1)_PATH=$withval; \
		AC_MSG_NOTICE([Setting m4_toupper($1)_PATH to $withval]); \
58 59 60 61
		GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=$withval); \
	fi; \
fi; \
]) # GIT_CONF_APPEND_PATH
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
#
# GIT_PARSE_WITH(PACKAGE)
# -----------------------
# For use in AC_ARG_WITH action-if-found, for packages default ON.
# * Set NO_PACKAGE=YesPlease for --without-PACKAGE
# * Set PACKAGEDIR=PATH for --with-PACKAGE=PATH
# * Unset NO_PACKAGE for --with-PACKAGE without ARG
AC_DEFUN([GIT_PARSE_WITH],
[PACKAGE=m4_toupper($1); \
if test "$withval" = "no"; then \
	m4_toupper(NO_$1)=YesPlease; \
elif test "$withval" = "yes"; then \
	m4_toupper(NO_$1)=; \
else \
	m4_toupper(NO_$1)=; \
77 78
	m4_toupper($1)DIR=$withval; \
	AC_MSG_NOTICE([Setting m4_toupper($1)DIR to $withval]); \
79 80 81
	GIT_CONF_APPEND_LINE(${PACKAGE}DIR=$withval); \
fi \
])# GIT_PARSE_WITH
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
#
# GIT_PARSE_WITH_SET_MAKE_VAR(WITHNAME, VAR, HELP_TEXT)
# ---------------------
# Set VAR to the value specied by --with-WITHNAME.
# No verification of arguments is performed, but warnings are issued
# if either 'yes' or 'no' is specified.
# HELP_TEXT is presented when --help is called.
# This is a direct way to allow setting variables in the Makefile.
AC_DEFUN([GIT_PARSE_WITH_SET_MAKE_VAR],
[AC_ARG_WITH([$1],
 [AS_HELP_STRING([--with-$1=VALUE], $3)],
 if test -n "$withval"; then \
  if test "$withval" = "yes" -o "$withval" = "no"; then \
    AC_MSG_WARN([You likely do not want either 'yes' or 'no' as]
		     [a value for $1 ($2).  Maybe you do...?]); \
  fi; \
  \
  AC_MSG_NOTICE([Setting $2 to $withval]); \
  GIT_CONF_APPEND_LINE($2=$withval); \
 fi)])# GIT_PARSE_WITH_SET_MAKE_VAR
102

103 104 105 106 107 108 109 110 111 112 113
dnl
dnl GIT_CHECK_FUNC(FUNCTION, IFTRUE, IFFALSE)
dnl -----------------------------------------
dnl Similar to AC_CHECK_FUNC, but on systems that do not generate
dnl warnings for missing prototypes (e.g. FreeBSD when compiling without
dnl -Wall), it does not work.  By looking for function definition in
dnl libraries, this problem can be worked around.
AC_DEFUN([GIT_CHECK_FUNC],[AC_CHECK_FUNC([$1],[
  AC_SEARCH_LIBS([$1],,
  [$2],[$3])
],[$3])])
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139

dnl
dnl GIT_STASH_FLAGS(BASEPATH_VAR)
dnl -----------------------------
dnl Allow for easy stashing of LDFLAGS and CPPFLAGS before running
dnl tests that may want to take user settings into account.
AC_DEFUN([GIT_STASH_FLAGS],[
if test -n "$1"; then
   old_CPPFLAGS="$CPPFLAGS"
   old_LDFLAGS="$LDFLAGS"
   CPPFLAGS="-I$1/include $CPPFLAGS"
   LDFLAGS="-L$1/$lib $LDFLAGS"
fi
])

dnl
dnl GIT_UNSTASH_FLAGS(BASEPATH_VAR)
dnl -----------------------------
dnl Restore the stashed *FLAGS values.
AC_DEFUN([GIT_UNSTASH_FLAGS],[
if test -n "$1"; then
   CPPFLAGS="$old_CPPFLAGS"
   LDFLAGS="$old_LDFLAGS"
fi
])

140
## Site configuration related to programs (before tests)
141 142
## --with-PACKAGE[=ARG] and --without-PACKAGE
#
143 144 145 146
# Set lib to alternative name of lib directory (e.g. lib64)
AC_ARG_WITH([lib],
 [AS_HELP_STRING([--with-lib=ARG],
                 [ARG specifies alternative name for lib directory])],
R
Ralf Wildenhues 已提交
147
 [if test "$withval" = "no" || test "$withval" = "yes"; then \
148 149
	AC_MSG_WARN([You should provide name for --with-lib=ARG]); \
else \
150 151
	lib=$withval; \
	AC_MSG_NOTICE([Setting lib to '$lib']); \
152 153 154
	GIT_CONF_APPEND_LINE(lib=$withval); \
fi; \
],[])
155 156 157 158 159

if test -z "$lib"; then
   AC_MSG_NOTICE([Setting lib to 'lib' (the default)])
   lib=lib
fi
160

161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
AC_ARG_ENABLE([pthreads],
 [AS_HELP_STRING([--enable-pthreads=FLAGS],
  [FLAGS is the value to pass to the compiler to enable POSIX Threads.]
  [The default if FLAGS is not specified is to try first -pthread]
  [and then -lpthread.]
  [--without-pthreads will disable threading.])],
[
if test "x$enableval" = "xyes"; then
   AC_MSG_NOTICE([Will try -pthread then -lpthread to enable POSIX Threads])
elif test "x$enableval" != "xno"; then
   PTHREAD_CFLAGS=$enableval
   AC_MSG_NOTICE([Setting '$PTHREAD_CFLAGS' as the FLAGS to enable POSIX Threads])
else
   AC_MSG_NOTICE([POSIX Threads will be disabled.])
   NO_PTHREADS=YesPlease
   USER_NOPTHREAD=1
fi],
[
   AC_MSG_NOTICE([Will try -pthread then -lpthread to enable POSIX Threads.])
])

182 183 184 185 186 187 188 189 190 191 192 193
## Site configuration (override autodetection)
## --with-PACKAGE[=ARG] and --without-PACKAGE
AC_MSG_NOTICE([CHECKS for site configuration])
#
# Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
# tests.  These tests take up a significant amount of the total test time
# but are not needed unless you plan to talk to SVN repos.
#
# Define PPC_SHA1 environment variable when running make to make use of
# a bundled SHA1 routine optimized for PowerPC.
#
# Define NO_OPENSSL environment variable if you do not have OpenSSL.
194
# This also implies BLK_SHA1.
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
#
# Define OPENSSLDIR=/foo/bar if your openssl header and library files are in
# /foo/bar/include and /foo/bar/lib directories.
AC_ARG_WITH(openssl,
AS_HELP_STRING([--with-openssl],[use OpenSSL library (default is YES)])
AS_HELP_STRING([],              [ARG can be prefix for openssl library and headers]),\
GIT_PARSE_WITH(openssl))
#
# Define NO_CURL if you do not have curl installed.  git-http-pull and
# git-http-push are not built, and you cannot use http:// and https://
# transports.
#
# Define CURLDIR=/foo/bar if your curl header and library files are in
# /foo/bar/include and /foo/bar/lib directories.
AC_ARG_WITH(curl,
AS_HELP_STRING([--with-curl],[support http(s):// transports (default is YES)])
AS_HELP_STRING([],           [ARG can be also prefix for curl library and headers]),
GIT_PARSE_WITH(curl))
#
# Define NO_EXPAT if you do not have expat installed.  git-http-push is
# not built, and you cannot push using http:// and https:// transports.
#
# Define EXPATDIR=/foo/bar if your expat header and library files are in
# /foo/bar/include and /foo/bar/lib directories.
AC_ARG_WITH(expat,
AS_HELP_STRING([--with-expat],
[support git-push using http:// and https:// transports via WebDAV (default is YES)])
AS_HELP_STRING([],            [ARG can be also prefix for expat library and headers]),
GIT_PARSE_WITH(expat))
#
# Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
# installed in /sw, but don't want GIT to link against any libraries
# installed there.  If defined you may specify your own (or Fink's)
# include directories and library directories by defining CFLAGS
# and LDFLAGS appropriately.
#
# Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
# have DarwinPorts installed in /opt/local, but don't want GIT to
# link against any libraries installed there.  If defined you may
# specify your own (or DarwinPort's) include directories and
# library directories by defining CFLAGS and LDFLAGS appropriately.
#
# Define NO_MMAP if you want to avoid mmap.
#
# Define NO_ICONV if your libc does not properly support iconv.
AC_ARG_WITH(iconv,
AS_HELP_STRING([--without-iconv],
[if your architecture doesn't properly support iconv])
AS_HELP_STRING([--with-iconv=PATH],
[PATH is prefix for libiconv library and headers])
AS_HELP_STRING([],
[used only if you need linking with libiconv]),
GIT_PARSE_WITH(iconv))

## --enable-FEATURE[=ARG] and --disable-FEATURE
#
# Define USE_NSEC below if you want git to care about sub-second file mtimes
# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
# randomly break unless your underlying filesystem supports those sub-second
# times (my ext3 doesn't).
#
# Define USE_STDEV below if you want git to care about the underlying device
# change being considered an inode change from the update-index perspective.

260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
#
# Allow user to set ETC_GITCONFIG variable
GIT_PARSE_WITH_SET_MAKE_VAR(gitconfig, ETC_GITCONFIG,
			Use VALUE instead of /etc/gitconfig as the
			global git configuration file.
			If VALUE is not fully qualified it will be interpretted
			as a path relative to the computed prefix at runtime.)

#
# Allow user to set the default pager
GIT_PARSE_WITH_SET_MAKE_VAR(pager, DEFAULT_PAGER,
			Use VALUE as the fall-back pager instead of 'less'.
			This is used by things like 'git log' when the user
			does not specify a pager to use through alternate
			methods. eg: /usr/bin/pager)
#
# Allow user to set the default editor
GIT_PARSE_WITH_SET_MAKE_VAR(editor, DEFAULT_EDITOR,
			Use VALUE as the fall-back editor instead of 'vi'.
			This is used by things like 'git commit' when the user
			does not specify a preferred editor through other
			methods. eg: /usr/bin/editor)

283
#
284 285 286 287 288 289
# Define SHELL_PATH to provide path to shell.
GIT_ARG_SET_PATH(shell)
#
# Define PERL_PATH to provide path to Perl.
GIT_ARG_SET_PATH(perl)
#
290
# Define PYTHON_PATH to provide path to Python.
B
Ben Walton 已提交
291
GIT_ARG_SET_PATH(python, allow-without)
292
#
293 294 295
# Define ZLIB_PATH to provide path to zlib.
GIT_ARG_SET_PATH(zlib)
#
296 297 298 299 300 301 302 303
# Declare the with-tcltk/without-tcltk options.
AC_ARG_WITH(tcltk,
AS_HELP_STRING([--with-tcltk],[use Tcl/Tk GUI (default is YES)])
AS_HELP_STRING([],[ARG is the full path to the Tcl/Tk interpreter.])
AS_HELP_STRING([],[Bare --with-tcltk will make the GUI part only if])
AS_HELP_STRING([],[Tcl/Tk interpreter will be found in a system.]),\
GIT_PARSE_WITH(tcltk))
#
304 305


306
## Checks for programs.
307
AC_MSG_NOTICE([CHECKS for programs])
308
#
D
Dennis Stosberg 已提交
309
AC_PROG_CC([cc gcc])
310
# which switch to pass runtime path to dynamic libraries to the linker
311
AC_CACHE_CHECK([if linker supports -R], git_cv_ld_dashr, [
312 313
   SAVE_LDFLAGS="${LDFLAGS}"
   LDFLAGS="${SAVE_LDFLAGS} -R /"
314
   AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [git_cv_ld_dashr=yes], [git_cv_ld_dashr=no])
315 316
   LDFLAGS="${SAVE_LDFLAGS}"
])
317
if test "$git_cv_ld_dashr" = "yes"; then
318 319
   AC_SUBST(CC_LD_DYNPATH, [-R])
else
320
   AC_CACHE_CHECK([if linker supports -Wl,-rpath,], git_cv_ld_wl_rpath, [
321 322
      SAVE_LDFLAGS="${LDFLAGS}"
      LDFLAGS="${SAVE_LDFLAGS} -Wl,-rpath,/"
323
      AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [git_cv_ld_wl_rpath=yes], [git_cv_ld_wl_rpath=no])
P
Paul Jarc 已提交
324
      LDFLAGS="${SAVE_LDFLAGS}"
325
   ])
326
   if test "$git_cv_ld_wl_rpath" = "yes"; then
327 328
      AC_SUBST(CC_LD_DYNPATH, [-Wl,-rpath,])
   else
329
      AC_CACHE_CHECK([if linker supports -rpath], git_cv_ld_rpath, [
330 331
         SAVE_LDFLAGS="${LDFLAGS}"
         LDFLAGS="${SAVE_LDFLAGS} -rpath /"
332
         AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [git_cv_ld_rpath=yes], [git_cv_ld_rpath=no])
P
Paul Jarc 已提交
333
         LDFLAGS="${SAVE_LDFLAGS}"
334
      ])
335
      if test "$git_cv_ld_rpath" = "yes"; then
336 337 338 339 340 341
         AC_SUBST(CC_LD_DYNPATH, [-rpath])
      else
         AC_MSG_WARN([linker does not support runtime path to dynamic libraries])
      fi
   fi
fi
342
#AC_PROG_INSTALL		# needs install-sh or install.sh in sources
343
AC_CHECK_TOOLS(AR, [gar ar], :)
344
AC_CHECK_PROGS(TAR, [gtar tar])
345 346 347 348 349 350 351 352 353 354
# TCLTK_PATH will be set to some value if we want Tcl/Tk
# or will be empty otherwise.
if test -z "$NO_TCLTK"; then
  if test "$with_tcltk" = ""; then
  # No Tcl/Tk switches given. Do not check for Tcl/Tk, use bare 'wish'.
    TCLTK_PATH=wish
    AC_SUBST(TCLTK_PATH)
  elif test "$with_tcltk" = "yes"; then
  # Tcl/Tk check requested.
    AC_CHECK_PROGS(TCLTK_PATH, [wish], )
355
  else
356 357 358 359 360
    AC_MSG_RESULT([Using Tcl/Tk interpreter $with_tcltk])
    TCLTK_PATH="$with_tcltk"
    AC_SUBST(TCLTK_PATH)
  fi
fi
361 362 363
AC_CHECK_PROGS(ASCIIDOC, [asciidoc])
if test -n "$ASCIIDOC"; then
	AC_MSG_CHECKING([for asciidoc version])
364
	asciidoc_version=`$ASCIIDOC --version 2>/dev/null`
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
	case "${asciidoc_version}" in
	asciidoc' '8*)
		ASCIIDOC8=YesPlease
		AC_MSG_RESULT([${asciidoc_version} > 7])
		;;
	asciidoc' '7*)
		ASCIIDOC8=
		AC_MSG_RESULT([${asciidoc_version}])
		;;
	*)
		ASCIIDOC8=
		AC_MSG_RESULT([${asciidoc_version} (unknown)])
		;;
	esac
fi
AC_SUBST(ASCIIDOC8)

382 383

## Checks for libraries.
J
Jakub Narebski 已提交
384
AC_MSG_NOTICE([CHECKS for libraries])
385
#
386
# Define NO_OPENSSL environment variable if you do not have OpenSSL.
J
Jakub Narebski 已提交
387
# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
388 389 390

GIT_STASH_FLAGS($OPENSSLDIR)

391
AC_CHECK_LIB([crypto], [SHA1_Init],
392
[NEEDS_SSL_WITH_CRYPTO=],
393
[AC_CHECK_LIB([ssl], [SHA1_Init],
394 395
 [NEEDS_SSL_WITH_CRYPTO=YesPlease],
 [NEEDS_SSL_WITH_CRYPTO= NO_OPENSSL=YesPlease])])
396 397 398

GIT_UNSTASH_FLAGS($OPENSSLDIR)

399 400
AC_SUBST(NEEDS_SSL_WITH_CRYPTO)
AC_SUBST(NO_OPENSSL)
401

402
#
403
# Define NO_CURL if you do not have libcurl installed.  git-http-pull and
404 405
# git-http-push are not built, and you cannot use http:// and https://
# transports.
406 407 408

GIT_STASH_FLAGS($CURLDIR)

409
AC_CHECK_LIB([curl], [curl_global_init],
410 411
[NO_CURL=],
[NO_CURL=YesPlease])
412 413 414

GIT_UNSTASH_FLAGS($CURLDIR)

415
AC_SUBST(NO_CURL)
416

417
#
418 419
# Define NO_EXPAT if you do not have expat installed.  git-http-push is
# not built, and you cannot push using http:// and https:// transports.
420 421 422

GIT_STASH_FLAGS($EXPATDIR)

423
AC_CHECK_LIB([expat], [XML_ParserCreate],
424 425
[NO_EXPAT=],
[NO_EXPAT=YesPlease])
426 427 428

GIT_UNSTASH_FLAGS($EXPATDIR)

429
AC_SUBST(NO_EXPAT)
430

431
#
F
Fredrik Kuivinen 已提交
432 433
# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin and
# some Solaris installations).
434
# Define NO_ICONV if neither libc nor libiconv support iconv.
435

436 437
if test -z "$NO_ICONV"; then

438 439
GIT_STASH_FLAGS($ICONVDIR)

F
Fredrik Kuivinen 已提交
440 441 442 443 444 445 446 447 448
AC_DEFUN([ICONVTEST_SRC], [
#include <iconv.h>

int main(void)
{
	iconv_open("", "");
	return 0;
}
])
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468

if test -n "$ICONVDIR"; then
   lib_order="-liconv -lc"
else
   lib_order="-lc -liconv"
fi

NO_ICONV=YesPlease

for l in $lib_order; do
    if test "$l" = "-liconv"; then
       NEEDS_LIBICONV=YesPlease
    else
       NEEDS_LIBICONV=
    fi

    old_LIBS="$LIBS"
    LIBS="$LIBS $l"
    AC_MSG_CHECKING([for iconv in $l])
    AC_LINK_IFELSE(ICONVTEST_SRC,
F
Fredrik Kuivinen 已提交
469
	[AC_MSG_RESULT([yes])
470 471 472 473 474 475 476 477
	NO_ICONV=
	break],
	[AC_MSG_RESULT([no])])
    LIBS="$old_LIBS"
done

#in case of break
LIBS="$old_LIBS"
478 479 480

GIT_UNSTASH_FLAGS($ICONVDIR)

481
AC_SUBST(NEEDS_LIBICONV)
482
AC_SUBST(NO_ICONV)
483

484 485 486 487 488 489
if test -n "$NO_ICONV"; then
    NEEDS_LIBICONV=
fi

fi

490
#
491
# Define NO_DEFLATE_BOUND if deflateBound is missing from zlib.
492 493 494

GIT_STASH_FLAGS($ZLIB_PATH)

495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511
AC_DEFUN([ZLIBTEST_SRC], [
#include <zlib.h>

int main(void)
{
	deflateBound(0, 0);
	return 0;
}
])
AC_MSG_CHECKING([for deflateBound in -lz])
old_LIBS="$LIBS"
LIBS="$LIBS -lz"
AC_LINK_IFELSE(ZLIBTEST_SRC,
	[AC_MSG_RESULT([yes])],
	[AC_MSG_RESULT([no])
	NO_DEFLATE_BOUND=yes])
LIBS="$old_LIBS"
512 513 514

GIT_UNSTASH_FLAGS($ZLIB_PATH)

515
AC_SUBST(NO_DEFLATE_BOUND)
516

517
#
518 519
# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
# Patrick Mauritz).
520
AC_CHECK_LIB([c], [socket],
521 522 523
[NEEDS_SOCKET=],
[NEEDS_SOCKET=YesPlease])
AC_SUBST(NEEDS_SOCKET)
524
test -n "$NEEDS_SOCKET" && LIBS="$LIBS -lsocket"
525

526 527 528 529
#
# Define NEEDS_RESOLV if linking with -lnsl and/or -lsocket is not enough.
# Notably on Solaris hstrerror resides in libresolv and on Solaris 7
# inet_ntop and inet_pton additionally reside there.
530
AC_CHECK_LIB([c], [hstrerror],
531 532 533 534
[NEEDS_RESOLV=],
[NEEDS_RESOLV=YesPlease])
AC_SUBST(NEEDS_RESOLV)
test -n "$NEEDS_RESOLV" && LIBS="$LIBS -lresolv"
535

536
AC_CHECK_LIB([c], [basename],
537 538 539 540 541
[NEEDS_LIBGEN=],
[NEEDS_LIBGEN=YesPlease])
AC_SUBST(NEEDS_LIBGEN)
test -n "$NEEDS_LIBGEN" && LIBS="$LIBS -lgen"

542
## Checks for header files.
543 544
AC_MSG_NOTICE([CHECKS for header files])
#
545 546 547 548 549 550
# Define NO_SYS_SELECT_H if you don't have sys/select.h.
AC_CHECK_HEADER([sys/select.h],
[NO_SYS_SELECT_H=],
[NO_SYS_SELECT_H=UnfortunatelyYes])
AC_SUBST(NO_SYS_SELECT_H)
#
551 552 553 554 555 556 557 558 559 560 561 562 563 564
# Define OLD_ICONV if your library has an old iconv(), where the second
# (input buffer pointer) parameter is declared with type (const char **).
AC_DEFUN([OLDICONVTEST_SRC], [[
#include <iconv.h>

extern size_t iconv(iconv_t cd,
		    char **inbuf, size_t *inbytesleft,
		    char **outbuf, size_t *outbytesleft);

int main(void)
{
	return 0;
}
]])
565 566 567

GIT_STASH_FLAGS($ICONVDIR)

568 569 570 571 572
AC_MSG_CHECKING([for old iconv()])
AC_COMPILE_IFELSE(OLDICONVTEST_SRC,
	[AC_MSG_RESULT([no])],
	[AC_MSG_RESULT([yes])
	OLD_ICONV=UnfortunatelyYes])
573

574 575 576
GIT_UNSTASH_FLAGS($ICONVDIR)

AC_SUBST(OLD_ICONV)
577 578

## Checks for typedefs, structures, and compiler characteristics.
579
AC_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.
582
AC_CHECK_MEMBER(struct dirent.d_ino,
583 584
[NO_D_INO_IN_DIRENT=],
[NO_D_INO_IN_DIRENT=YesPlease],
585
[#include <dirent.h>])
586
AC_SUBST(NO_D_INO_IN_DIRENT)
587
#
588 589
# Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
# d_type in struct dirent (latest Cygwin -- will be fixed soonish).
590
AC_CHECK_MEMBER(struct dirent.d_type,
591 592
[NO_D_TYPE_IN_DIRENT=],
[NO_D_TYPE_IN_DIRENT=YesPlease],
593
[#include <dirent.h>])
594
AC_SUBST(NO_D_TYPE_IN_DIRENT)
595
#
596 597
# Define NO_SOCKADDR_STORAGE if your platform does not have struct
# sockaddr_storage.
598
AC_CHECK_TYPE(struct sockaddr_storage,
599
[NO_SOCKADDR_STORAGE=],
600 601 602 603
[NO_SOCKADDR_STORAGE=YesPlease],[
#include <sys/types.h>
#include <sys/socket.h>
])
604 605
AC_SUBST(NO_SOCKADDR_STORAGE)
#
J
Junio C Hamano 已提交
606 607
# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
AC_CHECK_TYPE([struct addrinfo],[
608
 GIT_CHECK_FUNC([getaddrinfo],
609 610 611
  [NO_IPV6=],
  [NO_IPV6=YesPlease])
],[NO_IPV6=YesPlease],[
J
Junio C Hamano 已提交
612 613 614 615
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
])
616
AC_SUBST(NO_IPV6)
617 618 619 620 621
#
# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
# do not support the 'size specifiers' introduced by C99, namely ll, hh,
# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
# some C compilers supported these specifiers prior to C99 as an extension.
622 623
AC_CACHE_CHECK([whether formatted IO functions support C99 size specifiers],
 [ac_cv_c_c99_format],
624 625 626 627 628
[# Actually git uses only %z (%zu) in alloc.c, and %t (%td) in mktag.c
AC_RUN_IFELSE(
	[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
		[[char buf[64];
		if (sprintf(buf, "%lld%hhd%jd%zd%td", (long long int)1, (char)2, (intmax_t)3, (size_t)4, (ptrdiff_t)5) != 5)
R
Ralf Wildenhues 已提交
629
		  return 1;
630
		else if (strcmp(buf, "12345"))
R
Ralf Wildenhues 已提交
631
		  return 2;]])],
632 633 634 635
	[ac_cv_c_c99_format=yes],
	[ac_cv_c_c99_format=no])
])
if test $ac_cv_c_c99_format = no; then
636
	NO_C99_FORMAT=YesPlease
637
else
638
	NO_C99_FORMAT=
639
fi
640
AC_SUBST(NO_C99_FORMAT)
641
#
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661
# Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
# when attempting to read from an fopen'ed directory.
AC_CACHE_CHECK([whether system succeeds to read fopen'ed directory],
 [ac_cv_fread_reads_directories],
[
AC_RUN_IFELSE(
	[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
		[[char c;
		FILE *f = fopen(".", "r");
		return f && fread(&c, 1, 1, f)]])],
	[ac_cv_fread_reads_directories=no],
	[ac_cv_fread_reads_directories=yes])
])
if test $ac_cv_fread_reads_directories = yes; then
	FREAD_READS_DIRECTORIES=UnfortunatelyYes
else
	FREAD_READS_DIRECTORIES=
fi
AC_SUBST(FREAD_READS_DIRECTORIES)
#
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694
# Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
# or vsnprintf() return -1 instead of number of characters which would
# have been written to the final string if enough space had been available.
AC_CACHE_CHECK([whether snprintf() and/or vsnprintf() return bogus value],
 [ac_cv_snprintf_returns_bogus],
[
AC_RUN_IFELSE(
	[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
		#include "stdarg.h"

		int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
		{
		  int ret;
		  va_list ap;
		  va_start(ap, format);
		  ret = vsnprintf(str, maxsize, format, ap);
		  va_end(ap);
		  return ret;
		}],
		[[char buf[6];
		  if (test_vsnprintf(buf, 3, "%s", "12345") != 5
		      || strcmp(buf, "12")) return 1;
		  if (snprintf(buf, 3, "%s", "12345") != 5
		      || strcmp(buf, "12")) return 1]])],
	[ac_cv_snprintf_returns_bogus=no],
	[ac_cv_snprintf_returns_bogus=yes])
])
if test $ac_cv_snprintf_returns_bogus = yes; then
	SNPRINTF_RETURNS_BOGUS=UnfortunatelyYes
else
	SNPRINTF_RETURNS_BOGUS=
fi
AC_SUBST(SNPRINTF_RETURNS_BOGUS)
695

696

697
## Checks for library functions.
698 699
## (in default C library and libraries checked by AC_CHECK_LIB)
AC_MSG_NOTICE([CHECKS for library functions])
700
#
701 702 703 704 705 706
# Define NO_LIBGEN_H if you don't have libgen.h.
AC_CHECK_HEADER([libgen.h],
[NO_LIBGEN_H=],
[NO_LIBGEN_H=YesPlease])
AC_SUBST(NO_LIBGEN_H)
#
707
# Define NO_STRCASESTR if you don't have strcasestr.
708
GIT_CHECK_FUNC(strcasestr,
709 710 711
[NO_STRCASESTR=],
[NO_STRCASESTR=YesPlease])
AC_SUBST(NO_STRCASESTR)
712
#
713
# Define NO_MEMMEM if you don't have memmem.
714
GIT_CHECK_FUNC(memmem,
715 716 717 718
[NO_MEMMEM=],
[NO_MEMMEM=YesPlease])
AC_SUBST(NO_MEMMEM)
#
719
# Define NO_STRLCPY if you don't have strlcpy.
720
GIT_CHECK_FUNC(strlcpy,
721 722 723
[NO_STRLCPY=],
[NO_STRLCPY=YesPlease])
AC_SUBST(NO_STRLCPY)
724
#
725 726 727 728 729 730 731 732
# Define NO_UINTMAX_T if your platform does not have uintmax_t
AC_CHECK_TYPE(uintmax_t,
[NO_UINTMAX_T=],
[NO_UINTMAX_T=YesPlease],[
#include <inttypes.h>
])
AC_SUBST(NO_UINTMAX_T)
#
733
# Define NO_STRTOUMAX if you don't have strtoumax in the C library.
734
GIT_CHECK_FUNC(strtoumax,
735 736 737 738
[NO_STRTOUMAX=],
[NO_STRTOUMAX=YesPlease])
AC_SUBST(NO_STRTOUMAX)
#
739
# Define NO_SETENV if you don't have setenv in the C library.
740
GIT_CHECK_FUNC(setenv,
741 742 743
[NO_SETENV=],
[NO_SETENV=YesPlease])
AC_SUBST(NO_SETENV)
744
#
745
# Define NO_UNSETENV if you don't have unsetenv in the C library.
746
GIT_CHECK_FUNC(unsetenv,
747 748 749 750
[NO_UNSETENV=],
[NO_UNSETENV=YesPlease])
AC_SUBST(NO_UNSETENV)
#
751
# Define NO_MKDTEMP if you don't have mkdtemp in the C library.
752
GIT_CHECK_FUNC(mkdtemp,
753 754 755 756
[NO_MKDTEMP=],
[NO_MKDTEMP=YesPlease])
AC_SUBST(NO_MKDTEMP)
#
757 758 759 760 761 762 763
# Define NO_MKSTEMPS if you don't have mkstemps in the C library.
GIT_CHECK_FUNC(mkstemps,
[NO_MKSTEMPS=],
[NO_MKSTEMPS=YesPlease])
AC_SUBST(NO_MKSTEMPS)
#
#
764 765 766 767 768 769 770 771 772 773 774
# Define NO_MMAP if you want to avoid mmap.
#
# Define NO_ICONV if your libc does not properly support iconv.


## Other checks.
# Define USE_PIC if you need the main git objects to be built with -fPIC
# in order to build and link perl/Git.so.  x86-64 seems to need this.
#
# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
# Enable it on Windows.  By default, symrefs are still used.
D
David M. Syzdek 已提交
775
#
776
# Define NO_PTHREADS if we do not have pthreads.
J
Junio C Hamano 已提交
777
#
778
# Define PTHREAD_LIBS to the linker flag used for Pthread support.
779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814
AC_DEFUN([PTHREADTEST_SRC], [
#include <pthread.h>

int main(void)
{
	pthread_mutex_t test_mutex;
	return (0);
}
])

dnl AC_LANG_CONFTEST([AC_LANG_PROGRAM(
dnl   [[#include <pthread.h>]],
dnl   [[pthread_mutex_t test_mutex;]]
dnl )])

NO_PTHREADS=UnfortunatelyYes
PTHREAD_LIBS=

if test -n "$USER_NOPTHREAD"; then
   AC_MSG_NOTICE([Skipping POSIX Threads at user request.])
# handle these separately since PTHREAD_CFLAGS could be '-lpthreads
# -D_REENTRANT' or some such.
elif test -z "$PTHREAD_CFLAGS"; then
  for opt in -pthread -lpthread; do
     old_CFLAGS="$CFLAGS"
     CFLAGS="$opt $CFLAGS"
     AC_MSG_CHECKING([Checking for POSIX Threads with '$opt'])
     AC_LINK_IFELSE(PTHREADTEST_SRC,
	[AC_MSG_RESULT([yes])
		NO_PTHREADS=
		PTHREAD_LIBS="$opt"
		break
	],
	[AC_MSG_RESULT([no])])
      CFLAGS="$old_CFLAGS"
  done
D
David M. Syzdek 已提交
815
else
816 817 818 819 820 821 822 823 824 825 826
  old_CFLAGS="$CFLAGS"
  CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
  AC_MSG_CHECKING([Checking for POSIX Threads with '$PTHREAD_CFLAGS'])
  AC_LINK_IFELSE(PTHREADTEST_SRC,
	[AC_MSG_RESULT([yes])
		NO_PTHREADS=
		PTHREAD_LIBS="$PTHREAD_CFLAGS"
	],
	[AC_MSG_RESULT([no])])

  CFLAGS="$old_CFLAGS"
D
David M. Syzdek 已提交
827
fi
828 829 830

CFLAGS="$old_CFLAGS"

D
David M. Syzdek 已提交
831
AC_SUBST(PTHREAD_LIBS)
J
Junio C Hamano 已提交
832
AC_SUBST(NO_PTHREADS)
833 834

## Output files
835
AC_CONFIG_FILES(["${config_file}":"${config_in}":"${config_append}"])
836
AC_OUTPUT
837

838

839 840
## Cleanup
rm -f "${config_append}"