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