blob: d7399ebc61e75921cf6c00038dc021a25ba28beb [file] [log] [blame]
Benjamin Petersond7c77842008-05-26 13:01:25 +00001dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
Martin v. Löwis88afe662002-10-26 13:47:44 +00004
5# Set VERSION so we only need to edit in one place (i.e., here)
Martin v. Löwis174440b2008-10-03 08:59:41 +00006m4_define(PYTHON_VERSION, 2.7)
Martin v. Löwis88afe662002-10-26 13:47:44 +00007
Georg Brandl71f4fbb2011-02-25 11:04:50 +00008AC_PREREQ(2.65)
Alexandre Vassalotti130ae152009-07-18 00:31:06 +00009
Guido van Rossum76be6ed1995-01-02 18:33:54 +000010AC_REVISION($Revision$)
Georg Brandl464432d2009-05-20 18:24:08 +000011AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
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
Georg Brandlbcd64a32009-03-31 21:45:18 +000015dnl Ensure that if prefix is specified, it does not end in a slash. If
16dnl it does, we get path names containing '//' which is both ugly and
17dnl can cause trouble.
18
19dnl Last slash shouldn't be stripped if prefix=/
20if test "$prefix" != "/"; then
21 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
22fi
23
Martin v. Löwis8316feb2003-06-14 07:48:07 +000024dnl This is for stuff that absolutely must end up in pyconfig.h.
25dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000026AH_TOP([
27#ifndef Py_PYCONFIG_H
28#define Py_PYCONFIG_H
29])
Martin v. Löwis11437992002-04-12 09:54:03 +000030AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000031/* Define the macros needed if on a UnixWare 7.x system. */
32#if defined(__USLC__) && defined(__SCO_VERSION__)
33#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
34#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000035
36#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000037])
38
Martin v. Löwis8316feb2003-06-14 07:48:07 +000039# We don't use PACKAGE_ variables, and they cause conflicts
40# with other autoconf-based packages that include Python.h
41grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
42rm confdefs.h
43mv confdefs.h.new confdefs.h
44
Guido van Rossum642b6781997-07-19 19:35:41 +000045AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000046VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000047
Martin v. Löwis1142de32002-03-29 16:28:31 +000048AC_SUBST(SOVERSION)
49SOVERSION=1.0
50
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000051# The later defininition of _XOPEN_SOURCE disables certain features
52# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
53AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
54
Martin v. Löwisbcd93962003-05-03 10:32:18 +000055# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
56# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
57# them.
58AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
59
Andrew MacIntyreabccf412003-07-02 13:53:25 +000060# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
61# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
62# them.
63AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
64
Martin v. Löwisd6320502004-08-12 13:45:08 +000065# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
66# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
67AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
68
Ronald Oussoren5640ce22008-06-05 12:58:24 +000069# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
70# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
71# them.
72AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
73
74
Martin v. Löwise981a4e2002-11-11 13:26:51 +000075define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000076
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +000077# Arguments passed to configure.
78AC_SUBST(CONFIG_ARGS)
79CONFIG_ARGS="$ac_configure_args"
80
Ronald Oussoren3c0a1262010-01-17 19:27:57 +000081AC_MSG_CHECKING([for --enable-universalsdk])
Ronald Oussoren988117f2006-04-29 11:31:35 +000082AC_ARG_ENABLE(universalsdk,
Matthias Klose22520ea2010-05-08 10:14:46 +000083 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
Ronald Oussoren988117f2006-04-29 11:31:35 +000084[
85 case $enableval in
86 yes)
87 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren3c0a1262010-01-17 19:27:57 +000088 if test ! -d "${enableval}"
89 then
90 enableval=/
91 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +000092 ;;
93 esac
94 case $enableval in
95 no)
96 UNIVERSALSDK=
97 enable_universalsdk=
98 ;;
99 *)
100 UNIVERSALSDK=$enableval
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000101 if test ! -d "${UNIVERSALSDK}"
102 then
103 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
104 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000105 ;;
106 esac
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000107
Ronald Oussoren988117f2006-04-29 11:31:35 +0000108],[
109 UNIVERSALSDK=
110 enable_universalsdk=
111])
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000112if test -n "${UNIVERSALSDK}"
113then
114 AC_MSG_RESULT(${UNIVERSALSDK})
115else
116 AC_MSG_RESULT(no)
117fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000118AC_SUBST(UNIVERSALSDK)
119
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000120AC_SUBST(ARCH_RUN_32BIT)
121
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000122UNIVERSAL_ARCHS="32-bit"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000123AC_SUBST(LIPO_32BIT_FLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000124AC_MSG_CHECKING(for --with-universal-archs)
125AC_ARG_WITH(universal-archs,
Matthias Klose22520ea2010-05-08 10:14:46 +0000126 AS_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 +0000127[
128 AC_MSG_RESULT($withval)
129 UNIVERSAL_ARCHS="$withval"
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000130 if test "${enable_universalsdk}" ; then
131 :
132 else
133 AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
134 fi
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000135],
136[
137 AC_MSG_RESULT(32-bit)
138])
139
140
141
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000142AC_ARG_WITH(framework-name,
Matthias Klose22520ea2010-05-08 10:14:46 +0000143 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
Matthias Klose5183ebd2010-04-24 16:38:36 +0000144 [specify an alternate name of the framework built with --enable-framework]),
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000145[
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000146 if test "${enable_framework}"; then
147 :
148 else
149 AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
150 fi
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000151 PYTHONFRAMEWORK=${withval}
152 PYTHONFRAMEWORKDIR=${withval}.framework
153 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
154 ],[
155 PYTHONFRAMEWORK=Python
156 PYTHONFRAMEWORKDIR=Python.framework
157 PYTHONFRAMEWORKIDENTIFIER=org.python.python
158])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000159dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000160AC_ARG_ENABLE(framework,
Matthias Klose22520ea2010-05-08 10:14:46 +0000161 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000162[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000163 case $enableval in
164 yes)
165 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000166 esac
167 case $enableval in
168 no)
169 PYTHONFRAMEWORK=
170 PYTHONFRAMEWORKDIR=no-framework
171 PYTHONFRAMEWORKPREFIX=
172 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000173 FRAMEWORKINSTALLFIRST=
174 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000175 FRAMEWORKALTINSTALLFIRST=
176 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000177 if test "x${prefix}" = "xNONE"; then
178 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
179 else
180 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
181 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000182 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000183 ;;
184 *)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000185 PYTHONFRAMEWORKPREFIX="${enableval}"
Jack Jansen127e56e2001-09-11 14:41:54 +0000186 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000187 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000188 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000189 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
190 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000191 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000192
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000193 if test "x${prefix}" = "xNONE" ; then
194 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000195
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000196 else
197 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
198 fi
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000199
200 case "${enableval}" in
201 /System*)
202 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
203 if test "${prefix}" = "NONE" ; then
204 # See below
205 FRAMEWORKUNIXTOOLSPREFIX="/usr"
206 fi
207 ;;
208
209 /Library*)
210 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
211 ;;
212
213 */Library/Frameworks)
214 MDIR="`dirname "${enableval}"`"
215 MDIR="`dirname "${MDIR}"`"
216 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
217
218 if test "${prefix}" = "NONE"; then
219 # User hasn't specified the
220 # --prefix option, but wants to install
221 # the framework in a non-default location,
222 # ensure that the compatibility links get
223 # installed relative to that prefix as well
224 # instead of in /usr/local.
225 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
226 fi
227 ;;
228
229 *)
230 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
231 ;;
232 esac
233
Jack Jansen127e56e2001-09-11 14:41:54 +0000234 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Ronald Oussoren836b0392006-05-14 19:56:34 +0000235
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000236 # Add files for Mac specific code to the list of output
Ronald Oussoren836b0392006-05-14 19:56:34 +0000237 # files:
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000238 AC_CONFIG_FILES(Mac/Makefile)
239 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
240 AC_CONFIG_FILES(Mac/IDLE/Makefile)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000241 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
242 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000243 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000244 ],[
245 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000246 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000247 PYTHONFRAMEWORKPREFIX=
248 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000249 FRAMEWORKINSTALLFIRST=
250 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000251 FRAMEWORKALTINSTALLFIRST=
252 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000253 if test "x${prefix}" = "xNONE" ; then
254 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
255 else
256 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
257 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000258 enable_framework=
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000259
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000260])
261AC_SUBST(PYTHONFRAMEWORK)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000262AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000263AC_SUBST(PYTHONFRAMEWORKDIR)
264AC_SUBST(PYTHONFRAMEWORKPREFIX)
265AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000266AC_SUBST(FRAMEWORKINSTALLFIRST)
267AC_SUBST(FRAMEWORKINSTALLLAST)
Ronald Oussoren5b787322006-06-06 19:50:24 +0000268AC_SUBST(FRAMEWORKALTINSTALLFIRST)
269AC_SUBST(FRAMEWORKALTINSTALLLAST)
270AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000271AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000272
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000273##AC_ARG_WITH(dyld,
Matthias Klose22520ea2010-05-08 10:14:46 +0000274## AS_HELP_STRING([--with-dyld],
275## [Use (OpenStep|Rhapsody) dynamic linker]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000276##
Guido van Rossumb418f891996-07-30 18:06:02 +0000277# Set name for machine-dependent library files
278AC_SUBST(MACHDEP)
279AC_MSG_CHECKING(MACHDEP)
280if test -z "$MACHDEP"
281then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000282 ac_sys_system=`uname -s`
Georg Brandlfe18a112009-09-04 07:55:14 +0000283 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000284 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000285 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000286 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000287 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000288 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000289 ac_md_system=`echo $ac_sys_system |
290 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
291 ac_md_release=`echo $ac_sys_release |
Guido van Rossum67b26592001-10-20 14:21:45 +0000292 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +0000293 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000294
Guido van Rossumbcd91e01997-03-20 20:46:29 +0000295 case $MACHDEP in
Victor Stinneracacbaa2011-08-20 14:02:38 +0200296 linux*) MACHDEP="linux2";;
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000297 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000298 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000299 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000300 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000301 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000302 esac
303fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000304
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000305# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
306# disable features if it is defined, without any means to access these
307# features as extensions. For these systems, we skip the definition of
308# _XOPEN_SOURCE. Before adding a system to the list to gain access to
309# some feature, make sure there is no alternative way to access this
310# feature. Also, when using wildcards, make sure you have verified the
311# need for not defining _XOPEN_SOURCE on all systems matching the
312# wildcard, and that the wildcard does not include future systems
313# (which may remove their limitations).
314dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
315case $ac_sys_system/$ac_sys_release in
316 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
317 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000318 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis7875ef62010-02-15 21:41:12 +0000319 # In addition, Stefan Krah confirms that issue #1244610 exists through
320 # OpenBSD 4.6, but is fixed in 4.7.
Charles-François Natali97781b02011-07-22 23:43:42 +0200321 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@)
Martin v. Löwiscb78de62007-12-29 18:49:21 +0000322 define_xopen_source=no
323 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
324 # also defined. This can be overridden by defining _BSD_SOURCE
325 # As this has a different meaning on Linux, only define it on OpenBSD
326 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
327 ;;
Charles-François Natali97781b02011-07-22 23:43:42 +0200328 OpenBSD/*)
Martin v. Löwis5e2dd862010-02-15 08:32:00 +0000329 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
330 # also defined. This can be overridden by defining _BSD_SOURCE
331 # As this has a different meaning on Linux, only define it on OpenBSD
332 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
333 ;;
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000334 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
335 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
336 # Marc Recht
Georg Brandl4b9bcfc2008-11-16 08:00:17 +0000337 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 +0000338 define_xopen_source=no;;
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000339 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
340 # request to enable features supported by the standard as a request
341 # to disable features not supported by the standard. The best way
342 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
343 # entirely and define __EXTENSIONS__ instead.
344 SunOS/*)
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000345 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000346 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
347 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000348 # Reconfirmed for 7.1.4 by Martin v. Loewis.
349 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000350 define_xopen_source=no;;
351 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000352 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000353 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000354 define_xopen_source=no;;
Martin v. Löwisbb86d832008-11-04 20:40:09 +0000355 # On FreeBSD 4, the math functions C89 does not cover are never defined
356 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
357 FreeBSD/4.*)
358 define_xopen_source=no;;
359 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
360 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
361 # identifies itself as Darwin/7.*
362 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
363 # disables platform specific features beyond repair.
364 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
365 # has no effect, don't bother defining them
366 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000367 define_xopen_source=no;;
Ronald Oussorena55af9a2010-01-17 16:25:57 +0000368 Darwin/1@<:@0-9@:>@.*)
369 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000370 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
371 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
372 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000373 AIX/4)
374 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000375 AIX/5)
376 if test `uname -r` -eq 1; then
377 define_xopen_source=no
378 fi
379 ;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000380 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
381 # defining NI_NUMERICHOST.
382 QNX/6.3.2)
383 define_xopen_source=no
384 ;;
Martin v. Löwisa0588362006-04-04 06:03:50 +0000385
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000386esac
387
388if test $define_xopen_source = yes
389then
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000390 AC_DEFINE(_XOPEN_SOURCE, 600,
391 Define to the level of X/Open that your system supports)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000392
393 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
394 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
395 # several APIs are not declared. Since this is also needed in some
396 # cases for HP-UX, we define it globally.
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000397 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
398 Define to activate Unix95-and-earlier features)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000399
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000400 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
401
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000402fi
403
Guido van Rossum91922671997-10-09 20:24:13 +0000404#
405# SGI compilers allow the specification of the both the ABI and the
406# ISA on the command line. Depending on the values of these switches,
407# different and often incompatable code will be generated.
408#
409# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
410# thus supply support for various ABI/ISA combinations. The MACHDEP
411# variable is also adjusted.
412#
413AC_SUBST(SGI_ABI)
414if test ! -z "$SGI_ABI"
415then
416 CC="cc $SGI_ABI"
417 LDFLAGS="$SGI_ABI $LDFLAGS"
418 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
419fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000420AC_MSG_RESULT($MACHDEP)
421
Jack Jansen83f898c2002-12-30 22:23:40 +0000422# And add extra plat-mac for darwin
423AC_SUBST(EXTRAPLATDIR)
Jack Jansen7b59b422003-03-17 15:44:10 +0000424AC_SUBST(EXTRAMACHDEPPATH)
Jack Jansen83f898c2002-12-30 22:23:40 +0000425AC_MSG_CHECKING(EXTRAPLATDIR)
426if test -z "$EXTRAPLATDIR"
427then
428 case $MACHDEP in
Jack Jansen7b59b422003-03-17 15:44:10 +0000429 darwin)
430 EXTRAPLATDIR="\$(PLATMACDIRS)"
431 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
432 ;;
433 *)
434 EXTRAPLATDIR=""
435 EXTRAMACHDEPPATH=""
436 ;;
Jack Jansen83f898c2002-12-30 22:23:40 +0000437 esac
438fi
439AC_MSG_RESULT($EXTRAPLATDIR)
440
Jack Jansen6b08a402004-06-03 12:41:45 +0000441# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
442# it may influence the way we can build extensions, so distutils
443# needs to check it
444AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Ronald Oussoren988117f2006-04-29 11:31:35 +0000445AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000446CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Ronald Oussoren988117f2006-04-29 11:31:35 +0000447EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000448
Mark Dickinson65134662008-04-25 16:11:04 +0000449AC_MSG_CHECKING(machine type as reported by uname -m)
450ac_sys_machine=`uname -m`
451AC_MSG_RESULT($ac_sys_machine)
452
Guido van Rossum627b2d71993-12-24 10:39:16 +0000453# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000454
455# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
456# for debug/optimization stuff. BASECFLAGS is for flags that are required
457# just to get things to compile and link. Users are free to override OPT
458# when running configure or make. The build should not break if they do.
459# BASECFLAGS should generally not be messed with, however.
460
461# XXX shouldn't some/most/all of this code be merged with the stuff later
462# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000463AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000464AC_ARG_WITH(gcc,
Matthias Klose22520ea2010-05-08 10:14:46 +0000465 AS_HELP_STRING([--without-gcc], [never use gcc]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000466[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000467 case $withval in
Skip Montanaro516144f2009-01-04 10:36:58 +0000468 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000469 without_gcc=yes;;
470 yes) CC=gcc
471 without_gcc=no;;
472 *) CC=$withval
473 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000474 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000475 case $ac_sys_system in
Antoine Pitrou285cd162010-09-21 15:23:17 +0000476 AIX*) CC=${CC:-xlc_r}
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000477 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000478 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000479 case $BE_HOST_CPU in
480 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000481 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000482 without_gcc=yes
Skip Montanarodecc6a42003-01-01 20:07:49 +0000483 BASECFLAGS="$BASECFLAGS -export pragma"
484 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000485 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000486 ;;
487 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000488 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000489 without_gcc=no
Skip Montanarodecc6a42003-01-01 20:07:49 +0000490 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000491 ;;
492 *)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000493 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000494 ;;
495 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000496 AR="\$(srcdir)/Modules/ar_beos"
497 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000498 ;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000499 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000500 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000501AC_MSG_RESULT($without_gcc)
502
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000503# If the user switches compilers, we can't believe the cache
504if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
505then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000506 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
507(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000508fi
509
Trent Nelson15daa352012-12-13 06:46:39 +0000510if test "$MACHDEP" = "irix6" && test "$CC" != "gcc"; then
511 # Normally, MIPSpro CC treats #error directives as warnings, which means
512 # a successful exit code is returned (0). This is a problem because IRIX
513 # has a bunch of system headers with this guard at the top:
514 #
515 # #ifndef __c99
516 # #error This header file is to be used only for c99 mode compilations
517 # #else
518 #
519 # When autoconf tests for such a header, like stdint.h, this happens:
520 #
521 # configure:4619: cc -c conftest.c >&5
522 # cc-1035 cc: WARNING File = /usr/include/stdint.h, Line = 5
523 # #error directive: This header file is to be used only for c99 mode
524 # compilations
525 #
526 # #error This header file is to be used only for c99 mode compilations
527 # ^
528 #
529 # configure:4619: $? = 0
530 # configure:4619: result: yes
531 #
532 # Therefore, we use `-diag_error 1035` to have the compiler treat the
533 # warning as an error, which causes cc to return a non-zero result,
534 # which autoconf can interpret correctly.
535 CFLAGS="$CFLAGS -diag_error 1035"
536 # Whilst we're here, we might as well make sure CXX defaults to something
537 # sensible if we're not using gcc.
538 if test -z "$CXX"; then
539 CXX="CC"
540 fi
541fi
542
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000543# If the user set CFLAGS, use this instead of the automatically
544# determined setting
545preset_cflags="$CFLAGS"
Guido van Rossum627b2d71993-12-24 10:39:16 +0000546AC_PROG_CC
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000547if test ! -z "$preset_cflags"
548then
549 CFLAGS=$preset_cflags
550fi
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000551
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000552AC_SUBST(CXX)
553AC_SUBST(MAINCC)
554AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
555AC_ARG_WITH(cxx_main,
Matthias Klose22520ea2010-05-08 10:14:46 +0000556 AS_HELP_STRING([--with-cxx-main=<compiler>],
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000557 [compile main() and link python executable with C++ compiler]),
558[
559
560 case $withval in
561 no) with_cxx_main=no
562 MAINCC='$(CC)';;
563 yes) with_cxx_main=yes
564 MAINCC='$(CXX)';;
565 *) with_cxx_main=yes
566 MAINCC=$withval
567 if test -z "$CXX"
568 then
569 CXX=$withval
570 fi;;
571 esac], [
572 with_cxx_main=no
573 MAINCC='$(CC)'
574])
575AC_MSG_RESULT($with_cxx_main)
576
577preset_cxx="$CXX"
578if test -z "$CXX"
579then
580 case "$CC" in
581 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
582 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
583 esac
584 if test "$CXX" = "notfound"
585 then
586 CXX=""
587 fi
588fi
589if test -z "$CXX"
590then
591 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
592 if test "$CXX" = "notfound"
593 then
594 CXX=""
595 fi
596fi
597if test "$preset_cxx" != "$CXX"
598then
599 AC_MSG_WARN([
600
601 By default, distutils will build C++ extension modules with "$CXX".
602 If this is not intended, then set CXX on the configure command line.
603 ])
604fi
605
606
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000607# checks for UNIX variants that set C preprocessor variables
Matthias Klose9f8e0c12010-05-08 10:17:27 +0000608AC_USE_SYSTEM_EXTENSIONS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000609
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000610# Check for unsupported systems
611case $ac_sys_system/$ac_sys_release in
Brett Cannon19fab762007-06-02 03:02:29 +0000612atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000613 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
614 echo See README for details.
615 exit 1;;
616esac
617
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000618AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000619AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000620AC_ARG_WITH(suffix,
Matthias Klose22520ea2010-05-08 10:14:46 +0000621 AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000622[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000623 case $withval in
624 no) EXEEXT=;;
625 yes) EXEEXT=.exe;;
626 *) EXEEXT=$withval;;
627 esac])
628AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000629
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000630# Test whether we're running on a non-case-sensitive system, in which
631# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000632AC_SUBST(BUILDEXEEXT)
633AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000634if test ! -d CaseSensitiveTestDir; then
635mkdir CaseSensitiveTestDir
636fi
637
638if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000639then
Jack Jansen1999ef42001-12-06 21:47:20 +0000640 AC_MSG_RESULT(yes)
641 BUILDEXEEXT=.exe
642else
643 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000644 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000645fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000646rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000647
Guido van Rossumdd997f71998-10-07 19:58:26 +0000648case $MACHDEP in
649bsdos*)
650 case $CC in
651 gcc) CC="$CC -D_HAVE_BSDI";;
652 esac;;
653esac
654
Guido van Rossum84561611997-08-21 00:08:11 +0000655case $ac_sys_system in
656hp*|HP*)
657 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000658 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000659 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000660SunOS*)
661 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000662 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000663 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000664esac
665
Martin v. Löwise8964d42001-03-06 12:09:07 +0000666
Neil Schemenauer61c51152001-01-26 16:18:16 +0000667AC_SUBST(LIBRARY)
668AC_MSG_CHECKING(LIBRARY)
669if test -z "$LIBRARY"
670then
671 LIBRARY='libpython$(VERSION).a'
672fi
673AC_MSG_RESULT($LIBRARY)
674
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000675# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000676# name of the library into which to insert object files). BLDLIBRARY is also
677# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
678# is blank as the main program is not linked directly against LDLIBRARY.
679# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
680# systems without shared libraries, LDLIBRARY is the same as LIBRARY
681# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
682# DLLLIBRARY is the shared (i.e., DLL) library.
683#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000684# RUNSHARED is used to run shared python without installed libraries
685#
686# INSTSONAME is the name of the shared library that will be use to install
687# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000688AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000689AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000690AC_SUBST(BLDLIBRARY)
691AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000692AC_SUBST(INSTSONAME)
693AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000694LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000695BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000696INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000697DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000698LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000699RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000700
Guido van Rossumfb842551997-08-06 23:42:07 +0000701# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000702# If CXX is set, and if it is needed to link a main function that was
703# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
704# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000705# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000706# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000707AC_SUBST(LINKCC)
708AC_MSG_CHECKING(LINKCC)
709if test -z "$LINKCC"
710then
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000711 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000712 case $ac_sys_system in
713 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000714 exp_extra="\"\""
715 if test $ac_sys_release -ge 5 -o \
716 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
717 exp_extra="."
718 fi
719 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000720 QNX*)
721 # qcc must be used because the other compilers do not
722 # support -N.
723 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000724 esac
725fi
726AC_MSG_RESULT($LINKCC)
727
Tarek Ziadée2be83d2009-05-09 08:28:53 +0000728# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
729# make sure we default having it set to "no": this is used by
730# distutils.unixccompiler to know if it should add --enable-new-dtags
731# to linker command lines, and failing to detect GNU ld simply results
732# in the same bahaviour as before.
733AC_SUBST(GNULD)
734AC_MSG_CHECKING(for GNU ld)
735ac_prog=ld
736if test "$GCC" = yes; then
737 ac_prog=`$CC -print-prog-name=ld`
738fi
739case `"$ac_prog" -V 2>&1 < /dev/null` in
740 *GNU*)
741 GNULD=yes;;
742 *)
743 GNULD=no;;
744esac
745AC_MSG_RESULT($GNULD)
746
Martin v. Löwis1142de32002-03-29 16:28:31 +0000747AC_MSG_CHECKING(for --enable-shared)
748AC_ARG_ENABLE(shared,
Matthias Klose22520ea2010-05-08 10:14:46 +0000749 AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000750
Martin v. Löwis1142de32002-03-29 16:28:31 +0000751if test -z "$enable_shared"
752then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000753 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000754 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000755 enable_shared="yes";;
756 *)
757 enable_shared="no";;
758 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000759fi
760AC_MSG_RESULT($enable_shared)
761
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000762AC_MSG_CHECKING(for --enable-profiling)
763AC_ARG_ENABLE(profiling,
Matthias Klose22520ea2010-05-08 10:14:46 +0000764 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]),
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000765[ac_save_cc="$CC"
766 CC="$CC -pg"
Matthias Klosec511b472010-05-08 11:01:39 +0000767 AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
768 [ac_enable_profiling="yes"],
769 [ac_enable_profiling="no"],
770 [ac_enable_profiling="no"])
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000771 CC="$ac_save_cc"])
772AC_MSG_RESULT($ac_enable_profiling)
773
774case "$ac_enable_profiling" in
775 "yes")
776 BASECFLAGS="-pg $BASECFLAGS"
777 LDFLAGS="-pg $LDFLAGS"
778 ;;
779esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000780
781AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000782
Guido van Rossumb8552162001-09-05 14:58:11 +0000783# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
784# library that we build, but we do not want to link against it (we
785# will find it with a -framework option). For this reason there is an
786# extra variable BLDLIBRARY against which Python and the extension
787# modules are linked, BLDLIBRARY. This is normally the same as
788# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000789if test "$enable_framework"
790then
791 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000792 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000793 BLDLIBRARY=''
794else
795 BLDLIBRARY='$(LDLIBRARY)'
796fi
797
Martin v. Löwis1142de32002-03-29 16:28:31 +0000798# Other platforms follow
799if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000800 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000801 case $ac_sys_system in
802 BeOS*)
803 LDLIBRARY='libpython$(VERSION).so'
804 ;;
805 CYGWIN*)
806 LDLIBRARY='libpython$(VERSION).dll.a'
807 DLLLIBRARY='libpython$(VERSION).dll'
808 ;;
809 SunOS*)
810 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000811 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000812 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000813 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000814 ;;
Charles-François Natali3de8c732011-07-24 22:33:35 +0200815 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000816 LDLIBRARY='libpython$(VERSION).so'
817 BLDLIBRARY='-L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000818 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000819 case $ac_sys_system in
820 FreeBSD*)
821 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
822 ;;
823 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000824 INSTSONAME="$LDLIBRARY".$SOVERSION
825 ;;
826 hp*|HP*)
Neal Norwitz58e28882006-05-19 07:00:58 +0000827 case `uname -m` in
828 ia64)
829 LDLIBRARY='libpython$(VERSION).so'
830 ;;
831 *)
832 LDLIBRARY='libpython$(VERSION).sl'
833 ;;
834 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000835 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000836 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000837 ;;
838 OSF*)
839 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000840 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000841 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000842 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000843 atheos*)
844 LDLIBRARY='libpython$(VERSION).so'
845 BLDLIBRARY='-L. -lpython$(VERSION)'
846 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
847 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000848 Darwin*)
849 LDLIBRARY='libpython$(VERSION).dylib'
850 BLDLIBRARY='-L. -lpython$(VERSION)'
851 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
852 ;;
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000853 AIX*)
854 LDLIBRARY='libpython$(VERSION).so'
855 RUNSHARED=LIBPATH=`pwd`:${LIBPATH}
856 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000857
Martin v. Löwis1142de32002-03-29 16:28:31 +0000858 esac
Jason Tishler30765592003-09-04 11:04:06 +0000859else # shared is disabled
860 case $ac_sys_system in
861 CYGWIN*)
862 BLDLIBRARY='$(LIBRARY)'
863 LDLIBRARY='libpython$(VERSION).dll.a'
864 ;;
865 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000866fi
867
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000868AC_MSG_RESULT($LDLIBRARY)
869
Guido van Rossum627b2d71993-12-24 10:39:16 +0000870AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000871AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000872AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000873
Tarek Ziadé99f660a2009-05-07 21:20:34 +0000874# tweak ARFLAGS only if the user didn't set it on the command line
875AC_SUBST(ARFLAGS)
876if test -z "$ARFLAGS"
877then
878 ARFLAGS="rc"
879fi
880
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000881AC_SUBST(SVNVERSION)
Martin v. Löwisff600232006-04-03 19:12:32 +0000882AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000883if test $SVNVERSION = found
884then
885 SVNVERSION="svnversion \$(srcdir)"
886else
Benjamin Petersone5afa3b2009-05-23 19:24:37 +0000887 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000888fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000889
Trent Nelsond86ceec2012-10-16 09:42:45 -0400890AC_SUBST(BASECPPFLAGS)
Trent Nelsonabf20512012-10-17 04:32:49 -0400891if test "$abs_srcdir" != "$abs_builddir"; then
Trent Nelsond86ceec2012-10-16 09:42:45 -0400892 # If we're building out-of-tree make sure Include (in the current dir)
893 # gets picked up before its $srcdir counterpart in order for Python-ast.h
894 # and graminit.h to get picked up from the correct directory.
895 # (A side effect of this is that these resources will automatically be
896 # regenerated when building out-of-tree, regardless of whether or not
897 # the $srcdir counterpart is up-to-date. This is an acceptable trade
898 # off.)
899 BASECPPFLAGS="-IInclude"
900else
901 BASECPPFLAGS=""
902fi
903
Georg Brandl3a5508e2011-03-06 10:42:21 +0100904AC_SUBST(HGVERSION)
905AC_SUBST(HGTAG)
906AC_SUBST(HGBRANCH)
907AC_CHECK_PROG(HAS_HG, hg, found, not-found)
908if test $HAS_HG = found
909then
910 HGVERSION="hg id -i \$(srcdir)"
911 HGTAG="hg id -t \$(srcdir)"
912 HGBRANCH="hg id -b \$(srcdir)"
913else
914 HGVERSION=""
915 HGTAG=""
916 HGBRANCH=""
917fi
918
Neil Schemenauera42c8272001-03-31 00:01:55 +0000919case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000920bsdos*|hp*|HP*)
921 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000922 if test -z "$INSTALL"
923 then
924 INSTALL="${srcdir}/install-sh -c"
925 fi
926esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000927AC_PROG_INSTALL
Trent Nelsonf6407a12012-08-30 14:56:13 +0000928AC_PROG_MKDIR_P
Guido van Rossumb418f891996-07-30 18:06:02 +0000929
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000930# Not every filesystem supports hard links
931AC_SUBST(LN)
932if test -z "$LN" ; then
933 case $ac_sys_system in
934 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000935 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000936 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000937 *) LN=ln;;
938 esac
939fi
940
Fred Drake9f715822001-07-11 06:27:00 +0000941# Check for --with-pydebug
942AC_MSG_CHECKING(for --with-pydebug)
943AC_ARG_WITH(pydebug,
Matthias Klose22520ea2010-05-08 10:14:46 +0000944 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000945[
Fred Drake9f715822001-07-11 06:27:00 +0000946if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000947then
948 AC_DEFINE(Py_DEBUG, 1,
949 [Define if you want to build an interpreter with many run-time checks.])
950 AC_MSG_RESULT(yes);
951 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +0000952else AC_MSG_RESULT(no); Py_DEBUG='false'
953fi],
954[AC_MSG_RESULT(no)])
955
Skip Montanarodecc6a42003-01-01 20:07:49 +0000956# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
957# merged with this chunk of code?
958
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000959# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +0000960# ------------------------
961# (The following bit of code is complicated enough - please keep things
962# indented properly. Just pretend you're editing Python code. ;-)
963
964# There are two parallel sets of case statements below, one that checks to
965# see if OPT was set and one that does BASECFLAGS setting based upon
966# compiler and platform. BASECFLAGS tweaks need to be made even if the
967# user set OPT.
968
969# tweak OPT based on compiler and platform, only if the user didn't set
970# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +0000971AC_SUBST(OPT)
Benjamin Petersond4b721b2010-03-23 20:58:37 +0000972if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +0000973then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000974 case $GCC in
975 yes)
Skip Montanaro288a5be2006-04-13 02:00:56 +0000976 if test "$CC" != 'g++' ; then
977 STRICT_PROTO="-Wstrict-prototypes"
978 fi
Guido van Rossum7c862f82007-12-13 20:50:10 +0000979 # For gcc 4.x we need to use -fwrapv so lets check if its supported
980 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
981 WRAP="-fwrapv"
982 fi
Stefan Krah503e5e12011-09-14 15:19:42 +0200983
984 # Clang also needs -fwrapv
Stefan Krah2bc1e8f2011-12-08 22:26:06 +0100985 case $CC in
986 *clang*) WRAP="-fwrapv"
987 ;;
988 esac
Stefan Krah503e5e12011-09-14 15:19:42 +0200989
Skip Montanarodecc6a42003-01-01 20:07:49 +0000990 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000991 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000992 if test "$Py_DEBUG" = 'true' ; then
993 # Optimization messes up debuggers, so turn it off for
994 # debug builds.
Mark Dickinsond2f3e3f2010-05-05 22:23:58 +0000995 OPT="-g -O0 -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +0000996 else
Guido van Rossum7c862f82007-12-13 20:50:10 +0000997 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000998 fi
999 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001000 *)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001001 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001002 ;;
Fred Drake9f715822001-07-11 06:27:00 +00001003 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001004 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001005 SCO_SV*) OPT="$OPT -m486 -DSCO5"
1006 ;;
1007 esac
Fred Drake9f715822001-07-11 06:27:00 +00001008 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001009
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001010 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +00001011 OPT="-O"
1012 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001013 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +00001014fi
Guido van Rossum627b2d71993-12-24 10:39:16 +00001015
Skip Montanarodecc6a42003-01-01 20:07:49 +00001016AC_SUBST(BASECFLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001017
1018# The -arch flags for universal builds on OSX
1019UNIVERSAL_ARCH_FLAGS=
1020AC_SUBST(UNIVERSAL_ARCH_FLAGS)
1021
Skip Montanarodecc6a42003-01-01 20:07:49 +00001022# tweak BASECFLAGS based on compiler and platform
1023case $GCC in
1024yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001025 # Python violates C99 rules, by casting between incompatible
1026 # pointer types. GCC may generate bad code as a result of that,
1027 # so use -fno-strict-aliasing if supported.
1028 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
1029 ac_save_cc="$CC"
1030 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti00900892009-07-17 05:26:39 +00001031 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Matthias Klosec511b472010-05-08 11:01:39 +00001032 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001033 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001034 [ac_cv_no_strict_aliasing_ok=yes],
1035 [ac_cv_no_strict_aliasing_ok=no]))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001036 CC="$ac_save_cc"
1037 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
1038 if test $ac_cv_no_strict_aliasing_ok = yes
1039 then
1040 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
1041 fi
Mark Dickinson65134662008-04-25 16:11:04 +00001042
1043 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
1044 # support. Without this, treatment of subnormals doesn't follow
1045 # the standard.
1046 case $ac_sys_machine in
1047 alpha*)
1048 BASECFLAGS="$BASECFLAGS -mieee"
1049 ;;
1050 esac
1051
Skip Montanarodecc6a42003-01-01 20:07:49 +00001052 case $ac_sys_system in
1053 SCO_SV*)
1054 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
1055 ;;
1056 # is there any other compiler on Darwin besides gcc?
1057 Darwin*)
Jeffrey Yasskin1b4e45b2008-03-17 14:40:53 +00001058 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1059 # used to be here, but non-Apple gcc doesn't accept them.
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001060 if test "${CC}" = gcc
1061 then
1062 AC_MSG_CHECKING(which compiler should be used)
1063 case "${UNIVERSALSDK}" in
1064 */MacOSX10.4u.sdk)
1065 # Build using 10.4 SDK, force usage of gcc when the
1066 # compiler is gcc, otherwise the user will get very
1067 # confusing error messages when building on OSX 10.6
1068 CC=gcc-4.0
1069 CPP=cpp-4.0
1070 ;;
1071 esac
1072 AC_MSG_RESULT($CC)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001073 fi
1074
Benjamin Peterson4347c442008-07-17 15:59:24 +00001075 # Calculate the right deployment target for this build.
1076 #
1077 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
1078 if test ${cur_target} '>' 10.2; then
1079 cur_target=10.3
Ronald Oussoren25967582009-09-06 10:00:26 +00001080 if test ${enable_universalsdk}; then
1081 if test "${UNIVERSAL_ARCHS}" = "all"; then
1082 # Ensure that the default platform for a
1083 # 4-way universal build is OSX 10.5,
1084 # that's the first OS release where
1085 # 4-way builds make sense.
1086 cur_target='10.5'
Ronald Oussoren23d92532009-09-07 06:12:00 +00001087
1088 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
1089 cur_target='10.5'
1090
1091 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
1092 cur_target='10.5'
1093
1094 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1095 cur_target='10.5'
Ronald Oussoren25967582009-09-06 10:00:26 +00001096 fi
1097 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001098 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren25967582009-09-06 10:00:26 +00001099 # On Intel macs default to a deployment
1100 # target of 10.4, that's the first OSX
1101 # release with Intel support.
1102 cur_target="10.4"
1103 fi
1104 fi
Benjamin Peterson4347c442008-07-17 15:59:24 +00001105 fi
1106 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1107
1108 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1109 # environment with a value that is the same as what we'll use
1110 # in the Makefile to ensure that we'll get the same compiler
1111 # environment during configure and build time.
1112 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1113 export MACOSX_DEPLOYMENT_TARGET
1114 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1115
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001116 if test "${enable_universalsdk}"; then
1117 UNIVERSAL_ARCH_FLAGS=""
1118 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1119 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1120 ARCH_RUN_32BIT=""
Ronald Oussoren75912852010-04-08 08:13:31 +00001121 LIPO_32BIT_FLAGS=""
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001122
1123 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1124 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1125 LIPO_32BIT_FLAGS=""
1126 ARCH_RUN_32BIT="true"
1127
1128 elif test "$UNIVERSAL_ARCHS" = "all" ; then
1129 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1130 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001131 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001132
1133 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1134 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1135 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001136 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001137
1138 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1139 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1140 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren9922f172010-02-11 13:19:34 +00001141 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001142
1143 else
1144 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1145
1146 fi
1147
1148
Ronald Oussoren974eb5e2010-04-18 17:59:37 +00001149 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1150 if test "${UNIVERSALSDK}" != "/"
1151 then
1152 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1153 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1154 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001155 fi
1156
1157 fi
1158
1159
Skip Montanarodecc6a42003-01-01 20:07:49 +00001160 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001161 OSF*)
1162 BASECFLAGS="$BASECFLAGS -mieee"
1163 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001164 esac
1165 ;;
1166
1167*)
1168 case $ac_sys_system in
1169 OpenUNIX*|UnixWare*)
1170 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1171 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001172 OSF*)
1173 BASECFLAGS="$BASECFLAGS -ieee -std"
1174 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001175 SCO_SV*)
1176 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1177 ;;
1178 esac
1179 ;;
1180esac
1181
Fred Drakee1ceaa02001-12-04 20:55:47 +00001182if test "$Py_DEBUG" = 'true'; then
1183 :
1184else
1185 OPT="-DNDEBUG $OPT"
1186fi
1187
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001188if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001189then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001190 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001191fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001192
Neal Norwitz020c46a2006-01-07 21:39:28 +00001193# disable check for icc since it seems to pass, but generates a warning
1194if test "$CC" = icc
1195then
1196 ac_cv_opt_olimit_ok=no
1197fi
1198
Guido van Rossum91922671997-10-09 20:24:13 +00001199AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1200AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1201[ac_save_cc="$CC"
1202CC="$CC -OPT:Olimit=0"
Matthias Klosec511b472010-05-08 11:01:39 +00001203AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001204 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001205 [ac_cv_opt_olimit_ok=yes],
1206 [ac_cv_opt_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001207 )
Guido van Rossum91922671997-10-09 20:24:13 +00001208CC="$ac_save_cc"])
1209AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001210if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001211 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001212 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1213 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1214 # environment?
1215 Darwin*)
1216 ;;
Trent Nelson34562e12012-10-17 18:01:12 -04001217 # XXX thankfully this useless troublemaker of a flag has been
1218 # eradicated in the 3.x line. For now, make sure it isn't picked
1219 # up by any of our other platforms that use CC.
1220 AIX*|SunOS*|HP-UX*|IRIX*)
1221 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001222 *)
1223 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1224 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001225 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001226else
1227 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1228 AC_CACHE_VAL(ac_cv_olimit_ok,
1229 [ac_save_cc="$CC"
1230 CC="$CC -Olimit 1500"
Matthias Klosec511b472010-05-08 11:01:39 +00001231 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001232 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001233 [ac_cv_olimit_ok=yes],
1234 [ac_cv_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001235 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001236 CC="$ac_save_cc"])
1237 AC_MSG_RESULT($ac_cv_olimit_ok)
1238 if test $ac_cv_olimit_ok = yes; then
Stefan Krah67473262012-11-29 00:17:05 +01001239 case $ac_sys_system in
1240 # Issue #16534: On HP-UX ac_cv_olimit_ok=yes is a false positive.
1241 HP-UX*)
1242 ;;
1243 *)
1244 BASECFLAGS="$BASECFLAGS -Olimit 1500"
1245 ;;
1246 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001247 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001248fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001249
Martin v. Löwisaac13162006-10-19 10:58:46 +00001250# Check whether GCC supports PyArg_ParseTuple format
1251if test "$GCC" = "yes"
1252then
1253 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1254 save_CFLAGS=$CFLAGS
1255 CFLAGS="$CFLAGS -Werror"
Matthias Klosec511b472010-05-08 11:01:39 +00001256 AC_COMPILE_IFELSE([
1257 AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
1258 ],[
1259 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1,
1260 [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1261 AC_MSG_RESULT(yes)
1262 ],[
1263 AC_MSG_RESULT(no)
1264 ])
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001265 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001266fi
1267
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001268# On some compilers, pthreads are available without further options
1269# (e.g. MacOS X). On some of these systems, the compiler will not
1270# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1271# So we have to see first whether pthreads are available without
1272# options before we can check whether -Kpthread improves anything.
1273AC_MSG_CHECKING(whether pthreads are available without options)
1274AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Klosec511b472010-05-08 11:01:39 +00001275[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001276#include <stdio.h>
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001277#include <pthread.h>
1278
1279void* routine(void* p){return NULL;}
1280
1281int main(){
1282 pthread_t p;
1283 if(pthread_create(&p,NULL,routine,NULL)!=0)
1284 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001285 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001286 return 0;
1287}
Matthias Klosec511b472010-05-08 11:01:39 +00001288]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00001289 ac_cv_pthread_is_default=yes
1290 ac_cv_kthread=no
1291 ac_cv_pthread=no
Matthias Klosec511b472010-05-08 11:01:39 +00001292],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001293])
1294AC_MSG_RESULT($ac_cv_pthread_is_default)
1295
1296
1297if test $ac_cv_pthread_is_default = yes
1298then
1299 ac_cv_kpthread=no
1300else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001301# -Kpthread, if available, provides the right #defines
1302# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001303# Some compilers won't report that they do not support -Kpthread,
1304# so we need to run a program to see whether it really made the
1305# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001306AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1307AC_CACHE_VAL(ac_cv_kpthread,
1308[ac_save_cc="$CC"
1309CC="$CC -Kpthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001310AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001311#include <stdio.h>
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001312#include <pthread.h>
1313
1314void* routine(void* p){return NULL;}
1315
1316int main(){
1317 pthread_t p;
1318 if(pthread_create(&p,NULL,routine,NULL)!=0)
1319 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001320 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001321 return 0;
1322}
Matthias Klosec511b472010-05-08 11:01:39 +00001323]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001324CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001325AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001326fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001327
Skip Montanarod8d39a02003-07-10 20:44:10 +00001328if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001329then
1330# -Kthread, if available, provides the right #defines
1331# and linker options to make pthread_create available
1332# Some compilers won't report that they do not support -Kthread,
1333# so we need to run a program to see whether it really made the
1334# function available.
1335AC_MSG_CHECKING(whether $CC accepts -Kthread)
1336AC_CACHE_VAL(ac_cv_kthread,
1337[ac_save_cc="$CC"
1338CC="$CC -Kthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001339AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001340#include <stdio.h>
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001341#include <pthread.h>
1342
1343void* routine(void* p){return NULL;}
1344
1345int main(){
1346 pthread_t p;
1347 if(pthread_create(&p,NULL,routine,NULL)!=0)
1348 return 1;
1349 (void)pthread_detach(p);
1350 return 0;
1351}
Matthias Klosec511b472010-05-08 11:01:39 +00001352]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001353CC="$ac_save_cc"])
1354AC_MSG_RESULT($ac_cv_kthread)
1355fi
1356
Skip Montanarod8d39a02003-07-10 20:44:10 +00001357if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001358then
1359# -pthread, if available, provides the right #defines
1360# and linker options to make pthread_create available
1361# Some compilers won't report that they do not support -pthread,
1362# so we need to run a program to see whether it really made the
1363# function available.
1364AC_MSG_CHECKING(whether $CC accepts -pthread)
1365AC_CACHE_VAL(ac_cv_thread,
1366[ac_save_cc="$CC"
1367CC="$CC -pthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001368AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001369#include <stdio.h>
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001370#include <pthread.h>
1371
1372void* routine(void* p){return NULL;}
1373
1374int main(){
1375 pthread_t p;
1376 if(pthread_create(&p,NULL,routine,NULL)!=0)
1377 return 1;
1378 (void)pthread_detach(p);
1379 return 0;
1380}
Matthias Klosec511b472010-05-08 11:01:39 +00001381]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001382CC="$ac_save_cc"])
1383AC_MSG_RESULT($ac_cv_pthread)
1384fi
1385
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001386# If we have set a CC compiler flag for thread support then
1387# check if it works for CXX, too.
1388ac_cv_cxx_thread=no
1389if test ! -z "$CXX"
1390then
1391AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1392ac_save_cxx="$CXX"
1393
1394if test "$ac_cv_kpthread" = "yes"
1395then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001396 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001397 ac_cv_cxx_thread=yes
1398elif test "$ac_cv_kthread" = "yes"
1399then
1400 CXX="$CXX -Kthread"
1401 ac_cv_cxx_thread=yes
1402elif test "$ac_cv_pthread" = "yes"
1403then
1404 CXX="$CXX -pthread"
1405 ac_cv_cxx_thread=yes
1406fi
1407
1408if test $ac_cv_cxx_thread = yes
1409then
1410 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1411 $CXX -c conftest.$ac_ext 2>&5
1412 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1413 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1414 then
1415 ac_cv_cxx_thread=yes
1416 else
1417 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001418 fi
1419 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001420fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001421AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001422fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001423CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001424
Fred Drakece81d592000-07-09 14:39:29 +00001425dnl # check for ANSI or K&R ("traditional") preprocessor
1426dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Klosec511b472010-05-08 11:01:39 +00001427dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00001428dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1429dnl int foo;
1430dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Klosec511b472010-05-08 11:01:39 +00001431dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00001432dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001433
Guido van Rossum627b2d71993-12-24 10:39:16 +00001434# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001435AC_HEADER_STDC
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001436AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1437fcntl.h grp.h \
Neal Norwitz9fdfaaf2008-03-28 05:34:59 +00001438ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001439shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001440unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001441sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1442sys/lock.h sys/mkdev.h sys/modem.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001443sys/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 +00001444sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001445sys/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 +00001446sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001447bluetooth/bluetooth.h linux/tipc.h spawn.h util.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001448AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001449AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001450
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001451# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e2004-11-30 22:09:37 +00001452AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001453#ifdef HAVE_CURSES_H
1454#include <curses.h>
1455#endif
1456])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001457
Martin v. Löwis11017b12006-01-14 18:12:57 +00001458# On Linux, netlink.h requires asm/types.h
1459AC_CHECK_HEADERS(linux/netlink.h,,,[
1460#ifdef HAVE_ASM_TYPES_H
1461#include <asm/types.h>
1462#endif
1463#ifdef HAVE_SYS_SOCKET_H
1464#include <sys/socket.h>
1465#endif
1466])
1467
Guido van Rossum627b2d71993-12-24 10:39:16 +00001468# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001469was_it_defined=no
1470AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001471AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1472 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1473])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001474AC_MSG_RESULT($was_it_defined)
1475
Neal Norwitz11690112002-07-30 01:08:28 +00001476# Check whether using makedev requires defining _OSF_SOURCE
1477AC_MSG_CHECKING(for makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00001478AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Jesus Cea616de772010-04-28 10:32:30 +00001479#if defined(MAJOR_IN_MKDEV)
1480#include <sys/mkdev.h>
1481#elif defined(MAJOR_IN_SYSMACROS)
1482#include <sys/sysmacros.h>
1483#else
1484#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001485#endif ]], [[ makedev(0, 0) ]])],
1486[ac_cv_has_makedev=yes],
1487[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001488if test "$ac_cv_has_makedev" = "no"; then
1489 # we didn't link, try if _OSF_SOURCE will allow us to link
Matthias Klosec511b472010-05-08 11:01:39 +00001490 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001491#define _OSF_SOURCE 1
1492#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001493 ]], [[ makedev(0, 0) ]])],
1494[ac_cv_has_makedev=yes],
1495[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001496 if test "$ac_cv_has_makedev" = "yes"; then
1497 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1498 fi
1499fi
1500AC_MSG_RESULT($ac_cv_has_makedev)
1501if test "$ac_cv_has_makedev" = "yes"; then
1502 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1503fi
1504
Martin v. Löwis399a6892002-10-04 10:22:02 +00001505# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1506# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1507# defined, but the compiler does not support pragma redefine_extname,
1508# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1509# structures (such as rlimit64) without declaring them. As a
1510# work-around, disable LFS on such configurations
1511
1512use_lfs=yes
1513AC_MSG_CHECKING(Solaris LFS bug)
Matthias Klosec511b472010-05-08 11:01:39 +00001514AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis399a6892002-10-04 10:22:02 +00001515#define _LARGEFILE_SOURCE 1
1516#define _FILE_OFFSET_BITS 64
1517#include <sys/resource.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001518]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001519AC_MSG_RESULT($sol_lfs_bug)
1520if test "$sol_lfs_bug" = "yes"; then
1521 use_lfs=no
1522fi
1523
1524if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001525# Two defines needed to enable largefile support on various platforms
1526# These may affect some typedefs
Georg Brandl94800df2011-02-25 11:09:02 +00001527case $ac_sys_system/$ac_sys_release in
1528AIX*)
1529 AC_DEFINE(_LARGE_FILES, 1,
1530 [This must be defined on AIX systems to enable large file support.])
1531 ;;
1532esac
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001533AC_DEFINE(_LARGEFILE_SOURCE, 1,
1534[This must be defined on some systems to enable large file support.])
1535AC_DEFINE(_FILE_OFFSET_BITS, 64,
1536[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001537fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001538
Guido van Rossum300fda71996-08-19 21:58:16 +00001539# Add some code to confdefs.h so that the test for off_t works on SCO
1540cat >> confdefs.h <<\EOF
1541#if defined(SCO_DS)
1542#undef _OFF_T
1543#endif
1544EOF
1545
Guido van Rossumef2255b2000-03-10 22:30:29 +00001546# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001547AC_TYPE_MODE_T
1548AC_TYPE_OFF_T
1549AC_TYPE_PID_T
Matthias Klosecbf54b12010-05-08 11:04:18 +00001550AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001551AC_TYPE_SIZE_T
1552AC_TYPE_UID_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001553
1554# There are two separate checks for each of the exact-width integer types we
1555# need. First we check whether the type is available using the usual
1556# AC_CHECK_TYPE macro with the default includes (which includes <inttypes.h>
1557# and <stdint.h> where available). We then also use the special type checks of
1558# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available
1559# directly, #define's uint32_t to be a suitable type.
1560
1561AC_CHECK_TYPE(uint32_t,
1562 AC_DEFINE(HAVE_UINT32_T, 1, [Define if your compiler provides uint32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001563AC_TYPE_UINT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001564
1565AC_CHECK_TYPE(uint64_t,
1566 AC_DEFINE(HAVE_UINT64_T, 1, [Define if your compiler provides uint64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001567AC_TYPE_UINT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001568
1569AC_CHECK_TYPE(int32_t,
1570 AC_DEFINE(HAVE_INT32_T, 1, [Define if your compiler provides int32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001571AC_TYPE_INT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001572
1573AC_CHECK_TYPE(int64_t,
1574 AC_DEFINE(HAVE_INT64_T, 1, [Define if your compiler provides int64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001575AC_TYPE_INT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001576
Christian Heimes951cc0f2008-01-31 23:08:23 +00001577AC_CHECK_TYPE(ssize_t,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001578 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001579
Guido van Rossumef2255b2000-03-10 22:30:29 +00001580# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001581# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001582AC_CHECK_SIZEOF(int, 4)
1583AC_CHECK_SIZEOF(long, 4)
1584AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001585AC_CHECK_SIZEOF(short, 2)
1586AC_CHECK_SIZEOF(float, 4)
1587AC_CHECK_SIZEOF(double, 8)
1588AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001589AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001590AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001591
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001592AC_MSG_CHECKING(for long long support)
1593have_long_long=no
Matthias Klosec511b472010-05-08 11:01:39 +00001594AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001595 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1596 have_long_long=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001597],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001598AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001599if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001600AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001601fi
1602
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001603AC_MSG_CHECKING(for long double support)
1604have_long_double=no
Matthias Klosec511b472010-05-08 11:01:39 +00001605AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001606 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1607 have_long_double=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001608],[])
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001609AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001610if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001611AC_CHECK_SIZEOF(long double, 12)
1612fi
1613
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001614AC_MSG_CHECKING(for _Bool support)
1615have_c99_bool=no
Matthias Klosec511b472010-05-08 11:01:39 +00001616AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001617 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1618 have_c99_bool=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001619],[])
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001620AC_MSG_RESULT($have_c99_bool)
1621if test "$have_c99_bool" = yes ; then
1622AC_CHECK_SIZEOF(_Bool, 1)
1623fi
1624
Martin v. Löwisebe26702006-10-02 14:55:51 +00001625AC_CHECK_TYPES(uintptr_t,
1626 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001627 [], [#ifdef HAVE_STDINT_H
1628 #include <stdint.h>
Antoine Pitrou7be5a652010-10-10 08:14:41 +00001629 #endif
1630 #ifdef HAVE_INTTYPES_H
1631 #include <inttypes.h>
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001632 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001633
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001634AC_CHECK_SIZEOF(off_t, [], [
1635#ifdef HAVE_SYS_TYPES_H
1636#include <sys/types.h>
1637#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001638])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001639
1640AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001641if test "$have_long_long" = yes
1642then
1643if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001644 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001645 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1646 [Defined to enable large file support when an off_t is bigger than a long
1647 and long long is available and at least as big as an off_t. You may need
1648 to add some flags for configuration and compilation to enable this mode.
1649 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001650 AC_MSG_RESULT(yes)
1651else
1652 AC_MSG_RESULT(no)
1653fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001654else
1655 AC_MSG_RESULT(no)
1656fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001657
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001658AC_CHECK_SIZEOF(time_t, [], [
1659#ifdef HAVE_SYS_TYPES_H
1660#include <sys/types.h>
1661#endif
1662#ifdef HAVE_TIME_H
1663#include <time.h>
1664#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001665])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001666
Trent Mick635f6fb2000-08-23 21:33:05 +00001667# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001668ac_save_cc="$CC"
1669if test "$ac_cv_kpthread" = "yes"
1670then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001671elif test "$ac_cv_kthread" = "yes"
1672then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001673elif test "$ac_cv_pthread" = "yes"
1674then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001675fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001676AC_MSG_CHECKING(for pthread_t)
1677have_pthread_t=no
Matthias Klosec511b472010-05-08 11:01:39 +00001678AC_COMPILE_IFELSE([
1679 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1680],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001681AC_MSG_RESULT($have_pthread_t)
1682if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001683 AC_CHECK_SIZEOF(pthread_t, [], [
1684#ifdef HAVE_PTHREAD_H
1685#include <pthread.h>
1686#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001687 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001688fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001689CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001690
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001691AC_MSG_CHECKING(for --enable-toolbox-glue)
1692AC_ARG_ENABLE(toolbox-glue,
Matthias Klose22520ea2010-05-08 10:14:46 +00001693 AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001694
1695if test -z "$enable_toolbox_glue"
1696then
1697 case $ac_sys_system/$ac_sys_release in
1698 Darwin/*)
1699 enable_toolbox_glue="yes";;
1700 *)
1701 enable_toolbox_glue="no";;
1702 esac
1703fi
1704case "$enable_toolbox_glue" in
1705yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001706 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001707 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001708 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1709 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001710 ;;
1711*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001712 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001713 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001714 ;;
1715esac
1716AC_MSG_RESULT($enable_toolbox_glue)
1717
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001718
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001719AC_SUBST(OTHER_LIBTOOL_OPT)
1720case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001721 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001722 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1723 ;;
1724 Darwin/*)
1725 OTHER_LIBTOOL_OPT=""
1726 ;;
1727esac
1728
Ronald Oussoren25967582009-09-06 10:00:26 +00001729
1730ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001731AC_SUBST(LIBTOOL_CRUFT)
1732case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001733 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001734 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1735 if test "${enable_universalsdk}"; then
1736 :
1737 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001738 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001739 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001740 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001741 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001742 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001743 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001744 if test ${gcc_version} '<' 4.0
1745 then
1746 LIBTOOL_CRUFT="-lcc_dynamic"
1747 else
1748 LIBTOOL_CRUFT=""
1749 fi
Matthias Klosec511b472010-05-08 11:01:39 +00001750 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren25967582009-09-06 10:00:26 +00001751 #include <unistd.h>
1752 int main(int argc, char*argv[])
1753 {
1754 if (sizeof(long) == 4) {
1755 return 0;
1756 } else {
1757 return 1;
1758 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00001759 }
Matthias Klosec511b472010-05-08 11:01:39 +00001760 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren25967582009-09-06 10:00:26 +00001761
1762 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001763 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001764 i386)
1765 MACOSX_DEFAULT_ARCH="i386"
1766 ;;
1767 ppc)
1768 MACOSX_DEFAULT_ARCH="ppc"
1769 ;;
1770 *)
1771 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1772 ;;
1773 esac
1774 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001775 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001776 i386)
1777 MACOSX_DEFAULT_ARCH="x86_64"
1778 ;;
1779 ppc)
1780 MACOSX_DEFAULT_ARCH="ppc64"
1781 ;;
1782 *)
1783 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1784 ;;
1785 esac
1786
1787 #ARCH_RUN_32BIT="true"
1788 fi
1789
1790 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001791 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001792 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001793esac
1794
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001795AC_MSG_CHECKING(for --enable-framework)
1796if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001797then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001798 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001799 # -F. is needed to allow linking to the framework while
1800 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001801 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1802 [Define if you want to produce an OpenStep/Rhapsody framework
1803 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001804 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00001805 if test $enable_shared = "yes"
1806 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00001807 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead. See Mac/README.])
Ronald Oussoren450d5612009-06-08 21:12:41 +00001808 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001809else
1810 AC_MSG_RESULT(no)
1811fi
1812
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001813AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001814case $ac_sys_system/$ac_sys_release in
1815 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001816 AC_DEFINE(WITH_DYLD, 1,
1817 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1818 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1819 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001820 AC_MSG_RESULT(always on for Darwin)
1821 ;;
1822 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001823 AC_MSG_RESULT(no)
1824 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001825esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001826
Guido van Rossumac405f61994-09-12 10:56:06 +00001827# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001828AC_SUBST(SO)
1829AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001830AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001831AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001832AC_SUBST(CCSHARED)
1833AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001834# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001835# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001836AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001837if test -z "$SO"
1838then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001839 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00001840 hp*|HP*)
1841 case `uname -m` in
1842 ia64) SO=.so;;
1843 *) SO=.sl;;
1844 esac
1845 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001846 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001847 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001848 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001849else
1850 # this might also be a termcap variable, see #610332
1851 echo
1852 echo '====================================================================='
1853 echo '+ +'
1854 echo '+ WARNING: You have set SO in your environment. +'
1855 echo '+ Do you really mean to change the extension for shared libraries? +'
1856 echo '+ Continuing in 10 seconds to let you to ponder. +'
1857 echo '+ +'
1858 echo '====================================================================='
1859 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001860fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001861AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00001862
Neal Norwitz58e28882006-05-19 07:00:58 +00001863AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001864# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001865# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001866# (Shared libraries in this instance are shared modules to be loaded into
1867# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001868AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001869if test -z "$LDSHARED"
1870then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001871 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001872 AIX*)
Georg Brandl71f4fbb2011-02-25 11:04:50 +00001873 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001874 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001875 ;;
1876 BeOS*)
1877 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00001878 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001879 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001880 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001881 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00001882 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001883 if test "$GCC" = "yes" ; then
1884 LDSHARED='$(CC) -shared'
1885 LDCXXSHARED='$(CXX) -shared'
1886 else
1887 LDSHARED='$(CC) -G'
1888 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00001889 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00001890 hp*|HP*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001891 if test "$GCC" = "yes" ; then
1892 LDSHARED='$(CC) -shared'
1893 LDCXXSHARED='$(CXX) -shared'
1894 else
1895 LDSHARED='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00001896 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001897 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001898 Darwin/1.3*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001899 LDSHARED='$(CC) -bundle'
1900 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001901 if test "$enable_framework" ; then
1902 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001903 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1904 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001905 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001906 else
1907 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001908 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00001909 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001910 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001911 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001912 LDSHARED='$(CC) -bundle'
1913 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001914 if test "$enable_framework" ; then
1915 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001916 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1917 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001918 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001919 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001920 # No framework, use the Python app as bundle-loader
1921 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001922 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001923 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001924 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001925 Darwin/*)
1926 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1927 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00001928
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001929 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001930 then
Ronald Oussoren988117f2006-04-29 11:31:35 +00001931 if test "${enable_universalsdk}"; then
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001932 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001933 fi
Stefan Krah3a3e2032010-11-28 15:30:05 +00001934 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
1935 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
Jack Jansen6b08a402004-06-03 12:41:45 +00001936 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001937 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00001938 LDSHARED='$(CC) -bundle'
1939 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00001940 if test "$enable_framework" ; then
1941 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001942 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1943 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001944 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001945 else
1946 # No framework, use the Python app as bundle-loader
1947 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1948 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001949 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001950 fi
1951 fi
1952 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001953 Linux*|GNU*|QNX*)
1954 LDSHARED='$(CC) -shared'
1955 LDCXXSHARED='$(CXX) -shared';;
1956 BSD/OS*/4*)
1957 LDSHARED="gcc -shared"
1958 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00001959 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001960 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001961 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00001962 LDSHARED='$(CC) -shared'
1963 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00001964 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00001965 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00001966 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00001967 OpenBSD*)
1968 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1969 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00001970 LDSHARED='$(CC) -shared $(CCSHARED)'
1971 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00001972 else
1973 case `uname -r` in
1974 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1975 LDSHARED="ld -Bshareable ${LDFLAGS}"
1976 ;;
1977 *)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001978 LDSHARED='$(CC) -shared $(CCSHARED)'
1979 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00001980 ;;
1981 esac
1982 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001983 NetBSD*|DragonFly*)
Antoine Pitroucb402772011-01-02 20:51:34 +00001984 LDSHARED='$(CC) -shared'
1985 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001986 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001987 if test "$GCC" = "yes" ; then
1988 LDSHARED='$(CC) -shared'
1989 LDCXXSHARED='$(CXX) -shared'
1990 else
1991 LDSHARED='$(CC) -G'
1992 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001993 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001994 SCO_SV*)
1995 LDSHARED='$(CC) -Wl,-G,-Bexport'
1996 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
1997 CYGWIN*)
1998 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
1999 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
2000 atheos*)
2001 LDSHARED="gcc -shared"
2002 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002003 *) LDSHARED="ld";;
2004 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002005fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002006AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002007LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002008BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00002009# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002010# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002011AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002012if test -z "$CCSHARED"
2013then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002014 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00002015 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00002016 then CCSHARED="-fPIC";
2017 elif test `uname -p` = sparc;
2018 then CCSHARED="-xcode=pic32";
2019 else CCSHARED="-Kpic";
2020 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00002021 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00002022 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00002023 else CCSHARED="+z";
2024 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002025 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002026 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002027 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002028 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00002029 if test "$GCC" = "yes"
2030 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002031 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00002032 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002033 SCO_SV*)
2034 if test "$GCC" = "yes"
2035 then CCSHARED="-fPIC"
2036 else CCSHARED="-Kpic -belf"
2037 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002038 IRIX*/6*) case $CC in
2039 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00002040 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002041 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002042 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002043 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002044fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002045AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002046# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00002047# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002048AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002049if test -z "$LINKFORSHARED"
2050then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002051 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002052 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00002053 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00002054 LINKFORSHARED="-Wl,-E -Wl,+s";;
2055# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002056 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002057 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002058 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002059 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002060 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
2061 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002062 # not used by the core itself but which needs to be in the core so
2063 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00002064 # -prebind is no longer used, because it actually seems to give a
2065 # slowdown in stead of a speedup, maybe due to the large number of
2066 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002067
2068 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002069 if test "$enable_framework"
2070 then
Jack Jansenda49e192005-01-07 13:08:22 +00002071 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002072 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002073 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002074 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002075 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00002076 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002077 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00002078 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2079 then
2080 LINKFORSHARED="-Wl,--export-dynamic"
2081 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002082 SunOS/5*) case $CC in
2083 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00002084 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00002085 then
2086 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002087 fi;;
2088 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00002089 CYGWIN*)
2090 if test $enable_shared = "no"
2091 then
2092 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2093 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00002094 QNX*)
2095 # -Wl,-E causes the symbols to be added to the dynamic
2096 # symbol table so that they can be found when a module
2097 # is loaded. -N 2048K causes the stack size to be set
2098 # to 2048 kilobytes so that the stack doesn't overflow
2099 # when running test_compile.py.
2100 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002101 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002102fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002103AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002104
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002105
Neil Schemenauer61c51152001-01-26 16:18:16 +00002106AC_SUBST(CFLAGSFORSHARED)
2107AC_MSG_CHECKING(CFLAGSFORSHARED)
2108if test ! "$LIBRARY" = "$LDLIBRARY"
2109then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002110 case $ac_sys_system in
2111 CYGWIN*)
2112 # Cygwin needs CCSHARED when building extension DLLs
2113 # but not when building the interpreter DLL.
2114 CFLAGSFORSHARED='';;
2115 *)
2116 CFLAGSFORSHARED='$(CCSHARED)'
2117 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002118fi
2119AC_MSG_RESULT($CFLAGSFORSHARED)
2120
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002121# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2122# library (with --enable-shared).
2123# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002124# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2125# if it is not required, since it creates a dependency of the shared library
2126# to LIBS. This, in turn, means that applications linking the shared libpython
2127# don't need to link LIBS explicitly. The default should be only changed
2128# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002129AC_SUBST(SHLIBS)
2130AC_MSG_CHECKING(SHLIBS)
2131case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002132 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002133 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002134esac
2135AC_MSG_RESULT($SHLIBS)
2136
2137
Guido van Rossum627b2d71993-12-24 10:39:16 +00002138# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002139AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2140AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00002141
Skip Montanaro4d756af2008-12-01 01:55:22 +00002142# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002143if test "$with_threads" = "yes" -o -z "$with_threads"; then
2144 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2145 # posix4 on Solaris 2.6
2146 # pthread (first!) on Linux
2147fi
2148
Martin v. Löwis19d17342003-06-14 21:03:05 +00002149# check if we need libintl for locale functions
2150AC_CHECK_LIB(intl, textdomain,
2151 AC_DEFINE(WITH_LIBINTL, 1,
2152 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002153
2154# checks for system dependent C++ extensions support
2155case "$ac_sys_system" in
2156 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Klosec511b472010-05-08 11:01:39 +00002157 AC_LINK_IFELSE([
Georg Brandl94800df2011-02-25 11:09:02 +00002158 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Klosec511b472010-05-08 11:01:39 +00002159 [[loadAndInit("", 0, "")]])
2160 ],[
2161 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002162 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2163 and you want support for AIX C++ shared extension modules.])
Matthias Klosec511b472010-05-08 11:01:39 +00002164 AC_MSG_RESULT(yes)
2165 ],[
2166 AC_MSG_RESULT(no)
2167 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002168 *) ;;
2169esac
2170
Guido van Rossum70c7f481998-03-26 18:44:10 +00002171# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002172# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002173AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002174AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002175
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002176case "$ac_sys_system" in
2177BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002178AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2179;;
2180esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002181
Guido van Rossumc5a39031996-07-31 17:35:03 +00002182AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002183AC_ARG_WITH(libs,
Matthias Klose22520ea2010-05-08 10:14:46 +00002184 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002185[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002186AC_MSG_RESULT($withval)
2187LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002188],
2189[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002190
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002191AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2192
Benjamin Peterson2c196742009-12-31 03:17:18 +00002193# Check for use of the system expat library
2194AC_MSG_CHECKING(for --with-system-expat)
2195AC_ARG_WITH(system_expat,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002196 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2197 [],
2198 [with_system_expat="no"])
Benjamin Peterson2c196742009-12-31 03:17:18 +00002199
2200AC_MSG_RESULT($with_system_expat)
2201
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002202# Check for use of the system libffi library
2203AC_MSG_CHECKING(for --with-system-ffi)
2204AC_ARG_WITH(system_ffi,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002205 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2206 [],
2207 [with_system_ffi="no"])
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002208
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002209if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002210 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2211else
2212 LIBFFI_INCLUDEDIR=""
2213fi
2214AC_SUBST(LIBFFI_INCLUDEDIR)
2215
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002216AC_MSG_RESULT($with_system_ffi)
2217
Matthias Klose10cbe482009-04-29 17:18:19 +00002218# Check for --with-dbmliborder
2219AC_MSG_CHECKING(for --with-dbmliborder)
2220AC_ARG_WITH(dbmliborder,
Matthias Klose22520ea2010-05-08 10:14:46 +00002221 AS_HELP_STRING([--with-dbmliborder=db1:db2:...], [order to check db backends for dbm. Valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]),
Matthias Klose10cbe482009-04-29 17:18:19 +00002222[
2223if test x$with_dbmliborder = xyes
2224then
2225AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2226else
2227 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2228 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2229 then
2230 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2231 fi
2232 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002233fi])
2234AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002235
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002236# Determine if signalmodule should be used.
2237AC_SUBST(USE_SIGNAL_MODULE)
2238AC_SUBST(SIGNAL_OBJS)
2239AC_MSG_CHECKING(for --with-signal-module)
2240AC_ARG_WITH(signal-module,
Matthias Klose22520ea2010-05-08 10:14:46 +00002241 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002242
2243if test -z "$with_signal_module"
2244then with_signal_module="yes"
2245fi
2246AC_MSG_RESULT($with_signal_module)
2247
2248if test "${with_signal_module}" = "yes"; then
2249 USE_SIGNAL_MODULE=""
2250 SIGNAL_OBJS=""
2251else
2252 USE_SIGNAL_MODULE="#"
2253 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2254fi
2255
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002256# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002257AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002258USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002259
Guido van Rossum54d93d41997-01-22 20:51:58 +00002260AC_MSG_CHECKING(for --with-dec-threads)
2261AC_SUBST(LDLAST)
2262AC_ARG_WITH(dec-threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002263 AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002264[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002265AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002266LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002267if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002268 with_thread="$withval";
2269fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002270[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002271
Martin v. Löwis11437992002-04-12 09:54:03 +00002272# Templates for things AC_DEFINEd more than once.
2273# For a single AC_DEFINE, no template is needed.
2274AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2275AH_TEMPLATE(_REENTRANT,
2276 [Define to force use of thread-safe errno, h_errno, and other functions])
2277AH_TEMPLATE(WITH_THREAD,
2278 [Define if you want to compile in rudimentary thread support])
2279
Guido van Rossum54d93d41997-01-22 20:51:58 +00002280AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002281dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002282AC_ARG_WITH(threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002283 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002284
Barry Warsawc0d24d82000-06-29 16:12:00 +00002285# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002286dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002287AC_ARG_WITH(thread,
Matthias Klose22520ea2010-05-08 10:14:46 +00002288 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002289 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002290
2291if test -z "$with_threads"
2292then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002293fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002294AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002295
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002296AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002297if test "$with_threads" = "no"
2298then
2299 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002300elif test "$ac_cv_pthread_is_default" = yes
2301then
2302 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002303 # Defining _REENTRANT on system with POSIX threads should not hurt.
2304 AC_DEFINE(_REENTRANT)
2305 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002306 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002307elif test "$ac_cv_kpthread" = "yes"
2308then
2309 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002310 if test "$ac_cv_cxx_thread" = "yes"; then
2311 CXX="$CXX -Kpthread"
2312 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002313 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002314 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002315 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002316elif test "$ac_cv_kthread" = "yes"
2317then
2318 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002319 if test "$ac_cv_cxx_thread" = "yes"; then
2320 CXX="$CXX -Kthread"
2321 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002322 AC_DEFINE(WITH_THREAD)
2323 posix_threads=yes
2324 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002325elif test "$ac_cv_pthread" = "yes"
2326then
2327 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002328 if test "$ac_cv_cxx_thread" = "yes"; then
2329 CXX="$CXX -pthread"
2330 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002331 AC_DEFINE(WITH_THREAD)
2332 posix_threads=yes
2333 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002334else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002335 if test ! -z "$with_threads" -a -d "$with_threads"
2336 then LDFLAGS="$LDFLAGS -L$with_threads"
2337 fi
2338 if test ! -z "$withval" -a -d "$withval"
2339 then LDFLAGS="$LDFLAGS -L$withval"
2340 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002341
2342 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002343 # define _POSIX_THREADS in unistd.h. Some apparently don't
2344 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002345 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2346 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002347 [
2348#include <unistd.h>
2349#ifdef _POSIX_THREADS
2350yes
2351#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002352 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2353 AC_MSG_RESULT($unistd_defines_pthreads)
2354
Martin v. Löwis130fb172001-07-19 11:00:41 +00002355 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002356 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2357 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002358 AC_DEFINE(HURD_C_THREADS, 1,
2359 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002360 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002361 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002362 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2363 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002364 AC_DEFINE(MACH_C_THREADS, 1,
2365 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002366 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002367 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002368 AC_ARG_WITH([pth],
Matthias Klose22520ea2010-05-08 10:14:46 +00002369 AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002370 [AC_MSG_RESULT($withval)
2371 AC_DEFINE([WITH_THREAD])
2372 AC_DEFINE([HAVE_PTH], 1,
2373 [Define if you have GNU PTH threads.])
2374 LIBS="-lpth $LIBS"
2375 THREADOBJ="Python/thread.o"],
2376 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002377
2378 # Just looking for pthread_create in libpthread is not enough:
2379 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2380 # So we really have to include pthread.h, and then link.
2381 _libs=$LIBS
2382 LIBS="$LIBS -lpthread"
2383 AC_MSG_CHECKING([for pthread_create in -lpthread])
Stefan Krahae66ca62012-11-22 22:36:57 +01002384 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2385#include <stdio.h>
2386#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002387
Matthias Klosec511b472010-05-08 11:01:39 +00002388void * start_routine (void *arg) { exit (0); }]], [[
2389pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002390 AC_MSG_RESULT(yes)
2391 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002392 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002393 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002394 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002395 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002396 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002397 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002398 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2399 AC_DEFINE(ATHEOS_THREADS, 1,
2400 [Define this if you have AtheOS threads.])
2401 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002402 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002403 AC_DEFINE(BEOS_THREADS, 1,
2404 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002405 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002406 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002407 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002408 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002409 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002410 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002411 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002412 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002413 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002414 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002415 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002416 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002417 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002418 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002419 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002420 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002421 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002422 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002423 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002424
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002425 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2426 LIBS="$LIBS -lmpc"
2427 THREADOBJ="Python/thread.o"
2428 USE_THREAD_MODULE=""])
2429
2430 if test "$posix_threads" != "yes"; then
2431 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2432 LIBS="$LIBS -lthread"
2433 THREADOBJ="Python/thread.o"
2434 USE_THREAD_MODULE=""])
2435 fi
2436
2437 if test "$USE_THREAD_MODULE" != "#"
2438 then
2439 # If the above checks didn't disable threads, (at least) OSF1
2440 # needs this '-threads' argument during linking.
2441 case $ac_sys_system in
2442 OSF1) LDLAST=-threads;;
2443 esac
2444 fi
2445fi
2446
2447if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002448 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002449 AC_DEFINE(_POSIX_THREADS, 1,
2450 [Define if you have POSIX threads,
2451 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002452 fi
2453
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002454 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2455 case $ac_sys_system/$ac_sys_release in
Charles-François Natali4929eb92011-07-21 19:41:04 +02002456 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002457 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002458 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002459 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002460 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002461 ;;
Charles-François Natali4929eb92011-07-21 19:41:04 +02002462 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002463 [Define if the Posix semaphores do not work on your system])
Christian Heimescba36bb2008-01-30 22:54:18 +00002464 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002465 esac
2466
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002467 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2468 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Stefan Krahae66ca62012-11-22 22:36:57 +01002469 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2470 #include <stdio.h>
2471 #include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002472 void *foo(void *parm) {
2473 return NULL;
2474 }
2475 main() {
2476 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002477 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002478 if (pthread_attr_init(&attr)) exit(-1);
2479 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002480 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002481 exit(0);
Matthias Klosec511b472010-05-08 11:01:39 +00002482 }]])],
2483 [ac_cv_pthread_system_supported=yes],
2484 [ac_cv_pthread_system_supported=no],
2485 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002486 ])
2487 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2488 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002489 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002490 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002491 AC_CHECK_FUNCS(pthread_sigmask,
2492 [case $ac_sys_system in
2493 CYGWIN*)
2494 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2495 [Define if pthread_sigmask() does not work on your system.])
2496 ;;
2497 esac])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002498fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002499
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002500
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002501# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002502AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002503AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002504AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002505[ --enable-ipv6 Enable ipv6 (with ipv4) support
2506 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002507[ case "$enableval" in
2508 no)
2509 AC_MSG_RESULT(no)
2510 ipv6=no
2511 ;;
2512 *) AC_MSG_RESULT(yes)
2513 AC_DEFINE(ENABLE_IPV6)
2514 ipv6=yes
2515 ;;
2516 esac ],
2517
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002518[
2519dnl the check does not work on cross compilation case...
Matthias Klosec511b472010-05-08 11:01:39 +00002520 AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002521#include <sys/types.h>
2522#include <sys/socket.h>
2523main()
2524{
2525 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2526 exit(1);
2527 else
2528 exit(0);
2529}
Matthias Klosec511b472010-05-08 11:01:39 +00002530]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002531 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00002532 ipv6=yes
2533],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002534 AC_MSG_RESULT(no)
2535 ipv6=no
Matthias Klosec511b472010-05-08 11:01:39 +00002536],[
2537 AC_MSG_RESULT(no)
2538 ipv6=no
2539])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002540
2541if test "$ipv6" = "yes"; then
2542 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Klosec511b472010-05-08 11:01:39 +00002543 AC_COMPILE_IFELSE([
2544 AC_LANG_PROGRAM([[#include <sys/types.h>
2545#include <netinet/in.h>]],
2546 [[struct sockaddr_in6 x;
2547 x.sin6_scope_id;]])
2548 ],[
2549 AC_MSG_RESULT(yes)
2550 ipv6=yes
2551 ],[
2552 AC_MSG_RESULT(no, IPv6 disabled)
2553 ipv6=no
2554 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002555fi
2556
2557if test "$ipv6" = "yes"; then
2558 AC_DEFINE(ENABLE_IPV6)
2559fi
2560])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002561
2562ipv6type=unknown
2563ipv6lib=none
2564ipv6trylibc=no
2565
2566if test "$ipv6" = "yes"; then
2567 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002568 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2569 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002570 case $i in
2571 inria)
2572 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002573 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002574#include <netinet/in.h>
2575#ifdef IPV6_INRIA_VERSION
2576yes
2577#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002578 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002579 ;;
2580 kame)
2581 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002582 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002583#include <netinet/in.h>
2584#ifdef __KAME__
2585yes
2586#endif],
2587 [ipv6type=$i;
2588 ipv6lib=inet6
2589 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002590 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002591 ;;
2592 linux-glibc)
2593 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002594 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002595#include <features.h>
2596#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2597yes
2598#endif],
2599 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002600 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002601 ;;
2602 linux-inet6)
2603 dnl http://www.v6.linux.or.jp/
2604 if test -d /usr/inet6; then
2605 ipv6type=$i
2606 ipv6lib=inet6
2607 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002608 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002609 fi
2610 ;;
2611 solaris)
2612 if test -f /etc/netconfig; then
Antoine Pitrou31e85952011-01-03 18:57:14 +00002613 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002614 ipv6type=$i
2615 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002616 fi
2617 fi
2618 ;;
2619 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002620 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002621#include <sys/param.h>
2622#ifdef _TOSHIBA_INET6
2623yes
2624#endif],
2625 [ipv6type=$i;
2626 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002627 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002628 ;;
2629 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002630 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002631#include </usr/local/v6/include/sys/v6config.h>
2632#ifdef __V6D__
2633yes
2634#endif],
2635 [ipv6type=$i;
2636 ipv6lib=v6;
2637 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002638 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002639 ;;
2640 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002641 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002642#include <sys/param.h>
2643#ifdef _ZETA_MINAMI_INET6
2644yes
2645#endif],
2646 [ipv6type=$i;
2647 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002648 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002649 ;;
2650 esac
2651 if test "$ipv6type" != "unknown"; then
2652 break
2653 fi
2654 done
2655 AC_MSG_RESULT($ipv6type)
2656fi
2657
2658if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2659 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2660 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2661 echo "using lib$ipv6lib"
2662 else
2663 if test $ipv6trylibc = "yes"; then
2664 echo "using libc"
2665 else
2666 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2667 echo "You need to fetch lib$ipv6lib.a from appropriate"
2668 echo 'ipv6 kit and compile beforehand.'
2669 exit 1
2670 fi
2671 fi
2672fi
2673
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002674AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Klosec511b472010-05-08 11:01:39 +00002675AC_COMPILE_IFELSE([
Mark Dickinson0712b562010-05-08 19:13:21 +00002676 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
Matthias Klosec511b472010-05-08 11:01:39 +00002677],[
Matthias Klose5183ebd2010-04-24 16:38:36 +00002678 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Klosec511b472010-05-08 11:01:39 +00002679 AC_MSG_RESULT(yes)
2680],[
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002681 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00002682])
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002683
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002684# Check for --with-doc-strings
2685AC_MSG_CHECKING(for --with-doc-strings)
2686AC_ARG_WITH(doc-strings,
Matthias Klose22520ea2010-05-08 10:14:46 +00002687 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002688
2689if test -z "$with_doc_strings"
2690then with_doc_strings="yes"
2691fi
2692if test "$with_doc_strings" != "no"
2693then
2694 AC_DEFINE(WITH_DOC_STRINGS, 1,
2695 [Define if you want documentation strings in extension modules])
2696fi
2697AC_MSG_RESULT($with_doc_strings)
2698
Neil Schemenauera35c6882001-02-27 04:45:05 +00002699# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002700AC_MSG_CHECKING(for --with-tsc)
2701AC_ARG_WITH(tsc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002702 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002703if test "$withval" != no
2704then
2705 AC_DEFINE(WITH_TSC, 1,
2706 [Define to profile with the Pentium timestamp counter])
2707 AC_MSG_RESULT(yes)
2708else AC_MSG_RESULT(no)
2709fi],
2710[AC_MSG_RESULT(no)])
2711
2712# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002713AC_MSG_CHECKING(for --with-pymalloc)
2714AC_ARG_WITH(pymalloc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002715 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002716
2717if test -z "$with_pymalloc"
2718then with_pymalloc="yes"
2719fi
2720if test "$with_pymalloc" != "no"
2721then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002722 AC_DEFINE(WITH_PYMALLOC, 1,
2723 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002724fi
2725AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002726
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002727# Check for Valgrind support
2728AC_MSG_CHECKING([for --with-valgrind])
2729AC_ARG_WITH([valgrind],
Matthias Klose22520ea2010-05-08 10:14:46 +00002730 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002731 with_valgrind=no)
2732AC_MSG_RESULT([$with_valgrind])
2733if test "$with_valgrind" != no; then
2734 AC_CHECK_HEADER([valgrind/valgrind.h],
2735 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2736 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2737 )
2738fi
2739
Barry Warsawef82cd72000-06-30 16:21:01 +00002740# Check for --with-wctype-functions
2741AC_MSG_CHECKING(for --with-wctype-functions)
2742AC_ARG_WITH(wctype-functions,
Matthias Klose22520ea2010-05-08 10:14:46 +00002743 AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002744[
Barry Warsawef82cd72000-06-30 16:21:01 +00002745if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002746then
2747 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2748 [Define if you want wctype.h functions to be used instead of the
2749 one supplied by Python itself. (see Include/unicodectype.h).])
2750 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002751else AC_MSG_RESULT(no)
2752fi],
2753[AC_MSG_RESULT(no)])
2754
Guido van Rossum68242b51996-05-28 22:53:03 +00002755# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002756AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002757DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002758
Guido van Rossume97ee181999-12-20 21:27:22 +00002759# the dlopen() function means we might want to use dynload_shlib.o. some
2760# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002761AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002762
2763# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2764# loading of modules.
2765AC_SUBST(DYNLOADFILE)
2766AC_MSG_CHECKING(DYNLOADFILE)
2767if test -z "$DYNLOADFILE"
2768then
2769 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002770 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2771 if test "$ac_cv_func_dlopen" = yes
2772 then DYNLOADFILE="dynload_shlib.o"
2773 else DYNLOADFILE="dynload_aix.o"
2774 fi
2775 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002776 BeOS*) DYNLOADFILE="dynload_beos.o";;
2777 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00002778 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2779 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002780 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002781 *)
2782 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2783 # out any dynamic loading
2784 if test "$ac_cv_func_dlopen" = yes
2785 then DYNLOADFILE="dynload_shlib.o"
2786 else DYNLOADFILE="dynload_stub.o"
2787 fi
2788 ;;
2789 esac
2790fi
2791AC_MSG_RESULT($DYNLOADFILE)
2792if test "$DYNLOADFILE" != "dynload_stub.o"
2793then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002794 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2795 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002796fi
2797
Jack Jansenc49e5b72001-06-19 15:00:23 +00002798# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2799
2800AC_SUBST(MACHDEP_OBJS)
2801AC_MSG_CHECKING(MACHDEP_OBJS)
2802if test -z "$MACHDEP_OBJS"
2803then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002804 MACHDEP_OBJS=$extra_machdep_objs
2805else
2806 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002807fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002808AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002809
Guido van Rossum627b2d71993-12-24 10:39:16 +00002810# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00002811AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2812 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002813 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002814 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Antoine Pitrou30b3b352009-12-02 20:37:54 +00002815 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002816 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002817 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00002818 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2819 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002820 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002821 setlocale setregid setreuid setresuid setresgid \
2822 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00002823 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002824 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00002825 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002826
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002827# For some functions, having a definition is not sufficient, since
2828# we want to take their address.
2829AC_MSG_CHECKING(for chroot)
Matthias Klosec511b472010-05-08 11:01:39 +00002830AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
2831 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2832 AC_MSG_RESULT(yes)],
2833 [AC_MSG_RESULT(no)
2834])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002835AC_MSG_CHECKING(for link)
Matthias Klosec511b472010-05-08 11:01:39 +00002836AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
2837 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2838 AC_MSG_RESULT(yes)],
2839 [AC_MSG_RESULT(no)
2840])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002841AC_MSG_CHECKING(for symlink)
Matthias Klosec511b472010-05-08 11:01:39 +00002842AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
2843 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2844 AC_MSG_RESULT(yes)],
2845 [AC_MSG_RESULT(no)
2846])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002847AC_MSG_CHECKING(for fchdir)
Matthias Klosec511b472010-05-08 11:01:39 +00002848AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
2849 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2850 AC_MSG_RESULT(yes)],
2851 [AC_MSG_RESULT(no)
2852])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002853AC_MSG_CHECKING(for fsync)
Matthias Klosec511b472010-05-08 11:01:39 +00002854AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
2855 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2856 AC_MSG_RESULT(yes)],
2857 [AC_MSG_RESULT(no)
2858])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002859AC_MSG_CHECKING(for fdatasync)
Matthias Klosec511b472010-05-08 11:01:39 +00002860AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
2861 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2862 AC_MSG_RESULT(yes)],
2863 [AC_MSG_RESULT(no)
2864])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002865AC_MSG_CHECKING(for epoll)
Matthias Klosec511b472010-05-08 11:01:39 +00002866AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
2867 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2868 AC_MSG_RESULT(yes)],
2869 [AC_MSG_RESULT(no)
2870])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002871AC_MSG_CHECKING(for kqueue)
Matthias Klosec511b472010-05-08 11:01:39 +00002872AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002873#include <sys/types.h>
2874#include <sys/event.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002875 ]], [[int x=kqueue()]])],
2876 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2877 AC_MSG_RESULT(yes)],
2878 [AC_MSG_RESULT(no)
2879])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002880# On some systems (eg. FreeBSD 5), we would find a definition of the
2881# functions ctermid_r, setgroups in the library, but no prototype
2882# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2883# address to avoid compiler warnings and potential miscompilations
2884# because of the missing prototypes.
2885
2886AC_MSG_CHECKING(for ctermid_r)
Matthias Klosec511b472010-05-08 11:01:39 +00002887AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00002888#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002889]], [[void* p = ctermid_r]])],
2890 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2891 AC_MSG_RESULT(yes)],
2892 [AC_MSG_RESULT(no)
2893])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002894
Antoine Pitroub170f172010-09-10 18:47:36 +00002895AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
2896 [AC_COMPILE_IFELSE(
2897 [AC_LANG_PROGRAM(
2898 [#include <sys/file.h>],
2899 [void* p = flock]
2900 )],
2901 [ac_cv_flock_decl=yes],
2902 [ac_cv_flock_decl=no]
2903 )
Matthias Klosec511b472010-05-08 11:01:39 +00002904])
Antoine Pitroub170f172010-09-10 18:47:36 +00002905if test "x${ac_cv_flock_decl}" = xyes; then
2906 AC_CHECK_FUNCS(flock,,
2907 AC_CHECK_LIB(bsd,flock,
2908 [AC_DEFINE(HAVE_FLOCK)
2909 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
2910 ])
2911 )
Antoine Pitrou85729812010-09-07 14:55:24 +00002912fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002913
2914AC_MSG_CHECKING(for getpagesize)
Matthias Klosec511b472010-05-08 11:01:39 +00002915AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002916#include <unistd.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002917]], [[void* p = getpagesize]])],
2918 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2919 AC_MSG_RESULT(yes)],
2920 [AC_MSG_RESULT(no)
2921])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002922
Charles-François Natali93a11752011-11-27 13:01:35 +01002923AC_MSG_CHECKING(for broken unsetenv)
2924AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2925#include <stdlib.h>
2926]], [[int res = unsetenv("DUMMY")]])],
2927 [AC_MSG_RESULT(no)],
2928 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
2929 AC_MSG_RESULT(yes)
2930])
2931
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002932dnl check for true
2933AC_CHECK_PROGS(TRUE, true, /bin/true)
2934
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002935dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2936dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002937AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002938 AC_CHECK_LIB(resolv, inet_aton)
2939)
2940
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002941# On Tru64, chflags seems to be present, but calling it will
2942# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00002943AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07002944AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002945#include <sys/stat.h>
2946#include <unistd.h>
2947int main(int argc, char*argv[])
2948{
2949 if(chflags(argv[0], 0) != 0)
2950 return 1;
2951 return 0;
2952}
Ned Deily43e10542011-06-27 23:41:53 -07002953]])],
Matthias Klosec511b472010-05-08 11:01:39 +00002954[ac_cv_have_chflags=yes],
2955[ac_cv_have_chflags=no],
2956[ac_cv_have_chflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00002957])
2958if test "$ac_cv_have_chflags" = cross ; then
2959 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2960fi
2961if test "$ac_cv_have_chflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07002962 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002963fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002964
Gregory P. Smithbb213892009-11-02 01:37:37 +00002965AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07002966AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002967#include <sys/stat.h>
2968#include <unistd.h>
2969int main(int argc, char*argv[])
2970{
2971 if(lchflags(argv[0], 0) != 0)
2972 return 1;
2973 return 0;
2974}
Ned Deily43e10542011-06-27 23:41:53 -07002975]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00002976])
2977if test "$ac_cv_have_lchflags" = cross ; then
2978 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2979fi
2980if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07002981 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002982fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002983
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00002984dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00002985dnl
2986dnl On MacOSX the linker will search for dylibs on the entire linker path
2987dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2988dnl to revert to a more traditional unix behaviour and make it possible to
2989dnl override the system libz with a local static library of libz. Temporarily
2990dnl add that flag to our CFLAGS as well to ensure that we check the version
2991dnl of libz that will be used by setup.py.
2992dnl The -L/usr/local/lib is needed as wel to get the same compilation
2993dnl environment as setup.py (and leaving it out can cause configure to use the
2994dnl wrong version of the library)
2995case $ac_sys_system/$ac_sys_release in
2996Darwin/*)
2997 _CUR_CFLAGS="${CFLAGS}"
2998 _CUR_LDFLAGS="${LDFLAGS}"
2999 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
3000 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
3001 ;;
3002esac
3003
Matthias Klose5183ebd2010-04-24 16:38:36 +00003004AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003005
Ronald Oussorenf8752642006-07-06 10:13:35 +00003006case $ac_sys_system/$ac_sys_release in
3007Darwin/*)
3008 CFLAGS="${_CUR_CFLAGS}"
3009 LDFLAGS="${_CUR_LDFLAGS}"
3010 ;;
3011esac
3012
Martin v. Löwise9416172003-05-03 10:12:45 +00003013AC_MSG_CHECKING(for hstrerror)
Matthias Klosec511b472010-05-08 11:01:39 +00003014AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00003015#include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003016]], [[void* p = hstrerror; hstrerror(0)]])],
3017 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
3018 AC_MSG_RESULT(yes)],
3019 [AC_MSG_RESULT(no)
3020])
Martin v. Löwise9416172003-05-03 10:12:45 +00003021
3022AC_MSG_CHECKING(for inet_aton)
Matthias Klosec511b472010-05-08 11:01:39 +00003023AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00003024#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003025#include <sys/socket.h>
3026#include <netinet/in.h>
3027#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003028]], [[void* p = inet_aton;inet_aton(0,0)]])],
3029 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
3030 AC_MSG_RESULT(yes)],
3031 [AC_MSG_RESULT(no)
3032])
Martin v. Löwise9416172003-05-03 10:12:45 +00003033
3034AC_MSG_CHECKING(for inet_pton)
Matthias Klosec511b472010-05-08 11:01:39 +00003035AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003036#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003037#include <sys/socket.h>
3038#include <netinet/in.h>
3039#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003040]], [[void* p = inet_pton]])],
3041 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
3042 AC_MSG_RESULT(yes)],
3043 [AC_MSG_RESULT(no)
3044])
Martin v. Löwise9416172003-05-03 10:12:45 +00003045
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003046# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00003047AC_MSG_CHECKING(for setgroups)
Matthias Klosec511b472010-05-08 11:01:39 +00003048AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003049#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003050#ifdef HAVE_GRP_H
3051#include <grp.h>
3052#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003053]], [[void* p = setgroups]])],
3054 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
3055 AC_MSG_RESULT(yes)],
3056 [AC_MSG_RESULT(no)
3057])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003058
Fred Drake8cef4cf2000-06-28 16:40:38 +00003059# check for openpty and forkpty
3060
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00003061AC_CHECK_FUNCS(openpty,,
3062 AC_CHECK_LIB(util,openpty,
3063 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
3064 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
3065 )
3066)
3067AC_CHECK_FUNCS(forkpty,,
3068 AC_CHECK_LIB(util,forkpty,
3069 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
3070 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
3071 )
3072)
Fred Drake8cef4cf2000-06-28 16:40:38 +00003073
Brett Cannonaa5778d2008-03-18 04:09:00 +00003074# Stuff for expat.
3075AC_CHECK_FUNCS(memmove)
3076
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003077# check for long file support functions
3078AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
3079
Brett Cannonaa5778d2008-03-18 04:09:00 +00003080AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003081AC_CHECK_FUNCS(getpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003082 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
3083 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
3084 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003085)
Jack Jansen150753c2003-03-29 22:07:47 +00003086AC_CHECK_FUNCS(setpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003087 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
3088 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
3089 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003090)
3091AC_CHECK_FUNCS(gettimeofday,
Matthias Klosec511b472010-05-08 11:01:39 +00003092 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
3093 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
3094 [],
3095 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
3096 [Define if gettimeofday() does not have second (timezone) argument
3097 This is the case on Motorola V4 (R40V4.2)])
3098 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003099)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003100
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003101AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00003102AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00003103#if defined(MAJOR_IN_MKDEV)
3104#include <sys/mkdev.h>
3105#elif defined(MAJOR_IN_SYSMACROS)
3106#include <sys/sysmacros.h>
3107#else
3108#include <sys/types.h>
3109#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003110]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003111 makedev(major(0),minor(0));
Matthias Klosec511b472010-05-08 11:01:39 +00003112]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003113 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3114 [Define to 1 if you have the device macros.])
3115 AC_MSG_RESULT(yes)
3116],[
3117 AC_MSG_RESULT(no)
3118])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003119
3120# On OSF/1 V5.1, getaddrinfo is available, but a define
3121# for [no]getaddrinfo in netdb.h.
3122AC_MSG_CHECKING(for getaddrinfo)
Matthias Klosec511b472010-05-08 11:01:39 +00003123AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003124#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003125#include <sys/socket.h>
3126#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003127#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003128]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
3129[have_getaddrinfo=yes],
3130[have_getaddrinfo=no])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003131AC_MSG_RESULT($have_getaddrinfo)
3132if test $have_getaddrinfo = yes
3133then
3134 AC_MSG_CHECKING(getaddrinfo bug)
3135 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003136 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Stefan Krah0afe4e42012-11-22 23:56:51 +01003137#include <stdio.h>
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003138#include <sys/types.h>
3139#include <netdb.h>
3140#include <string.h>
3141#include <sys/socket.h>
3142#include <netinet/in.h>
3143
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003144int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003145{
3146 int passive, gaierr, inet4 = 0, inet6 = 0;
3147 struct addrinfo hints, *ai, *aitop;
3148 char straddr[INET6_ADDRSTRLEN], strport[16];
3149
3150 for (passive = 0; passive <= 1; passive++) {
3151 memset(&hints, 0, sizeof(hints));
3152 hints.ai_family = AF_UNSPEC;
3153 hints.ai_flags = passive ? AI_PASSIVE : 0;
3154 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00003155 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003156 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3157 (void)gai_strerror(gaierr);
3158 goto bad;
3159 }
3160 for (ai = aitop; ai; ai = ai->ai_next) {
3161 if (ai->ai_addr == NULL ||
3162 ai->ai_addrlen == 0 ||
3163 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3164 straddr, sizeof(straddr), strport, sizeof(strport),
3165 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3166 goto bad;
3167 }
3168 switch (ai->ai_family) {
3169 case AF_INET:
3170 if (strcmp(strport, "54321") != 0) {
3171 goto bad;
3172 }
3173 if (passive) {
3174 if (strcmp(straddr, "0.0.0.0") != 0) {
3175 goto bad;
3176 }
3177 } else {
3178 if (strcmp(straddr, "127.0.0.1") != 0) {
3179 goto bad;
3180 }
3181 }
3182 inet4++;
3183 break;
3184 case AF_INET6:
3185 if (strcmp(strport, "54321") != 0) {
3186 goto bad;
3187 }
3188 if (passive) {
3189 if (strcmp(straddr, "::") != 0) {
3190 goto bad;
3191 }
3192 } else {
3193 if (strcmp(straddr, "::1") != 0) {
3194 goto bad;
3195 }
3196 }
3197 inet6++;
3198 break;
3199 case AF_UNSPEC:
3200 goto bad;
3201 break;
3202 default:
3203 /* another family support? */
3204 break;
3205 }
3206 }
3207 }
3208
3209 if (!(inet4 == 0 || inet4 == 2))
3210 goto bad;
3211 if (!(inet6 == 0 || inet6 == 2))
3212 goto bad;
3213
3214 if (aitop)
3215 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003216 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003217
3218 bad:
3219 if (aitop)
3220 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003221 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003222}
Matthias Klosec511b472010-05-08 11:01:39 +00003223]]])],
3224[ac_cv_buggy_getaddrinfo=no],
3225[ac_cv_buggy_getaddrinfo=yes],
3226[ac_cv_buggy_getaddrinfo=yes]))
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003227fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003228
Benjamin Peterson75fed812010-11-01 01:47:19 +00003229AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3230
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003231if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003232then
3233 if test $ipv6 = yes
3234 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003235 echo 'Fatal: You must get working getaddrinfo() function.'
3236 echo ' or you can specify "--disable-ipv6"'.
3237 exit 1
3238 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003239else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003240 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003241fi
Benjamin Peterson75fed812010-11-01 01:47:19 +00003242
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003243AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003244
Guido van Rossum627b2d71993-12-24 10:39:16 +00003245# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003246AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003247AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003248AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003249AC_CHECK_MEMBERS([struct stat.st_rdev])
3250AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003251AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003252AC_CHECK_MEMBERS([struct stat.st_gen])
3253AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003254AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003255
3256AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Klosec511b472010-05-08 11:01:39 +00003257AC_CACHE_VAL(ac_cv_header_time_altzone,[
3258 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3259 [ac_cv_header_time_altzone=yes],
3260 [ac_cv_header_time_altzone=no])
3261 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003262AC_MSG_RESULT($ac_cv_header_time_altzone)
3263if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003264 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003265fi
3266
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003267was_it_defined=no
3268AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Klosec511b472010-05-08 11:01:39 +00003269AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003270#include <sys/types.h>
3271#include <sys/select.h>
3272#include <sys/time.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003273]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003274 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3275 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3276 (which you can't on SCO ODT 3.0).])
3277 was_it_defined=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003278],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003279AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003280
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003281AC_MSG_CHECKING(for addrinfo)
3282AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003283AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3284 [ac_cv_struct_addrinfo=yes],
3285 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003286AC_MSG_RESULT($ac_cv_struct_addrinfo)
3287if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003288 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003289fi
3290
3291AC_MSG_CHECKING(for sockaddr_storage)
3292AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Klosec511b472010-05-08 11:01:39 +00003293AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003294# include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003295# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3296 [ac_cv_struct_sockaddr_storage=yes],
3297 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003298AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3299if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003300 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003301fi
3302
Guido van Rossum627b2d71993-12-24 10:39:16 +00003303# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003304
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003305AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003306AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003307
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003308works=no
3309AC_MSG_CHECKING(for working volatile)
Matthias Klosec511b472010-05-08 11:01:39 +00003310AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3311 [works=yes],
3312 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003313)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003314AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003315
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003316works=no
3317AC_MSG_CHECKING(for working signed char)
Matthias Klosec511b472010-05-08 11:01:39 +00003318AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3319 [works=yes],
3320 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003321)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003322AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003323
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003324have_prototypes=no
3325AC_MSG_CHECKING(for prototypes)
Matthias Klosec511b472010-05-08 11:01:39 +00003326AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3327 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3328 [Define if your compiler supports function prototype])
3329 have_prototypes=yes],
3330 []
3331)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003332AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003333
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003334works=no
3335AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Klosec511b472010-05-08 11:01:39 +00003336AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003337#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003338int foo(int x, ...) {
3339 va_list va;
3340 va_start(va, x);
3341 va_arg(va, int);
3342 va_arg(va, char *);
3343 va_arg(va, double);
3344 return 0;
3345}
Matthias Klosec511b472010-05-08 11:01:39 +00003346]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003347 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3348 [Define if your compiler supports variable length function prototypes
3349 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3350 works=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003351],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003352AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003353
Dave Cole331708b2004-08-09 04:51:41 +00003354# check for socketpair
3355AC_MSG_CHECKING(for socketpair)
Matthias Klosec511b472010-05-08 11:01:39 +00003356AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003357#include <sys/types.h>
3358#include <sys/socket.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003359]], [[void *x=socketpair]])],
3360 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3361 AC_MSG_RESULT(yes)],
3362 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003363)
3364
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003365# check if sockaddr has sa_len member
3366AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Klosec511b472010-05-08 11:01:39 +00003367AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3368#include <sys/socket.h>]], [[struct sockaddr x;
3369x.sa_len = 0;]])],
3370 [AC_MSG_RESULT(yes)
3371 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3372 [AC_MSG_RESULT(no)]
3373)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003374
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003375va_list_is_array=no
3376AC_MSG_CHECKING(whether va_list is an array)
Matthias Klosec511b472010-05-08 11:01:39 +00003377AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003378#ifdef HAVE_STDARG_PROTOTYPES
3379#include <stdarg.h>
3380#else
3381#include <varargs.h>
3382#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003383]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003384 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3385 va_list_is_array=yes
3386])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003387AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003388
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003389# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003390AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3391 [Define this if you have some version of gethostbyname_r()])
3392
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003393AC_CHECK_FUNC(gethostbyname_r, [
3394 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3395 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3396 OLD_CFLAGS=$CFLAGS
3397 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003398 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003399# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003400 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003401 char *name;
3402 struct hostent *he, *res;
3403 char buffer[2048];
3404 int buflen = 2048;
3405 int h_errnop;
3406
3407 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Klosec511b472010-05-08 11:01:39 +00003408 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003409 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003410 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3411 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003412 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00003413 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003414 AC_MSG_RESULT(no)
3415 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Klosec511b472010-05-08 11:01:39 +00003416 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003417# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003418 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003419 char *name;
3420 struct hostent *he;
Matthias Klosec511b472010-05-08 11:01:39 +00003421 char buffer[2048];
3422 int buflen = 2048;
3423 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003424
Matthias Klosec511b472010-05-08 11:01:39 +00003425 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3426 ]])],
3427 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003428 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Klosec511b472010-05-08 11:01:39 +00003429 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3430 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003431 AC_MSG_RESULT(yes)
3432 ], [
3433 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00003434 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3435 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3436# include <netdb.h>
3437 ]], [[
3438 char *name;
3439 struct hostent *he;
3440 struct hostent_data data;
3441
3442 (void) gethostbyname_r(name, he, &data);
3443 ]])],
3444 [
3445 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3446 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3447 [Define this if you have the 3-arg version of gethostbyname_r().])
3448 AC_MSG_RESULT(yes)
3449 ], [
3450 AC_MSG_RESULT(no)
3451 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003452 ])
3453 ])
3454 CFLAGS=$OLD_CFLAGS
3455], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003456 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003457])
3458AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3459AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3460AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003461AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003462AC_SUBST(HAVE_GETHOSTBYNAME)
3463
Guido van Rossum627b2d71993-12-24 10:39:16 +00003464# checks for system services
3465# (none yet)
3466
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003467# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003468AC_CHECK_FUNC(__fpu_control,
3469 [],
3470 [AC_CHECK_LIB(ieee, __fpu_control)
3471])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003472
Guido van Rossum93274221997-05-09 02:42:00 +00003473# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003474AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003475AC_ARG_WITH(fpectl,
Matthias Klose22520ea2010-05-08 10:14:46 +00003476 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003477[
Guido van Rossum93274221997-05-09 02:42:00 +00003478if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003479then
3480 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3481 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3482 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003483else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003484fi],
3485[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003486
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003487# check for --with-libm=...
3488AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003489case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003490Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003491BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003492*) LIBM=-lm
3493esac
Guido van Rossum93274221997-05-09 02:42:00 +00003494AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003495AC_ARG_WITH(libm,
Matthias Klose22520ea2010-05-08 10:14:46 +00003496 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003497[
Guido van Rossum93274221997-05-09 02:42:00 +00003498if test "$withval" = no
3499then LIBM=
3500 AC_MSG_RESULT(force LIBM empty)
3501elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003502then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003503 AC_MSG_RESULT(set LIBM="$withval")
3504else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003505fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003506[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003507
3508# check for --with-libc=...
3509AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003510AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003511AC_ARG_WITH(libc,
Matthias Klose22520ea2010-05-08 10:14:46 +00003512 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003513[
Guido van Rossum93274221997-05-09 02:42:00 +00003514if test "$withval" = no
3515then LIBC=
3516 AC_MSG_RESULT(force LIBC empty)
3517elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003518then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003519 AC_MSG_RESULT(set LIBC="$withval")
3520else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003521fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003522[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003523
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003524# **************************************************
3525# * Check for various properties of floating point *
3526# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003527
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003528AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3529AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003530AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003531#include <string.h>
3532int main() {
3533 double x = 9006104071832581.0;
3534 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3535 return 0;
3536 else
3537 return 1;
3538}
Matthias Klosec511b472010-05-08 11:01:39 +00003539]])],
3540[ac_cv_little_endian_double=yes],
3541[ac_cv_little_endian_double=no],
3542[ac_cv_little_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003543AC_MSG_RESULT($ac_cv_little_endian_double)
3544if test "$ac_cv_little_endian_double" = yes
3545then
3546 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3547 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3548 with the least significant byte first])
3549fi
3550
3551AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3552AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003553AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003554#include <string.h>
3555int main() {
3556 double x = 9006104071832581.0;
3557 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3558 return 0;
3559 else
3560 return 1;
3561}
Matthias Klosec511b472010-05-08 11:01:39 +00003562]])],
3563[ac_cv_big_endian_double=yes],
3564[ac_cv_big_endian_double=no],
3565[ac_cv_big_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003566AC_MSG_RESULT($ac_cv_big_endian_double)
3567if test "$ac_cv_big_endian_double" = yes
3568then
3569 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3570 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3571 with the most significant byte first])
3572fi
3573
3574# Some ARM platforms use a mixed-endian representation for doubles.
3575# While Python doesn't currently have full support for these platforms
3576# (see e.g., issue 1762561), we can at least make sure that float <-> string
3577# conversions work.
3578AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3579AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003580AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003581#include <string.h>
3582int main() {
3583 double x = 9006104071832581.0;
3584 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3585 return 0;
3586 else
3587 return 1;
3588}
Matthias Klosec511b472010-05-08 11:01:39 +00003589]])],
3590[ac_cv_mixed_endian_double=yes],
3591[ac_cv_mixed_endian_double=no],
3592[ac_cv_mixed_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003593AC_MSG_RESULT($ac_cv_mixed_endian_double)
3594if test "$ac_cv_mixed_endian_double" = yes
3595then
3596 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3597 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3598 in ARM mixed-endian order (byte order 45670123)])
3599fi
3600
3601# The short float repr introduced in Python 3.1 requires the
3602# correctly-rounded string <-> double conversion functions from
3603# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3604# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003605# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003606# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003607
3608# This inline assembler syntax may also work for suncc and icc,
3609# so we try it on all platforms.
3610
3611AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Matthias Klosec511b472010-05-08 11:01:39 +00003612AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsona548dee2009-11-15 13:12:43 +00003613 unsigned short cw;
3614 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3615 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Klosec511b472010-05-08 11:01:39 +00003616]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsona548dee2009-11-15 13:12:43 +00003617AC_MSG_RESULT($have_gcc_asm_for_x87)
3618if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003619then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003620 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3621 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003622fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003623
Mark Dickinson04b27232009-01-04 12:29:36 +00003624# Detect whether system arithmetic is subject to x87-style double
3625# rounding issues. The result of this test has little meaning on non
3626# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3627# mode is round-to-nearest and double rounding issues are present, and
3628# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3629AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003630# $BASECFLAGS may affect the result
3631ac_save_cc="$CC"
3632CC="$CC $BASECFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003633AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson04b27232009-01-04 12:29:36 +00003634#include <stdlib.h>
3635#include <math.h>
3636int main() {
3637 volatile double x, y, z;
3638 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3639 x = 0.99999999999999989; /* 1-2**-53 */
3640 y = 1./x;
3641 if (y != 1.)
3642 exit(0);
3643 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3644 x = 1e16;
3645 y = 2.99999;
3646 z = x + y;
3647 if (z != 1e16+4.)
3648 exit(0);
3649 /* both tests show evidence of double rounding */
3650 exit(1);
3651}
Matthias Klosec511b472010-05-08 11:01:39 +00003652]])],
3653[ac_cv_x87_double_rounding=no],
3654[ac_cv_x87_double_rounding=yes],
3655[ac_cv_x87_double_rounding=no])
Mark Dickinson99abd142009-10-24 13:44:16 +00003656CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003657AC_MSG_RESULT($ac_cv_x87_double_rounding)
3658if test "$ac_cv_x87_double_rounding" = yes
3659then
3660 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3661 [Define if arithmetic is subject to x87-style double rounding issue])
3662fi
3663
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003664# ************************************
3665# * Check for mathematical functions *
3666# ************************************
3667
3668LIBS_SAVE=$LIBS
3669LIBS="$LIBS $LIBM"
3670
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003671# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3672# -0. on some architectures.
3673AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3674AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003675AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003676#include <math.h>
3677#include <stdlib.h>
3678int main() {
3679 /* return 0 if either negative zeros don't exist
3680 on this platform or if negative zeros exist
3681 and tanh(-0.) == -0. */
3682 if (atan2(0., -1.) == atan2(-0., -1.) ||
3683 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3684 else exit(1);
3685}
Matthias Klosec511b472010-05-08 11:01:39 +00003686]])],
3687[ac_cv_tanh_preserves_zero_sign=yes],
3688[ac_cv_tanh_preserves_zero_sign=no],
3689[ac_cv_tanh_preserves_zero_sign=no])])
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003690AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3691if test "$ac_cv_tanh_preserves_zero_sign" = yes
3692then
3693 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3694 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3695fi
3696
3697AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3698AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3699AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3700
3701LIBS=$LIBS_SAVE
3702
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003703# For multiprocessing module, check that sem_open
3704# actually works. For FreeBSD versions <= 7.2,
3705# the kernel module that provides POSIX semaphores
3706# isn't loaded by default, so an attempt to call
3707# sem_open results in a 'Signal 12' error.
3708AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3709AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Klosec511b472010-05-08 11:01:39 +00003710AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003711#include <unistd.h>
3712#include <fcntl.h>
3713#include <stdio.h>
3714#include <semaphore.h>
3715#include <sys/stat.h>
3716
3717int main(void) {
3718 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3719 if (a == SEM_FAILED) {
3720 perror("sem_open");
3721 return 1;
3722 }
3723 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003724 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003725 return 0;
3726}
Matthias Klosec511b472010-05-08 11:01:39 +00003727]])],
3728[ac_cv_posix_semaphores_enabled=yes],
3729[ac_cv_posix_semaphores_enabled=no],
3730[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003731)
3732AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3733if test $ac_cv_posix_semaphores_enabled = no
3734then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00003735 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3736 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003737fi
3738
Jesse Noller355b1262009-04-02 00:03:28 +00003739# Multiprocessing check for broken sem_getvalue
3740AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003741AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Klosec511b472010-05-08 11:01:39 +00003742AC_RUN_IFELSE([AC_LANG_SOURCE([[
Jesse Noller355b1262009-04-02 00:03:28 +00003743#include <unistd.h>
3744#include <fcntl.h>
3745#include <stdio.h>
3746#include <semaphore.h>
3747#include <sys/stat.h>
3748
3749int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003750 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00003751 int count;
3752 int res;
3753 if(a==SEM_FAILED){
3754 perror("sem_open");
3755 return 1;
3756
3757 }
3758 res = sem_getvalue(a, &count);
3759 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003760 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00003761 return res==-1 ? 1 : 0;
3762}
Matthias Klosec511b472010-05-08 11:01:39 +00003763]])],
3764[ac_cv_broken_sem_getvalue=no],
3765[ac_cv_broken_sem_getvalue=yes],
3766[ac_cv_broken_sem_getvalue=yes])
Jesse Noller355b1262009-04-02 00:03:28 +00003767)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003768AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3769if test $ac_cv_broken_sem_getvalue = yes
3770then
3771 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3772 [define to 1 if your sem_getvalue is broken.])
3773fi
Mark Dickinson04b27232009-01-04 12:29:36 +00003774
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003775# determine what size digit to use for Python's longs
3776AC_MSG_CHECKING([digit size for Python's longs])
3777AC_ARG_ENABLE(big-digits,
Matthias Klose22520ea2010-05-08 10:14:46 +00003778AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003779[case $enable_big_digits in
3780yes)
3781 enable_big_digits=30 ;;
3782no)
3783 enable_big_digits=15 ;;
3784[15|30])
3785 ;;
3786*)
3787 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3788esac
3789AC_MSG_RESULT($enable_big_digits)
3790AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3791],
3792[AC_MSG_RESULT(no value specified)])
3793
Guido van Rossumef2255b2000-03-10 22:30:29 +00003794# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003795AC_CHECK_HEADER(wchar.h, [
3796 AC_DEFINE(HAVE_WCHAR_H, 1,
3797 [Define if the compiler provides a wchar.h header file.])
3798 wchar_h="yes"
3799],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003800wchar_h="no"
3801)
3802
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003803# determine wchar_t size
3804if test "$wchar_h" = yes
3805then
Guido van Rossum67b26592001-10-20 14:21:45 +00003806 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003807fi
3808
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003809AC_MSG_CHECKING(for UCS-4 tcl)
3810have_ucs4_tcl=no
Matthias Klosec511b472010-05-08 11:01:39 +00003811AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003812#include <tcl.h>
3813#if TCL_UTF_MAX != 6
3814# error "NOT UCS4_TCL"
Matthias Klosec511b472010-05-08 11:01:39 +00003815#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003816 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3817 have_ucs4_tcl=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003818],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003819AC_MSG_RESULT($have_ucs4_tcl)
3820
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003821# check whether wchar_t is signed or not
3822if test "$wchar_h" = yes
3823then
3824 # check whether wchar_t is signed or not
3825 AC_MSG_CHECKING(whether wchar_t is signed)
3826 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Klosec511b472010-05-08 11:01:39 +00003827 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003828 #include <wchar.h>
3829 int main()
3830 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00003831 /* Success: exit code 0 */
3832 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003833 }
Matthias Klosec511b472010-05-08 11:01:39 +00003834 ]])],
3835 [ac_cv_wchar_t_signed=yes],
3836 [ac_cv_wchar_t_signed=no],
3837 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003838 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3839fi
3840
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003841AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003842dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003843AC_ARG_ENABLE(unicode,
Benjamin Peterson66556b02010-05-25 02:23:32 +00003844 AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003845 [],
3846 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003847
3848if test $enable_unicode = yes
3849then
Martin v. Löwisfd917792001-06-27 20:22:04 +00003850 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003851 case "$have_ucs4_tcl" in
3852 yes) enable_unicode="ucs4"
3853 ;;
3854 *) enable_unicode="ucs2"
3855 ;;
3856 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003857fi
3858
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003859AH_TEMPLATE(Py_UNICODE_SIZE,
3860 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003861case "$enable_unicode" in
3862ucs2) unicode_size="2"
3863 AC_DEFINE(Py_UNICODE_SIZE,2)
3864 ;;
3865ucs4) unicode_size="4"
3866 AC_DEFINE(Py_UNICODE_SIZE,4)
3867 ;;
Martin v. Löwised11a5d2012-05-20 10:42:17 +02003868no) ;; # To allow --disable-unicode
Ezio Melotti5820efb2010-02-27 00:05:42 +00003869*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003870esac
3871
Martin v. Löwis11437992002-04-12 09:54:03 +00003872AH_TEMPLATE(PY_UNICODE_TYPE,
3873 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003874
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003875AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003876if test "$enable_unicode" = "no"
3877then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003878 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003879 AC_MSG_RESULT(not used)
3880else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003881 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003882 AC_DEFINE(Py_USING_UNICODE, 1,
3883 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003884
3885 # wchar_t is only usable if it maps to an unsigned type
3886 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003887 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003888 then
3889 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003890 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3891 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003892 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003893 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003894 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3895 elif test "$ac_cv_sizeof_short" = "$unicode_size"
3896 then
3897 PY_UNICODE_TYPE="unsigned short"
3898 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3899 elif test "$ac_cv_sizeof_long" = "$unicode_size"
3900 then
3901 PY_UNICODE_TYPE="unsigned long"
3902 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3903 else
3904 PY_UNICODE_TYPE="no type found"
3905 fi
3906 AC_MSG_RESULT($PY_UNICODE_TYPE)
3907fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00003908
3909# check for endianness
3910AC_C_BIGENDIAN
3911
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003912# Check whether right shifting a negative integer extends the sign bit
3913# or fills with zeros (like the Cray J90, according to Tim Peters).
3914AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003915AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003916AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003917int main()
3918{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003919 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003920}
Matthias Klosec511b472010-05-08 11:01:39 +00003921]])],
3922[ac_cv_rshift_extends_sign=yes],
3923[ac_cv_rshift_extends_sign=no],
3924[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003925AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3926if test "$ac_cv_rshift_extends_sign" = no
3927then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003928 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3929 [Define if i>>j for signed int i does not extend the sign bit
3930 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003931fi
3932
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003933# check for getc_unlocked and related locking functions
3934AC_MSG_CHECKING(for getc_unlocked() and friends)
3935AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Klosec511b472010-05-08 11:01:39 +00003936AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003937 FILE *f = fopen("/dev/null", "r");
3938 flockfile(f);
3939 getc_unlocked(f);
3940 funlockfile(f);
Matthias Klosec511b472010-05-08 11:01:39 +00003941]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003942AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3943if test "$ac_cv_have_getc_unlocked" = yes
3944then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003945 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3946 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003947fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003948
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003949# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003950# save the value of LIBS so we don't actually link Python with readline
3951LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00003952
3953# On some systems we need to link readline to a termcap compatible
3954# library. NOTE: Keep the precedence of listed libraries synchronised
3955# with setup.py.
3956py_cv_lib_readline=no
3957AC_MSG_CHECKING([how to link readline libs])
3958for py_libtermcap in "" ncursesw ncurses curses termcap; do
3959 if test -z "$py_libtermcap"; then
3960 READLINE_LIBS="-lreadline"
3961 else
3962 READLINE_LIBS="-lreadline -l$py_libtermcap"
3963 fi
3964 LIBS="$READLINE_LIBS $LIBS_no_readline"
3965 AC_LINK_IFELSE(
3966 [AC_LANG_CALL([],[readline])],
3967 [py_cv_lib_readline=yes])
3968 if test $py_cv_lib_readline = yes; then
3969 break
3970 fi
3971done
3972# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3973#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00003974if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00003975 AC_MSG_RESULT([none])
3976else
3977 AC_MSG_RESULT([$READLINE_LIBS])
3978 AC_DEFINE(HAVE_LIBREADLINE, 1,
3979 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003980fi
3981
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003982# check for readline 2.1
3983AC_CHECK_LIB(readline, rl_callback_handler_install,
3984 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003985 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003986
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003987# check for readline 2.2
Matthias Klosec511b472010-05-08 11:01:39 +00003988AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
3989 [have_readline=yes],
3990 [have_readline=no]
3991)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003992if test $have_readline = yes
3993then
3994 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3995 [readline/readline.h],
3996 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3997 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00003998 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3999 [readline/readline.h],
4000 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
4001 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004002fi
4003
Martin v. Löwis0daad592001-09-30 21:09:59 +00004004# check for readline 4.0
4005AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004006 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004007 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00004008
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004009# also in 4.0
4010AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
4011 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004012 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004013
Guido van Rossum353ae582001-07-10 16:45:32 +00004014# check for readline 4.2
4015AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004016 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004017 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00004018
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004019# also in readline 4.2
Matthias Klosec511b472010-05-08 11:01:39 +00004020AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4021 [have_readline=yes],
4022 [have_readline=no]
4023)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004024if test $have_readline = yes
4025then
4026 AC_EGREP_HEADER([extern int rl_catch_signals;],
4027 [readline/readline.h],
4028 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
4029 [Define if you can turn off readline's signal handling.]), )
4030fi
4031
Martin v. Löwis82bca632006-02-10 20:49:30 +00004032# End of readline checks: restore LIBS
4033LIBS=$LIBS_no_readline
4034
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004035AC_MSG_CHECKING(for broken nice())
4036AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Klosec511b472010-05-08 11:01:39 +00004037AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004038int main()
4039{
4040 int val1 = nice(1);
4041 if (val1 != -1 && val1 == nice(2))
4042 exit(0);
4043 exit(1);
4044}
Matthias Klosec511b472010-05-08 11:01:39 +00004045]])],
4046[ac_cv_broken_nice=yes],
4047[ac_cv_broken_nice=no],
4048[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004049AC_MSG_RESULT($ac_cv_broken_nice)
4050if test "$ac_cv_broken_nice" = yes
4051then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004052 AC_DEFINE(HAVE_BROKEN_NICE, 1,
4053 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004054fi
4055
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004056AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004057AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Klosec511b472010-05-08 11:01:39 +00004058AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004059#include <poll.h>
4060
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004061int main()
4062{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004063 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004064 int poll_test;
4065
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004066 close (42);
4067
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004068 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004069 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004070 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004071 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004072 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004073 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004074 return 1;
4075}
Matthias Klosec511b472010-05-08 11:01:39 +00004076]])],
4077[ac_cv_broken_poll=yes],
4078[ac_cv_broken_poll=no],
4079[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004080AC_MSG_RESULT($ac_cv_broken_poll)
4081if test "$ac_cv_broken_poll" = yes
4082then
4083 AC_DEFINE(HAVE_BROKEN_POLL, 1,
4084 [Define if poll() sets errno on invalid file descriptors.])
4085fi
4086
Brett Cannon43802422005-02-10 20:48:03 +00004087# Before we can test tzset, we need to check if struct tm has a tm_zone
4088# (which is not required by ISO C or UNIX spec) and/or if we support
4089# tzname[]
4090AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004091
Brett Cannon43802422005-02-10 20:48:03 +00004092# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004093AC_MSG_CHECKING(for working tzset())
4094AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Klosec511b472010-05-08 11:01:39 +00004095AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004096#include <stdlib.h>
4097#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00004098#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00004099
4100#if HAVE_TZNAME
4101extern char *tzname[];
4102#endif
4103
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004104int main()
4105{
Brett Cannon18367812003-09-19 00:59:16 +00004106 /* Note that we need to ensure that not only does tzset(3)
4107 do 'something' with localtime, but it works as documented
4108 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00004109 This includes making sure that tzname is set properly if
4110 tm->tm_zone does not exist since it is the alternative way
4111 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00004112
4113 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00004114 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00004115 */
4116
Brett Cannon43802422005-02-10 20:48:03 +00004117 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00004118 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
4119
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004120 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004121 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004122 if (localtime(&groundhogday)->tm_hour != 0)
4123 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004124#if HAVE_TZNAME
4125 /* For UTC, tzname[1] is sometimes "", sometimes " " */
4126 if (strcmp(tzname[0], "UTC") ||
4127 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4128 exit(1);
4129#endif
Brett Cannon18367812003-09-19 00:59:16 +00004130
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004131 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004132 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004133 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004134 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004135#if HAVE_TZNAME
4136 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4137 exit(1);
4138#endif
Brett Cannon18367812003-09-19 00:59:16 +00004139
4140 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4141 tzset();
4142 if (localtime(&groundhogday)->tm_hour != 11)
4143 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004144#if HAVE_TZNAME
4145 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4146 exit(1);
4147#endif
4148
4149#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004150 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4151 exit(1);
4152 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4153 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004154#endif
Brett Cannon18367812003-09-19 00:59:16 +00004155
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004156 exit(0);
4157}
Matthias Klosec511b472010-05-08 11:01:39 +00004158]])],
4159[ac_cv_working_tzset=yes],
4160[ac_cv_working_tzset=no],
4161[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004162AC_MSG_RESULT($ac_cv_working_tzset)
4163if test "$ac_cv_working_tzset" = yes
4164then
4165 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4166 [Define if tzset() actually switches the local timezone in a meaningful way.])
4167fi
4168
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004169# Look for subsecond timestamps in struct stat
4170AC_MSG_CHECKING(for tv_nsec in struct stat)
4171AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Klosec511b472010-05-08 11:01:39 +00004172AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004173struct stat st;
4174st.st_mtim.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004175]])],
4176[ac_cv_stat_tv_nsec=yes],
4177[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004178AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4179if test "$ac_cv_stat_tv_nsec" = yes
4180then
4181 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4182 [Define if you have struct stat.st_mtim.tv_nsec])
4183fi
4184
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004185# Look for BSD style subsecond timestamps in struct stat
4186AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4187AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Klosec511b472010-05-08 11:01:39 +00004188AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004189struct stat st;
4190st.st_mtimespec.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004191]])],
4192[ac_cv_stat_tv_nsec2=yes],
4193[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004194AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4195if test "$ac_cv_stat_tv_nsec2" = yes
4196then
4197 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4198 [Define if you have struct stat.st_mtimensec])
4199fi
4200
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004201# On HP/UX 11.0, mvwdelch is a block with a return statement
4202AC_MSG_CHECKING(whether mvwdelch is an expression)
4203AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Klosec511b472010-05-08 11:01:39 +00004204AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004205 int rtn;
4206 rtn = mvwdelch(0,0,0);
Matthias Klosec511b472010-05-08 11:01:39 +00004207]])],
4208[ac_cv_mvwdelch_is_expression=yes],
4209[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004210AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4211
4212if test "$ac_cv_mvwdelch_is_expression" = yes
4213then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004214 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4215 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004216fi
4217
4218AC_MSG_CHECKING(whether WINDOW has _flags)
4219AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Klosec511b472010-05-08 11:01:39 +00004220AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004221 WINDOW *w;
4222 w->_flags = 0;
Matthias Klosec511b472010-05-08 11:01:39 +00004223]])],
4224[ac_cv_window_has_flags=yes],
4225[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004226AC_MSG_RESULT($ac_cv_window_has_flags)
4227
4228
4229if test "$ac_cv_window_has_flags" = yes
4230then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004231 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4232 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004233fi
4234
Walter Dörwald4994d952006-06-19 08:07:50 +00004235AC_MSG_CHECKING(for is_term_resized)
Matthias Klosec511b472010-05-08 11:01:39 +00004236AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4237 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4238 AC_MSG_RESULT(yes)],
4239 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004240)
4241
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004242AC_MSG_CHECKING(for resize_term)
Matthias Klosec511b472010-05-08 11:01:39 +00004243AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4244 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4245 AC_MSG_RESULT(yes)],
4246 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004247)
4248
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004249AC_MSG_CHECKING(for resizeterm)
Matthias Klosec511b472010-05-08 11:01:39 +00004250AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4251 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4252 AC_MSG_RESULT(yes)],
4253 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004254)
4255
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004256AC_MSG_CHECKING(for /dev/ptmx)
4257
4258if test -r /dev/ptmx
4259then
4260 AC_MSG_RESULT(yes)
4261 AC_DEFINE(HAVE_DEV_PTMX, 1,
4262 [Define if we have /dev/ptmx.])
4263else
4264 AC_MSG_RESULT(no)
4265fi
4266
4267AC_MSG_CHECKING(for /dev/ptc)
4268
4269if test -r /dev/ptc
4270then
4271 AC_MSG_RESULT(yes)
4272 AC_DEFINE(HAVE_DEV_PTC, 1,
4273 [Define if we have /dev/ptc.])
4274else
4275 AC_MSG_RESULT(no)
4276fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004277
Mark Dickinson82864d12009-11-15 16:18:58 +00004278if test "$have_long_long" = yes
4279then
4280 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4281 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Klosec511b472010-05-08 11:01:39 +00004282 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson82864d12009-11-15 16:18:58 +00004283 #include <stdio.h>
4284 #include <stddef.h>
4285 #include <string.h>
4286
4287 #ifdef HAVE_SYS_TYPES_H
4288 #include <sys/types.h>
4289 #endif
4290
4291 int main()
4292 {
4293 char buffer[256];
4294
4295 if (sprintf(buffer, "%lld", (long long)123) < 0)
4296 return 1;
4297 if (strcmp(buffer, "123"))
4298 return 1;
4299
4300 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4301 return 1;
4302 if (strcmp(buffer, "-123"))
4303 return 1;
4304
4305 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4306 return 1;
4307 if (strcmp(buffer, "123"))
4308 return 1;
4309
4310 return 0;
4311 }
Matthias Klosec511b472010-05-08 11:01:39 +00004312 ]]])],
4313 [ac_cv_have_long_long_format=yes],
4314 [ac_cv_have_long_long_format=no],
4315 [ac_cv_have_long_long_format=no])
Mark Dickinson82864d12009-11-15 16:18:58 +00004316 )
4317 AC_MSG_RESULT($ac_cv_have_long_long_format)
4318fi
4319
Mark Dickinson5ce84742009-12-31 20:48:04 +00004320if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004321then
4322 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4323 [Define to printf format modifier for long long type])
4324fi
4325
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004326if test $ac_sys_system = Darwin
4327then
4328 LIBS="$LIBS -framework CoreFoundation"
4329fi
4330
Mark Dickinson82864d12009-11-15 16:18:58 +00004331
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004332AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Klosec511b472010-05-08 11:01:39 +00004333AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004334#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004335#include <stddef.h>
4336#include <string.h>
4337
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004338#ifdef HAVE_SYS_TYPES_H
4339#include <sys/types.h>
4340#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004341
4342#ifdef HAVE_SSIZE_T
4343typedef ssize_t Py_ssize_t;
4344#elif SIZEOF_VOID_P == SIZEOF_LONG
4345typedef long Py_ssize_t;
4346#else
4347typedef int Py_ssize_t;
4348#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004349
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004350int main()
4351{
4352 char buffer[256];
4353
Brett Cannon09d12362006-05-11 05:11:33 +00004354 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4355 return 1;
4356
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004357 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004358 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004359
4360 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4361 return 1;
4362
4363 if (strcmp(buffer, "-123"))
4364 return 1;
4365
Brett Cannon09d12362006-05-11 05:11:33 +00004366 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004367}
Matthias Klosec511b472010-05-08 11:01:39 +00004368]])],
4369[ac_cv_have_size_t_format=yes],
4370[ac_cv_have_size_t_format=no],
4371[ac_cv_have_size_t_format="cross -- assuming yes"
4372])])
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004373if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004374 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4375 [Define to printf format modifier for Py_ssize_t])
4376fi
Brett Cannon09d12362006-05-11 05:11:33 +00004377
Martin v. Löwis01c04012002-11-11 14:58:44 +00004378AC_CHECK_TYPE(socklen_t,,
4379 AC_DEFINE(socklen_t,int,
Matthias Klose5183ebd2010-04-24 16:38:36 +00004380 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004381#ifdef HAVE_SYS_TYPES_H
4382#include <sys/types.h>
4383#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004384#ifdef HAVE_SYS_SOCKET_H
4385#include <sys/socket.h>
4386#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004387])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004388
R. David Murray1d9d16e2010-10-16 00:43:13 +00004389case $ac_sys_system in
4390AIX*)
4391 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4392esac
4393
4394
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004395AC_SUBST(THREADHEADERS)
4396
4397for h in `(cd $srcdir;echo Python/thread_*.h)`
4398do
4399 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4400done
4401
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004402AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004403SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004404AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004405for dir in $SRCDIRS; do
4406 if test ! -d $dir; then
4407 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004408 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004409done
4410AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004411
Guido van Rossum627b2d71993-12-24 10:39:16 +00004412# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004413AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrouaabdceb2010-09-10 20:03:17 +00004414AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004415AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004416
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004417echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004418if test ! -f Modules/Setup
4419then
4420 cp $srcdir/Modules/Setup.dist Modules/Setup
4421fi
4422
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004423echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004424if test ! -f Modules/Setup.local
4425then
4426 echo "# Edit this file for local setup changes" >Modules/Setup.local
4427fi
4428
4429echo "creating Makefile"
4430$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4431 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004432 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004433
4434case $ac_sys_system in
4435BeOS)
4436 AC_MSG_WARN([
4437
4438 Support for BeOS is deprecated as of Python 2.6.
4439 See PEP 11 for the gory details.
4440 ])
4441 ;;
4442*) ;;
4443esac
4444
Neil Schemenauer66252162001-02-19 04:47:42 +00004445mv config.c Modules