blob: 855fa3bc6620223eade137824df0058557a7bfc6 [file] [log] [blame]
Benjamin Petersonfbeb6b62008-05-26 16:04:49 +00001dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
Martin v. Löwis88afe662002-10-26 13:47:44 +00004
5# Set VERSION so we only need to edit in one place (i.e., here)
Benjamin Peterson46ea4f72009-06-27 21:40:27 +00006m4_define(PYTHON_VERSION, 3.2)
Martin v. Löwis88afe662002-10-26 13:47:44 +00007
Alexandre Vassalottib89910f2009-07-18 00:33:23 +00008dnl Some m4 magic to ensure that the configure script is generated
9dnl by the correct autoconf version.
10m4_define([version_required],
11[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]), [$1]), 0,
12 [],
13 [m4_fatal([Autoconf version $1 is required for Python], 63)])
14])
Matthias Kloseb9621712010-04-24 17:59:49 +000015version_required(2.65)
Alexandre Vassalottib89910f2009-07-18 00:33:23 +000016
Guido van Rossum76be6ed1995-01-02 18:33:54 +000017AC_REVISION($Revision$)
Georg Brandle2e15612009-05-20 18:25:10 +000018AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
Martin v. Löwis88afe662002-10-26 13:47:44 +000019AC_CONFIG_SRCDIR([Include/object.h])
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000020AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +000021
Benjamin Petersond23f8222009-04-05 19:13:16 +000022dnl Ensure that if prefix is specified, it does not end in a slash. If
23dnl it does, we get path names containing '//' which is both ugly and
24dnl can cause trouble.
25
26dnl Last slash shouldn't be stripped if prefix=/
27if test "$prefix" != "/"; then
28 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
29fi
30
Martin v. Löwis8316feb2003-06-14 07:48:07 +000031dnl This is for stuff that absolutely must end up in pyconfig.h.
32dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000033AH_TOP([
34#ifndef Py_PYCONFIG_H
35#define Py_PYCONFIG_H
36])
Martin v. Löwis11437992002-04-12 09:54:03 +000037AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000038/* Define the macros needed if on a UnixWare 7.x system. */
39#if defined(__USLC__) && defined(__SCO_VERSION__)
40#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
41#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000042
43#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000044])
45
Martin v. Löwis8316feb2003-06-14 07:48:07 +000046# We don't use PACKAGE_ variables, and they cause conflicts
47# with other autoconf-based packages that include Python.h
48grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
49rm confdefs.h
50mv confdefs.h.new confdefs.h
51
Guido van Rossum642b6781997-07-19 19:35:41 +000052AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000053VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000054
Martin v. Löwis1142de32002-03-29 16:28:31 +000055AC_SUBST(SOVERSION)
56SOVERSION=1.0
57
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000058# The later defininition of _XOPEN_SOURCE disables certain features
59# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
60AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
61
Martin v. Löwisbcd93962003-05-03 10:32:18 +000062# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
63# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
64# them.
65AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
66
Andrew MacIntyreabccf412003-07-02 13:53:25 +000067# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
68# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
69# them.
70AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
71
Martin v. Löwisd6320502004-08-12 13:45:08 +000072# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
73# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
74AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
75
Georg Brandlfcaf9102008-07-16 02:17:56 +000076# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
77# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
78# them.
79AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
80
81
Martin v. Löwise981a4e2002-11-11 13:26:51 +000082define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000083
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +000084# Arguments passed to configure.
85AC_SUBST(CONFIG_ARGS)
86CONFIG_ARGS="$ac_configure_args"
87
Ronald Oussoren8af24c12010-02-07 12:03:42 +000088AC_MSG_CHECKING([for --enable-universalsdk])
Thomas Wouters477c8d52006-05-27 19:21:47 +000089AC_ARG_ENABLE(universalsdk,
Matthias Klose2b8733f2010-04-25 18:34:36 +000090 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
Thomas Wouters477c8d52006-05-27 19:21:47 +000091[
92 case $enableval in
93 yes)
94 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren8af24c12010-02-07 12:03:42 +000095 if test ! -d "${enableval}"
96 then
97 enableval=/
98 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +000099 ;;
100 esac
101 case $enableval in
102 no)
103 UNIVERSALSDK=
104 enable_universalsdk=
105 ;;
106 *)
107 UNIVERSALSDK=$enableval
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000108 if test ! -d "${UNIVERSALSDK}"
109 then
110 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
111 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000112 ;;
113 esac
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000114
Thomas Wouters477c8d52006-05-27 19:21:47 +0000115],[
116 UNIVERSALSDK=
117 enable_universalsdk=
118])
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000119if test -n "${UNIVERSALSDK}"
120then
121 AC_MSG_RESULT(${UNIVERSALSDK})
122else
123 AC_MSG_RESULT(no)
124fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000125AC_SUBST(UNIVERSALSDK)
126
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000127AC_SUBST(ARCH_RUN_32BIT)
128
Georg Brandlfcaf9102008-07-16 02:17:56 +0000129UNIVERSAL_ARCHS="32-bit"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000130AC_SUBST(LIPO_32BIT_FLAGS)
Georg Brandlfcaf9102008-07-16 02:17:56 +0000131AC_MSG_CHECKING(for --with-universal-archs)
132AC_ARG_WITH(universal-archs,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000133 AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")]),
Georg Brandlfcaf9102008-07-16 02:17:56 +0000134[
135 AC_MSG_RESULT($withval)
136 UNIVERSAL_ARCHS="$withval"
137],
138[
139 AC_MSG_RESULT(32-bit)
140])
141
142
143
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000144AC_ARG_WITH(framework-name,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000145 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
Matthias Klosec80c93f2010-04-24 17:04:35 +0000146 [specify an alternate name of the framework built with --enable-framework]),
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000147[
148 PYTHONFRAMEWORK=${withval}
149 PYTHONFRAMEWORKDIR=${withval}.framework
150 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
151 ],[
152 PYTHONFRAMEWORK=Python
153 PYTHONFRAMEWORKDIR=Python.framework
154 PYTHONFRAMEWORKIDENTIFIER=org.python.python
155])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000156dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000157AC_ARG_ENABLE(framework,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000158 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000159[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000160 case $enableval in
161 yes)
162 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000163 esac
164 case $enableval in
165 no)
166 PYTHONFRAMEWORK=
167 PYTHONFRAMEWORKDIR=no-framework
168 PYTHONFRAMEWORKPREFIX=
169 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000170 FRAMEWORKINSTALLFIRST=
171 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000172 FRAMEWORKALTINSTALLFIRST=
173 FRAMEWORKALTINSTALLLAST=
174 if test "x${prefix}" = "xNONE"; then
175 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
176 else
177 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
178 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000179 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000180 ;;
181 *)
182 PYTHONFRAMEWORKPREFIX=$enableval
Jack Jansen127e56e2001-09-11 14:41:54 +0000183 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Thomas Wouters477c8d52006-05-27 19:21:47 +0000184 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussorenf6ccbf62009-06-02 10:55:56 +0000185 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure "
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000186 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
187 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000188
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000189 if test "x${prefix}" = "xNONE" ; then
190 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
191 else
192 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
193 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000194 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Thomas Wouters477c8d52006-05-27 19:21:47 +0000195
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000196 # Add files for Mac specific code to the list of output
Thomas Wouters477c8d52006-05-27 19:21:47 +0000197 # files:
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000198 AC_CONFIG_FILES(Mac/Makefile)
199 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000200 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
201 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000202 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000203 ],[
204 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000205 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000206 PYTHONFRAMEWORKPREFIX=
207 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000208 FRAMEWORKINSTALLFIRST=
209 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000210 FRAMEWORKALTINSTALLFIRST=
211 FRAMEWORKALTINSTALLLAST=
212 if test "x${prefix}" = "xNONE" ; then
213 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
214 else
215 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
216 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000217 enable_framework=
Georg Brandlfcaf9102008-07-16 02:17:56 +0000218
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000219])
220AC_SUBST(PYTHONFRAMEWORK)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000221AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000222AC_SUBST(PYTHONFRAMEWORKDIR)
223AC_SUBST(PYTHONFRAMEWORKPREFIX)
224AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000225AC_SUBST(FRAMEWORKINSTALLFIRST)
226AC_SUBST(FRAMEWORKINSTALLLAST)
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000227AC_SUBST(FRAMEWORKALTINSTALLFIRST)
228AC_SUBST(FRAMEWORKALTINSTALLLAST)
229AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000230
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000231##AC_ARG_WITH(dyld,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000232## AS_HELP_STRING([--with-dyld],
Matthias Klosec80c93f2010-04-24 17:04:35 +0000233## [Use (OpenStep|Rhapsody) dynamic linker]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000234##
Guido van Rossumb418f891996-07-30 18:06:02 +0000235# Set name for machine-dependent library files
236AC_SUBST(MACHDEP)
237AC_MSG_CHECKING(MACHDEP)
238if test -z "$MACHDEP"
239then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000240 ac_sys_system=`uname -s`
Benjamin Peterson8719ad52009-09-11 22:24:02 +0000241 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000242 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000243 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000244 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000245 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000246 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000247 ac_md_system=`echo $ac_sys_system |
248 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
249 ac_md_release=`echo $ac_sys_release |
Guido van Rossum67b26592001-10-20 14:21:45 +0000250 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +0000251 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000252
Guido van Rossumbcd91e01997-03-20 20:46:29 +0000253 case $MACHDEP in
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000254 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000255 darwin*) MACHDEP="darwin";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000256 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000257 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000258 esac
259fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000260
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000261# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
262# disable features if it is defined, without any means to access these
263# features as extensions. For these systems, we skip the definition of
264# _XOPEN_SOURCE. Before adding a system to the list to gain access to
265# some feature, make sure there is no alternative way to access this
266# feature. Also, when using wildcards, make sure you have verified the
267# need for not defining _XOPEN_SOURCE on all systems matching the
268# wildcard, and that the wildcard does not include future systems
269# (which may remove their limitations).
270dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
271case $ac_sys_system/$ac_sys_release in
272 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
273 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000274 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis19ed3c82010-02-15 21:45:06 +0000275 # In addition, Stefan Krah confirms that issue #1244610 exists through
276 # OpenBSD 4.6, but is fixed in 4.7.
277 OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0123456@:>@)
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000278 define_xopen_source=no
279 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
280 # also defined. This can be overridden by defining _BSD_SOURCE
281 # As this has a different meaning on Linux, only define it on OpenBSD
282 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
283 ;;
Martin v. Löwis19ed3c82010-02-15 21:45:06 +0000284 OpenBSD/4.@<:@789@:>@)
Martin v. Löwis7671efc2010-02-15 08:35:16 +0000285 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
286 # also defined. This can be overridden by defining _BSD_SOURCE
287 # As this has a different meaning on Linux, only define it on OpenBSD
288 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
289 ;;
Thomas Wouters89f507f2006-12-13 04:49:30 +0000290 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
291 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
292 # Marc Recht
Benjamin Petersonf608c612008-11-16 18:33:53 +0000293 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 +0000294 define_xopen_source=no;;
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000295 # On Solaris 2.6, sys/wait.h is inconsistent in the usage
296 # of union __?sigval. Reported by Stuart Bishop.
297 SunOS/5.6)
298 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000299 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
300 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000301 # Reconfirmed for 7.1.4 by Martin v. Loewis.
302 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000303 define_xopen_source=no;;
304 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000305 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000306 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000307 define_xopen_source=no;;
Martin v. Löwisb37509b2008-11-04 20:45:29 +0000308 # On FreeBSD 4, the math functions C89 does not cover are never defined
309 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
310 FreeBSD/4.*)
311 define_xopen_source=no;;
312 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
313 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
314 # identifies itself as Darwin/7.*
315 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
316 # disables platform specific features beyond repair.
317 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
318 # has no effect, don't bother defining them
319 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000320 define_xopen_source=no;;
Ronald Oussoren92fb9412010-03-09 06:40:19 +0000321 Darwin/1@<:@0-9@:>@.*)
Ronald Oussorenb8f11a62010-03-08 07:02:03 +0000322 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000323 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
324 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
325 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000326 AIX/4)
327 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000328 AIX/5)
329 if test `uname -r` -eq 1; then
330 define_xopen_source=no
331 fi
332 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000333 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
334 # defining NI_NUMERICHOST.
335 QNX/6.3.2)
336 define_xopen_source=no
337 ;;
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000338
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000339esac
340
341if test $define_xopen_source = yes
342then
Skip Montanarof0d5f792004-08-15 14:08:23 +0000343 # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
344 # defined precisely as g++ defines it
Martin v. Löwis7dece662005-11-26 11:38:24 +0000345 # Furthermore, on Solaris 10, XPG6 requires the use of a C99
346 # compiler
Skip Montanarof0d5f792004-08-15 14:08:23 +0000347 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis7dece662005-11-26 11:38:24 +0000348 SunOS/5.8|SunOS/5.9|SunOS/5.10)
Skip Montanarof0d5f792004-08-15 14:08:23 +0000349 AC_DEFINE(_XOPEN_SOURCE, 500,
350 Define to the level of X/Open that your system supports)
351 ;;
352 *)
353 AC_DEFINE(_XOPEN_SOURCE, 600,
354 Define to the level of X/Open that your system supports)
355 ;;
356 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000357
358 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
359 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
360 # several APIs are not declared. Since this is also needed in some
361 # cases for HP-UX, we define it globally.
Martin v. Löwis7dece662005-11-26 11:38:24 +0000362 # except for Solaris 10, where it must not be defined,
363 # as it implies XPG4.2
364 case $ac_sys_system/$ac_sys_release in
365 SunOS/5.10)
366 ;;
367 *)
368 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
369 Define to activate Unix95-and-earlier features)
370 ;;
371 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000372
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000373 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
374
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000375fi
376
Guido van Rossum91922671997-10-09 20:24:13 +0000377#
378# SGI compilers allow the specification of the both the ABI and the
379# ISA on the command line. Depending on the values of these switches,
380# different and often incompatable code will be generated.
381#
382# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
383# thus supply support for various ABI/ISA combinations. The MACHDEP
384# variable is also adjusted.
385#
386AC_SUBST(SGI_ABI)
387if test ! -z "$SGI_ABI"
388then
389 CC="cc $SGI_ABI"
390 LDFLAGS="$SGI_ABI $LDFLAGS"
391 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
392fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000393AC_MSG_RESULT($MACHDEP)
394
Jack Jansen6b08a402004-06-03 12:41:45 +0000395# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
396# it may influence the way we can build extensions, so distutils
397# needs to check it
398AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000399AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000400CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000401EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000402
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000403AC_MSG_CHECKING(machine type as reported by uname -m)
404ac_sys_machine=`uname -m`
405AC_MSG_RESULT($ac_sys_machine)
406
Guido van Rossum627b2d71993-12-24 10:39:16 +0000407# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000408
409# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
410# for debug/optimization stuff. BASECFLAGS is for flags that are required
411# just to get things to compile and link. Users are free to override OPT
412# when running configure or make. The build should not break if they do.
413# BASECFLAGS should generally not be messed with, however.
414
415# XXX shouldn't some/most/all of this code be merged with the stuff later
416# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000417AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000418AC_ARG_WITH(gcc,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000419 AS_HELP_STRING([--without-gcc], [never use gcc]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000420[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000421 case $withval in
Benjamin Peterson960cf0f2009-01-09 04:11:44 +0000422 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000423 without_gcc=yes;;
424 yes) CC=gcc
425 without_gcc=no;;
426 *) CC=$withval
427 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000428 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000429 case $ac_sys_system in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000430 AIX*) CC=cc_r
431 without_gcc=;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000432 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000433 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000434AC_MSG_RESULT($without_gcc)
435
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000436# If the user switches compilers, we can't believe the cache
437if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
438then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000439 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
440(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000441fi
442
Victor Stinner00d6a1d2010-03-25 01:02:29 +0000443save_CFLAGS=$CFLAGS
Guido van Rossum627b2d71993-12-24 10:39:16 +0000444AC_PROG_CC
Victor Stinner00d6a1d2010-03-25 01:02:29 +0000445CFLAGS=$save_CFLAGS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000446
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000447AC_SUBST(CXX)
448AC_SUBST(MAINCC)
449AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
450AC_ARG_WITH(cxx_main,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000451 AS_HELP_STRING([--with-cxx-main=<compiler>],
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000452 [compile main() and link python executable with C++ compiler]),
453[
454
455 case $withval in
456 no) with_cxx_main=no
457 MAINCC='$(CC)';;
458 yes) with_cxx_main=yes
459 MAINCC='$(CXX)';;
460 *) with_cxx_main=yes
461 MAINCC=$withval
462 if test -z "$CXX"
463 then
464 CXX=$withval
465 fi;;
466 esac], [
467 with_cxx_main=no
468 MAINCC='$(CC)'
469])
470AC_MSG_RESULT($with_cxx_main)
471
472preset_cxx="$CXX"
473if test -z "$CXX"
474then
475 case "$CC" in
476 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
477 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
478 esac
479 if test "$CXX" = "notfound"
480 then
481 CXX=""
482 fi
483fi
484if test -z "$CXX"
485then
486 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
487 if test "$CXX" = "notfound"
488 then
489 CXX=""
490 fi
491fi
492if test "$preset_cxx" != "$CXX"
493then
494 AC_MSG_WARN([
495
496 By default, distutils will build C++ extension modules with "$CXX".
497 If this is not intended, then set CXX on the configure command line.
498 ])
499fi
500
501
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000502# checks for UNIX variants that set C preprocessor variables
503AC_AIX
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000504
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000505# Check for unsupported systems
506case $ac_sys_system/$ac_sys_release in
Guido van Rossumcd16bf62007-06-13 18:07:49 +0000507atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000508 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
509 echo See README for details.
510 exit 1;;
511esac
512
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000513AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000514AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000515AC_ARG_WITH(suffix,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000516 AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000517[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000518 case $withval in
519 no) EXEEXT=;;
520 yes) EXEEXT=.exe;;
521 *) EXEEXT=$withval;;
522 esac])
523AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000524
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000525# Test whether we're running on a non-case-sensitive system, in which
526# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000527AC_SUBST(BUILDEXEEXT)
528AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000529if test ! -d CaseSensitiveTestDir; then
530mkdir CaseSensitiveTestDir
531fi
532
533if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000534then
Jack Jansen1999ef42001-12-06 21:47:20 +0000535 AC_MSG_RESULT(yes)
536 BUILDEXEEXT=.exe
537else
538 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000539 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000540fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000541rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000542
Guido van Rossumdd997f71998-10-07 19:58:26 +0000543case $MACHDEP in
544bsdos*)
545 case $CC in
546 gcc) CC="$CC -D_HAVE_BSDI";;
547 esac;;
548esac
549
Guido van Rossum84561611997-08-21 00:08:11 +0000550case $ac_sys_system in
551hp*|HP*)
552 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000553 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000554 esac;;
555esac
556
Martin v. Löwise8964d42001-03-06 12:09:07 +0000557
Neil Schemenauer61c51152001-01-26 16:18:16 +0000558AC_SUBST(LIBRARY)
559AC_MSG_CHECKING(LIBRARY)
560if test -z "$LIBRARY"
561then
562 LIBRARY='libpython$(VERSION).a'
563fi
564AC_MSG_RESULT($LIBRARY)
565
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000566# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000567# name of the library into which to insert object files). BLDLIBRARY is also
568# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
569# is blank as the main program is not linked directly against LDLIBRARY.
570# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
571# systems without shared libraries, LDLIBRARY is the same as LIBRARY
572# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
573# DLLLIBRARY is the shared (i.e., DLL) library.
574#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000575# RUNSHARED is used to run shared python without installed libraries
576#
577# INSTSONAME is the name of the shared library that will be use to install
578# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000579AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000580AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000581AC_SUBST(BLDLIBRARY)
582AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000583AC_SUBST(INSTSONAME)
584AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000585LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000586BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000587INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000588DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000589LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000590RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000591
Guido van Rossumfb842551997-08-06 23:42:07 +0000592# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000593# If CXX is set, and if it is needed to link a main function that was
594# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
595# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000596# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000597# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000598AC_SUBST(LINKCC)
599AC_MSG_CHECKING(LINKCC)
600if test -z "$LINKCC"
601then
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000602 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000603 case $ac_sys_system in
604 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000605 exp_extra="\"\""
606 if test $ac_sys_release -ge 5 -o \
607 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
608 exp_extra="."
609 fi
610 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000611 QNX*)
612 # qcc must be used because the other compilers do not
613 # support -N.
614 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000615 esac
616fi
617AC_MSG_RESULT($LINKCC)
618
Tarek Ziadébe720e02009-05-09 11:55:12 +0000619# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
620# make sure we default having it set to "no": this is used by
621# distutils.unixccompiler to know if it should add --enable-new-dtags
622# to linker command lines, and failing to detect GNU ld simply results
623# in the same bahaviour as before.
624AC_SUBST(GNULD)
625AC_MSG_CHECKING(for GNU ld)
626ac_prog=ld
627if test "$GCC" = yes; then
628 ac_prog=`$CC -print-prog-name=ld`
629fi
630case `"$ac_prog" -V 2>&1 < /dev/null` in
631 *GNU*)
632 GNULD=yes;;
633 *)
634 GNULD=no;;
635esac
636AC_MSG_RESULT($GNULD)
637
Martin v. Löwis1142de32002-03-29 16:28:31 +0000638AC_MSG_CHECKING(for --enable-shared)
639AC_ARG_ENABLE(shared,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000640 AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000641
Martin v. Löwis1142de32002-03-29 16:28:31 +0000642if test -z "$enable_shared"
643then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000644 case $ac_sys_system in
Antoine Pitrou6103ab12009-10-24 20:11:21 +0000645 CYGWIN*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000646 enable_shared="yes";;
647 *)
648 enable_shared="no";;
649 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000650fi
651AC_MSG_RESULT($enable_shared)
652
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000653AC_MSG_CHECKING(for --enable-profiling)
654AC_ARG_ENABLE(profiling,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000655 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]),
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000656[ac_save_cc="$CC"
657 CC="$CC -pg"
658 AC_TRY_RUN([int main() { return 0; }],
659 ac_enable_profiling="yes",
660 ac_enable_profiling="no",
661 ac_enable_profiling="no")
662 CC="$ac_save_cc"])
663AC_MSG_RESULT($ac_enable_profiling)
664
665case "$ac_enable_profiling" in
666 "yes")
667 BASECFLAGS="-pg $BASECFLAGS"
668 LDFLAGS="-pg $LDFLAGS"
669 ;;
670esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000671
672AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000673
Guido van Rossumb8552162001-09-05 14:58:11 +0000674# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
675# library that we build, but we do not want to link against it (we
676# will find it with a -framework option). For this reason there is an
677# extra variable BLDLIBRARY against which Python and the extension
678# modules are linked, BLDLIBRARY. This is normally the same as
679# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000680if test "$enable_framework"
681then
682 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000683 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000684 BLDLIBRARY=''
685else
686 BLDLIBRARY='$(LDLIBRARY)'
687fi
688
Martin v. Löwis1142de32002-03-29 16:28:31 +0000689# Other platforms follow
690if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000691 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000692 case $ac_sys_system in
Martin v. Löwis1142de32002-03-29 16:28:31 +0000693 CYGWIN*)
694 LDLIBRARY='libpython$(VERSION).dll.a'
695 DLLLIBRARY='libpython$(VERSION).dll'
696 ;;
697 SunOS*)
698 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000699 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000700 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000701 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000702 ;;
Martin v. Löwis86d66262006-02-17 08:40:11 +0000703 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000704 LDLIBRARY='libpython$(VERSION).so'
705 BLDLIBRARY='-L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000706 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000707 case $ac_sys_system in
708 FreeBSD*)
709 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
710 ;;
711 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000712 INSTSONAME="$LDLIBRARY".$SOVERSION
713 ;;
714 hp*|HP*)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000715 case `uname -m` in
716 ia64)
717 LDLIBRARY='libpython$(VERSION).so'
718 ;;
719 *)
720 LDLIBRARY='libpython$(VERSION).sl'
721 ;;
722 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000723 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000724 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000725 ;;
726 OSF*)
727 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000728 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000729 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000730 ;;
Georg Brandlb1441c72009-01-03 22:33:39 +0000731 Darwin*)
732 LDLIBRARY='libpython$(VERSION).dylib'
733 BLDLIBRARY='-L. -lpython$(VERSION)'
734 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
735 ;;
736
Martin v. Löwis1142de32002-03-29 16:28:31 +0000737 esac
Jason Tishler30765592003-09-04 11:04:06 +0000738else # shared is disabled
739 case $ac_sys_system in
740 CYGWIN*)
741 BLDLIBRARY='$(LIBRARY)'
742 LDLIBRARY='libpython$(VERSION).dll.a'
743 ;;
744 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000745fi
746
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000747AC_MSG_RESULT($LDLIBRARY)
748
Guido van Rossum627b2d71993-12-24 10:39:16 +0000749AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000750AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000751AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000752
Tarek Ziadé5662d3e2009-05-07 21:24:43 +0000753# tweak ARFLAGS only if the user didn't set it on the command line
754AC_SUBST(ARFLAGS)
755if test -z "$ARFLAGS"
756then
757 ARFLAGS="rc"
758fi
759
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000760AC_SUBST(SVNVERSION)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000761AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000762if test $SVNVERSION = found
763then
764 SVNVERSION="svnversion \$(srcdir)"
765else
Benjamin Petersonf53eec82009-05-23 19:36:27 +0000766 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000767fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000768
Neil Schemenauera42c8272001-03-31 00:01:55 +0000769case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000770bsdos*|hp*|HP*)
771 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000772 if test -z "$INSTALL"
773 then
774 INSTALL="${srcdir}/install-sh -c"
775 fi
776esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000777AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000778
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000779# Not every filesystem supports hard links
780AC_SUBST(LN)
781if test -z "$LN" ; then
782 case $ac_sys_system in
Guido van Rossumaef734b2001-01-10 21:09:12 +0000783 CYGWIN*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000784 *) LN=ln;;
785 esac
786fi
787
Fred Drake9f715822001-07-11 06:27:00 +0000788# Check for --with-pydebug
789AC_MSG_CHECKING(for --with-pydebug)
790AC_ARG_WITH(pydebug,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000791 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000792[
Fred Drake9f715822001-07-11 06:27:00 +0000793if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000794then
795 AC_DEFINE(Py_DEBUG, 1,
796 [Define if you want to build an interpreter with many run-time checks.])
797 AC_MSG_RESULT(yes);
798 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +0000799else AC_MSG_RESULT(no); Py_DEBUG='false'
800fi],
801[AC_MSG_RESULT(no)])
802
Skip Montanarodecc6a42003-01-01 20:07:49 +0000803# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
804# merged with this chunk of code?
805
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000806# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +0000807# ------------------------
808# (The following bit of code is complicated enough - please keep things
809# indented properly. Just pretend you're editing Python code. ;-)
810
811# There are two parallel sets of case statements below, one that checks to
812# see if OPT was set and one that does BASECFLAGS setting based upon
813# compiler and platform. BASECFLAGS tweaks need to be made even if the
814# user set OPT.
815
816# tweak OPT based on compiler and platform, only if the user didn't set
817# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +0000818AC_SUBST(OPT)
Benjamin Peterson65b4ec52010-03-23 21:02:34 +0000819if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +0000820then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000821 case $GCC in
822 yes)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000823 if test "$CC" != 'g++' ; then
824 STRICT_PROTO="-Wstrict-prototypes"
825 fi
Christian Heimes38053212007-12-14 01:24:44 +0000826 # For gcc 4.x we need to use -fwrapv so lets check if its supported
827 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
828 WRAP="-fwrapv"
829 fi
Skip Montanarodecc6a42003-01-01 20:07:49 +0000830 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000831 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000832 if test "$Py_DEBUG" = 'true' ; then
833 # Optimization messes up debuggers, so turn it off for
834 # debug builds.
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000835 OPT="-g -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +0000836 else
Christian Heimes38053212007-12-14 01:24:44 +0000837 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000838 fi
839 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000840 *)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000841 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000842 ;;
Fred Drake9f715822001-07-11 06:27:00 +0000843 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000844 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000845 SCO_SV*) OPT="$OPT -m486 -DSCO5"
846 ;;
847 esac
Fred Drake9f715822001-07-11 06:27:00 +0000848 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000849
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000850 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +0000851 OPT="-O"
852 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000853 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000854fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000855
Skip Montanarodecc6a42003-01-01 20:07:49 +0000856AC_SUBST(BASECFLAGS)
Georg Brandlfcaf9102008-07-16 02:17:56 +0000857
858# The -arch flags for universal builds on OSX
859UNIVERSAL_ARCH_FLAGS=
860AC_SUBST(UNIVERSAL_ARCH_FLAGS)
861
Skip Montanarodecc6a42003-01-01 20:07:49 +0000862# tweak BASECFLAGS based on compiler and platform
863case $GCC in
864yes)
Benjamin Petersone6c9d242010-03-30 17:34:47 +0000865 # Python doesn't violate C99 aliasing rules, but older versions of
866 # GCC produce warnings for legal Python code. Enable
867 # -fno-strict-aliasing on versions of GCC that support but produce
868 # warnings. See Issue3326
869 AC_MSG_CHECKING(whether $CC accepts and needs -fno-strict-aliasing)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000870 ac_save_cc="$CC"
871 CC="$CC -fno-strict-aliasing"
Benjamin Petersone6c9d242010-03-30 17:34:47 +0000872 save_CFLAGS="$CFLAGS"
873 AC_CACHE_VAL(ac_cv_no_strict_aliasing,
874 AC_TRY_COMPILE([],[int main() { return 0; }],
875 CC="$ac_save_cc -fstrict-aliasing"
876 CFLAGS="$CFLAGS -Werror -Wstrict-aliasing"
877 AC_TRY_COMPILE([],[void f(int **x) {} int main() { double *x; f((int **) &x); return 0; }],
878 ac_cv_no_strict_aliasing=no,
879 ac_cv_no_strict_aliasing=yes),
880 ac_cv_no_strict_aliasing=no))
881 CFLAGS="$save_CFLAGS"
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000882 CC="$ac_save_cc"
Benjamin Petersone6c9d242010-03-30 17:34:47 +0000883 AC_MSG_RESULT($ac_cv_no_strict_aliasing)
884 if test $ac_cv_no_strict_aliasing = yes
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000885 then
886 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
887 fi
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +0000888
889 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
890 # support. Without this, treatment of subnormals doesn't follow
891 # the standard.
892 case $ac_sys_machine in
893 alpha*)
894 BASECFLAGS="$BASECFLAGS -mieee"
895 ;;
896 esac
897
Skip Montanarodecc6a42003-01-01 20:07:49 +0000898 case $ac_sys_system in
899 SCO_SV*)
900 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
901 ;;
902 # is there any other compiler on Darwin besides gcc?
903 Darwin*)
Christian Heimesb186d002008-03-18 15:15:01 +0000904 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
905 # used to be here, but non-Apple gcc doesn't accept them.
Ronald Oussoren666028b2010-04-18 19:07:43 +0000906 if test "${CC}" = gcc
907 then
908 AC_MSG_CHECKING(which compiler should be used)
909 case "${UNIVERSALSDK}" in
910 */MacOSX10.4u.sdk)
911 # Build using 10.4 SDK, force usage of gcc when the
912 # compiler is gcc, otherwise the user will get very
913 # confusing error messages when building on OSX 10.6
914 CC=gcc-4.0
915 CPP=cpp-4.0
916 ;;
917 esac
918 AC_MSG_RESULT($CC)
919 fi
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000920
921
Thomas Wouters477c8d52006-05-27 19:21:47 +0000922 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +0000923 UNIVERSAL_ARCH_FLAGS=""
924 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
925 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000926 ARCH_RUN_32BIT=""
Benjamin Peterson051858e2010-04-11 22:14:02 +0000927 LIPO_32BIT_FLAGS=""
Georg Brandlfcaf9102008-07-16 02:17:56 +0000928 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
929 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000930 LIPO_32BIT_FLAGS=""
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000931 ARCH_RUN_32BIT="true"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000932
933 elif test "$UNIVERSAL_ARCHS" = "all" ; then
934 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000935 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +0000936 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000937
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000938 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
939 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000940 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +0000941 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000942
943 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
944 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000945 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +0000946 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000947
Georg Brandlfcaf9102008-07-16 02:17:56 +0000948 else
Ronald Oussoren74f29b42009-09-20 20:09:26 +0000949 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
Georg Brandlfcaf9102008-07-16 02:17:56 +0000950
951 fi
952
953
Ronald Oussoren666028b2010-04-18 19:07:43 +0000954 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
955 if test "${UNIVERSALSDK}" != "/"
956 then
957 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
958 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Ronald Oussoren712979d2010-04-20 19:51:33 +0000959 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000960 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000961 fi
962
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000963 # Calculate the right deployment target for this build.
964 #
965 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
966 if test ${cur_target} '>' 10.2; then
967 cur_target=10.3
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000968 if test ${enable_universalsdk}; then
969 if test "${UNIVERSAL_ARCHS}" = "all"; then
970 # Ensure that the default platform for a
971 # 4-way universal build is OSX 10.5,
972 # that's the first OS release where
973 # 4-way builds make sense.
974 cur_target='10.5'
Ronald Oussoren3c064c12009-09-08 07:12:42 +0000975
976 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
977 cur_target='10.5'
978
979 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
980 cur_target='10.5'
981
982 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
983 cur_target='10.5'
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000984 fi
985 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +0000986 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +0000987 # On Intel macs default to a deployment
988 # target of 10.4, that's the first OSX
989 # release with Intel support.
990 cur_target="10.4"
991 fi
992 fi
Benjamin Peterson67c38e22008-07-17 16:10:34 +0000993 fi
994 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
995
996 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
997 # environment with a value that is the same as what we'll use
998 # in the Makefile to ensure that we'll get the same compiler
999 # environment during configure and build time.
1000 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1001 export MACOSX_DEPLOYMENT_TARGET
1002 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1003
Skip Montanarodecc6a42003-01-01 20:07:49 +00001004 ;;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001005 OSF*)
1006 BASECFLAGS="$BASECFLAGS -mieee"
1007 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001008 esac
1009 ;;
1010
1011*)
1012 case $ac_sys_system in
1013 OpenUNIX*|UnixWare*)
1014 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1015 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001016 OSF*)
1017 BASECFLAGS="$BASECFLAGS -ieee -std"
1018 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001019 SCO_SV*)
1020 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1021 ;;
1022 esac
1023 ;;
1024esac
1025
Fred Drakee1ceaa02001-12-04 20:55:47 +00001026if test "$Py_DEBUG" = 'true'; then
1027 :
1028else
1029 OPT="-DNDEBUG $OPT"
1030fi
1031
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001032if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001033then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001034 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001035fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001036
Neal Norwitz020c46a2006-01-07 21:39:28 +00001037# disable check for icc since it seems to pass, but generates a warning
1038if test "$CC" = icc
1039then
1040 ac_cv_opt_olimit_ok=no
1041fi
1042
Guido van Rossum91922671997-10-09 20:24:13 +00001043AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1044AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1045[ac_save_cc="$CC"
1046CC="$CC -OPT:Olimit=0"
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001047AC_TRY_COMPILE([],[int main() { return 0; }],
Guido van Rossum91922671997-10-09 20:24:13 +00001048 ac_cv_opt_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001049 ac_cv_opt_olimit_ok=no,
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001050 )
Guido van Rossum91922671997-10-09 20:24:13 +00001051CC="$ac_save_cc"])
1052AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001053if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001054 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001055 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1056 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1057 # environment?
1058 Darwin*)
1059 ;;
1060 *)
1061 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1062 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001063 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001064else
1065 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1066 AC_CACHE_VAL(ac_cv_olimit_ok,
1067 [ac_save_cc="$CC"
1068 CC="$CC -Olimit 1500"
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001069 AC_TRY_COMPILE([],[int main() { return 0; }],
Guido van Rossumf8678121998-07-07 21:05:09 +00001070 ac_cv_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001071 ac_cv_olimit_ok=no,
Gregory P. Smith4e3ed012009-11-01 21:09:10 +00001072 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001073 CC="$ac_save_cc"])
1074 AC_MSG_RESULT($ac_cv_olimit_ok)
1075 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001076 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +00001077 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001078fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001079
Thomas Wouters89f507f2006-12-13 04:49:30 +00001080# Check whether GCC supports PyArg_ParseTuple format
1081if test "$GCC" = "yes"
1082then
1083 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1084 save_CFLAGS=$CFLAGS
1085 CFLAGS="$CFLAGS -Werror"
1086 AC_TRY_COMPILE([
1087 void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
1088 ],,
1089 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1090 AC_MSG_RESULT(yes),
1091 AC_MSG_RESULT(no)
1092 )
1093 CFLAGS=$save_CFLAGS
1094fi
1095
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001096# On some compilers, pthreads are available without further options
1097# (e.g. MacOS X). On some of these systems, the compiler will not
1098# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1099# So we have to see first whether pthreads are available without
1100# options before we can check whether -Kpthread improves anything.
1101AC_MSG_CHECKING(whether pthreads are available without options)
1102AC_CACHE_VAL(ac_cv_pthread_is_default,
1103[AC_TRY_RUN([
1104#include <pthread.h>
1105
1106void* routine(void* p){return NULL;}
1107
1108int main(){
1109 pthread_t p;
1110 if(pthread_create(&p,NULL,routine,NULL)!=0)
1111 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001112 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001113 return 0;
1114}
1115],
Skip Montanarod8d39a02003-07-10 20:44:10 +00001116[
1117 ac_cv_pthread_is_default=yes
1118 ac_cv_kthread=no
1119 ac_cv_pthread=no
1120],
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001121 ac_cv_pthread_is_default=no,
1122 ac_cv_pthread_is_default=no)
1123])
1124AC_MSG_RESULT($ac_cv_pthread_is_default)
1125
1126
1127if test $ac_cv_pthread_is_default = yes
1128then
1129 ac_cv_kpthread=no
1130else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001131# -Kpthread, if available, provides the right #defines
1132# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001133# Some compilers won't report that they do not support -Kpthread,
1134# so we need to run a program to see whether it really made the
1135# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001136AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1137AC_CACHE_VAL(ac_cv_kpthread,
1138[ac_save_cc="$CC"
1139CC="$CC -Kpthread"
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001140AC_TRY_RUN([
1141#include <pthread.h>
1142
1143void* routine(void* p){return NULL;}
1144
1145int main(){
1146 pthread_t p;
1147 if(pthread_create(&p,NULL,routine,NULL)!=0)
1148 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001149 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001150 return 0;
1151}
1152],
Martin v. Löwis130fb172001-07-19 11:00:41 +00001153 ac_cv_kpthread=yes,
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001154 ac_cv_kpthread=no,
Martin v. Löwis130fb172001-07-19 11:00:41 +00001155 ac_cv_kpthread=no)
1156CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001157AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001158fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001159
Skip Montanarod8d39a02003-07-10 20:44:10 +00001160if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001161then
1162# -Kthread, if available, provides the right #defines
1163# and linker options to make pthread_create available
1164# Some compilers won't report that they do not support -Kthread,
1165# so we need to run a program to see whether it really made the
1166# function available.
1167AC_MSG_CHECKING(whether $CC accepts -Kthread)
1168AC_CACHE_VAL(ac_cv_kthread,
1169[ac_save_cc="$CC"
1170CC="$CC -Kthread"
1171AC_TRY_RUN([
1172#include <pthread.h>
1173
1174void* routine(void* p){return NULL;}
1175
1176int main(){
1177 pthread_t p;
1178 if(pthread_create(&p,NULL,routine,NULL)!=0)
1179 return 1;
1180 (void)pthread_detach(p);
1181 return 0;
1182}
1183],
1184 ac_cv_kthread=yes,
1185 ac_cv_kthread=no,
1186 ac_cv_kthread=no)
1187CC="$ac_save_cc"])
1188AC_MSG_RESULT($ac_cv_kthread)
1189fi
1190
Skip Montanarod8d39a02003-07-10 20:44:10 +00001191if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001192then
1193# -pthread, if available, provides the right #defines
1194# and linker options to make pthread_create available
1195# Some compilers won't report that they do not support -pthread,
1196# so we need to run a program to see whether it really made the
1197# function available.
1198AC_MSG_CHECKING(whether $CC accepts -pthread)
1199AC_CACHE_VAL(ac_cv_thread,
1200[ac_save_cc="$CC"
1201CC="$CC -pthread"
1202AC_TRY_RUN([
1203#include <pthread.h>
1204
1205void* routine(void* p){return NULL;}
1206
1207int main(){
1208 pthread_t p;
1209 if(pthread_create(&p,NULL,routine,NULL)!=0)
1210 return 1;
1211 (void)pthread_detach(p);
1212 return 0;
1213}
1214],
1215 ac_cv_pthread=yes,
1216 ac_cv_pthread=no,
1217 ac_cv_pthread=no)
1218CC="$ac_save_cc"])
1219AC_MSG_RESULT($ac_cv_pthread)
1220fi
1221
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001222# If we have set a CC compiler flag for thread support then
1223# check if it works for CXX, too.
1224ac_cv_cxx_thread=no
1225if test ! -z "$CXX"
1226then
1227AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1228ac_save_cxx="$CXX"
1229
1230if test "$ac_cv_kpthread" = "yes"
1231then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001232 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001233 ac_cv_cxx_thread=yes
1234elif test "$ac_cv_kthread" = "yes"
1235then
1236 CXX="$CXX -Kthread"
1237 ac_cv_cxx_thread=yes
1238elif test "$ac_cv_pthread" = "yes"
1239then
1240 CXX="$CXX -pthread"
1241 ac_cv_cxx_thread=yes
1242fi
1243
1244if test $ac_cv_cxx_thread = yes
1245then
1246 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1247 $CXX -c conftest.$ac_ext 2>&5
1248 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1249 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1250 then
1251 ac_cv_cxx_thread=yes
1252 else
1253 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001254 fi
1255 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001256fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001257AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001258fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001259CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001260
Fred Drakece81d592000-07-09 14:39:29 +00001261dnl # check for ANSI or K&R ("traditional") preprocessor
1262dnl AC_MSG_CHECKING(for C preprocessor type)
1263dnl AC_TRY_COMPILE([
1264dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1265dnl int foo;
1266dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1267dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1268dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001269
Guido van Rossum627b2d71993-12-24 10:39:16 +00001270# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001271AC_HEADER_STDC
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001272AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1273fcntl.h grp.h \
Christian Heimesbbe741d2008-03-28 10:53:29 +00001274ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Thomas Wouters89f507f2006-12-13 04:49:30 +00001275shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001276unistd.h utime.h \
Christian Heimes4fbc72b2008-03-22 00:47:35 +00001277sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1278sys/lock.h sys/mkdev.h sys/modem.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001279sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Georg Brandlf78e02b2008-06-10 17:40:04 +00001280sys/termio.h sys/time.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001281sys/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 +00001282sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Ronald Oussoren755740f2010-02-07 19:56:39 +00001283bluetooth/bluetooth.h linux/tipc.h spawn.h util.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001284AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001285AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001286
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001287# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e72004-11-30 22:09:37 +00001288AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001289#ifdef HAVE_CURSES_H
1290#include <curses.h>
1291#endif
1292])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001293
Martin v. Löwis11017b12006-01-14 18:12:57 +00001294# On Linux, netlink.h requires asm/types.h
1295AC_CHECK_HEADERS(linux/netlink.h,,,[
1296#ifdef HAVE_ASM_TYPES_H
1297#include <asm/types.h>
1298#endif
1299#ifdef HAVE_SYS_SOCKET_H
1300#include <sys/socket.h>
1301#endif
1302])
1303
Guido van Rossum627b2d71993-12-24 10:39:16 +00001304# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001305was_it_defined=no
1306AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001307AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1308 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1309])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001310AC_MSG_RESULT($was_it_defined)
1311
Neal Norwitz11690112002-07-30 01:08:28 +00001312# Check whether using makedev requires defining _OSF_SOURCE
1313AC_MSG_CHECKING(for makedev)
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001314AC_TRY_LINK([#include <sys/types.h> ],
Neal Norwitz11690112002-07-30 01:08:28 +00001315 [ makedev(0, 0) ],
1316 ac_cv_has_makedev=yes,
1317 ac_cv_has_makedev=no)
1318if test "$ac_cv_has_makedev" = "no"; then
1319 # we didn't link, try if _OSF_SOURCE will allow us to link
1320 AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001321#define _OSF_SOURCE 1
1322#include <sys/types.h>
Neal Norwitz11690112002-07-30 01:08:28 +00001323 ],
1324 [ makedev(0, 0) ],
1325 ac_cv_has_makedev=yes,
1326 ac_cv_has_makedev=no)
1327 if test "$ac_cv_has_makedev" = "yes"; then
1328 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1329 fi
1330fi
1331AC_MSG_RESULT($ac_cv_has_makedev)
1332if test "$ac_cv_has_makedev" = "yes"; then
1333 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1334fi
1335
Martin v. Löwis399a6892002-10-04 10:22:02 +00001336# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1337# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1338# defined, but the compiler does not support pragma redefine_extname,
1339# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1340# structures (such as rlimit64) without declaring them. As a
1341# work-around, disable LFS on such configurations
1342
1343use_lfs=yes
1344AC_MSG_CHECKING(Solaris LFS bug)
1345AC_TRY_COMPILE([
1346#define _LARGEFILE_SOURCE 1
1347#define _FILE_OFFSET_BITS 64
1348#include <sys/resource.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00001349],[struct rlimit foo;],sol_lfs_bug=no,sol_lfs_bug=yes)
Martin v. Löwis399a6892002-10-04 10:22:02 +00001350AC_MSG_RESULT($sol_lfs_bug)
1351if test "$sol_lfs_bug" = "yes"; then
1352 use_lfs=no
1353fi
1354
1355if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001356# Two defines needed to enable largefile support on various platforms
1357# These may affect some typedefs
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001358AC_DEFINE(_LARGEFILE_SOURCE, 1,
1359[This must be defined on some systems to enable large file support.])
1360AC_DEFINE(_FILE_OFFSET_BITS, 64,
1361[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001362fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001363
Guido van Rossum300fda71996-08-19 21:58:16 +00001364# Add some code to confdefs.h so that the test for off_t works on SCO
1365cat >> confdefs.h <<\EOF
1366#if defined(SCO_DS)
1367#undef _OFF_T
1368#endif
1369EOF
1370
Guido van Rossumef2255b2000-03-10 22:30:29 +00001371# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001372AC_TYPE_MODE_T
1373AC_TYPE_OFF_T
1374AC_TYPE_PID_T
1375AC_TYPE_SIGNAL
1376AC_TYPE_SIZE_T
1377AC_TYPE_UID_T
Mark Dickinsonbd792642009-03-18 20:06:12 +00001378AC_TYPE_UINT32_T
1379AC_TYPE_UINT64_T
1380AC_TYPE_INT32_T
1381AC_TYPE_INT64_T
Christian Heimes400adb02008-02-01 08:12:03 +00001382AC_CHECK_TYPE(ssize_t,
Matthias Klosec80c93f2010-04-24 17:04:35 +00001383 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001384
Guido van Rossumef2255b2000-03-10 22:30:29 +00001385# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001386# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001387AC_CHECK_SIZEOF(int, 4)
1388AC_CHECK_SIZEOF(long, 4)
1389AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001390AC_CHECK_SIZEOF(short, 2)
1391AC_CHECK_SIZEOF(float, 4)
1392AC_CHECK_SIZEOF(double, 8)
1393AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001394AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes400adb02008-02-01 08:12:03 +00001395AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001396
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001397AC_MSG_CHECKING(for long long support)
1398have_long_long=no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001399AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1400 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1401 have_long_long=yes
1402])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001403AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001404if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001405AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001406fi
1407
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001408AC_MSG_CHECKING(for long double support)
1409have_long_double=no
1410AC_TRY_COMPILE([], [long double x; x = (long double)0;], [
1411 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1412 have_long_double=yes
1413])
1414AC_MSG_RESULT($have_long_double)
1415if test "$have_long_double" = yes ; then
1416AC_CHECK_SIZEOF(long double, 16)
1417fi
1418
1419
Thomas Woutersb2137042007-02-01 18:02:27 +00001420AC_MSG_CHECKING(for _Bool support)
1421have_c99_bool=no
1422AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1423 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1424 have_c99_bool=yes
1425])
1426AC_MSG_RESULT($have_c99_bool)
1427if test "$have_c99_bool" = yes ; then
1428AC_CHECK_SIZEOF(_Bool, 1)
1429fi
1430
Thomas Wouters89f507f2006-12-13 04:49:30 +00001431AC_CHECK_TYPES(uintptr_t,
1432 [AC_CHECK_SIZEOF(uintptr_t, 4)],
1433 [], [#ifdef HAVE_STDINT_H
1434 #include <stdint.h>
1435 #endif])
1436
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001437AC_CHECK_SIZEOF(off_t, [], [
1438#ifdef HAVE_SYS_TYPES_H
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001439#include <sys/types.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001440#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001441])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001442
1443AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson2df5d282009-12-31 21:22:50 +00001444if test "$have_long_long" = yes
1445then
1446if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001447 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001448 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1449 [Defined to enable large file support when an off_t is bigger than a long
1450 and long long is available and at least as big as an off_t. You may need
1451 to add some flags for configuration and compilation to enable this mode.
1452 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001453 AC_MSG_RESULT(yes)
1454else
1455 AC_MSG_RESULT(no)
1456fi
Mark Dickinson2df5d282009-12-31 21:22:50 +00001457else
1458 AC_MSG_RESULT(no)
1459fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001460
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001461AC_CHECK_SIZEOF(time_t, [], [
1462#ifdef HAVE_SYS_TYPES_H
1463#include <sys/types.h>
1464#endif
1465#ifdef HAVE_TIME_H
Fred Drakea3f6e912000-06-29 20:44:47 +00001466#include <time.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001467#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001468])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001469
Trent Mick635f6fb2000-08-23 21:33:05 +00001470# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001471ac_save_cc="$CC"
1472if test "$ac_cv_kpthread" = "yes"
1473then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001474elif test "$ac_cv_kthread" = "yes"
1475then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001476elif test "$ac_cv_pthread" = "yes"
1477then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001478fi
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001479
Trent Mick635f6fb2000-08-23 21:33:05 +00001480AC_MSG_CHECKING(for pthread_t)
1481have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +00001482AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +00001483AC_MSG_RESULT($have_pthread_t)
1484if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001485 AC_CHECK_SIZEOF(pthread_t, [], [
1486#ifdef HAVE_PTHREAD_H
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001487#include <pthread.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001488#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001489 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001490fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001491CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001492
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001493AC_SUBST(OTHER_LIBTOOL_OPT)
1494case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001495 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001496 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1497 ;;
1498 Darwin/*)
1499 OTHER_LIBTOOL_OPT=""
1500 ;;
1501esac
1502
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001503
1504ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001505AC_SUBST(LIBTOOL_CRUFT)
1506case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001507 Darwin/@<:@01567@:>@\..*)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001508 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1509 if test "${enable_universalsdk}"; then
1510 :
1511 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001512 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001513 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001514 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001515 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001516 Darwin/*)
Ronald Oussoren9812a6c2010-02-07 11:53:18 +00001517 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001518 if test ${gcc_version} '<' 4.0
1519 then
1520 LIBTOOL_CRUFT="-lcc_dynamic"
1521 else
1522 LIBTOOL_CRUFT=""
1523 fi
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001524 AC_TRY_RUN([
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001525 #include <unistd.h>
1526 int main(int argc, char*argv[])
1527 {
1528 if (sizeof(long) == 4) {
1529 return 0;
1530 } else {
1531 return 1;
1532 }
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001533 }
1534 ], ac_osx_32bit=yes,
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001535 ac_osx_32bit=no,
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001536 ac_osx_32bit=yes)
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001537
1538 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001539 case `/usr/bin/arch` in
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001540 i386)
1541 MACOSX_DEFAULT_ARCH="i386"
1542 ;;
1543 ppc)
1544 MACOSX_DEFAULT_ARCH="ppc"
1545 ;;
1546 *)
1547 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1548 ;;
1549 esac
1550 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001551 case `/usr/bin/arch` in
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001552 i386)
1553 MACOSX_DEFAULT_ARCH="x86_64"
1554 ;;
1555 ppc)
1556 MACOSX_DEFAULT_ARCH="ppc64"
1557 ;;
1558 *)
1559 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1560 ;;
1561 esac
1562
1563 #ARCH_RUN_32BIT="true"
1564 fi
1565
1566 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001567 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001568 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001569esac
1570
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001571AC_MSG_CHECKING(for --enable-framework)
1572if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001573then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001574 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001575 # -F. is needed to allow linking to the framework while
1576 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001577 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1578 [Define if you want to produce an OpenStep/Rhapsody framework
1579 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001580 AC_MSG_RESULT(yes)
Ronald Oussoren99aab652009-06-08 21:22:57 +00001581 if test $enable_shared = "yes"
1582 then
1583 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
1584 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001585else
1586 AC_MSG_RESULT(no)
1587fi
1588
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001589AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001590case $ac_sys_system/$ac_sys_release in
1591 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001592 AC_DEFINE(WITH_DYLD, 1,
1593 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1594 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1595 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001596 AC_MSG_RESULT(always on for Darwin)
1597 ;;
1598 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001599 AC_MSG_RESULT(no)
1600 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001601esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001602
Guido van Rossumac405f61994-09-12 10:56:06 +00001603# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001604AC_SUBST(SO)
1605AC_SUBST(LDSHARED)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001606AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001607AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001608AC_SUBST(CCSHARED)
1609AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001610# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001611# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001612AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001613if test -z "$SO"
1614then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001615 case $ac_sys_system in
Thomas Wouters477c8d52006-05-27 19:21:47 +00001616 hp*|HP*)
1617 case `uname -m` in
1618 ia64) SO=.so;;
1619 *) SO=.sl;;
1620 esac
1621 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001622 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001623 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001624 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001625else
1626 # this might also be a termcap variable, see #610332
1627 echo
1628 echo '====================================================================='
1629 echo '+ +'
1630 echo '+ WARNING: You have set SO in your environment. +'
1631 echo '+ Do you really mean to change the extension for shared libraries? +'
1632 echo '+ Continuing in 10 seconds to let you to ponder. +'
1633 echo '+ +'
1634 echo '====================================================================='
1635 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001636fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001637AC_MSG_RESULT($SO)
Georg Brandlb1441c72009-01-03 22:33:39 +00001638
Thomas Wouters477c8d52006-05-27 19:21:47 +00001639AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001640# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001641# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001642# (Shared libraries in this instance are shared modules to be loaded into
1643# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001644AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001645if test -z "$LDSHARED"
1646then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001647 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001648 AIX*)
1649 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001650 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001651 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001652 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001653 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a6632000-05-26 12:22:54 +00001654 SunOS/5*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001655 if test "$GCC" = "yes" ; then
1656 LDSHARED='$(CC) -shared'
1657 LDCXXSHARED='$(CXX) -shared'
1658 else
1659 LDSHARED='$(CC) -G'
1660 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a6632000-05-26 12:22:54 +00001661 fi ;;
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001662 hp*|HP*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001663 if test "$GCC" = "yes" ; then
1664 LDSHARED='$(CC) -shared'
1665 LDCXXSHARED='$(CXX) -shared'
1666 else
1667 LDSHARED='ld -b'
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001668 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001669 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001670 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +00001671 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001672 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001673 if test "$enable_framework" ; then
1674 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001675 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1676 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001677 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001678 else
1679 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001680 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001681 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001682 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001683 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001684 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001685 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001686 if test "$enable_framework" ; then
1687 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001688 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1689 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001690 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001691 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001692 # No framework, use the Python app as bundle-loader
1693 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001694 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001695 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001696 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001697 Darwin/*)
1698 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1699 # This allows an extension to be used in any Python
Thomas Wouters89d996e2007-09-08 17:39:28 +00001700
Georg Brandlfcaf9102008-07-16 02:17:56 +00001701 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001702 then
Thomas Wouters477c8d52006-05-27 19:21:47 +00001703 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +00001704 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001705 fi
Jack Jansen6b08a402004-06-03 12:41:45 +00001706 LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001707 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle -undefined dynamic_lookup'
Jack Jansen6b08a402004-06-03 12:41:45 +00001708 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001709 else
1710 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001711 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00001712 if test "$enable_framework" ; then
1713 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001714 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1715 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001716 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001717 else
1718 # No framework, use the Python app as bundle-loader
1719 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1720 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001721 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001722 fi
1723 fi
1724 ;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001725 Linux*|GNU*|QNX*)
1726 LDSHARED='$(CC) -shared'
1727 LDCXXSHARED='$(CXX) -shared';;
1728 BSD/OS*/4*)
1729 LDSHARED="gcc -shared"
1730 LDCXXSHARED="g++ -shared";;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001731 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001732 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001733 then
Benjamin Petersonab0a7522010-03-14 15:18:25 +00001734 LDSHARED='$(CC) -shared ${LDFLAGS}'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001735 LDCXXSHARED='$(CXX) -shared ${LDFLAGS}'
Guido van Rossum0286ae82000-08-29 15:06:49 +00001736 else
1737 LDSHARED="ld -Bshareable ${LDFLAGS}"
1738 fi;;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001739 OpenBSD*)
1740 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1741 then
1742 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001743 LDCXXSHARED='$(CXX) -shared $(CCSHARED) ${LDFLAGS}'
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001744 else
1745 case `uname -r` in
1746 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1747 LDSHARED="ld -Bshareable ${LDFLAGS}"
1748 ;;
1749 *)
1750 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001751 LDCXXSHARED='$(CXX) -shared $(CCSHARED) ${LDFLAGS}'
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001752 ;;
1753 esac
1754 fi;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001755 NetBSD*|DragonFly*)
1756 LDSHARED="cc -shared ${LDFLAGS}"
1757 LDCXXSHARED="c++ -shared ${LDFLAGS}";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001758 OpenUNIX*|UnixWare*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001759 if test "$GCC" = "yes" ; then
1760 LDSHARED='$(CC) -shared'
1761 LDCXXSHARED='$(CXX) -shared'
1762 else
1763 LDSHARED='$(CC) -G'
1764 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001765 fi;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001766 SCO_SV*)
1767 LDSHARED='$(CC) -Wl,-G,-Bexport'
1768 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
1769 CYGWIN*)
1770 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
1771 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001772 *) LDSHARED="ld";;
1773 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001774fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001775AC_MSG_RESULT($LDSHARED)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001776LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001777BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001778# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001779# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001780AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001781if test -z "$CCSHARED"
1782then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001783 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001784 SunOS*) if test "$GCC" = yes;
Guido van Rossumd8faa362007-04-27 19:54:29 +00001785 then CCSHARED="-fPIC";
1786 elif test `uname -p` = sparc;
1787 then CCSHARED="-xcode=pic32";
1788 else CCSHARED="-Kpic";
1789 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001790 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001791 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001792 else CCSHARED="+z";
1793 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001794 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001795 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001796 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001797 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001798 if test "$GCC" = "yes"
1799 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001800 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001801 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001802 SCO_SV*)
1803 if test "$GCC" = "yes"
1804 then CCSHARED="-fPIC"
1805 else CCSHARED="-Kpic -belf"
1806 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001807 IRIX*/6*) case $CC in
1808 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001809 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001810 esac;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001811 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001812fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001813AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001814# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001815# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001816AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001817if test -z "$LINKFORSHARED"
1818then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001819 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001820 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001821 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001822 LINKFORSHARED="-Wl,-E -Wl,+s";;
1823# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001824 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001825 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001826 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001827 Darwin/*)
Benjamin Peterson9c80cac2009-05-23 16:34:23 +00001828 LINKFORSHARED="$extra_undefs -framework CoreFoundation"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001829 if test "$enable_framework"
1830 then
Jack Jansenda49e192005-01-07 13:08:22 +00001831 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001832 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001833 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001834 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001835 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001836 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001837 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001838 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1839 then
1840 LINKFORSHARED="-Wl,--export-dynamic"
1841 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001842 SunOS/5*) case $CC in
1843 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001844 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001845 then
1846 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001847 fi;;
1848 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001849 CYGWIN*)
1850 if test $enable_shared = "no"
1851 then
1852 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1853 fi;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001854 QNX*)
1855 # -Wl,-E causes the symbols to be added to the dynamic
1856 # symbol table so that they can be found when a module
1857 # is loaded. -N 2048K causes the stack size to be set
1858 # to 2048 kilobytes so that the stack doesn't overflow
1859 # when running test_compile.py.
1860 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00001861 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001862fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001863AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001864
Georg Brandl93de2162008-07-16 02:21:06 +00001865
Neil Schemenauer61c51152001-01-26 16:18:16 +00001866AC_SUBST(CFLAGSFORSHARED)
1867AC_MSG_CHECKING(CFLAGSFORSHARED)
1868if test ! "$LIBRARY" = "$LDLIBRARY"
1869then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00001870 case $ac_sys_system in
1871 CYGWIN*)
1872 # Cygwin needs CCSHARED when building extension DLLs
1873 # but not when building the interpreter DLL.
1874 CFLAGSFORSHARED='';;
1875 *)
1876 CFLAGSFORSHARED='$(CCSHARED)'
1877 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00001878fi
1879AC_MSG_RESULT($CFLAGSFORSHARED)
1880
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001881# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1882# library (with --enable-shared).
1883# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001884# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1885# if it is not required, since it creates a dependency of the shared library
1886# to LIBS. This, in turn, means that applications linking the shared libpython
1887# don't need to link LIBS explicitly. The default should be only changed
1888# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001889AC_SUBST(SHLIBS)
1890AC_MSG_CHECKING(SHLIBS)
1891case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001892 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001893 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001894esac
1895AC_MSG_RESULT($SHLIBS)
1896
1897
Guido van Rossum627b2d71993-12-24 10:39:16 +00001898# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001899AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
1900AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00001901
Georg Brandleee31162008-12-07 15:15:22 +00001902# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00001903if test "$with_threads" = "yes" -o -z "$with_threads"; then
1904 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1905 # posix4 on Solaris 2.6
1906 # pthread (first!) on Linux
1907fi
1908
Martin v. Löwis19d17342003-06-14 21:03:05 +00001909# check if we need libintl for locale functions
1910AC_CHECK_LIB(intl, textdomain,
Brett Cannonc6d936e2009-06-07 20:09:53 +00001911 [AC_DEFINE(WITH_LIBINTL, 1,
1912 [Define to 1 if libintl is needed for locale functions.])
1913 LIBS="-lintl $LIBS"])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001914
1915# checks for system dependent C++ extensions support
1916case "$ac_sys_system" in
1917 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1918 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1919 [loadAndInit("", 0, "")],
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001920 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1921 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1922 and you want support for AIX C++ shared extension modules.])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001923 AC_MSG_RESULT(yes)],
1924 [AC_MSG_RESULT(no)]);;
1925 *) ;;
1926esac
1927
Guido van Rossum70c7f481998-03-26 18:44:10 +00001928# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001929AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001930AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00001931
Guido van Rossumc5a39031996-07-31 17:35:03 +00001932AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001933AC_ARG_WITH(libs,
Matthias Klose2b8733f2010-04-25 18:34:36 +00001934 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001935[
Guido van Rossumc5a39031996-07-31 17:35:03 +00001936AC_MSG_RESULT($withval)
1937LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001938],
1939[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001940
Benjamin Peterson0f64b0b2010-03-09 21:49:52 +00001941AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
1942
Benjamin Petersonb2d90462009-12-31 03:23:10 +00001943# Check for use of the system expat library
1944AC_MSG_CHECKING(for --with-system-expat)
1945AC_ARG_WITH(system_expat,
Matthias Klose2b8733f2010-04-25 18:34:36 +00001946 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]))
Benjamin Petersonb2d90462009-12-31 03:23:10 +00001947
1948AC_MSG_RESULT($with_system_expat)
1949
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001950# Check for use of the system libffi library
1951AC_MSG_CHECKING(for --with-system-ffi)
1952AC_ARG_WITH(system_ffi,
Matthias Klose2b8733f2010-04-25 18:34:36 +00001953 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]))
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001954
Benjamin Peterson0f64b0b2010-03-09 21:49:52 +00001955if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Petersond78735d2010-01-01 16:04:23 +00001956 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
1957else
1958 LIBFFI_INCLUDEDIR=""
1959fi
1960AC_SUBST(LIBFFI_INCLUDEDIR)
1961
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001962AC_MSG_RESULT($with_system_ffi)
1963
Matthias Klose55708cc2009-04-30 08:06:49 +00001964# Check for --with-dbmliborder
1965AC_MSG_CHECKING(for --with-dbmliborder)
1966AC_ARG_WITH(dbmliborder,
Matthias Klose2b8733f2010-04-25 18:34:36 +00001967 AS_HELP_STRING([--with-dbmliborder=db1:db2:...], [order to check db backends for dbm. Valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]),
Matthias Klose55708cc2009-04-30 08:06:49 +00001968[
1969if test x$with_dbmliborder = xyes
1970then
1971AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1972else
1973 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
1974 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
1975 then
1976 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1977 fi
1978 done
1979fi])
1980AC_MSG_RESULT($with_dbmliborder)
1981
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001982# Determine if signalmodule should be used.
1983AC_SUBST(USE_SIGNAL_MODULE)
1984AC_SUBST(SIGNAL_OBJS)
1985AC_MSG_CHECKING(for --with-signal-module)
1986AC_ARG_WITH(signal-module,
Matthias Klose2b8733f2010-04-25 18:34:36 +00001987 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001988
1989if test -z "$with_signal_module"
1990then with_signal_module="yes"
1991fi
1992AC_MSG_RESULT($with_signal_module)
1993
1994if test "${with_signal_module}" = "yes"; then
1995 USE_SIGNAL_MODULE=""
1996 SIGNAL_OBJS=""
1997else
1998 USE_SIGNAL_MODULE="#"
1999 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2000fi
2001
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002002# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002003AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002004USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002005
Guido van Rossum54d93d41997-01-22 20:51:58 +00002006AC_MSG_CHECKING(for --with-dec-threads)
2007AC_SUBST(LDLAST)
2008AC_ARG_WITH(dec-threads,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002009 AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002010[
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002011AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002012LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002013if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002014 with_thread="$withval";
2015fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002016[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002017
Martin v. Löwis11437992002-04-12 09:54:03 +00002018# Templates for things AC_DEFINEd more than once.
2019# For a single AC_DEFINE, no template is needed.
2020AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2021AH_TEMPLATE(_REENTRANT,
2022 [Define to force use of thread-safe errno, h_errno, and other functions])
2023AH_TEMPLATE(WITH_THREAD,
2024 [Define if you want to compile in rudimentary thread support])
2025
Guido van Rossum54d93d41997-01-22 20:51:58 +00002026AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002027dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002028AC_ARG_WITH(threads,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002029 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002030
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002031# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002032dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002033AC_ARG_WITH(thread,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002034 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002035 [with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002036
2037if test -z "$with_threads"
2038then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002039fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002040AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002041
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002042AC_SUBST(THREADOBJ)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002043if test "$with_threads" = "no"
2044then
2045 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002046elif test "$ac_cv_pthread_is_default" = yes
2047then
2048 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002049 # Defining _REENTRANT on system with POSIX threads should not hurt.
2050 AC_DEFINE(_REENTRANT)
2051 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002052 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002053elif test "$ac_cv_kpthread" = "yes"
2054then
2055 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002056 if test "$ac_cv_cxx_thread" = "yes"; then
2057 CXX="$CXX -Kpthread"
2058 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002059 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002060 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002061 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002062elif test "$ac_cv_kthread" = "yes"
2063then
2064 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002065 if test "$ac_cv_cxx_thread" = "yes"; then
2066 CXX="$CXX -Kthread"
2067 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002068 AC_DEFINE(WITH_THREAD)
2069 posix_threads=yes
2070 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002071elif test "$ac_cv_pthread" = "yes"
2072then
2073 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002074 if test "$ac_cv_cxx_thread" = "yes"; then
2075 CXX="$CXX -pthread"
2076 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002077 AC_DEFINE(WITH_THREAD)
2078 posix_threads=yes
2079 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002080else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002081 if test ! -z "$with_threads" -a -d "$with_threads"
2082 then LDFLAGS="$LDFLAGS -L$with_threads"
2083 fi
2084 if test ! -z "$withval" -a -d "$withval"
2085 then LDFLAGS="$LDFLAGS -L$withval"
2086 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002087
2088 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002089 # define _POSIX_THREADS in unistd.h. Some apparently don't
2090 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002091 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2092 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002093 [
2094#include <unistd.h>
2095#ifdef _POSIX_THREADS
2096yes
2097#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002098 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2099 AC_MSG_RESULT($unistd_defines_pthreads)
2100
Martin v. Löwis130fb172001-07-19 11:00:41 +00002101 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002102 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2103 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002104 AC_DEFINE(HURD_C_THREADS, 1,
2105 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002106 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002107 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002108 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2109 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002110 AC_DEFINE(MACH_C_THREADS, 1,
2111 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002112 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002113 # Just looking for pthread_create in libpthread is not enough:
2114 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2115 # So we really have to include pthread.h, and then link.
2116 _libs=$LIBS
2117 LIBS="$LIBS -lpthread"
2118 AC_MSG_CHECKING([for pthread_create in -lpthread])
2119 AC_TRY_LINK([#include <pthread.h>
2120
2121void * start_routine (void *arg) { exit (0); }], [
2122pthread_create (NULL, NULL, start_routine, NULL)], [
2123 AC_MSG_RESULT(yes)
2124 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002125 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002126 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002127 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002128 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002129 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002130 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002131 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002132 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002133 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002134 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002135 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002136 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002137 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002138 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002139 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002140 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002141 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002142 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002143 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002144 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002145 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002146 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002147 USE_THREAD_MODULE="#"])
Antoine Pitroudb6c5672009-10-24 20:35:52 +00002148 ])])])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002149
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002150 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2151 LIBS="$LIBS -lmpc"
2152 THREADOBJ="Python/thread.o"
2153 USE_THREAD_MODULE=""])
2154
2155 if test "$posix_threads" != "yes"; then
2156 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2157 LIBS="$LIBS -lthread"
2158 THREADOBJ="Python/thread.o"
2159 USE_THREAD_MODULE=""])
2160 fi
2161
2162 if test "$USE_THREAD_MODULE" != "#"
2163 then
2164 # If the above checks didn't disable threads, (at least) OSF1
2165 # needs this '-threads' argument during linking.
2166 case $ac_sys_system in
2167 OSF1) LDLAST=-threads;;
2168 esac
2169 fi
2170fi
2171
2172if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002173 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002174 AC_DEFINE(_POSIX_THREADS, 1,
2175 [Define if you have POSIX threads,
2176 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002177 fi
2178
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002179 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2180 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002181 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002182 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002183 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002184 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002185 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002186 ;;
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002187 AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002188 [Define if the Posix semaphores do not work on your system])
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002189 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002190 esac
2191
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002192 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2193 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2194 [AC_TRY_RUN([#include <pthread.h>
2195 void *foo(void *parm) {
2196 return NULL;
2197 }
2198 main() {
2199 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002200 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002201 if (pthread_attr_init(&attr)) exit(-1);
2202 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002203 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002204 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00002205 }],
2206 ac_cv_pthread_system_supported=yes,
2207 ac_cv_pthread_system_supported=no,
2208 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002209 ])
2210 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2211 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002212 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002213 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002214 AC_CHECK_FUNCS(pthread_sigmask,
2215 [case $ac_sys_system in
2216 CYGWIN*)
2217 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2218 [Define if pthread_sigmask() does not work on your system.])
2219 ;;
2220 esac])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002221fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002222
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002223
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002224# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002225AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002226AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002227AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002228[ --enable-ipv6 Enable ipv6 (with ipv4) support
2229 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002230[ case "$enableval" in
2231 no)
2232 AC_MSG_RESULT(no)
2233 ipv6=no
2234 ;;
2235 *) AC_MSG_RESULT(yes)
2236 AC_DEFINE(ENABLE_IPV6)
2237 ipv6=yes
2238 ;;
2239 esac ],
2240
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002241[
2242dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002243 AC_TRY_RUN([ /* AF_INET6 available check */
2244#include <sys/types.h>
2245#include <sys/socket.h>
2246main()
2247{
2248 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2249 exit(1);
2250 else
2251 exit(0);
2252}
2253],
2254 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002255 ipv6=yes,
2256 AC_MSG_RESULT(no)
2257 ipv6=no,
2258 AC_MSG_RESULT(no)
2259 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002260)
2261
2262if test "$ipv6" = "yes"; then
2263 AC_MSG_CHECKING(if RFC2553 API is available)
2264 AC_TRY_COMPILE([#include <sys/types.h>
2265#include <netinet/in.h>],
2266 [struct sockaddr_in6 x;
2267x.sin6_scope_id;],
2268 AC_MSG_RESULT(yes)
2269 ipv6=yes,
2270 AC_MSG_RESULT(no, IPv6 disabled)
2271 ipv6=no)
2272fi
2273
2274if test "$ipv6" = "yes"; then
2275 AC_DEFINE(ENABLE_IPV6)
2276fi
2277])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002278
2279ipv6type=unknown
2280ipv6lib=none
2281ipv6trylibc=no
2282
2283if test "$ipv6" = "yes"; then
2284 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002285 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2286 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002287 case $i in
2288 inria)
2289 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002290 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002291#include <netinet/in.h>
2292#ifdef IPV6_INRIA_VERSION
2293yes
2294#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002295 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002296 ;;
2297 kame)
2298 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002299 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002300#include <netinet/in.h>
2301#ifdef __KAME__
2302yes
2303#endif],
2304 [ipv6type=$i;
2305 ipv6lib=inet6
2306 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002307 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002308 ;;
2309 linux-glibc)
2310 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002311 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002312#include <features.h>
2313#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2314yes
2315#endif],
2316 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002317 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002318 ;;
2319 linux-inet6)
2320 dnl http://www.v6.linux.or.jp/
2321 if test -d /usr/inet6; then
2322 ipv6type=$i
2323 ipv6lib=inet6
2324 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002325 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002326 fi
2327 ;;
2328 solaris)
2329 if test -f /etc/netconfig; then
2330 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2331 ipv6type=$i
2332 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002333 fi
2334 fi
2335 ;;
2336 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002337 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002338#include <sys/param.h>
2339#ifdef _TOSHIBA_INET6
2340yes
2341#endif],
2342 [ipv6type=$i;
2343 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002344 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002345 ;;
2346 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002347 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002348#include </usr/local/v6/include/sys/v6config.h>
2349#ifdef __V6D__
2350yes
2351#endif],
2352 [ipv6type=$i;
2353 ipv6lib=v6;
2354 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002355 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002356 ;;
2357 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002358 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002359#include <sys/param.h>
2360#ifdef _ZETA_MINAMI_INET6
2361yes
2362#endif],
2363 [ipv6type=$i;
2364 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002365 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002366 ;;
2367 esac
2368 if test "$ipv6type" != "unknown"; then
2369 break
2370 fi
2371 done
2372 AC_MSG_RESULT($ipv6type)
2373fi
2374
2375if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2376 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2377 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2378 echo "using lib$ipv6lib"
2379 else
2380 if test $ipv6trylibc = "yes"; then
2381 echo "using libc"
2382 else
2383 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2384 echo "You need to fetch lib$ipv6lib.a from appropriate"
2385 echo 'ipv6 kit and compile beforehand.'
2386 exit 1
2387 fi
2388 fi
2389fi
2390
Georg Brandl93de2162008-07-16 02:21:06 +00002391AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Klosec80c93f2010-04-24 17:04:35 +00002392AC_TRY_COMPILE([#include <Carbon/Carbon.h>], [FSIORefNum fRef = 0],
2393 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Georg Brandl93de2162008-07-16 02:21:06 +00002394 AC_MSG_RESULT(yes),
2395 AC_MSG_RESULT(no)
2396)
2397
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002398# Check for --with-doc-strings
2399AC_MSG_CHECKING(for --with-doc-strings)
2400AC_ARG_WITH(doc-strings,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002401 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002402
2403if test -z "$with_doc_strings"
2404then with_doc_strings="yes"
2405fi
2406if test "$with_doc_strings" != "no"
2407then
2408 AC_DEFINE(WITH_DOC_STRINGS, 1,
2409 [Define if you want documentation strings in extension modules])
2410fi
2411AC_MSG_RESULT($with_doc_strings)
2412
Neil Schemenauera35c6882001-02-27 04:45:05 +00002413# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002414AC_MSG_CHECKING(for --with-tsc)
2415AC_ARG_WITH(tsc,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002416 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002417if test "$withval" != no
2418then
2419 AC_DEFINE(WITH_TSC, 1,
2420 [Define to profile with the Pentium timestamp counter])
2421 AC_MSG_RESULT(yes)
2422else AC_MSG_RESULT(no)
2423fi],
2424[AC_MSG_RESULT(no)])
2425
2426# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002427AC_MSG_CHECKING(for --with-pymalloc)
2428AC_ARG_WITH(pymalloc,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002429 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002430
2431if test -z "$with_pymalloc"
2432then with_pymalloc="yes"
2433fi
2434if test "$with_pymalloc" != "no"
2435then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002436 AC_DEFINE(WITH_PYMALLOC, 1,
2437 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002438fi
2439AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002440
Benjamin Peterson05159c42009-12-03 03:01:27 +00002441# Check for Valgrind support
2442AC_MSG_CHECKING([for --with-valgrind])
2443AC_ARG_WITH([valgrind],
Matthias Klose2b8733f2010-04-25 18:34:36 +00002444 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson05159c42009-12-03 03:01:27 +00002445 with_valgrind=no)
2446AC_MSG_RESULT([$with_valgrind])
2447if test "$with_valgrind" != no; then
2448 AC_CHECK_HEADER([valgrind/valgrind.h],
2449 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2450 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2451 )
2452fi
2453
Barry Warsawef82cd72000-06-30 16:21:01 +00002454# Check for --with-wctype-functions
2455AC_MSG_CHECKING(for --with-wctype-functions)
2456AC_ARG_WITH(wctype-functions,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002457 AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002458[
Barry Warsawef82cd72000-06-30 16:21:01 +00002459if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002460then
2461 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2462 [Define if you want wctype.h functions to be used instead of the
2463 one supplied by Python itself. (see Include/unicodectype.h).])
2464 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002465else AC_MSG_RESULT(no)
2466fi],
2467[AC_MSG_RESULT(no)])
2468
Guido van Rossum68242b51996-05-28 22:53:03 +00002469# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002470AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002471DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002472
Guido van Rossume97ee181999-12-20 21:27:22 +00002473# the dlopen() function means we might want to use dynload_shlib.o. some
2474# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002475AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002476
2477# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2478# loading of modules.
2479AC_SUBST(DYNLOADFILE)
2480AC_MSG_CHECKING(DYNLOADFILE)
2481if test -z "$DYNLOADFILE"
2482then
2483 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002484 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2485 if test "$ac_cv_func_dlopen" = yes
2486 then DYNLOADFILE="dynload_shlib.o"
2487 else DYNLOADFILE="dynload_aix.o"
2488 fi
2489 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002490 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002491 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2492 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002493 *)
2494 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2495 # out any dynamic loading
2496 if test "$ac_cv_func_dlopen" = yes
2497 then DYNLOADFILE="dynload_shlib.o"
2498 else DYNLOADFILE="dynload_stub.o"
2499 fi
2500 ;;
2501 esac
2502fi
2503AC_MSG_RESULT($DYNLOADFILE)
2504if test "$DYNLOADFILE" != "dynload_stub.o"
2505then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002506 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2507 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002508fi
2509
Jack Jansenc49e5b72001-06-19 15:00:23 +00002510# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2511
2512AC_SUBST(MACHDEP_OBJS)
2513AC_MSG_CHECKING(MACHDEP_OBJS)
2514if test -z "$MACHDEP_OBJS"
2515then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002516 MACHDEP_OBJS=$extra_machdep_objs
2517else
2518 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002519fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002520AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002521
Guido van Rossum627b2d71993-12-24 10:39:16 +00002522# checks for library functions
Martin v. Löwis823725e2008-03-24 13:39:54 +00002523AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2524 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002525 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis7aed61a2009-11-27 14:09:49 +00002526 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Antoine Pitroub7572f02009-12-02 20:46:48 +00002527 initgroups kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002528 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002529 putenv readlink realpath \
Benjamin Peterson965ce872009-04-05 21:24:58 +00002530 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2531 setgid \
Martin v. Löwis7aed61a2009-11-27 14:09:49 +00002532 setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setuid setvbuf \
2533 sigaction siginterrupt sigrelse snprintf strftime strlcpy \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002534 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Martin v. Löwis113a0852009-05-29 17:25:39 +00002535 truncate uname unsetenv utimes waitpid wait3 wait4 \
2536 wcscoll wcsftime wcsxfrm _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002537
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002538# For some functions, having a definition is not sufficient, since
2539# we want to take their address.
2540AC_MSG_CHECKING(for chroot)
Matthias Klosec80c93f2010-04-24 17:04:35 +00002541AC_TRY_COMPILE([#include <unistd.h>], [void *x=chroot],
2542 AC_DEFINE(HAVE_CHROOT, 1, [Define if you have the 'chroot' function.])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002543 AC_MSG_RESULT(yes),
2544 AC_MSG_RESULT(no)
2545)
2546AC_MSG_CHECKING(for link)
Matthias Klosec80c93f2010-04-24 17:04:35 +00002547AC_TRY_COMPILE([#include <unistd.h>], [void *x=link],
2548 AC_DEFINE(HAVE_LINK, 1, [Define if you have the 'link' function.])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002549 AC_MSG_RESULT(yes),
2550 AC_MSG_RESULT(no)
2551)
2552AC_MSG_CHECKING(for symlink)
Matthias Klosec80c93f2010-04-24 17:04:35 +00002553AC_TRY_COMPILE([#include <unistd.h>], [void *x=symlink],
2554 AC_DEFINE(HAVE_SYMLINK, 1, [Define if you have the 'symlink' function.])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002555 AC_MSG_RESULT(yes),
2556 AC_MSG_RESULT(no)
2557)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002558AC_MSG_CHECKING(for fchdir)
Matthias Klosec80c93f2010-04-24 17:04:35 +00002559AC_TRY_COMPILE([#include <unistd.h>], [void *x=fchdir],
2560 AC_DEFINE(HAVE_FCHDIR, 1, [Define if you have the 'fchdir' function.])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002561 AC_MSG_RESULT(yes),
2562 AC_MSG_RESULT(no)
2563)
2564AC_MSG_CHECKING(for fsync)
Matthias Klosec80c93f2010-04-24 17:04:35 +00002565AC_TRY_COMPILE([#include <unistd.h>], [void *x=fsync],
2566 AC_DEFINE(HAVE_FSYNC, 1, [Define if you have the 'fsync' function.])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002567 AC_MSG_RESULT(yes),
2568 AC_MSG_RESULT(no)
2569)
2570AC_MSG_CHECKING(for fdatasync)
Matthias Klosec80c93f2010-04-24 17:04:35 +00002571AC_TRY_COMPILE([#include <unistd.h>], [void *x=fdatasync],
2572 AC_DEFINE(HAVE_FDATASYNC, 1, [Define if you have the 'fdatasync' function.])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002573 AC_MSG_RESULT(yes),
2574 AC_MSG_RESULT(no)
2575)
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002576AC_MSG_CHECKING(for epoll)
Matthias Klosec80c93f2010-04-24 17:04:35 +00002577AC_TRY_COMPILE([#include <sys/epoll.h>], [void *x=epoll_create],
2578 AC_DEFINE(HAVE_EPOLL, 1, [Define if you have the 'epoll' functions.])
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002579 AC_MSG_RESULT(yes),
2580 AC_MSG_RESULT(no)
2581)
2582AC_MSG_CHECKING(for kqueue)
2583AC_TRY_COMPILE([
2584#include <sys/types.h>
2585#include <sys/event.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00002586 ], [int x=kqueue()],
2587 AC_DEFINE(HAVE_KQUEUE, 1, [Define if you have the 'kqueue' functions.])
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002588 AC_MSG_RESULT(yes),
2589 AC_MSG_RESULT(no)
2590)
Martin v. Löwisd5843682002-11-21 20:41:28 +00002591# On some systems (eg. FreeBSD 5), we would find a definition of the
2592# functions ctermid_r, setgroups in the library, but no prototype
2593# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2594# address to avoid compiler warnings and potential miscompilations
2595# because of the missing prototypes.
2596
2597AC_MSG_CHECKING(for ctermid_r)
2598AC_TRY_COMPILE([
2599#include "confdefs.h"
2600#include <stdio.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00002601], [void* p = ctermid_r],
2602 AC_DEFINE(HAVE_CTERMID_R, 1, [Define if you have the 'ctermid_r' function.])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002603 AC_MSG_RESULT(yes),
2604 AC_MSG_RESULT(no)
2605)
2606
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002607AC_MSG_CHECKING(for flock)
2608AC_TRY_COMPILE([
2609#include "confdefs.h"
2610#include <sys/file.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00002611], [void* p = flock],
2612 AC_DEFINE(HAVE_FLOCK, 1, [Define if you have the 'flock' function.])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002613 AC_MSG_RESULT(yes),
2614 AC_MSG_RESULT(no)
2615)
2616
2617AC_MSG_CHECKING(for getpagesize)
2618AC_TRY_COMPILE([
2619#include "confdefs.h"
2620#include <unistd.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00002621], [void* p = getpagesize],
2622 AC_DEFINE(HAVE_GETPAGESIZE, 1, [Define if you have the 'getpagesize' function.])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002623 AC_MSG_RESULT(yes),
2624 AC_MSG_RESULT(no)
2625)
2626
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002627dnl check for true
2628AC_CHECK_PROGS(TRUE, true, /bin/true)
2629
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002630dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2631dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002632AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002633 AC_CHECK_LIB(resolv, inet_aton)
2634)
2635
Christian Heimesd0764e22007-12-04 15:00:33 +00002636# On Tru64, chflags seems to be present, but calling it will
2637# exit Python
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002638AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002639AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002640#include <sys/stat.h>
2641#include <unistd.h>
2642int main(int argc, char*argv[])
2643{
2644 if(chflags(argv[0], 0) != 0)
2645 return 1;
2646 return 0;
2647}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002648]], ac_cv_have_chflags=yes,
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002649 ac_cv_have_chflags=no,
2650 ac_cv_have_chflags=cross)
2651])
2652if test "$ac_cv_have_chflags" = cross ; then
2653 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2654fi
2655if test "$ac_cv_have_chflags" = yes ; then
Matthias Klosec80c93f2010-04-24 17:04:35 +00002656 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the `chflags' function.])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002657fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002658
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002659AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002660AC_TRY_RUN([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002661#include <sys/stat.h>
2662#include <unistd.h>
2663int main(int argc, char*argv[])
2664{
2665 if(lchflags(argv[0], 0) != 0)
2666 return 1;
2667 return 0;
2668}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002669]], ac_cv_have_lchflags=yes,
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002670 ac_cv_have_lchflags=no,
2671 ac_cv_have_lchflags=cross)
2672])
2673if test "$ac_cv_have_lchflags" = cross ; then
2674 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2675fi
2676if test "$ac_cv_have_lchflags" = yes ; then
Matthias Klosec80c93f2010-04-24 17:04:35 +00002677 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the `lchflags' function.])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002678fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002679
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002680dnl Check if system zlib has *Copy() functions
2681dnl
2682dnl On MacOSX the linker will search for dylibs on the entire linker path
2683dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2684dnl to revert to a more traditional unix behaviour and make it possible to
2685dnl override the system libz with a local static library of libz. Temporarily
2686dnl add that flag to our CFLAGS as well to ensure that we check the version
2687dnl of libz that will be used by setup.py.
2688dnl The -L/usr/local/lib is needed as wel to get the same compilation
2689dnl environment as setup.py (and leaving it out can cause configure to use the
2690dnl wrong version of the library)
2691case $ac_sys_system/$ac_sys_release in
2692Darwin/*)
2693 _CUR_CFLAGS="${CFLAGS}"
2694 _CUR_LDFLAGS="${LDFLAGS}"
2695 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2696 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2697 ;;
2698esac
2699
Matthias Klosec80c93f2010-04-24 17:04:35 +00002700AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002701
2702case $ac_sys_system/$ac_sys_release in
2703Darwin/*)
2704 CFLAGS="${_CUR_CFLAGS}"
2705 LDFLAGS="${_CUR_LDFLAGS}"
2706 ;;
2707esac
2708
Martin v. Löwise9416172003-05-03 10:12:45 +00002709AC_MSG_CHECKING(for hstrerror)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002710AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002711#include "confdefs.h"
2712#include <netdb.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00002713], [void* p = hstrerror; hstrerror(0)],
2714 AC_DEFINE(HAVE_HSTRERROR, 1, [Define if you have the 'hstrerror' function.])
Martin v. Löwise9416172003-05-03 10:12:45 +00002715 AC_MSG_RESULT(yes),
2716 AC_MSG_RESULT(no)
2717)
2718
2719AC_MSG_CHECKING(for inet_aton)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002720AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002721#include "confdefs.h"
Martin v. Löwis86d66262006-02-17 08:40:11 +00002722#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002723#include <sys/socket.h>
2724#include <netinet/in.h>
2725#include <arpa/inet.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00002726], [void* p = inet_aton;inet_aton(0,0)],
2727 AC_DEFINE(HAVE_INET_ATON, 1, [Define if you have the 'inet_aton' function.])
Martin v. Löwise9416172003-05-03 10:12:45 +00002728 AC_MSG_RESULT(yes),
2729 AC_MSG_RESULT(no)
2730)
2731
2732AC_MSG_CHECKING(for inet_pton)
2733AC_TRY_COMPILE([
2734#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002735#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002736#include <sys/socket.h>
2737#include <netinet/in.h>
2738#include <arpa/inet.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00002739], [void* p = inet_pton],
2740 AC_DEFINE(HAVE_INET_PTON, 1, [Define if you have the 'inet_pton' function.])
Martin v. Löwise9416172003-05-03 10:12:45 +00002741 AC_MSG_RESULT(yes),
2742 AC_MSG_RESULT(no)
2743)
2744
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002745# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002746AC_MSG_CHECKING(for setgroups)
2747AC_TRY_COMPILE([
2748#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002749#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002750#ifdef HAVE_GRP_H
2751#include <grp.h>
2752#endif
Martin v. Löwisd5843682002-11-21 20:41:28 +00002753],
Matthias Klosec80c93f2010-04-24 17:04:35 +00002754[void* p = setgroups],
2755 AC_DEFINE(HAVE_SETGROUPS, 1, [Define if you have the 'setgroups' function.])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002756 AC_MSG_RESULT(yes),
2757 AC_MSG_RESULT(no)
2758)
2759
Fred Drake8cef4cf2000-06-28 16:40:38 +00002760# check for openpty and forkpty
2761
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002762AC_CHECK_FUNCS(openpty,,
2763 AC_CHECK_LIB(util,openpty,
2764 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2765 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2766 )
2767)
2768AC_CHECK_FUNCS(forkpty,,
2769 AC_CHECK_LIB(util,forkpty,
2770 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2771 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2772 )
2773)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002774
Christian Heimesb186d002008-03-18 15:15:01 +00002775# Stuff for expat.
2776AC_CHECK_FUNCS(memmove)
2777
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002778# check for long file support functions
2779AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2780
Christian Heimesb186d002008-03-18 15:15:01 +00002781AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002782AC_CHECK_FUNCS(getpgrp,
2783 AC_TRY_COMPILE([#include <unistd.h>],
2784 [getpgrp(0);],
2785 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2786 [Define if getpgrp() must be called as getpgrp(0).])
2787 )
2788)
Jack Jansen150753c2003-03-29 22:07:47 +00002789AC_CHECK_FUNCS(setpgrp,
2790 AC_TRY_COMPILE([#include <unistd.h>],
2791 [setpgrp(0,0);],
2792 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2793 [Define if setpgrp() must be called as setpgrp(0, 0).])
2794 )
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002795)
2796AC_CHECK_FUNCS(gettimeofday,
2797 AC_TRY_COMPILE([#include <sys/time.h>],
2798 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2799 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2800 [Define if gettimeofday() does not have second (timezone) argument
2801 This is the case on Motorola V4 (R40V4.2)])
2802 )
2803)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002804
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002805AC_MSG_CHECKING(for major, minor, and makedev)
Martin v. Löwise3271202002-11-07 07:42:30 +00002806AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002807#if defined(MAJOR_IN_MKDEV)
2808#include <sys/mkdev.h>
2809#elif defined(MAJOR_IN_SYSMACROS)
2810#include <sys/sysmacros.h>
2811#else
2812#include <sys/types.h>
2813#endif
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002814],[
2815 makedev(major(0),minor(0));
2816],[
2817 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2818 [Define to 1 if you have the device macros.])
2819 AC_MSG_RESULT(yes)
2820],[
2821 AC_MSG_RESULT(no)
2822])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002823
2824# On OSF/1 V5.1, getaddrinfo is available, but a define
2825# for [no]getaddrinfo in netdb.h.
2826AC_MSG_CHECKING(for getaddrinfo)
2827AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002828#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002829#include <sys/socket.h>
2830#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002831#include <stdio.h>
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002832], [getaddrinfo(NULL, NULL, NULL, NULL);],
2833have_getaddrinfo=yes,
2834have_getaddrinfo=no)
2835AC_MSG_RESULT($have_getaddrinfo)
2836if test $have_getaddrinfo = yes
2837then
2838 AC_MSG_CHECKING(getaddrinfo bug)
2839 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
2840 AC_TRY_RUN([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002841#include <sys/types.h>
2842#include <netdb.h>
2843#include <string.h>
2844#include <sys/socket.h>
2845#include <netinet/in.h>
2846
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002847int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002848{
2849 int passive, gaierr, inet4 = 0, inet6 = 0;
2850 struct addrinfo hints, *ai, *aitop;
2851 char straddr[INET6_ADDRSTRLEN], strport[16];
2852
2853 for (passive = 0; passive <= 1; passive++) {
2854 memset(&hints, 0, sizeof(hints));
2855 hints.ai_family = AF_UNSPEC;
2856 hints.ai_flags = passive ? AI_PASSIVE : 0;
2857 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002858 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002859 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2860 (void)gai_strerror(gaierr);
2861 goto bad;
2862 }
2863 for (ai = aitop; ai; ai = ai->ai_next) {
2864 if (ai->ai_addr == NULL ||
2865 ai->ai_addrlen == 0 ||
2866 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2867 straddr, sizeof(straddr), strport, sizeof(strport),
2868 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2869 goto bad;
2870 }
2871 switch (ai->ai_family) {
2872 case AF_INET:
2873 if (strcmp(strport, "54321") != 0) {
2874 goto bad;
2875 }
2876 if (passive) {
2877 if (strcmp(straddr, "0.0.0.0") != 0) {
2878 goto bad;
2879 }
2880 } else {
2881 if (strcmp(straddr, "127.0.0.1") != 0) {
2882 goto bad;
2883 }
2884 }
2885 inet4++;
2886 break;
2887 case AF_INET6:
2888 if (strcmp(strport, "54321") != 0) {
2889 goto bad;
2890 }
2891 if (passive) {
2892 if (strcmp(straddr, "::") != 0) {
2893 goto bad;
2894 }
2895 } else {
2896 if (strcmp(straddr, "::1") != 0) {
2897 goto bad;
2898 }
2899 }
2900 inet6++;
2901 break;
2902 case AF_UNSPEC:
2903 goto bad;
2904 break;
2905 default:
2906 /* another family support? */
2907 break;
2908 }
2909 }
2910 }
2911
2912 if (!(inet4 == 0 || inet4 == 2))
2913 goto bad;
2914 if (!(inet6 == 0 || inet6 == 2))
2915 goto bad;
2916
2917 if (aitop)
2918 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002919 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002920
2921 bad:
2922 if (aitop)
2923 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002924 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002925}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002926]], ac_cv_buggy_getaddrinfo=no,
2927 ac_cv_buggy_getaddrinfo=yes,
2928 ac_cv_buggy_getaddrinfo=yes))
2929fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002930
Mark Dickinson2df5d282009-12-31 21:22:50 +00002931if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002932then
2933 if test $ipv6 = yes
2934 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002935 echo 'Fatal: You must get working getaddrinfo() function.'
2936 echo ' or you can specify "--disable-ipv6"'.
2937 exit 1
2938 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002939else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002940 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002941fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00002942AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002943
Guido van Rossum627b2d71993-12-24 10:39:16 +00002944# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002945AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00002946AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002947AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00002948AC_CHECK_MEMBERS([struct stat.st_rdev])
2949AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00002950AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00002951AC_CHECK_MEMBERS([struct stat.st_gen])
2952AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00002953AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002954
2955AC_MSG_CHECKING(for time.h that defines altzone)
2956AC_CACHE_VAL(ac_cv_header_time_altzone,
2957[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2958 ac_cv_header_time_altzone=yes,
2959 ac_cv_header_time_altzone=no)])
2960AC_MSG_RESULT($ac_cv_header_time_altzone)
2961if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002962 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002963fi
2964
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002965was_it_defined=no
2966AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002967AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002968#include <sys/types.h>
2969#include <sys/select.h>
2970#include <sys/time.h>
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002971], [;], [
2972 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2973 [Define if you can safely include both <sys/select.h> and <sys/time.h>
2974 (which you can't on SCO ODT 3.0).])
2975 was_it_defined=yes
2976])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00002977AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002978
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002979AC_MSG_CHECKING(for addrinfo)
2980AC_CACHE_VAL(ac_cv_struct_addrinfo,
2981AC_TRY_COMPILE([
2982# include <netdb.h>],
2983 [struct addrinfo a],
2984 ac_cv_struct_addrinfo=yes,
2985 ac_cv_struct_addrinfo=no))
2986AC_MSG_RESULT($ac_cv_struct_addrinfo)
2987if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002988 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002989fi
2990
2991AC_MSG_CHECKING(for sockaddr_storage)
2992AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2993AC_TRY_COMPILE([
2994# include <sys/types.h>
2995# include <sys/socket.h>],
2996 [struct sockaddr_storage s],
2997 ac_cv_struct_sockaddr_storage=yes,
2998 ac_cv_struct_sockaddr_storage=no))
2999AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3000if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003001 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003002fi
3003
Guido van Rossum627b2d71993-12-24 10:39:16 +00003004# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003005
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003006AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003007AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003008
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003009works=no
3010AC_MSG_CHECKING(for working volatile)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003011AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
3012 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
3013)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003014AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003015
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003016works=no
3017AC_MSG_CHECKING(for working signed char)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003018AC_TRY_COMPILE([], [signed char c;], works=yes,
3019 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
3020)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003021AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003022
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003023have_prototypes=no
3024AC_MSG_CHECKING(for prototypes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003025AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
3026 AC_DEFINE(HAVE_PROTOTYPES, 1,
3027 [Define if your compiler supports function prototype])
3028 have_prototypes=yes
3029])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003030AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003031
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003032works=no
3033AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003034AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003035#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003036int foo(int x, ...) {
3037 va_list va;
3038 va_start(va, x);
3039 va_arg(va, int);
3040 va_arg(va, char *);
3041 va_arg(va, double);
3042 return 0;
3043}
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003044], [return foo(10, "", 3.14);], [
3045 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3046 [Define if your compiler supports variable length function prototypes
3047 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3048 works=yes
3049])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003050AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003051
Dave Cole331708b2004-08-09 04:51:41 +00003052# check for socketpair
3053AC_MSG_CHECKING(for socketpair)
3054AC_TRY_COMPILE([
3055#include <sys/types.h>
3056#include <sys/socket.h>
Matthias Klosec80c93f2010-04-24 17:04:35 +00003057], [void *x=socketpair],
3058 AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
Dave Cole331708b2004-08-09 04:51:41 +00003059 AC_MSG_RESULT(yes),
3060 AC_MSG_RESULT(no)
3061)
3062
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003063# check if sockaddr has sa_len member
3064AC_MSG_CHECKING(if sockaddr has sa_len member)
3065AC_TRY_COMPILE([#include <sys/types.h>
3066#include <sys/socket.h>],
3067[struct sockaddr x;
3068x.sa_len = 0;],
3069 AC_MSG_RESULT(yes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003070 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003071 AC_MSG_RESULT(no))
3072
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003073va_list_is_array=no
3074AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003075AC_TRY_COMPILE([
3076#ifdef HAVE_STDARG_PROTOTYPES
3077#include <stdarg.h>
3078#else
3079#include <varargs.h>
3080#endif
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003081], [va_list list1, list2; list1 = list2;], , [
3082 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3083 va_list_is_array=yes
3084])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003085AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003086
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003087# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003088AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3089 [Define this if you have some version of gethostbyname_r()])
3090
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003091AC_CHECK_FUNC(gethostbyname_r, [
3092 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3093 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3094 OLD_CFLAGS=$CFLAGS
3095 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3096 AC_TRY_COMPILE([
3097# include <netdb.h>
3098 ], [
3099 char *name;
3100 struct hostent *he, *res;
3101 char buffer[2048];
3102 int buflen = 2048;
3103 int h_errnop;
3104
3105 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3106 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003107 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003108 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3109 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003110 AC_MSG_RESULT(yes)
3111 ], [
3112 AC_MSG_RESULT(no)
3113 AC_MSG_CHECKING([gethostbyname_r with 5 args])
3114 AC_TRY_COMPILE([
3115# include <netdb.h>
3116 ], [
3117 char *name;
3118 struct hostent *he;
3119 char buffer[2048];
3120 int buflen = 2048;
3121 int h_errnop;
3122
3123 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3124 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003125 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003126 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3127 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003128 AC_MSG_RESULT(yes)
3129 ], [
3130 AC_MSG_RESULT(no)
3131 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3132 AC_TRY_COMPILE([
3133# include <netdb.h>
3134 ], [
3135 char *name;
3136 struct hostent *he;
3137 struct hostent_data data;
3138
3139 (void) gethostbyname_r(name, he, &data);
3140 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003141 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003142 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3143 [Define this if you have the 3-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003144 AC_MSG_RESULT(yes)
3145 ], [
3146 AC_MSG_RESULT(no)
3147 ])
3148 ])
3149 ])
3150 CFLAGS=$OLD_CFLAGS
3151], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003152 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003153])
3154AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3155AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3156AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003157AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003158AC_SUBST(HAVE_GETHOSTBYNAME)
3159
Guido van Rossum627b2d71993-12-24 10:39:16 +00003160# checks for system services
3161# (none yet)
3162
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003163# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003164AC_CHECK_FUNC(__fpu_control,
3165 [],
3166 [AC_CHECK_LIB(ieee, __fpu_control)
3167])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003168
Guido van Rossum93274221997-05-09 02:42:00 +00003169# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003170AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003171AC_ARG_WITH(fpectl,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003172 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003173[
Guido van Rossum93274221997-05-09 02:42:00 +00003174if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003175then
3176 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3177 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3178 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003179else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003180fi],
3181[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003182
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003183# check for --with-libm=...
3184AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003185case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003186Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003187*) LIBM=-lm
3188esac
Guido van Rossum93274221997-05-09 02:42:00 +00003189AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003190AC_ARG_WITH(libm,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003191 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003192[
Guido van Rossum93274221997-05-09 02:42:00 +00003193if test "$withval" = no
3194then LIBM=
3195 AC_MSG_RESULT(force LIBM empty)
3196elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003197then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003198 AC_MSG_RESULT(set LIBM="$withval")
3199else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003200fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003201[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003202
3203# check for --with-libc=...
3204AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003205AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003206AC_ARG_WITH(libc,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003207 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003208[
Guido van Rossum93274221997-05-09 02:42:00 +00003209if test "$withval" = no
3210then LIBC=
3211 AC_MSG_RESULT(force LIBC empty)
3212elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003213then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003214 AC_MSG_RESULT(set LIBC="$withval")
3215else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003216fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003217[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003218
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003219# **************************************************
3220# * Check for various properties of floating point *
3221# **************************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003222
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003223AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3224AC_CACHE_VAL(ac_cv_little_endian_double, [
3225AC_TRY_RUN([
3226#include <string.h>
3227int main() {
3228 double x = 9006104071832581.0;
3229 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3230 return 0;
3231 else
3232 return 1;
3233}
3234],
3235ac_cv_little_endian_double=yes,
3236ac_cv_little_endian_double=no,
3237ac_cv_little_endian_double=no)])
3238AC_MSG_RESULT($ac_cv_little_endian_double)
3239if test "$ac_cv_little_endian_double" = yes
3240then
3241 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3242 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3243 with the least significant byte first])
3244fi
3245
3246AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3247AC_CACHE_VAL(ac_cv_big_endian_double, [
3248AC_TRY_RUN([
3249#include <string.h>
3250int main() {
3251 double x = 9006104071832581.0;
3252 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3253 return 0;
3254 else
3255 return 1;
3256}
3257],
3258ac_cv_big_endian_double=yes,
3259ac_cv_big_endian_double=no,
3260ac_cv_big_endian_double=no)])
3261AC_MSG_RESULT($ac_cv_big_endian_double)
3262if test "$ac_cv_big_endian_double" = yes
3263then
3264 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3265 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3266 with the most significant byte first])
3267fi
3268
3269# Some ARM platforms use a mixed-endian representation for doubles.
3270# While Python doesn't currently have full support for these platforms
3271# (see e.g., issue 1762561), we can at least make sure that float <-> string
3272# conversions work.
3273AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3274AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3275AC_TRY_RUN([
3276#include <string.h>
3277int main() {
3278 double x = 9006104071832581.0;
3279 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3280 return 0;
3281 else
3282 return 1;
3283}
3284],
3285ac_cv_mixed_endian_double=yes,
3286ac_cv_mixed_endian_double=no,
3287ac_cv_mixed_endian_double=no)])
3288AC_MSG_RESULT($ac_cv_mixed_endian_double)
3289if test "$ac_cv_mixed_endian_double" = yes
3290then
3291 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3292 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3293 in ARM mixed-endian order (byte order 45670123)])
3294fi
3295
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003296# The short float repr introduced in Python 3.1 requires the
3297# correctly-rounded string <-> double conversion functions from
3298# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3299# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003300# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003301# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003302
3303# This inline assembler syntax may also work for suncc and icc,
3304# so we try it on all platforms.
3305
3306AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3307AC_TRY_COMPILE([], [
3308 unsigned short cw;
3309 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3310 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3311],
3312[have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
3313AC_MSG_RESULT($have_gcc_asm_for_x87)
3314if test "$have_gcc_asm_for_x87" = yes
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003315then
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003316 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3317 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003318fi
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003319
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003320# Detect whether system arithmetic is subject to x87-style double
3321# rounding issues. The result of this test has little meaning on non
3322# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3323# mode is round-to-nearest and double rounding issues are present, and
3324# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3325AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003326# $BASECFLAGS may affect the result
3327ac_save_cc="$CC"
3328CC="$CC $BASECFLAGS"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003329AC_TRY_RUN([
3330#include <stdlib.h>
3331#include <math.h>
3332int main() {
3333 volatile double x, y, z;
3334 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3335 x = 0.99999999999999989; /* 1-2**-53 */
3336 y = 1./x;
3337 if (y != 1.)
3338 exit(0);
3339 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3340 x = 1e16;
3341 y = 2.99999;
3342 z = x + y;
3343 if (z != 1e16+4.)
3344 exit(0);
3345 /* both tests show evidence of double rounding */
3346 exit(1);
3347}
3348],
3349ac_cv_x87_double_rounding=no,
3350ac_cv_x87_double_rounding=yes,
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003351ac_cv_x87_double_rounding=no)
3352CC="$ac_save_cc"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003353AC_MSG_RESULT($ac_cv_x87_double_rounding)
3354if test "$ac_cv_x87_double_rounding" = yes
3355then
3356 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3357 [Define if arithmetic is subject to x87-style double rounding issue])
3358fi
3359
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003360# ************************************
3361# * Check for mathematical functions *
3362# ************************************
3363
3364LIBS_SAVE=$LIBS
3365LIBS="$LIBS $LIBM"
3366
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003367# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3368# -0. on some architectures.
3369AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3370AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3371AC_TRY_RUN([
3372#include <math.h>
3373#include <stdlib.h>
3374int main() {
3375 /* return 0 if either negative zeros don't exist
3376 on this platform or if negative zeros exist
3377 and tanh(-0.) == -0. */
3378 if (atan2(0., -1.) == atan2(-0., -1.) ||
3379 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3380 else exit(1);
3381}
3382],
3383ac_cv_tanh_preserves_zero_sign=yes,
3384ac_cv_tanh_preserves_zero_sign=no,
3385ac_cv_tanh_preserves_zero_sign=no)])
3386AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3387if test "$ac_cv_tanh_preserves_zero_sign" = yes
3388then
3389 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3390 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3391fi
3392
Mark Dickinson9c113362009-09-05 10:36:23 +00003393AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3394AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003395AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
Christian Heimes99170a52007-12-19 02:07:34 +00003396
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003397LIBS=$LIBS_SAVE
3398
Mark Dickinsona614f042009-11-28 12:48:43 +00003399# For multiprocessing module, check that sem_open
3400# actually works. For FreeBSD versions <= 7.2,
3401# the kernel module that provides POSIX semaphores
3402# isn't loaded by default, so an attempt to call
3403# sem_open results in a 'Signal 12' error.
3404AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3405AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
3406AC_TRY_RUN([
3407#include <unistd.h>
3408#include <fcntl.h>
3409#include <stdio.h>
3410#include <semaphore.h>
3411#include <sys/stat.h>
3412
3413int main(void) {
3414 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3415 if (a == SEM_FAILED) {
3416 perror("sem_open");
3417 return 1;
3418 }
3419 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003420 sem_unlink("/autoconf");
Mark Dickinsona614f042009-11-28 12:48:43 +00003421 return 0;
3422}
3423], ac_cv_posix_semaphores_enabled=yes,
3424 ac_cv_posix_semaphores_enabled=no,
3425 ac_cv_posix_semaphores_enabled=yes)
3426)
3427AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3428if test $ac_cv_posix_semaphores_enabled = no
3429then
3430 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3431 [Define if POSIX semaphores aren't enabled on your system])
3432fi
3433
Mark Dickinson10683072009-04-18 21:18:19 +00003434# Multiprocessing check for broken sem_getvalue
3435AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003436AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Mark Dickinson10683072009-04-18 21:18:19 +00003437AC_TRY_RUN([
3438#include <unistd.h>
3439#include <fcntl.h>
3440#include <stdio.h>
3441#include <semaphore.h>
3442#include <sys/stat.h>
3443
3444int main(void){
Mark Dickinsonba79b352009-12-13 21:10:57 +00003445 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Mark Dickinson10683072009-04-18 21:18:19 +00003446 int count;
3447 int res;
3448 if(a==SEM_FAILED){
3449 perror("sem_open");
3450 return 1;
3451
3452 }
3453 res = sem_getvalue(a, &count);
3454 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003455 sem_unlink("/autocftw");
Mark Dickinson10683072009-04-18 21:18:19 +00003456 return res==-1 ? 1 : 0;
3457}
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003458], ac_cv_broken_sem_getvalue=no,
3459 ac_cv_broken_sem_getvalue=yes,
3460 ac_cv_broken_sem_getvalue=yes)
Mark Dickinson10683072009-04-18 21:18:19 +00003461)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003462AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3463if test $ac_cv_broken_sem_getvalue = yes
3464then
3465 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3466 [define to 1 if your sem_getvalue is broken.])
3467fi
Mark Dickinson10683072009-04-18 21:18:19 +00003468
Mark Dickinsonbd792642009-03-18 20:06:12 +00003469# determine what size digit to use for Python's longs
3470AC_MSG_CHECKING([digit size for Python's longs])
3471AC_ARG_ENABLE(big-digits,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003472AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonbd792642009-03-18 20:06:12 +00003473[case $enable_big_digits in
3474yes)
3475 enable_big_digits=30 ;;
3476no)
3477 enable_big_digits=15 ;;
3478[15|30])
3479 ;;
3480*)
3481 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3482esac
3483AC_MSG_RESULT($enable_big_digits)
3484AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3485],
3486[AC_MSG_RESULT(no value specified)])
3487
Guido van Rossumef2255b2000-03-10 22:30:29 +00003488# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003489AC_CHECK_HEADER(wchar.h, [
3490 AC_DEFINE(HAVE_WCHAR_H, 1,
3491 [Define if the compiler provides a wchar.h header file.])
3492 wchar_h="yes"
3493],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003494wchar_h="no"
3495)
3496
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003497# determine wchar_t size
3498if test "$wchar_h" = yes
3499then
Guido van Rossum67b26592001-10-20 14:21:45 +00003500 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003501fi
3502
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003503AC_MSG_CHECKING(for UCS-4 tcl)
3504have_ucs4_tcl=no
3505AC_TRY_COMPILE([
3506#include <tcl.h>
3507#if TCL_UTF_MAX != 6
3508# error "NOT UCS4_TCL"
3509#endif], [], [
3510 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3511 have_ucs4_tcl=yes
3512])
3513AC_MSG_RESULT($have_ucs4_tcl)
3514
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003515# check whether wchar_t is signed or not
3516if test "$wchar_h" = yes
3517then
3518 # check whether wchar_t is signed or not
3519 AC_MSG_CHECKING(whether wchar_t is signed)
3520 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3521 AC_TRY_RUN([
3522 #include <wchar.h>
3523 int main()
3524 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003525 /* Success: exit code 0 */
3526 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003527 }
3528 ],
3529 ac_cv_wchar_t_signed=yes,
3530 ac_cv_wchar_t_signed=no,
3531 ac_cv_wchar_t_signed=yes)])
3532 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3533fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003534
Georg Brandl52d168a2008-01-07 18:10:24 +00003535AC_MSG_CHECKING(what type to use for str)
3536AC_ARG_WITH(wide-unicode,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003537 AS_HELP_STRING([--with-wide-unicode], [Use 4-byte Unicode characters (default is 2 bytes)]),
Georg Brandl52d168a2008-01-07 18:10:24 +00003538[
3539if test "$withval" != no
3540then unicode_size="4"
3541else unicode_size="2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003542fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003543],
3544[
3545case "$have_ucs4_tcl" in
3546 yes) unicode_size="4" ;;
3547 *) unicode_size="2" ;;
3548esac
3549])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003550
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003551AH_TEMPLATE(Py_UNICODE_SIZE,
3552 [Define as the size of the unicode type.])
Georg Brandl52d168a2008-01-07 18:10:24 +00003553case "$unicode_size" in
3554 4) AC_DEFINE(Py_UNICODE_SIZE, 4) ;;
3555 *) AC_DEFINE(Py_UNICODE_SIZE, 2) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003556esac
3557
Martin v. Löwis11437992002-04-12 09:54:03 +00003558AH_TEMPLATE(PY_UNICODE_TYPE,
3559 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003560
Georg Brandl52d168a2008-01-07 18:10:24 +00003561# wchar_t is only usable if it maps to an unsigned type
3562if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003563 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00003564then
3565 PY_UNICODE_TYPE="wchar_t"
3566 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3567 [Define if you have a useable wchar_t type defined in wchar.h; useable
3568 means wchar_t must be an unsigned type with at least 16 bits. (see
3569 Include/unicodeobject.h).])
3570 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3571elif test "$ac_cv_sizeof_short" = "$unicode_size"
3572then
3573 PY_UNICODE_TYPE="unsigned short"
3574 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3575elif test "$ac_cv_sizeof_long" = "$unicode_size"
3576then
3577 PY_UNICODE_TYPE="unsigned long"
3578 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3579else
3580 PY_UNICODE_TYPE="no type found"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003581fi
Georg Brandl52d168a2008-01-07 18:10:24 +00003582AC_MSG_RESULT($PY_UNICODE_TYPE)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003583
3584# check for endianness
3585AC_C_BIGENDIAN
3586
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003587# Check whether right shifting a negative integer extends the sign bit
3588# or fills with zeros (like the Cray J90, according to Tim Peters).
3589AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003590AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003591AC_TRY_RUN([
3592int main()
3593{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003594 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003595}
Guido van Rossum3065c942001-09-17 04:03:14 +00003596],
3597ac_cv_rshift_extends_sign=yes,
3598ac_cv_rshift_extends_sign=no,
3599ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003600AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3601if test "$ac_cv_rshift_extends_sign" = no
3602then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003603 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3604 [Define if i>>j for signed int i does not extend the sign bit
3605 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003606fi
3607
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003608# check for getc_unlocked and related locking functions
3609AC_MSG_CHECKING(for getc_unlocked() and friends)
3610AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3611AC_TRY_LINK([#include <stdio.h>],[
3612 FILE *f = fopen("/dev/null", "r");
3613 flockfile(f);
3614 getc_unlocked(f);
3615 funlockfile(f);
3616], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3617AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3618if test "$ac_cv_have_getc_unlocked" = yes
3619then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003620 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3621 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003622fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003623
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003624# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003625# save the value of LIBS so we don't actually link Python with readline
3626LIBS_no_readline=$LIBS
Gregory P. Smith18820942008-09-07 06:24:49 +00003627
3628# On some systems we need to link readline to a termcap compatible
3629# library. NOTE: Keep the precedence of listed libraries synchronised
3630# with setup.py.
3631py_cv_lib_readline=no
3632AC_MSG_CHECKING([how to link readline libs])
3633for py_libtermcap in "" ncursesw ncurses curses termcap; do
3634 if test -z "$py_libtermcap"; then
3635 READLINE_LIBS="-lreadline"
3636 else
3637 READLINE_LIBS="-lreadline -l$py_libtermcap"
3638 fi
3639 LIBS="$READLINE_LIBS $LIBS_no_readline"
3640 AC_LINK_IFELSE(
3641 [AC_LANG_CALL([],[readline])],
3642 [py_cv_lib_readline=yes])
3643 if test $py_cv_lib_readline = yes; then
3644 break
3645 fi
3646done
3647# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3648#AC_SUBST([READLINE_LIBS])
Gregory P. Smith97515912008-09-07 19:23:19 +00003649if test $py_cv_lib_readline = no; then
Gregory P. Smith18820942008-09-07 06:24:49 +00003650 AC_MSG_RESULT([none])
3651else
3652 AC_MSG_RESULT([$READLINE_LIBS])
3653 AC_DEFINE(HAVE_LIBREADLINE, 1,
3654 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003655fi
3656
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003657# check for readline 2.1
3658AC_CHECK_LIB(readline, rl_callback_handler_install,
3659 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003660 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003661
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003662# check for readline 2.2
3663AC_TRY_CPP([#include <readline/readline.h>],
3664have_readline=yes, have_readline=no)
3665if test $have_readline = yes
3666then
3667 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3668 [readline/readline.h],
3669 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3670 [Define if you have readline 2.2]), )
Antoine Pitroud5131772009-10-26 19:22:14 +00003671 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3672 [readline/readline.h],
3673 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3674 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003675fi
3676
Martin v. Löwis0daad592001-09-30 21:09:59 +00003677# check for readline 4.0
3678AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003679 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003680 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003681
Thomas Wouters89d996e2007-09-08 17:39:28 +00003682# also in 4.0
3683AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3684 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003685 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Thomas Wouters89d996e2007-09-08 17:39:28 +00003686
Guido van Rossum353ae582001-07-10 16:45:32 +00003687# check for readline 4.2
3688AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003689 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003690 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003691
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003692# also in readline 4.2
3693AC_TRY_CPP([#include <readline/readline.h>],
3694have_readline=yes, have_readline=no)
3695if test $have_readline = yes
3696then
3697 AC_EGREP_HEADER([extern int rl_catch_signals;],
3698 [readline/readline.h],
3699 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3700 [Define if you can turn off readline's signal handling.]), )
3701fi
3702
Martin v. Löwis82bca632006-02-10 20:49:30 +00003703# End of readline checks: restore LIBS
3704LIBS=$LIBS_no_readline
3705
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003706AC_MSG_CHECKING(for broken nice())
3707AC_CACHE_VAL(ac_cv_broken_nice, [
3708AC_TRY_RUN([
3709int main()
3710{
3711 int val1 = nice(1);
3712 if (val1 != -1 && val1 == nice(2))
3713 exit(0);
3714 exit(1);
3715}
Guido van Rossum3065c942001-09-17 04:03:14 +00003716],
3717ac_cv_broken_nice=yes,
3718ac_cv_broken_nice=no,
3719ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003720AC_MSG_RESULT($ac_cv_broken_nice)
3721if test "$ac_cv_broken_nice" = yes
3722then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003723 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3724 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003725fi
3726
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003727AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003728AC_CACHE_VAL(ac_cv_broken_poll,
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003729AC_TRY_RUN([
3730#include <poll.h>
3731
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003732int main()
3733{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003734 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003735 int poll_test;
3736
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003737 close (42);
3738
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003739 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003740 if (poll_test < 0)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003741 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003742 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003743 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003744 else
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003745 return 1;
3746}
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003747],
3748ac_cv_broken_poll=yes,
3749ac_cv_broken_poll=no,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003750ac_cv_broken_poll=no))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003751AC_MSG_RESULT($ac_cv_broken_poll)
3752if test "$ac_cv_broken_poll" = yes
3753then
3754 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3755 [Define if poll() sets errno on invalid file descriptors.])
3756fi
3757
Brett Cannon43802422005-02-10 20:48:03 +00003758# Before we can test tzset, we need to check if struct tm has a tm_zone
3759# (which is not required by ISO C or UNIX spec) and/or if we support
3760# tzname[]
3761AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003762
Brett Cannon43802422005-02-10 20:48:03 +00003763# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003764AC_MSG_CHECKING(for working tzset())
3765AC_CACHE_VAL(ac_cv_working_tzset, [
3766AC_TRY_RUN([
3767#include <stdlib.h>
3768#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003769#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003770
3771#if HAVE_TZNAME
3772extern char *tzname[];
3773#endif
3774
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003775int main()
3776{
Brett Cannon18367812003-09-19 00:59:16 +00003777 /* Note that we need to ensure that not only does tzset(3)
3778 do 'something' with localtime, but it works as documented
3779 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003780 This includes making sure that tzname is set properly if
3781 tm->tm_zone does not exist since it is the alternative way
3782 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003783
3784 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003785 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003786 */
3787
Brett Cannon43802422005-02-10 20:48:03 +00003788 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003789 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3790
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003791 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003792 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003793 if (localtime(&groundhogday)->tm_hour != 0)
3794 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003795#if HAVE_TZNAME
3796 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3797 if (strcmp(tzname[0], "UTC") ||
3798 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3799 exit(1);
3800#endif
Brett Cannon18367812003-09-19 00:59:16 +00003801
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003802 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003803 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003804 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003805 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003806#if HAVE_TZNAME
3807 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3808 exit(1);
3809#endif
Brett Cannon18367812003-09-19 00:59:16 +00003810
3811 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3812 tzset();
3813 if (localtime(&groundhogday)->tm_hour != 11)
3814 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003815#if HAVE_TZNAME
3816 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3817 exit(1);
3818#endif
3819
3820#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00003821 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3822 exit(1);
3823 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3824 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003825#endif
Brett Cannon18367812003-09-19 00:59:16 +00003826
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003827 exit(0);
3828}
3829],
3830ac_cv_working_tzset=yes,
3831ac_cv_working_tzset=no,
3832ac_cv_working_tzset=no)])
3833AC_MSG_RESULT($ac_cv_working_tzset)
3834if test "$ac_cv_working_tzset" = yes
3835then
3836 AC_DEFINE(HAVE_WORKING_TZSET, 1,
3837 [Define if tzset() actually switches the local timezone in a meaningful way.])
3838fi
3839
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003840# Look for subsecond timestamps in struct stat
3841AC_MSG_CHECKING(for tv_nsec in struct stat)
3842AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3843AC_TRY_COMPILE([#include <sys/stat.h>], [
3844struct stat st;
3845st.st_mtim.tv_nsec = 1;
3846],
Martin v. Löwisa32c9942002-09-09 16:17:47 +00003847ac_cv_stat_tv_nsec=yes,
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003848ac_cv_stat_tv_nsec=no,
3849ac_cv_stat_tv_nsec=no))
3850AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3851if test "$ac_cv_stat_tv_nsec" = yes
3852then
3853 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3854 [Define if you have struct stat.st_mtim.tv_nsec])
3855fi
3856
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003857# Look for BSD style subsecond timestamps in struct stat
3858AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3859AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3860AC_TRY_COMPILE([#include <sys/stat.h>], [
3861struct stat st;
3862st.st_mtimespec.tv_nsec = 1;
3863],
3864ac_cv_stat_tv_nsec2=yes,
3865ac_cv_stat_tv_nsec2=no,
3866ac_cv_stat_tv_nsec2=no))
3867AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3868if test "$ac_cv_stat_tv_nsec2" = yes
3869then
3870 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3871 [Define if you have struct stat.st_mtimensec])
3872fi
3873
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003874# On HP/UX 11.0, mvwdelch is a block with a return statement
3875AC_MSG_CHECKING(whether mvwdelch is an expression)
3876AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3877AC_TRY_COMPILE([#include <curses.h>], [
3878 int rtn;
3879 rtn = mvwdelch(0,0,0);
3880], ac_cv_mvwdelch_is_expression=yes,
3881 ac_cv_mvwdelch_is_expression=no,
3882 ac_cv_mvwdelch_is_expression=yes))
3883AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3884
3885if test "$ac_cv_mvwdelch_is_expression" = yes
3886then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003887 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3888 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003889fi
3890
3891AC_MSG_CHECKING(whether WINDOW has _flags)
3892AC_CACHE_VAL(ac_cv_window_has_flags,
3893AC_TRY_COMPILE([#include <curses.h>], [
3894 WINDOW *w;
3895 w->_flags = 0;
3896], ac_cv_window_has_flags=yes,
3897 ac_cv_window_has_flags=no,
3898 ac_cv_window_has_flags=no))
3899AC_MSG_RESULT($ac_cv_window_has_flags)
3900
3901
3902if test "$ac_cv_window_has_flags" = yes
3903then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003904 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
3905 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003906fi
3907
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003908AC_MSG_CHECKING(for is_term_resized)
Matthias Klosec80c93f2010-04-24 17:04:35 +00003909AC_TRY_COMPILE([#include <curses.h>], [void *x=is_term_resized],
3910 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, [Define if you have the 'is_term_resized' function.])
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003911 AC_MSG_RESULT(yes),
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003912 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003913)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00003914
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003915AC_MSG_CHECKING(for resize_term)
Matthias Klosec80c93f2010-04-24 17:04:35 +00003916AC_TRY_COMPILE([#include <curses.h>], [void *x=resize_term],
3917 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, [Define if you have the 'resize_term' function.])
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003918 AC_MSG_RESULT(yes),
Neal Norwitz865400f2003-03-21 01:42:58 +00003919 AC_MSG_RESULT(no)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003920)
3921
3922AC_MSG_CHECKING(for resizeterm)
Matthias Klosec80c93f2010-04-24 17:04:35 +00003923AC_TRY_COMPILE([#include <curses.h>], [void *x=resizeterm],
3924 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, [Define if you have the 'resizeterm' function.])
Thomas Wouters0e3f5912006-08-11 14:57:12 +00003925 AC_MSG_RESULT(yes),
3926 AC_MSG_RESULT(no)
3927)
3928
Thomas Wouters89f507f2006-12-13 04:49:30 +00003929AC_MSG_CHECKING(for /dev/ptmx)
3930
3931if test -r /dev/ptmx
3932then
3933 AC_MSG_RESULT(yes)
3934 AC_DEFINE(HAVE_DEV_PTMX, 1,
3935 [Define if we have /dev/ptmx.])
3936else
3937 AC_MSG_RESULT(no)
3938fi
3939
3940AC_MSG_CHECKING(for /dev/ptc)
3941
3942if test -r /dev/ptc
3943then
3944 AC_MSG_RESULT(yes)
3945 AC_DEFINE(HAVE_DEV_PTC, 1,
3946 [Define if we have /dev/ptc.])
3947else
3948 AC_MSG_RESULT(no)
3949fi
Neal Norwitz865400f2003-03-21 01:42:58 +00003950
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00003951if test "$have_long_long" = yes
3952then
3953 AC_MSG_CHECKING(for %lld and %llu printf() format support)
3954 AC_CACHE_VAL(ac_cv_have_long_long_format,
3955 AC_TRY_RUN([[
3956 #include <stdio.h>
3957 #include <stddef.h>
3958 #include <string.h>
3959
3960 #ifdef HAVE_SYS_TYPES_H
3961 #include <sys/types.h>
3962 #endif
3963
3964 int main()
3965 {
3966 char buffer[256];
3967
3968 if (sprintf(buffer, "%lld", (long long)123) < 0)
3969 return 1;
3970 if (strcmp(buffer, "123"))
3971 return 1;
3972
3973 if (sprintf(buffer, "%lld", (long long)-123) < 0)
3974 return 1;
3975 if (strcmp(buffer, "-123"))
3976 return 1;
3977
3978 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
3979 return 1;
3980 if (strcmp(buffer, "123"))
3981 return 1;
3982
3983 return 0;
3984 }
3985 ]], ac_cv_have_long_long_format=yes,
3986 ac_cv_have_long_long_format=no,
3987 ac_cv_have_long_long_format=no)
3988 )
3989 AC_MSG_RESULT($ac_cv_have_long_long_format)
3990fi
3991
Mark Dickinson89d7d412009-12-31 20:50:59 +00003992if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00003993then
3994 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
3995 [Define to printf format modifier for long long type])
3996fi
3997
Ronald Oussoren3c1928a2009-11-19 17:15:31 +00003998if test $ac_sys_system = Darwin
3999then
4000 LIBS="$LIBS -framework CoreFoundation"
4001fi
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004002
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004003AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
4004AC_TRY_RUN([
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00004005#include <stdio.h>
Thomas Wouters477c8d52006-05-27 19:21:47 +00004006#include <stddef.h>
4007#include <string.h>
4008
Christian Heimes2c181612007-12-17 20:04:13 +00004009#ifdef HAVE_SYS_TYPES_H
4010#include <sys/types.h>
4011#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00004012
4013#ifdef HAVE_SSIZE_T
4014typedef ssize_t Py_ssize_t;
4015#elif SIZEOF_VOID_P == SIZEOF_LONG
4016typedef long Py_ssize_t;
4017#else
4018typedef int Py_ssize_t;
4019#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00004020
Christian Heimes2c181612007-12-17 20:04:13 +00004021int main()
4022{
4023 char buffer[256];
4024
Thomas Wouters477c8d52006-05-27 19:21:47 +00004025 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4026 return 1;
4027
Thomas Wouters89f507f2006-12-13 04:49:30 +00004028 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00004029 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00004030
4031 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4032 return 1;
4033
4034 if (strcmp(buffer, "-123"))
4035 return 1;
4036
Thomas Wouters477c8d52006-05-27 19:21:47 +00004037 return 0;
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004038}
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004039], ac_cv_have_size_t_format=yes,
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00004040 ac_cv_have_size_t_format=no,
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004041 [ac_cv_have_size_t_format="cross -- assuming yes"]
4042)])
4043if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004044 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4045 [Define to printf format modifier for Py_ssize_t])
4046fi
Thomas Wouters477c8d52006-05-27 19:21:47 +00004047
Martin v. Löwis01c04012002-11-11 14:58:44 +00004048AC_CHECK_TYPE(socklen_t,,
4049 AC_DEFINE(socklen_t,int,
Matthias Klosec80c93f2010-04-24 17:04:35 +00004050 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004051#ifdef HAVE_SYS_TYPES_H
4052#include <sys/types.h>
4053#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004054#ifdef HAVE_SYS_SOCKET_H
4055#include <sys/socket.h>
4056#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004057])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004058
Antoine Pitroufff95302008-09-03 18:58:51 +00004059AC_MSG_CHECKING(for broken mbstowcs)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004060AC_CACHE_VAL(ac_cv_broken_mbstowcs,
Antoine Pitroufff95302008-09-03 18:58:51 +00004061AC_TRY_RUN([
4062#include<stdlib.h>
4063int main() {
4064 size_t len = -1;
4065 const char *str = "text";
4066 len = mbstowcs(NULL, str, 0);
4067 return (len != 4);
4068}
4069],
4070ac_cv_broken_mbstowcs=no,
4071ac_cv_broken_mbstowcs=yes,
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004072ac_cv_broken_mbstowcs=no))
Antoine Pitroufff95302008-09-03 18:58:51 +00004073AC_MSG_RESULT($ac_cv_broken_mbstowcs)
4074if test "$ac_cv_broken_mbstowcs" = yes
4075then
4076 AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
4077 [Define if mbstowcs(NULL, "text", 0) does not return the number of
4078 wide chars that would be converted.])
4079fi
4080
Antoine Pitroub52ec782009-01-25 16:34:23 +00004081# Check for --with-computed-gotos
4082AC_MSG_CHECKING(for --with-computed-gotos)
4083AC_ARG_WITH(computed-gotos,
Matthias Klose2b8733f2010-04-25 18:34:36 +00004084 AS_HELP_STRING([--with-computed-gotos],
Matthias Klosec80c93f2010-04-24 17:04:35 +00004085 [Use computed gotos / threaded dispatch in evaluation loop (not available on all compilers)]),
Antoine Pitroub52ec782009-01-25 16:34:23 +00004086[
4087if test "$withval" != no
4088then
4089 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4090 [Define if you want to use computed gotos in ceval.c.])
4091 AC_MSG_RESULT(yes)
4092else AC_MSG_RESULT(no)
4093fi],
4094[AC_MSG_RESULT(no)])
4095
4096
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004097AC_SUBST(THREADHEADERS)
4098
4099for h in `(cd $srcdir;echo Python/thread_*.h)`
4100do
4101 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4102done
4103
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004104AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004105SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004106AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004107for dir in $SRCDIRS; do
4108 if test ! -d $dir; then
4109 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004110 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004111done
4112AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004113
Guido van Rossum627b2d71993-12-24 10:39:16 +00004114# generate output files
Antoine Pitrou20327222009-05-24 20:39:11 +00004115AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Martin v. Löwis88afe662002-10-26 13:47:44 +00004116AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004117
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004118echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004119if test ! -f Modules/Setup
4120then
4121 cp $srcdir/Modules/Setup.dist Modules/Setup
4122fi
4123
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004124echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004125if test ! -f Modules/Setup.local
4126then
4127 echo "# Edit this file for local setup changes" >Modules/Setup.local
4128fi
4129
4130echo "creating Makefile"
4131$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4132 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004133 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00004134mv config.c Modules