blob: 1e1cc1d955a1addf44c6e9872b9d66780abc45c8 [file] [log] [blame]
Benjamin Petersonfbeb6b62008-05-26 16:04:49 +00001dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
4dnl NOTE: autoconf 2.64 doesn't seem to work (use 2.63).
Martin v. Löwis88afe662002-10-26 13:47:44 +00005
6# Set VERSION so we only need to edit in one place (i.e., here)
Guido van Rossum0c4eb622006-03-30 16:19:24 +00007m4_define(PYTHON_VERSION, 3.0)
Martin v. Löwis88afe662002-10-26 13:47:44 +00008
Guido van Rossum76be6ed1995-01-02 18:33:54 +00009AC_REVISION($Revision$)
Thomas Wouters47b49bf2007-08-30 22:15:33 +000010AC_PREREQ(2.61)
Martin v. Löwis1d459062005-03-14 21:23:33 +000011AC_INIT(python, PYTHON_VERSION, http://www.python.org/python-bugs)
Martin v. Löwis88afe662002-10-26 13:47:44 +000012AC_CONFIG_SRCDIR([Include/object.h])
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000013AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +000014
Martin v. Löwis8316feb2003-06-14 07:48:07 +000015dnl This is for stuff that absolutely must end up in pyconfig.h.
16dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000017AH_TOP([
18#ifndef Py_PYCONFIG_H
19#define Py_PYCONFIG_H
20])
Martin v. Löwis11437992002-04-12 09:54:03 +000021AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000022/* Define the macros needed if on a UnixWare 7.x system. */
23#if defined(__USLC__) && defined(__SCO_VERSION__)
24#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
25#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000026
27#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000028])
29
Martin v. Löwis8316feb2003-06-14 07:48:07 +000030# We don't use PACKAGE_ variables, and they cause conflicts
31# with other autoconf-based packages that include Python.h
32grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
33rm confdefs.h
34mv confdefs.h.new confdefs.h
35
Guido van Rossum642b6781997-07-19 19:35:41 +000036AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000037VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000038
Martin v. Löwis1142de32002-03-29 16:28:31 +000039AC_SUBST(SOVERSION)
40SOVERSION=1.0
41
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000042# The later defininition of _XOPEN_SOURCE disables certain features
43# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
44AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
45
Martin v. Löwisbcd93962003-05-03 10:32:18 +000046# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
47# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
48# them.
49AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
50
Andrew MacIntyreabccf412003-07-02 13:53:25 +000051# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
52# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
53# them.
54AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
55
Martin v. Löwisd6320502004-08-12 13:45:08 +000056# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
57# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
58AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
59
Georg Brandlfcaf9102008-07-16 02:17:56 +000060# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
61# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
62# them.
63AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
64
65
Martin v. Löwise981a4e2002-11-11 13:26:51 +000066define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000067
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +000068# Arguments passed to configure.
69AC_SUBST(CONFIG_ARGS)
70CONFIG_ARGS="$ac_configure_args"
71
Thomas Wouters477c8d52006-05-27 19:21:47 +000072AC_ARG_ENABLE(universalsdk,
Christian Heimes68f5fbe2008-02-14 08:27:37 +000073 AC_HELP_STRING(--enable-universalsdk@<:@=SDKDIR@:>@, Build against Mac OS X 10.4u SDK (ppc/i386)),
Thomas Wouters477c8d52006-05-27 19:21:47 +000074[
75 case $enableval in
76 yes)
77 enableval=/Developer/SDKs/MacOSX10.4u.sdk
78 ;;
79 esac
80 case $enableval in
81 no)
82 UNIVERSALSDK=
83 enable_universalsdk=
84 ;;
85 *)
86 UNIVERSALSDK=$enableval
87 ;;
88 esac
89],[
90 UNIVERSALSDK=
91 enable_universalsdk=
92])
93AC_SUBST(UNIVERSALSDK)
94
Georg Brandlfcaf9102008-07-16 02:17:56 +000095UNIVERSAL_ARCHS="32-bit"
96AC_MSG_CHECKING(for --with-universal-archs)
97AC_ARG_WITH(universal-archs,
98 AC_HELP_STRING(--with-universal-archs=ARCH, select architectures for universal build ("32-bit", "64-bit" or "all")),
99[
100 AC_MSG_RESULT($withval)
101 UNIVERSAL_ARCHS="$withval"
102],
103[
104 AC_MSG_RESULT(32-bit)
105])
106
107
108
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000109AC_ARG_WITH(framework-name,
110 AC_HELP_STRING(--with-framework-name=FRAMEWORK,
111 specify an alternate name of the framework built with --enable-framework),
112[
113 PYTHONFRAMEWORK=${withval}
114 PYTHONFRAMEWORKDIR=${withval}.framework
115 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
116 ],[
117 PYTHONFRAMEWORK=Python
118 PYTHONFRAMEWORKDIR=Python.framework
119 PYTHONFRAMEWORKIDENTIFIER=org.python.python
120])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000121dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000122AC_ARG_ENABLE(framework,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000123 AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
124[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000125 case $enableval in
126 yes)
127 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000128 esac
129 case $enableval in
130 no)
131 PYTHONFRAMEWORK=
132 PYTHONFRAMEWORKDIR=no-framework
133 PYTHONFRAMEWORKPREFIX=
134 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000135 FRAMEWORKINSTALLFIRST=
136 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000137 FRAMEWORKALTINSTALLFIRST=
138 FRAMEWORKALTINSTALLLAST=
139 if test "x${prefix}" = "xNONE"; then
140 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
141 else
142 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
143 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000144 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000145 ;;
146 *)
147 PYTHONFRAMEWORKPREFIX=$enableval
Jack Jansen127e56e2001-09-11 14:41:54 +0000148 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Thomas Wouters477c8d52006-05-27 19:21:47 +0000149 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000150 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
151 if test "$UNIVERSAL_ARCHS" = "all"
152 then
153 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps4way frameworkinstallunixtools4way"
154 else
155 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
156 fi
157
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000158 if test "x${prefix}" = "xNONE" ; then
159 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
160 else
161 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
162 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000163 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Thomas Wouters477c8d52006-05-27 19:21:47 +0000164
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000165 # Add files for Mac specific code to the list of output
Thomas Wouters477c8d52006-05-27 19:21:47 +0000166 # files:
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000167 AC_CONFIG_FILES(Mac/Makefile)
168 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000169 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
170 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000171 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000172 ],[
173 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000174 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000175 PYTHONFRAMEWORKPREFIX=
176 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000177 FRAMEWORKINSTALLFIRST=
178 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000179 FRAMEWORKALTINSTALLFIRST=
180 FRAMEWORKALTINSTALLLAST=
181 if test "x${prefix}" = "xNONE" ; then
182 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
183 else
184 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
185 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000186 enable_framework=
Georg Brandlfcaf9102008-07-16 02:17:56 +0000187
188 if test "$UNIVERSAL_ARCHS" = "all"
189 then
190 FRAMEWORKINSTALLLAST=update4wayuniversal
191 FRAMEWORKALTINSTALLLAST=update4wayuniversal
192 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000193])
194AC_SUBST(PYTHONFRAMEWORK)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000195AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000196AC_SUBST(PYTHONFRAMEWORKDIR)
197AC_SUBST(PYTHONFRAMEWORKPREFIX)
198AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000199AC_SUBST(FRAMEWORKINSTALLFIRST)
200AC_SUBST(FRAMEWORKINSTALLLAST)
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000201AC_SUBST(FRAMEWORKALTINSTALLFIRST)
202AC_SUBST(FRAMEWORKALTINSTALLLAST)
203AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000204
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000205##AC_ARG_WITH(dyld,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000206## AC_HELP_STRING(--with-dyld,
207## Use (OpenStep|Rhapsody) dynamic linker))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000208##
Guido van Rossumb418f891996-07-30 18:06:02 +0000209# Set name for machine-dependent library files
210AC_SUBST(MACHDEP)
211AC_MSG_CHECKING(MACHDEP)
212if test -z "$MACHDEP"
213then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000214 ac_sys_system=`uname -s`
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000215 if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64" \
216 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000217 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000218 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000219 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000220 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000221 ac_md_system=`echo $ac_sys_system |
222 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
223 ac_md_release=`echo $ac_sys_release |
Guido van Rossum67b26592001-10-20 14:21:45 +0000224 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +0000225 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000226
Guido van Rossumbcd91e01997-03-20 20:46:29 +0000227 case $MACHDEP in
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000228 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000229 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000230 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000231 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000232 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000233 esac
234fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000235
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000236# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
237# disable features if it is defined, without any means to access these
238# features as extensions. For these systems, we skip the definition of
239# _XOPEN_SOURCE. Before adding a system to the list to gain access to
240# some feature, make sure there is no alternative way to access this
241# feature. Also, when using wildcards, make sure you have verified the
242# need for not defining _XOPEN_SOURCE on all systems matching the
243# wildcard, and that the wildcard does not include future systems
244# (which may remove their limitations).
245dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
246case $ac_sys_system/$ac_sys_release in
247 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
248 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000249 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Georg Brandlf78e02b2008-06-10 17:40:04 +0000250 OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0123@:>@)
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000251 define_xopen_source=no
252 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
253 # also defined. This can be overridden by defining _BSD_SOURCE
254 # As this has a different meaning on Linux, only define it on OpenBSD
255 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
256 ;;
Thomas Wouters89f507f2006-12-13 04:49:30 +0000257 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
258 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
259 # Marc Recht
260 NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6[A-S])
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000261 define_xopen_source=no;;
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000262 # On Solaris 2.6, sys/wait.h is inconsistent in the usage
263 # of union __?sigval. Reported by Stuart Bishop.
264 SunOS/5.6)
265 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000266 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
267 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000268 # Reconfirmed for 7.1.4 by Martin v. Loewis.
269 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000270 define_xopen_source=no;;
271 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000272 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000273 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000274 define_xopen_source=no;;
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000275 # On FreeBSD 4.8 and MacOS X 10.2, a bug in ncurses.h means that
276 # it craps out if _XOPEN_EXTENDED_SOURCE is defined. Apparently,
277 # this is fixed in 10.3, which identifies itself as Darwin/7.*
278 # This should hopefully be fixed in FreeBSD 4.9
279 FreeBSD/4.8* | Darwin/6* )
280 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000281 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
282 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
283 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000284 AIX/4)
285 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000286 AIX/5)
287 if test `uname -r` -eq 1; then
288 define_xopen_source=no
289 fi
290 ;;
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000291 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
292 # disables platform specific features beyond repair.
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000293 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000294 # has no effect, don't bother defining them
295 Darwin/@<:@789@:>@.*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000296 define_xopen_source=no
297 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000298 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
299 # defining NI_NUMERICHOST.
300 QNX/6.3.2)
301 define_xopen_source=no
302 ;;
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000303
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000304esac
305
306if test $define_xopen_source = yes
307then
Skip Montanarof0d5f792004-08-15 14:08:23 +0000308 # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
309 # defined precisely as g++ defines it
Martin v. Löwis7dece662005-11-26 11:38:24 +0000310 # Furthermore, on Solaris 10, XPG6 requires the use of a C99
311 # compiler
Skip Montanarof0d5f792004-08-15 14:08:23 +0000312 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis7dece662005-11-26 11:38:24 +0000313 SunOS/5.8|SunOS/5.9|SunOS/5.10)
Skip Montanarof0d5f792004-08-15 14:08:23 +0000314 AC_DEFINE(_XOPEN_SOURCE, 500,
315 Define to the level of X/Open that your system supports)
316 ;;
317 *)
318 AC_DEFINE(_XOPEN_SOURCE, 600,
319 Define to the level of X/Open that your system supports)
320 ;;
321 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000322
323 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
324 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
325 # several APIs are not declared. Since this is also needed in some
326 # cases for HP-UX, we define it globally.
Martin v. Löwis7dece662005-11-26 11:38:24 +0000327 # except for Solaris 10, where it must not be defined,
328 # as it implies XPG4.2
329 case $ac_sys_system/$ac_sys_release in
330 SunOS/5.10)
331 ;;
332 *)
333 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
334 Define to activate Unix95-and-earlier features)
335 ;;
336 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000337
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000338 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
339
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000340fi
341
Guido van Rossum91922671997-10-09 20:24:13 +0000342#
343# SGI compilers allow the specification of the both the ABI and the
344# ISA on the command line. Depending on the values of these switches,
345# different and often incompatable code will be generated.
346#
347# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
348# thus supply support for various ABI/ISA combinations. The MACHDEP
349# variable is also adjusted.
350#
351AC_SUBST(SGI_ABI)
352if test ! -z "$SGI_ABI"
353then
354 CC="cc $SGI_ABI"
355 LDFLAGS="$SGI_ABI $LDFLAGS"
356 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
357fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000358AC_MSG_RESULT($MACHDEP)
359
Jack Jansen6b08a402004-06-03 12:41:45 +0000360# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
361# it may influence the way we can build extensions, so distutils
362# needs to check it
363AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000364AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000365CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000366EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000367
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000368AC_MSG_CHECKING(machine type as reported by uname -m)
369ac_sys_machine=`uname -m`
370AC_MSG_RESULT($ac_sys_machine)
371
Guido van Rossum627b2d71993-12-24 10:39:16 +0000372# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000373
374# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
375# for debug/optimization stuff. BASECFLAGS is for flags that are required
376# just to get things to compile and link. Users are free to override OPT
377# when running configure or make. The build should not break if they do.
378# BASECFLAGS should generally not be messed with, however.
379
380# XXX shouldn't some/most/all of this code be merged with the stuff later
381# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000382AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000383AC_ARG_WITH(gcc,
384 AC_HELP_STRING(--without-gcc,never use gcc),
385[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000386 case $withval in
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000387 no) CC=cc
388 without_gcc=yes;;
389 yes) CC=gcc
390 without_gcc=no;;
391 *) CC=$withval
392 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000393 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000394 case $ac_sys_system in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000395 AIX*) CC=cc_r
396 without_gcc=;;
Trent Mick635f6fb2000-08-23 21:33:05 +0000397 Monterey*)
398 RANLIB=:
Martin v. Löwis130fb172001-07-19 11:00:41 +0000399 without_gcc=;;
400 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000401 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000402AC_MSG_RESULT($without_gcc)
403
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000404# If the user switches compilers, we can't believe the cache
405if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
406then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000407 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
408(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000409fi
410
Guido van Rossum627b2d71993-12-24 10:39:16 +0000411AC_PROG_CC
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000412
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000413AC_SUBST(CXX)
414AC_SUBST(MAINCC)
415AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
416AC_ARG_WITH(cxx_main,
417 AC_HELP_STRING([--with-cxx-main=<compiler>],
418 [compile main() and link python executable with C++ compiler]),
419[
420
421 case $withval in
422 no) with_cxx_main=no
423 MAINCC='$(CC)';;
424 yes) with_cxx_main=yes
425 MAINCC='$(CXX)';;
426 *) with_cxx_main=yes
427 MAINCC=$withval
428 if test -z "$CXX"
429 then
430 CXX=$withval
431 fi;;
432 esac], [
433 with_cxx_main=no
434 MAINCC='$(CC)'
435])
436AC_MSG_RESULT($with_cxx_main)
437
438preset_cxx="$CXX"
439if test -z "$CXX"
440then
441 case "$CC" in
442 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
443 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
444 esac
445 if test "$CXX" = "notfound"
446 then
447 CXX=""
448 fi
449fi
450if test -z "$CXX"
451then
452 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
453 if test "$CXX" = "notfound"
454 then
455 CXX=""
456 fi
457fi
458if test "$preset_cxx" != "$CXX"
459then
460 AC_MSG_WARN([
461
462 By default, distutils will build C++ extension modules with "$CXX".
463 If this is not intended, then set CXX on the configure command line.
464 ])
465fi
466
467
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000468# checks for UNIX variants that set C preprocessor variables
469AC_AIX
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000470
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000471# Check for unsupported systems
472case $ac_sys_system/$ac_sys_release in
Guido van Rossumcd16bf62007-06-13 18:07:49 +0000473atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000474 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
475 echo See README for details.
476 exit 1;;
477esac
478
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000479AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000480AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000481AC_ARG_WITH(suffix,
482 AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
483[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000484 case $withval in
485 no) EXEEXT=;;
486 yes) EXEEXT=.exe;;
487 *) EXEEXT=$withval;;
488 esac])
489AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000490
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000491# Test whether we're running on a non-case-sensitive system, in which
492# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000493AC_SUBST(BUILDEXEEXT)
494AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000495if test ! -d CaseSensitiveTestDir; then
496mkdir CaseSensitiveTestDir
497fi
498
499if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000500then
Jack Jansen1999ef42001-12-06 21:47:20 +0000501 AC_MSG_RESULT(yes)
502 BUILDEXEEXT=.exe
503else
504 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000505 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000506fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000507rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000508
Guido van Rossumdd997f71998-10-07 19:58:26 +0000509case $MACHDEP in
510bsdos*)
511 case $CC in
512 gcc) CC="$CC -D_HAVE_BSDI";;
513 esac;;
514esac
515
Guido van Rossum84561611997-08-21 00:08:11 +0000516case $ac_sys_system in
517hp*|HP*)
518 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000519 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000520 esac;;
Trent Mick635f6fb2000-08-23 21:33:05 +0000521Monterey*)
522 case $CC in
523 cc) CC="$CC -Wl,-Bexport";;
524 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000525SunOS*)
526 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000527 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000528 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000529esac
530
Martin v. Löwise8964d42001-03-06 12:09:07 +0000531
Neil Schemenauer61c51152001-01-26 16:18:16 +0000532AC_SUBST(LIBRARY)
533AC_MSG_CHECKING(LIBRARY)
534if test -z "$LIBRARY"
535then
536 LIBRARY='libpython$(VERSION).a'
537fi
538AC_MSG_RESULT($LIBRARY)
539
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000540# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000541# name of the library into which to insert object files). BLDLIBRARY is also
542# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
543# is blank as the main program is not linked directly against LDLIBRARY.
544# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
545# systems without shared libraries, LDLIBRARY is the same as LIBRARY
546# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
547# DLLLIBRARY is the shared (i.e., DLL) library.
548#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000549# RUNSHARED is used to run shared python without installed libraries
550#
551# INSTSONAME is the name of the shared library that will be use to install
552# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000553AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000554AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000555AC_SUBST(BLDLIBRARY)
556AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000557AC_SUBST(INSTSONAME)
558AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000559LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000560BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000561INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000562DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000563LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000564RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000565
Guido van Rossumfb842551997-08-06 23:42:07 +0000566# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000567# If CXX is set, and if it is needed to link a main function that was
568# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
569# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000570# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000571# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000572AC_SUBST(LINKCC)
573AC_MSG_CHECKING(LINKCC)
574if test -z "$LINKCC"
575then
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000576 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000577 case $ac_sys_system in
578 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000579 exp_extra="\"\""
580 if test $ac_sys_release -ge 5 -o \
581 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
582 exp_extra="."
583 fi
584 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000585 Monterey64*)
Martin v. Löwis4e732dc2002-03-19 15:15:32 +0000586 LINKCC="$LINKCC -L/usr/lib/ia64l64";;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000587 QNX*)
588 # qcc must be used because the other compilers do not
589 # support -N.
590 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000591 esac
592fi
593AC_MSG_RESULT($LINKCC)
594
Martin v. Löwis1142de32002-03-29 16:28:31 +0000595AC_MSG_CHECKING(for --enable-shared)
596AC_ARG_ENABLE(shared,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000597 AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000598
Martin v. Löwis1142de32002-03-29 16:28:31 +0000599if test -z "$enable_shared"
600then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000601 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000602 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000603 enable_shared="yes";;
604 *)
605 enable_shared="no";;
606 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000607fi
608AC_MSG_RESULT($enable_shared)
609
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000610AC_MSG_CHECKING(for --enable-profiling)
611AC_ARG_ENABLE(profiling,
612 AC_HELP_STRING(--enable-profiling, enable C-level code profiling),
613[ac_save_cc="$CC"
614 CC="$CC -pg"
615 AC_TRY_RUN([int main() { return 0; }],
616 ac_enable_profiling="yes",
617 ac_enable_profiling="no",
618 ac_enable_profiling="no")
619 CC="$ac_save_cc"])
620AC_MSG_RESULT($ac_enable_profiling)
621
622case "$ac_enable_profiling" in
623 "yes")
624 BASECFLAGS="-pg $BASECFLAGS"
625 LDFLAGS="-pg $LDFLAGS"
626 ;;
627esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000628
629AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000630
Guido van Rossumb8552162001-09-05 14:58:11 +0000631# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
632# library that we build, but we do not want to link against it (we
633# will find it with a -framework option). For this reason there is an
634# extra variable BLDLIBRARY against which Python and the extension
635# modules are linked, BLDLIBRARY. This is normally the same as
636# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000637if test "$enable_framework"
638then
639 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000640 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000641 BLDLIBRARY=''
642else
643 BLDLIBRARY='$(LDLIBRARY)'
644fi
645
Martin v. Löwis1142de32002-03-29 16:28:31 +0000646# Other platforms follow
647if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000648 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000649 case $ac_sys_system in
Martin v. Löwis1142de32002-03-29 16:28:31 +0000650 CYGWIN*)
651 LDLIBRARY='libpython$(VERSION).dll.a'
652 DLLLIBRARY='libpython$(VERSION).dll'
653 ;;
654 SunOS*)
655 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000656 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000657 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000658 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000659 ;;
Martin v. Löwis86d66262006-02-17 08:40:11 +0000660 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000661 LDLIBRARY='libpython$(VERSION).so'
662 BLDLIBRARY='-L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000663 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000664 case $ac_sys_system in
665 FreeBSD*)
666 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
667 ;;
668 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000669 INSTSONAME="$LDLIBRARY".$SOVERSION
670 ;;
671 hp*|HP*)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000672 case `uname -m` in
673 ia64)
674 LDLIBRARY='libpython$(VERSION).so'
675 ;;
676 *)
677 LDLIBRARY='libpython$(VERSION).sl'
678 ;;
679 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000680 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000681 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000682 ;;
683 OSF*)
684 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000685 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000686 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000687 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000688 atheos*)
689 LDLIBRARY='libpython$(VERSION).so'
690 BLDLIBRARY='-L. -lpython$(VERSION)'
691 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
692 ;;
Martin v. Löwis1142de32002-03-29 16:28:31 +0000693 esac
Jason Tishler30765592003-09-04 11:04:06 +0000694else # shared is disabled
695 case $ac_sys_system in
696 CYGWIN*)
697 BLDLIBRARY='$(LIBRARY)'
698 LDLIBRARY='libpython$(VERSION).dll.a'
699 ;;
700 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000701fi
702
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000703AC_MSG_RESULT($LDLIBRARY)
704
Guido van Rossum627b2d71993-12-24 10:39:16 +0000705AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000706AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000707AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000708
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000709AC_SUBST(SVNVERSION)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000710AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000711if test $SVNVERSION = found
712then
713 SVNVERSION="svnversion \$(srcdir)"
714else
715 SVNVERSION="echo exported"
716fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000717
Neil Schemenauera42c8272001-03-31 00:01:55 +0000718case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000719bsdos*|hp*|HP*)
720 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000721 if test -z "$INSTALL"
722 then
723 INSTALL="${srcdir}/install-sh -c"
724 fi
725esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000726AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000727
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000728# Not every filesystem supports hard links
729AC_SUBST(LN)
730if test -z "$LN" ; then
731 case $ac_sys_system in
Guido van Rossumaef734b2001-01-10 21:09:12 +0000732 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000733 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000734 *) LN=ln;;
735 esac
736fi
737
Fred Drake9f715822001-07-11 06:27:00 +0000738# Check for --with-pydebug
739AC_MSG_CHECKING(for --with-pydebug)
740AC_ARG_WITH(pydebug,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000741 AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
742[
Fred Drake9f715822001-07-11 06:27:00 +0000743if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000744then
745 AC_DEFINE(Py_DEBUG, 1,
746 [Define if you want to build an interpreter with many run-time checks.])
747 AC_MSG_RESULT(yes);
748 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +0000749else AC_MSG_RESULT(no); Py_DEBUG='false'
750fi],
751[AC_MSG_RESULT(no)])
752
Skip Montanarodecc6a42003-01-01 20:07:49 +0000753# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
754# merged with this chunk of code?
755
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000756# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +0000757# ------------------------
758# (The following bit of code is complicated enough - please keep things
759# indented properly. Just pretend you're editing Python code. ;-)
760
761# There are two parallel sets of case statements below, one that checks to
762# see if OPT was set and one that does BASECFLAGS setting based upon
763# compiler and platform. BASECFLAGS tweaks need to be made even if the
764# user set OPT.
765
766# tweak OPT based on compiler and platform, only if the user didn't set
767# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +0000768AC_SUBST(OPT)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000769if test -z "$OPT"
Guido van Rossumb418f891996-07-30 18:06:02 +0000770then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000771 case $GCC in
772 yes)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000773 if test "$CC" != 'g++' ; then
774 STRICT_PROTO="-Wstrict-prototypes"
775 fi
Christian Heimes38053212007-12-14 01:24:44 +0000776 # For gcc 4.x we need to use -fwrapv so lets check if its supported
777 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
778 WRAP="-fwrapv"
779 fi
Skip Montanarodecc6a42003-01-01 20:07:49 +0000780 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000781 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000782 if test "$Py_DEBUG" = 'true' ; then
783 # Optimization messes up debuggers, so turn it off for
784 # debug builds.
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000785 OPT="-g -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +0000786 else
Christian Heimes38053212007-12-14 01:24:44 +0000787 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000788 fi
789 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000790 *)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000791 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000792 ;;
Fred Drake9f715822001-07-11 06:27:00 +0000793 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000794 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000795 SCO_SV*) OPT="$OPT -m486 -DSCO5"
796 ;;
797 esac
Fred Drake9f715822001-07-11 06:27:00 +0000798 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000799
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000800 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +0000801 OPT="-O"
802 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000803 esac
Skip Montanarodecc6a42003-01-01 20:07:49 +0000804
805 # The current (beta) Monterey compiler dies with optimizations
806 # XXX what is Monterey? Does it still die w/ -O? Can we get rid of this?
Jack Jansenca06bc62001-08-03 15:32:23 +0000807 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000808 Monterey*)
809 OPT=""
810 ;;
Jack Jansenca06bc62001-08-03 15:32:23 +0000811 esac
Skip Montanarodecc6a42003-01-01 20:07:49 +0000812
Guido van Rossum4e8af441994-08-19 15:33:54 +0000813fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000814
Skip Montanarodecc6a42003-01-01 20:07:49 +0000815AC_SUBST(BASECFLAGS)
Georg Brandlfcaf9102008-07-16 02:17:56 +0000816
817# The -arch flags for universal builds on OSX
818UNIVERSAL_ARCH_FLAGS=
819AC_SUBST(UNIVERSAL_ARCH_FLAGS)
820
Skip Montanarodecc6a42003-01-01 20:07:49 +0000821# tweak BASECFLAGS based on compiler and platform
822case $GCC in
823yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000824 # Python violates C99 rules, by casting between incompatible
825 # pointer types. GCC may generate bad code as a result of that,
826 # so use -fno-strict-aliasing if supported.
827 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
828 ac_save_cc="$CC"
829 CC="$CC -fno-strict-aliasing"
830 AC_TRY_RUN([int main() { return 0; }],
831 ac_cv_no_strict_aliasing_ok=yes,
832 ac_cv_no_strict_aliasing_ok=no,
833 ac_cv_no_strict_aliasing_ok=no)
834 CC="$ac_save_cc"
835 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
836 if test $ac_cv_no_strict_aliasing_ok = yes
837 then
838 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
839 fi
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000840
841 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
842 # support. Without this, treatment of subnormals doesn't follow
843 # the standard.
844 case $ac_sys_machine in
845 alpha*)
846 BASECFLAGS="$BASECFLAGS -mieee"
847 ;;
848 esac
849
Skip Montanarodecc6a42003-01-01 20:07:49 +0000850 case $ac_sys_system in
851 SCO_SV*)
852 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
853 ;;
854 # is there any other compiler on Darwin besides gcc?
855 Darwin*)
Christian Heimesb186d002008-03-18 15:15:01 +0000856 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
857 # used to be here, but non-Apple gcc doesn't accept them.
Thomas Wouters477c8d52006-05-27 19:21:47 +0000858 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +0000859 UNIVERSAL_ARCH_FLAGS=""
860 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
861 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
862
863 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
864 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
865
866 elif test "$UNIVERSAL_ARCHS" = "all" ; then
867 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
868
869 else
870 AC_MSG_ERROR([proper usage is --with-universalarch=32-bit|64-bit|all])
871
872 fi
873
874
875 BASECFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
Georg Brandl93de2162008-07-16 02:21:06 +0000876 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
Thomas Wouters477c8d52006-05-27 19:21:47 +0000877 fi
878
Skip Montanarodecc6a42003-01-01 20:07:49 +0000879 ;;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000880 OSF*)
881 BASECFLAGS="$BASECFLAGS -mieee"
882 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000883 esac
884 ;;
885
886*)
887 case $ac_sys_system in
888 OpenUNIX*|UnixWare*)
889 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
890 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +0000891 OSF*)
892 BASECFLAGS="$BASECFLAGS -ieee -std"
893 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000894 SCO_SV*)
895 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
896 ;;
897 esac
898 ;;
899esac
900
Fred Drakee1ceaa02001-12-04 20:55:47 +0000901if test "$Py_DEBUG" = 'true'; then
902 :
903else
904 OPT="-DNDEBUG $OPT"
905fi
906
Guido van Rossum6f2260e1996-09-09 16:21:03 +0000907if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +0000908then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000909 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +0000910fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000911
Neal Norwitz020c46a2006-01-07 21:39:28 +0000912# disable check for icc since it seems to pass, but generates a warning
913if test "$CC" = icc
914then
915 ac_cv_opt_olimit_ok=no
916fi
917
Guido van Rossum91922671997-10-09 20:24:13 +0000918AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
919AC_CACHE_VAL(ac_cv_opt_olimit_ok,
920[ac_save_cc="$CC"
921CC="$CC -OPT:Olimit=0"
922AC_TRY_RUN([int main() { return 0; }],
923 ac_cv_opt_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +0000924 ac_cv_opt_olimit_ok=no,
Guido van Rossum91922671997-10-09 20:24:13 +0000925 ac_cv_opt_olimit_ok=no)
926CC="$ac_save_cc"])
927AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +0000928if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +0000929 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000930 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
931 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
932 # environment?
933 Darwin*)
934 ;;
935 *)
936 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
937 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +0000938 esac
Guido van Rossumf8678121998-07-07 21:05:09 +0000939else
940 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
941 AC_CACHE_VAL(ac_cv_olimit_ok,
942 [ac_save_cc="$CC"
943 CC="$CC -Olimit 1500"
944 AC_TRY_RUN([int main() { return 0; }],
945 ac_cv_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +0000946 ac_cv_olimit_ok=no,
Guido van Rossumf8678121998-07-07 21:05:09 +0000947 ac_cv_olimit_ok=no)
948 CC="$ac_save_cc"])
949 AC_MSG_RESULT($ac_cv_olimit_ok)
950 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000951 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +0000952 fi
Guido van Rossum201afe51997-05-14 21:14:44 +0000953fi
Guido van Rossumf8678121998-07-07 21:05:09 +0000954
Thomas Wouters89f507f2006-12-13 04:49:30 +0000955# Check whether GCC supports PyArg_ParseTuple format
956if test "$GCC" = "yes"
957then
958 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
959 save_CFLAGS=$CFLAGS
960 CFLAGS="$CFLAGS -Werror"
961 AC_TRY_COMPILE([
962 void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
963 ],,
964 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
965 AC_MSG_RESULT(yes),
966 AC_MSG_RESULT(no)
967 )
968 CFLAGS=$save_CFLAGS
969fi
970
Martin v. Löwisa5f73f92001-10-15 08:06:29 +0000971# On some compilers, pthreads are available without further options
972# (e.g. MacOS X). On some of these systems, the compiler will not
973# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
974# So we have to see first whether pthreads are available without
975# options before we can check whether -Kpthread improves anything.
976AC_MSG_CHECKING(whether pthreads are available without options)
977AC_CACHE_VAL(ac_cv_pthread_is_default,
978[AC_TRY_RUN([
979#include <pthread.h>
980
981void* routine(void* p){return NULL;}
982
983int main(){
984 pthread_t p;
985 if(pthread_create(&p,NULL,routine,NULL)!=0)
986 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +0000987 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +0000988 return 0;
989}
990],
Skip Montanarod8d39a02003-07-10 20:44:10 +0000991[
992 ac_cv_pthread_is_default=yes
993 ac_cv_kthread=no
994 ac_cv_pthread=no
995],
Martin v. Löwisa5f73f92001-10-15 08:06:29 +0000996 ac_cv_pthread_is_default=no,
997 ac_cv_pthread_is_default=no)
998])
999AC_MSG_RESULT($ac_cv_pthread_is_default)
1000
1001
1002if test $ac_cv_pthread_is_default = yes
1003then
1004 ac_cv_kpthread=no
1005else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001006# -Kpthread, if available, provides the right #defines
1007# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001008# Some compilers won't report that they do not support -Kpthread,
1009# so we need to run a program to see whether it really made the
1010# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001011AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1012AC_CACHE_VAL(ac_cv_kpthread,
1013[ac_save_cc="$CC"
1014CC="$CC -Kpthread"
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001015AC_TRY_RUN([
1016#include <pthread.h>
1017
1018void* routine(void* p){return NULL;}
1019
1020int main(){
1021 pthread_t p;
1022 if(pthread_create(&p,NULL,routine,NULL)!=0)
1023 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001024 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001025 return 0;
1026}
1027],
Martin v. Löwis130fb172001-07-19 11:00:41 +00001028 ac_cv_kpthread=yes,
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001029 ac_cv_kpthread=no,
Martin v. Löwis130fb172001-07-19 11:00:41 +00001030 ac_cv_kpthread=no)
1031CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001032AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001033fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001034
Skip Montanarod8d39a02003-07-10 20:44:10 +00001035if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001036then
1037# -Kthread, if available, provides the right #defines
1038# and linker options to make pthread_create available
1039# Some compilers won't report that they do not support -Kthread,
1040# so we need to run a program to see whether it really made the
1041# function available.
1042AC_MSG_CHECKING(whether $CC accepts -Kthread)
1043AC_CACHE_VAL(ac_cv_kthread,
1044[ac_save_cc="$CC"
1045CC="$CC -Kthread"
1046AC_TRY_RUN([
1047#include <pthread.h>
1048
1049void* routine(void* p){return NULL;}
1050
1051int main(){
1052 pthread_t p;
1053 if(pthread_create(&p,NULL,routine,NULL)!=0)
1054 return 1;
1055 (void)pthread_detach(p);
1056 return 0;
1057}
1058],
1059 ac_cv_kthread=yes,
1060 ac_cv_kthread=no,
1061 ac_cv_kthread=no)
1062CC="$ac_save_cc"])
1063AC_MSG_RESULT($ac_cv_kthread)
1064fi
1065
Skip Montanarod8d39a02003-07-10 20:44:10 +00001066if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001067then
1068# -pthread, if available, provides the right #defines
1069# and linker options to make pthread_create available
1070# Some compilers won't report that they do not support -pthread,
1071# so we need to run a program to see whether it really made the
1072# function available.
1073AC_MSG_CHECKING(whether $CC accepts -pthread)
1074AC_CACHE_VAL(ac_cv_thread,
1075[ac_save_cc="$CC"
1076CC="$CC -pthread"
1077AC_TRY_RUN([
1078#include <pthread.h>
1079
1080void* routine(void* p){return NULL;}
1081
1082int main(){
1083 pthread_t p;
1084 if(pthread_create(&p,NULL,routine,NULL)!=0)
1085 return 1;
1086 (void)pthread_detach(p);
1087 return 0;
1088}
1089],
1090 ac_cv_pthread=yes,
1091 ac_cv_pthread=no,
1092 ac_cv_pthread=no)
1093CC="$ac_save_cc"])
1094AC_MSG_RESULT($ac_cv_pthread)
1095fi
1096
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001097# If we have set a CC compiler flag for thread support then
1098# check if it works for CXX, too.
1099ac_cv_cxx_thread=no
1100if test ! -z "$CXX"
1101then
1102AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1103ac_save_cxx="$CXX"
1104
1105if test "$ac_cv_kpthread" = "yes"
1106then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001107 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001108 ac_cv_cxx_thread=yes
1109elif test "$ac_cv_kthread" = "yes"
1110then
1111 CXX="$CXX -Kthread"
1112 ac_cv_cxx_thread=yes
1113elif test "$ac_cv_pthread" = "yes"
1114then
1115 CXX="$CXX -pthread"
1116 ac_cv_cxx_thread=yes
1117fi
1118
1119if test $ac_cv_cxx_thread = yes
1120then
1121 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1122 $CXX -c conftest.$ac_ext 2>&5
1123 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1124 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1125 then
1126 ac_cv_cxx_thread=yes
1127 else
1128 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001129 fi
1130 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001131fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001132AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001133fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001134CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001135
Fred Drakece81d592000-07-09 14:39:29 +00001136dnl # check for ANSI or K&R ("traditional") preprocessor
1137dnl AC_MSG_CHECKING(for C preprocessor type)
1138dnl AC_TRY_COMPILE([
1139dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1140dnl int foo;
1141dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1142dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1143dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001144
Guido van Rossum627b2d71993-12-24 10:39:16 +00001145# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001146AC_HEADER_STDC
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001147AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1148fcntl.h grp.h \
Christian Heimesbbe741d2008-03-28 10:53:29 +00001149ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Thomas Wouters89f507f2006-12-13 04:49:30 +00001150shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001151unistd.h utime.h \
Christian Heimes4fbc72b2008-03-22 00:47:35 +00001152sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1153sys/lock.h sys/mkdev.h sys/modem.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001154sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Georg Brandlf78e02b2008-06-10 17:40:04 +00001155sys/termio.h sys/time.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001156sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
Hye-Shik Chang81268602004-02-02 06:05:24 +00001157sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimes043d6f62008-01-07 17:19:16 +00001158bluetooth/bluetooth.h linux/tipc.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001159AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001160AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001161
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001162# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e72004-11-30 22:09:37 +00001163AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001164#ifdef HAVE_CURSES_H
1165#include <curses.h>
1166#endif
1167])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001168
Martin v. Löwis11017b12006-01-14 18:12:57 +00001169# On Linux, netlink.h requires asm/types.h
1170AC_CHECK_HEADERS(linux/netlink.h,,,[
1171#ifdef HAVE_ASM_TYPES_H
1172#include <asm/types.h>
1173#endif
1174#ifdef HAVE_SYS_SOCKET_H
1175#include <sys/socket.h>
1176#endif
1177])
1178
Guido van Rossum627b2d71993-12-24 10:39:16 +00001179# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001180was_it_defined=no
1181AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001182AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1183 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1184])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001185AC_MSG_RESULT($was_it_defined)
1186
Neal Norwitz11690112002-07-30 01:08:28 +00001187# Check whether using makedev requires defining _OSF_SOURCE
1188AC_MSG_CHECKING(for makedev)
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001189AC_TRY_LINK([#include <sys/types.h> ],
Neal Norwitz11690112002-07-30 01:08:28 +00001190 [ makedev(0, 0) ],
1191 ac_cv_has_makedev=yes,
1192 ac_cv_has_makedev=no)
1193if test "$ac_cv_has_makedev" = "no"; then
1194 # we didn't link, try if _OSF_SOURCE will allow us to link
1195 AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001196#define _OSF_SOURCE 1
1197#include <sys/types.h>
Neal Norwitz11690112002-07-30 01:08:28 +00001198 ],
1199 [ makedev(0, 0) ],
1200 ac_cv_has_makedev=yes,
1201 ac_cv_has_makedev=no)
1202 if test "$ac_cv_has_makedev" = "yes"; then
1203 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1204 fi
1205fi
1206AC_MSG_RESULT($ac_cv_has_makedev)
1207if test "$ac_cv_has_makedev" = "yes"; then
1208 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1209fi
1210
Martin v. Löwis399a6892002-10-04 10:22:02 +00001211# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1212# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1213# defined, but the compiler does not support pragma redefine_extname,
1214# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1215# structures (such as rlimit64) without declaring them. As a
1216# work-around, disable LFS on such configurations
1217
1218use_lfs=yes
1219AC_MSG_CHECKING(Solaris LFS bug)
1220AC_TRY_COMPILE([
1221#define _LARGEFILE_SOURCE 1
1222#define _FILE_OFFSET_BITS 64
1223#include <sys/resource.h>
1224],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1225AC_MSG_RESULT($sol_lfs_bug)
1226if test "$sol_lfs_bug" = "yes"; then
1227 use_lfs=no
1228fi
1229
1230if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001231# Two defines needed to enable largefile support on various platforms
1232# These may affect some typedefs
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001233AC_DEFINE(_LARGEFILE_SOURCE, 1,
1234[This must be defined on some systems to enable large file support.])
1235AC_DEFINE(_FILE_OFFSET_BITS, 64,
1236[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001237fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001238
Guido van Rossum300fda71996-08-19 21:58:16 +00001239# Add some code to confdefs.h so that the test for off_t works on SCO
1240cat >> confdefs.h <<\EOF
1241#if defined(SCO_DS)
1242#undef _OFF_T
1243#endif
1244EOF
1245
Guido van Rossumef2255b2000-03-10 22:30:29 +00001246# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001247AC_TYPE_MODE_T
1248AC_TYPE_OFF_T
1249AC_TYPE_PID_T
1250AC_TYPE_SIGNAL
1251AC_TYPE_SIZE_T
1252AC_TYPE_UID_T
Christian Heimes400adb02008-02-01 08:12:03 +00001253AC_CHECK_TYPE(ssize_t,
Martin v. Löwis18e16552006-02-15 17:27:45 +00001254 AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001255
Guido van Rossumef2255b2000-03-10 22:30:29 +00001256# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001257# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001258AC_CHECK_SIZEOF(int, 4)
1259AC_CHECK_SIZEOF(long, 4)
1260AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001261AC_CHECK_SIZEOF(short, 2)
1262AC_CHECK_SIZEOF(float, 4)
1263AC_CHECK_SIZEOF(double, 8)
1264AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001265AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes400adb02008-02-01 08:12:03 +00001266AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001267
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001268AC_MSG_CHECKING(for long long support)
1269have_long_long=no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001270AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1271 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1272 have_long_long=yes
1273])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001274AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001275if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001276AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001277fi
1278
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001279AC_MSG_CHECKING(for long double support)
1280have_long_double=no
1281AC_TRY_COMPILE([], [long double x; x = (long double)0;], [
1282 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1283 have_long_double=yes
1284])
1285AC_MSG_RESULT($have_long_double)
1286if test "$have_long_double" = yes ; then
1287AC_CHECK_SIZEOF(long double, 16)
1288fi
1289
1290
Thomas Woutersb2137042007-02-01 18:02:27 +00001291AC_MSG_CHECKING(for _Bool support)
1292have_c99_bool=no
1293AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1294 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1295 have_c99_bool=yes
1296])
1297AC_MSG_RESULT($have_c99_bool)
1298if test "$have_c99_bool" = yes ; then
1299AC_CHECK_SIZEOF(_Bool, 1)
1300fi
1301
Thomas Wouters89f507f2006-12-13 04:49:30 +00001302AC_CHECK_TYPES(uintptr_t,
1303 [AC_CHECK_SIZEOF(uintptr_t, 4)],
1304 [], [#ifdef HAVE_STDINT_H
1305 #include <stdint.h>
1306 #endif])
1307
Barry Warsawbc7c7f92000-08-18 04:53:33 +00001308
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001309# Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
1310AC_MSG_CHECKING(size of off_t)
1311AC_CACHE_VAL(ac_cv_sizeof_off_t,
1312[AC_TRY_RUN([#include <stdio.h>
1313#include <sys/types.h>
1314main()
1315{
1316 FILE *f=fopen("conftestval", "w");
1317 if (!f) exit(1);
1318 fprintf(f, "%d\n", sizeof(off_t));
1319 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001320}],
1321ac_cv_sizeof_off_t=`cat conftestval`,
1322ac_cv_sizeof_off_t=0,
1323ac_cv_sizeof_off_t=4)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001324])
1325AC_MSG_RESULT($ac_cv_sizeof_off_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001326AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t,
1327[The number of bytes in an off_t.])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001328
1329AC_MSG_CHECKING(whether to enable large file support)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001330if test "$have_long_long" = yes -a \
1331 "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
1332 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001333 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1334 [Defined to enable large file support when an off_t is bigger than a long
1335 and long long is available and at least as big as an off_t. You may need
1336 to add some flags for configuration and compilation to enable this mode.
1337 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001338 AC_MSG_RESULT(yes)
1339else
1340 AC_MSG_RESULT(no)
1341fi
1342
Fred Drakea3f6e912000-06-29 20:44:47 +00001343# AC_CHECK_SIZEOF() doesn't include <time.h>.
1344AC_MSG_CHECKING(size of time_t)
1345AC_CACHE_VAL(ac_cv_sizeof_time_t,
1346[AC_TRY_RUN([#include <stdio.h>
1347#include <time.h>
1348main()
1349{
1350 FILE *f=fopen("conftestval", "w");
1351 if (!f) exit(1);
1352 fprintf(f, "%d\n", sizeof(time_t));
1353 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001354}],
1355ac_cv_sizeof_time_t=`cat conftestval`,
1356ac_cv_sizeof_time_t=0,
1357ac_cv_sizeof_time_t=4)
Fred Drakea3f6e912000-06-29 20:44:47 +00001358])
1359AC_MSG_RESULT($ac_cv_sizeof_time_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001360AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t,
1361[The number of bytes in a time_t.])
Fred Drakea3f6e912000-06-29 20:44:47 +00001362
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001363
Trent Mick635f6fb2000-08-23 21:33:05 +00001364# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001365ac_save_cc="$CC"
1366if test "$ac_cv_kpthread" = "yes"
1367then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001368elif test "$ac_cv_kthread" = "yes"
1369then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001370elif test "$ac_cv_pthread" = "yes"
1371then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001372fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001373AC_MSG_CHECKING(for pthread_t)
1374have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +00001375AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +00001376AC_MSG_RESULT($have_pthread_t)
1377if test "$have_pthread_t" = yes ; then
1378 # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
1379 AC_MSG_CHECKING(size of pthread_t)
1380 AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
1381 [AC_TRY_RUN([#include <stdio.h>
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001382#include <pthread.h>
Trent Mick635f6fb2000-08-23 21:33:05 +00001383 main()
1384 {
1385 FILE *f=fopen("conftestval", "w");
1386 if (!f) exit(1);
1387 fprintf(f, "%d\n", sizeof(pthread_t));
1388 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001389 }],
1390 ac_cv_sizeof_pthread_t=`cat conftestval`,
1391 ac_cv_sizeof_pthread_t=0,
1392 ac_cv_sizeof_pthread_t=4)
Trent Mick635f6fb2000-08-23 21:33:05 +00001393 ])
1394 AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001395 AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t,
1396 [The number of bytes in a pthread_t.])
Trent Mick635f6fb2000-08-23 21:33:05 +00001397fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001398CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001399
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001400
Georg Brandl93de2162008-07-16 02:21:06 +00001401
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001402AC_SUBST(OTHER_LIBTOOL_OPT)
1403case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001404 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001405 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1406 ;;
1407 Darwin/*)
1408 OTHER_LIBTOOL_OPT=""
1409 ;;
1410esac
1411
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001412AC_SUBST(LIBTOOL_CRUFT)
1413case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001414 Darwin/@<:@01567@:>@\..*)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001415 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1416 if test "${enable_universalsdk}"; then
1417 :
1418 else
1419 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `arch`"
1420 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001421 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001422 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001423 Darwin/*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001424 gcc_version=`gcc -v 2>&1 | grep version | cut -d\ -f3`
1425 if test ${gcc_version} '<' 4.0
1426 then
1427 LIBTOOL_CRUFT="-lcc_dynamic"
1428 else
1429 LIBTOOL_CRUFT=""
1430 fi
Jack Jansen39fd2312006-02-23 15:12:19 +00001431 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only `arch`"
Jack Jansenb36687a2004-07-16 08:43:47 +00001432 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001433 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001434esac
1435
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001436AC_MSG_CHECKING(for --enable-framework)
1437if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001438then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001439 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001440 # -F. is needed to allow linking to the framework while
1441 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001442 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1443 [Define if you want to produce an OpenStep/Rhapsody framework
1444 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001445 AC_MSG_RESULT(yes)
1446else
1447 AC_MSG_RESULT(no)
1448fi
1449
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001450AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001451case $ac_sys_system/$ac_sys_release in
1452 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001453 AC_DEFINE(WITH_DYLD, 1,
1454 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1455 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1456 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001457 AC_MSG_RESULT(always on for Darwin)
1458 ;;
1459 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001460 AC_MSG_RESULT(no)
1461 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001462esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001463
Guido van Rossumac405f61994-09-12 10:56:06 +00001464# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001465AC_SUBST(SO)
1466AC_SUBST(LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001467AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001468AC_SUBST(CCSHARED)
1469AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001470# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001471# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001472AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001473if test -z "$SO"
1474then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001475 case $ac_sys_system in
Thomas Wouters477c8d52006-05-27 19:21:47 +00001476 hp*|HP*)
1477 case `uname -m` in
1478 ia64) SO=.so;;
1479 *) SO=.sl;;
1480 esac
1481 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001482 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001483 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001484 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001485else
1486 # this might also be a termcap variable, see #610332
1487 echo
1488 echo '====================================================================='
1489 echo '+ +'
1490 echo '+ WARNING: You have set SO in your environment. +'
1491 echo '+ Do you really mean to change the extension for shared libraries? +'
1492 echo '+ Continuing in 10 seconds to let you to ponder. +'
1493 echo '+ +'
1494 echo '====================================================================='
1495 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001496fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001497AC_MSG_RESULT($SO)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001498AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001499# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001500# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001501# (Shared libraries in this instance are shared modules to be loaded into
1502# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001503AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001504if test -z "$LDSHARED"
1505then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001506 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001507 AIX*)
1508 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001509 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001510 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001511 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001512 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a6632000-05-26 12:22:54 +00001513 SunOS/5*)
1514 if test "$GCC" = "yes"
Neil Schemenauer95052722001-02-19 18:17:33 +00001515 then LDSHARED='$(CC) -shared'
Martin v. Löwisaa5afe12002-10-07 06:21:41 +00001516 else LDSHARED='$(CC) -G';
Greg Ward57c9a6632000-05-26 12:22:54 +00001517 fi ;;
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001518 hp*|HP*)
1519 if test "$GCC" = "yes"
1520 then LDSHARED='$(CC) -shared'
1521 else LDSHARED='ld -b';
1522 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001523 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001524 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +00001525 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1526 if test "$enable_framework" ; then
1527 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001528 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1529 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001530 else
1531 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001532 LDSHARED="$LDSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001533 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001534 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001535 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1536 if test "$enable_framework" ; then
1537 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001538 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1539 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001540 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001541 # No framework, use the Python app as bundle-loader
1542 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001543 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001544 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001545 Darwin/*)
1546 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1547 # This allows an extension to be used in any Python
Jack Jansenbe954622004-12-26 23:07:48 +00001548 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
Thomas Wouters477c8d52006-05-27 19:21:47 +00001549 if test ${cur_target} '>' 10.2; then
1550 cur_target=10.3
1551 fi
Georg Brandlfcaf9102008-07-16 02:17:56 +00001552 if test "${UNIVERSAL_ARCHS}" = "all"; then
1553 # Ensure that the default platform for a 4-way
1554 # universal build is OSX 10.5, that's the first
1555 # OS release where 4-way builds make sense.
1556 cur_target='10.5'
1557 fi
Jack Jansenc110f862005-01-07 10:49:32 +00001558 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
Thomas Wouters89d996e2007-09-08 17:39:28 +00001559
1560 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1561 # environment with a value that is the same as what we'll use
1562 # in the Makefile to ensure that we'll get the same compiler
1563 # environment during configure and build time.
1564 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1565 export MACOSX_DEPLOYMENT_TARGET
1566
Thomas Wouters477c8d52006-05-27 19:21:47 +00001567 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
Georg Brandlfcaf9102008-07-16 02:17:56 +00001568 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001569 then
Thomas Wouters477c8d52006-05-27 19:21:47 +00001570 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +00001571 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001572 fi
Jack Jansen6b08a402004-06-03 12:41:45 +00001573 LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1574 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001575 else
1576 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1577 if test "$enable_framework" ; then
1578 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001579 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1580 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001581 else
1582 # No framework, use the Python app as bundle-loader
1583 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1584 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1585 fi
1586 fi
1587 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001588 Linux*|GNU*|QNX*) LDSHARED='$(CC) -shared';;
Guido van Rossum458e7fa1999-09-17 15:40:40 +00001589 BSD/OS*/4*) LDSHARED="gcc -shared";;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001590 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001591 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001592 then
Hye-Shik Chang33761492004-10-26 09:53:46 +00001593 LDSHARED="$CC -shared ${LDFLAGS}"
Guido van Rossum0286ae82000-08-29 15:06:49 +00001594 else
1595 LDSHARED="ld -Bshareable ${LDFLAGS}"
1596 fi;;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001597 OpenBSD*)
1598 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1599 then
1600 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1601 else
1602 case `uname -r` in
1603 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1604 LDSHARED="ld -Bshareable ${LDFLAGS}"
1605 ;;
1606 *)
1607 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1608 ;;
1609 esac
1610 fi;;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001611 NetBSD*|DragonFly*) LDSHARED="cc -shared ${LDFLAGS}";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001612 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001613 if test "$GCC" = "yes"
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001614 then LDSHARED='$(CC) -shared'
1615 else LDSHARED='$(CC) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001616 fi;;
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001617 SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
Trent Mick635f6fb2000-08-23 21:33:05 +00001618 Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001619 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001620 atheos*) LDSHARED="gcc -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001621 *) LDSHARED="ld";;
1622 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001623fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001624AC_MSG_RESULT($LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001625BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001626# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001627# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001628AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001629if test -z "$CCSHARED"
1630then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001631 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001632 SunOS*) if test "$GCC" = yes;
Guido van Rossumd8faa362007-04-27 19:54:29 +00001633 then CCSHARED="-fPIC";
1634 elif test `uname -p` = sparc;
1635 then CCSHARED="-xcode=pic32";
1636 else CCSHARED="-Kpic";
1637 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001638 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001639 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001640 else CCSHARED="+z";
1641 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001642 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001643 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001644 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001645 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001646 if test "$GCC" = "yes"
1647 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001648 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001649 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001650 SCO_SV*)
1651 if test "$GCC" = "yes"
1652 then CCSHARED="-fPIC"
1653 else CCSHARED="-Kpic -belf"
1654 fi;;
Trent Mick635f6fb2000-08-23 21:33:05 +00001655 Monterey*) CCSHARED="-G";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001656 IRIX*/6*) case $CC in
1657 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001658 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001659 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001660 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001661 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001662fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001663AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001664# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001665# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001666AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001667if test -z "$LINKFORSHARED"
1668then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001669 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001670 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001671 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001672 LINKFORSHARED="-Wl,-E -Wl,+s";;
1673# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001674 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001675 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001676 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001677 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001678 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
1679 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001680 # not used by the core itself but which needs to be in the core so
1681 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00001682 # -prebind is no longer used, because it actually seems to give a
1683 # slowdown in stead of a speedup, maybe due to the large number of
1684 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001685
1686 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001687 if test "$enable_framework"
1688 then
Jack Jansenda49e192005-01-07 13:08:22 +00001689 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001690 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001691 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001692 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001693 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001694 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001695 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001696 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1697 then
1698 LINKFORSHARED="-Wl,--export-dynamic"
1699 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001700 SunOS/5*) case $CC in
1701 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001702 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001703 then
1704 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001705 fi;;
1706 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001707 CYGWIN*)
1708 if test $enable_shared = "no"
1709 then
1710 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1711 fi;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001712 QNX*)
1713 # -Wl,-E causes the symbols to be added to the dynamic
1714 # symbol table so that they can be found when a module
1715 # is loaded. -N 2048K causes the stack size to be set
1716 # to 2048 kilobytes so that the stack doesn't overflow
1717 # when running test_compile.py.
1718 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00001719 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001720fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001721AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001722
Georg Brandl93de2162008-07-16 02:21:06 +00001723
Neil Schemenauer61c51152001-01-26 16:18:16 +00001724AC_SUBST(CFLAGSFORSHARED)
1725AC_MSG_CHECKING(CFLAGSFORSHARED)
1726if test ! "$LIBRARY" = "$LDLIBRARY"
1727then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00001728 case $ac_sys_system in
1729 CYGWIN*)
1730 # Cygwin needs CCSHARED when building extension DLLs
1731 # but not when building the interpreter DLL.
1732 CFLAGSFORSHARED='';;
1733 *)
1734 CFLAGSFORSHARED='$(CCSHARED)'
1735 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00001736fi
1737AC_MSG_RESULT($CFLAGSFORSHARED)
1738
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001739# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1740# library (with --enable-shared).
1741# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001742# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1743# if it is not required, since it creates a dependency of the shared library
1744# to LIBS. This, in turn, means that applications linking the shared libpython
1745# don't need to link LIBS explicitly. The default should be only changed
1746# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001747AC_SUBST(SHLIBS)
1748AC_MSG_CHECKING(SHLIBS)
1749case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001750 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001751 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001752esac
1753AC_MSG_RESULT($SHLIBS)
1754
1755
Guido van Rossum627b2d71993-12-24 10:39:16 +00001756# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001757AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
1758AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00001759
1760# only check for sem_ini if thread support is requested
1761if test "$with_threads" = "yes" -o -z "$with_threads"; then
1762 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1763 # posix4 on Solaris 2.6
1764 # pthread (first!) on Linux
1765fi
1766
Martin v. Löwis19d17342003-06-14 21:03:05 +00001767# check if we need libintl for locale functions
1768AC_CHECK_LIB(intl, textdomain,
1769 AC_DEFINE(WITH_LIBINTL, 1,
1770 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001771
1772# checks for system dependent C++ extensions support
1773case "$ac_sys_system" in
1774 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1775 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1776 [loadAndInit("", 0, "")],
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001777 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1778 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1779 and you want support for AIX C++ shared extension modules.])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001780 AC_MSG_RESULT(yes)],
1781 [AC_MSG_RESULT(no)]);;
1782 *) ;;
1783esac
1784
Guido van Rossum70c7f481998-03-26 18:44:10 +00001785# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001786AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001787AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00001788
Guido van Rossumc5a39031996-07-31 17:35:03 +00001789AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001790AC_ARG_WITH(libs,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001791 AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1792[
Guido van Rossumc5a39031996-07-31 17:35:03 +00001793AC_MSG_RESULT($withval)
1794LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001795],
1796[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001797
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001798# Check for use of the system libffi library
1799AC_MSG_CHECKING(for --with-system-ffi)
1800AC_ARG_WITH(system_ffi,
1801 AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
1802
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001803AC_MSG_RESULT($with_system_ffi)
1804
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001805# Determine if signalmodule should be used.
1806AC_SUBST(USE_SIGNAL_MODULE)
1807AC_SUBST(SIGNAL_OBJS)
1808AC_MSG_CHECKING(for --with-signal-module)
1809AC_ARG_WITH(signal-module,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001810 AC_HELP_STRING(--with-signal-module, disable/enable signal module))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001811
1812if test -z "$with_signal_module"
1813then with_signal_module="yes"
1814fi
1815AC_MSG_RESULT($with_signal_module)
1816
1817if test "${with_signal_module}" = "yes"; then
1818 USE_SIGNAL_MODULE=""
1819 SIGNAL_OBJS=""
1820else
1821 USE_SIGNAL_MODULE="#"
1822 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1823fi
1824
Guido van Rossum3d15bd82001-01-10 18:53:48 +00001825# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00001826AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001827USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00001828
Guido van Rossum54d93d41997-01-22 20:51:58 +00001829AC_MSG_CHECKING(for --with-dec-threads)
1830AC_SUBST(LDLAST)
1831AC_ARG_WITH(dec-threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001832 AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1833[
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001834AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00001835LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00001836if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00001837 with_thread="$withval";
1838fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001839[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00001840
Martin v. Löwis11437992002-04-12 09:54:03 +00001841# Templates for things AC_DEFINEd more than once.
1842# For a single AC_DEFINE, no template is needed.
1843AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
1844AH_TEMPLATE(_REENTRANT,
1845 [Define to force use of thread-safe errno, h_errno, and other functions])
1846AH_TEMPLATE(WITH_THREAD,
1847 [Define if you want to compile in rudimentary thread support])
1848
Guido van Rossum54d93d41997-01-22 20:51:58 +00001849AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001850dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001851AC_ARG_WITH(threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001852 AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
Guido van Rossum54d93d41997-01-22 20:51:58 +00001853
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001854# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001855dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00001856AC_ARG_WITH(thread,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001857 AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
1858 [with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001859
1860if test -z "$with_threads"
1861then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001862fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001863AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00001864
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001865AC_SUBST(THREADOBJ)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001866if test "$with_threads" = "no"
1867then
1868 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001869elif test "$ac_cv_pthread_is_default" = yes
1870then
1871 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001872 # Defining _REENTRANT on system with POSIX threads should not hurt.
1873 AC_DEFINE(_REENTRANT)
1874 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001875 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001876elif test "$ac_cv_kpthread" = "yes"
1877then
1878 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00001879 if test "$ac_cv_cxx_thread" = "yes"; then
1880 CXX="$CXX -Kpthread"
1881 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001882 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001883 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001884 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001885elif test "$ac_cv_kthread" = "yes"
1886then
1887 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00001888 if test "$ac_cv_cxx_thread" = "yes"; then
1889 CXX="$CXX -Kthread"
1890 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001891 AC_DEFINE(WITH_THREAD)
1892 posix_threads=yes
1893 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001894elif test "$ac_cv_pthread" = "yes"
1895then
1896 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00001897 if test "$ac_cv_cxx_thread" = "yes"; then
1898 CXX="$CXX -pthread"
1899 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001900 AC_DEFINE(WITH_THREAD)
1901 posix_threads=yes
1902 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001903else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001904 if test ! -z "$with_threads" -a -d "$with_threads"
1905 then LDFLAGS="$LDFLAGS -L$with_threads"
1906 fi
1907 if test ! -z "$withval" -a -d "$withval"
1908 then LDFLAGS="$LDFLAGS -L$withval"
1909 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001910
1911 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00001912 # define _POSIX_THREADS in unistd.h. Some apparently don't
1913 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001914 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
1915 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001916 [
1917#include <unistd.h>
1918#ifdef _POSIX_THREADS
1919yes
1920#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001921 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
1922 AC_MSG_RESULT($unistd_defines_pthreads)
1923
Martin v. Löwis130fb172001-07-19 11:00:41 +00001924 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001925 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
1926 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001927 AC_DEFINE(HURD_C_THREADS, 1,
1928 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001929 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001930 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00001931 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
1932 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001933 AC_DEFINE(MACH_C_THREADS, 1,
1934 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001935 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00001936 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001937 AC_ARG_WITH([pth],
1938 AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
1939 [AC_MSG_RESULT($withval)
1940 AC_DEFINE([WITH_THREAD])
1941 AC_DEFINE([HAVE_PTH], 1,
1942 [Define if you have GNU PTH threads.])
1943 LIBS="-lpth $LIBS"
1944 THREADOBJ="Python/thread.o"],
1945 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00001946
1947 # Just looking for pthread_create in libpthread is not enough:
1948 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
1949 # So we really have to include pthread.h, and then link.
1950 _libs=$LIBS
1951 LIBS="$LIBS -lpthread"
1952 AC_MSG_CHECKING([for pthread_create in -lpthread])
1953 AC_TRY_LINK([#include <pthread.h>
1954
1955void * start_routine (void *arg) { exit (0); }], [
1956pthread_create (NULL, NULL, start_routine, NULL)], [
1957 AC_MSG_RESULT(yes)
1958 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001959 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001960 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00001961 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00001962 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001963 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001964 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001965 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
1966 AC_DEFINE(ATHEOS_THREADS, 1,
1967 [Define this if you have AtheOS threads.])
1968 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00001969 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001970 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001971 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001972 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00001973 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001974 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001975 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001976 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00001977 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001978 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001979 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001980 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00001981 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001982 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001983 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001984 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00001985 USE_THREAD_MODULE="#"])
Skip Montanaroeb33e5a2007-08-17 12:57:41 +00001986 ])])])])])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001987
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001988 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
1989 LIBS="$LIBS -lmpc"
1990 THREADOBJ="Python/thread.o"
1991 USE_THREAD_MODULE=""])
1992
1993 if test "$posix_threads" != "yes"; then
1994 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
1995 LIBS="$LIBS -lthread"
1996 THREADOBJ="Python/thread.o"
1997 USE_THREAD_MODULE=""])
1998 fi
1999
2000 if test "$USE_THREAD_MODULE" != "#"
2001 then
2002 # If the above checks didn't disable threads, (at least) OSF1
2003 # needs this '-threads' argument during linking.
2004 case $ac_sys_system in
2005 OSF1) LDLAST=-threads;;
2006 esac
2007 fi
2008fi
2009
2010if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002011 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002012 AC_DEFINE(_POSIX_THREADS, 1,
2013 [Define if you have POSIX threads,
2014 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002015 fi
2016
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002017 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2018 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002019 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2020 Defined for Solaris 2.6 bug in pthread header.)
2021 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002022 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002023 Define if the Posix semaphores do not work on your system)
2024 ;;
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002025 AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2026 Define if the Posix semaphores do not work on your system)
2027 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002028 esac
2029
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002030 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2031 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2032 [AC_TRY_RUN([#include <pthread.h>
2033 void *foo(void *parm) {
2034 return NULL;
2035 }
2036 main() {
2037 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002038 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002039 if (pthread_attr_init(&attr)) exit(-1);
2040 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002041 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002042 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00002043 }],
2044 ac_cv_pthread_system_supported=yes,
2045 ac_cv_pthread_system_supported=no,
2046 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002047 ])
2048 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2049 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002050 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002051 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002052 AC_CHECK_FUNCS(pthread_sigmask,
2053 [case $ac_sys_system in
2054 CYGWIN*)
2055 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2056 [Define if pthread_sigmask() does not work on your system.])
2057 ;;
2058 esac])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002059fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002060
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002061
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002062# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002063AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002064AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002065AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002066[ --enable-ipv6 Enable ipv6 (with ipv4) support
2067 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002068[ case "$enableval" in
2069 no)
2070 AC_MSG_RESULT(no)
2071 ipv6=no
2072 ;;
2073 *) AC_MSG_RESULT(yes)
2074 AC_DEFINE(ENABLE_IPV6)
2075 ipv6=yes
2076 ;;
2077 esac ],
2078
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002079[
2080dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002081 AC_TRY_RUN([ /* AF_INET6 available check */
2082#include <sys/types.h>
2083#include <sys/socket.h>
2084main()
2085{
2086 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2087 exit(1);
2088 else
2089 exit(0);
2090}
2091],
2092 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002093 ipv6=yes,
2094 AC_MSG_RESULT(no)
2095 ipv6=no,
2096 AC_MSG_RESULT(no)
2097 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002098)
2099
2100if test "$ipv6" = "yes"; then
2101 AC_MSG_CHECKING(if RFC2553 API is available)
2102 AC_TRY_COMPILE([#include <sys/types.h>
2103#include <netinet/in.h>],
2104 [struct sockaddr_in6 x;
2105x.sin6_scope_id;],
2106 AC_MSG_RESULT(yes)
2107 ipv6=yes,
2108 AC_MSG_RESULT(no, IPv6 disabled)
2109 ipv6=no)
2110fi
2111
2112if test "$ipv6" = "yes"; then
2113 AC_DEFINE(ENABLE_IPV6)
2114fi
2115])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002116
2117ipv6type=unknown
2118ipv6lib=none
2119ipv6trylibc=no
2120
2121if test "$ipv6" = "yes"; then
2122 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002123 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2124 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002125 case $i in
2126 inria)
2127 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002128 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002129#include <netinet/in.h>
2130#ifdef IPV6_INRIA_VERSION
2131yes
2132#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002133 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002134 ;;
2135 kame)
2136 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002137 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002138#include <netinet/in.h>
2139#ifdef __KAME__
2140yes
2141#endif],
2142 [ipv6type=$i;
2143 ipv6lib=inet6
2144 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002145 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002146 ;;
2147 linux-glibc)
2148 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002149 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002150#include <features.h>
2151#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2152yes
2153#endif],
2154 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002155 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002156 ;;
2157 linux-inet6)
2158 dnl http://www.v6.linux.or.jp/
2159 if test -d /usr/inet6; then
2160 ipv6type=$i
2161 ipv6lib=inet6
2162 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002163 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002164 fi
2165 ;;
2166 solaris)
2167 if test -f /etc/netconfig; then
2168 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2169 ipv6type=$i
2170 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002171 fi
2172 fi
2173 ;;
2174 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002175 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002176#include <sys/param.h>
2177#ifdef _TOSHIBA_INET6
2178yes
2179#endif],
2180 [ipv6type=$i;
2181 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002182 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002183 ;;
2184 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002185 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002186#include </usr/local/v6/include/sys/v6config.h>
2187#ifdef __V6D__
2188yes
2189#endif],
2190 [ipv6type=$i;
2191 ipv6lib=v6;
2192 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002193 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002194 ;;
2195 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002196 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002197#include <sys/param.h>
2198#ifdef _ZETA_MINAMI_INET6
2199yes
2200#endif],
2201 [ipv6type=$i;
2202 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002203 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002204 ;;
2205 esac
2206 if test "$ipv6type" != "unknown"; then
2207 break
2208 fi
2209 done
2210 AC_MSG_RESULT($ipv6type)
2211fi
2212
2213if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2214 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2215 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2216 echo "using lib$ipv6lib"
2217 else
2218 if test $ipv6trylibc = "yes"; then
2219 echo "using libc"
2220 else
2221 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2222 echo "You need to fetch lib$ipv6lib.a from appropriate"
2223 echo 'ipv6 kit and compile beforehand.'
2224 exit 1
2225 fi
2226 fi
2227fi
2228
Georg Brandl93de2162008-07-16 02:21:06 +00002229AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2230AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
2231 AC_DEFINE(HAVE_OSX105_SDK, 1, Define if compiling using MacOS X 10.5 SDK or later.)
2232 AC_MSG_RESULT(yes),
2233 AC_MSG_RESULT(no)
2234)
2235
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002236# Check for --with-doc-strings
2237AC_MSG_CHECKING(for --with-doc-strings)
2238AC_ARG_WITH(doc-strings,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002239 AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002240
2241if test -z "$with_doc_strings"
2242then with_doc_strings="yes"
2243fi
2244if test "$with_doc_strings" != "no"
2245then
2246 AC_DEFINE(WITH_DOC_STRINGS, 1,
2247 [Define if you want documentation strings in extension modules])
2248fi
2249AC_MSG_RESULT($with_doc_strings)
2250
Neil Schemenauera35c6882001-02-27 04:45:05 +00002251# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002252AC_MSG_CHECKING(for --with-tsc)
2253AC_ARG_WITH(tsc,
2254[ --with(out)-tsc enable/disable timestamp counter profile], [
2255if test "$withval" != no
2256then
2257 AC_DEFINE(WITH_TSC, 1,
2258 [Define to profile with the Pentium timestamp counter])
2259 AC_MSG_RESULT(yes)
2260else AC_MSG_RESULT(no)
2261fi],
2262[AC_MSG_RESULT(no)])
2263
2264# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002265AC_MSG_CHECKING(for --with-pymalloc)
2266AC_ARG_WITH(pymalloc,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002267 AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002268
2269if test -z "$with_pymalloc"
2270then with_pymalloc="yes"
2271fi
2272if test "$with_pymalloc" != "no"
2273then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002274 AC_DEFINE(WITH_PYMALLOC, 1,
2275 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002276fi
2277AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002278
Barry Warsawef82cd72000-06-30 16:21:01 +00002279# Check for --with-wctype-functions
2280AC_MSG_CHECKING(for --with-wctype-functions)
2281AC_ARG_WITH(wctype-functions,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002282 AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2283[
Barry Warsawef82cd72000-06-30 16:21:01 +00002284if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002285then
2286 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2287 [Define if you want wctype.h functions to be used instead of the
2288 one supplied by Python itself. (see Include/unicodectype.h).])
2289 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002290else AC_MSG_RESULT(no)
2291fi],
2292[AC_MSG_RESULT(no)])
2293
Guido van Rossum68242b51996-05-28 22:53:03 +00002294# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002295AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002296DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002297
Guido van Rossume97ee181999-12-20 21:27:22 +00002298# the dlopen() function means we might want to use dynload_shlib.o. some
2299# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002300AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002301
2302# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2303# loading of modules.
2304AC_SUBST(DYNLOADFILE)
2305AC_MSG_CHECKING(DYNLOADFILE)
2306if test -z "$DYNLOADFILE"
2307then
2308 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002309 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2310 if test "$ac_cv_func_dlopen" = yes
2311 then DYNLOADFILE="dynload_shlib.o"
2312 else DYNLOADFILE="dynload_aix.o"
2313 fi
2314 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002315 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002316 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2317 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002318 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002319 *)
2320 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2321 # out any dynamic loading
2322 if test "$ac_cv_func_dlopen" = yes
2323 then DYNLOADFILE="dynload_shlib.o"
2324 else DYNLOADFILE="dynload_stub.o"
2325 fi
2326 ;;
2327 esac
2328fi
2329AC_MSG_RESULT($DYNLOADFILE)
2330if test "$DYNLOADFILE" != "dynload_stub.o"
2331then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002332 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2333 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002334fi
2335
Jack Jansenc49e5b72001-06-19 15:00:23 +00002336# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2337
2338AC_SUBST(MACHDEP_OBJS)
2339AC_MSG_CHECKING(MACHDEP_OBJS)
2340if test -z "$MACHDEP_OBJS"
2341then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002342 MACHDEP_OBJS=$extra_machdep_objs
2343else
2344 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002345fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002346AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002347
Guido van Rossum627b2d71993-12-24 10:39:16 +00002348# checks for library functions
Martin v. Löwis823725e2008-03-24 13:39:54 +00002349AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2350 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002351 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwisc3001752005-01-23 09:27:24 +00002352 getpriority getpwent getspnam getspent getsid getwd \
Christian Heimesd0764e22007-12-04 15:00:33 +00002353 kill killpg lchmod lchown lstat mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002354 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002355 putenv readlink realpath \
Martin v. Löwisd5843682002-11-21 20:41:28 +00002356 select setegid seteuid setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002357 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Gregory P. Smith6c357262007-09-03 16:44:06 +00002358 sigaction siginterrupt sigrelse strftime strlcpy \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002359 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Martin v. Löwis92fab752008-03-08 10:40:41 +00002360 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll wcsxfrm _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002361
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002362# For some functions, having a definition is not sufficient, since
2363# we want to take their address.
2364AC_MSG_CHECKING(for chroot)
2365AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2366 AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2367 AC_MSG_RESULT(yes),
2368 AC_MSG_RESULT(no)
2369)
2370AC_MSG_CHECKING(for link)
2371AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2372 AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2373 AC_MSG_RESULT(yes),
2374 AC_MSG_RESULT(no)
2375)
2376AC_MSG_CHECKING(for symlink)
2377AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2378 AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2379 AC_MSG_RESULT(yes),
2380 AC_MSG_RESULT(no)
2381)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002382AC_MSG_CHECKING(for fchdir)
2383AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2384 AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2385 AC_MSG_RESULT(yes),
2386 AC_MSG_RESULT(no)
2387)
2388AC_MSG_CHECKING(for fsync)
2389AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
Skip Montanarod4fa8072003-09-25 14:49:15 +00002390 AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002391 AC_MSG_RESULT(yes),
2392 AC_MSG_RESULT(no)
2393)
2394AC_MSG_CHECKING(for fdatasync)
2395AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2396 AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2397 AC_MSG_RESULT(yes),
2398 AC_MSG_RESULT(no)
2399)
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002400AC_MSG_CHECKING(for epoll)
2401AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
2402 AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2403 AC_MSG_RESULT(yes),
2404 AC_MSG_RESULT(no)
2405)
2406AC_MSG_CHECKING(for kqueue)
2407AC_TRY_COMPILE([
2408#include <sys/types.h>
2409#include <sys/event.h>
2410 ], int x=kqueue(),
2411 AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2412 AC_MSG_RESULT(yes),
2413 AC_MSG_RESULT(no)
2414)
Martin v. Löwisd5843682002-11-21 20:41:28 +00002415# On some systems (eg. FreeBSD 5), we would find a definition of the
2416# functions ctermid_r, setgroups in the library, but no prototype
2417# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2418# address to avoid compiler warnings and potential miscompilations
2419# because of the missing prototypes.
2420
2421AC_MSG_CHECKING(for ctermid_r)
2422AC_TRY_COMPILE([
2423#include "confdefs.h"
2424#include <stdio.h>
2425], void* p = ctermid_r,
2426 AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2427 AC_MSG_RESULT(yes),
2428 AC_MSG_RESULT(no)
2429)
2430
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002431AC_MSG_CHECKING(for flock)
2432AC_TRY_COMPILE([
2433#include "confdefs.h"
2434#include <sys/file.h>
2435], void* p = flock,
2436 AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2437 AC_MSG_RESULT(yes),
2438 AC_MSG_RESULT(no)
2439)
2440
2441AC_MSG_CHECKING(for getpagesize)
2442AC_TRY_COMPILE([
2443#include "confdefs.h"
2444#include <unistd.h>
2445], void* p = getpagesize,
2446 AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2447 AC_MSG_RESULT(yes),
2448 AC_MSG_RESULT(no)
2449)
2450
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002451dnl check for true
2452AC_CHECK_PROGS(TRUE, true, /bin/true)
2453
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002454dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2455dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002456AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002457 AC_CHECK_LIB(resolv, inet_aton)
2458)
2459
Christian Heimesd0764e22007-12-04 15:00:33 +00002460# On Tru64, chflags seems to be present, but calling it will
2461# exit Python
2462AC_MSG_CHECKING(for chflags)
2463AC_TRY_RUN([
2464#include <sys/stat.h>
2465#include <unistd.h>
2466int main(int argc, char*argv[])
2467{
2468 if(chflags(argv[0], 0) != 0)
2469 return 1;
2470 return 0;
2471}
2472],AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
2473 AC_MSG_RESULT(yes),
2474 AC_MSG_RESULT(no)
2475)
2476
2477AC_MSG_CHECKING(for lchflags)
2478AC_TRY_RUN([
2479#include <sys/stat.h>
2480#include <unistd.h>
2481int main(int argc, char*argv[])
2482{
2483 if(lchflags(argv[0], 0) != 0)
2484 return 1;
2485 return 0;
2486}
2487],AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
2488 AC_MSG_RESULT(yes),
2489 AC_MSG_RESULT(no)
2490)
2491
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002492dnl Check if system zlib has *Copy() functions
2493dnl
2494dnl On MacOSX the linker will search for dylibs on the entire linker path
2495dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2496dnl to revert to a more traditional unix behaviour and make it possible to
2497dnl override the system libz with a local static library of libz. Temporarily
2498dnl add that flag to our CFLAGS as well to ensure that we check the version
2499dnl of libz that will be used by setup.py.
2500dnl The -L/usr/local/lib is needed as wel to get the same compilation
2501dnl environment as setup.py (and leaving it out can cause configure to use the
2502dnl wrong version of the library)
2503case $ac_sys_system/$ac_sys_release in
2504Darwin/*)
2505 _CUR_CFLAGS="${CFLAGS}"
2506 _CUR_LDFLAGS="${LDFLAGS}"
2507 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2508 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2509 ;;
2510esac
2511
2512AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2513
2514case $ac_sys_system/$ac_sys_release in
2515Darwin/*)
2516 CFLAGS="${_CUR_CFLAGS}"
2517 LDFLAGS="${_CUR_LDFLAGS}"
2518 ;;
2519esac
2520
Martin v. Löwise9416172003-05-03 10:12:45 +00002521AC_MSG_CHECKING(for hstrerror)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002522AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002523#include "confdefs.h"
2524#include <netdb.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002525], void* p = hstrerror; hstrerror(0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002526 AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2527 AC_MSG_RESULT(yes),
2528 AC_MSG_RESULT(no)
2529)
2530
2531AC_MSG_CHECKING(for inet_aton)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002532AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002533#include "confdefs.h"
Martin v. Löwis86d66262006-02-17 08:40:11 +00002534#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002535#include <sys/socket.h>
2536#include <netinet/in.h>
2537#include <arpa/inet.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002538], void* p = inet_aton;inet_aton(0,0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002539 AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2540 AC_MSG_RESULT(yes),
2541 AC_MSG_RESULT(no)
2542)
2543
2544AC_MSG_CHECKING(for inet_pton)
2545AC_TRY_COMPILE([
2546#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002547#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002548#include <sys/socket.h>
2549#include <netinet/in.h>
2550#include <arpa/inet.h>
2551], void* p = inet_pton,
2552 AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2553 AC_MSG_RESULT(yes),
2554 AC_MSG_RESULT(no)
2555)
2556
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002557# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002558AC_MSG_CHECKING(for setgroups)
2559AC_TRY_COMPILE([
2560#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002561#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002562#ifdef HAVE_GRP_H
2563#include <grp.h>
2564#endif
Martin v. Löwisd5843682002-11-21 20:41:28 +00002565],
2566void* p = setgroups,
2567 AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2568 AC_MSG_RESULT(yes),
2569 AC_MSG_RESULT(no)
2570)
2571
Fred Drake8cef4cf2000-06-28 16:40:38 +00002572# check for openpty and forkpty
2573
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002574AC_CHECK_FUNCS(openpty,,
2575 AC_CHECK_LIB(util,openpty,
2576 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2577 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2578 )
2579)
2580AC_CHECK_FUNCS(forkpty,,
2581 AC_CHECK_LIB(util,forkpty,
2582 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2583 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2584 )
2585)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002586
Christian Heimesb186d002008-03-18 15:15:01 +00002587# Stuff for expat.
2588AC_CHECK_FUNCS(memmove)
2589
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002590# check for long file support functions
2591AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2592
Christian Heimesb186d002008-03-18 15:15:01 +00002593AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002594AC_CHECK_FUNCS(getpgrp,
2595 AC_TRY_COMPILE([#include <unistd.h>],
2596 [getpgrp(0);],
2597 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2598 [Define if getpgrp() must be called as getpgrp(0).])
2599 )
2600)
Jack Jansen150753c2003-03-29 22:07:47 +00002601AC_CHECK_FUNCS(setpgrp,
2602 AC_TRY_COMPILE([#include <unistd.h>],
2603 [setpgrp(0,0);],
2604 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2605 [Define if setpgrp() must be called as setpgrp(0, 0).])
2606 )
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002607)
2608AC_CHECK_FUNCS(gettimeofday,
2609 AC_TRY_COMPILE([#include <sys/time.h>],
2610 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2611 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2612 [Define if gettimeofday() does not have second (timezone) argument
2613 This is the case on Motorola V4 (R40V4.2)])
2614 )
2615)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002616
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002617AC_MSG_CHECKING(for major, minor, and makedev)
Martin v. Löwise3271202002-11-07 07:42:30 +00002618AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002619#if defined(MAJOR_IN_MKDEV)
2620#include <sys/mkdev.h>
2621#elif defined(MAJOR_IN_SYSMACROS)
2622#include <sys/sysmacros.h>
2623#else
2624#include <sys/types.h>
2625#endif
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002626],[
2627 makedev(major(0),minor(0));
2628],[
2629 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2630 [Define to 1 if you have the device macros.])
2631 AC_MSG_RESULT(yes)
2632],[
2633 AC_MSG_RESULT(no)
2634])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002635
2636# On OSF/1 V5.1, getaddrinfo is available, but a define
2637# for [no]getaddrinfo in netdb.h.
2638AC_MSG_CHECKING(for getaddrinfo)
2639AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002640#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002641#include <sys/socket.h>
2642#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002643#include <stdio.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002644],[
2645getaddrinfo(NULL, NULL, NULL, NULL);
2646], [
2647AC_MSG_RESULT(yes)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002648AC_MSG_CHECKING(getaddrinfo bug)
2649AC_TRY_RUN([
2650#include <sys/types.h>
2651#include <netdb.h>
2652#include <string.h>
2653#include <sys/socket.h>
2654#include <netinet/in.h>
2655
2656main()
2657{
2658 int passive, gaierr, inet4 = 0, inet6 = 0;
2659 struct addrinfo hints, *ai, *aitop;
2660 char straddr[INET6_ADDRSTRLEN], strport[16];
2661
2662 for (passive = 0; passive <= 1; passive++) {
2663 memset(&hints, 0, sizeof(hints));
2664 hints.ai_family = AF_UNSPEC;
2665 hints.ai_flags = passive ? AI_PASSIVE : 0;
2666 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002667 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002668 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2669 (void)gai_strerror(gaierr);
2670 goto bad;
2671 }
2672 for (ai = aitop; ai; ai = ai->ai_next) {
2673 if (ai->ai_addr == NULL ||
2674 ai->ai_addrlen == 0 ||
2675 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2676 straddr, sizeof(straddr), strport, sizeof(strport),
2677 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2678 goto bad;
2679 }
2680 switch (ai->ai_family) {
2681 case AF_INET:
2682 if (strcmp(strport, "54321") != 0) {
2683 goto bad;
2684 }
2685 if (passive) {
2686 if (strcmp(straddr, "0.0.0.0") != 0) {
2687 goto bad;
2688 }
2689 } else {
2690 if (strcmp(straddr, "127.0.0.1") != 0) {
2691 goto bad;
2692 }
2693 }
2694 inet4++;
2695 break;
2696 case AF_INET6:
2697 if (strcmp(strport, "54321") != 0) {
2698 goto bad;
2699 }
2700 if (passive) {
2701 if (strcmp(straddr, "::") != 0) {
2702 goto bad;
2703 }
2704 } else {
2705 if (strcmp(straddr, "::1") != 0) {
2706 goto bad;
2707 }
2708 }
2709 inet6++;
2710 break;
2711 case AF_UNSPEC:
2712 goto bad;
2713 break;
2714 default:
2715 /* another family support? */
2716 break;
2717 }
2718 }
2719 }
2720
2721 if (!(inet4 == 0 || inet4 == 2))
2722 goto bad;
2723 if (!(inet6 == 0 || inet6 == 2))
2724 goto bad;
2725
2726 if (aitop)
2727 freeaddrinfo(aitop);
2728 exit(0);
2729
2730 bad:
2731 if (aitop)
2732 freeaddrinfo(aitop);
2733 exit(1);
2734}
2735],
2736AC_MSG_RESULT(good)
2737buggygetaddrinfo=no,
2738AC_MSG_RESULT(buggy)
2739buggygetaddrinfo=yes,
2740AC_MSG_RESULT(buggy)
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002741buggygetaddrinfo=yes)], [
2742AC_MSG_RESULT(no)
2743buggygetaddrinfo=yes
2744])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002745
2746if test "$buggygetaddrinfo" = "yes"; then
2747 if test "$ipv6" = "yes"; then
2748 echo 'Fatal: You must get working getaddrinfo() function.'
2749 echo ' or you can specify "--disable-ipv6"'.
2750 exit 1
2751 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002752else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002753 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002754fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00002755AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002756
Guido van Rossum627b2d71993-12-24 10:39:16 +00002757# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002758AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00002759AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002760AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00002761AC_CHECK_MEMBERS([struct stat.st_rdev])
2762AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00002763AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00002764AC_CHECK_MEMBERS([struct stat.st_gen])
2765AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00002766AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002767
2768AC_MSG_CHECKING(for time.h that defines altzone)
2769AC_CACHE_VAL(ac_cv_header_time_altzone,
2770[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2771 ac_cv_header_time_altzone=yes,
2772 ac_cv_header_time_altzone=no)])
2773AC_MSG_RESULT($ac_cv_header_time_altzone)
2774if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002775 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002776fi
2777
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002778was_it_defined=no
2779AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002780AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002781#include <sys/types.h>
2782#include <sys/select.h>
2783#include <sys/time.h>
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002784], [;], [
2785 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2786 [Define if you can safely include both <sys/select.h> and <sys/time.h>
2787 (which you can't on SCO ODT 3.0).])
2788 was_it_defined=yes
2789])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002790AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002791
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002792AC_MSG_CHECKING(for addrinfo)
2793AC_CACHE_VAL(ac_cv_struct_addrinfo,
2794AC_TRY_COMPILE([
2795# include <netdb.h>],
2796 [struct addrinfo a],
2797 ac_cv_struct_addrinfo=yes,
2798 ac_cv_struct_addrinfo=no))
2799AC_MSG_RESULT($ac_cv_struct_addrinfo)
2800if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002801 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002802fi
2803
2804AC_MSG_CHECKING(for sockaddr_storage)
2805AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2806AC_TRY_COMPILE([
2807# include <sys/types.h>
2808# include <sys/socket.h>],
2809 [struct sockaddr_storage s],
2810 ac_cv_struct_sockaddr_storage=yes,
2811 ac_cv_struct_sockaddr_storage=no))
2812AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2813if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002814 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002815fi
2816
Guido van Rossum627b2d71993-12-24 10:39:16 +00002817# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002818
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002819AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002820AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002821
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002822works=no
2823AC_MSG_CHECKING(for working volatile)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002824AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
2825 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
2826)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002827AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00002828
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002829works=no
2830AC_MSG_CHECKING(for working signed char)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002831AC_TRY_COMPILE([], [signed char c;], works=yes,
2832 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
2833)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002834AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002835
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002836have_prototypes=no
2837AC_MSG_CHECKING(for prototypes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002838AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
2839 AC_DEFINE(HAVE_PROTOTYPES, 1,
2840 [Define if your compiler supports function prototype])
2841 have_prototypes=yes
2842])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002843AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002844
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002845works=no
2846AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002847AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002848#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00002849int foo(int x, ...) {
2850 va_list va;
2851 va_start(va, x);
2852 va_arg(va, int);
2853 va_arg(va, char *);
2854 va_arg(va, double);
2855 return 0;
2856}
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002857], [return foo(10, "", 3.14);], [
2858 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
2859 [Define if your compiler supports variable length function prototypes
2860 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
2861 works=yes
2862])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002863AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002864
Dave Cole331708b2004-08-09 04:51:41 +00002865# check for socketpair
2866AC_MSG_CHECKING(for socketpair)
2867AC_TRY_COMPILE([
2868#include <sys/types.h>
2869#include <sys/socket.h>
2870], void *x=socketpair,
2871 AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
2872 AC_MSG_RESULT(yes),
2873 AC_MSG_RESULT(no)
2874)
2875
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002876# check if sockaddr has sa_len member
2877AC_MSG_CHECKING(if sockaddr has sa_len member)
2878AC_TRY_COMPILE([#include <sys/types.h>
2879#include <sys/socket.h>],
2880[struct sockaddr x;
2881x.sa_len = 0;],
2882 AC_MSG_RESULT(yes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002883 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002884 AC_MSG_RESULT(no))
2885
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002886va_list_is_array=no
2887AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002888AC_TRY_COMPILE([
2889#ifdef HAVE_STDARG_PROTOTYPES
2890#include <stdarg.h>
2891#else
2892#include <varargs.h>
2893#endif
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002894], [va_list list1, list2; list1 = list2;], , [
2895 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
2896 va_list_is_array=yes
2897])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002898AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002899
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00002900# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00002901AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
2902 [Define this if you have some version of gethostbyname_r()])
2903
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00002904AC_CHECK_FUNC(gethostbyname_r, [
2905 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2906 AC_MSG_CHECKING([gethostbyname_r with 6 args])
2907 OLD_CFLAGS=$CFLAGS
2908 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
2909 AC_TRY_COMPILE([
2910# include <netdb.h>
2911 ], [
2912 char *name;
2913 struct hostent *he, *res;
2914 char buffer[2048];
2915 int buflen = 2048;
2916 int h_errnop;
2917
2918 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
2919 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00002920 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002921 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
2922 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00002923 AC_MSG_RESULT(yes)
2924 ], [
2925 AC_MSG_RESULT(no)
2926 AC_MSG_CHECKING([gethostbyname_r with 5 args])
2927 AC_TRY_COMPILE([
2928# include <netdb.h>
2929 ], [
2930 char *name;
2931 struct hostent *he;
2932 char buffer[2048];
2933 int buflen = 2048;
2934 int h_errnop;
2935
2936 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
2937 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00002938 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002939 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
2940 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00002941 AC_MSG_RESULT(yes)
2942 ], [
2943 AC_MSG_RESULT(no)
2944 AC_MSG_CHECKING([gethostbyname_r with 3 args])
2945 AC_TRY_COMPILE([
2946# include <netdb.h>
2947 ], [
2948 char *name;
2949 struct hostent *he;
2950 struct hostent_data data;
2951
2952 (void) gethostbyname_r(name, he, &data);
2953 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00002954 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002955 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
2956 [Define this if you have the 3-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00002957 AC_MSG_RESULT(yes)
2958 ], [
2959 AC_MSG_RESULT(no)
2960 ])
2961 ])
2962 ])
2963 CFLAGS=$OLD_CFLAGS
2964], [
Thomas Wouters3a584202000-08-05 23:28:51 +00002965 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00002966])
2967AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
2968AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
2969AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00002970AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00002971AC_SUBST(HAVE_GETHOSTBYNAME)
2972
Guido van Rossum627b2d71993-12-24 10:39:16 +00002973# checks for system services
2974# (none yet)
2975
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002976# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00002977AC_CHECK_FUNC(__fpu_control,
2978 [],
2979 [AC_CHECK_LIB(ieee, __fpu_control)
2980])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002981
Guido van Rossum93274221997-05-09 02:42:00 +00002982# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00002983AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002984AC_ARG_WITH(fpectl,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002985 AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
2986[
Guido van Rossum93274221997-05-09 02:42:00 +00002987if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002988then
2989 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
2990 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
2991 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00002992else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00002993fi],
2994[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00002995
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002996# check for --with-libm=...
2997AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00002998case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00002999Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003000*) LIBM=-lm
3001esac
Guido van Rossum93274221997-05-09 02:42:00 +00003002AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003003AC_ARG_WITH(libm,
3004 AC_HELP_STRING(--with-libm=STRING, math library),
3005[
Guido van Rossum93274221997-05-09 02:42:00 +00003006if test "$withval" = no
3007then LIBM=
3008 AC_MSG_RESULT(force LIBM empty)
3009elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003010then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003011 AC_MSG_RESULT(set LIBM="$withval")
3012else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003013fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003014[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003015
3016# check for --with-libc=...
3017AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003018AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003019AC_ARG_WITH(libc,
3020 AC_HELP_STRING(--with-libc=STRING, C library),
3021[
Guido van Rossum93274221997-05-09 02:42:00 +00003022if test "$withval" = no
3023then LIBC=
3024 AC_MSG_RESULT(force LIBC empty)
3025elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003026then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003027 AC_MSG_RESULT(set LIBC="$withval")
3028else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003029fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003030[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003031
Christian Heimes99170a52007-12-19 02:07:34 +00003032# ************************************
3033# * Check for mathematical functions *
3034# ************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003035
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003036LIBS_SAVE=$LIBS
3037LIBS="$LIBS $LIBM"
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003038
3039# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3040# -0. on some architectures.
3041AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3042AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3043AC_TRY_RUN([
3044#include <math.h>
3045#include <stdlib.h>
3046int main() {
3047 /* return 0 if either negative zeros don't exist
3048 on this platform or if negative zeros exist
3049 and tanh(-0.) == -0. */
3050 if (atan2(0., -1.) == atan2(-0., -1.) ||
3051 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3052 else exit(1);
3053}
3054],
3055ac_cv_tanh_preserves_zero_sign=yes,
3056ac_cv_tanh_preserves_zero_sign=no,
3057ac_cv_tanh_preserves_zero_sign=no)])
3058AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3059if test "$ac_cv_tanh_preserves_zero_sign" = yes
3060then
3061 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3062 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3063fi
3064
Guido van Rossumf2f7eb31996-08-30 15:18:00 +00003065AC_REPLACE_FUNCS(hypot)
Christian Heimes99170a52007-12-19 02:07:34 +00003066
Christian Heimes9bd667a2008-01-20 15:14:11 +00003067AC_CHECK_FUNCS(acosh asinh atanh copysign expm1 finite isinf isnan log1p)
Christian Heimes99170a52007-12-19 02:07:34 +00003068
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003069LIBS=$LIBS_SAVE
3070
Guido van Rossumef2255b2000-03-10 22:30:29 +00003071# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003072AC_CHECK_HEADER(wchar.h, [
3073 AC_DEFINE(HAVE_WCHAR_H, 1,
3074 [Define if the compiler provides a wchar.h header file.])
3075 wchar_h="yes"
3076],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003077wchar_h="no"
3078)
3079
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003080# determine wchar_t size
3081if test "$wchar_h" = yes
3082then
Guido van Rossum67b26592001-10-20 14:21:45 +00003083 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003084fi
3085
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003086AC_MSG_CHECKING(for UCS-4 tcl)
3087have_ucs4_tcl=no
3088AC_TRY_COMPILE([
3089#include <tcl.h>
3090#if TCL_UTF_MAX != 6
3091# error "NOT UCS4_TCL"
3092#endif], [], [
3093 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3094 have_ucs4_tcl=yes
3095])
3096AC_MSG_RESULT($have_ucs4_tcl)
3097
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003098# check whether wchar_t is signed or not
3099if test "$wchar_h" = yes
3100then
3101 # check whether wchar_t is signed or not
3102 AC_MSG_CHECKING(whether wchar_t is signed)
3103 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3104 AC_TRY_RUN([
3105 #include <wchar.h>
3106 int main()
3107 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003108 /* Success: exit code 0 */
3109 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003110 }
3111 ],
3112 ac_cv_wchar_t_signed=yes,
3113 ac_cv_wchar_t_signed=no,
3114 ac_cv_wchar_t_signed=yes)])
3115 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3116fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003117
Georg Brandl52d168a2008-01-07 18:10:24 +00003118AC_MSG_CHECKING(what type to use for str)
3119AC_ARG_WITH(wide-unicode,
3120 AC_HELP_STRING(--with-wide-unicode, Use 4-byte Unicode characters (default is 2 bytes)),
3121[
3122if test "$withval" != no
3123then unicode_size="4"
3124else unicode_size="2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003125fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003126],
3127[
3128case "$have_ucs4_tcl" in
3129 yes) unicode_size="4" ;;
3130 *) unicode_size="2" ;;
3131esac
3132])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003133
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003134AH_TEMPLATE(Py_UNICODE_SIZE,
3135 [Define as the size of the unicode type.])
Georg Brandl52d168a2008-01-07 18:10:24 +00003136case "$unicode_size" in
3137 4) AC_DEFINE(Py_UNICODE_SIZE, 4) ;;
3138 *) AC_DEFINE(Py_UNICODE_SIZE, 2) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003139esac
3140
Martin v. Löwis11437992002-04-12 09:54:03 +00003141AH_TEMPLATE(PY_UNICODE_TYPE,
3142 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003143
Georg Brandl52d168a2008-01-07 18:10:24 +00003144# wchar_t is only usable if it maps to an unsigned type
3145if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003146 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00003147then
3148 PY_UNICODE_TYPE="wchar_t"
3149 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3150 [Define if you have a useable wchar_t type defined in wchar.h; useable
3151 means wchar_t must be an unsigned type with at least 16 bits. (see
3152 Include/unicodeobject.h).])
3153 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3154elif test "$ac_cv_sizeof_short" = "$unicode_size"
3155then
3156 PY_UNICODE_TYPE="unsigned short"
3157 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3158elif test "$ac_cv_sizeof_long" = "$unicode_size"
3159then
3160 PY_UNICODE_TYPE="unsigned long"
3161 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3162else
3163 PY_UNICODE_TYPE="no type found"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003164fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003165AC_MSG_RESULT($PY_UNICODE_TYPE)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003166
3167# check for endianness
3168AC_C_BIGENDIAN
3169
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003170# Check whether right shifting a negative integer extends the sign bit
3171# or fills with zeros (like the Cray J90, according to Tim Peters).
3172AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003173AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003174AC_TRY_RUN([
3175int main()
3176{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003177 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003178}
Guido van Rossum3065c942001-09-17 04:03:14 +00003179],
3180ac_cv_rshift_extends_sign=yes,
3181ac_cv_rshift_extends_sign=no,
3182ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003183AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3184if test "$ac_cv_rshift_extends_sign" = no
3185then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003186 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3187 [Define if i>>j for signed int i does not extend the sign bit
3188 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003189fi
3190
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003191# check for getc_unlocked and related locking functions
3192AC_MSG_CHECKING(for getc_unlocked() and friends)
3193AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3194AC_TRY_LINK([#include <stdio.h>],[
3195 FILE *f = fopen("/dev/null", "r");
3196 flockfile(f);
3197 getc_unlocked(f);
3198 funlockfile(f);
3199], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3200AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3201if test "$ac_cv_have_getc_unlocked" = yes
3202then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003203 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3204 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003205fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003206
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003207# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003208# save the value of LIBS so we don't actually link Python with readline
3209LIBS_no_readline=$LIBS
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003210AC_CHECK_LIB(readline, readline)
3211if test "$ac_cv_have_readline_readline" = no
3212then
3213 AC_CHECK_LIB(termcap, readline)
3214fi
3215
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003216# check for readline 2.1
3217AC_CHECK_LIB(readline, rl_callback_handler_install,
3218 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003219 [Define if you have readline 2.1]), , )
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003220
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003221# check for readline 2.2
3222AC_TRY_CPP([#include <readline/readline.h>],
3223have_readline=yes, have_readline=no)
3224if test $have_readline = yes
3225then
3226 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3227 [readline/readline.h],
3228 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3229 [Define if you have readline 2.2]), )
3230fi
3231
Martin v. Löwis0daad592001-09-30 21:09:59 +00003232# check for readline 4.0
3233AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003234 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003235 [Define if you have readline 4.0]), , )
Martin v. Löwis0daad592001-09-30 21:09:59 +00003236
Thomas Wouters89d996e2007-09-08 17:39:28 +00003237# also in 4.0
3238AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3239 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
3240 [Define if you have readline 4.0]), , )
3241
Guido van Rossum353ae582001-07-10 16:45:32 +00003242# check for readline 4.2
3243AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003244 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003245 [Define if you have readline 4.2]), , )
Guido van Rossum353ae582001-07-10 16:45:32 +00003246
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003247# also in readline 4.2
3248AC_TRY_CPP([#include <readline/readline.h>],
3249have_readline=yes, have_readline=no)
3250if test $have_readline = yes
3251then
3252 AC_EGREP_HEADER([extern int rl_catch_signals;],
3253 [readline/readline.h],
3254 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3255 [Define if you can turn off readline's signal handling.]), )
3256fi
3257
Martin v. Löwis82bca632006-02-10 20:49:30 +00003258# End of readline checks: restore LIBS
3259LIBS=$LIBS_no_readline
3260
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003261AC_MSG_CHECKING(for broken nice())
3262AC_CACHE_VAL(ac_cv_broken_nice, [
3263AC_TRY_RUN([
3264int main()
3265{
3266 int val1 = nice(1);
3267 if (val1 != -1 && val1 == nice(2))
3268 exit(0);
3269 exit(1);
3270}
Guido van Rossum3065c942001-09-17 04:03:14 +00003271],
3272ac_cv_broken_nice=yes,
3273ac_cv_broken_nice=no,
3274ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003275AC_MSG_RESULT($ac_cv_broken_nice)
3276if test "$ac_cv_broken_nice" = yes
3277then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003278 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3279 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003280fi
3281
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003282AC_MSG_CHECKING(for broken poll())
3283AC_TRY_RUN([
3284#include <poll.h>
3285
3286int main (void)
3287 {
3288 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
3289
3290 close (42);
3291
3292 int poll_test = poll (&poll_struct, 1, 0);
3293
3294 if (poll_test < 0)
3295 {
3296 exit(0);
3297 }
3298 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
3299 {
3300 exit(0);
3301 }
3302 else
3303 {
3304 exit(1);
3305 }
3306 }
3307],
3308ac_cv_broken_poll=yes,
3309ac_cv_broken_poll=no,
3310ac_cv_broken_poll=no)
3311AC_MSG_RESULT($ac_cv_broken_poll)
3312if test "$ac_cv_broken_poll" = yes
3313then
3314 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3315 [Define if poll() sets errno on invalid file descriptors.])
3316fi
3317
Brett Cannon43802422005-02-10 20:48:03 +00003318# Before we can test tzset, we need to check if struct tm has a tm_zone
3319# (which is not required by ISO C or UNIX spec) and/or if we support
3320# tzname[]
3321AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003322
Brett Cannon43802422005-02-10 20:48:03 +00003323# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003324AC_MSG_CHECKING(for working tzset())
3325AC_CACHE_VAL(ac_cv_working_tzset, [
3326AC_TRY_RUN([
3327#include <stdlib.h>
3328#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003329#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003330
3331#if HAVE_TZNAME
3332extern char *tzname[];
3333#endif
3334
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003335int main()
3336{
Brett Cannon18367812003-09-19 00:59:16 +00003337 /* Note that we need to ensure that not only does tzset(3)
3338 do 'something' with localtime, but it works as documented
3339 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003340 This includes making sure that tzname is set properly if
3341 tm->tm_zone does not exist since it is the alternative way
3342 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003343
3344 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003345 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003346 */
3347
Brett Cannon43802422005-02-10 20:48:03 +00003348 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003349 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3350
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003351 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003352 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003353 if (localtime(&groundhogday)->tm_hour != 0)
3354 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003355#if HAVE_TZNAME
3356 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3357 if (strcmp(tzname[0], "UTC") ||
3358 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3359 exit(1);
3360#endif
Brett Cannon18367812003-09-19 00:59:16 +00003361
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003362 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003363 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003364 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003365 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003366#if HAVE_TZNAME
3367 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3368 exit(1);
3369#endif
Brett Cannon18367812003-09-19 00:59:16 +00003370
3371 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3372 tzset();
3373 if (localtime(&groundhogday)->tm_hour != 11)
3374 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003375#if HAVE_TZNAME
3376 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3377 exit(1);
3378#endif
3379
3380#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00003381 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3382 exit(1);
3383 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3384 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003385#endif
Brett Cannon18367812003-09-19 00:59:16 +00003386
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003387 exit(0);
3388}
3389],
3390ac_cv_working_tzset=yes,
3391ac_cv_working_tzset=no,
3392ac_cv_working_tzset=no)])
3393AC_MSG_RESULT($ac_cv_working_tzset)
3394if test "$ac_cv_working_tzset" = yes
3395then
3396 AC_DEFINE(HAVE_WORKING_TZSET, 1,
3397 [Define if tzset() actually switches the local timezone in a meaningful way.])
3398fi
3399
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003400# Look for subsecond timestamps in struct stat
3401AC_MSG_CHECKING(for tv_nsec in struct stat)
3402AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3403AC_TRY_COMPILE([#include <sys/stat.h>], [
3404struct stat st;
3405st.st_mtim.tv_nsec = 1;
3406],
Martin v. Löwisa32c9942002-09-09 16:17:47 +00003407ac_cv_stat_tv_nsec=yes,
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003408ac_cv_stat_tv_nsec=no,
3409ac_cv_stat_tv_nsec=no))
3410AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3411if test "$ac_cv_stat_tv_nsec" = yes
3412then
3413 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3414 [Define if you have struct stat.st_mtim.tv_nsec])
3415fi
3416
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003417# Look for BSD style subsecond timestamps in struct stat
3418AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3419AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3420AC_TRY_COMPILE([#include <sys/stat.h>], [
3421struct stat st;
3422st.st_mtimespec.tv_nsec = 1;
3423],
3424ac_cv_stat_tv_nsec2=yes,
3425ac_cv_stat_tv_nsec2=no,
3426ac_cv_stat_tv_nsec2=no))
3427AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3428if test "$ac_cv_stat_tv_nsec2" = yes
3429then
3430 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3431 [Define if you have struct stat.st_mtimensec])
3432fi
3433
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003434# On HP/UX 11.0, mvwdelch is a block with a return statement
3435AC_MSG_CHECKING(whether mvwdelch is an expression)
3436AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3437AC_TRY_COMPILE([#include <curses.h>], [
3438 int rtn;
3439 rtn = mvwdelch(0,0,0);
3440], ac_cv_mvwdelch_is_expression=yes,
3441 ac_cv_mvwdelch_is_expression=no,
3442 ac_cv_mvwdelch_is_expression=yes))
3443AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3444
3445if test "$ac_cv_mvwdelch_is_expression" = yes
3446then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003447 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3448 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003449fi
3450
3451AC_MSG_CHECKING(whether WINDOW has _flags)
3452AC_CACHE_VAL(ac_cv_window_has_flags,
3453AC_TRY_COMPILE([#include <curses.h>], [
3454 WINDOW *w;
3455 w->_flags = 0;
3456], ac_cv_window_has_flags=yes,
3457 ac_cv_window_has_flags=no,
3458 ac_cv_window_has_flags=no))
3459AC_MSG_RESULT($ac_cv_window_has_flags)
3460
3461
3462if test "$ac_cv_window_has_flags" = yes
3463then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003464 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
3465 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003466fi
3467
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003468AC_MSG_CHECKING(for is_term_resized)
3469AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
3470 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
3471 AC_MSG_RESULT(yes),
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003472 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003473)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003474
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003475AC_MSG_CHECKING(for resize_term)
3476AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
3477 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
3478 AC_MSG_RESULT(yes),
Neal Norwitz865400f2003-03-21 01:42:58 +00003479 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003480)
3481
3482AC_MSG_CHECKING(for resizeterm)
3483AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
3484 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
3485 AC_MSG_RESULT(yes),
3486 AC_MSG_RESULT(no)
3487)
3488
Thomas Wouters89f507f2006-12-13 04:49:30 +00003489AC_MSG_CHECKING(for /dev/ptmx)
3490
3491if test -r /dev/ptmx
3492then
3493 AC_MSG_RESULT(yes)
3494 AC_DEFINE(HAVE_DEV_PTMX, 1,
3495 [Define if we have /dev/ptmx.])
3496else
3497 AC_MSG_RESULT(no)
3498fi
3499
3500AC_MSG_CHECKING(for /dev/ptc)
3501
3502if test -r /dev/ptc
3503then
3504 AC_MSG_RESULT(yes)
3505 AC_DEFINE(HAVE_DEV_PTC, 1,
3506 [Define if we have /dev/ptc.])
3507else
3508 AC_MSG_RESULT(no)
3509fi
Neal Norwitz865400f2003-03-21 01:42:58 +00003510
Thomas Wouters477c8d52006-05-27 19:21:47 +00003511AC_MSG_CHECKING(for %zd printf() format support)
3512AC_TRY_RUN([#include <stdio.h>
3513#include <stddef.h>
3514#include <string.h>
3515
Christian Heimes2c181612007-12-17 20:04:13 +00003516#ifdef HAVE_SYS_TYPES_H
3517#include <sys/types.h>
3518#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00003519
3520#ifdef HAVE_SSIZE_T
3521typedef ssize_t Py_ssize_t;
3522#elif SIZEOF_VOID_P == SIZEOF_LONG
3523typedef long Py_ssize_t;
3524#else
3525typedef int Py_ssize_t;
3526#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00003527
Christian Heimes2c181612007-12-17 20:04:13 +00003528int main()
3529{
3530 char buffer[256];
3531
Thomas Wouters477c8d52006-05-27 19:21:47 +00003532 if(sprintf(buffer, "%zd", (size_t)123) < 0)
3533 return 1;
3534
Thomas Wouters89f507f2006-12-13 04:49:30 +00003535 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00003536 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00003537
3538 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
3539 return 1;
3540
3541 if (strcmp(buffer, "-123"))
3542 return 1;
3543
Thomas Wouters477c8d52006-05-27 19:21:47 +00003544 return 0;
3545}],
3546[AC_MSG_RESULT(yes)
3547 AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
3548 AC_MSG_RESULT(no))
3549
Martin v. Löwis01c04012002-11-11 14:58:44 +00003550AC_CHECK_TYPE(socklen_t,,
3551 AC_DEFINE(socklen_t,int,
3552 Define to `int' if <sys/socket.h> does not define.),[
3553#ifdef HAVE_SYS_TYPES_H
3554#include <sys/types.h>
3555#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00003556#ifdef HAVE_SYS_SOCKET_H
3557#include <sys/socket.h>
3558#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00003559])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003560
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00003561AC_SUBST(THREADHEADERS)
3562
3563for h in `(cd $srcdir;echo Python/thread_*.h)`
3564do
3565 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
3566done
3567
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003568AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00003569SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00003570AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003571for dir in $SRCDIRS; do
3572 if test ! -d $dir; then
3573 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00003574 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003575done
3576AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00003577
Guido van Rossum627b2d71993-12-24 10:39:16 +00003578# generate output files
Martin v. Löwis88afe662002-10-26 13:47:44 +00003579AC_CONFIG_FILES(Makefile.pre Modules/Setup.config)
3580AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00003581
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003582echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00003583if test ! -f Modules/Setup
3584then
3585 cp $srcdir/Modules/Setup.dist Modules/Setup
3586fi
3587
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003588echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00003589if test ! -f Modules/Setup.local
3590then
3591 echo "# Edit this file for local setup changes" >Modules/Setup.local
3592fi
3593
3594echo "creating Makefile"
3595$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
3596 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00003597 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00003598mv config.c Modules