blob: 66da672cbef0ee070709d0295b3f3ab2cfc36725 [file] [log] [blame]
Benjamin Petersond7c77842008-05-26 13:01:25 +00001dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
Georg Brandl5c7f8fb2008-12-05 09:00:55 +00004dnl NOTE: autoconf 2.64 doesn't seem to work (use 2.61).
Martin v. Löwis88afe662002-10-26 13:47:44 +00005
6# Set VERSION so we only need to edit in one place (i.e., here)
Neal Norwitz9be57322006-08-18 05:39:20 +00007m4_define(PYTHON_VERSION, 2.6)
Martin v. Löwis88afe662002-10-26 13:47:44 +00008
Guido van Rossum76be6ed1995-01-02 18:33:54 +00009AC_REVISION($Revision$)
Martin v. Löwiseba40652007-08-30 20:10:57 +000010AC_PREREQ(2.61)
Martin v. Löwis1d459062005-03-14 21:23:33 +000011AC_INIT(python, PYTHON_VERSION, http://www.python.org/python-bugs)
Martin v. Löwis88afe662002-10-26 13:47:44 +000012AC_CONFIG_SRCDIR([Include/object.h])
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000013AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +000014
Martin v. Löwis8316feb2003-06-14 07:48:07 +000015dnl This is for stuff that absolutely must end up in pyconfig.h.
16dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000017AH_TOP([
18#ifndef Py_PYCONFIG_H
19#define Py_PYCONFIG_H
20])
Martin v. Löwis11437992002-04-12 09:54:03 +000021AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000022/* Define the macros needed if on a UnixWare 7.x system. */
23#if defined(__USLC__) && defined(__SCO_VERSION__)
24#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
25#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000026
27#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000028])
29
Martin v. Löwis8316feb2003-06-14 07:48:07 +000030# We don't use PACKAGE_ variables, and they cause conflicts
31# with other autoconf-based packages that include Python.h
32grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
33rm confdefs.h
34mv confdefs.h.new confdefs.h
35
Guido van Rossum642b6781997-07-19 19:35:41 +000036AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000037VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000038
Martin v. Löwis1142de32002-03-29 16:28:31 +000039AC_SUBST(SOVERSION)
40SOVERSION=1.0
41
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000042# The later defininition of _XOPEN_SOURCE disables certain features
43# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
44AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
45
Martin v. Löwisbcd93962003-05-03 10:32:18 +000046# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
47# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
48# them.
49AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
50
Andrew MacIntyreabccf412003-07-02 13:53:25 +000051# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
52# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
53# them.
54AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
55
Martin v. Löwisd6320502004-08-12 13:45:08 +000056# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
57# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
58AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
59
Ronald Oussoren5640ce22008-06-05 12:58:24 +000060# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
61# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
62# them.
63AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
64
65
Martin v. Löwise981a4e2002-11-11 13:26:51 +000066define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000067
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +000068# Arguments passed to configure.
69AC_SUBST(CONFIG_ARGS)
70CONFIG_ARGS="$ac_configure_args"
71
Ronald Oussoren9b831f42010-02-07 11:57:14 +000072AC_MSG_CHECKING([for --enable-universalsdk])
Ronald Oussoren988117f2006-04-29 11:31:35 +000073AC_ARG_ENABLE(universalsdk,
Brett Cannon91a1dec2008-02-13 19:15:44 +000074 AC_HELP_STRING(--enable-universalsdk@<:@=SDKDIR@:>@, Build against Mac OS X 10.4u SDK (ppc/i386)),
Ronald Oussoren988117f2006-04-29 11:31:35 +000075[
76 case $enableval in
77 yes)
78 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren9b831f42010-02-07 11:57:14 +000079 if test ! -d "${enableval}"
80 then
81 enableval=/
82 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +000083 ;;
84 esac
85 case $enableval in
86 no)
87 UNIVERSALSDK=
88 enable_universalsdk=
89 ;;
90 *)
91 UNIVERSALSDK=$enableval
Ronald Oussoren9b831f42010-02-07 11:57:14 +000092 if test ! -d "${UNIVERSALSDK}"
93 then
94 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
95 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +000096 ;;
97 esac
Ronald Oussoren9b831f42010-02-07 11:57:14 +000098
Ronald Oussoren988117f2006-04-29 11:31:35 +000099],[
100 UNIVERSALSDK=
101 enable_universalsdk=
102])
Ronald Oussoren9b831f42010-02-07 11:57:14 +0000103if test -n "${UNIVERSALSDK}"
104then
105 AC_MSG_RESULT(${UNIVERSALSDK})
106else
107 AC_MSG_RESULT(no)
108fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000109AC_SUBST(UNIVERSALSDK)
110
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000111AC_SUBST(ARCH_RUN_32BIT)
112
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000113UNIVERSAL_ARCHS="32-bit"
114AC_MSG_CHECKING(for --with-universal-archs)
115AC_ARG_WITH(universal-archs,
Ronald Oussoren7ab74352009-09-08 07:10:07 +0000116 AC_HELP_STRING(--with-universal-archs=ARCH, select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")),
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000117[
118 AC_MSG_RESULT($withval)
119 UNIVERSAL_ARCHS="$withval"
Ronald Oussorend0841712009-09-29 13:01:59 +0000120 if test "${enable_universalsdk}" ; then
121 :
122 else
123 AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
124 fi
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000125],
126[
127 AC_MSG_RESULT(32-bit)
128])
129
130
131
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000132AC_ARG_WITH(framework-name,
133 AC_HELP_STRING(--with-framework-name=FRAMEWORK,
134 specify an alternate name of the framework built with --enable-framework),
135[
Ronald Oussorend0841712009-09-29 13:01:59 +0000136 if test "${enable_framework}"; then
137 :
138 else
139 AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
140 fi
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000141 PYTHONFRAMEWORK=${withval}
142 PYTHONFRAMEWORKDIR=${withval}.framework
143 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
144 ],[
145 PYTHONFRAMEWORK=Python
146 PYTHONFRAMEWORKDIR=Python.framework
147 PYTHONFRAMEWORKIDENTIFIER=org.python.python
148])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000149dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000150AC_ARG_ENABLE(framework,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000151 AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
152[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000153 case $enableval in
154 yes)
155 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000156 esac
157 case $enableval in
158 no)
159 PYTHONFRAMEWORK=
160 PYTHONFRAMEWORKDIR=no-framework
161 PYTHONFRAMEWORKPREFIX=
162 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000163 FRAMEWORKINSTALLFIRST=
164 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000165 FRAMEWORKALTINSTALLFIRST=
166 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000167 if test "x${prefix}" = "xNONE"; then
168 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
169 else
170 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
171 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000172 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000173 ;;
174 *)
175 PYTHONFRAMEWORKPREFIX=$enableval
Jack Jansen127e56e2001-09-11 14:41:54 +0000176 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000177 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000178 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
179 if test "$UNIVERSAL_ARCHS" = "all"
180 then
181 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps4way frameworkinstallunixtools4way"
Ronald Oussoren75d83852009-03-30 17:56:14 +0000182 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps4way frameworkaltinstallunixtools4way"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000183 else
Ronald Oussoren75d83852009-03-30 17:56:14 +0000184 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000185 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
186 fi
187
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000188 if test "x${prefix}" = "xNONE" ; then
189 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
190 else
191 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
192 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000193 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Ronald Oussoren836b0392006-05-14 19:56:34 +0000194
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000195 # Add files for Mac specific code to the list of output
Ronald Oussoren836b0392006-05-14 19:56:34 +0000196 # files:
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000197 AC_CONFIG_FILES(Mac/Makefile)
198 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
199 AC_CONFIG_FILES(Mac/IDLE/Makefile)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +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=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000208 FRAMEWORKINSTALLFIRST=
209 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000210 FRAMEWORKALTINSTALLFIRST=
211 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000212 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=
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000218
219 if test "$UNIVERSAL_ARCHS" = "all"
220 then
221 FRAMEWORKINSTALLLAST=update4wayuniversal
222 FRAMEWORKALTINSTALLLAST=update4wayuniversal
223 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000224])
225AC_SUBST(PYTHONFRAMEWORK)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000226AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000227AC_SUBST(PYTHONFRAMEWORKDIR)
228AC_SUBST(PYTHONFRAMEWORKPREFIX)
229AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000230AC_SUBST(FRAMEWORKINSTALLFIRST)
231AC_SUBST(FRAMEWORKINSTALLLAST)
Ronald Oussoren5b787322006-06-06 19:50:24 +0000232AC_SUBST(FRAMEWORKALTINSTALLFIRST)
233AC_SUBST(FRAMEWORKALTINSTALLLAST)
234AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000235
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000236##AC_ARG_WITH(dyld,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000237## AC_HELP_STRING(--with-dyld,
238## Use (OpenStep|Rhapsody) dynamic linker))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000239##
Guido van Rossumb418f891996-07-30 18:06:02 +0000240# Set name for machine-dependent library files
241AC_SUBST(MACHDEP)
242AC_MSG_CHECKING(MACHDEP)
243if test -z "$MACHDEP"
244then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000245 ac_sys_system=`uname -s`
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000246 if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64" \
247 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000248 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000249 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000250 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000251 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000252 ac_md_system=`echo $ac_sys_system |
253 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
254 ac_md_release=`echo $ac_sys_release |
Guido van Rossum67b26592001-10-20 14:21:45 +0000255 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +0000256 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000257
Guido van Rossumbcd91e01997-03-20 20:46:29 +0000258 case $MACHDEP in
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000259 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000260 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000261 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000262 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000263 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000264 esac
265fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000266
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000267# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
268# disable features if it is defined, without any means to access these
269# features as extensions. For these systems, we skip the definition of
270# _XOPEN_SOURCE. Before adding a system to the list to gain access to
271# some feature, make sure there is no alternative way to access this
272# feature. Also, when using wildcards, make sure you have verified the
273# need for not defining _XOPEN_SOURCE on all systems matching the
274# wildcard, and that the wildcard does not include future systems
275# (which may remove their limitations).
276dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
277case $ac_sys_system/$ac_sys_release in
278 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
279 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000280 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Gregory P. Smith980b99b2008-09-07 05:15:18 +0000281 OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0123@:>@)
Martin v. Löwiscb78de62007-12-29 18:49:21 +0000282 define_xopen_source=no
283 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
284 # also defined. This can be overridden by defining _BSD_SOURCE
285 # As this has a different meaning on Linux, only define it on OpenBSD
286 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
287 ;;
Martin v. Löwis4bacaca2010-02-15 08:34:34 +0000288 OpenBSD/4.@<:@4@:>@)
289 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
290 # also defined. This can be overridden by defining _BSD_SOURCE
291 # As this has a different meaning on Linux, only define it on OpenBSD
292 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
293 ;;
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000294 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
295 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
296 # Marc Recht
Georg Brandl60616122008-11-16 08:02:56 +0000297 NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000298 define_xopen_source=no;;
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000299 # On Solaris 2.6, sys/wait.h is inconsistent in the usage
300 # of union __?sigval. Reported by Stuart Bishop.
301 SunOS/5.6)
302 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000303 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
304 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000305 # Reconfirmed for 7.1.4 by Martin v. Loewis.
306 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000307 define_xopen_source=no;;
308 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000309 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000310 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000311 define_xopen_source=no;;
Martin v. Löwis7f08c1f2008-11-04 20:43:31 +0000312 # On FreeBSD 4, the math functions C89 does not cover are never defined
313 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
314 FreeBSD/4.*)
315 define_xopen_source=no;;
316 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
317 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
318 # identifies itself as Darwin/7.*
319 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
320 # disables platform specific features beyond repair.
321 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
322 # has no effect, don't bother defining them
323 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000324 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000325 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
326 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
327 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000328 AIX/4)
329 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000330 AIX/5)
331 if test `uname -r` -eq 1; then
332 define_xopen_source=no
333 fi
334 ;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000335 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
336 # defining NI_NUMERICHOST.
337 QNX/6.3.2)
338 define_xopen_source=no
339 ;;
Martin v. Löwisa0588362006-04-04 06:03:50 +0000340
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000341esac
342
343if test $define_xopen_source = yes
344then
Skip Montanarof0d5f792004-08-15 14:08:23 +0000345 # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
346 # defined precisely as g++ defines it
Martin v. Löwis7dece662005-11-26 11:38:24 +0000347 # Furthermore, on Solaris 10, XPG6 requires the use of a C99
348 # compiler
Skip Montanarof0d5f792004-08-15 14:08:23 +0000349 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis7dece662005-11-26 11:38:24 +0000350 SunOS/5.8|SunOS/5.9|SunOS/5.10)
Skip Montanarof0d5f792004-08-15 14:08:23 +0000351 AC_DEFINE(_XOPEN_SOURCE, 500,
352 Define to the level of X/Open that your system supports)
353 ;;
354 *)
355 AC_DEFINE(_XOPEN_SOURCE, 600,
356 Define to the level of X/Open that your system supports)
357 ;;
358 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000359
360 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
361 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
362 # several APIs are not declared. Since this is also needed in some
363 # cases for HP-UX, we define it globally.
Martin v. Löwis7dece662005-11-26 11:38:24 +0000364 # except for Solaris 10, where it must not be defined,
365 # as it implies XPG4.2
366 case $ac_sys_system/$ac_sys_release in
367 SunOS/5.10)
368 ;;
369 *)
370 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
371 Define to activate Unix95-and-earlier features)
372 ;;
373 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000374
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000375 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
376
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000377fi
378
Guido van Rossum91922671997-10-09 20:24:13 +0000379#
380# SGI compilers allow the specification of the both the ABI and the
381# ISA on the command line. Depending on the values of these switches,
382# different and often incompatable code will be generated.
383#
384# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
385# thus supply support for various ABI/ISA combinations. The MACHDEP
386# variable is also adjusted.
387#
388AC_SUBST(SGI_ABI)
389if test ! -z "$SGI_ABI"
390then
391 CC="cc $SGI_ABI"
392 LDFLAGS="$SGI_ABI $LDFLAGS"
393 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
394fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000395AC_MSG_RESULT($MACHDEP)
396
Jack Jansen83f898c2002-12-30 22:23:40 +0000397# And add extra plat-mac for darwin
398AC_SUBST(EXTRAPLATDIR)
Jack Jansen7b59b422003-03-17 15:44:10 +0000399AC_SUBST(EXTRAMACHDEPPATH)
Jack Jansen83f898c2002-12-30 22:23:40 +0000400AC_MSG_CHECKING(EXTRAPLATDIR)
401if test -z "$EXTRAPLATDIR"
402then
403 case $MACHDEP in
Jack Jansen7b59b422003-03-17 15:44:10 +0000404 darwin)
405 EXTRAPLATDIR="\$(PLATMACDIRS)"
406 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
407 ;;
408 *)
409 EXTRAPLATDIR=""
410 EXTRAMACHDEPPATH=""
411 ;;
Jack Jansen83f898c2002-12-30 22:23:40 +0000412 esac
413fi
414AC_MSG_RESULT($EXTRAPLATDIR)
415
Jack Jansen6b08a402004-06-03 12:41:45 +0000416# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
417# it may influence the way we can build extensions, so distutils
418# needs to check it
419AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Ronald Oussoren988117f2006-04-29 11:31:35 +0000420AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000421CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Ronald Oussoren988117f2006-04-29 11:31:35 +0000422EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000423
Mark Dickinson65134662008-04-25 16:11:04 +0000424AC_MSG_CHECKING(machine type as reported by uname -m)
425ac_sys_machine=`uname -m`
426AC_MSG_RESULT($ac_sys_machine)
427
Guido van Rossum627b2d71993-12-24 10:39:16 +0000428# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000429
430# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
431# for debug/optimization stuff. BASECFLAGS is for flags that are required
432# just to get things to compile and link. Users are free to override OPT
433# when running configure or make. The build should not break if they do.
434# BASECFLAGS should generally not be messed with, however.
435
436# XXX shouldn't some/most/all of this code be merged with the stuff later
437# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000438AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000439AC_ARG_WITH(gcc,
440 AC_HELP_STRING(--without-gcc,never use gcc),
441[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000442 case $withval in
Georg Brandlc04c2892009-01-14 00:00:17 +0000443 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000444 without_gcc=yes;;
445 yes) CC=gcc
446 without_gcc=no;;
447 *) CC=$withval
448 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000449 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000450 case $ac_sys_system in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000451 AIX*) CC=cc_r
452 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000453 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000454 case $BE_HOST_CPU in
455 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000456 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000457 without_gcc=yes
Skip Montanarodecc6a42003-01-01 20:07:49 +0000458 BASECFLAGS="$BASECFLAGS -export pragma"
459 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000460 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000461 ;;
462 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000463 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000464 without_gcc=no
Skip Montanarodecc6a42003-01-01 20:07:49 +0000465 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000466 ;;
467 *)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000468 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000469 ;;
470 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000471 AR="\$(srcdir)/Modules/ar_beos"
472 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000473 ;;
Trent Mick635f6fb2000-08-23 21:33:05 +0000474 Monterey*)
475 RANLIB=:
Martin v. Löwis130fb172001-07-19 11:00:41 +0000476 without_gcc=;;
477 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000478 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000479AC_MSG_RESULT($without_gcc)
480
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000481# If the user switches compilers, we can't believe the cache
482if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
483then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000484 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
485(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000486fi
487
Guido van Rossum627b2d71993-12-24 10:39:16 +0000488AC_PROG_CC
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000489
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000490AC_SUBST(CXX)
491AC_SUBST(MAINCC)
492AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
493AC_ARG_WITH(cxx_main,
494 AC_HELP_STRING([--with-cxx-main=<compiler>],
495 [compile main() and link python executable with C++ compiler]),
496[
497
498 case $withval in
499 no) with_cxx_main=no
500 MAINCC='$(CC)';;
501 yes) with_cxx_main=yes
502 MAINCC='$(CXX)';;
503 *) with_cxx_main=yes
504 MAINCC=$withval
505 if test -z "$CXX"
506 then
507 CXX=$withval
508 fi;;
509 esac], [
510 with_cxx_main=no
511 MAINCC='$(CC)'
512])
513AC_MSG_RESULT($with_cxx_main)
514
515preset_cxx="$CXX"
516if test -z "$CXX"
517then
518 case "$CC" in
519 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
520 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
521 esac
522 if test "$CXX" = "notfound"
523 then
524 CXX=""
525 fi
526fi
527if test -z "$CXX"
528then
529 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
530 if test "$CXX" = "notfound"
531 then
532 CXX=""
533 fi
534fi
535if test "$preset_cxx" != "$CXX"
536then
537 AC_MSG_WARN([
538
539 By default, distutils will build C++ extension modules with "$CXX".
540 If this is not intended, then set CXX on the configure command line.
541 ])
542fi
543
544
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000545# checks for UNIX variants that set C preprocessor variables
546AC_AIX
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000547
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000548# Check for unsupported systems
549case $ac_sys_system/$ac_sys_release in
Brett Cannon19fab762007-06-02 03:02:29 +0000550atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000551 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
552 echo See README for details.
553 exit 1;;
554esac
555
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000556AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000557AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000558AC_ARG_WITH(suffix,
559 AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
560[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000561 case $withval in
562 no) EXEEXT=;;
563 yes) EXEEXT=.exe;;
564 *) EXEEXT=$withval;;
565 esac])
566AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000567
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000568# Test whether we're running on a non-case-sensitive system, in which
569# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000570AC_SUBST(BUILDEXEEXT)
571AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000572if test ! -d CaseSensitiveTestDir; then
573mkdir CaseSensitiveTestDir
574fi
575
576if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000577then
Jack Jansen1999ef42001-12-06 21:47:20 +0000578 AC_MSG_RESULT(yes)
579 BUILDEXEEXT=.exe
580else
581 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000582 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000583fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000584rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000585
Guido van Rossumdd997f71998-10-07 19:58:26 +0000586case $MACHDEP in
587bsdos*)
588 case $CC in
589 gcc) CC="$CC -D_HAVE_BSDI";;
590 esac;;
591esac
592
Guido van Rossum84561611997-08-21 00:08:11 +0000593case $ac_sys_system in
594hp*|HP*)
595 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000596 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000597 esac;;
Trent Mick635f6fb2000-08-23 21:33:05 +0000598Monterey*)
599 case $CC in
600 cc) CC="$CC -Wl,-Bexport";;
601 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000602SunOS*)
603 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000604 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000605 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000606esac
607
Martin v. Löwise8964d42001-03-06 12:09:07 +0000608
Neil Schemenauer61c51152001-01-26 16:18:16 +0000609AC_SUBST(LIBRARY)
610AC_MSG_CHECKING(LIBRARY)
611if test -z "$LIBRARY"
612then
613 LIBRARY='libpython$(VERSION).a'
614fi
615AC_MSG_RESULT($LIBRARY)
616
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000617# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000618# name of the library into which to insert object files). BLDLIBRARY is also
619# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
620# is blank as the main program is not linked directly against LDLIBRARY.
621# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
622# systems without shared libraries, LDLIBRARY is the same as LIBRARY
623# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
624# DLLLIBRARY is the shared (i.e., DLL) library.
625#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000626# RUNSHARED is used to run shared python without installed libraries
627#
628# INSTSONAME is the name of the shared library that will be use to install
629# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000630AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000631AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000632AC_SUBST(BLDLIBRARY)
633AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000634AC_SUBST(INSTSONAME)
635AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000636LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000637BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000638INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000639DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000640LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000641RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000642
Guido van Rossumfb842551997-08-06 23:42:07 +0000643# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000644# If CXX is set, and if it is needed to link a main function that was
645# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
646# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000647# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000648# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000649AC_SUBST(LINKCC)
650AC_MSG_CHECKING(LINKCC)
651if test -z "$LINKCC"
652then
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000653 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000654 case $ac_sys_system in
655 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000656 exp_extra="\"\""
657 if test $ac_sys_release -ge 5 -o \
658 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
659 exp_extra="."
660 fi
661 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000662 Monterey64*)
Martin v. Löwis4e732dc2002-03-19 15:15:32 +0000663 LINKCC="$LINKCC -L/usr/lib/ia64l64";;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000664 QNX*)
665 # qcc must be used because the other compilers do not
666 # support -N.
667 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000668 esac
669fi
670AC_MSG_RESULT($LINKCC)
671
Martin v. Löwis1142de32002-03-29 16:28:31 +0000672AC_MSG_CHECKING(for --enable-shared)
673AC_ARG_ENABLE(shared,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000674 AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000675
Martin v. Löwis1142de32002-03-29 16:28:31 +0000676if test -z "$enable_shared"
677then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000678 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000679 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000680 enable_shared="yes";;
681 *)
682 enable_shared="no";;
683 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000684fi
685AC_MSG_RESULT($enable_shared)
686
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000687AC_MSG_CHECKING(for --enable-profiling)
688AC_ARG_ENABLE(profiling,
689 AC_HELP_STRING(--enable-profiling, enable C-level code profiling),
690[ac_save_cc="$CC"
691 CC="$CC -pg"
692 AC_TRY_RUN([int main() { return 0; }],
693 ac_enable_profiling="yes",
694 ac_enable_profiling="no",
695 ac_enable_profiling="no")
696 CC="$ac_save_cc"])
697AC_MSG_RESULT($ac_enable_profiling)
698
699case "$ac_enable_profiling" in
700 "yes")
701 BASECFLAGS="-pg $BASECFLAGS"
702 LDFLAGS="-pg $LDFLAGS"
703 ;;
704esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000705
706AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000707
Guido van Rossumb8552162001-09-05 14:58:11 +0000708# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
709# library that we build, but we do not want to link against it (we
710# will find it with a -framework option). For this reason there is an
711# extra variable BLDLIBRARY against which Python and the extension
712# modules are linked, BLDLIBRARY. This is normally the same as
713# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000714if test "$enable_framework"
715then
716 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000717 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000718 BLDLIBRARY=''
719else
720 BLDLIBRARY='$(LDLIBRARY)'
721fi
722
Martin v. Löwis1142de32002-03-29 16:28:31 +0000723# Other platforms follow
724if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000725 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000726 case $ac_sys_system in
727 BeOS*)
728 LDLIBRARY='libpython$(VERSION).so'
729 ;;
730 CYGWIN*)
731 LDLIBRARY='libpython$(VERSION).dll.a'
732 DLLLIBRARY='libpython$(VERSION).dll'
733 ;;
734 SunOS*)
735 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000736 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000737 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000738 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000739 ;;
Martin v. Löwis86d66262006-02-17 08:40:11 +0000740 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000741 LDLIBRARY='libpython$(VERSION).so'
742 BLDLIBRARY='-L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000743 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000744 case $ac_sys_system in
745 FreeBSD*)
746 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
747 ;;
748 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000749 INSTSONAME="$LDLIBRARY".$SOVERSION
750 ;;
751 hp*|HP*)
Neal Norwitz58e28882006-05-19 07:00:58 +0000752 case `uname -m` in
753 ia64)
754 LDLIBRARY='libpython$(VERSION).so'
755 ;;
756 *)
757 LDLIBRARY='libpython$(VERSION).sl'
758 ;;
759 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000760 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000761 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000762 ;;
763 OSF*)
764 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000765 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000766 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000767 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000768 atheos*)
769 LDLIBRARY='libpython$(VERSION).so'
770 BLDLIBRARY='-L. -lpython$(VERSION)'
771 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
772 ;;
Ronald Oussorene9cce8e2009-01-02 10:46:42 +0000773 Darwin*)
774 LDLIBRARY='libpython$(VERSION).dylib'
775 BLDLIBRARY='-L. -lpython$(VERSION)'
776 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
777 ;;
778
Martin v. Löwis1142de32002-03-29 16:28:31 +0000779 esac
Jason Tishler30765592003-09-04 11:04:06 +0000780else # shared is disabled
781 case $ac_sys_system in
782 CYGWIN*)
783 BLDLIBRARY='$(LIBRARY)'
784 LDLIBRARY='libpython$(VERSION).dll.a'
785 ;;
786 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000787fi
788
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000789AC_MSG_RESULT($LDLIBRARY)
790
Guido van Rossum627b2d71993-12-24 10:39:16 +0000791AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000792AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000793AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000794
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000795AC_SUBST(SVNVERSION)
Martin v. Löwisff600232006-04-03 19:12:32 +0000796AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000797if test $SVNVERSION = found
798then
799 SVNVERSION="svnversion \$(srcdir)"
800else
Benjamin Peterson2eb65452009-05-23 19:35:33 +0000801 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000802fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000803
Neil Schemenauera42c8272001-03-31 00:01:55 +0000804case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000805bsdos*|hp*|HP*)
806 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000807 if test -z "$INSTALL"
808 then
809 INSTALL="${srcdir}/install-sh -c"
810 fi
811esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000812AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000813
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000814# Not every filesystem supports hard links
815AC_SUBST(LN)
816if test -z "$LN" ; then
817 case $ac_sys_system in
818 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000819 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000820 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000821 *) LN=ln;;
822 esac
823fi
824
Fred Drake9f715822001-07-11 06:27:00 +0000825# Check for --with-pydebug
826AC_MSG_CHECKING(for --with-pydebug)
827AC_ARG_WITH(pydebug,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000828 AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
829[
Fred Drake9f715822001-07-11 06:27:00 +0000830if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000831then
832 AC_DEFINE(Py_DEBUG, 1,
833 [Define if you want to build an interpreter with many run-time checks.])
834 AC_MSG_RESULT(yes);
835 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +0000836else AC_MSG_RESULT(no); Py_DEBUG='false'
837fi],
838[AC_MSG_RESULT(no)])
839
Skip Montanarodecc6a42003-01-01 20:07:49 +0000840# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
841# merged with this chunk of code?
842
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000843# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +0000844# ------------------------
845# (The following bit of code is complicated enough - please keep things
846# indented properly. Just pretend you're editing Python code. ;-)
847
848# There are two parallel sets of case statements below, one that checks to
849# see if OPT was set and one that does BASECFLAGS setting based upon
850# compiler and platform. BASECFLAGS tweaks need to be made even if the
851# user set OPT.
852
853# tweak OPT based on compiler and platform, only if the user didn't set
854# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +0000855AC_SUBST(OPT)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000856if test -z "$OPT"
Guido van Rossumb418f891996-07-30 18:06:02 +0000857then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000858 case $GCC in
859 yes)
Skip Montanaro288a5be2006-04-13 02:00:56 +0000860 if test "$CC" != 'g++' ; then
861 STRICT_PROTO="-Wstrict-prototypes"
862 fi
Guido van Rossum7c862f82007-12-13 20:50:10 +0000863 # For gcc 4.x we need to use -fwrapv so lets check if its supported
864 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
865 WRAP="-fwrapv"
866 fi
Skip Montanarodecc6a42003-01-01 20:07:49 +0000867 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000868 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000869 if test "$Py_DEBUG" = 'true' ; then
870 # Optimization messes up debuggers, so turn it off for
871 # debug builds.
Skip Montanaro288a5be2006-04-13 02:00:56 +0000872 OPT="-g -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +0000873 else
Guido van Rossum7c862f82007-12-13 20:50:10 +0000874 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000875 fi
876 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000877 *)
Skip Montanaro288a5be2006-04-13 02:00:56 +0000878 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000879 ;;
Fred Drake9f715822001-07-11 06:27:00 +0000880 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000881 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000882 SCO_SV*) OPT="$OPT -m486 -DSCO5"
883 ;;
884 esac
Fred Drake9f715822001-07-11 06:27:00 +0000885 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000886
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000887 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +0000888 OPT="-O"
889 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000890 esac
Skip Montanarodecc6a42003-01-01 20:07:49 +0000891
892 # The current (beta) Monterey compiler dies with optimizations
893 # XXX what is Monterey? Does it still die w/ -O? Can we get rid of this?
Jack Jansenca06bc62001-08-03 15:32:23 +0000894 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000895 Monterey*)
896 OPT=""
897 ;;
Jack Jansenca06bc62001-08-03 15:32:23 +0000898 esac
Skip Montanarodecc6a42003-01-01 20:07:49 +0000899
Guido van Rossum4e8af441994-08-19 15:33:54 +0000900fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000901
Skip Montanarodecc6a42003-01-01 20:07:49 +0000902AC_SUBST(BASECFLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000903
904# The -arch flags for universal builds on OSX
905UNIVERSAL_ARCH_FLAGS=
906AC_SUBST(UNIVERSAL_ARCH_FLAGS)
907
Skip Montanarodecc6a42003-01-01 20:07:49 +0000908# tweak BASECFLAGS based on compiler and platform
909case $GCC in
910yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000911 # Python violates C99 rules, by casting between incompatible
912 # pointer types. GCC may generate bad code as a result of that,
913 # so use -fno-strict-aliasing if supported.
914 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
915 ac_save_cc="$CC"
916 CC="$CC -fno-strict-aliasing"
917 AC_TRY_RUN([int main() { return 0; }],
918 ac_cv_no_strict_aliasing_ok=yes,
919 ac_cv_no_strict_aliasing_ok=no,
920 ac_cv_no_strict_aliasing_ok=no)
921 CC="$ac_save_cc"
922 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
923 if test $ac_cv_no_strict_aliasing_ok = yes
924 then
925 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
926 fi
Mark Dickinson65134662008-04-25 16:11:04 +0000927
928 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
929 # support. Without this, treatment of subnormals doesn't follow
930 # the standard.
931 case $ac_sys_machine in
932 alpha*)
933 BASECFLAGS="$BASECFLAGS -mieee"
934 ;;
935 esac
936
Skip Montanarodecc6a42003-01-01 20:07:49 +0000937 case $ac_sys_system in
938 SCO_SV*)
939 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
940 ;;
941 # is there any other compiler on Darwin besides gcc?
942 Darwin*)
Jeffrey Yasskin1b4e45b2008-03-17 14:40:53 +0000943 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
944 # used to be here, but non-Apple gcc doesn't accept them.
Benjamin Peterson4347c442008-07-17 15:59:24 +0000945
946
Ronald Oussoren988117f2006-04-29 11:31:35 +0000947 if test "${enable_universalsdk}"; then
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000948 UNIVERSAL_ARCH_FLAGS=""
949 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
950 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000951 ARCH_RUN_32BIT=""
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000952
953 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
954 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
Ronald Oussoren461f2202009-09-06 10:54:28 +0000955 ARCH_RUN_32BIT="true"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000956
957 elif test "$UNIVERSAL_ARCHS" = "all" ; then
958 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
Ronald Oussorend8244f52010-02-11 13:22:03 +0000959 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000960
Ronald Oussoren7ab74352009-09-08 07:10:07 +0000961 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
962 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
Ronald Oussorend8244f52010-02-11 13:22:03 +0000963 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussoren7ab74352009-09-08 07:10:07 +0000964
965 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
966 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
Ronald Oussorend8244f52010-02-11 13:22:03 +0000967 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussoren7ab74352009-09-08 07:10:07 +0000968
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000969 else
Ronald Oussorenba0aa6b2009-09-20 20:16:38 +0000970 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000971
972 fi
973
974
975 BASECFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
Ronald Oussoren5a849d42008-07-22 07:06:00 +0000976 tgt=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
Benjamin Peterson4347c442008-07-17 15:59:24 +0000977 if test "${UNIVERSALSDK}" != "/" -a "${tgt}" '>' '10.4' ; then
978 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
979 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000980 fi
981
Benjamin Peterson4347c442008-07-17 15:59:24 +0000982 # Calculate the right deployment target for this build.
983 #
984 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
985 if test ${cur_target} '>' 10.2; then
986 cur_target=10.3
Ronald Oussoren461f2202009-09-06 10:54:28 +0000987 if test ${enable_universalsdk}; then
988 if test "${UNIVERSAL_ARCHS}" = "all"; then
989 # Ensure that the default platform for a
990 # 4-way universal build is OSX 10.5,
991 # that's the first OS release where
992 # 4-way builds make sense.
993 cur_target='10.5'
Ronald Oussoren7ab74352009-09-08 07:10:07 +0000994
995 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
996 cur_target='10.5'
997
998 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
999 cur_target='10.5'
1000
1001 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1002 cur_target='10.5'
Ronald Oussoren461f2202009-09-06 10:54:28 +00001003 fi
1004 else
Ronald Oussoren25e192c2010-02-11 13:27:59 +00001005 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren461f2202009-09-06 10:54:28 +00001006 # On Intel macs default to a deployment
1007 # target of 10.4, that's the first OSX
1008 # release with Intel support.
1009 cur_target="10.4"
1010 fi
1011 fi
Benjamin Peterson4347c442008-07-17 15:59:24 +00001012 fi
1013 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1014
1015 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1016 # environment with a value that is the same as what we'll use
1017 # in the Makefile to ensure that we'll get the same compiler
1018 # environment during configure and build time.
1019 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1020 export MACOSX_DEPLOYMENT_TARGET
1021 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1022
Skip Montanarodecc6a42003-01-01 20:07:49 +00001023 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001024 OSF*)
1025 BASECFLAGS="$BASECFLAGS -mieee"
1026 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001027 esac
1028 ;;
1029
1030*)
1031 case $ac_sys_system in
1032 OpenUNIX*|UnixWare*)
1033 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1034 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001035 OSF*)
1036 BASECFLAGS="$BASECFLAGS -ieee -std"
1037 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001038 SCO_SV*)
1039 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1040 ;;
1041 esac
1042 ;;
1043esac
1044
Fred Drakee1ceaa02001-12-04 20:55:47 +00001045if test "$Py_DEBUG" = 'true'; then
1046 :
1047else
1048 OPT="-DNDEBUG $OPT"
1049fi
1050
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001051if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001052then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001053 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001054fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001055
Neal Norwitz020c46a2006-01-07 21:39:28 +00001056# disable check for icc since it seems to pass, but generates a warning
1057if test "$CC" = icc
1058then
1059 ac_cv_opt_olimit_ok=no
1060fi
1061
Guido van Rossum91922671997-10-09 20:24:13 +00001062AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1063AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1064[ac_save_cc="$CC"
1065CC="$CC -OPT:Olimit=0"
1066AC_TRY_RUN([int main() { return 0; }],
1067 ac_cv_opt_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001068 ac_cv_opt_olimit_ok=no,
Guido van Rossum91922671997-10-09 20:24:13 +00001069 ac_cv_opt_olimit_ok=no)
1070CC="$ac_save_cc"])
1071AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001072if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001073 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001074 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1075 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1076 # environment?
1077 Darwin*)
1078 ;;
1079 *)
1080 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1081 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001082 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001083else
1084 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1085 AC_CACHE_VAL(ac_cv_olimit_ok,
1086 [ac_save_cc="$CC"
1087 CC="$CC -Olimit 1500"
1088 AC_TRY_RUN([int main() { return 0; }],
1089 ac_cv_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001090 ac_cv_olimit_ok=no,
Guido van Rossumf8678121998-07-07 21:05:09 +00001091 ac_cv_olimit_ok=no)
1092 CC="$ac_save_cc"])
1093 AC_MSG_RESULT($ac_cv_olimit_ok)
1094 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001095 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +00001096 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001097fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001098
Martin v. Löwisaac13162006-10-19 10:58:46 +00001099# Check whether GCC supports PyArg_ParseTuple format
1100if test "$GCC" = "yes"
1101then
1102 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1103 save_CFLAGS=$CFLAGS
1104 CFLAGS="$CFLAGS -Werror"
1105 AC_TRY_COMPILE([
1106 void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
1107 ],,
1108 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1109 AC_MSG_RESULT(yes),
1110 AC_MSG_RESULT(no)
1111 )
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001112 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001113fi
1114
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001115# On some compilers, pthreads are available without further options
1116# (e.g. MacOS X). On some of these systems, the compiler will not
1117# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1118# So we have to see first whether pthreads are available without
1119# options before we can check whether -Kpthread improves anything.
1120AC_MSG_CHECKING(whether pthreads are available without options)
1121AC_CACHE_VAL(ac_cv_pthread_is_default,
1122[AC_TRY_RUN([
1123#include <pthread.h>
1124
1125void* routine(void* p){return NULL;}
1126
1127int main(){
1128 pthread_t p;
1129 if(pthread_create(&p,NULL,routine,NULL)!=0)
1130 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001131 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001132 return 0;
1133}
1134],
Skip Montanarod8d39a02003-07-10 20:44:10 +00001135[
1136 ac_cv_pthread_is_default=yes
1137 ac_cv_kthread=no
1138 ac_cv_pthread=no
1139],
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001140 ac_cv_pthread_is_default=no,
1141 ac_cv_pthread_is_default=no)
1142])
1143AC_MSG_RESULT($ac_cv_pthread_is_default)
1144
1145
1146if test $ac_cv_pthread_is_default = yes
1147then
1148 ac_cv_kpthread=no
1149else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001150# -Kpthread, if available, provides the right #defines
1151# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001152# Some compilers won't report that they do not support -Kpthread,
1153# so we need to run a program to see whether it really made the
1154# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001155AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1156AC_CACHE_VAL(ac_cv_kpthread,
1157[ac_save_cc="$CC"
1158CC="$CC -Kpthread"
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001159AC_TRY_RUN([
1160#include <pthread.h>
1161
1162void* routine(void* p){return NULL;}
1163
1164int main(){
1165 pthread_t p;
1166 if(pthread_create(&p,NULL,routine,NULL)!=0)
1167 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001168 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001169 return 0;
1170}
1171],
Martin v. Löwis130fb172001-07-19 11:00:41 +00001172 ac_cv_kpthread=yes,
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001173 ac_cv_kpthread=no,
Martin v. Löwis130fb172001-07-19 11:00:41 +00001174 ac_cv_kpthread=no)
1175CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001176AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001177fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001178
Skip Montanarod8d39a02003-07-10 20:44:10 +00001179if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001180then
1181# -Kthread, if available, provides the right #defines
1182# and linker options to make pthread_create available
1183# Some compilers won't report that they do not support -Kthread,
1184# so we need to run a program to see whether it really made the
1185# function available.
1186AC_MSG_CHECKING(whether $CC accepts -Kthread)
1187AC_CACHE_VAL(ac_cv_kthread,
1188[ac_save_cc="$CC"
1189CC="$CC -Kthread"
1190AC_TRY_RUN([
1191#include <pthread.h>
1192
1193void* routine(void* p){return NULL;}
1194
1195int main(){
1196 pthread_t p;
1197 if(pthread_create(&p,NULL,routine,NULL)!=0)
1198 return 1;
1199 (void)pthread_detach(p);
1200 return 0;
1201}
1202],
1203 ac_cv_kthread=yes,
1204 ac_cv_kthread=no,
1205 ac_cv_kthread=no)
1206CC="$ac_save_cc"])
1207AC_MSG_RESULT($ac_cv_kthread)
1208fi
1209
Skip Montanarod8d39a02003-07-10 20:44:10 +00001210if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001211then
1212# -pthread, if available, provides the right #defines
1213# and linker options to make pthread_create available
1214# Some compilers won't report that they do not support -pthread,
1215# so we need to run a program to see whether it really made the
1216# function available.
1217AC_MSG_CHECKING(whether $CC accepts -pthread)
1218AC_CACHE_VAL(ac_cv_thread,
1219[ac_save_cc="$CC"
1220CC="$CC -pthread"
1221AC_TRY_RUN([
1222#include <pthread.h>
1223
1224void* routine(void* p){return NULL;}
1225
1226int main(){
1227 pthread_t p;
1228 if(pthread_create(&p,NULL,routine,NULL)!=0)
1229 return 1;
1230 (void)pthread_detach(p);
1231 return 0;
1232}
1233],
1234 ac_cv_pthread=yes,
1235 ac_cv_pthread=no,
1236 ac_cv_pthread=no)
1237CC="$ac_save_cc"])
1238AC_MSG_RESULT($ac_cv_pthread)
1239fi
1240
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001241# If we have set a CC compiler flag for thread support then
1242# check if it works for CXX, too.
1243ac_cv_cxx_thread=no
1244if test ! -z "$CXX"
1245then
1246AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1247ac_save_cxx="$CXX"
1248
1249if test "$ac_cv_kpthread" = "yes"
1250then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001251 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001252 ac_cv_cxx_thread=yes
1253elif test "$ac_cv_kthread" = "yes"
1254then
1255 CXX="$CXX -Kthread"
1256 ac_cv_cxx_thread=yes
1257elif test "$ac_cv_pthread" = "yes"
1258then
1259 CXX="$CXX -pthread"
1260 ac_cv_cxx_thread=yes
1261fi
1262
1263if test $ac_cv_cxx_thread = yes
1264then
1265 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1266 $CXX -c conftest.$ac_ext 2>&5
1267 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1268 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1269 then
1270 ac_cv_cxx_thread=yes
1271 else
1272 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001273 fi
1274 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001275fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001276AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001277fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001278CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001279
Fred Drakece81d592000-07-09 14:39:29 +00001280dnl # check for ANSI or K&R ("traditional") preprocessor
1281dnl AC_MSG_CHECKING(for C preprocessor type)
1282dnl AC_TRY_COMPILE([
1283dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1284dnl int foo;
1285dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1286dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1287dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001288
Guido van Rossum627b2d71993-12-24 10:39:16 +00001289# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001290AC_HEADER_STDC
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001291AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1292fcntl.h grp.h \
Neal Norwitz9fdfaaf2008-03-28 05:34:59 +00001293ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001294shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001295unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001296sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1297sys/lock.h sys/mkdev.h sys/modem.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001298sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Martin v. Löwis8c255e42008-05-23 15:06:50 +00001299sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001300sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
Martin v. Löwis0347a9a2006-10-27 07:06:52 +00001301sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimesfb2d25a2008-01-07 16:12:44 +00001302bluetooth/bluetooth.h linux/tipc.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001303AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001304AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001305
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001306# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e72004-11-30 22:09:37 +00001307AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001308#ifdef HAVE_CURSES_H
1309#include <curses.h>
1310#endif
1311])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001312
Martin v. Löwis11017b12006-01-14 18:12:57 +00001313# On Linux, netlink.h requires asm/types.h
1314AC_CHECK_HEADERS(linux/netlink.h,,,[
1315#ifdef HAVE_ASM_TYPES_H
1316#include <asm/types.h>
1317#endif
1318#ifdef HAVE_SYS_SOCKET_H
1319#include <sys/socket.h>
1320#endif
1321])
1322
Guido van Rossum627b2d71993-12-24 10:39:16 +00001323# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001324was_it_defined=no
1325AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001326AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1327 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1328])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001329AC_MSG_RESULT($was_it_defined)
1330
Neal Norwitz11690112002-07-30 01:08:28 +00001331# Check whether using makedev requires defining _OSF_SOURCE
1332AC_MSG_CHECKING(for makedev)
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001333AC_TRY_LINK([#include <sys/types.h> ],
Neal Norwitz11690112002-07-30 01:08:28 +00001334 [ makedev(0, 0) ],
1335 ac_cv_has_makedev=yes,
1336 ac_cv_has_makedev=no)
1337if test "$ac_cv_has_makedev" = "no"; then
1338 # we didn't link, try if _OSF_SOURCE will allow us to link
1339 AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001340#define _OSF_SOURCE 1
1341#include <sys/types.h>
Neal Norwitz11690112002-07-30 01:08:28 +00001342 ],
1343 [ makedev(0, 0) ],
1344 ac_cv_has_makedev=yes,
1345 ac_cv_has_makedev=no)
1346 if test "$ac_cv_has_makedev" = "yes"; then
1347 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1348 fi
1349fi
1350AC_MSG_RESULT($ac_cv_has_makedev)
1351if test "$ac_cv_has_makedev" = "yes"; then
1352 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1353fi
1354
Martin v. Löwis399a6892002-10-04 10:22:02 +00001355# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1356# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1357# defined, but the compiler does not support pragma redefine_extname,
1358# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1359# structures (such as rlimit64) without declaring them. As a
1360# work-around, disable LFS on such configurations
1361
1362use_lfs=yes
1363AC_MSG_CHECKING(Solaris LFS bug)
1364AC_TRY_COMPILE([
1365#define _LARGEFILE_SOURCE 1
1366#define _FILE_OFFSET_BITS 64
1367#include <sys/resource.h>
1368],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1369AC_MSG_RESULT($sol_lfs_bug)
1370if test "$sol_lfs_bug" = "yes"; then
1371 use_lfs=no
1372fi
1373
1374if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001375# Two defines needed to enable largefile support on various platforms
1376# These may affect some typedefs
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001377AC_DEFINE(_LARGEFILE_SOURCE, 1,
1378[This must be defined on some systems to enable large file support.])
1379AC_DEFINE(_FILE_OFFSET_BITS, 64,
1380[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001381fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001382
Guido van Rossum300fda71996-08-19 21:58:16 +00001383# Add some code to confdefs.h so that the test for off_t works on SCO
1384cat >> confdefs.h <<\EOF
1385#if defined(SCO_DS)
1386#undef _OFF_T
1387#endif
1388EOF
1389
Guido van Rossumef2255b2000-03-10 22:30:29 +00001390# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001391AC_TYPE_MODE_T
1392AC_TYPE_OFF_T
1393AC_TYPE_PID_T
1394AC_TYPE_SIGNAL
1395AC_TYPE_SIZE_T
1396AC_TYPE_UID_T
Christian Heimes951cc0f2008-01-31 23:08:23 +00001397AC_CHECK_TYPE(ssize_t,
Martin v. Löwis18e16552006-02-15 17:27:45 +00001398 AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001399
Guido van Rossumef2255b2000-03-10 22:30:29 +00001400# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001401# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001402AC_CHECK_SIZEOF(int, 4)
1403AC_CHECK_SIZEOF(long, 4)
1404AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001405AC_CHECK_SIZEOF(short, 2)
1406AC_CHECK_SIZEOF(float, 4)
1407AC_CHECK_SIZEOF(double, 8)
1408AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001409AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001410AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001411
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001412AC_MSG_CHECKING(for long long support)
1413have_long_long=no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001414AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1415 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1416 have_long_long=yes
1417])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001418AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001419if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001420AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001421fi
1422
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001423AC_MSG_CHECKING(for long double support)
1424have_long_double=no
1425AC_TRY_COMPILE([], [long double x; x = (long double)0.;], [
1426 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1427 have_long_double=yes
1428])
1429AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001430if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001431AC_CHECK_SIZEOF(long double, 12)
1432fi
1433
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001434AC_MSG_CHECKING(for _Bool support)
1435have_c99_bool=no
1436AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1437 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1438 have_c99_bool=yes
1439])
1440AC_MSG_RESULT($have_c99_bool)
1441if test "$have_c99_bool" = yes ; then
1442AC_CHECK_SIZEOF(_Bool, 1)
1443fi
1444
Martin v. Löwisebe26702006-10-02 14:55:51 +00001445AC_CHECK_TYPES(uintptr_t,
1446 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001447 [], [#ifdef HAVE_STDINT_H
1448 #include <stdint.h>
1449 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001450
Barry Warsawbc7c7f92000-08-18 04:53:33 +00001451
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001452# Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
1453AC_MSG_CHECKING(size of off_t)
1454AC_CACHE_VAL(ac_cv_sizeof_off_t,
1455[AC_TRY_RUN([#include <stdio.h>
1456#include <sys/types.h>
1457main()
1458{
1459 FILE *f=fopen("conftestval", "w");
1460 if (!f) exit(1);
1461 fprintf(f, "%d\n", sizeof(off_t));
1462 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001463}],
1464ac_cv_sizeof_off_t=`cat conftestval`,
1465ac_cv_sizeof_off_t=0,
1466ac_cv_sizeof_off_t=4)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001467])
1468AC_MSG_RESULT($ac_cv_sizeof_off_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001469AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t,
1470[The number of bytes in an off_t.])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001471
1472AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinsoncaa44c02009-12-31 21:20:06 +00001473if test "$have_long_long" = yes
1474then
1475if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001476 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001477 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1478 [Defined to enable large file support when an off_t is bigger than a long
1479 and long long is available and at least as big as an off_t. You may need
1480 to add some flags for configuration and compilation to enable this mode.
1481 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001482 AC_MSG_RESULT(yes)
1483else
1484 AC_MSG_RESULT(no)
1485fi
Mark Dickinsoncaa44c02009-12-31 21:20:06 +00001486else
1487 AC_MSG_RESULT(no)
1488fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001489
Fred Drakea3f6e912000-06-29 20:44:47 +00001490# AC_CHECK_SIZEOF() doesn't include <time.h>.
1491AC_MSG_CHECKING(size of time_t)
1492AC_CACHE_VAL(ac_cv_sizeof_time_t,
1493[AC_TRY_RUN([#include <stdio.h>
1494#include <time.h>
1495main()
1496{
1497 FILE *f=fopen("conftestval", "w");
1498 if (!f) exit(1);
1499 fprintf(f, "%d\n", sizeof(time_t));
1500 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001501}],
1502ac_cv_sizeof_time_t=`cat conftestval`,
1503ac_cv_sizeof_time_t=0,
1504ac_cv_sizeof_time_t=4)
Fred Drakea3f6e912000-06-29 20:44:47 +00001505])
1506AC_MSG_RESULT($ac_cv_sizeof_time_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001507AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t,
1508[The number of bytes in a time_t.])
Fred Drakea3f6e912000-06-29 20:44:47 +00001509
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001510
Trent Mick635f6fb2000-08-23 21:33:05 +00001511# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001512ac_save_cc="$CC"
1513if test "$ac_cv_kpthread" = "yes"
1514then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001515elif test "$ac_cv_kthread" = "yes"
1516then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001517elif test "$ac_cv_pthread" = "yes"
1518then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001519fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001520AC_MSG_CHECKING(for pthread_t)
1521have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +00001522AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +00001523AC_MSG_RESULT($have_pthread_t)
1524if test "$have_pthread_t" = yes ; then
1525 # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
1526 AC_MSG_CHECKING(size of pthread_t)
1527 AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
1528 [AC_TRY_RUN([#include <stdio.h>
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001529#include <pthread.h>
Trent Mick635f6fb2000-08-23 21:33:05 +00001530 main()
1531 {
1532 FILE *f=fopen("conftestval", "w");
1533 if (!f) exit(1);
1534 fprintf(f, "%d\n", sizeof(pthread_t));
1535 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001536 }],
1537 ac_cv_sizeof_pthread_t=`cat conftestval`,
1538 ac_cv_sizeof_pthread_t=0,
1539 ac_cv_sizeof_pthread_t=4)
Trent Mick635f6fb2000-08-23 21:33:05 +00001540 ])
1541 AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001542 AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t,
1543 [The number of bytes in a pthread_t.])
Trent Mick635f6fb2000-08-23 21:33:05 +00001544fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001545CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001546
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001547AC_MSG_CHECKING(for --enable-toolbox-glue)
1548AC_ARG_ENABLE(toolbox-glue,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001549 AC_HELP_STRING(--enable-toolbox-glue, disable/enable MacOSX glue code for extensions))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001550
1551if test -z "$enable_toolbox_glue"
1552then
1553 case $ac_sys_system/$ac_sys_release in
1554 Darwin/*)
1555 enable_toolbox_glue="yes";;
1556 *)
1557 enable_toolbox_glue="no";;
1558 esac
1559fi
1560case "$enable_toolbox_glue" in
1561yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001562 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001563 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001564 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1565 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001566 ;;
1567*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001568 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001569 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001570 ;;
1571esac
1572AC_MSG_RESULT($enable_toolbox_glue)
1573
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001574
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001575AC_SUBST(OTHER_LIBTOOL_OPT)
1576case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001577 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001578 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1579 ;;
1580 Darwin/*)
1581 OTHER_LIBTOOL_OPT=""
1582 ;;
1583esac
1584
Ronald Oussoren461f2202009-09-06 10:54:28 +00001585
1586ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001587AC_SUBST(LIBTOOL_CRUFT)
1588case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001589 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001590 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1591 if test "${enable_universalsdk}"; then
1592 :
1593 else
Ronald Oussoren25e192c2010-02-11 13:27:59 +00001594 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001595 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001596 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001597 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001598 Darwin/*)
Ronald Oussorenc0fa2d242010-02-07 11:50:54 +00001599 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001600 if test ${gcc_version} '<' 4.0
1601 then
1602 LIBTOOL_CRUFT="-lcc_dynamic"
1603 else
1604 LIBTOOL_CRUFT=""
1605 fi
Ronald Oussoren7ab74352009-09-08 07:10:07 +00001606 AC_TRY_RUN([
Ronald Oussoren461f2202009-09-06 10:54:28 +00001607 #include <unistd.h>
1608 int main(int argc, char*argv[])
1609 {
1610 if (sizeof(long) == 4) {
1611 return 0;
1612 } else {
1613 return 1;
1614 }
Ronald Oussoren7ab74352009-09-08 07:10:07 +00001615 }
1616 ], ac_osx_32bit=yes,
Ronald Oussoren461f2202009-09-06 10:54:28 +00001617 ac_osx_32bit=no,
Ronald Oussoren7ab74352009-09-08 07:10:07 +00001618 ac_osx_32bit=yes)
Ronald Oussoren461f2202009-09-06 10:54:28 +00001619
1620 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussoren25e192c2010-02-11 13:27:59 +00001621 case `/usr/bin/arch` in
Ronald Oussoren461f2202009-09-06 10:54:28 +00001622 i386)
1623 MACOSX_DEFAULT_ARCH="i386"
1624 ;;
1625 ppc)
1626 MACOSX_DEFAULT_ARCH="ppc"
1627 ;;
1628 *)
1629 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1630 ;;
1631 esac
1632 else
Ronald Oussoren25e192c2010-02-11 13:27:59 +00001633 case `/usr/bin/arch` in
Ronald Oussoren461f2202009-09-06 10:54:28 +00001634 i386)
1635 MACOSX_DEFAULT_ARCH="x86_64"
1636 ;;
1637 ppc)
1638 MACOSX_DEFAULT_ARCH="ppc64"
1639 ;;
1640 *)
1641 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1642 ;;
1643 esac
1644
1645 #ARCH_RUN_32BIT="true"
1646 fi
1647
1648 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001649 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001650 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001651esac
1652
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001653AC_MSG_CHECKING(for --enable-framework)
1654if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001655then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001656 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001657 # -F. is needed to allow linking to the framework while
1658 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001659 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1660 [Define if you want to produce an OpenStep/Rhapsody framework
1661 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001662 AC_MSG_RESULT(yes)
Ronald Oussorene6e62672009-06-08 21:19:36 +00001663 if test $enable_shared = "yes"
1664 then
Ronald Oussorend0841712009-09-29 13:01:59 +00001665 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead. See Mac/README.])
Ronald Oussorene6e62672009-06-08 21:19:36 +00001666 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001667else
1668 AC_MSG_RESULT(no)
1669fi
1670
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001671AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001672case $ac_sys_system/$ac_sys_release in
1673 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001674 AC_DEFINE(WITH_DYLD, 1,
1675 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1676 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1677 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001678 AC_MSG_RESULT(always on for Darwin)
1679 ;;
1680 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001681 AC_MSG_RESULT(no)
1682 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001683esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001684
Guido van Rossumac405f61994-09-12 10:56:06 +00001685# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001686AC_SUBST(SO)
1687AC_SUBST(LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001688AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001689AC_SUBST(CCSHARED)
1690AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001691# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001692# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001693AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001694if test -z "$SO"
1695then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001696 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00001697 hp*|HP*)
1698 case `uname -m` in
1699 ia64) SO=.so;;
1700 *) SO=.sl;;
1701 esac
1702 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001703 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001704 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001705 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001706else
1707 # this might also be a termcap variable, see #610332
1708 echo
1709 echo '====================================================================='
1710 echo '+ +'
1711 echo '+ WARNING: You have set SO in your environment. +'
1712 echo '+ Do you really mean to change the extension for shared libraries? +'
1713 echo '+ Continuing in 10 seconds to let you to ponder. +'
1714 echo '+ +'
1715 echo '====================================================================='
1716 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001717fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001718AC_MSG_RESULT($SO)
Ronald Oussorene9cce8e2009-01-02 10:46:42 +00001719
Neal Norwitz58e28882006-05-19 07:00:58 +00001720AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001721# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001722# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001723# (Shared libraries in this instance are shared modules to be loaded into
1724# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001725AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001726if test -z "$LDSHARED"
1727then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001728 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001729 AIX*)
1730 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001731 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001732 ;;
1733 BeOS*)
1734 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00001735 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001736 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001737 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001738 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a6632000-05-26 12:22:54 +00001739 SunOS/5*)
1740 if test "$GCC" = "yes"
Neil Schemenauer95052722001-02-19 18:17:33 +00001741 then LDSHARED='$(CC) -shared'
Martin v. Löwisaa5afe12002-10-07 06:21:41 +00001742 else LDSHARED='$(CC) -G';
Greg Ward57c9a6632000-05-26 12:22:54 +00001743 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00001744 hp*|HP*)
1745 if test "$GCC" = "yes"
1746 then LDSHARED='$(CC) -shared'
1747 else LDSHARED='ld -b';
1748 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001749 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001750 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +00001751 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1752 if test "$enable_framework" ; then
1753 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001754 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1755 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001756 else
1757 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001758 LDSHARED="$LDSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001759 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001760 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001761 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1762 if test "$enable_framework" ; then
1763 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001764 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1765 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001766 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001767 # No framework, use the Python app as bundle-loader
1768 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001769 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001770 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001771 Darwin/*)
1772 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1773 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00001774
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001775 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001776 then
Ronald Oussoren988117f2006-04-29 11:31:35 +00001777 if test "${enable_universalsdk}"; then
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001778 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001779 fi
Jack Jansen6b08a402004-06-03 12:41:45 +00001780 LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1781 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001782 else
1783 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1784 if test "$enable_framework" ; then
1785 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001786 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1787 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001788 else
1789 # No framework, use the Python app as bundle-loader
1790 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1791 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1792 fi
1793 fi
1794 ;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00001795 Linux*|GNU*|QNX*) LDSHARED='$(CC) -shared';;
Guido van Rossum458e7fa1999-09-17 15:40:40 +00001796 BSD/OS*/4*) LDSHARED="gcc -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00001797 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001798 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001799 then
Hye-Shik Chang33761492004-10-26 09:53:46 +00001800 LDSHARED="$CC -shared ${LDFLAGS}"
Guido van Rossum0286ae82000-08-29 15:06:49 +00001801 else
1802 LDSHARED="ld -Bshareable ${LDFLAGS}"
1803 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00001804 OpenBSD*)
1805 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1806 then
1807 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1808 else
1809 case `uname -r` in
1810 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1811 LDSHARED="ld -Bshareable ${LDFLAGS}"
1812 ;;
1813 *)
1814 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1815 ;;
1816 esac
1817 fi;;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001818 NetBSD*|DragonFly*) LDSHARED="cc -shared ${LDFLAGS}";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001819 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001820 if test "$GCC" = "yes"
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001821 then LDSHARED='$(CC) -shared'
1822 else LDSHARED='$(CC) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001823 fi;;
Martin v. Löwis79f3c532002-12-11 12:51:58 +00001824 SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
Trent Mick635f6fb2000-08-23 21:33:05 +00001825 Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001826 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001827 atheos*) LDSHARED="gcc -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001828 *) LDSHARED="ld";;
1829 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001830fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001831AC_MSG_RESULT($LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001832BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001833# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001834# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001835AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001836if test -z "$CCSHARED"
1837then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001838 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001839 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00001840 then CCSHARED="-fPIC";
1841 elif test `uname -p` = sparc;
1842 then CCSHARED="-xcode=pic32";
1843 else CCSHARED="-Kpic";
1844 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001845 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001846 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001847 else CCSHARED="+z";
1848 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001849 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001850 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001851 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001852 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001853 if test "$GCC" = "yes"
1854 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001855 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001856 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001857 SCO_SV*)
1858 if test "$GCC" = "yes"
1859 then CCSHARED="-fPIC"
1860 else CCSHARED="-Kpic -belf"
1861 fi;;
Trent Mick635f6fb2000-08-23 21:33:05 +00001862 Monterey*) CCSHARED="-G";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001863 IRIX*/6*) case $CC in
1864 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001865 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001866 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001867 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001868 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001869fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001870AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001871# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001872# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001873AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001874if test -z "$LINKFORSHARED"
1875then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001876 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001877 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001878 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001879 LINKFORSHARED="-Wl,-E -Wl,+s";;
1880# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001881 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001882 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001883 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001884 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001885 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
1886 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001887 # not used by the core itself but which needs to be in the core so
1888 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00001889 # -prebind is no longer used, because it actually seems to give a
1890 # slowdown in stead of a speedup, maybe due to the large number of
1891 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001892
1893 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001894 if test "$enable_framework"
1895 then
Jack Jansenda49e192005-01-07 13:08:22 +00001896 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001897 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001898 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001899 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001900 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001901 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001902 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001903 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1904 then
1905 LINKFORSHARED="-Wl,--export-dynamic"
1906 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001907 SunOS/5*) case $CC in
1908 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001909 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001910 then
1911 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001912 fi;;
1913 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001914 CYGWIN*)
1915 if test $enable_shared = "no"
1916 then
1917 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1918 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00001919 QNX*)
1920 # -Wl,-E causes the symbols to be added to the dynamic
1921 # symbol table so that they can be found when a module
1922 # is loaded. -N 2048K causes the stack size to be set
1923 # to 2048 kilobytes so that the stack doesn't overflow
1924 # when running test_compile.py.
1925 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00001926 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001927fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001928AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001929
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001930
Neil Schemenauer61c51152001-01-26 16:18:16 +00001931AC_SUBST(CFLAGSFORSHARED)
1932AC_MSG_CHECKING(CFLAGSFORSHARED)
1933if test ! "$LIBRARY" = "$LDLIBRARY"
1934then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00001935 case $ac_sys_system in
1936 CYGWIN*)
1937 # Cygwin needs CCSHARED when building extension DLLs
1938 # but not when building the interpreter DLL.
1939 CFLAGSFORSHARED='';;
1940 *)
1941 CFLAGSFORSHARED='$(CCSHARED)'
1942 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00001943fi
1944AC_MSG_RESULT($CFLAGSFORSHARED)
1945
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001946# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1947# library (with --enable-shared).
1948# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001949# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1950# if it is not required, since it creates a dependency of the shared library
1951# to LIBS. This, in turn, means that applications linking the shared libpython
1952# don't need to link LIBS explicitly. The default should be only changed
1953# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001954AC_SUBST(SHLIBS)
1955AC_MSG_CHECKING(SHLIBS)
1956case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001957 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001958 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001959esac
1960AC_MSG_RESULT($SHLIBS)
1961
1962
Guido van Rossum627b2d71993-12-24 10:39:16 +00001963# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001964AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
1965AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00001966
Georg Brandl5c7f8fb2008-12-05 09:00:55 +00001967# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00001968if test "$with_threads" = "yes" -o -z "$with_threads"; then
1969 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1970 # posix4 on Solaris 2.6
1971 # pthread (first!) on Linux
1972fi
1973
Martin v. Löwis19d17342003-06-14 21:03:05 +00001974# check if we need libintl for locale functions
1975AC_CHECK_LIB(intl, textdomain,
1976 AC_DEFINE(WITH_LIBINTL, 1,
1977 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001978
1979# checks for system dependent C++ extensions support
1980case "$ac_sys_system" in
1981 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1982 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1983 [loadAndInit("", 0, "")],
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001984 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1985 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1986 and you want support for AIX C++ shared extension modules.])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001987 AC_MSG_RESULT(yes)],
1988 [AC_MSG_RESULT(no)]);;
1989 *) ;;
1990esac
1991
Guido van Rossum70c7f481998-03-26 18:44:10 +00001992# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001993# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001994AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00001995AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00001996
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00001997case "$ac_sys_system" in
1998BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001999AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2000;;
2001esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002002
Guido van Rossumc5a39031996-07-31 17:35:03 +00002003AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002004AC_ARG_WITH(libs,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002005 AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
2006[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002007AC_MSG_RESULT($withval)
2008LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002009],
2010[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002011
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002012# Check for use of the system libffi library
2013AC_MSG_CHECKING(for --with-system-ffi)
2014AC_ARG_WITH(system_ffi,
2015 AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
2016
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002017AC_MSG_RESULT($with_system_ffi)
2018
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002019# Determine if signalmodule should be used.
2020AC_SUBST(USE_SIGNAL_MODULE)
2021AC_SUBST(SIGNAL_OBJS)
2022AC_MSG_CHECKING(for --with-signal-module)
2023AC_ARG_WITH(signal-module,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002024 AC_HELP_STRING(--with-signal-module, disable/enable signal module))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002025
2026if test -z "$with_signal_module"
2027then with_signal_module="yes"
2028fi
2029AC_MSG_RESULT($with_signal_module)
2030
2031if test "${with_signal_module}" = "yes"; then
2032 USE_SIGNAL_MODULE=""
2033 SIGNAL_OBJS=""
2034else
2035 USE_SIGNAL_MODULE="#"
2036 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2037fi
2038
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002039# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002040AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002041USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002042
Guido van Rossum54d93d41997-01-22 20:51:58 +00002043AC_MSG_CHECKING(for --with-dec-threads)
2044AC_SUBST(LDLAST)
2045AC_ARG_WITH(dec-threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002046 AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
2047[
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002048AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002049LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002050if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002051 with_thread="$withval";
2052fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002053[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002054
Martin v. Löwis11437992002-04-12 09:54:03 +00002055# Templates for things AC_DEFINEd more than once.
2056# For a single AC_DEFINE, no template is needed.
2057AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2058AH_TEMPLATE(_REENTRANT,
2059 [Define to force use of thread-safe errno, h_errno, and other functions])
2060AH_TEMPLATE(WITH_THREAD,
2061 [Define if you want to compile in rudimentary thread support])
2062
Guido van Rossum54d93d41997-01-22 20:51:58 +00002063AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002064dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002065AC_ARG_WITH(threads,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002066 AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002067
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002068# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002069dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002070AC_ARG_WITH(thread,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002071 AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
2072 [with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002073
2074if test -z "$with_threads"
2075then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002076fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002077AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002078
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002079AC_SUBST(THREADOBJ)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002080if test "$with_threads" = "no"
2081then
2082 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002083elif test "$ac_cv_pthread_is_default" = yes
2084then
2085 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002086 # Defining _REENTRANT on system with POSIX threads should not hurt.
2087 AC_DEFINE(_REENTRANT)
2088 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002089 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002090elif test "$ac_cv_kpthread" = "yes"
2091then
2092 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002093 if test "$ac_cv_cxx_thread" = "yes"; then
2094 CXX="$CXX -Kpthread"
2095 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002096 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002097 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002098 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002099elif test "$ac_cv_kthread" = "yes"
2100then
2101 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002102 if test "$ac_cv_cxx_thread" = "yes"; then
2103 CXX="$CXX -Kthread"
2104 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002105 AC_DEFINE(WITH_THREAD)
2106 posix_threads=yes
2107 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002108elif test "$ac_cv_pthread" = "yes"
2109then
2110 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002111 if test "$ac_cv_cxx_thread" = "yes"; then
2112 CXX="$CXX -pthread"
2113 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002114 AC_DEFINE(WITH_THREAD)
2115 posix_threads=yes
2116 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002117else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002118 if test ! -z "$with_threads" -a -d "$with_threads"
2119 then LDFLAGS="$LDFLAGS -L$with_threads"
2120 fi
2121 if test ! -z "$withval" -a -d "$withval"
2122 then LDFLAGS="$LDFLAGS -L$withval"
2123 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002124
2125 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002126 # define _POSIX_THREADS in unistd.h. Some apparently don't
2127 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002128 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2129 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002130 [
2131#include <unistd.h>
2132#ifdef _POSIX_THREADS
2133yes
2134#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002135 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2136 AC_MSG_RESULT($unistd_defines_pthreads)
2137
Martin v. Löwis130fb172001-07-19 11:00:41 +00002138 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002139 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2140 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002141 AC_DEFINE(HURD_C_THREADS, 1,
2142 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002143 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002144 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002145 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2146 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002147 AC_DEFINE(MACH_C_THREADS, 1,
2148 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002149 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002150 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002151 AC_ARG_WITH([pth],
2152 AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
2153 [AC_MSG_RESULT($withval)
2154 AC_DEFINE([WITH_THREAD])
2155 AC_DEFINE([HAVE_PTH], 1,
2156 [Define if you have GNU PTH threads.])
2157 LIBS="-lpth $LIBS"
2158 THREADOBJ="Python/thread.o"],
2159 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002160
2161 # Just looking for pthread_create in libpthread is not enough:
2162 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2163 # So we really have to include pthread.h, and then link.
2164 _libs=$LIBS
2165 LIBS="$LIBS -lpthread"
2166 AC_MSG_CHECKING([for pthread_create in -lpthread])
2167 AC_TRY_LINK([#include <pthread.h>
2168
2169void * start_routine (void *arg) { exit (0); }], [
2170pthread_create (NULL, NULL, start_routine, NULL)], [
2171 AC_MSG_RESULT(yes)
2172 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002173 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002174 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002175 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002176 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002177 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002178 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002179 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2180 AC_DEFINE(ATHEOS_THREADS, 1,
2181 [Define this if you have AtheOS threads.])
2182 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002183 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002184 AC_DEFINE(BEOS_THREADS, 1,
2185 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002186 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002187 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002188 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002189 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002190 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002191 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002192 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002193 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002194 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002195 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002196 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002197 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002198 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002199 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002200 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002201 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002202 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002203 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002204 ])])])])])])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002205
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002206 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2207 LIBS="$LIBS -lmpc"
2208 THREADOBJ="Python/thread.o"
2209 USE_THREAD_MODULE=""])
2210
2211 if test "$posix_threads" != "yes"; then
2212 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2213 LIBS="$LIBS -lthread"
2214 THREADOBJ="Python/thread.o"
2215 USE_THREAD_MODULE=""])
2216 fi
2217
2218 if test "$USE_THREAD_MODULE" != "#"
2219 then
2220 # If the above checks didn't disable threads, (at least) OSF1
2221 # needs this '-threads' argument during linking.
2222 case $ac_sys_system in
2223 OSF1) LDLAST=-threads;;
2224 esac
2225 fi
2226fi
2227
2228if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002229 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002230 AC_DEFINE(_POSIX_THREADS, 1,
2231 [Define if you have POSIX threads,
2232 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002233 fi
2234
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002235 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2236 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002237 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2238 Defined for Solaris 2.6 bug in pthread header.)
2239 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002240 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002241 Define if the Posix semaphores do not work on your system)
2242 ;;
Christian Heimescba36bb2008-01-30 22:54:18 +00002243 AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2244 Define if the Posix semaphores do not work on your system)
2245 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002246 esac
2247
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002248 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2249 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2250 [AC_TRY_RUN([#include <pthread.h>
2251 void *foo(void *parm) {
2252 return NULL;
2253 }
2254 main() {
2255 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002256 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002257 if (pthread_attr_init(&attr)) exit(-1);
2258 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002259 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002260 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00002261 }],
2262 ac_cv_pthread_system_supported=yes,
2263 ac_cv_pthread_system_supported=no,
2264 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002265 ])
2266 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2267 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002268 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002269 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002270 AC_CHECK_FUNCS(pthread_sigmask,
2271 [case $ac_sys_system in
2272 CYGWIN*)
2273 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2274 [Define if pthread_sigmask() does not work on your system.])
2275 ;;
2276 esac])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002277fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002278
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002279
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002280# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002281AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002282AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002283AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002284[ --enable-ipv6 Enable ipv6 (with ipv4) support
2285 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002286[ case "$enableval" in
2287 no)
2288 AC_MSG_RESULT(no)
2289 ipv6=no
2290 ;;
2291 *) AC_MSG_RESULT(yes)
2292 AC_DEFINE(ENABLE_IPV6)
2293 ipv6=yes
2294 ;;
2295 esac ],
2296
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002297[
2298dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002299 AC_TRY_RUN([ /* AF_INET6 available check */
2300#include <sys/types.h>
2301#include <sys/socket.h>
2302main()
2303{
2304 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2305 exit(1);
2306 else
2307 exit(0);
2308}
2309],
2310 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002311 ipv6=yes,
2312 AC_MSG_RESULT(no)
2313 ipv6=no,
2314 AC_MSG_RESULT(no)
2315 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002316)
2317
2318if test "$ipv6" = "yes"; then
2319 AC_MSG_CHECKING(if RFC2553 API is available)
2320 AC_TRY_COMPILE([#include <sys/types.h>
2321#include <netinet/in.h>],
2322 [struct sockaddr_in6 x;
2323x.sin6_scope_id;],
2324 AC_MSG_RESULT(yes)
2325 ipv6=yes,
2326 AC_MSG_RESULT(no, IPv6 disabled)
2327 ipv6=no)
2328fi
2329
2330if test "$ipv6" = "yes"; then
2331 AC_DEFINE(ENABLE_IPV6)
2332fi
2333])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002334
2335ipv6type=unknown
2336ipv6lib=none
2337ipv6trylibc=no
2338
2339if test "$ipv6" = "yes"; then
2340 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002341 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2342 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002343 case $i in
2344 inria)
2345 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002346 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002347#include <netinet/in.h>
2348#ifdef IPV6_INRIA_VERSION
2349yes
2350#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002351 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002352 ;;
2353 kame)
2354 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002355 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002356#include <netinet/in.h>
2357#ifdef __KAME__
2358yes
2359#endif],
2360 [ipv6type=$i;
2361 ipv6lib=inet6
2362 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002363 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002364 ;;
2365 linux-glibc)
2366 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002367 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002368#include <features.h>
2369#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2370yes
2371#endif],
2372 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002373 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002374 ;;
2375 linux-inet6)
2376 dnl http://www.v6.linux.or.jp/
2377 if test -d /usr/inet6; then
2378 ipv6type=$i
2379 ipv6lib=inet6
2380 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002381 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002382 fi
2383 ;;
2384 solaris)
2385 if test -f /etc/netconfig; then
2386 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2387 ipv6type=$i
2388 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002389 fi
2390 fi
2391 ;;
2392 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002393 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002394#include <sys/param.h>
2395#ifdef _TOSHIBA_INET6
2396yes
2397#endif],
2398 [ipv6type=$i;
2399 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002400 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002401 ;;
2402 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002403 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002404#include </usr/local/v6/include/sys/v6config.h>
2405#ifdef __V6D__
2406yes
2407#endif],
2408 [ipv6type=$i;
2409 ipv6lib=v6;
2410 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002411 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002412 ;;
2413 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002414 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002415#include <sys/param.h>
2416#ifdef _ZETA_MINAMI_INET6
2417yes
2418#endif],
2419 [ipv6type=$i;
2420 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002421 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002422 ;;
2423 esac
2424 if test "$ipv6type" != "unknown"; then
2425 break
2426 fi
2427 done
2428 AC_MSG_RESULT($ipv6type)
2429fi
2430
2431if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2432 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2433 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2434 echo "using lib$ipv6lib"
2435 else
2436 if test $ipv6trylibc = "yes"; then
2437 echo "using libc"
2438 else
2439 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2440 echo "You need to fetch lib$ipv6lib.a from appropriate"
2441 echo 'ipv6 kit and compile beforehand.'
2442 exit 1
2443 fi
2444 fi
2445fi
2446
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002447AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2448AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
2449 AC_DEFINE(HAVE_OSX105_SDK, 1, Define if compiling using MacOS X 10.5 SDK or later.)
2450 AC_MSG_RESULT(yes),
2451 AC_MSG_RESULT(no)
2452)
2453
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002454# Check for --with-doc-strings
2455AC_MSG_CHECKING(for --with-doc-strings)
2456AC_ARG_WITH(doc-strings,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002457 AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002458
2459if test -z "$with_doc_strings"
2460then with_doc_strings="yes"
2461fi
2462if test "$with_doc_strings" != "no"
2463then
2464 AC_DEFINE(WITH_DOC_STRINGS, 1,
2465 [Define if you want documentation strings in extension modules])
2466fi
2467AC_MSG_RESULT($with_doc_strings)
2468
Neil Schemenauera35c6882001-02-27 04:45:05 +00002469# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002470AC_MSG_CHECKING(for --with-tsc)
2471AC_ARG_WITH(tsc,
2472[ --with(out)-tsc enable/disable timestamp counter profile], [
2473if test "$withval" != no
2474then
2475 AC_DEFINE(WITH_TSC, 1,
2476 [Define to profile with the Pentium timestamp counter])
2477 AC_MSG_RESULT(yes)
2478else AC_MSG_RESULT(no)
2479fi],
2480[AC_MSG_RESULT(no)])
2481
2482# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002483AC_MSG_CHECKING(for --with-pymalloc)
2484AC_ARG_WITH(pymalloc,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002485 AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002486
2487if test -z "$with_pymalloc"
2488then with_pymalloc="yes"
2489fi
2490if test "$with_pymalloc" != "no"
2491then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002492 AC_DEFINE(WITH_PYMALLOC, 1,
2493 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002494fi
2495AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002496
Barry Warsawef82cd72000-06-30 16:21:01 +00002497# Check for --with-wctype-functions
2498AC_MSG_CHECKING(for --with-wctype-functions)
2499AC_ARG_WITH(wctype-functions,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002500 AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2501[
Barry Warsawef82cd72000-06-30 16:21:01 +00002502if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002503then
2504 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2505 [Define if you want wctype.h functions to be used instead of the
2506 one supplied by Python itself. (see Include/unicodectype.h).])
2507 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002508else AC_MSG_RESULT(no)
2509fi],
2510[AC_MSG_RESULT(no)])
2511
Guido van Rossum68242b51996-05-28 22:53:03 +00002512# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002513AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002514DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002515
Guido van Rossume97ee181999-12-20 21:27:22 +00002516# the dlopen() function means we might want to use dynload_shlib.o. some
2517# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002518AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002519
2520# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2521# loading of modules.
2522AC_SUBST(DYNLOADFILE)
2523AC_MSG_CHECKING(DYNLOADFILE)
2524if test -z "$DYNLOADFILE"
2525then
2526 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002527 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2528 if test "$ac_cv_func_dlopen" = yes
2529 then DYNLOADFILE="dynload_shlib.o"
2530 else DYNLOADFILE="dynload_aix.o"
2531 fi
2532 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002533 BeOS*) DYNLOADFILE="dynload_beos.o";;
2534 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00002535 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2536 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002537 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002538 *)
2539 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2540 # out any dynamic loading
2541 if test "$ac_cv_func_dlopen" = yes
2542 then DYNLOADFILE="dynload_shlib.o"
2543 else DYNLOADFILE="dynload_stub.o"
2544 fi
2545 ;;
2546 esac
2547fi
2548AC_MSG_RESULT($DYNLOADFILE)
2549if test "$DYNLOADFILE" != "dynload_stub.o"
2550then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002551 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2552 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002553fi
2554
Jack Jansenc49e5b72001-06-19 15:00:23 +00002555# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2556
2557AC_SUBST(MACHDEP_OBJS)
2558AC_MSG_CHECKING(MACHDEP_OBJS)
2559if test -z "$MACHDEP_OBJS"
2560then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002561 MACHDEP_OBJS=$extra_machdep_objs
2562else
2563 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002564fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002565AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002566
Guido van Rossum627b2d71993-12-24 10:39:16 +00002567# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00002568AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2569 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002570 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwisc3001752005-01-23 09:27:24 +00002571 getpriority getpwent getspnam getspent getsid getwd \
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002572 kill killpg lchmod lchown lstat mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002573 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002574 putenv readlink realpath \
Martin v. Löwisd5843682002-11-21 20:41:28 +00002575 select setegid seteuid setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002576 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00002577 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002578 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00002579 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002580
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002581# For some functions, having a definition is not sufficient, since
2582# we want to take their address.
2583AC_MSG_CHECKING(for chroot)
2584AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2585 AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2586 AC_MSG_RESULT(yes),
2587 AC_MSG_RESULT(no)
2588)
2589AC_MSG_CHECKING(for link)
2590AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2591 AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2592 AC_MSG_RESULT(yes),
2593 AC_MSG_RESULT(no)
2594)
2595AC_MSG_CHECKING(for symlink)
2596AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2597 AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2598 AC_MSG_RESULT(yes),
2599 AC_MSG_RESULT(no)
2600)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002601AC_MSG_CHECKING(for fchdir)
2602AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2603 AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2604 AC_MSG_RESULT(yes),
2605 AC_MSG_RESULT(no)
2606)
2607AC_MSG_CHECKING(for fsync)
2608AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
Skip Montanarod4fa8072003-09-25 14:49:15 +00002609 AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002610 AC_MSG_RESULT(yes),
2611 AC_MSG_RESULT(no)
2612)
2613AC_MSG_CHECKING(for fdatasync)
2614AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2615 AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2616 AC_MSG_RESULT(yes),
2617 AC_MSG_RESULT(no)
2618)
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002619AC_MSG_CHECKING(for epoll)
2620AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
2621 AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2622 AC_MSG_RESULT(yes),
2623 AC_MSG_RESULT(no)
2624)
2625AC_MSG_CHECKING(for kqueue)
2626AC_TRY_COMPILE([
2627#include <sys/types.h>
2628#include <sys/event.h>
2629 ], int x=kqueue(),
2630 AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2631 AC_MSG_RESULT(yes),
2632 AC_MSG_RESULT(no)
2633)
Martin v. Löwisd5843682002-11-21 20:41:28 +00002634# On some systems (eg. FreeBSD 5), we would find a definition of the
2635# functions ctermid_r, setgroups in the library, but no prototype
2636# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2637# address to avoid compiler warnings and potential miscompilations
2638# because of the missing prototypes.
2639
2640AC_MSG_CHECKING(for ctermid_r)
2641AC_TRY_COMPILE([
2642#include "confdefs.h"
2643#include <stdio.h>
2644], void* p = ctermid_r,
2645 AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2646 AC_MSG_RESULT(yes),
2647 AC_MSG_RESULT(no)
2648)
2649
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002650AC_MSG_CHECKING(for flock)
2651AC_TRY_COMPILE([
2652#include "confdefs.h"
2653#include <sys/file.h>
2654], void* p = flock,
2655 AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2656 AC_MSG_RESULT(yes),
2657 AC_MSG_RESULT(no)
2658)
2659
2660AC_MSG_CHECKING(for getpagesize)
2661AC_TRY_COMPILE([
2662#include "confdefs.h"
2663#include <unistd.h>
2664], void* p = getpagesize,
2665 AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2666 AC_MSG_RESULT(yes),
2667 AC_MSG_RESULT(no)
2668)
2669
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002670dnl check for true
2671AC_CHECK_PROGS(TRUE, true, /bin/true)
2672
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002673dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2674dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002675AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002676 AC_CHECK_LIB(resolv, inet_aton)
2677)
2678
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002679# On Tru64, chflags seems to be present, but calling it will
2680# exit Python
Benjamin Petersonb453f0b2010-01-30 19:51:50 +00002681AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
2682AC_TRY_RUN([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002683#include <sys/stat.h>
2684#include <unistd.h>
2685int main(int argc, char*argv[])
2686{
2687 if(chflags(argv[0], 0) != 0)
2688 return 1;
2689 return 0;
2690}
Benjamin Petersonb453f0b2010-01-30 19:51:50 +00002691]], ac_cv_have_chflags=yes,
2692 ac_cv_have_chflags=no,
2693 ac_cv_have_chflags=cross)
2694])
2695if test "$ac_cv_have_chflags" = cross ; then
2696 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2697fi
2698if test "$ac_cv_have_chflags" = yes ; then
2699 AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
2700fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002701
Benjamin Petersonb453f0b2010-01-30 19:51:50 +00002702AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
2703AC_TRY_RUN([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002704#include <sys/stat.h>
2705#include <unistd.h>
2706int main(int argc, char*argv[])
2707{
2708 if(lchflags(argv[0], 0) != 0)
2709 return 1;
2710 return 0;
2711}
Benjamin Petersonb453f0b2010-01-30 19:51:50 +00002712]], ac_cv_have_lchflags=yes,
2713 ac_cv_have_lchflags=no,
2714 ac_cv_have_lchflags=cross)
2715])
2716if test "$ac_cv_have_lchflags" = cross ; then
2717 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2718fi
2719if test "$ac_cv_have_lchflags" = yes ; then
2720 AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
2721fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002722
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00002723dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00002724dnl
2725dnl On MacOSX the linker will search for dylibs on the entire linker path
2726dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2727dnl to revert to a more traditional unix behaviour and make it possible to
2728dnl override the system libz with a local static library of libz. Temporarily
2729dnl add that flag to our CFLAGS as well to ensure that we check the version
2730dnl of libz that will be used by setup.py.
2731dnl The -L/usr/local/lib is needed as wel to get the same compilation
2732dnl environment as setup.py (and leaving it out can cause configure to use the
2733dnl wrong version of the library)
2734case $ac_sys_system/$ac_sys_release in
2735Darwin/*)
2736 _CUR_CFLAGS="${CFLAGS}"
2737 _CUR_LDFLAGS="${LDFLAGS}"
2738 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2739 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2740 ;;
2741esac
2742
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00002743AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2744
Ronald Oussorenf8752642006-07-06 10:13:35 +00002745case $ac_sys_system/$ac_sys_release in
2746Darwin/*)
2747 CFLAGS="${_CUR_CFLAGS}"
2748 LDFLAGS="${_CUR_LDFLAGS}"
2749 ;;
2750esac
2751
Martin v. Löwise9416172003-05-03 10:12:45 +00002752AC_MSG_CHECKING(for hstrerror)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002753AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002754#include "confdefs.h"
2755#include <netdb.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002756], void* p = hstrerror; hstrerror(0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002757 AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2758 AC_MSG_RESULT(yes),
2759 AC_MSG_RESULT(no)
2760)
2761
2762AC_MSG_CHECKING(for inet_aton)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002763AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002764#include "confdefs.h"
Martin v. Löwis86d66262006-02-17 08:40:11 +00002765#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002766#include <sys/socket.h>
2767#include <netinet/in.h>
2768#include <arpa/inet.h>
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002769], void* p = inet_aton;inet_aton(0,0),
Martin v. Löwise9416172003-05-03 10:12:45 +00002770 AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2771 AC_MSG_RESULT(yes),
2772 AC_MSG_RESULT(no)
2773)
2774
2775AC_MSG_CHECKING(for inet_pton)
2776AC_TRY_COMPILE([
2777#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002778#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002779#include <sys/socket.h>
2780#include <netinet/in.h>
2781#include <arpa/inet.h>
2782], void* p = inet_pton,
2783 AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2784 AC_MSG_RESULT(yes),
2785 AC_MSG_RESULT(no)
2786)
2787
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002788# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002789AC_MSG_CHECKING(for setgroups)
2790AC_TRY_COMPILE([
2791#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002792#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002793#ifdef HAVE_GRP_H
2794#include <grp.h>
2795#endif
Martin v. Löwisd5843682002-11-21 20:41:28 +00002796],
2797void* p = setgroups,
2798 AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2799 AC_MSG_RESULT(yes),
2800 AC_MSG_RESULT(no)
2801)
2802
Fred Drake8cef4cf2000-06-28 16:40:38 +00002803# check for openpty and forkpty
2804
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002805AC_CHECK_FUNCS(openpty,,
2806 AC_CHECK_LIB(util,openpty,
2807 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2808 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2809 )
2810)
2811AC_CHECK_FUNCS(forkpty,,
2812 AC_CHECK_LIB(util,forkpty,
2813 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2814 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2815 )
2816)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002817
Brett Cannonaa5778d2008-03-18 04:09:00 +00002818# Stuff for expat.
2819AC_CHECK_FUNCS(memmove)
2820
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002821# check for long file support functions
2822AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2823
Brett Cannonaa5778d2008-03-18 04:09:00 +00002824AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002825AC_CHECK_FUNCS(getpgrp,
2826 AC_TRY_COMPILE([#include <unistd.h>],
2827 [getpgrp(0);],
2828 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2829 [Define if getpgrp() must be called as getpgrp(0).])
2830 )
2831)
Jack Jansen150753c2003-03-29 22:07:47 +00002832AC_CHECK_FUNCS(setpgrp,
2833 AC_TRY_COMPILE([#include <unistd.h>],
2834 [setpgrp(0,0);],
2835 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2836 [Define if setpgrp() must be called as setpgrp(0, 0).])
2837 )
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002838)
2839AC_CHECK_FUNCS(gettimeofday,
2840 AC_TRY_COMPILE([#include <sys/time.h>],
2841 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2842 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2843 [Define if gettimeofday() does not have second (timezone) argument
2844 This is the case on Motorola V4 (R40V4.2)])
2845 )
2846)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002847
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002848AC_MSG_CHECKING(for major, minor, and makedev)
Martin v. Löwise3271202002-11-07 07:42:30 +00002849AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002850#if defined(MAJOR_IN_MKDEV)
2851#include <sys/mkdev.h>
2852#elif defined(MAJOR_IN_SYSMACROS)
2853#include <sys/sysmacros.h>
2854#else
2855#include <sys/types.h>
2856#endif
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002857],[
2858 makedev(major(0),minor(0));
2859],[
2860 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2861 [Define to 1 if you have the device macros.])
2862 AC_MSG_RESULT(yes)
2863],[
2864 AC_MSG_RESULT(no)
2865])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002866
2867# On OSF/1 V5.1, getaddrinfo is available, but a define
2868# for [no]getaddrinfo in netdb.h.
2869AC_MSG_CHECKING(for getaddrinfo)
2870AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002871#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002872#include <sys/socket.h>
2873#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002874#include <stdio.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002875],[
2876getaddrinfo(NULL, NULL, NULL, NULL);
2877], [
2878AC_MSG_RESULT(yes)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002879AC_MSG_CHECKING(getaddrinfo bug)
2880AC_TRY_RUN([
2881#include <sys/types.h>
2882#include <netdb.h>
2883#include <string.h>
2884#include <sys/socket.h>
2885#include <netinet/in.h>
2886
2887main()
2888{
2889 int passive, gaierr, inet4 = 0, inet6 = 0;
2890 struct addrinfo hints, *ai, *aitop;
2891 char straddr[INET6_ADDRSTRLEN], strport[16];
2892
2893 for (passive = 0; passive <= 1; passive++) {
2894 memset(&hints, 0, sizeof(hints));
2895 hints.ai_family = AF_UNSPEC;
2896 hints.ai_flags = passive ? AI_PASSIVE : 0;
2897 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002898 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002899 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2900 (void)gai_strerror(gaierr);
2901 goto bad;
2902 }
2903 for (ai = aitop; ai; ai = ai->ai_next) {
2904 if (ai->ai_addr == NULL ||
2905 ai->ai_addrlen == 0 ||
2906 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2907 straddr, sizeof(straddr), strport, sizeof(strport),
2908 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2909 goto bad;
2910 }
2911 switch (ai->ai_family) {
2912 case AF_INET:
2913 if (strcmp(strport, "54321") != 0) {
2914 goto bad;
2915 }
2916 if (passive) {
2917 if (strcmp(straddr, "0.0.0.0") != 0) {
2918 goto bad;
2919 }
2920 } else {
2921 if (strcmp(straddr, "127.0.0.1") != 0) {
2922 goto bad;
2923 }
2924 }
2925 inet4++;
2926 break;
2927 case AF_INET6:
2928 if (strcmp(strport, "54321") != 0) {
2929 goto bad;
2930 }
2931 if (passive) {
2932 if (strcmp(straddr, "::") != 0) {
2933 goto bad;
2934 }
2935 } else {
2936 if (strcmp(straddr, "::1") != 0) {
2937 goto bad;
2938 }
2939 }
2940 inet6++;
2941 break;
2942 case AF_UNSPEC:
2943 goto bad;
2944 break;
2945 default:
2946 /* another family support? */
2947 break;
2948 }
2949 }
2950 }
2951
2952 if (!(inet4 == 0 || inet4 == 2))
2953 goto bad;
2954 if (!(inet6 == 0 || inet6 == 2))
2955 goto bad;
2956
2957 if (aitop)
2958 freeaddrinfo(aitop);
2959 exit(0);
2960
2961 bad:
2962 if (aitop)
2963 freeaddrinfo(aitop);
2964 exit(1);
2965}
2966],
2967AC_MSG_RESULT(good)
2968buggygetaddrinfo=no,
2969AC_MSG_RESULT(buggy)
2970buggygetaddrinfo=yes,
2971AC_MSG_RESULT(buggy)
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002972buggygetaddrinfo=yes)], [
2973AC_MSG_RESULT(no)
2974buggygetaddrinfo=yes
2975])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002976
2977if test "$buggygetaddrinfo" = "yes"; then
2978 if test "$ipv6" = "yes"; then
2979 echo 'Fatal: You must get working getaddrinfo() function.'
2980 echo ' or you can specify "--disable-ipv6"'.
2981 exit 1
2982 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002983else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002984 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002985fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00002986AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002987
Guido van Rossum627b2d71993-12-24 10:39:16 +00002988# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002989AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00002990AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002991AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00002992AC_CHECK_MEMBERS([struct stat.st_rdev])
2993AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00002994AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00002995AC_CHECK_MEMBERS([struct stat.st_gen])
2996AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00002997AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002998
2999AC_MSG_CHECKING(for time.h that defines altzone)
3000AC_CACHE_VAL(ac_cv_header_time_altzone,
3001[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
3002 ac_cv_header_time_altzone=yes,
3003 ac_cv_header_time_altzone=no)])
3004AC_MSG_RESULT($ac_cv_header_time_altzone)
3005if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003006 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003007fi
3008
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003009was_it_defined=no
3010AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003011AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003012#include <sys/types.h>
3013#include <sys/select.h>
3014#include <sys/time.h>
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003015], [;], [
3016 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3017 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3018 (which you can't on SCO ODT 3.0).])
3019 was_it_defined=yes
3020])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003021AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003022
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003023AC_MSG_CHECKING(for addrinfo)
3024AC_CACHE_VAL(ac_cv_struct_addrinfo,
3025AC_TRY_COMPILE([
3026# include <netdb.h>],
3027 [struct addrinfo a],
3028 ac_cv_struct_addrinfo=yes,
3029 ac_cv_struct_addrinfo=no))
3030AC_MSG_RESULT($ac_cv_struct_addrinfo)
3031if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003032 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003033fi
3034
3035AC_MSG_CHECKING(for sockaddr_storage)
3036AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
3037AC_TRY_COMPILE([
3038# include <sys/types.h>
3039# include <sys/socket.h>],
3040 [struct sockaddr_storage s],
3041 ac_cv_struct_sockaddr_storage=yes,
3042 ac_cv_struct_sockaddr_storage=no))
3043AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3044if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003045 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003046fi
3047
Guido van Rossum627b2d71993-12-24 10:39:16 +00003048# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003049
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003050AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003051AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003052
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003053works=no
3054AC_MSG_CHECKING(for working volatile)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003055AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
3056 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
3057)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003058AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003059
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003060works=no
3061AC_MSG_CHECKING(for working signed char)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003062AC_TRY_COMPILE([], [signed char c;], works=yes,
3063 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
3064)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003065AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003066
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003067have_prototypes=no
3068AC_MSG_CHECKING(for prototypes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003069AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
3070 AC_DEFINE(HAVE_PROTOTYPES, 1,
3071 [Define if your compiler supports function prototype])
3072 have_prototypes=yes
3073])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003074AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003075
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003076works=no
3077AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003078AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003079#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003080int foo(int x, ...) {
3081 va_list va;
3082 va_start(va, x);
3083 va_arg(va, int);
3084 va_arg(va, char *);
3085 va_arg(va, double);
3086 return 0;
3087}
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003088], [return foo(10, "", 3.14);], [
3089 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3090 [Define if your compiler supports variable length function prototypes
3091 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3092 works=yes
3093])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003094AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003095
Dave Cole331708b2004-08-09 04:51:41 +00003096# check for socketpair
3097AC_MSG_CHECKING(for socketpair)
3098AC_TRY_COMPILE([
3099#include <sys/types.h>
3100#include <sys/socket.h>
3101], void *x=socketpair,
3102 AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
3103 AC_MSG_RESULT(yes),
3104 AC_MSG_RESULT(no)
3105)
3106
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003107# check if sockaddr has sa_len member
3108AC_MSG_CHECKING(if sockaddr has sa_len member)
3109AC_TRY_COMPILE([#include <sys/types.h>
3110#include <sys/socket.h>],
3111[struct sockaddr x;
3112x.sa_len = 0;],
3113 AC_MSG_RESULT(yes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003114 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003115 AC_MSG_RESULT(no))
3116
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003117va_list_is_array=no
3118AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003119AC_TRY_COMPILE([
3120#ifdef HAVE_STDARG_PROTOTYPES
3121#include <stdarg.h>
3122#else
3123#include <varargs.h>
3124#endif
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003125], [va_list list1, list2; list1 = list2;], , [
3126 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3127 va_list_is_array=yes
3128])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003129AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003130
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003131# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003132AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3133 [Define this if you have some version of gethostbyname_r()])
3134
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003135AC_CHECK_FUNC(gethostbyname_r, [
3136 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3137 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3138 OLD_CFLAGS=$CFLAGS
3139 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3140 AC_TRY_COMPILE([
3141# include <netdb.h>
3142 ], [
3143 char *name;
3144 struct hostent *he, *res;
3145 char buffer[2048];
3146 int buflen = 2048;
3147 int h_errnop;
3148
3149 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3150 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003151 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003152 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3153 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003154 AC_MSG_RESULT(yes)
3155 ], [
3156 AC_MSG_RESULT(no)
3157 AC_MSG_CHECKING([gethostbyname_r with 5 args])
3158 AC_TRY_COMPILE([
3159# include <netdb.h>
3160 ], [
3161 char *name;
3162 struct hostent *he;
3163 char buffer[2048];
3164 int buflen = 2048;
3165 int h_errnop;
3166
3167 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3168 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003169 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003170 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3171 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003172 AC_MSG_RESULT(yes)
3173 ], [
3174 AC_MSG_RESULT(no)
3175 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3176 AC_TRY_COMPILE([
3177# include <netdb.h>
3178 ], [
3179 char *name;
3180 struct hostent *he;
3181 struct hostent_data data;
3182
3183 (void) gethostbyname_r(name, he, &data);
3184 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003185 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003186 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3187 [Define this if you have the 3-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003188 AC_MSG_RESULT(yes)
3189 ], [
3190 AC_MSG_RESULT(no)
3191 ])
3192 ])
3193 ])
3194 CFLAGS=$OLD_CFLAGS
3195], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003196 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003197])
3198AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3199AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3200AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003201AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003202AC_SUBST(HAVE_GETHOSTBYNAME)
3203
Guido van Rossum627b2d71993-12-24 10:39:16 +00003204# checks for system services
3205# (none yet)
3206
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003207# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003208AC_CHECK_FUNC(__fpu_control,
3209 [],
3210 [AC_CHECK_LIB(ieee, __fpu_control)
3211])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003212
Guido van Rossum93274221997-05-09 02:42:00 +00003213# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003214AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003215AC_ARG_WITH(fpectl,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003216 AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
3217[
Guido van Rossum93274221997-05-09 02:42:00 +00003218if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003219then
3220 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3221 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3222 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003223else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003224fi],
3225[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003226
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003227# check for --with-libm=...
3228AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003229case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003230Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003231BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003232*) LIBM=-lm
3233esac
Guido van Rossum93274221997-05-09 02:42:00 +00003234AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003235AC_ARG_WITH(libm,
3236 AC_HELP_STRING(--with-libm=STRING, math library),
3237[
Guido van Rossum93274221997-05-09 02:42:00 +00003238if test "$withval" = no
3239then LIBM=
3240 AC_MSG_RESULT(force LIBM empty)
3241elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003242then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003243 AC_MSG_RESULT(set LIBM="$withval")
3244else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003245fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003246[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003247
3248# check for --with-libc=...
3249AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003250AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003251AC_ARG_WITH(libc,
3252 AC_HELP_STRING(--with-libc=STRING, C library),
3253[
Guido van Rossum93274221997-05-09 02:42:00 +00003254if test "$withval" = no
3255then LIBC=
3256 AC_MSG_RESULT(force LIBC empty)
3257elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003258then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003259 AC_MSG_RESULT(set LIBC="$withval")
3260else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003261fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003262[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003263
Christian Heimes0a8143f2007-12-18 23:22:54 +00003264# ************************************
3265# * Check for mathematical functions *
3266# ************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003267
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003268LIBS_SAVE=$LIBS
3269LIBS="$LIBS $LIBM"
3270
Mark Dickinsone05e8402009-05-04 13:30:43 +00003271# Detect whether system arithmetic is subject to x87-style double
3272# rounding issues. The result of this test has little meaning on non
3273# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3274# mode is round-to-nearest and double rounding issues are present, and
3275# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3276AC_MSG_CHECKING(for x87-style double rounding)
3277AC_CACHE_VAL(ac_cv_x87_double_rounding, [
3278AC_TRY_RUN([
3279#include <stdlib.h>
3280#include <math.h>
3281int main() {
3282 volatile double x, y, z;
3283 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3284 x = 0.99999999999999989; /* 1-2**-53 */
3285 y = 1./x;
3286 if (y != 1.)
3287 exit(0);
3288 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3289 x = 1e16;
3290 y = 2.99999;
3291 z = x + y;
3292 if (z != 1e16+4.)
3293 exit(0);
3294 /* both tests show evidence of double rounding */
3295 exit(1);
3296}
3297],
3298ac_cv_x87_double_rounding=no,
3299ac_cv_x87_double_rounding=yes,
3300ac_cv_x87_double_rounding=no)])
3301AC_MSG_RESULT($ac_cv_x87_double_rounding)
3302if test "$ac_cv_x87_double_rounding" = yes
3303then
3304 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3305 [Define if arithmetic is subject to x87-style double rounding issue])
3306fi
3307
3308
Mark Dickinson265d7382008-04-21 22:32:24 +00003309# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3310# -0. on some architectures.
3311AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3312AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3313AC_TRY_RUN([
3314#include <math.h>
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003315#include <stdlib.h>
Mark Dickinson265d7382008-04-21 22:32:24 +00003316int main() {
3317 /* return 0 if either negative zeros don't exist
3318 on this platform or if negative zeros exist
3319 and tanh(-0.) == -0. */
3320 if (atan2(0., -1.) == atan2(-0., -1.) ||
3321 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3322 else exit(1);
3323}
3324],
3325ac_cv_tanh_preserves_zero_sign=yes,
3326ac_cv_tanh_preserves_zero_sign=no,
3327ac_cv_tanh_preserves_zero_sign=no)])
3328AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3329if test "$ac_cv_tanh_preserves_zero_sign" = yes
3330then
3331 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3332 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3333fi
3334
Mark Dickinsone05e8402009-05-04 13:30:43 +00003335AC_CHECK_FUNCS([acosh asinh atanh copysign expm1 finite hypot log1p])
3336AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
Christian Heimes0a8143f2007-12-18 23:22:54 +00003337
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003338LIBS=$LIBS_SAVE
3339
Guido van Rossumef2255b2000-03-10 22:30:29 +00003340# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003341AC_CHECK_HEADER(wchar.h, [
3342 AC_DEFINE(HAVE_WCHAR_H, 1,
3343 [Define if the compiler provides a wchar.h header file.])
3344 wchar_h="yes"
3345],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003346wchar_h="no"
3347)
3348
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003349# determine wchar_t size
3350if test "$wchar_h" = yes
3351then
Guido van Rossum67b26592001-10-20 14:21:45 +00003352 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003353fi
3354
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003355AC_MSG_CHECKING(for UCS-4 tcl)
3356have_ucs4_tcl=no
3357AC_TRY_COMPILE([
3358#include <tcl.h>
3359#if TCL_UTF_MAX != 6
3360# error "NOT UCS4_TCL"
3361#endif], [], [
3362 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3363 have_ucs4_tcl=yes
3364])
3365AC_MSG_RESULT($have_ucs4_tcl)
3366
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003367# check whether wchar_t is signed or not
3368if test "$wchar_h" = yes
3369then
3370 # check whether wchar_t is signed or not
3371 AC_MSG_CHECKING(whether wchar_t is signed)
3372 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3373 AC_TRY_RUN([
3374 #include <wchar.h>
3375 int main()
3376 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00003377 /* Success: exit code 0 */
3378 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003379 }
3380 ],
3381 ac_cv_wchar_t_signed=yes,
3382 ac_cv_wchar_t_signed=no,
3383 ac_cv_wchar_t_signed=yes)])
3384 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3385fi
3386
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003387AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003388dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003389AC_ARG_ENABLE(unicode,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003390 AC_HELP_STRING(--enable-unicode@<:@=ucs@<:@24@:>@@:>@, Enable Unicode strings (default is yes)),
3391 [],
3392 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003393
3394if test $enable_unicode = yes
3395then
Martin v. Löwisfd917792001-06-27 20:22:04 +00003396 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003397 case "$have_ucs4_tcl" in
3398 yes) enable_unicode="ucs4"
3399 ;;
3400 *) enable_unicode="ucs2"
3401 ;;
3402 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003403fi
3404
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003405AH_TEMPLATE(Py_UNICODE_SIZE,
3406 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003407case "$enable_unicode" in
3408ucs2) unicode_size="2"
3409 AC_DEFINE(Py_UNICODE_SIZE,2)
3410 ;;
3411ucs4) unicode_size="4"
3412 AC_DEFINE(Py_UNICODE_SIZE,4)
3413 ;;
3414esac
3415
Martin v. Löwis11437992002-04-12 09:54:03 +00003416AH_TEMPLATE(PY_UNICODE_TYPE,
3417 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003418
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003419AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003420if test "$enable_unicode" = "no"
3421then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003422 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003423 AC_MSG_RESULT(not used)
3424else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003425 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003426 AC_DEFINE(Py_USING_UNICODE, 1,
3427 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003428
3429 # wchar_t is only usable if it maps to an unsigned type
3430 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003431 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003432 then
3433 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003434 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3435 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003436 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003437 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003438 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3439 elif test "$ac_cv_sizeof_short" = "$unicode_size"
3440 then
3441 PY_UNICODE_TYPE="unsigned short"
3442 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3443 elif test "$ac_cv_sizeof_long" = "$unicode_size"
3444 then
3445 PY_UNICODE_TYPE="unsigned long"
3446 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3447 else
3448 PY_UNICODE_TYPE="no type found"
3449 fi
3450 AC_MSG_RESULT($PY_UNICODE_TYPE)
3451fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00003452
3453# check for endianness
3454AC_C_BIGENDIAN
3455
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003456# Check whether right shifting a negative integer extends the sign bit
3457# or fills with zeros (like the Cray J90, according to Tim Peters).
3458AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003459AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003460AC_TRY_RUN([
3461int main()
3462{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003463 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003464}
Guido van Rossum3065c942001-09-17 04:03:14 +00003465],
3466ac_cv_rshift_extends_sign=yes,
3467ac_cv_rshift_extends_sign=no,
3468ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003469AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3470if test "$ac_cv_rshift_extends_sign" = no
3471then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003472 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3473 [Define if i>>j for signed int i does not extend the sign bit
3474 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003475fi
3476
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003477# check for getc_unlocked and related locking functions
3478AC_MSG_CHECKING(for getc_unlocked() and friends)
3479AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3480AC_TRY_LINK([#include <stdio.h>],[
3481 FILE *f = fopen("/dev/null", "r");
3482 flockfile(f);
3483 getc_unlocked(f);
3484 funlockfile(f);
3485], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3486AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3487if test "$ac_cv_have_getc_unlocked" = yes
3488then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003489 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3490 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003491fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003492
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003493# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003494# save the value of LIBS so we don't actually link Python with readline
3495LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00003496
3497# On some systems we need to link readline to a termcap compatible
3498# library. NOTE: Keep the precedence of listed libraries synchronised
3499# with setup.py.
3500py_cv_lib_readline=no
3501AC_MSG_CHECKING([how to link readline libs])
3502for py_libtermcap in "" ncursesw ncurses curses termcap; do
3503 if test -z "$py_libtermcap"; then
3504 READLINE_LIBS="-lreadline"
3505 else
3506 READLINE_LIBS="-lreadline -l$py_libtermcap"
3507 fi
3508 LIBS="$READLINE_LIBS $LIBS_no_readline"
3509 AC_LINK_IFELSE(
3510 [AC_LANG_CALL([],[readline])],
3511 [py_cv_lib_readline=yes])
3512 if test $py_cv_lib_readline = yes; then
3513 break
3514 fi
3515done
3516# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3517#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00003518if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00003519 AC_MSG_RESULT([none])
3520else
3521 AC_MSG_RESULT([$READLINE_LIBS])
3522 AC_DEFINE(HAVE_LIBREADLINE, 1,
3523 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003524fi
3525
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003526# check for readline 2.1
3527AC_CHECK_LIB(readline, rl_callback_handler_install,
3528 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003529 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003530
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003531# check for readline 2.2
3532AC_TRY_CPP([#include <readline/readline.h>],
3533have_readline=yes, have_readline=no)
3534if test $have_readline = yes
3535then
3536 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3537 [readline/readline.h],
3538 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3539 [Define if you have readline 2.2]), )
Antoine Pitrou632e93f2009-10-27 12:30:12 +00003540 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3541 [readline/readline.h],
3542 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3543 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003544fi
3545
Martin v. Löwis0daad592001-09-30 21:09:59 +00003546# check for readline 4.0
3547AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003548 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003549 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003550
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00003551# also in 4.0
3552AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3553 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003554 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00003555
Guido van Rossum353ae582001-07-10 16:45:32 +00003556# check for readline 4.2
3557AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003558 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003559 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003560
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003561# also in readline 4.2
3562AC_TRY_CPP([#include <readline/readline.h>],
3563have_readline=yes, have_readline=no)
3564if test $have_readline = yes
3565then
3566 AC_EGREP_HEADER([extern int rl_catch_signals;],
3567 [readline/readline.h],
3568 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3569 [Define if you can turn off readline's signal handling.]), )
3570fi
3571
Martin v. Löwis82bca632006-02-10 20:49:30 +00003572# End of readline checks: restore LIBS
3573LIBS=$LIBS_no_readline
3574
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003575AC_MSG_CHECKING(for broken nice())
3576AC_CACHE_VAL(ac_cv_broken_nice, [
3577AC_TRY_RUN([
3578int main()
3579{
3580 int val1 = nice(1);
3581 if (val1 != -1 && val1 == nice(2))
3582 exit(0);
3583 exit(1);
3584}
Guido van Rossum3065c942001-09-17 04:03:14 +00003585],
3586ac_cv_broken_nice=yes,
3587ac_cv_broken_nice=no,
3588ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003589AC_MSG_RESULT($ac_cv_broken_nice)
3590if test "$ac_cv_broken_nice" = yes
3591then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003592 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3593 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003594fi
3595
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003596AC_MSG_CHECKING(for broken poll())
3597AC_TRY_RUN([
3598#include <poll.h>
3599
3600int main (void)
3601 {
3602 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
3603
3604 close (42);
3605
3606 int poll_test = poll (&poll_struct, 1, 0);
3607
3608 if (poll_test < 0)
3609 {
3610 exit(0);
3611 }
3612 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
3613 {
3614 exit(0);
3615 }
3616 else
3617 {
3618 exit(1);
3619 }
3620 }
3621],
3622ac_cv_broken_poll=yes,
3623ac_cv_broken_poll=no,
3624ac_cv_broken_poll=no)
3625AC_MSG_RESULT($ac_cv_broken_poll)
3626if test "$ac_cv_broken_poll" = yes
3627then
3628 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3629 [Define if poll() sets errno on invalid file descriptors.])
3630fi
3631
Brett Cannon43802422005-02-10 20:48:03 +00003632# Before we can test tzset, we need to check if struct tm has a tm_zone
3633# (which is not required by ISO C or UNIX spec) and/or if we support
3634# tzname[]
3635AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003636
Brett Cannon43802422005-02-10 20:48:03 +00003637# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003638AC_MSG_CHECKING(for working tzset())
3639AC_CACHE_VAL(ac_cv_working_tzset, [
3640AC_TRY_RUN([
3641#include <stdlib.h>
3642#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003643#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003644
3645#if HAVE_TZNAME
3646extern char *tzname[];
3647#endif
3648
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003649int main()
3650{
Brett Cannon18367812003-09-19 00:59:16 +00003651 /* Note that we need to ensure that not only does tzset(3)
3652 do 'something' with localtime, but it works as documented
3653 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003654 This includes making sure that tzname is set properly if
3655 tm->tm_zone does not exist since it is the alternative way
3656 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003657
3658 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003659 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003660 */
3661
Brett Cannon43802422005-02-10 20:48:03 +00003662 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003663 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3664
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003665 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003666 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003667 if (localtime(&groundhogday)->tm_hour != 0)
3668 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003669#if HAVE_TZNAME
3670 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3671 if (strcmp(tzname[0], "UTC") ||
3672 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3673 exit(1);
3674#endif
Brett Cannon18367812003-09-19 00:59:16 +00003675
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003676 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003677 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003678 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003679 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003680#if HAVE_TZNAME
3681 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3682 exit(1);
3683#endif
Brett Cannon18367812003-09-19 00:59:16 +00003684
3685 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3686 tzset();
3687 if (localtime(&groundhogday)->tm_hour != 11)
3688 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003689#if HAVE_TZNAME
3690 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3691 exit(1);
3692#endif
3693
3694#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00003695 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3696 exit(1);
3697 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3698 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003699#endif
Brett Cannon18367812003-09-19 00:59:16 +00003700
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003701 exit(0);
3702}
3703],
3704ac_cv_working_tzset=yes,
3705ac_cv_working_tzset=no,
3706ac_cv_working_tzset=no)])
3707AC_MSG_RESULT($ac_cv_working_tzset)
3708if test "$ac_cv_working_tzset" = yes
3709then
3710 AC_DEFINE(HAVE_WORKING_TZSET, 1,
3711 [Define if tzset() actually switches the local timezone in a meaningful way.])
3712fi
3713
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003714# Look for subsecond timestamps in struct stat
3715AC_MSG_CHECKING(for tv_nsec in struct stat)
3716AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3717AC_TRY_COMPILE([#include <sys/stat.h>], [
3718struct stat st;
3719st.st_mtim.tv_nsec = 1;
3720],
Martin v. Löwisa32c9942002-09-09 16:17:47 +00003721ac_cv_stat_tv_nsec=yes,
Martin v. Löwis94717ed2002-09-09 14:24:16 +00003722ac_cv_stat_tv_nsec=no,
3723ac_cv_stat_tv_nsec=no))
3724AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3725if test "$ac_cv_stat_tv_nsec" = yes
3726then
3727 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3728 [Define if you have struct stat.st_mtim.tv_nsec])
3729fi
3730
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003731# Look for BSD style subsecond timestamps in struct stat
3732AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3733AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3734AC_TRY_COMPILE([#include <sys/stat.h>], [
3735struct stat st;
3736st.st_mtimespec.tv_nsec = 1;
3737],
3738ac_cv_stat_tv_nsec2=yes,
3739ac_cv_stat_tv_nsec2=no,
3740ac_cv_stat_tv_nsec2=no))
3741AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3742if test "$ac_cv_stat_tv_nsec2" = yes
3743then
3744 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3745 [Define if you have struct stat.st_mtimensec])
3746fi
3747
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003748# On HP/UX 11.0, mvwdelch is a block with a return statement
3749AC_MSG_CHECKING(whether mvwdelch is an expression)
3750AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3751AC_TRY_COMPILE([#include <curses.h>], [
3752 int rtn;
3753 rtn = mvwdelch(0,0,0);
3754], ac_cv_mvwdelch_is_expression=yes,
3755 ac_cv_mvwdelch_is_expression=no,
3756 ac_cv_mvwdelch_is_expression=yes))
3757AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3758
3759if test "$ac_cv_mvwdelch_is_expression" = yes
3760then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003761 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3762 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003763fi
3764
3765AC_MSG_CHECKING(whether WINDOW has _flags)
3766AC_CACHE_VAL(ac_cv_window_has_flags,
3767AC_TRY_COMPILE([#include <curses.h>], [
3768 WINDOW *w;
3769 w->_flags = 0;
3770], ac_cv_window_has_flags=yes,
3771 ac_cv_window_has_flags=no,
3772 ac_cv_window_has_flags=no))
3773AC_MSG_RESULT($ac_cv_window_has_flags)
3774
3775
3776if test "$ac_cv_window_has_flags" = yes
3777then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003778 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
3779 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00003780fi
3781
Walter Dörwald4994d952006-06-19 08:07:50 +00003782AC_MSG_CHECKING(for is_term_resized)
3783AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
3784 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
3785 AC_MSG_RESULT(yes),
3786 AC_MSG_RESULT(no)
3787)
3788
Walter Dörwald05fdbf12006-06-19 08:14:09 +00003789AC_MSG_CHECKING(for resize_term)
3790AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
3791 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
Walter Dörwald4994d952006-06-19 08:07:50 +00003792 AC_MSG_RESULT(yes),
3793 AC_MSG_RESULT(no)
3794)
3795
Walter Dörwald05fdbf12006-06-19 08:14:09 +00003796AC_MSG_CHECKING(for resizeterm)
3797AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
3798 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
Walter Dörwald4994d952006-06-19 08:07:50 +00003799 AC_MSG_RESULT(yes),
3800 AC_MSG_RESULT(no)
3801)
3802
Martin v. Löwisfefbc202006-10-17 18:59:23 +00003803AC_MSG_CHECKING(for /dev/ptmx)
3804
3805if test -r /dev/ptmx
3806then
3807 AC_MSG_RESULT(yes)
3808 AC_DEFINE(HAVE_DEV_PTMX, 1,
3809 [Define if we have /dev/ptmx.])
3810else
3811 AC_MSG_RESULT(no)
3812fi
3813
3814AC_MSG_CHECKING(for /dev/ptc)
3815
3816if test -r /dev/ptc
3817then
3818 AC_MSG_RESULT(yes)
3819 AC_DEFINE(HAVE_DEV_PTC, 1,
3820 [Define if we have /dev/ptc.])
3821else
3822 AC_MSG_RESULT(no)
3823fi
Neal Norwitz865400f2003-03-21 01:42:58 +00003824
Brett Cannon09d12362006-05-11 05:11:33 +00003825AC_MSG_CHECKING(for %zd printf() format support)
3826AC_TRY_RUN([#include <stdio.h>
3827#include <stddef.h>
3828#include <string.h>
3829
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00003830#ifdef HAVE_SYS_TYPES_H
3831#include <sys/types.h>
3832#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00003833
3834#ifdef HAVE_SSIZE_T
3835typedef ssize_t Py_ssize_t;
3836#elif SIZEOF_VOID_P == SIZEOF_LONG
3837typedef long Py_ssize_t;
3838#else
3839typedef int Py_ssize_t;
3840#endif
Brett Cannon09d12362006-05-11 05:11:33 +00003841
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00003842int main()
3843{
3844 char buffer[256];
3845
Brett Cannon09d12362006-05-11 05:11:33 +00003846 if(sprintf(buffer, "%zd", (size_t)123) < 0)
3847 return 1;
3848
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00003849 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00003850 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00003851
3852 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
3853 return 1;
3854
3855 if (strcmp(buffer, "-123"))
3856 return 1;
3857
Brett Cannon09d12362006-05-11 05:11:33 +00003858 return 0;
3859}],
3860[AC_MSG_RESULT(yes)
3861 AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
3862 AC_MSG_RESULT(no))
3863
Martin v. Löwis01c04012002-11-11 14:58:44 +00003864AC_CHECK_TYPE(socklen_t,,
3865 AC_DEFINE(socklen_t,int,
3866 Define to `int' if <sys/socket.h> does not define.),[
3867#ifdef HAVE_SYS_TYPES_H
3868#include <sys/types.h>
3869#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00003870#ifdef HAVE_SYS_SOCKET_H
3871#include <sys/socket.h>
3872#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00003873])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003874
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00003875AC_SUBST(THREADHEADERS)
3876
3877for h in `(cd $srcdir;echo Python/thread_*.h)`
3878do
3879 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
3880done
3881
Ronald Oussoren55114422009-11-19 16:37:33 +00003882if test $ac_sys_system = Darwin
3883then
3884 LIBS="$LIBS -framework CoreFoundation"
3885fi
3886
3887
3888
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003889AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00003890SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00003891AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003892for dir in $SRCDIRS; do
3893 if test ! -d $dir; then
3894 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00003895 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00003896done
3897AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00003898
Guido van Rossum627b2d71993-12-24 10:39:16 +00003899# generate output files
Martin v. Löwis88afe662002-10-26 13:47:44 +00003900AC_CONFIG_FILES(Makefile.pre Modules/Setup.config)
3901AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00003902
Martin v. Löwisf7afe952006-04-14 15:16:15 +00003903echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00003904if test ! -f Modules/Setup
3905then
3906 cp $srcdir/Modules/Setup.dist Modules/Setup
3907fi
3908
Martin v. Löwisf7afe952006-04-14 15:16:15 +00003909echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00003910if test ! -f Modules/Setup.local
3911then
3912 echo "# Edit this file for local setup changes" >Modules/Setup.local
3913fi
3914
3915echo "creating Makefile"
3916$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
3917 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00003918 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00003919
3920case $ac_sys_system in
3921BeOS)
3922 AC_MSG_WARN([
3923
3924 Support for BeOS is deprecated as of Python 2.6.
3925 See PEP 11 for the gory details.
3926 ])
3927 ;;
3928*) ;;
3929esac
3930
Neil Schemenauer66252162001-02-19 04:47:42 +00003931mv config.c Modules