blob: 871592aba049e2ff96fb0c937a85b83b61acfa1d [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}"
Thomas Wouters477c8d52006-05-27 19:21:47 +0000876 fi
877
Skip Montanarodecc6a42003-01-01 20:07:49 +0000878 ;;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000879 OSF*)
880 BASECFLAGS="$BASECFLAGS -mieee"
881 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000882 esac
883 ;;
884
885*)
886 case $ac_sys_system in
887 OpenUNIX*|UnixWare*)
888 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
889 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +0000890 OSF*)
891 BASECFLAGS="$BASECFLAGS -ieee -std"
892 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000893 SCO_SV*)
894 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
895 ;;
896 esac
897 ;;
898esac
899
Fred Drakee1ceaa02001-12-04 20:55:47 +0000900if test "$Py_DEBUG" = 'true'; then
901 :
902else
903 OPT="-DNDEBUG $OPT"
904fi
905
Guido van Rossum6f2260e1996-09-09 16:21:03 +0000906if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +0000907then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000908 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +0000909fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000910
Neal Norwitz020c46a2006-01-07 21:39:28 +0000911# disable check for icc since it seems to pass, but generates a warning
912if test "$CC" = icc
913then
914 ac_cv_opt_olimit_ok=no
915fi
916
Guido van Rossum91922671997-10-09 20:24:13 +0000917AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
918AC_CACHE_VAL(ac_cv_opt_olimit_ok,
919[ac_save_cc="$CC"
920CC="$CC -OPT:Olimit=0"
921AC_TRY_RUN([int main() { return 0; }],
922 ac_cv_opt_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +0000923 ac_cv_opt_olimit_ok=no,
Guido van Rossum91922671997-10-09 20:24:13 +0000924 ac_cv_opt_olimit_ok=no)
925CC="$ac_save_cc"])
926AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +0000927if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +0000928 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000929 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
930 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
931 # environment?
932 Darwin*)
933 ;;
934 *)
935 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
936 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +0000937 esac
Guido van Rossumf8678121998-07-07 21:05:09 +0000938else
939 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
940 AC_CACHE_VAL(ac_cv_olimit_ok,
941 [ac_save_cc="$CC"
942 CC="$CC -Olimit 1500"
943 AC_TRY_RUN([int main() { return 0; }],
944 ac_cv_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +0000945 ac_cv_olimit_ok=no,
Guido van Rossumf8678121998-07-07 21:05:09 +0000946 ac_cv_olimit_ok=no)
947 CC="$ac_save_cc"])
948 AC_MSG_RESULT($ac_cv_olimit_ok)
949 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000950 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +0000951 fi
Guido van Rossum201afe51997-05-14 21:14:44 +0000952fi
Guido van Rossumf8678121998-07-07 21:05:09 +0000953
Thomas Wouters89f507f2006-12-13 04:49:30 +0000954# Check whether GCC supports PyArg_ParseTuple format
955if test "$GCC" = "yes"
956then
957 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
958 save_CFLAGS=$CFLAGS
959 CFLAGS="$CFLAGS -Werror"
960 AC_TRY_COMPILE([
961 void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
962 ],,
963 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
964 AC_MSG_RESULT(yes),
965 AC_MSG_RESULT(no)
966 )
967 CFLAGS=$save_CFLAGS
968fi
969
Martin v. Löwisa5f73f92001-10-15 08:06:29 +0000970# On some compilers, pthreads are available without further options
971# (e.g. MacOS X). On some of these systems, the compiler will not
972# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
973# So we have to see first whether pthreads are available without
974# options before we can check whether -Kpthread improves anything.
975AC_MSG_CHECKING(whether pthreads are available without options)
976AC_CACHE_VAL(ac_cv_pthread_is_default,
977[AC_TRY_RUN([
978#include <pthread.h>
979
980void* routine(void* p){return NULL;}
981
982int main(){
983 pthread_t p;
984 if(pthread_create(&p,NULL,routine,NULL)!=0)
985 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +0000986 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +0000987 return 0;
988}
989],
Skip Montanarod8d39a02003-07-10 20:44:10 +0000990[
991 ac_cv_pthread_is_default=yes
992 ac_cv_kthread=no
993 ac_cv_pthread=no
994],
Martin v. Löwisa5f73f92001-10-15 08:06:29 +0000995 ac_cv_pthread_is_default=no,
996 ac_cv_pthread_is_default=no)
997])
998AC_MSG_RESULT($ac_cv_pthread_is_default)
999
1000
1001if test $ac_cv_pthread_is_default = yes
1002then
1003 ac_cv_kpthread=no
1004else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001005# -Kpthread, if available, provides the right #defines
1006# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001007# Some compilers won't report that they do not support -Kpthread,
1008# so we need to run a program to see whether it really made the
1009# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001010AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1011AC_CACHE_VAL(ac_cv_kpthread,
1012[ac_save_cc="$CC"
1013CC="$CC -Kpthread"
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001014AC_TRY_RUN([
1015#include <pthread.h>
1016
1017void* routine(void* p){return NULL;}
1018
1019int main(){
1020 pthread_t p;
1021 if(pthread_create(&p,NULL,routine,NULL)!=0)
1022 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001023 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001024 return 0;
1025}
1026],
Martin v. Löwis130fb172001-07-19 11:00:41 +00001027 ac_cv_kpthread=yes,
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001028 ac_cv_kpthread=no,
Martin v. Löwis130fb172001-07-19 11:00:41 +00001029 ac_cv_kpthread=no)
1030CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001031AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001032fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001033
Skip Montanarod8d39a02003-07-10 20:44:10 +00001034if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001035then
1036# -Kthread, if available, provides the right #defines
1037# and linker options to make pthread_create available
1038# Some compilers won't report that they do not support -Kthread,
1039# so we need to run a program to see whether it really made the
1040# function available.
1041AC_MSG_CHECKING(whether $CC accepts -Kthread)
1042AC_CACHE_VAL(ac_cv_kthread,
1043[ac_save_cc="$CC"
1044CC="$CC -Kthread"
1045AC_TRY_RUN([
1046#include <pthread.h>
1047
1048void* routine(void* p){return NULL;}
1049
1050int main(){
1051 pthread_t p;
1052 if(pthread_create(&p,NULL,routine,NULL)!=0)
1053 return 1;
1054 (void)pthread_detach(p);
1055 return 0;
1056}
1057],
1058 ac_cv_kthread=yes,
1059 ac_cv_kthread=no,
1060 ac_cv_kthread=no)
1061CC="$ac_save_cc"])
1062AC_MSG_RESULT($ac_cv_kthread)
1063fi
1064
Skip Montanarod8d39a02003-07-10 20:44:10 +00001065if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001066then
1067# -pthread, if available, provides the right #defines
1068# and linker options to make pthread_create available
1069# Some compilers won't report that they do not support -pthread,
1070# so we need to run a program to see whether it really made the
1071# function available.
1072AC_MSG_CHECKING(whether $CC accepts -pthread)
1073AC_CACHE_VAL(ac_cv_thread,
1074[ac_save_cc="$CC"
1075CC="$CC -pthread"
1076AC_TRY_RUN([
1077#include <pthread.h>
1078
1079void* routine(void* p){return NULL;}
1080
1081int main(){
1082 pthread_t p;
1083 if(pthread_create(&p,NULL,routine,NULL)!=0)
1084 return 1;
1085 (void)pthread_detach(p);
1086 return 0;
1087}
1088],
1089 ac_cv_pthread=yes,
1090 ac_cv_pthread=no,
1091 ac_cv_pthread=no)
1092CC="$ac_save_cc"])
1093AC_MSG_RESULT($ac_cv_pthread)
1094fi
1095
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001096# If we have set a CC compiler flag for thread support then
1097# check if it works for CXX, too.
1098ac_cv_cxx_thread=no
1099if test ! -z "$CXX"
1100then
1101AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1102ac_save_cxx="$CXX"
1103
1104if test "$ac_cv_kpthread" = "yes"
1105then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001106 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001107 ac_cv_cxx_thread=yes
1108elif test "$ac_cv_kthread" = "yes"
1109then
1110 CXX="$CXX -Kthread"
1111 ac_cv_cxx_thread=yes
1112elif test "$ac_cv_pthread" = "yes"
1113then
1114 CXX="$CXX -pthread"
1115 ac_cv_cxx_thread=yes
1116fi
1117
1118if test $ac_cv_cxx_thread = yes
1119then
1120 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1121 $CXX -c conftest.$ac_ext 2>&5
1122 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1123 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1124 then
1125 ac_cv_cxx_thread=yes
1126 else
1127 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001128 fi
1129 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001130fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001131AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001132fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001133CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001134
Fred Drakece81d592000-07-09 14:39:29 +00001135dnl # check for ANSI or K&R ("traditional") preprocessor
1136dnl AC_MSG_CHECKING(for C preprocessor type)
1137dnl AC_TRY_COMPILE([
1138dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1139dnl int foo;
1140dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1141dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1142dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001143
Guido van Rossum627b2d71993-12-24 10:39:16 +00001144# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001145AC_HEADER_STDC
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001146AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1147fcntl.h grp.h \
Christian Heimesbbe741d2008-03-28 10:53:29 +00001148ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Thomas Wouters89f507f2006-12-13 04:49:30 +00001149shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001150unistd.h utime.h \
Christian Heimes4fbc72b2008-03-22 00:47:35 +00001151sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1152sys/lock.h sys/mkdev.h sys/modem.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001153sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Georg Brandlf78e02b2008-06-10 17:40:04 +00001154sys/termio.h sys/time.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001155sys/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 +00001156sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimes043d6f62008-01-07 17:19:16 +00001157bluetooth/bluetooth.h linux/tipc.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001158AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001159AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001160
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001161# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e72004-11-30 22:09:37 +00001162AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001163#ifdef HAVE_CURSES_H
1164#include <curses.h>
1165#endif
1166])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001167
Martin v. Löwis11017b12006-01-14 18:12:57 +00001168# On Linux, netlink.h requires asm/types.h
1169AC_CHECK_HEADERS(linux/netlink.h,,,[
1170#ifdef HAVE_ASM_TYPES_H
1171#include <asm/types.h>
1172#endif
1173#ifdef HAVE_SYS_SOCKET_H
1174#include <sys/socket.h>
1175#endif
1176])
1177
Guido van Rossum627b2d71993-12-24 10:39:16 +00001178# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001179was_it_defined=no
1180AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001181AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1182 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1183])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001184AC_MSG_RESULT($was_it_defined)
1185
Neal Norwitz11690112002-07-30 01:08:28 +00001186# Check whether using makedev requires defining _OSF_SOURCE
1187AC_MSG_CHECKING(for makedev)
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001188AC_TRY_LINK([#include <sys/types.h> ],
Neal Norwitz11690112002-07-30 01:08:28 +00001189 [ makedev(0, 0) ],
1190 ac_cv_has_makedev=yes,
1191 ac_cv_has_makedev=no)
1192if test "$ac_cv_has_makedev" = "no"; then
1193 # we didn't link, try if _OSF_SOURCE will allow us to link
1194 AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001195#define _OSF_SOURCE 1
1196#include <sys/types.h>
Neal Norwitz11690112002-07-30 01:08:28 +00001197 ],
1198 [ makedev(0, 0) ],
1199 ac_cv_has_makedev=yes,
1200 ac_cv_has_makedev=no)
1201 if test "$ac_cv_has_makedev" = "yes"; then
1202 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1203 fi
1204fi
1205AC_MSG_RESULT($ac_cv_has_makedev)
1206if test "$ac_cv_has_makedev" = "yes"; then
1207 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1208fi
1209
Martin v. Löwis399a6892002-10-04 10:22:02 +00001210# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1211# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1212# defined, but the compiler does not support pragma redefine_extname,
1213# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1214# structures (such as rlimit64) without declaring them. As a
1215# work-around, disable LFS on such configurations
1216
1217use_lfs=yes
1218AC_MSG_CHECKING(Solaris LFS bug)
1219AC_TRY_COMPILE([
1220#define _LARGEFILE_SOURCE 1
1221#define _FILE_OFFSET_BITS 64
1222#include <sys/resource.h>
1223],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1224AC_MSG_RESULT($sol_lfs_bug)
1225if test "$sol_lfs_bug" = "yes"; then
1226 use_lfs=no
1227fi
1228
1229if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001230# Two defines needed to enable largefile support on various platforms
1231# These may affect some typedefs
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001232AC_DEFINE(_LARGEFILE_SOURCE, 1,
1233[This must be defined on some systems to enable large file support.])
1234AC_DEFINE(_FILE_OFFSET_BITS, 64,
1235[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001236fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001237
Guido van Rossum300fda71996-08-19 21:58:16 +00001238# Add some code to confdefs.h so that the test for off_t works on SCO
1239cat >> confdefs.h <<\EOF
1240#if defined(SCO_DS)
1241#undef _OFF_T
1242#endif
1243EOF
1244
Guido van Rossumef2255b2000-03-10 22:30:29 +00001245# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001246AC_TYPE_MODE_T
1247AC_TYPE_OFF_T
1248AC_TYPE_PID_T
1249AC_TYPE_SIGNAL
1250AC_TYPE_SIZE_T
1251AC_TYPE_UID_T
Christian Heimes400adb02008-02-01 08:12:03 +00001252AC_CHECK_TYPE(ssize_t,
Martin v. Löwis18e16552006-02-15 17:27:45 +00001253 AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001254
Guido van Rossumef2255b2000-03-10 22:30:29 +00001255# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001256# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001257AC_CHECK_SIZEOF(int, 4)
1258AC_CHECK_SIZEOF(long, 4)
1259AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001260AC_CHECK_SIZEOF(short, 2)
1261AC_CHECK_SIZEOF(float, 4)
1262AC_CHECK_SIZEOF(double, 8)
1263AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001264AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes400adb02008-02-01 08:12:03 +00001265AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001266
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001267AC_MSG_CHECKING(for long long support)
1268have_long_long=no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001269AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1270 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1271 have_long_long=yes
1272])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001273AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001274if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001275AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001276fi
1277
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001278AC_MSG_CHECKING(for long double support)
1279have_long_double=no
1280AC_TRY_COMPILE([], [long double x; x = (long double)0;], [
1281 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1282 have_long_double=yes
1283])
1284AC_MSG_RESULT($have_long_double)
1285if test "$have_long_double" = yes ; then
1286AC_CHECK_SIZEOF(long double, 16)
1287fi
1288
1289
Thomas Woutersb2137042007-02-01 18:02:27 +00001290AC_MSG_CHECKING(for _Bool support)
1291have_c99_bool=no
1292AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1293 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1294 have_c99_bool=yes
1295])
1296AC_MSG_RESULT($have_c99_bool)
1297if test "$have_c99_bool" = yes ; then
1298AC_CHECK_SIZEOF(_Bool, 1)
1299fi
1300
Thomas Wouters89f507f2006-12-13 04:49:30 +00001301AC_CHECK_TYPES(uintptr_t,
1302 [AC_CHECK_SIZEOF(uintptr_t, 4)],
1303 [], [#ifdef HAVE_STDINT_H
1304 #include <stdint.h>
1305 #endif])
1306
Barry Warsawbc7c7f92000-08-18 04:53:33 +00001307
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001308# Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
1309AC_MSG_CHECKING(size of off_t)
1310AC_CACHE_VAL(ac_cv_sizeof_off_t,
1311[AC_TRY_RUN([#include <stdio.h>
1312#include <sys/types.h>
1313main()
1314{
1315 FILE *f=fopen("conftestval", "w");
1316 if (!f) exit(1);
1317 fprintf(f, "%d\n", sizeof(off_t));
1318 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001319}],
1320ac_cv_sizeof_off_t=`cat conftestval`,
1321ac_cv_sizeof_off_t=0,
1322ac_cv_sizeof_off_t=4)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001323])
1324AC_MSG_RESULT($ac_cv_sizeof_off_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001325AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t,
1326[The number of bytes in an off_t.])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001327
1328AC_MSG_CHECKING(whether to enable large file support)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001329if test "$have_long_long" = yes -a \
1330 "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
1331 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001332 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1333 [Defined to enable large file support when an off_t is bigger than a long
1334 and long long is available and at least as big as an off_t. You may need
1335 to add some flags for configuration and compilation to enable this mode.
1336 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001337 AC_MSG_RESULT(yes)
1338else
1339 AC_MSG_RESULT(no)
1340fi
1341
Fred Drakea3f6e912000-06-29 20:44:47 +00001342# AC_CHECK_SIZEOF() doesn't include <time.h>.
1343AC_MSG_CHECKING(size of time_t)
1344AC_CACHE_VAL(ac_cv_sizeof_time_t,
1345[AC_TRY_RUN([#include <stdio.h>
1346#include <time.h>
1347main()
1348{
1349 FILE *f=fopen("conftestval", "w");
1350 if (!f) exit(1);
1351 fprintf(f, "%d\n", sizeof(time_t));
1352 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001353}],
1354ac_cv_sizeof_time_t=`cat conftestval`,
1355ac_cv_sizeof_time_t=0,
1356ac_cv_sizeof_time_t=4)
Fred Drakea3f6e912000-06-29 20:44:47 +00001357])
1358AC_MSG_RESULT($ac_cv_sizeof_time_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001359AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t,
1360[The number of bytes in a time_t.])
Fred Drakea3f6e912000-06-29 20:44:47 +00001361
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001362
Trent Mick635f6fb2000-08-23 21:33:05 +00001363# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001364ac_save_cc="$CC"
1365if test "$ac_cv_kpthread" = "yes"
1366then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001367elif test "$ac_cv_kthread" = "yes"
1368then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001369elif test "$ac_cv_pthread" = "yes"
1370then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001371fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001372AC_MSG_CHECKING(for pthread_t)
1373have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +00001374AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +00001375AC_MSG_RESULT($have_pthread_t)
1376if test "$have_pthread_t" = yes ; then
1377 # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
1378 AC_MSG_CHECKING(size of pthread_t)
1379 AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
1380 [AC_TRY_RUN([#include <stdio.h>
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001381#include <pthread.h>
Trent Mick635f6fb2000-08-23 21:33:05 +00001382 main()
1383 {
1384 FILE *f=fopen("conftestval", "w");
1385 if (!f) exit(1);
1386 fprintf(f, "%d\n", sizeof(pthread_t));
1387 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001388 }],
1389 ac_cv_sizeof_pthread_t=`cat conftestval`,
1390 ac_cv_sizeof_pthread_t=0,
1391 ac_cv_sizeof_pthread_t=4)
Trent Mick635f6fb2000-08-23 21:33:05 +00001392 ])
1393 AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001394 AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t,
1395 [The number of bytes in a pthread_t.])
Trent Mick635f6fb2000-08-23 21:33:05 +00001396fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001397CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001398
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001399
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001400AC_SUBST(OTHER_LIBTOOL_OPT)
1401case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001402 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001403 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1404 ;;
1405 Darwin/*)
1406 OTHER_LIBTOOL_OPT=""
1407 ;;
1408esac
1409
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001410AC_SUBST(LIBTOOL_CRUFT)
1411case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001412 Darwin/@<:@01567@:>@\..*)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001413 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1414 if test "${enable_universalsdk}"; then
1415 :
1416 else
1417 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `arch`"
1418 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001419 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001420 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001421 Darwin/*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001422 gcc_version=`gcc -v 2>&1 | grep version | cut -d\ -f3`
1423 if test ${gcc_version} '<' 4.0
1424 then
1425 LIBTOOL_CRUFT="-lcc_dynamic"
1426 else
1427 LIBTOOL_CRUFT=""
1428 fi
Jack Jansen39fd2312006-02-23 15:12:19 +00001429 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only `arch`"
Jack Jansenb36687a2004-07-16 08:43:47 +00001430 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001431 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001432esac
1433
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001434AC_MSG_CHECKING(for --enable-framework)
1435if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001436then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001437 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001438 # -F. is needed to allow linking to the framework while
1439 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001440 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1441 [Define if you want to produce an OpenStep/Rhapsody framework
1442 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001443 AC_MSG_RESULT(yes)
1444else
1445 AC_MSG_RESULT(no)
1446fi
1447
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001448AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001449case $ac_sys_system/$ac_sys_release in
1450 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001451 AC_DEFINE(WITH_DYLD, 1,
1452 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1453 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1454 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001455 AC_MSG_RESULT(always on for Darwin)
1456 ;;
1457 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001458 AC_MSG_RESULT(no)
1459 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001460esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001461
Guido van Rossumac405f61994-09-12 10:56:06 +00001462# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001463AC_SUBST(SO)
1464AC_SUBST(LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001465AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001466AC_SUBST(CCSHARED)
1467AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001468# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001469# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001470AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001471if test -z "$SO"
1472then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001473 case $ac_sys_system in
Thomas Wouters477c8d52006-05-27 19:21:47 +00001474 hp*|HP*)
1475 case `uname -m` in
1476 ia64) SO=.so;;
1477 *) SO=.sl;;
1478 esac
1479 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001480 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001481 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001482 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001483else
1484 # this might also be a termcap variable, see #610332
1485 echo
1486 echo '====================================================================='
1487 echo '+ +'
1488 echo '+ WARNING: You have set SO in your environment. +'
1489 echo '+ Do you really mean to change the extension for shared libraries? +'
1490 echo '+ Continuing in 10 seconds to let you to ponder. +'
1491 echo '+ +'
1492 echo '====================================================================='
1493 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001494fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001495AC_MSG_RESULT($SO)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001496AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001497# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001498# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001499# (Shared libraries in this instance are shared modules to be loaded into
1500# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001501AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001502if test -z "$LDSHARED"
1503then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001504 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001505 AIX*)
1506 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001507 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001508 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001509 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001510 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a6632000-05-26 12:22:54 +00001511 SunOS/5*)
1512 if test "$GCC" = "yes"
Neil Schemenauer95052722001-02-19 18:17:33 +00001513 then LDSHARED='$(CC) -shared'
Martin v. Löwisaa5afe12002-10-07 06:21:41 +00001514 else LDSHARED='$(CC) -G';
Greg Ward57c9a6632000-05-26 12:22:54 +00001515 fi ;;
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001516 hp*|HP*)
1517 if test "$GCC" = "yes"
1518 then LDSHARED='$(CC) -shared'
1519 else LDSHARED='ld -b';
1520 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001521 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001522 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +00001523 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1524 if test "$enable_framework" ; then
1525 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001526 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1527 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001528 else
1529 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001530 LDSHARED="$LDSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001531 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001532 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001533 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1534 if test "$enable_framework" ; then
1535 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001536 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1537 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001538 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001539 # No framework, use the Python app as bundle-loader
1540 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001541 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001542 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001543 Darwin/*)
1544 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1545 # This allows an extension to be used in any Python
Jack Jansenbe954622004-12-26 23:07:48 +00001546 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
Thomas Wouters477c8d52006-05-27 19:21:47 +00001547 if test ${cur_target} '>' 10.2; then
1548 cur_target=10.3
1549 fi
Georg Brandlfcaf9102008-07-16 02:17:56 +00001550 if test "${UNIVERSAL_ARCHS}" = "all"; then
1551 # Ensure that the default platform for a 4-way
1552 # universal build is OSX 10.5, that's the first
1553 # OS release where 4-way builds make sense.
1554 cur_target='10.5'
1555 fi
Jack Jansenc110f862005-01-07 10:49:32 +00001556 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
Thomas Wouters89d996e2007-09-08 17:39:28 +00001557
1558 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1559 # environment with a value that is the same as what we'll use
1560 # in the Makefile to ensure that we'll get the same compiler
1561 # environment during configure and build time.
1562 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1563 export MACOSX_DEPLOYMENT_TARGET
1564
Thomas Wouters477c8d52006-05-27 19:21:47 +00001565 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
Georg Brandlfcaf9102008-07-16 02:17:56 +00001566 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001567 then
Thomas Wouters477c8d52006-05-27 19:21:47 +00001568 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +00001569 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001570 fi
Jack Jansen6b08a402004-06-03 12:41:45 +00001571 LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1572 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001573 else
1574 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1575 if test "$enable_framework" ; then
1576 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001577 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1578 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001579 else
1580 # No framework, use the Python app as bundle-loader
1581 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1582 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1583 fi
1584 fi
1585 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001586 Linux*|GNU*|QNX*) LDSHARED='$(CC) -shared';;
Guido van Rossum458e7fa1999-09-17 15:40:40 +00001587 BSD/OS*/4*) LDSHARED="gcc -shared";;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001588 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001589 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001590 then
Hye-Shik Chang33761492004-10-26 09:53:46 +00001591 LDSHARED="$CC -shared ${LDFLAGS}"
Guido van Rossum0286ae82000-08-29 15:06:49 +00001592 else
1593 LDSHARED="ld -Bshareable ${LDFLAGS}"
1594 fi;;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001595 OpenBSD*)
1596 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1597 then
1598 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1599 else
1600 case `uname -r` in
1601 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1602 LDSHARED="ld -Bshareable ${LDFLAGS}"
1603 ;;
1604 *)
1605 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1606 ;;
1607 esac
1608 fi;;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001609 NetBSD*|DragonFly*) LDSHARED="cc -shared ${LDFLAGS}";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001610 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001611 if test "$GCC" = "yes"
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001612 then LDSHARED='$(CC) -shared'
1613 else LDSHARED='$(CC) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001614 fi;;
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001615 SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
Trent Mick635f6fb2000-08-23 21:33:05 +00001616 Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001617 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001618 atheos*) LDSHARED="gcc -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001619 *) LDSHARED="ld";;
1620 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001621fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001622AC_MSG_RESULT($LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001623BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001624# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001625# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001626AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001627if test -z "$CCSHARED"
1628then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001629 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001630 SunOS*) if test "$GCC" = yes;
Guido van Rossumd8faa362007-04-27 19:54:29 +00001631 then CCSHARED="-fPIC";
1632 elif test `uname -p` = sparc;
1633 then CCSHARED="-xcode=pic32";
1634 else CCSHARED="-Kpic";
1635 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001636 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001637 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001638 else CCSHARED="+z";
1639 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001640 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001641 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001642 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001643 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001644 if test "$GCC" = "yes"
1645 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001646 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001647 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001648 SCO_SV*)
1649 if test "$GCC" = "yes"
1650 then CCSHARED="-fPIC"
1651 else CCSHARED="-Kpic -belf"
1652 fi;;
Trent Mick635f6fb2000-08-23 21:33:05 +00001653 Monterey*) CCSHARED="-G";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001654 IRIX*/6*) case $CC in
1655 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001656 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001657 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001658 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001659 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001660fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001661AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001662# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001663# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001664AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001665if test -z "$LINKFORSHARED"
1666then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001667 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001668 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001669 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001670 LINKFORSHARED="-Wl,-E -Wl,+s";;
1671# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001672 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001673 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001674 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001675 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001676 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
1677 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001678 # not used by the core itself but which needs to be in the core so
1679 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00001680 # -prebind is no longer used, because it actually seems to give a
1681 # slowdown in stead of a speedup, maybe due to the large number of
1682 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001683
1684 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001685 if test "$enable_framework"
1686 then
Jack Jansenda49e192005-01-07 13:08:22 +00001687 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001688 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001689 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001690 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001691 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001692 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001693 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001694 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1695 then
1696 LINKFORSHARED="-Wl,--export-dynamic"
1697 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001698 SunOS/5*) case $CC in
1699 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001700 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001701 then
1702 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001703 fi;;
1704 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001705 CYGWIN*)
1706 if test $enable_shared = "no"
1707 then
1708 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1709 fi;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001710 QNX*)
1711 # -Wl,-E causes the symbols to be added to the dynamic
1712 # symbol table so that they can be found when a module
1713 # is loaded. -N 2048K causes the stack size to be set
1714 # to 2048 kilobytes so that the stack doesn't overflow
1715 # when running test_compile.py.
1716 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00001717 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001718fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001719AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001720
Neil Schemenauer61c51152001-01-26 16:18:16 +00001721AC_SUBST(CFLAGSFORSHARED)
1722AC_MSG_CHECKING(CFLAGSFORSHARED)
1723if test ! "$LIBRARY" = "$LDLIBRARY"
1724then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00001725 case $ac_sys_system in
1726 CYGWIN*)
1727 # Cygwin needs CCSHARED when building extension DLLs
1728 # but not when building the interpreter DLL.
1729 CFLAGSFORSHARED='';;
1730 *)
1731 CFLAGSFORSHARED='$(CCSHARED)'
1732 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00001733fi
1734AC_MSG_RESULT($CFLAGSFORSHARED)
1735
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001736# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1737# library (with --enable-shared).
1738# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001739# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1740# if it is not required, since it creates a dependency of the shared library
1741# to LIBS. This, in turn, means that applications linking the shared libpython
1742# don't need to link LIBS explicitly. The default should be only changed
1743# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001744AC_SUBST(SHLIBS)
1745AC_MSG_CHECKING(SHLIBS)
1746case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001747 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001748 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001749esac
1750AC_MSG_RESULT($SHLIBS)
1751
1752
Guido van Rossum627b2d71993-12-24 10:39:16 +00001753# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001754AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
1755AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00001756
1757# only check for sem_ini if thread support is requested
1758if test "$with_threads" = "yes" -o -z "$with_threads"; then
1759 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1760 # posix4 on Solaris 2.6
1761 # pthread (first!) on Linux
1762fi
1763
Martin v. Löwis19d17342003-06-14 21:03:05 +00001764# check if we need libintl for locale functions
1765AC_CHECK_LIB(intl, textdomain,
1766 AC_DEFINE(WITH_LIBINTL, 1,
1767 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001768
1769# checks for system dependent C++ extensions support
1770case "$ac_sys_system" in
1771 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1772 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1773 [loadAndInit("", 0, "")],
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001774 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1775 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1776 and you want support for AIX C++ shared extension modules.])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001777 AC_MSG_RESULT(yes)],
1778 [AC_MSG_RESULT(no)]);;
1779 *) ;;
1780esac
1781
Guido van Rossum70c7f481998-03-26 18:44:10 +00001782# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001783AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001784AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00001785
Guido van Rossumc5a39031996-07-31 17:35:03 +00001786AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001787AC_ARG_WITH(libs,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001788 AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1789[
Guido van Rossumc5a39031996-07-31 17:35:03 +00001790AC_MSG_RESULT($withval)
1791LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001792],
1793[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001794
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001795# Check for use of the system libffi library
1796AC_MSG_CHECKING(for --with-system-ffi)
1797AC_ARG_WITH(system_ffi,
1798 AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
1799
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001800AC_MSG_RESULT($with_system_ffi)
1801
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001802# Determine if signalmodule should be used.
1803AC_SUBST(USE_SIGNAL_MODULE)
1804AC_SUBST(SIGNAL_OBJS)
1805AC_MSG_CHECKING(for --with-signal-module)
1806AC_ARG_WITH(signal-module,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001807 AC_HELP_STRING(--with-signal-module, disable/enable signal module))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001808
1809if test -z "$with_signal_module"
1810then with_signal_module="yes"
1811fi
1812AC_MSG_RESULT($with_signal_module)
1813
1814if test "${with_signal_module}" = "yes"; then
1815 USE_SIGNAL_MODULE=""
1816 SIGNAL_OBJS=""
1817else
1818 USE_SIGNAL_MODULE="#"
1819 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1820fi
1821
Guido van Rossum3d15bd82001-01-10 18:53:48 +00001822# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00001823AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001824USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00001825
Guido van Rossum54d93d41997-01-22 20:51:58 +00001826AC_MSG_CHECKING(for --with-dec-threads)
1827AC_SUBST(LDLAST)
1828AC_ARG_WITH(dec-threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001829 AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1830[
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001831AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00001832LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00001833if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00001834 with_thread="$withval";
1835fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001836[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00001837
Martin v. Löwis11437992002-04-12 09:54:03 +00001838# Templates for things AC_DEFINEd more than once.
1839# For a single AC_DEFINE, no template is needed.
1840AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
1841AH_TEMPLATE(_REENTRANT,
1842 [Define to force use of thread-safe errno, h_errno, and other functions])
1843AH_TEMPLATE(WITH_THREAD,
1844 [Define if you want to compile in rudimentary thread support])
1845
Guido van Rossum54d93d41997-01-22 20:51:58 +00001846AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001847dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001848AC_ARG_WITH(threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001849 AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
Guido van Rossum54d93d41997-01-22 20:51:58 +00001850
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001851# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001852dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00001853AC_ARG_WITH(thread,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001854 AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
1855 [with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001856
1857if test -z "$with_threads"
1858then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001859fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001860AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00001861
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001862AC_SUBST(THREADOBJ)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001863if test "$with_threads" = "no"
1864then
1865 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001866elif test "$ac_cv_pthread_is_default" = yes
1867then
1868 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001869 # Defining _REENTRANT on system with POSIX threads should not hurt.
1870 AC_DEFINE(_REENTRANT)
1871 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001872 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001873elif test "$ac_cv_kpthread" = "yes"
1874then
1875 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00001876 if test "$ac_cv_cxx_thread" = "yes"; then
1877 CXX="$CXX -Kpthread"
1878 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001879 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001880 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001881 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001882elif test "$ac_cv_kthread" = "yes"
1883then
1884 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00001885 if test "$ac_cv_cxx_thread" = "yes"; then
1886 CXX="$CXX -Kthread"
1887 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001888 AC_DEFINE(WITH_THREAD)
1889 posix_threads=yes
1890 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001891elif test "$ac_cv_pthread" = "yes"
1892then
1893 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00001894 if test "$ac_cv_cxx_thread" = "yes"; then
1895 CXX="$CXX -pthread"
1896 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001897 AC_DEFINE(WITH_THREAD)
1898 posix_threads=yes
1899 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001900else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001901 if test ! -z "$with_threads" -a -d "$with_threads"
1902 then LDFLAGS="$LDFLAGS -L$with_threads"
1903 fi
1904 if test ! -z "$withval" -a -d "$withval"
1905 then LDFLAGS="$LDFLAGS -L$withval"
1906 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001907
1908 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00001909 # define _POSIX_THREADS in unistd.h. Some apparently don't
1910 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001911 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
1912 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001913 [
1914#include <unistd.h>
1915#ifdef _POSIX_THREADS
1916yes
1917#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001918 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
1919 AC_MSG_RESULT($unistd_defines_pthreads)
1920
Martin v. Löwis130fb172001-07-19 11:00:41 +00001921 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001922 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
1923 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001924 AC_DEFINE(HURD_C_THREADS, 1,
1925 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001926 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001927 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00001928 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
1929 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001930 AC_DEFINE(MACH_C_THREADS, 1,
1931 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001932 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00001933 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001934 AC_ARG_WITH([pth],
1935 AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
1936 [AC_MSG_RESULT($withval)
1937 AC_DEFINE([WITH_THREAD])
1938 AC_DEFINE([HAVE_PTH], 1,
1939 [Define if you have GNU PTH threads.])
1940 LIBS="-lpth $LIBS"
1941 THREADOBJ="Python/thread.o"],
1942 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00001943
1944 # Just looking for pthread_create in libpthread is not enough:
1945 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
1946 # So we really have to include pthread.h, and then link.
1947 _libs=$LIBS
1948 LIBS="$LIBS -lpthread"
1949 AC_MSG_CHECKING([for pthread_create in -lpthread])
1950 AC_TRY_LINK([#include <pthread.h>
1951
1952void * start_routine (void *arg) { exit (0); }], [
1953pthread_create (NULL, NULL, start_routine, NULL)], [
1954 AC_MSG_RESULT(yes)
1955 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001956 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001957 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00001958 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00001959 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001960 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001961 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001962 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
1963 AC_DEFINE(ATHEOS_THREADS, 1,
1964 [Define this if you have AtheOS threads.])
1965 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00001966 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001967 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001968 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001969 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00001970 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001971 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001972 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001973 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00001974 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001975 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001976 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001977 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00001978 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001979 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001980 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001981 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00001982 USE_THREAD_MODULE="#"])
Skip Montanaroeb33e5a2007-08-17 12:57:41 +00001983 ])])])])])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001984
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001985 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
1986 LIBS="$LIBS -lmpc"
1987 THREADOBJ="Python/thread.o"
1988 USE_THREAD_MODULE=""])
1989
1990 if test "$posix_threads" != "yes"; then
1991 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
1992 LIBS="$LIBS -lthread"
1993 THREADOBJ="Python/thread.o"
1994 USE_THREAD_MODULE=""])
1995 fi
1996
1997 if test "$USE_THREAD_MODULE" != "#"
1998 then
1999 # If the above checks didn't disable threads, (at least) OSF1
2000 # needs this '-threads' argument during linking.
2001 case $ac_sys_system in
2002 OSF1) LDLAST=-threads;;
2003 esac
2004 fi
2005fi
2006
2007if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002008 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002009 AC_DEFINE(_POSIX_THREADS, 1,
2010 [Define if you have POSIX threads,
2011 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002012 fi
2013
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002014 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2015 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002016 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2017 Defined for Solaris 2.6 bug in pthread header.)
2018 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002019 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002020 Define if the Posix semaphores do not work on your system)
2021 ;;
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002022 AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2023 Define if the Posix semaphores do not work on your system)
2024 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002025 esac
2026
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002027 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2028 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2029 [AC_TRY_RUN([#include <pthread.h>
2030 void *foo(void *parm) {
2031 return NULL;
2032 }
2033 main() {
2034 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002035 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002036 if (pthread_attr_init(&attr)) exit(-1);
2037 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002038 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002039 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00002040 }],
2041 ac_cv_pthread_system_supported=yes,
2042 ac_cv_pthread_system_supported=no,
2043 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002044 ])
2045 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2046 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002047 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002048 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002049 AC_CHECK_FUNCS(pthread_sigmask,
2050 [case $ac_sys_system in
2051 CYGWIN*)
2052 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2053 [Define if pthread_sigmask() does not work on your system.])
2054 ;;
2055 esac])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002056fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002057
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002058
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002059# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002060AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002061AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002062AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002063[ --enable-ipv6 Enable ipv6 (with ipv4) support
2064 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002065[ case "$enableval" in
2066 no)
2067 AC_MSG_RESULT(no)
2068 ipv6=no
2069 ;;
2070 *) AC_MSG_RESULT(yes)
2071 AC_DEFINE(ENABLE_IPV6)
2072 ipv6=yes
2073 ;;
2074 esac ],
2075
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002076[
2077dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002078 AC_TRY_RUN([ /* AF_INET6 available check */
2079#include <sys/types.h>
2080#include <sys/socket.h>
2081main()
2082{
2083 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2084 exit(1);
2085 else
2086 exit(0);
2087}
2088],
2089 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002090 ipv6=yes,
2091 AC_MSG_RESULT(no)
2092 ipv6=no,
2093 AC_MSG_RESULT(no)
2094 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002095)
2096
2097if test "$ipv6" = "yes"; then
2098 AC_MSG_CHECKING(if RFC2553 API is available)
2099 AC_TRY_COMPILE([#include <sys/types.h>
2100#include <netinet/in.h>],
2101 [struct sockaddr_in6 x;
2102x.sin6_scope_id;],
2103 AC_MSG_RESULT(yes)
2104 ipv6=yes,
2105 AC_MSG_RESULT(no, IPv6 disabled)
2106 ipv6=no)
2107fi
2108
2109if test "$ipv6" = "yes"; then
2110 AC_DEFINE(ENABLE_IPV6)
2111fi
2112])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002113
2114ipv6type=unknown
2115ipv6lib=none
2116ipv6trylibc=no
2117
2118if test "$ipv6" = "yes"; then
2119 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002120 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2121 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002122 case $i in
2123 inria)
2124 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002125 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002126#include <netinet/in.h>
2127#ifdef IPV6_INRIA_VERSION
2128yes
2129#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002130 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002131 ;;
2132 kame)
2133 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002134 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002135#include <netinet/in.h>
2136#ifdef __KAME__
2137yes
2138#endif],
2139 [ipv6type=$i;
2140 ipv6lib=inet6
2141 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002142 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002143 ;;
2144 linux-glibc)
2145 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002146 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002147#include <features.h>
2148#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2149yes
2150#endif],
2151 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002152 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002153 ;;
2154 linux-inet6)
2155 dnl http://www.v6.linux.or.jp/
2156 if test -d /usr/inet6; then
2157 ipv6type=$i
2158 ipv6lib=inet6
2159 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002160 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002161 fi
2162 ;;
2163 solaris)
2164 if test -f /etc/netconfig; then
2165 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2166 ipv6type=$i
2167 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002168 fi
2169 fi
2170 ;;
2171 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002172 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002173#include <sys/param.h>
2174#ifdef _TOSHIBA_INET6
2175yes
2176#endif],
2177 [ipv6type=$i;
2178 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002179 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002180 ;;
2181 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002182 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002183#include </usr/local/v6/include/sys/v6config.h>
2184#ifdef __V6D__
2185yes
2186#endif],
2187 [ipv6type=$i;
2188 ipv6lib=v6;
2189 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002190 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002191 ;;
2192 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002193 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002194#include <sys/param.h>
2195#ifdef _ZETA_MINAMI_INET6
2196yes
2197#endif],
2198 [ipv6type=$i;
2199 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002200 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002201 ;;
2202 esac
2203 if test "$ipv6type" != "unknown"; then
2204 break
2205 fi
2206 done
2207 AC_MSG_RESULT($ipv6type)
2208fi
2209
2210if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2211 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2212 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2213 echo "using lib$ipv6lib"
2214 else
2215 if test $ipv6trylibc = "yes"; then
2216 echo "using libc"
2217 else
2218 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2219 echo "You need to fetch lib$ipv6lib.a from appropriate"
2220 echo 'ipv6 kit and compile beforehand.'
2221 exit 1
2222 fi
2223 fi
2224fi
2225
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002226# Check for --with-doc-strings
2227AC_MSG_CHECKING(for --with-doc-strings)
2228AC_ARG_WITH(doc-strings,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002229 AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002230
2231if test -z "$with_doc_strings"
2232then with_doc_strings="yes"
2233fi
2234if test "$with_doc_strings" != "no"
2235then
2236 AC_DEFINE(WITH_DOC_STRINGS, 1,
2237 [Define if you want documentation strings in extension modules])
2238fi
2239AC_MSG_RESULT($with_doc_strings)
2240
Neil Schemenauera35c6882001-02-27 04:45:05 +00002241# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002242AC_MSG_CHECKING(for --with-tsc)
2243AC_ARG_WITH(tsc,
2244[ --with(out)-tsc enable/disable timestamp counter profile], [
2245if test "$withval" != no
2246then
2247 AC_DEFINE(WITH_TSC, 1,
2248 [Define to profile with the Pentium timestamp counter])
2249 AC_MSG_RESULT(yes)
2250else AC_MSG_RESULT(no)
2251fi],
2252[AC_MSG_RESULT(no)])
2253
2254# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002255AC_MSG_CHECKING(for --with-pymalloc)
2256AC_ARG_WITH(pymalloc,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002257 AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002258
2259if test -z "$with_pymalloc"
2260then with_pymalloc="yes"
2261fi
2262if test "$with_pymalloc" != "no"
2263then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002264 AC_DEFINE(WITH_PYMALLOC, 1,
2265 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002266fi
2267AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002268
Barry Warsawef82cd72000-06-30 16:21:01 +00002269# Check for --with-wctype-functions
2270AC_MSG_CHECKING(for --with-wctype-functions)
2271AC_ARG_WITH(wctype-functions,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002272 AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2273[
Barry Warsawef82cd72000-06-30 16:21:01 +00002274if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002275then
2276 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2277 [Define if you want wctype.h functions to be used instead of the
2278 one supplied by Python itself. (see Include/unicodectype.h).])
2279 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002280else AC_MSG_RESULT(no)
2281fi],
2282[AC_MSG_RESULT(no)])
2283
Guido van Rossum68242b51996-05-28 22:53:03 +00002284# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002285AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002286DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002287
Guido van Rossume97ee181999-12-20 21:27:22 +00002288# the dlopen() function means we might want to use dynload_shlib.o. some
2289# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002290AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002291
2292# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2293# loading of modules.
2294AC_SUBST(DYNLOADFILE)
2295AC_MSG_CHECKING(DYNLOADFILE)
2296if test -z "$DYNLOADFILE"
2297then
2298 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002299 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2300 if test "$ac_cv_func_dlopen" = yes
2301 then DYNLOADFILE="dynload_shlib.o"
2302 else DYNLOADFILE="dynload_aix.o"
2303 fi
2304 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002305 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002306 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2307 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002308 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002309 *)
2310 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2311 # out any dynamic loading
2312 if test "$ac_cv_func_dlopen" = yes
2313 then DYNLOADFILE="dynload_shlib.o"
2314 else DYNLOADFILE="dynload_stub.o"
2315 fi
2316 ;;
2317 esac
2318fi
2319AC_MSG_RESULT($DYNLOADFILE)
2320if test "$DYNLOADFILE" != "dynload_stub.o"
2321then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002322 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2323 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002324fi
2325
Jack Jansenc49e5b72001-06-19 15:00:23 +00002326# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2327
2328AC_SUBST(MACHDEP_OBJS)
2329AC_MSG_CHECKING(MACHDEP_OBJS)
2330if test -z "$MACHDEP_OBJS"
2331then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002332 MACHDEP_OBJS=$extra_machdep_objs
2333else
2334 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002335fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002336AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002337
Guido van Rossum627b2d71993-12-24 10:39:16 +00002338# checks for library functions
Martin v. Löwis823725e2008-03-24 13:39:54 +00002339AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2340 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002341 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwisc3001752005-01-23 09:27:24 +00002342 getpriority getpwent getspnam getspent getsid getwd \
Christian Heimesd0764e22007-12-04 15:00:33 +00002343 kill killpg lchmod lchown lstat mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002344 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002345 putenv readlink realpath \
Martin v. Löwisd5843682002-11-21 20:41:28 +00002346 select setegid seteuid setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002347 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Gregory P. Smith6c357262007-09-03 16:44:06 +00002348 sigaction siginterrupt sigrelse strftime strlcpy \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002349 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Martin v. Löwis92fab752008-03-08 10:40:41 +00002350 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll wcsxfrm _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002351
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002352# For some functions, having a definition is not sufficient, since
2353# we want to take their address.
2354AC_MSG_CHECKING(for chroot)
2355AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2356 AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2357 AC_MSG_RESULT(yes),
2358 AC_MSG_RESULT(no)
2359)
2360AC_MSG_CHECKING(for link)
2361AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2362 AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2363 AC_MSG_RESULT(yes),
2364 AC_MSG_RESULT(no)
2365)
2366AC_MSG_CHECKING(for symlink)
2367AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2368 AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2369 AC_MSG_RESULT(yes),
2370 AC_MSG_RESULT(no)
2371)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002372AC_MSG_CHECKING(for fchdir)
2373AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2374 AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2375 AC_MSG_RESULT(yes),
2376 AC_MSG_RESULT(no)
2377)
2378AC_MSG_CHECKING(for fsync)
2379AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
Skip Montanarod4fa8072003-09-25 14:49:15 +00002380 AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002381 AC_MSG_RESULT(yes),
2382 AC_MSG_RESULT(no)
2383)
2384AC_MSG_CHECKING(for fdatasync)
2385AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2386 AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2387 AC_MSG_RESULT(yes),
2388 AC_MSG_RESULT(no)
2389)
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002390AC_MSG_CHECKING(for epoll)
2391AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
2392 AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2393 AC_MSG_RESULT(yes),
2394 AC_MSG_RESULT(no)
2395)
2396AC_MSG_CHECKING(for kqueue)
2397AC_TRY_COMPILE([
2398#include <sys/types.h>
2399#include <sys/event.h>
2400 ], int x=kqueue(),
2401 AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2402 AC_MSG_RESULT(yes),
2403 AC_MSG_RESULT(no)
2404)
Martin v. Löwisd5843682002-11-21 20:41:28 +00002405# On some systems (eg. FreeBSD 5), we would find a definition of the
2406# functions ctermid_r, setgroups in the library, but no prototype
2407# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2408# address to avoid compiler warnings and potential miscompilations
2409# because of the missing prototypes.
2410
2411AC_MSG_CHECKING(for ctermid_r)
2412AC_TRY_COMPILE([
2413#include "confdefs.h"
2414#include <stdio.h>
2415], void* p = ctermid_r,
2416 AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2417 AC_MSG_RESULT(yes),
2418 AC_MSG_RESULT(no)
2419)
2420
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002421AC_MSG_CHECKING(for flock)
2422AC_TRY_COMPILE([
2423#include "confdefs.h"
2424#include <sys/file.h>
2425], void* p = flock,
2426 AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2427 AC_MSG_RESULT(yes),
2428 AC_MSG_RESULT(no)
2429)
2430
2431AC_MSG_CHECKING(for getpagesize)
2432AC_TRY_COMPILE([
2433#include "confdefs.h"
2434#include <unistd.h>
2435], void* p = getpagesize,
2436 AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2437 AC_MSG_RESULT(yes),
2438 AC_MSG_RESULT(no)
2439)
2440
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002441dnl check for true
2442AC_CHECK_PROGS(TRUE, true, /bin/true)
2443
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002444dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2445dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002446AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002447 AC_CHECK_LIB(resolv, inet_aton)
2448)
2449
Christian Heimesd0764e22007-12-04 15:00:33 +00002450# On Tru64, chflags seems to be present, but calling it will
2451# exit Python
2452AC_MSG_CHECKING(for chflags)
2453AC_TRY_RUN([
2454#include <sys/stat.h>
2455#include <unistd.h>
2456int main(int argc, char*argv[])
2457{
2458 if(chflags(argv[0], 0) != 0)
2459 return 1;
2460 return 0;
2461}
2462],AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
2463 AC_MSG_RESULT(yes),
2464 AC_MSG_RESULT(no)
2465)
2466
2467AC_MSG_CHECKING(for lchflags)
2468AC_TRY_RUN([
2469#include <sys/stat.h>
2470#include <unistd.h>
2471int main(int argc, char*argv[])
2472{
2473 if(lchflags(argv[0], 0) != 0)
2474 return 1;
2475 return 0;
2476}
2477],AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
2478 AC_MSG_RESULT(yes),
2479 AC_MSG_RESULT(no)
2480)
2481
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002482dnl Check if system zlib has *Copy() functions
2483dnl
2484dnl On MacOSX the linker will search for dylibs on the entire linker path
2485dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2486dnl to revert to a more traditional unix behaviour and make it possible to
2487dnl override the system libz with a local static library of libz. Temporarily
2488dnl add that flag to our CFLAGS as well to ensure that we check the version
2489dnl of libz that will be used by setup.py.
2490dnl The -L/usr/local/lib is needed as wel to get the same compilation
2491dnl environment as setup.py (and leaving it out can cause configure to use the
2492dnl wrong version of the library)
2493case $ac_sys_system/$ac_sys_release in
2494Darwin/*)
2495 _CUR_CFLAGS="${CFLAGS}"
2496 _CUR_LDFLAGS="${LDFLAGS}"
2497 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2498 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2499 ;;
2500esac
2501
2502AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2503
2504case $ac_sys_system/$ac_sys_release in
2505Darwin/*)
2506 CFLAGS="${_CUR_CFLAGS}"
2507 LDFLAGS="${_CUR_LDFLAGS}"
2508 ;;
2509esac
2510
Martin v. Löwise9416172003-05-03 10:12:45 +00002511AC_MSG_CHECKING(for hstrerror)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002512AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002513#include "confdefs.h"
2514#include <netdb.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002515], void* p = hstrerror; hstrerror(0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002516 AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2517 AC_MSG_RESULT(yes),
2518 AC_MSG_RESULT(no)
2519)
2520
2521AC_MSG_CHECKING(for inet_aton)
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"
Martin v. Löwis86d66262006-02-17 08:40:11 +00002524#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002525#include <sys/socket.h>
2526#include <netinet/in.h>
2527#include <arpa/inet.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002528], void* p = inet_aton;inet_aton(0,0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002529 AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2530 AC_MSG_RESULT(yes),
2531 AC_MSG_RESULT(no)
2532)
2533
2534AC_MSG_CHECKING(for inet_pton)
2535AC_TRY_COMPILE([
2536#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002537#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002538#include <sys/socket.h>
2539#include <netinet/in.h>
2540#include <arpa/inet.h>
2541], void* p = inet_pton,
2542 AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2543 AC_MSG_RESULT(yes),
2544 AC_MSG_RESULT(no)
2545)
2546
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002547# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002548AC_MSG_CHECKING(for setgroups)
2549AC_TRY_COMPILE([
2550#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002551#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002552#ifdef HAVE_GRP_H
2553#include <grp.h>
2554#endif
Martin v. Löwisd5843682002-11-21 20:41:28 +00002555],
2556void* p = setgroups,
2557 AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2558 AC_MSG_RESULT(yes),
2559 AC_MSG_RESULT(no)
2560)
2561
Fred Drake8cef4cf2000-06-28 16:40:38 +00002562# check for openpty and forkpty
2563
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002564AC_CHECK_FUNCS(openpty,,
2565 AC_CHECK_LIB(util,openpty,
2566 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2567 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2568 )
2569)
2570AC_CHECK_FUNCS(forkpty,,
2571 AC_CHECK_LIB(util,forkpty,
2572 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2573 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2574 )
2575)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002576
Christian Heimesb186d002008-03-18 15:15:01 +00002577# Stuff for expat.
2578AC_CHECK_FUNCS(memmove)
2579
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002580# check for long file support functions
2581AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2582
Christian Heimesb186d002008-03-18 15:15:01 +00002583AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002584AC_CHECK_FUNCS(getpgrp,
2585 AC_TRY_COMPILE([#include <unistd.h>],
2586 [getpgrp(0);],
2587 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2588 [Define if getpgrp() must be called as getpgrp(0).])
2589 )
2590)
Jack Jansen150753c2003-03-29 22:07:47 +00002591AC_CHECK_FUNCS(setpgrp,
2592 AC_TRY_COMPILE([#include <unistd.h>],
2593 [setpgrp(0,0);],
2594 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2595 [Define if setpgrp() must be called as setpgrp(0, 0).])
2596 )
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002597)
2598AC_CHECK_FUNCS(gettimeofday,
2599 AC_TRY_COMPILE([#include <sys/time.h>],
2600 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2601 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2602 [Define if gettimeofday() does not have second (timezone) argument
2603 This is the case on Motorola V4 (R40V4.2)])
2604 )
2605)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002606
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002607AC_MSG_CHECKING(for major, minor, and makedev)
Martin v. Löwise3271202002-11-07 07:42:30 +00002608AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002609#if defined(MAJOR_IN_MKDEV)
2610#include <sys/mkdev.h>
2611#elif defined(MAJOR_IN_SYSMACROS)
2612#include <sys/sysmacros.h>
2613#else
2614#include <sys/types.h>
2615#endif
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002616],[
2617 makedev(major(0),minor(0));
2618],[
2619 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2620 [Define to 1 if you have the device macros.])
2621 AC_MSG_RESULT(yes)
2622],[
2623 AC_MSG_RESULT(no)
2624])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002625
2626# On OSF/1 V5.1, getaddrinfo is available, but a define
2627# for [no]getaddrinfo in netdb.h.
2628AC_MSG_CHECKING(for getaddrinfo)
2629AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002630#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002631#include <sys/socket.h>
2632#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002633#include <stdio.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002634],[
2635getaddrinfo(NULL, NULL, NULL, NULL);
2636], [
2637AC_MSG_RESULT(yes)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002638AC_MSG_CHECKING(getaddrinfo bug)
2639AC_TRY_RUN([
2640#include <sys/types.h>
2641#include <netdb.h>
2642#include <string.h>
2643#include <sys/socket.h>
2644#include <netinet/in.h>
2645
2646main()
2647{
2648 int passive, gaierr, inet4 = 0, inet6 = 0;
2649 struct addrinfo hints, *ai, *aitop;
2650 char straddr[INET6_ADDRSTRLEN], strport[16];
2651
2652 for (passive = 0; passive <= 1; passive++) {
2653 memset(&hints, 0, sizeof(hints));
2654 hints.ai_family = AF_UNSPEC;
2655 hints.ai_flags = passive ? AI_PASSIVE : 0;
2656 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002657 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002658 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2659 (void)gai_strerror(gaierr);
2660 goto bad;
2661 }
2662 for (ai = aitop; ai; ai = ai->ai_next) {
2663 if (ai->ai_addr == NULL ||
2664 ai->ai_addrlen == 0 ||
2665 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2666 straddr, sizeof(straddr), strport, sizeof(strport),
2667 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2668 goto bad;
2669 }
2670 switch (ai->ai_family) {
2671 case AF_INET:
2672 if (strcmp(strport, "54321") != 0) {
2673 goto bad;
2674 }
2675 if (passive) {
2676 if (strcmp(straddr, "0.0.0.0") != 0) {
2677 goto bad;
2678 }
2679 } else {
2680 if (strcmp(straddr, "127.0.0.1") != 0) {
2681 goto bad;
2682 }
2683 }
2684 inet4++;
2685 break;
2686 case AF_INET6:
2687 if (strcmp(strport, "54321") != 0) {
2688 goto bad;
2689 }
2690 if (passive) {
2691 if (strcmp(straddr, "::") != 0) {
2692 goto bad;
2693 }
2694 } else {
2695 if (strcmp(straddr, "::1") != 0) {
2696 goto bad;
2697 }
2698 }
2699 inet6++;
2700 break;
2701 case AF_UNSPEC:
2702 goto bad;
2703 break;
2704 default:
2705 /* another family support? */
2706 break;
2707 }
2708 }
2709 }
2710
2711 if (!(inet4 == 0 || inet4 == 2))
2712 goto bad;
2713 if (!(inet6 == 0 || inet6 == 2))
2714 goto bad;
2715
2716 if (aitop)
2717 freeaddrinfo(aitop);
2718 exit(0);
2719
2720 bad:
2721 if (aitop)
2722 freeaddrinfo(aitop);
2723 exit(1);
2724}
2725],
2726AC_MSG_RESULT(good)
2727buggygetaddrinfo=no,
2728AC_MSG_RESULT(buggy)
2729buggygetaddrinfo=yes,
2730AC_MSG_RESULT(buggy)
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002731buggygetaddrinfo=yes)], [
2732AC_MSG_RESULT(no)
2733buggygetaddrinfo=yes
2734])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002735
2736if test "$buggygetaddrinfo" = "yes"; then
2737 if test "$ipv6" = "yes"; then
2738 echo 'Fatal: You must get working getaddrinfo() function.'
2739 echo ' or you can specify "--disable-ipv6"'.
2740 exit 1
2741 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002742else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002743 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002744fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00002745AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002746
Guido van Rossum627b2d71993-12-24 10:39:16 +00002747# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002748AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00002749AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002750AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00002751AC_CHECK_MEMBERS([struct stat.st_rdev])
2752AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00002753AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00002754AC_CHECK_MEMBERS([struct stat.st_gen])
2755AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00002756AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002757
2758AC_MSG_CHECKING(for time.h that defines altzone)
2759AC_CACHE_VAL(ac_cv_header_time_altzone,
2760[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2761 ac_cv_header_time_altzone=yes,
2762 ac_cv_header_time_altzone=no)])
2763AC_MSG_RESULT($ac_cv_header_time_altzone)
2764if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002765 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002766fi
2767
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002768was_it_defined=no
2769AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002770AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002771#include <sys/types.h>
2772#include <sys/select.h>
2773#include <sys/time.h>
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002774], [;], [
2775 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2776 [Define if you can safely include both <sys/select.h> and <sys/time.h>
2777 (which you can't on SCO ODT 3.0).])
2778 was_it_defined=yes
2779])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002780AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002781
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002782AC_MSG_CHECKING(for addrinfo)
2783AC_CACHE_VAL(ac_cv_struct_addrinfo,
2784AC_TRY_COMPILE([
2785# include <netdb.h>],
2786 [struct addrinfo a],
2787 ac_cv_struct_addrinfo=yes,
2788 ac_cv_struct_addrinfo=no))
2789AC_MSG_RESULT($ac_cv_struct_addrinfo)
2790if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002791 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002792fi
2793
2794AC_MSG_CHECKING(for sockaddr_storage)
2795AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2796AC_TRY_COMPILE([
2797# include <sys/types.h>
2798# include <sys/socket.h>],
2799 [struct sockaddr_storage s],
2800 ac_cv_struct_sockaddr_storage=yes,
2801 ac_cv_struct_sockaddr_storage=no))
2802AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2803if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002804 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002805fi
2806
Guido van Rossum627b2d71993-12-24 10:39:16 +00002807# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002808
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002809AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002810AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002811
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002812works=no
2813AC_MSG_CHECKING(for working volatile)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002814AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
2815 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
2816)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002817AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00002818
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002819works=no
2820AC_MSG_CHECKING(for working signed char)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002821AC_TRY_COMPILE([], [signed char c;], works=yes,
2822 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
2823)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002824AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002825
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002826have_prototypes=no
2827AC_MSG_CHECKING(for prototypes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002828AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
2829 AC_DEFINE(HAVE_PROTOTYPES, 1,
2830 [Define if your compiler supports function prototype])
2831 have_prototypes=yes
2832])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002833AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002834
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002835works=no
2836AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002837AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002838#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00002839int foo(int x, ...) {
2840 va_list va;
2841 va_start(va, x);
2842 va_arg(va, int);
2843 va_arg(va, char *);
2844 va_arg(va, double);
2845 return 0;
2846}
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002847], [return foo(10, "", 3.14);], [
2848 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
2849 [Define if your compiler supports variable length function prototypes
2850 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
2851 works=yes
2852])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002853AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002854
Dave Cole331708b2004-08-09 04:51:41 +00002855# check for socketpair
2856AC_MSG_CHECKING(for socketpair)
2857AC_TRY_COMPILE([
2858#include <sys/types.h>
2859#include <sys/socket.h>
2860], void *x=socketpair,
2861 AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
2862 AC_MSG_RESULT(yes),
2863 AC_MSG_RESULT(no)
2864)
2865
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002866# check if sockaddr has sa_len member
2867AC_MSG_CHECKING(if sockaddr has sa_len member)
2868AC_TRY_COMPILE([#include <sys/types.h>
2869#include <sys/socket.h>],
2870[struct sockaddr x;
2871x.sa_len = 0;],
2872 AC_MSG_RESULT(yes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002873 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002874 AC_MSG_RESULT(no))
2875
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002876va_list_is_array=no
2877AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002878AC_TRY_COMPILE([
2879#ifdef HAVE_STDARG_PROTOTYPES
2880#include <stdarg.h>
2881#else
2882#include <varargs.h>
2883#endif
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002884], [va_list list1, list2; list1 = list2;], , [
2885 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
2886 va_list_is_array=yes
2887])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002888AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002889
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00002890# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00002891AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
2892 [Define this if you have some version of gethostbyname_r()])
2893
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00002894AC_CHECK_FUNC(gethostbyname_r, [
2895 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2896 AC_MSG_CHECKING([gethostbyname_r with 6 args])
2897 OLD_CFLAGS=$CFLAGS
2898 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
2899 AC_TRY_COMPILE([
2900# include <netdb.h>
2901 ], [
2902 char *name;
2903 struct hostent *he, *res;
2904 char buffer[2048];
2905 int buflen = 2048;
2906 int h_errnop;
2907
2908 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
2909 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00002910 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002911 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
2912 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00002913 AC_MSG_RESULT(yes)
2914 ], [
2915 AC_MSG_RESULT(no)
2916 AC_MSG_CHECKING([gethostbyname_r with 5 args])
2917 AC_TRY_COMPILE([
2918# include <netdb.h>
2919 ], [
2920 char *name;
2921 struct hostent *he;
2922 char buffer[2048];
2923 int buflen = 2048;
2924 int h_errnop;
2925
2926 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
2927 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00002928 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002929 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
2930 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00002931 AC_MSG_RESULT(yes)
2932 ], [
2933 AC_MSG_RESULT(no)
2934 AC_MSG_CHECKING([gethostbyname_r with 3 args])
2935 AC_TRY_COMPILE([
2936# include <netdb.h>
2937 ], [
2938 char *name;
2939 struct hostent *he;
2940 struct hostent_data data;
2941
2942 (void) gethostbyname_r(name, he, &data);
2943 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00002944 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002945 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
2946 [Define this if you have the 3-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00002947 AC_MSG_RESULT(yes)
2948 ], [
2949 AC_MSG_RESULT(no)
2950 ])
2951 ])
2952 ])
2953 CFLAGS=$OLD_CFLAGS
2954], [
Thomas Wouters3a584202000-08-05 23:28:51 +00002955 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00002956])
2957AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
2958AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
2959AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00002960AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00002961AC_SUBST(HAVE_GETHOSTBYNAME)
2962
Guido van Rossum627b2d71993-12-24 10:39:16 +00002963# checks for system services
2964# (none yet)
2965
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002966# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00002967AC_CHECK_FUNC(__fpu_control,
2968 [],
2969 [AC_CHECK_LIB(ieee, __fpu_control)
2970])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002971
Guido van Rossum93274221997-05-09 02:42:00 +00002972# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00002973AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002974AC_ARG_WITH(fpectl,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002975 AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
2976[
Guido van Rossum93274221997-05-09 02:42:00 +00002977if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002978then
2979 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
2980 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
2981 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00002982else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00002983fi],
2984[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00002985
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002986# check for --with-libm=...
2987AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00002988case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00002989Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00002990*) LIBM=-lm
2991esac
Guido van Rossum93274221997-05-09 02:42:00 +00002992AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002993AC_ARG_WITH(libm,
2994 AC_HELP_STRING(--with-libm=STRING, math library),
2995[
Guido van Rossum93274221997-05-09 02:42:00 +00002996if test "$withval" = no
2997then LIBM=
2998 AC_MSG_RESULT(force LIBM empty)
2999elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003000then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003001 AC_MSG_RESULT(set LIBM="$withval")
3002else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003003fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003004[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003005
3006# check for --with-libc=...
3007AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003008AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003009AC_ARG_WITH(libc,
3010 AC_HELP_STRING(--with-libc=STRING, C library),
3011[
Guido van Rossum93274221997-05-09 02:42:00 +00003012if test "$withval" = no
3013then LIBC=
3014 AC_MSG_RESULT(force LIBC empty)
3015elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003016then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003017 AC_MSG_RESULT(set LIBC="$withval")
3018else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003019fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003020[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003021
Christian Heimes99170a52007-12-19 02:07:34 +00003022# ************************************
3023# * Check for mathematical functions *
3024# ************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003025
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003026LIBS_SAVE=$LIBS
3027LIBS="$LIBS $LIBM"
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003028
3029# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3030# -0. on some architectures.
3031AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3032AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3033AC_TRY_RUN([
3034#include <math.h>
3035#include <stdlib.h>
3036int main() {
3037 /* return 0 if either negative zeros don't exist
3038 on this platform or if negative zeros exist
3039 and tanh(-0.) == -0. */
3040 if (atan2(0., -1.) == atan2(-0., -1.) ||
3041 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3042 else exit(1);
3043}
3044],
3045ac_cv_tanh_preserves_zero_sign=yes,
3046ac_cv_tanh_preserves_zero_sign=no,
3047ac_cv_tanh_preserves_zero_sign=no)])
3048AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3049if test "$ac_cv_tanh_preserves_zero_sign" = yes
3050then
3051 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3052 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3053fi
3054
Guido van Rossumf2f7eb31996-08-30 15:18:00 +00003055AC_REPLACE_FUNCS(hypot)
Christian Heimes99170a52007-12-19 02:07:34 +00003056
Christian Heimes9bd667a2008-01-20 15:14:11 +00003057AC_CHECK_FUNCS(acosh asinh atanh copysign expm1 finite isinf isnan log1p)
Christian Heimes99170a52007-12-19 02:07:34 +00003058
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003059LIBS=$LIBS_SAVE
3060
Guido van Rossumef2255b2000-03-10 22:30:29 +00003061# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003062AC_CHECK_HEADER(wchar.h, [
3063 AC_DEFINE(HAVE_WCHAR_H, 1,
3064 [Define if the compiler provides a wchar.h header file.])
3065 wchar_h="yes"
3066],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003067wchar_h="no"
3068)
3069
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003070# determine wchar_t size
3071if test "$wchar_h" = yes
3072then
Guido van Rossum67b26592001-10-20 14:21:45 +00003073 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003074fi
3075
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003076AC_MSG_CHECKING(for UCS-4 tcl)
3077have_ucs4_tcl=no
3078AC_TRY_COMPILE([
3079#include <tcl.h>
3080#if TCL_UTF_MAX != 6
3081# error "NOT UCS4_TCL"
3082#endif], [], [
3083 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3084 have_ucs4_tcl=yes
3085])
3086AC_MSG_RESULT($have_ucs4_tcl)
3087
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003088# check whether wchar_t is signed or not
3089if test "$wchar_h" = yes
3090then
3091 # check whether wchar_t is signed or not
3092 AC_MSG_CHECKING(whether wchar_t is signed)
3093 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3094 AC_TRY_RUN([
3095 #include <wchar.h>
3096 int main()
3097 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003098 /* Success: exit code 0 */
3099 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003100 }
3101 ],
3102 ac_cv_wchar_t_signed=yes,
3103 ac_cv_wchar_t_signed=no,
3104 ac_cv_wchar_t_signed=yes)])
3105 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3106fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003107
Georg Brandl52d168a2008-01-07 18:10:24 +00003108AC_MSG_CHECKING(what type to use for str)
3109AC_ARG_WITH(wide-unicode,
3110 AC_HELP_STRING(--with-wide-unicode, Use 4-byte Unicode characters (default is 2 bytes)),
3111[
3112if test "$withval" != no
3113then unicode_size="4"
3114else unicode_size="2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003115fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003116],
3117[
3118case "$have_ucs4_tcl" in
3119 yes) unicode_size="4" ;;
3120 *) unicode_size="2" ;;
3121esac
3122])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003123
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003124AH_TEMPLATE(Py_UNICODE_SIZE,
3125 [Define as the size of the unicode type.])
Georg Brandl52d168a2008-01-07 18:10:24 +00003126case "$unicode_size" in
3127 4) AC_DEFINE(Py_UNICODE_SIZE, 4) ;;
3128 *) AC_DEFINE(Py_UNICODE_SIZE, 2) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003129esac
3130
Martin v. Löwis11437992002-04-12 09:54:03 +00003131AH_TEMPLATE(PY_UNICODE_TYPE,
3132 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003133
Georg Brandl52d168a2008-01-07 18:10:24 +00003134# wchar_t is only usable if it maps to an unsigned type
3135if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003136 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00003137then
3138 PY_UNICODE_TYPE="wchar_t"
3139 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3140 [Define if you have a useable wchar_t type defined in wchar.h; useable
3141 means wchar_t must be an unsigned type with at least 16 bits. (see
3142 Include/unicodeobject.h).])
3143 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3144elif test "$ac_cv_sizeof_short" = "$unicode_size"
3145then
3146 PY_UNICODE_TYPE="unsigned short"
3147 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3148elif test "$ac_cv_sizeof_long" = "$unicode_size"
3149then
3150 PY_UNICODE_TYPE="unsigned long"
3151 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3152else
3153 PY_UNICODE_TYPE="no type found"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003154fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003155AC_MSG_RESULT($PY_UNICODE_TYPE)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003156
3157# check for endianness
3158AC_C_BIGENDIAN
3159
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003160# Check whether right shifting a negative integer extends the sign bit
3161# or fills with zeros (like the Cray J90, according to Tim Peters).
3162AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003163AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003164AC_TRY_RUN([
3165int main()
3166{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003167 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003168}
Guido van Rossum3065c942001-09-17 04:03:14 +00003169],
3170ac_cv_rshift_extends_sign=yes,
3171ac_cv_rshift_extends_sign=no,
3172ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003173AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3174if test "$ac_cv_rshift_extends_sign" = no
3175then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003176 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3177 [Define if i>>j for signed int i does not extend the sign bit
3178 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003179fi
3180
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003181# check for getc_unlocked and related locking functions
3182AC_MSG_CHECKING(for getc_unlocked() and friends)
3183AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3184AC_TRY_LINK([#include <stdio.h>],[
3185 FILE *f = fopen("/dev/null", "r");
3186 flockfile(f);
3187 getc_unlocked(f);
3188 funlockfile(f);
3189], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3190AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3191if test "$ac_cv_have_getc_unlocked" = yes
3192then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003193 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3194 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003195fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003196
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003197# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003198# save the value of LIBS so we don't actually link Python with readline
3199LIBS_no_readline=$LIBS
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003200AC_CHECK_LIB(readline, readline)
3201if test "$ac_cv_have_readline_readline" = no
3202then
3203 AC_CHECK_LIB(termcap, readline)
3204fi
3205
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003206# check for readline 2.1
3207AC_CHECK_LIB(readline, rl_callback_handler_install,
3208 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003209 [Define if you have readline 2.1]), , )
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003210
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003211# check for readline 2.2
3212AC_TRY_CPP([#include <readline/readline.h>],
3213have_readline=yes, have_readline=no)
3214if test $have_readline = yes
3215then
3216 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3217 [readline/readline.h],
3218 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3219 [Define if you have readline 2.2]), )
3220fi
3221
Martin v. Löwis0daad592001-09-30 21:09:59 +00003222# check for readline 4.0
3223AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003224 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003225 [Define if you have readline 4.0]), , )
Martin v. Löwis0daad592001-09-30 21:09:59 +00003226
Thomas Wouters89d996e2007-09-08 17:39:28 +00003227# also in 4.0
3228AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3229 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
3230 [Define if you have readline 4.0]), , )
3231
Guido van Rossum353ae582001-07-10 16:45:32 +00003232# check for readline 4.2
3233AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003234 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003235 [Define if you have readline 4.2]), , )
Guido van Rossum353ae582001-07-10 16:45:32 +00003236
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003237# also in readline 4.2
3238AC_TRY_CPP([#include <readline/readline.h>],
3239have_readline=yes, have_readline=no)
3240if test $have_readline = yes
3241then
3242 AC_EGREP_HEADER([extern int rl_catch_signals;],
3243 [readline/readline.h],
3244 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3245 [Define if you can turn off readline's signal handling.]), )
3246fi
3247
Martin v. Löwis82bca632006-02-10 20:49:30 +00003248# End of readline checks: restore LIBS
3249LIBS=$LIBS_no_readline
3250
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003251AC_MSG_CHECKING(for broken nice())
3252AC_CACHE_VAL(ac_cv_broken_nice, [
3253AC_TRY_RUN([
3254int main()
3255{
3256 int val1 = nice(1);
3257 if (val1 != -1 && val1 == nice(2))
3258 exit(0);
3259 exit(1);
3260}
Guido van Rossum3065c942001-09-17 04:03:14 +00003261],
3262ac_cv_broken_nice=yes,
3263ac_cv_broken_nice=no,
3264ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003265AC_MSG_RESULT($ac_cv_broken_nice)
3266if test "$ac_cv_broken_nice" = yes
3267then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003268 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3269 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003270fi
3271
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003272AC_MSG_CHECKING(for broken poll())
3273AC_TRY_RUN([
3274#include <poll.h>
3275
3276int main (void)
3277 {
3278 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
3279
3280 close (42);
3281
3282 int poll_test = poll (&poll_struct, 1, 0);
3283
3284 if (poll_test < 0)
3285 {
3286 exit(0);
3287 }
3288 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
3289 {
3290 exit(0);
3291 }
3292 else
3293 {
3294 exit(1);
3295 }
3296 }
3297],
3298ac_cv_broken_poll=yes,
3299ac_cv_broken_poll=no,
3300ac_cv_broken_poll=no)
3301AC_MSG_RESULT($ac_cv_broken_poll)
3302if test "$ac_cv_broken_poll" = yes
3303then
3304 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3305 [Define if poll() sets errno on invalid file descriptors.])
3306fi
3307
Brett Cannon43802422005-02-10 20:48:03 +00003308# Before we can test tzset, we need to check if struct tm has a tm_zone
3309# (which is not required by ISO C or UNIX spec) and/or if we support
3310# tzname[]
3311AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003312
Brett Cannon43802422005-02-10 20:48:03 +00003313# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003314AC_MSG_CHECKING(for working tzset())
3315AC_CACHE_VAL(ac_cv_working_tzset, [
3316AC_TRY_RUN([
3317#include <stdlib.h>
3318#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003319#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003320
3321#if HAVE_TZNAME
3322extern char *tzname[];
3323#endif
3324
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003325int main()
3326{
Brett Cannon18367812003-09-19 00:59:16 +00003327 /* Note that we need to ensure that not only does tzset(3)
3328 do 'something' with localtime, but it works as documented
3329 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003330 This includes making sure that tzname is set properly if
3331 tm->tm_zone does not exist since it is the alternative way
3332 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003333
3334 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003335 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003336 */
3337
Brett Cannon43802422005-02-10 20:48:03 +00003338 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003339 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3340
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003341 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003342 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003343 if (localtime(&groundhogday)->tm_hour != 0)
3344 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003345#if HAVE_TZNAME
3346 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3347 if (strcmp(tzname[0], "UTC") ||
3348 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3349 exit(1);
3350#endif
Brett Cannon18367812003-09-19 00:59:16 +00003351
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003352 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003353 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003354 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003355 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003356#if HAVE_TZNAME
3357 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3358 exit(1);
3359#endif
Brett Cannon18367812003-09-19 00:59:16 +00003360
3361 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3362 tzset();
3363 if (localtime(&groundhogday)->tm_hour != 11)
3364 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003365#if HAVE_TZNAME
3366 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3367 exit(1);
3368#endif
3369
3370#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00003371 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3372 exit(1);
3373 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3374 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003375#endif
Brett Cannon18367812003-09-19 00:59:16 +00003376
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003377 exit(0);
3378}
3379],
3380ac_cv_working_tzset=yes,
3381ac_cv_working_tzset=no,
3382ac_cv_working_tzset=no)])
3383AC_MSG_RESULT($ac_cv_working_tzset)
3384if test "$ac_cv_working_tzset" = yes
3385then
3386 AC_DEFINE(HAVE_WORKING_TZSET, 1,
3387 [Define if tzset() actually switches the local timezone in a meaningful way.])
3388fi
3389
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003390# Look for subsecond timestamps in struct stat
3391AC_MSG_CHECKING(for tv_nsec in struct stat)
3392AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3393AC_TRY_COMPILE([#include <sys/stat.h>], [
3394struct stat st;
3395st.st_mtim.tv_nsec = 1;
3396],
Martin v. Löwisa32c9942002-09-09 16:17:47 +00003397ac_cv_stat_tv_nsec=yes,
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003398ac_cv_stat_tv_nsec=no,
3399ac_cv_stat_tv_nsec=no))
3400AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3401if test "$ac_cv_stat_tv_nsec" = yes
3402then
3403 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3404 [Define if you have struct stat.st_mtim.tv_nsec])
3405fi
3406
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003407# Look for BSD style subsecond timestamps in struct stat
3408AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3409AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3410AC_TRY_COMPILE([#include <sys/stat.h>], [
3411struct stat st;
3412st.st_mtimespec.tv_nsec = 1;
3413],
3414ac_cv_stat_tv_nsec2=yes,
3415ac_cv_stat_tv_nsec2=no,
3416ac_cv_stat_tv_nsec2=no))
3417AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3418if test "$ac_cv_stat_tv_nsec2" = yes
3419then
3420 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3421 [Define if you have struct stat.st_mtimensec])
3422fi
3423
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003424# On HP/UX 11.0, mvwdelch is a block with a return statement
3425AC_MSG_CHECKING(whether mvwdelch is an expression)
3426AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3427AC_TRY_COMPILE([#include <curses.h>], [
3428 int rtn;
3429 rtn = mvwdelch(0,0,0);
3430], ac_cv_mvwdelch_is_expression=yes,
3431 ac_cv_mvwdelch_is_expression=no,
3432 ac_cv_mvwdelch_is_expression=yes))
3433AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3434
3435if test "$ac_cv_mvwdelch_is_expression" = yes
3436then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003437 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3438 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003439fi
3440
3441AC_MSG_CHECKING(whether WINDOW has _flags)
3442AC_CACHE_VAL(ac_cv_window_has_flags,
3443AC_TRY_COMPILE([#include <curses.h>], [
3444 WINDOW *w;
3445 w->_flags = 0;
3446], ac_cv_window_has_flags=yes,
3447 ac_cv_window_has_flags=no,
3448 ac_cv_window_has_flags=no))
3449AC_MSG_RESULT($ac_cv_window_has_flags)
3450
3451
3452if test "$ac_cv_window_has_flags" = yes
3453then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003454 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
3455 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003456fi
3457
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003458AC_MSG_CHECKING(for is_term_resized)
3459AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
3460 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
3461 AC_MSG_RESULT(yes),
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003462 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003463)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003464
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003465AC_MSG_CHECKING(for resize_term)
3466AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
3467 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
3468 AC_MSG_RESULT(yes),
Neal Norwitz865400f2003-03-21 01:42:58 +00003469 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003470)
3471
3472AC_MSG_CHECKING(for resizeterm)
3473AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
3474 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
3475 AC_MSG_RESULT(yes),
3476 AC_MSG_RESULT(no)
3477)
3478
Thomas Wouters89f507f2006-12-13 04:49:30 +00003479AC_MSG_CHECKING(for /dev/ptmx)
3480
3481if test -r /dev/ptmx
3482then
3483 AC_MSG_RESULT(yes)
3484 AC_DEFINE(HAVE_DEV_PTMX, 1,
3485 [Define if we have /dev/ptmx.])
3486else
3487 AC_MSG_RESULT(no)
3488fi
3489
3490AC_MSG_CHECKING(for /dev/ptc)
3491
3492if test -r /dev/ptc
3493then
3494 AC_MSG_RESULT(yes)
3495 AC_DEFINE(HAVE_DEV_PTC, 1,
3496 [Define if we have /dev/ptc.])
3497else
3498 AC_MSG_RESULT(no)
3499fi
Neal Norwitz865400f2003-03-21 01:42:58 +00003500
Thomas Wouters477c8d52006-05-27 19:21:47 +00003501AC_MSG_CHECKING(for %zd printf() format support)
3502AC_TRY_RUN([#include <stdio.h>
3503#include <stddef.h>
3504#include <string.h>
3505
Christian Heimes2c181612007-12-17 20:04:13 +00003506#ifdef HAVE_SYS_TYPES_H
3507#include <sys/types.h>
3508#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00003509
3510#ifdef HAVE_SSIZE_T
3511typedef ssize_t Py_ssize_t;
3512#elif SIZEOF_VOID_P == SIZEOF_LONG
3513typedef long Py_ssize_t;
3514#else
3515typedef int Py_ssize_t;
3516#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00003517
Christian Heimes2c181612007-12-17 20:04:13 +00003518int main()
3519{
3520 char buffer[256];
3521
Thomas Wouters477c8d52006-05-27 19:21:47 +00003522 if(sprintf(buffer, "%zd", (size_t)123) < 0)
3523 return 1;
3524
Thomas Wouters89f507f2006-12-13 04:49:30 +00003525 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00003526 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00003527
3528 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
3529 return 1;
3530
3531 if (strcmp(buffer, "-123"))
3532 return 1;
3533
Thomas Wouters477c8d52006-05-27 19:21:47 +00003534 return 0;
3535}],
3536[AC_MSG_RESULT(yes)
3537 AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
3538 AC_MSG_RESULT(no))
3539
Martin v. Löwis01c04012002-11-11 14:58:44 +00003540AC_CHECK_TYPE(socklen_t,,
3541 AC_DEFINE(socklen_t,int,
3542 Define to `int' if <sys/socket.h> does not define.),[
3543#ifdef HAVE_SYS_TYPES_H
3544#include <sys/types.h>
3545#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00003546#ifdef HAVE_SYS_SOCKET_H
3547#include <sys/socket.h>
3548#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00003549])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003550
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00003551AC_SUBST(THREADHEADERS)
3552
3553for h in `(cd $srcdir;echo Python/thread_*.h)`
3554do
3555 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
3556done
3557
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003558AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00003559SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00003560AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003561for dir in $SRCDIRS; do
3562 if test ! -d $dir; then
3563 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00003564 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003565done
3566AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00003567
Guido van Rossum627b2d71993-12-24 10:39:16 +00003568# generate output files
Martin v. Löwis88afe662002-10-26 13:47:44 +00003569AC_CONFIG_FILES(Makefile.pre Modules/Setup.config)
3570AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00003571
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003572echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00003573if test ! -f Modules/Setup
3574then
3575 cp $srcdir/Modules/Setup.dist Modules/Setup
3576fi
3577
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003578echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00003579if test ! -f Modules/Setup.local
3580then
3581 echo "# Edit this file for local setup changes" >Modules/Setup.local
3582fi
3583
3584echo "creating Makefile"
3585$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
3586 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00003587 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00003588mv config.c Modules