~ubuntu-branches/ubuntu/maverick/python3.1/maverick

« back to all changes in this revision

Viewing changes to configure.in

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-03-23 00:01:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090323000127-5fstfxju4ufrhthq
Tags: upstream-3.1~a1+20090322
ImportĀ upstreamĀ versionĀ 3.1~a1+20090322

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl ***********************************************
 
2
dnl * Please run autoreconf to test your changes! *
 
3
dnl ***********************************************
 
4
dnl NOTE: autoconf 2.64 doesn't seem to work (use 2.61).
 
5
 
 
6
# Set VERSION so we only need to edit in one place (i.e., here)
 
7
m4_define(PYTHON_VERSION, 3.1)
 
8
 
 
9
AC_REVISION($Revision: 70459 $)
 
10
AC_PREREQ(2.61)
 
11
AC_INIT(python, PYTHON_VERSION, http://www.python.org/python-bugs)
 
12
AC_CONFIG_SRCDIR([Include/object.h])
 
13
AC_CONFIG_HEADER(pyconfig.h)
 
14
 
 
15
dnl This is for stuff that absolutely must end up in pyconfig.h.
 
16
dnl Please use pyport.h instead, if possible.
 
17
AH_TOP([
 
18
#ifndef Py_PYCONFIG_H
 
19
#define Py_PYCONFIG_H
 
20
])
 
21
AH_BOTTOM([
 
22
/* Define the macros needed if on a UnixWare 7.x system. */
 
23
#if defined(__USLC__) && defined(__SCO_VERSION__)
 
24
#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
 
25
#endif
 
26
 
 
27
#endif /*Py_PYCONFIG_H*/
 
28
])
 
29
 
 
30
# We don't use PACKAGE_ variables, and they cause conflicts
 
31
# with other autoconf-based packages that include Python.h
 
32
grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
 
33
rm confdefs.h
 
34
mv confdefs.h.new confdefs.h
 
35
 
 
36
AC_SUBST(VERSION)
 
37
VERSION=PYTHON_VERSION
 
38
 
 
39
AC_SUBST(SOVERSION)
 
40
SOVERSION=1.0
 
41
 
 
42
# The later defininition of _XOPEN_SOURCE disables certain features
 
43
# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
 
44
AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
 
45
 
 
46
# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
 
47
# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
 
48
# them.
 
49
AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
 
50
 
 
51
# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
 
52
# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
 
53
# them.
 
54
AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
 
55
 
 
56
# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
 
57
# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
 
58
AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
 
59
 
 
60
# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
 
61
# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
 
62
# them.
 
63
AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
 
64
 
 
65
 
 
66
define_xopen_source=yes
 
67
 
 
68
# Arguments passed to configure.
 
69
AC_SUBST(CONFIG_ARGS)
 
70
CONFIG_ARGS="$ac_configure_args"
 
71
 
 
72
AC_ARG_ENABLE(universalsdk,
 
73
        AC_HELP_STRING(--enable-universalsdk@<:@=SDKDIR@:>@, Build against Mac OS X 10.4u SDK (ppc/i386)),
 
74
[
 
75
        case $enableval in
 
76
        yes)
 
77
                enableval=/Developer/SDKs/MacOSX10.4u.sdk
 
78
                ;;
 
79
        esac
 
80
        case $enableval in
 
81
        no)
 
82
                UNIVERSALSDK=
 
83
                enable_universalsdk=
 
84
                ;;
 
85
        *)
 
86
                UNIVERSALSDK=$enableval
 
87
                ;;
 
88
        esac
 
89
],[
 
90
        UNIVERSALSDK=
 
91
        enable_universalsdk=
 
92
])
 
93
AC_SUBST(UNIVERSALSDK)
 
94
 
 
95
ARCH_RUN_32BIT=
 
96
AC_SUBST(ARCH_RUN_32BIT)
 
97
 
 
98
UNIVERSAL_ARCHS="32-bit"
 
99
AC_MSG_CHECKING(for --with-universal-archs)
 
100
AC_ARG_WITH(universal-archs,
 
101
    AC_HELP_STRING(--with-universal-archs=ARCH, select architectures for universal build ("32-bit", "64-bit" or "all")),
 
102
[
 
103
        AC_MSG_RESULT($withval)
 
104
        UNIVERSAL_ARCHS="$withval"
 
105
],
 
106
[
 
107
        AC_MSG_RESULT(32-bit)
 
108
])
 
109
 
 
110
 
 
111
 
 
112
AC_ARG_WITH(framework-name,
 
113
              AC_HELP_STRING(--with-framework-name=FRAMEWORK, 
 
114
                             specify an alternate name of the framework built with --enable-framework),
 
115
[
 
116
    PYTHONFRAMEWORK=${withval}
 
117
    PYTHONFRAMEWORKDIR=${withval}.framework
 
118
    PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
 
119
    ],[
 
120
    PYTHONFRAMEWORK=Python
 
121
    PYTHONFRAMEWORKDIR=Python.framework
 
122
    PYTHONFRAMEWORKIDENTIFIER=org.python.python
 
123
])
 
124
dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
 
125
AC_ARG_ENABLE(framework,
 
126
              AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
 
127
[
 
128
        case $enableval in
 
129
        yes) 
 
130
                enableval=/Library/Frameworks
 
131
        esac
 
132
        case $enableval in
 
133
        no)
 
134
                PYTHONFRAMEWORK=
 
135
                PYTHONFRAMEWORKDIR=no-framework
 
136
                PYTHONFRAMEWORKPREFIX=
 
137
                PYTHONFRAMEWORKINSTALLDIR=
 
138
                FRAMEWORKINSTALLFIRST=
 
139
                FRAMEWORKINSTALLLAST=
 
140
                FRAMEWORKALTINSTALLFIRST=
 
141
                FRAMEWORKALTINSTALLLAST=
 
142
                if test "x${prefix}" = "xNONE"; then
 
143
                        FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
 
144
                else
 
145
                        FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
 
146
                fi
 
147
                enable_framework=
 
148
                ;;
 
149
        *)
 
150
                PYTHONFRAMEWORKPREFIX=$enableval
 
151
                PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
 
152
                FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
 
153
                FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
 
154
                if test "$UNIVERSAL_ARCHS" = "all"
 
155
                then
 
156
                        FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps4way frameworkinstallunixtools4way"
 
157
                else
 
158
                        FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
 
159
                fi
 
160
 
 
161
                if test "x${prefix}" = "xNONE" ; then
 
162
                        FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
 
163
                else
 
164
                        FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
 
165
                fi
 
166
                prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
 
167
 
 
168
                # Add files for Mac specific code to the list of output
 
169
                # files:
 
170
                AC_CONFIG_FILES(Mac/Makefile)
 
171
                AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
 
172
                AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
 
173
                AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
 
174
        esac
 
175
        ],[
 
176
        PYTHONFRAMEWORK=
 
177
        PYTHONFRAMEWORKDIR=no-framework
 
178
        PYTHONFRAMEWORKPREFIX=
 
179
        PYTHONFRAMEWORKINSTALLDIR=
 
180
        FRAMEWORKINSTALLFIRST=
 
181
        FRAMEWORKINSTALLLAST=
 
182
        FRAMEWORKALTINSTALLFIRST=
 
183
        FRAMEWORKALTINSTALLLAST=
 
184
        if test "x${prefix}" = "xNONE" ; then
 
185
                FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
 
186
        else
 
187
                FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
 
188
        fi
 
189
        enable_framework=
 
190
 
 
191
        if test "$UNIVERSAL_ARCHS" = "all" 
 
192
        then
 
193
                FRAMEWORKINSTALLLAST=update4wayuniversal
 
194
                FRAMEWORKALTINSTALLLAST=update4wayuniversal
 
195
        fi
 
196
])
 
197
AC_SUBST(PYTHONFRAMEWORK)
 
198
AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
 
199
AC_SUBST(PYTHONFRAMEWORKDIR)
 
200
AC_SUBST(PYTHONFRAMEWORKPREFIX)
 
201
AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
 
202
AC_SUBST(FRAMEWORKINSTALLFIRST)
 
203
AC_SUBST(FRAMEWORKINSTALLLAST)
 
204
AC_SUBST(FRAMEWORKALTINSTALLFIRST)
 
205
AC_SUBST(FRAMEWORKALTINSTALLLAST)
 
206
AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
 
207
 
 
208
##AC_ARG_WITH(dyld,
 
209
##            AC_HELP_STRING(--with-dyld,
 
210
##                           Use (OpenStep|Rhapsody) dynamic linker))
 
211
##
 
212
# Set name for machine-dependent library files
 
213
AC_SUBST(MACHDEP)
 
214
AC_MSG_CHECKING(MACHDEP)
 
215
if test -z "$MACHDEP"
 
216
then
 
217
        ac_sys_system=`uname -s`
 
218
        if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64" \
 
219
        -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
 
220
                ac_sys_release=`uname -v`
 
221
        else
 
222
                ac_sys_release=`uname -r`
 
223
        fi
 
224
        ac_md_system=`echo $ac_sys_system |
 
225
                           tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
 
226
        ac_md_release=`echo $ac_sys_release |
 
227
                           tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
 
228
        MACHDEP="$ac_md_system$ac_md_release"
 
229
 
 
230
        case $MACHDEP in
 
231
        cygwin*) MACHDEP="cygwin";;
 
232
        darwin*) MACHDEP="darwin";;
 
233
        atheos*) MACHDEP="atheos";;
 
234
        irix646) MACHDEP="irix6";;
 
235
        '')     MACHDEP="unknown";;
 
236
        esac
 
237
fi
 
238
        
 
239
# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
 
240
# disable features if it is defined, without any means to access these
 
241
# features as extensions. For these systems, we skip the definition of
 
242
# _XOPEN_SOURCE. Before adding a system to the list to gain access to
 
243
# some feature, make sure there is no alternative way to access this
 
244
# feature. Also, when using wildcards, make sure you have verified the
 
245
# need for not defining _XOPEN_SOURCE on all systems matching the
 
246
# wildcard, and that the wildcard does not include future systems
 
247
# (which may remove their limitations).
 
248
dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
 
249
case $ac_sys_system/$ac_sys_release in
 
250
  # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
 
251
  # even though select is a POSIX function. Reported by J. Ribbens.
 
252
  # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
 
253
  OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0123@:>@) 
 
254
    define_xopen_source=no
 
255
    # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
 
256
    # also defined. This can be overridden by defining _BSD_SOURCE
 
257
    # As this has a different meaning on Linux, only define it on OpenBSD
 
258
    AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
 
259
    ;;
 
260
  # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
 
261
  # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
 
262
  # Marc Recht
 
263
  NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
 
264
    define_xopen_source=no;;
 
265
  # On Solaris 2.6, sys/wait.h is inconsistent in the usage
 
266
  # of union __?sigval. Reported by Stuart Bishop.
 
267
  SunOS/5.6)
 
268
    define_xopen_source=no;;
 
269
  # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
 
270
  # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
 
271
  # Reconfirmed for 7.1.4 by Martin v. Loewis.
 
272
  OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
 
273
    define_xopen_source=no;;
 
274
  # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
 
275
  # but used in struct sockaddr.sa_family. Reported by Tim Rice.
 
276
  SCO_SV/3.2)
 
277
    define_xopen_source=no;;
 
278
  # On FreeBSD 4, the math functions C89 does not cover are never defined
 
279
  # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
 
280
  FreeBSD/4.*)
 
281
    define_xopen_source=no;;
 
282
  # On MacOS X 10.2, a bug in ncurses.h means that it craps out if 
 
283
  # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
 
284
  # identifies itself as Darwin/7.*
 
285
  # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
 
286
  # disables platform specific features beyond repair.
 
287
  # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE 
 
288
  # has no effect, don't bother defining them
 
289
  Darwin/@<:@6789@:>@.*)
 
290
    define_xopen_source=no;;
 
291
  # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
 
292
  # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
 
293
  # or has another value. By not (re)defining it, the defaults come in place.
 
294
  AIX/4)
 
295
    define_xopen_source=no;;
 
296
  AIX/5)
 
297
    if test `uname -r` -eq 1; then
 
298
      define_xopen_source=no
 
299
    fi
 
300
    ;;
 
301
  # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
 
302
  # defining NI_NUMERICHOST.
 
303
  QNX/6.3.2)
 
304
    define_xopen_source=no
 
305
    ;;
 
306
 
 
307
esac
 
308
 
 
309
if test $define_xopen_source = yes
 
310
then
 
311
  # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
 
312
  # defined precisely as g++ defines it
 
313
  # Furthermore, on Solaris 10, XPG6 requires the use of a C99
 
314
  # compiler
 
315
  case $ac_sys_system/$ac_sys_release in
 
316
    SunOS/5.8|SunOS/5.9|SunOS/5.10)
 
317
      AC_DEFINE(_XOPEN_SOURCE, 500, 
 
318
                Define to the level of X/Open that your system supports)
 
319
      ;;
 
320
    *)
 
321
      AC_DEFINE(_XOPEN_SOURCE, 600, 
 
322
                Define to the level of X/Open that your system supports)
 
323
      ;;
 
324
  esac
 
325
 
 
326
  # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
 
327
  # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
 
328
  # several APIs are not declared. Since this is also needed in some
 
329
  # cases for HP-UX, we define it globally.
 
330
  # except for Solaris 10, where it must not be defined, 
 
331
  # as it implies XPG4.2
 
332
  case $ac_sys_system/$ac_sys_release in
 
333
    SunOS/5.10)
 
334
      ;;
 
335
    *)
 
336
      AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
 
337
                Define to activate Unix95-and-earlier features)
 
338
      ;;
 
339
  esac
 
340
 
 
341
  AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
 
342
  
 
343
fi
 
344
 
 
345
#
 
346
# SGI compilers allow the specification of the both the ABI and the
 
347
# ISA on the command line.  Depending on the values of these switches,
 
348
# different and often incompatable code will be generated.
 
349
#
 
350
# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
 
351
# thus supply support for various ABI/ISA combinations.  The MACHDEP
 
352
# variable is also adjusted.
 
353
#
 
354
AC_SUBST(SGI_ABI)
 
355
if test ! -z "$SGI_ABI"
 
356
then
 
357
        CC="cc $SGI_ABI"
 
358
        LDFLAGS="$SGI_ABI $LDFLAGS"
 
359
        MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
 
360
fi
 
361
AC_MSG_RESULT($MACHDEP)
 
362
 
 
363
# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
 
364
# it may influence the way we can build extensions, so distutils
 
365
# needs to check it
 
366
AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
 
367
AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
 
368
CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
 
369
EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
 
370
 
 
371
AC_MSG_CHECKING(machine type as reported by uname -m)
 
372
ac_sys_machine=`uname -m`
 
373
AC_MSG_RESULT($ac_sys_machine)
 
374
 
 
375
# checks for alternative programs
 
376
 
 
377
# compiler flags are generated in two sets, BASECFLAGS and OPT.  OPT is just
 
378
# for debug/optimization stuff.  BASECFLAGS is for flags that are required
 
379
# just to get things to compile and link.  Users are free to override OPT
 
380
# when running configure or make.  The build should not break if they do.
 
381
# BASECFLAGS should generally not be messed with, however.
 
382
 
 
383
# XXX shouldn't some/most/all of this code be merged with the stuff later
 
384
# on that fiddles with OPT and BASECFLAGS?
 
385
AC_MSG_CHECKING(for --without-gcc)
 
386
AC_ARG_WITH(gcc,
 
387
            AC_HELP_STRING(--without-gcc,never use gcc),
 
388
[
 
389
        case $withval in
 
390
        no)     CC=${CC:-cc}
 
391
                without_gcc=yes;;
 
392
        yes)    CC=gcc
 
393
                without_gcc=no;;
 
394
        *)      CC=$withval
 
395
                without_gcc=$withval;;
 
396
        esac], [
 
397
        case $ac_sys_system in
 
398
        AIX*)   CC=cc_r
 
399
                without_gcc=;;
 
400
    Monterey*)
 
401
        RANLIB=:
 
402
        without_gcc=;;
 
403
        *)      without_gcc=no;;
 
404
        esac])
 
405
AC_MSG_RESULT($without_gcc)
 
406
 
 
407
# If the user switches compilers, we can't believe the cache
 
408
if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
 
409
then
 
410
  AC_MSG_ERROR([cached CC is different -- throw away $cache_file
 
411
(it is also a good idea to do 'make clean' before compiling)])
 
412
fi
 
413
 
 
414
AC_PROG_CC
 
415
 
 
416
AC_SUBST(CXX)
 
417
AC_SUBST(MAINCC)
 
418
AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
 
419
AC_ARG_WITH(cxx_main,
 
420
            AC_HELP_STRING([--with-cxx-main=<compiler>],
 
421
                           [compile main() and link python executable with C++ compiler]),
 
422
[
 
423
        
 
424
        case $withval in
 
425
        no)     with_cxx_main=no
 
426
                MAINCC='$(CC)';;
 
427
        yes)    with_cxx_main=yes
 
428
                MAINCC='$(CXX)';;
 
429
        *)      with_cxx_main=yes
 
430
                MAINCC=$withval
 
431
                if test -z "$CXX"
 
432
                then
 
433
                        CXX=$withval
 
434
                fi;;
 
435
        esac], [
 
436
        with_cxx_main=no
 
437
        MAINCC='$(CC)'
 
438
])
 
439
AC_MSG_RESULT($with_cxx_main)
 
440
 
 
441
preset_cxx="$CXX"
 
442
if test -z "$CXX"
 
443
then
 
444
        case "$CC" in
 
445
        gcc)    AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
 
446
        cc)     AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
 
447
        esac
 
448
        if test "$CXX" = "notfound"
 
449
        then
 
450
                CXX=""
 
451
        fi
 
452
fi
 
453
if test -z "$CXX"
 
454
then
 
455
        AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
 
456
        if test "$CXX" = "notfound"
 
457
        then
 
458
                CXX=""
 
459
        fi
 
460
fi
 
461
if test "$preset_cxx" != "$CXX"
 
462
then
 
463
        AC_MSG_WARN([
 
464
 
 
465
  By default, distutils will build C++ extension modules with "$CXX".
 
466
  If this is not intended, then set CXX on the configure command line.
 
467
  ])
 
468
fi
 
469
 
 
470
 
 
471
# checks for UNIX variants that set C preprocessor variables
 
472
AC_AIX
 
473
 
 
474
# Check for unsupported systems
 
475
case $ac_sys_system/$ac_sys_release in
 
476
atheos*|Linux*/1*)
 
477
   echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
 
478
   echo See README for details.
 
479
   exit 1;;
 
480
esac
 
481
 
 
482
AC_EXEEXT
 
483
AC_MSG_CHECKING(for --with-suffix)
 
484
AC_ARG_WITH(suffix,
 
485
            AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
 
486
[
 
487
        case $withval in
 
488
        no)     EXEEXT=;;
 
489
        yes)    EXEEXT=.exe;;
 
490
        *)      EXEEXT=$withval;;
 
491
        esac])
 
492
AC_MSG_RESULT($EXEEXT)
 
493
 
 
494
# Test whether we're running on a non-case-sensitive system, in which
 
495
# case we give a warning if no ext is given
 
496
AC_SUBST(BUILDEXEEXT)
 
497
AC_MSG_CHECKING(for case-insensitive build directory)
 
498
if test ! -d CaseSensitiveTestDir; then
 
499
mkdir CaseSensitiveTestDir
 
500
fi
 
501
 
 
502
if test -d casesensitivetestdir
 
503
then
 
504
    AC_MSG_RESULT(yes)
 
505
    BUILDEXEEXT=.exe
 
506
else
 
507
        AC_MSG_RESULT(no)
 
508
        BUILDEXEEXT=$EXEEXT
 
509
fi
 
510
rmdir CaseSensitiveTestDir
 
511
 
 
512
case $MACHDEP in
 
513
bsdos*)
 
514
    case $CC in
 
515
    gcc) CC="$CC -D_HAVE_BSDI";;
 
516
    esac;;
 
517
esac
 
518
 
 
519
case $ac_sys_system in
 
520
hp*|HP*)
 
521
    case $CC in
 
522
    cc|*/cc) CC="$CC -Ae";;
 
523
    esac;;
 
524
Monterey*)
 
525
    case $CC in
 
526
    cc) CC="$CC -Wl,-Bexport";;
 
527
    esac;;
 
528
SunOS*)
 
529
    # Some functions have a prototype only with that define, e.g. confstr
 
530
    AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
 
531
    ;;
 
532
esac
 
533
 
 
534
 
 
535
AC_SUBST(LIBRARY)
 
536
AC_MSG_CHECKING(LIBRARY)
 
537
if test -z "$LIBRARY"
 
538
then
 
539
        LIBRARY='libpython$(VERSION).a'
 
540
fi
 
541
AC_MSG_RESULT($LIBRARY)
 
542
 
 
543
# LDLIBRARY is the name of the library to link against (as opposed to the
 
544
# name of the library into which to insert object files). BLDLIBRARY is also
 
545
# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
 
546
# is blank as the main program is not linked directly against LDLIBRARY.
 
547
# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
 
548
# systems without shared libraries, LDLIBRARY is the same as LIBRARY
 
549
# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
 
550
# DLLLIBRARY is the shared (i.e., DLL) library.
 
551
 
552
# RUNSHARED is used to run shared python without installed libraries
 
553
#
 
554
# INSTSONAME is the name of the shared library that will be use to install
 
555
# on the system - some systems like version suffix, others don't
 
556
AC_SUBST(LDLIBRARY)
 
557
AC_SUBST(DLLLIBRARY)
 
558
AC_SUBST(BLDLIBRARY)
 
559
AC_SUBST(LDLIBRARYDIR)
 
560
AC_SUBST(INSTSONAME)
 
561
AC_SUBST(RUNSHARED)
 
562
LDLIBRARY="$LIBRARY"
 
563
BLDLIBRARY='$(LDLIBRARY)'
 
564
INSTSONAME='$(LDLIBRARY)'
 
565
DLLLIBRARY=''
 
566
LDLIBRARYDIR=''
 
567
RUNSHARED=''
 
568
 
 
569
# LINKCC is the command that links the python executable -- default is $(CC).
 
570
# If CXX is set, and if it is needed to link a main function that was
 
571
# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
 
572
# python might then depend on the C++ runtime
 
573
# This is altered for AIX in order to build the export list before 
 
574
# linking.
 
575
AC_SUBST(LINKCC)
 
576
AC_MSG_CHECKING(LINKCC)
 
577
if test -z "$LINKCC"
 
578
then
 
579
        LINKCC='$(PURIFY) $(MAINCC)'
 
580
        case $ac_sys_system in
 
581
        AIX*)
 
582
           exp_extra="\"\""
 
583
           if test $ac_sys_release -ge 5 -o \
 
584
                   $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
 
585
               exp_extra="."
 
586
           fi
 
587
           LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
 
588
        Monterey64*)
 
589
           LINKCC="$LINKCC -L/usr/lib/ia64l64";;
 
590
        QNX*)
 
591
           # qcc must be used because the other compilers do not
 
592
           # support -N.
 
593
           LINKCC=qcc;;
 
594
        esac
 
595
fi
 
596
AC_MSG_RESULT($LINKCC)
 
597
 
 
598
AC_MSG_CHECKING(for --enable-shared)
 
599
AC_ARG_ENABLE(shared,
 
600
              AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
 
601
 
 
602
if test -z "$enable_shared"
 
603
then 
 
604
  case $ac_sys_system in
 
605
  CYGWIN* | atheos*)
 
606
    enable_shared="yes";;
 
607
  *)
 
608
    enable_shared="no";;
 
609
  esac
 
610
fi
 
611
AC_MSG_RESULT($enable_shared)
 
612
 
 
613
AC_MSG_CHECKING(for --enable-profiling)
 
614
AC_ARG_ENABLE(profiling,
 
615
              AC_HELP_STRING(--enable-profiling, enable C-level code profiling),
 
616
[ac_save_cc="$CC"
 
617
 CC="$CC -pg"
 
618
 AC_TRY_RUN([int main() { return 0; }],
 
619
   ac_enable_profiling="yes",
 
620
   ac_enable_profiling="no",
 
621
   ac_enable_profiling="no")
 
622
 CC="$ac_save_cc"])
 
623
AC_MSG_RESULT($ac_enable_profiling)
 
624
 
 
625
case "$ac_enable_profiling" in
 
626
    "yes")
 
627
        BASECFLAGS="-pg $BASECFLAGS"
 
628
        LDFLAGS="-pg $LDFLAGS"
 
629
    ;;
 
630
esac
 
631
 
 
632
AC_MSG_CHECKING(LDLIBRARY)
 
633
 
 
634
# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
 
635
# library that we build, but we do not want to link against it (we
 
636
# will find it with a -framework option). For this reason there is an
 
637
# extra variable BLDLIBRARY against which Python and the extension
 
638
# modules are linked, BLDLIBRARY. This is normally the same as
 
639
# LDLIBRARY, but empty for MacOSX framework builds.
 
640
if test "$enable_framework"
 
641
then
 
642
  LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
 
643
  RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
 
644
  BLDLIBRARY=''
 
645
else
 
646
  BLDLIBRARY='$(LDLIBRARY)'
 
647
fi  
 
648
 
 
649
# Other platforms follow
 
650
if test $enable_shared = "yes"; then
 
651
  AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
 
652
  case $ac_sys_system in
 
653
    CYGWIN*)
 
654
          LDLIBRARY='libpython$(VERSION).dll.a'
 
655
          DLLLIBRARY='libpython$(VERSION).dll'
 
656
          ;;
 
657
    SunOS*)
 
658
          LDLIBRARY='libpython$(VERSION).so'
 
659
          BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
 
660
          RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
 
661
          INSTSONAME="$LDLIBRARY".$SOVERSION
 
662
          ;;
 
663
    Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
 
664
          LDLIBRARY='libpython$(VERSION).so'
 
665
          BLDLIBRARY='-L. -lpython$(VERSION)'
 
666
          RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
 
667
          case $ac_sys_system in
 
668
              FreeBSD*)
 
669
                SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
 
670
                ;;
 
671
          esac
 
672
          INSTSONAME="$LDLIBRARY".$SOVERSION
 
673
          ;;
 
674
    hp*|HP*)
 
675
          case `uname -m` in
 
676
                ia64)
 
677
                        LDLIBRARY='libpython$(VERSION).so'
 
678
                        ;;
 
679
                *)
 
680
                        LDLIBRARY='libpython$(VERSION).sl'
 
681
                        ;;
 
682
          esac
 
683
          BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
 
684
          RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
 
685
          ;;
 
686
    OSF*)
 
687
          LDLIBRARY='libpython$(VERSION).so'
 
688
          BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
 
689
          RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
 
690
          ;;
 
691
    atheos*)
 
692
          LDLIBRARY='libpython$(VERSION).so'
 
693
          BLDLIBRARY='-L. -lpython$(VERSION)'
 
694
          RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
 
695
          ;;
 
696
    Darwin*)
 
697
        LDLIBRARY='libpython$(VERSION).dylib'
 
698
        BLDLIBRARY='-L. -lpython$(VERSION)'
 
699
        RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
 
700
        ;;
 
701
 
 
702
  esac
 
703
else # shared is disabled
 
704
  case $ac_sys_system in
 
705
    CYGWIN*)
 
706
          BLDLIBRARY='$(LIBRARY)'
 
707
          LDLIBRARY='libpython$(VERSION).dll.a'
 
708
          ;;
 
709
  esac
 
710
fi
 
711
 
 
712
AC_MSG_RESULT($LDLIBRARY)
 
713
 
 
714
AC_PROG_RANLIB
 
715
AC_SUBST(AR)
 
716
AC_CHECK_PROGS(AR, ar aal, ar)
 
717
 
 
718
AC_SUBST(SVNVERSION)
 
719
AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
 
720
if test $SVNVERSION = found
 
721
then
 
722
        SVNVERSION="svnversion \$(srcdir)"
 
723
else
 
724
        SVNVERSION="echo exported"
 
725
fi
 
726
 
 
727
case $MACHDEP in
 
728
bsdos*|hp*|HP*)
 
729
        # install -d does not work on BSDI or HP-UX
 
730
        if test -z "$INSTALL"
 
731
        then
 
732
                INSTALL="${srcdir}/install-sh -c"
 
733
        fi
 
734
esac
 
735
AC_PROG_INSTALL
 
736
 
 
737
# Not every filesystem supports hard links
 
738
AC_SUBST(LN)
 
739
if test -z "$LN" ; then
 
740
        case $ac_sys_system in
 
741
                CYGWIN*) LN="ln -s";;
 
742
                atheos*) LN="ln -s";;
 
743
                *) LN=ln;;
 
744
        esac
 
745
fi
 
746
 
 
747
# Check for --with-pydebug
 
748
AC_MSG_CHECKING(for --with-pydebug)
 
749
AC_ARG_WITH(pydebug, 
 
750
            AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
 
751
[
 
752
if test "$withval" != no
 
753
then 
 
754
  AC_DEFINE(Py_DEBUG, 1, 
 
755
  [Define if you want to build an interpreter with many run-time checks.]) 
 
756
  AC_MSG_RESULT(yes); 
 
757
  Py_DEBUG='true'
 
758
else AC_MSG_RESULT(no); Py_DEBUG='false'
 
759
fi],
 
760
[AC_MSG_RESULT(no)])
 
761
 
 
762
# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
 
763
# merged with this chunk of code?
 
764
 
 
765
# Optimizer/debugger flags
 
766
# ------------------------
 
767
# (The following bit of code is complicated enough - please keep things
 
768
# indented properly.  Just pretend you're editing Python code. ;-)
 
769
 
 
770
# There are two parallel sets of case statements below, one that checks to
 
771
# see if OPT was set and one that does BASECFLAGS setting based upon
 
772
# compiler and platform.  BASECFLAGS tweaks need to be made even if the
 
773
# user set OPT.
 
774
 
 
775
# tweak OPT based on compiler and platform, only if the user didn't set
 
776
# it on the command line
 
777
AC_SUBST(OPT)
 
778
if test -z "$OPT"
 
779
then
 
780
    case $GCC in
 
781
    yes)
 
782
        if test "$CC" != 'g++' ; then
 
783
            STRICT_PROTO="-Wstrict-prototypes"
 
784
        fi
 
785
        # For gcc 4.x we need to use -fwrapv so lets check if its supported
 
786
        if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
 
787
           WRAP="-fwrapv"
 
788
        fi
 
789
        case $ac_cv_prog_cc_g in
 
790
        yes)
 
791
            if test "$Py_DEBUG" = 'true' ; then
 
792
                # Optimization messes up debuggers, so turn it off for
 
793
                # debug builds.
 
794
                OPT="-g -Wall $STRICT_PROTO"
 
795
            else
 
796
                OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
 
797
            fi
 
798
            ;;
 
799
        *)
 
800
            OPT="-O3 -Wall $STRICT_PROTO"
 
801
            ;;
 
802
        esac
 
803
        case $ac_sys_system in
 
804
            SCO_SV*) OPT="$OPT -m486 -DSCO5"
 
805
            ;;
 
806
        esac
 
807
        ;;
 
808
 
 
809
    *)
 
810
        OPT="-O"
 
811
        ;;
 
812
    esac
 
813
 
 
814
    # The current (beta) Monterey compiler dies with optimizations
 
815
    # XXX what is Monterey? Does it still die w/ -O? Can we get rid of this?
 
816
    case $ac_sys_system in
 
817
        Monterey*)
 
818
            OPT=""
 
819
            ;;
 
820
    esac
 
821
 
 
822
fi
 
823
 
 
824
AC_SUBST(BASECFLAGS)
 
825
 
 
826
# The -arch flags for universal builds on OSX
 
827
UNIVERSAL_ARCH_FLAGS=
 
828
AC_SUBST(UNIVERSAL_ARCH_FLAGS)
 
829
 
 
830
# tweak BASECFLAGS based on compiler and platform
 
831
case $GCC in
 
832
yes)
 
833
    # Python violates C99 rules, by casting between incompatible
 
834
    # pointer types. GCC may generate bad code as a result of that,
 
835
    # so use -fno-strict-aliasing if supported.
 
836
    AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
 
837
     ac_save_cc="$CC"
 
838
     CC="$CC -fno-strict-aliasing"
 
839
     AC_TRY_RUN([int main() { return 0; }],
 
840
     ac_cv_no_strict_aliasing_ok=yes,
 
841
     ac_cv_no_strict_aliasing_ok=no,
 
842
     ac_cv_no_strict_aliasing_ok=no)
 
843
     CC="$ac_save_cc"
 
844
    AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
 
845
    if test $ac_cv_no_strict_aliasing_ok = yes
 
846
    then
 
847
      BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
 
848
    fi
 
849
 
 
850
    # if using gcc on alpha, use -mieee to get (near) full IEEE 754
 
851
    # support.  Without this, treatment of subnormals doesn't follow
 
852
    # the standard.
 
853
    case $ac_sys_machine in
 
854
         alpha*)
 
855
                BASECFLAGS="$BASECFLAGS -mieee"
 
856
                ;;
 
857
    esac
 
858
 
 
859
    case $ac_sys_system in
 
860
        SCO_SV*)
 
861
            BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
 
862
            ;;
 
863
        # is there any other compiler on Darwin besides gcc?
 
864
        Darwin*)
 
865
            # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
 
866
            # used to be here, but non-Apple gcc doesn't accept them.
 
867
 
 
868
 
 
869
            if test "${enable_universalsdk}"; then
 
870
                UNIVERSAL_ARCH_FLAGS=""
 
871
                if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
 
872
                   UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
 
873
                   ARCH_RUN_32BIT=""
 
874
 
 
875
                 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
 
876
                   UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
 
877
 
 
878
                 elif test "$UNIVERSAL_ARCHS" = "all" ; then
 
879
                   UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
 
880
                   ARCH_RUN_32BIT="arch -i386 -ppc"
 
881
 
 
882
                 else
 
883
                   AC_MSG_ERROR([proper usage is --with-universalarch=32-bit|64-bit|all])
 
884
 
 
885
                 fi
 
886
 
 
887
 
 
888
                BASECFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
 
889
                tgt=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
 
890
                if test "${UNIVERSALSDK}" != "/" -a "${tgt}" '>' '10.4' ; then
 
891
                        CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
 
892
                fi
 
893
            fi
 
894
 
 
895
            # Calculate the right deployment target for this build.
 
896
            #
 
897
            cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
 
898
            if test ${cur_target} '>' 10.2; then
 
899
                    cur_target=10.3
 
900
            fi
 
901
            if test "${UNIVERSAL_ARCHS}" = "all"; then
 
902
                    # Ensure that the default platform for a 4-way
 
903
                    # universal build is OSX 10.5, that's the first
 
904
                    # OS release where 4-way builds make sense.
 
905
                    cur_target='10.5'
 
906
            fi
 
907
            CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
 
908
            
 
909
            # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the 
 
910
            # environment with a value that is the same as what we'll use
 
911
            # in the Makefile to ensure that we'll get the same compiler
 
912
            # environment during configure and build time.
 
913
            MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
 
914
            export MACOSX_DEPLOYMENT_TARGET
 
915
            EXPORT_MACOSX_DEPLOYMENT_TARGET=''
 
916
 
 
917
            ;;
 
918
        OSF*)
 
919
            BASECFLAGS="$BASECFLAGS -mieee"
 
920
            ;;
 
921
    esac
 
922
    ;;
 
923
 
 
924
*)
 
925
    case $ac_sys_system in
 
926
    OpenUNIX*|UnixWare*)
 
927
        BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
 
928
        ;;
 
929
    OSF*)
 
930
        BASECFLAGS="$BASECFLAGS -ieee -std"
 
931
        ;;
 
932
    SCO_SV*)
 
933
        BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
 
934
        ;;
 
935
    esac
 
936
    ;;
 
937
esac
 
938
 
 
939
if test "$Py_DEBUG" = 'true'; then
 
940
  :
 
941
else
 
942
  OPT="-DNDEBUG $OPT"
 
943
fi
 
944
 
 
945
if test "$ac_arch_flags"
 
946
then
 
947
        BASECFLAGS="$BASECFLAGS $ac_arch_flags"
 
948
fi
 
949
 
 
950
# disable check for icc since it seems to pass, but generates a warning
 
951
if test "$CC" = icc
 
952
then
 
953
  ac_cv_opt_olimit_ok=no
 
954
fi
 
955
 
 
956
AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
 
957
AC_CACHE_VAL(ac_cv_opt_olimit_ok,
 
958
[ac_save_cc="$CC"
 
959
CC="$CC -OPT:Olimit=0"
 
960
AC_TRY_RUN([int main() { return 0; }],
 
961
  ac_cv_opt_olimit_ok=yes,
 
962
  ac_cv_opt_olimit_ok=no,
 
963
  ac_cv_opt_olimit_ok=no)
 
964
CC="$ac_save_cc"])
 
965
AC_MSG_RESULT($ac_cv_opt_olimit_ok)
 
966
if test $ac_cv_opt_olimit_ok = yes; then
 
967
    case $ac_sys_system in
 
968
        # XXX is this branch needed? On MacOSX 10.2.2 the result of the
 
969
        # olimit_ok test is "no".  Is it "yes" in some other Darwin-esque
 
970
        # environment?
 
971
        Darwin*)
 
972
            ;;
 
973
        *)
 
974
            BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
 
975
            ;;
 
976
    esac
 
977
else
 
978
  AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
 
979
  AC_CACHE_VAL(ac_cv_olimit_ok,
 
980
  [ac_save_cc="$CC"
 
981
  CC="$CC -Olimit 1500"
 
982
  AC_TRY_RUN([int main() { return 0; }],
 
983
    ac_cv_olimit_ok=yes,
 
984
    ac_cv_olimit_ok=no,
 
985
    ac_cv_olimit_ok=no)
 
986
  CC="$ac_save_cc"])
 
987
  AC_MSG_RESULT($ac_cv_olimit_ok)
 
988
  if test $ac_cv_olimit_ok = yes; then
 
989
    BASECFLAGS="$BASECFLAGS -Olimit 1500"
 
990
  fi
 
991
fi
 
992
 
 
993
# Check whether GCC supports PyArg_ParseTuple format
 
994
if test "$GCC" = "yes"
 
995
then
 
996
  AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
 
997
  save_CFLAGS=$CFLAGS
 
998
  CFLAGS="$CFLAGS -Werror"
 
999
  AC_TRY_COMPILE([
 
1000
    void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
 
1001
  ],,
 
1002
  AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
 
1003
  AC_MSG_RESULT(yes),
 
1004
  AC_MSG_RESULT(no)
 
1005
  )
 
1006
  CFLAGS=$save_CFLAGS
 
1007
fi
 
1008
 
 
1009
# On some compilers, pthreads are available without further options
 
1010
# (e.g. MacOS X). On some of these systems, the compiler will not
 
1011
# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
 
1012
# So we have to see first whether pthreads are available without
 
1013
# options before we can check whether -Kpthread improves anything.
 
1014
AC_MSG_CHECKING(whether pthreads are available without options)
 
1015
AC_CACHE_VAL(ac_cv_pthread_is_default,
 
1016
[AC_TRY_RUN([
 
1017
#include <pthread.h>
 
1018
 
 
1019
void* routine(void* p){return NULL;}
 
1020
 
 
1021
int main(){
 
1022
  pthread_t p;
 
1023
  if(pthread_create(&p,NULL,routine,NULL)!=0)
 
1024
    return 1;
 
1025
  (void)pthread_detach(p);
 
1026
  return 0;
 
1027
}
 
1028
],
 
1029
[
 
1030
  ac_cv_pthread_is_default=yes
 
1031
  ac_cv_kthread=no
 
1032
  ac_cv_pthread=no
 
1033
],
 
1034
  ac_cv_pthread_is_default=no,
 
1035
  ac_cv_pthread_is_default=no)
 
1036
])
 
1037
AC_MSG_RESULT($ac_cv_pthread_is_default)
 
1038
 
 
1039
 
 
1040
if test $ac_cv_pthread_is_default = yes 
 
1041
then
 
1042
  ac_cv_kpthread=no
 
1043
else
 
1044
# -Kpthread, if available, provides the right #defines
 
1045
# and linker options to make pthread_create available
 
1046
# Some compilers won't report that they do not support -Kpthread,
 
1047
# so we need to run a program to see whether it really made the
 
1048
# function available.
 
1049
AC_MSG_CHECKING(whether $CC accepts -Kpthread)
 
1050
AC_CACHE_VAL(ac_cv_kpthread,
 
1051
[ac_save_cc="$CC"
 
1052
CC="$CC -Kpthread"
 
1053
AC_TRY_RUN([
 
1054
#include <pthread.h>
 
1055
 
 
1056
void* routine(void* p){return NULL;}
 
1057
 
 
1058
int main(){
 
1059
  pthread_t p;
 
1060
  if(pthread_create(&p,NULL,routine,NULL)!=0)
 
1061
    return 1;
 
1062
  (void)pthread_detach(p);
 
1063
  return 0;
 
1064
}
 
1065
],
 
1066
  ac_cv_kpthread=yes,
 
1067
  ac_cv_kpthread=no,
 
1068
  ac_cv_kpthread=no)
 
1069
CC="$ac_save_cc"])
 
1070
AC_MSG_RESULT($ac_cv_kpthread)
 
1071
fi
 
1072
 
 
1073
if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
 
1074
then
 
1075
# -Kthread, if available, provides the right #defines
 
1076
# and linker options to make pthread_create available
 
1077
# Some compilers won't report that they do not support -Kthread,
 
1078
# so we need to run a program to see whether it really made the
 
1079
# function available.
 
1080
AC_MSG_CHECKING(whether $CC accepts -Kthread)
 
1081
AC_CACHE_VAL(ac_cv_kthread,
 
1082
[ac_save_cc="$CC"
 
1083
CC="$CC -Kthread"
 
1084
AC_TRY_RUN([
 
1085
#include <pthread.h>
 
1086
 
 
1087
void* routine(void* p){return NULL;}
 
1088
 
 
1089
int main(){
 
1090
  pthread_t p;
 
1091
  if(pthread_create(&p,NULL,routine,NULL)!=0)
 
1092
    return 1;
 
1093
  (void)pthread_detach(p);
 
1094
  return 0;
 
1095
}
 
1096
],
 
1097
  ac_cv_kthread=yes,
 
1098
  ac_cv_kthread=no,
 
1099
  ac_cv_kthread=no)
 
1100
CC="$ac_save_cc"])
 
1101
AC_MSG_RESULT($ac_cv_kthread)
 
1102
fi
 
1103
 
 
1104
if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
 
1105
then
 
1106
# -pthread, if available, provides the right #defines
 
1107
# and linker options to make pthread_create available
 
1108
# Some compilers won't report that they do not support -pthread,
 
1109
# so we need to run a program to see whether it really made the
 
1110
# function available.
 
1111
AC_MSG_CHECKING(whether $CC accepts -pthread)
 
1112
AC_CACHE_VAL(ac_cv_thread,
 
1113
[ac_save_cc="$CC"
 
1114
CC="$CC -pthread"
 
1115
AC_TRY_RUN([
 
1116
#include <pthread.h>
 
1117
 
 
1118
void* routine(void* p){return NULL;}
 
1119
 
 
1120
int main(){
 
1121
  pthread_t p;
 
1122
  if(pthread_create(&p,NULL,routine,NULL)!=0)
 
1123
    return 1;
 
1124
  (void)pthread_detach(p);
 
1125
  return 0;
 
1126
}
 
1127
],
 
1128
  ac_cv_pthread=yes,
 
1129
  ac_cv_pthread=no,
 
1130
  ac_cv_pthread=no)
 
1131
CC="$ac_save_cc"])
 
1132
AC_MSG_RESULT($ac_cv_pthread)
 
1133
fi
 
1134
 
 
1135
# If we have set a CC compiler flag for thread support then
 
1136
# check if it works for CXX, too.
 
1137
ac_cv_cxx_thread=no
 
1138
if test ! -z "$CXX"
 
1139
then
 
1140
AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
 
1141
ac_save_cxx="$CXX"
 
1142
 
 
1143
if test "$ac_cv_kpthread" = "yes"
 
1144
then
 
1145
  CXX="$CXX -Kpthread"  
 
1146
  ac_cv_cxx_thread=yes
 
1147
elif test "$ac_cv_kthread" = "yes"
 
1148
then
 
1149
  CXX="$CXX -Kthread"
 
1150
  ac_cv_cxx_thread=yes
 
1151
elif test "$ac_cv_pthread" = "yes"
 
1152
then 
 
1153
  CXX="$CXX -pthread"
 
1154
  ac_cv_cxx_thread=yes
 
1155
fi
 
1156
 
 
1157
if test $ac_cv_cxx_thread = yes
 
1158
then
 
1159
  echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
 
1160
  $CXX -c conftest.$ac_ext 2>&5
 
1161
  if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
 
1162
     && test -s conftest$ac_exeext && ./conftest$ac_exeext
 
1163
  then
 
1164
    ac_cv_cxx_thread=yes
 
1165
  else
 
1166
    ac_cv_cxx_thread=no
 
1167
  fi
 
1168
  rm -fr conftest*
 
1169
fi
 
1170
AC_MSG_RESULT($ac_cv_cxx_thread)
 
1171
fi
 
1172
CXX="$ac_save_cxx"
 
1173
 
 
1174
dnl # check for ANSI or K&R ("traditional") preprocessor
 
1175
dnl AC_MSG_CHECKING(for C preprocessor type)
 
1176
dnl AC_TRY_COMPILE([
 
1177
dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
 
1178
dnl int foo;
 
1179
dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
 
1180
dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
 
1181
dnl AC_MSG_RESULT($cpp_type)
 
1182
 
 
1183
# checks for header files
 
1184
AC_HEADER_STDC
 
1185
AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
 
1186
fcntl.h grp.h \
 
1187
ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
 
1188
shadow.h signal.h stdint.h stropts.h termios.h thread.h \
 
1189
unistd.h utime.h \
 
1190
sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
 
1191
sys/lock.h sys/mkdev.h sys/modem.h \
 
1192
sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
 
1193
sys/termio.h sys/time.h \
 
1194
sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
 
1195
sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
 
1196
bluetooth/bluetooth.h linux/tipc.h)
 
1197
AC_HEADER_DIRENT
 
1198
AC_HEADER_MAJOR
 
1199
 
 
1200
# On Solaris, term.h requires curses.h
 
1201
AC_CHECK_HEADERS(term.h,,,[
 
1202
#ifdef HAVE_CURSES_H
 
1203
#include <curses.h>
 
1204
#endif
 
1205
])
 
1206
 
 
1207
# On Linux, netlink.h requires asm/types.h
 
1208
AC_CHECK_HEADERS(linux/netlink.h,,,[
 
1209
#ifdef HAVE_ASM_TYPES_H
 
1210
#include <asm/types.h>
 
1211
#endif
 
1212
#ifdef HAVE_SYS_SOCKET_H
 
1213
#include <sys/socket.h>
 
1214
#endif
 
1215
])
 
1216
 
 
1217
# checks for typedefs
 
1218
was_it_defined=no
 
1219
AC_MSG_CHECKING(for clock_t in time.h)
 
1220
AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
 
1221
    AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
 
1222
])
 
1223
AC_MSG_RESULT($was_it_defined)
 
1224
 
 
1225
# Check whether using makedev requires defining _OSF_SOURCE
 
1226
AC_MSG_CHECKING(for makedev)
 
1227
AC_TRY_LINK([#include <sys/types.h> ],
 
1228
            [ makedev(0, 0) ],
 
1229
            ac_cv_has_makedev=yes,
 
1230
            ac_cv_has_makedev=no)
 
1231
if test "$ac_cv_has_makedev" = "no"; then
 
1232
    # we didn't link, try if _OSF_SOURCE will allow us to link
 
1233
    AC_TRY_LINK([
 
1234
#define _OSF_SOURCE 1
 
1235
#include <sys/types.h>
 
1236
    ],
 
1237
    [ makedev(0, 0) ],
 
1238
    ac_cv_has_makedev=yes,
 
1239
    ac_cv_has_makedev=no)
 
1240
    if test "$ac_cv_has_makedev" = "yes"; then
 
1241
        AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
 
1242
    fi
 
1243
fi
 
1244
AC_MSG_RESULT($ac_cv_has_makedev)
 
1245
if test "$ac_cv_has_makedev" = "yes"; then
 
1246
    AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
 
1247
fi
 
1248
 
 
1249
# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
 
1250
# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
 
1251
# defined, but the compiler does not support pragma redefine_extname,
 
1252
# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
 
1253
# structures (such as rlimit64) without declaring them. As a
 
1254
# work-around, disable LFS on such configurations
 
1255
 
 
1256
use_lfs=yes
 
1257
AC_MSG_CHECKING(Solaris LFS bug)
 
1258
AC_TRY_COMPILE([
 
1259
#define _LARGEFILE_SOURCE 1
 
1260
#define _FILE_OFFSET_BITS 64
 
1261
#include <sys/resource.h>
 
1262
],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
 
1263
AC_MSG_RESULT($sol_lfs_bug)
 
1264
if test "$sol_lfs_bug" = "yes"; then
 
1265
  use_lfs=no
 
1266
fi
 
1267
 
 
1268
if test "$use_lfs" = "yes"; then
 
1269
# Two defines needed to enable largefile support on various platforms
 
1270
# These may affect some typedefs
 
1271
AC_DEFINE(_LARGEFILE_SOURCE, 1, 
 
1272
[This must be defined on some systems to enable large file support.])
 
1273
AC_DEFINE(_FILE_OFFSET_BITS, 64,
 
1274
[This must be set to 64 on some systems to enable large file support.])
 
1275
fi
 
1276
 
 
1277
# Add some code to confdefs.h so that the test for off_t works on SCO
 
1278
cat >> confdefs.h <<\EOF
 
1279
#if defined(SCO_DS)
 
1280
#undef _OFF_T
 
1281
#endif
 
1282
EOF
 
1283
 
 
1284
# Type availability checks
 
1285
AC_TYPE_MODE_T
 
1286
AC_TYPE_OFF_T
 
1287
AC_TYPE_PID_T
 
1288
AC_TYPE_SIGNAL
 
1289
AC_TYPE_SIZE_T
 
1290
AC_TYPE_UID_T
 
1291
AC_TYPE_UINT32_T
 
1292
AC_TYPE_UINT64_T
 
1293
AC_TYPE_INT32_T
 
1294
AC_TYPE_INT64_T
 
1295
AC_CHECK_TYPE(ssize_t,
 
1296
  AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
 
1297
 
 
1298
# Sizes of various common basic types
 
1299
# ANSI C requires sizeof(char) == 1, so no need to check it
 
1300
AC_CHECK_SIZEOF(int, 4)
 
1301
AC_CHECK_SIZEOF(long, 4)
 
1302
AC_CHECK_SIZEOF(void *, 4)
 
1303
AC_CHECK_SIZEOF(short, 2)
 
1304
AC_CHECK_SIZEOF(float, 4)
 
1305
AC_CHECK_SIZEOF(double, 8)
 
1306
AC_CHECK_SIZEOF(fpos_t, 4)
 
1307
AC_CHECK_SIZEOF(size_t, 4)
 
1308
AC_CHECK_SIZEOF(pid_t, 4)
 
1309
 
 
1310
AC_MSG_CHECKING(for long long support)
 
1311
have_long_long=no
 
1312
AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
 
1313
  AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.]) 
 
1314
  have_long_long=yes
 
1315
])
 
1316
AC_MSG_RESULT($have_long_long)
 
1317
if test "$have_long_long" = yes ; then
 
1318
AC_CHECK_SIZEOF(long long, 8)
 
1319
fi
 
1320
 
 
1321
AC_MSG_CHECKING(for long double support)
 
1322
have_long_double=no
 
1323
AC_TRY_COMPILE([], [long double x; x = (long double)0;], [
 
1324
  AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.]) 
 
1325
  have_long_double=yes
 
1326
])
 
1327
AC_MSG_RESULT($have_long_double)
 
1328
if test "$have_long_double" = yes ; then
 
1329
AC_CHECK_SIZEOF(long double, 16)
 
1330
fi
 
1331
 
 
1332
 
 
1333
AC_MSG_CHECKING(for _Bool support)
 
1334
have_c99_bool=no
 
1335
AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
 
1336
  AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.]) 
 
1337
  have_c99_bool=yes
 
1338
])
 
1339
AC_MSG_RESULT($have_c99_bool)
 
1340
if test "$have_c99_bool" = yes ; then
 
1341
AC_CHECK_SIZEOF(_Bool, 1)
 
1342
fi
 
1343
 
 
1344
AC_CHECK_TYPES(uintptr_t, 
 
1345
   [AC_CHECK_SIZEOF(uintptr_t, 4)], 
 
1346
   [], [#ifdef HAVE_STDINT_H
 
1347
        #include <stdint.h>
 
1348
        #endif])
 
1349
 
 
1350
 
 
1351
# Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
 
1352
AC_MSG_CHECKING(size of off_t)
 
1353
AC_CACHE_VAL(ac_cv_sizeof_off_t,
 
1354
[AC_TRY_RUN([#include <stdio.h>
 
1355
#include <sys/types.h>
 
1356
main()
 
1357
{
 
1358
  FILE *f=fopen("conftestval", "w");
 
1359
  if (!f) exit(1);
 
1360
  fprintf(f, "%d\n", sizeof(off_t));
 
1361
  exit(0);
 
1362
}],
 
1363
ac_cv_sizeof_off_t=`cat conftestval`,
 
1364
ac_cv_sizeof_off_t=0,
 
1365
ac_cv_sizeof_off_t=4)
 
1366
])
 
1367
AC_MSG_RESULT($ac_cv_sizeof_off_t)
 
1368
AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t,
 
1369
[The number of bytes in an off_t.])
 
1370
 
 
1371
AC_MSG_CHECKING(whether to enable large file support)
 
1372
if test "$have_long_long" = yes -a \
 
1373
        "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
 
1374
        "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
 
1375
  AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, 
 
1376
  [Defined to enable large file support when an off_t is bigger than a long
 
1377
   and long long is available and at least as big as an off_t. You may need
 
1378
   to add some flags for configuration and compilation to enable this mode.
 
1379
   (For Solaris and Linux, the necessary defines are already defined.)])
 
1380
  AC_MSG_RESULT(yes)
 
1381
else
 
1382
  AC_MSG_RESULT(no)
 
1383
fi
 
1384
 
 
1385
# AC_CHECK_SIZEOF() doesn't include <time.h>.
 
1386
AC_MSG_CHECKING(size of time_t)
 
1387
AC_CACHE_VAL(ac_cv_sizeof_time_t,
 
1388
[AC_TRY_RUN([#include <stdio.h>
 
1389
#include <time.h>
 
1390
main()
 
1391
{
 
1392
  FILE *f=fopen("conftestval", "w");
 
1393
  if (!f) exit(1);
 
1394
  fprintf(f, "%d\n", sizeof(time_t));
 
1395
  exit(0);
 
1396
}],
 
1397
ac_cv_sizeof_time_t=`cat conftestval`,
 
1398
ac_cv_sizeof_time_t=0,
 
1399
ac_cv_sizeof_time_t=4)
 
1400
])
 
1401
AC_MSG_RESULT($ac_cv_sizeof_time_t)
 
1402
AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t, 
 
1403
[The number of bytes in a time_t.])
 
1404
 
 
1405
 
 
1406
# if have pthread_t then define SIZEOF_PTHREAD_T
 
1407
ac_save_cc="$CC"
 
1408
if test "$ac_cv_kpthread" = "yes"
 
1409
then CC="$CC -Kpthread"
 
1410
elif test "$ac_cv_kthread" = "yes"
 
1411
then CC="$CC -Kthread"
 
1412
elif test "$ac_cv_pthread" = "yes"
 
1413
then CC="$CC -pthread"
 
1414
fi
 
1415
AC_MSG_CHECKING(for pthread_t)
 
1416
have_pthread_t=no
 
1417
AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
 
1418
AC_MSG_RESULT($have_pthread_t)
 
1419
if test "$have_pthread_t" = yes ; then
 
1420
  # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
 
1421
  AC_MSG_CHECKING(size of pthread_t)
 
1422
  AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
 
1423
  [AC_TRY_RUN([#include <stdio.h>
 
1424
#include <pthread.h>
 
1425
  main()
 
1426
  {
 
1427
    FILE *f=fopen("conftestval", "w");
 
1428
    if (!f) exit(1);
 
1429
    fprintf(f, "%d\n", sizeof(pthread_t));
 
1430
    exit(0);
 
1431
  }],
 
1432
  ac_cv_sizeof_pthread_t=`cat conftestval`,
 
1433
  ac_cv_sizeof_pthread_t=0,
 
1434
  ac_cv_sizeof_pthread_t=4)
 
1435
  ])
 
1436
  AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
 
1437
  AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t,
 
1438
   [The number of bytes in a pthread_t.])
 
1439
fi
 
1440
CC="$ac_save_cc"
 
1441
 
 
1442
 
 
1443
 
 
1444
AC_SUBST(OTHER_LIBTOOL_OPT)
 
1445
case $ac_sys_system/$ac_sys_release in
 
1446
  Darwin/@<:@01567@:>@\..*) 
 
1447
    OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
 
1448
    ;;
 
1449
  Darwin/*)
 
1450
    OTHER_LIBTOOL_OPT=""
 
1451
    ;;
 
1452
esac
 
1453
 
 
1454
AC_SUBST(LIBTOOL_CRUFT)
 
1455
case $ac_sys_system/$ac_sys_release in
 
1456
  Darwin/@<:@01567@:>@\..*) 
 
1457
    LIBTOOL_CRUFT="-framework System -lcc_dynamic"
 
1458
    if test "${enable_universalsdk}"; then
 
1459
            :
 
1460
    else
 
1461
        LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `arch`"
 
1462
    fi
 
1463
    LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
 
1464
    LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
 
1465
  Darwin/*)
 
1466
    gcc_version=`gcc -v 2>&1 |  grep version | cut -d\  -f3`
 
1467
    if test ${gcc_version} '<' 4.0
 
1468
        then
 
1469
            LIBTOOL_CRUFT="-lcc_dynamic"
 
1470
        else 
 
1471
            LIBTOOL_CRUFT=""
 
1472
    fi
 
1473
    LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only `arch`"
 
1474
    LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
 
1475
    LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
 
1476
esac
 
1477
 
 
1478
AC_MSG_CHECKING(for --enable-framework)
 
1479
if test "$enable_framework"
 
1480
then
 
1481
        BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
 
1482
        # -F. is needed to allow linking to the framework while 
 
1483
        # in the build location.
 
1484
        AC_DEFINE(WITH_NEXT_FRAMEWORK, 1, 
 
1485
         [Define if you want to produce an OpenStep/Rhapsody framework
 
1486
         (shared library plus accessory files).])
 
1487
        AC_MSG_RESULT(yes)
 
1488
else
 
1489
        AC_MSG_RESULT(no)
 
1490
fi
 
1491
 
 
1492
AC_MSG_CHECKING(for dyld)
 
1493
case $ac_sys_system/$ac_sys_release in
 
1494
  Darwin/*)
 
1495
        AC_DEFINE(WITH_DYLD, 1, 
 
1496
        [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
 
1497
         dynamic linker (dyld) instead of the old-style (NextStep) dynamic
 
1498
         linker (rld). Dyld is necessary to support frameworks.])
 
1499
        AC_MSG_RESULT(always on for Darwin)
 
1500
        ;;
 
1501
  *)
 
1502
        AC_MSG_RESULT(no)
 
1503
        ;;
 
1504
esac
 
1505
 
 
1506
# Set info about shared libraries.
 
1507
AC_SUBST(SO)
 
1508
AC_SUBST(LDSHARED)
 
1509
AC_SUBST(BLDSHARED)
 
1510
AC_SUBST(CCSHARED)
 
1511
AC_SUBST(LINKFORSHARED)
 
1512
# SO is the extension of shared libraries `(including the dot!)
 
1513
# -- usually .so, .sl on HP-UX, .dll on Cygwin
 
1514
AC_MSG_CHECKING(SO)
 
1515
if test -z "$SO"
 
1516
then
 
1517
        case $ac_sys_system in
 
1518
        hp*|HP*)
 
1519
                case `uname -m` in
 
1520
                        ia64) SO=.so;;
 
1521
                        *)    SO=.sl;;
 
1522
                esac
 
1523
                ;;
 
1524
        CYGWIN*)   SO=.dll;;
 
1525
        *)         SO=.so;;
 
1526
        esac
 
1527
else
 
1528
        # this might also be a termcap variable, see #610332
 
1529
        echo
 
1530
        echo '====================================================================='
 
1531
        echo '+                                                                   +'
 
1532
        echo '+ WARNING: You have set SO in your environment.                     +'
 
1533
        echo '+ Do you really mean to change the extension for shared libraries?  +'
 
1534
        echo '+ Continuing in 10 seconds to let you to ponder.                    +'
 
1535
        echo '+                                                                   +'
 
1536
        echo '====================================================================='
 
1537
        sleep 10
 
1538
fi
 
1539
AC_MSG_RESULT($SO)
 
1540
 
 
1541
AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
 
1542
# LDSHARED is the ld *command* used to create shared library
 
1543
# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
 
1544
# (Shared libraries in this instance are shared modules to be loaded into
 
1545
# Python, as opposed to building Python itself as a shared library.)
 
1546
AC_MSG_CHECKING(LDSHARED)
 
1547
if test -z "$LDSHARED"
 
1548
then
 
1549
        case $ac_sys_system/$ac_sys_release in
 
1550
        AIX*)
 
1551
                BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
 
1552
                LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
 
1553
                ;;
 
1554
        IRIX/5*) LDSHARED="ld -shared";;
 
1555
        IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
 
1556
        SunOS/5*) 
 
1557
                if test "$GCC" = "yes"
 
1558
                then LDSHARED='$(CC) -shared'
 
1559
                else LDSHARED='$(CC) -G';
 
1560
                fi ;;
 
1561
        hp*|HP*)
 
1562
                if test "$GCC" = "yes"
 
1563
                then LDSHARED='$(CC) -shared'
 
1564
                else LDSHARED='ld -b';
 
1565
                fi ;;
 
1566
        OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
 
1567
        Darwin/1.3*)
 
1568
                LDSHARED='$(CC) $(LDFLAGS) -bundle'
 
1569
                if test "$enable_framework" ; then
 
1570
                        # Link against the framework. All externals should be defined.
 
1571
                        BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
 
1572
                        LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
 
1573
                else
 
1574
                        # No framework. Ignore undefined symbols, assuming they come from Python
 
1575
                        LDSHARED="$LDSHARED -undefined suppress"
 
1576
                fi ;;
 
1577
        Darwin/1.4*|Darwin/5.*|Darwin/6.*)
 
1578
                LDSHARED='$(CC) $(LDFLAGS) -bundle'
 
1579
                if test "$enable_framework" ; then
 
1580
                        # Link against the framework. All externals should be defined.
 
1581
                        BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
 
1582
                        LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
 
1583
                else
 
1584
                        # No framework, use the Python app as bundle-loader
 
1585
                        BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
 
1586
                        LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
 
1587
                fi ;;
 
1588
        Darwin/*)
 
1589
                # Use -undefined dynamic_lookup whenever possible (10.3 and later).
 
1590
                # This allows an extension to be used in any Python
 
1591
 
 
1592
                if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
 
1593
                then
 
1594
                        if test "${enable_universalsdk}"; then
 
1595
                                LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
 
1596
                        fi
 
1597
                        LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
 
1598
                        BLDSHARED="$LDSHARED"
 
1599
                else
 
1600
                        LDSHARED='$(CC) $(LDFLAGS) -bundle'
 
1601
                        if test "$enable_framework" ; then
 
1602
                                # Link against the framework. All externals should be defined.
 
1603
                                BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
 
1604
                                LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
 
1605
                        else
 
1606
                                # No framework, use the Python app as bundle-loader
 
1607
                                BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
 
1608
                                LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
 
1609
                        fi
 
1610
                fi
 
1611
                ;;
 
1612
        Linux*|GNU*|QNX*) LDSHARED='$(CC) -shared';;
 
1613
        BSD/OS*/4*) LDSHARED="gcc -shared";;
 
1614
        FreeBSD*)
 
1615
                if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
 
1616
                then
 
1617
                        LDSHARED="$CC -shared ${LDFLAGS}"
 
1618
                else
 
1619
                        LDSHARED="ld -Bshareable ${LDFLAGS}"
 
1620
                fi;;
 
1621
        OpenBSD*)
 
1622
                if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
 
1623
                then
 
1624
                                LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
 
1625
                else
 
1626
                                case `uname -r` in
 
1627
                                [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
 
1628
                                   LDSHARED="ld -Bshareable ${LDFLAGS}"
 
1629
                                   ;;
 
1630
                                *)
 
1631
                                   LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
 
1632
                                   ;;
 
1633
                                esac
 
1634
                fi;;
 
1635
        NetBSD*|DragonFly*) LDSHARED="cc -shared ${LDFLAGS}";;
 
1636
        OpenUNIX*|UnixWare*)
 
1637
                if test "$GCC" = "yes"
 
1638
                then LDSHARED='$(CC) -shared'
 
1639
                else LDSHARED='$(CC) -G'
 
1640
                fi;;
 
1641
        SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
 
1642
        Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
 
1643
        CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
 
1644
        atheos*) LDSHARED="gcc -shared";;
 
1645
        *)      LDSHARED="ld";;
 
1646
        esac
 
1647
fi
 
1648
AC_MSG_RESULT($LDSHARED)
 
1649
BLDSHARED=${BLDSHARED-$LDSHARED}
 
1650
# CCSHARED are the C *flags* used to create objects to go into a shared
 
1651
# library (module) -- this is only needed for a few systems
 
1652
AC_MSG_CHECKING(CCSHARED)
 
1653
if test -z "$CCSHARED"
 
1654
then
 
1655
        case $ac_sys_system/$ac_sys_release in
 
1656
        SunOS*) if test "$GCC" = yes;
 
1657
                then CCSHARED="-fPIC";
 
1658
                elif test `uname -p` = sparc;
 
1659
                then CCSHARED="-xcode=pic32";
 
1660
                else CCSHARED="-Kpic";
 
1661
                fi;;
 
1662
        hp*|HP*) if test "$GCC" = yes;
 
1663
                 then CCSHARED="-fPIC";
 
1664
                 else CCSHARED="+z";
 
1665
                 fi;;
 
1666
        Linux*|GNU*) CCSHARED="-fPIC";;
 
1667
        BSD/OS*/4*) CCSHARED="-fpic";;
 
1668
        FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
 
1669
        OpenUNIX*|UnixWare*)
 
1670
                if test "$GCC" = "yes"
 
1671
                then CCSHARED="-fPIC"
 
1672
                else CCSHARED="-KPIC"
 
1673
                fi;;
 
1674
        SCO_SV*)
 
1675
                if test "$GCC" = "yes"
 
1676
                then CCSHARED="-fPIC"
 
1677
                else CCSHARED="-Kpic -belf"
 
1678
                fi;;
 
1679
        Monterey*) CCSHARED="-G";;
 
1680
        IRIX*/6*)  case $CC in
 
1681
                   *gcc*) CCSHARED="-shared";;
 
1682
                   *) CCSHARED="";;
 
1683
                   esac;;
 
1684
        atheos*) CCSHARED="-fPIC";;
 
1685
        esac
 
1686
fi
 
1687
AC_MSG_RESULT($CCSHARED)
 
1688
# LINKFORSHARED are the flags passed to the $(CC) command that links
 
1689
# the python executable -- this is only needed for a few systems
 
1690
AC_MSG_CHECKING(LINKFORSHARED)
 
1691
if test -z "$LINKFORSHARED"
 
1692
then
 
1693
        case $ac_sys_system/$ac_sys_release in
 
1694
        AIX*)   LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
 
1695
        hp*|HP*)
 
1696
            LINKFORSHARED="-Wl,-E -Wl,+s";;
 
1697
#           LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
 
1698
        BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
 
1699
        Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
 
1700
        # -u libsys_s pulls in all symbols in libsys
 
1701
        Darwin/*) 
 
1702
                # -u _PyMac_Error is needed to pull in the mac toolbox glue,
 
1703
                # which is
 
1704
                # not used by the core itself but which needs to be in the core so
 
1705
                # that dynamically loaded extension modules have access to it.
 
1706
                # -prebind is no longer used, because it actually seems to give a
 
1707
                # slowdown in stead of a speedup, maybe due to the large number of
 
1708
                # dynamic loads Python does.
 
1709
 
 
1710
                LINKFORSHARED="$extra_undefs"
 
1711
                if test "$enable_framework"
 
1712
                then
 
1713
                        LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
 
1714
                fi
 
1715
                LINKFORSHARED="$LINKFORSHARED";;
 
1716
        OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
 
1717
        SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
 
1718
        ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
 
1719
        FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) 
 
1720
                if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
 
1721
                then
 
1722
                        LINKFORSHARED="-Wl,--export-dynamic"
 
1723
                fi;;
 
1724
        SunOS/5*) case $CC in
 
1725
                  *gcc*)
 
1726
                    if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
 
1727
                    then
 
1728
                        LINKFORSHARED="-Xlinker --export-dynamic"
 
1729
                    fi;;
 
1730
                  esac;;
 
1731
        CYGWIN*)
 
1732
                if test $enable_shared = "no"
 
1733
                then
 
1734
                        LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
 
1735
                fi;;
 
1736
        QNX*)
 
1737
                # -Wl,-E causes the symbols to be added to the dynamic
 
1738
                # symbol table so that they can be found when a module
 
1739
                # is loaded.  -N 2048K causes the stack size to be set
 
1740
                # to 2048 kilobytes so that the stack doesn't overflow
 
1741
                # when running test_compile.py.
 
1742
                LINKFORSHARED='-Wl,-E -N 2048K';;
 
1743
        esac
 
1744
fi
 
1745
AC_MSG_RESULT($LINKFORSHARED)
 
1746
 
 
1747
 
 
1748
AC_SUBST(CFLAGSFORSHARED)
 
1749
AC_MSG_CHECKING(CFLAGSFORSHARED)
 
1750
if test ! "$LIBRARY" = "$LDLIBRARY"
 
1751
then
 
1752
        case $ac_sys_system in
 
1753
        CYGWIN*)
 
1754
                # Cygwin needs CCSHARED when building extension DLLs
 
1755
                # but not when building the interpreter DLL.
 
1756
                CFLAGSFORSHARED='';;
 
1757
        *)
 
1758
                CFLAGSFORSHARED='$(CCSHARED)'
 
1759
        esac
 
1760
fi
 
1761
AC_MSG_RESULT($CFLAGSFORSHARED)
 
1762
 
 
1763
# SHLIBS are libraries (except -lc and -lm) to link to the python shared
 
1764
# library (with --enable-shared).
 
1765
# For platforms on which shared libraries are not allowed to have unresolved
 
1766
# symbols, this must be set to $(LIBS) (expanded by make). We do this even
 
1767
# if it is not required, since it creates a dependency of the shared library
 
1768
# to LIBS. This, in turn, means that applications linking the shared libpython
 
1769
# don't need to link LIBS explicitly. The default should be only changed
 
1770
# on systems where this approach causes problems.
 
1771
AC_SUBST(SHLIBS)
 
1772
AC_MSG_CHECKING(SHLIBS)
 
1773
case "$ac_sys_system" in
 
1774
        *)
 
1775
                SHLIBS='$(LIBS)';;
 
1776
esac
 
1777
AC_MSG_RESULT($SHLIBS)
 
1778
 
 
1779
 
 
1780
# checks for libraries
 
1781
AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
 
1782
AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
 
1783
 
 
1784
# only check for sem_init if thread support is requested
 
1785
if test "$with_threads" = "yes" -o -z "$with_threads"; then
 
1786
    AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
 
1787
                                                # posix4 on Solaris 2.6
 
1788
                                                # pthread (first!) on Linux
 
1789
fi
 
1790
 
 
1791
# check if we need libintl for locale functions
 
1792
AC_CHECK_LIB(intl, textdomain,
 
1793
        AC_DEFINE(WITH_LIBINTL, 1,
 
1794
        [Define to 1 if libintl is needed for locale functions.]))
 
1795
 
 
1796
# checks for system dependent C++ extensions support
 
1797
case "$ac_sys_system" in
 
1798
        AIX*)   AC_MSG_CHECKING(for genuine AIX C++ extensions support)
 
1799
                AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
 
1800
                            [loadAndInit("", 0, "")],
 
1801
                            [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
 
1802
                      [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
 
1803
                       and you want support for AIX C++ shared extension modules.])
 
1804
                             AC_MSG_RESULT(yes)],
 
1805
                            [AC_MSG_RESULT(no)]);;
 
1806
        *) ;;
 
1807
esac
 
1808
 
 
1809
# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
 
1810
AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
 
1811
AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
 
1812
 
 
1813
AC_MSG_CHECKING(for --with-libs)
 
1814
AC_ARG_WITH(libs,
 
1815
            AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
 
1816
[
 
1817
AC_MSG_RESULT($withval)
 
1818
LIBS="$withval $LIBS"
 
1819
],
 
1820
[AC_MSG_RESULT(no)])
 
1821
 
 
1822
# Check for use of the system libffi library
 
1823
AC_MSG_CHECKING(for --with-system-ffi)
 
1824
AC_ARG_WITH(system_ffi,
 
1825
            AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
 
1826
 
 
1827
AC_MSG_RESULT($with_system_ffi)
 
1828
 
 
1829
# Determine if signalmodule should be used.
 
1830
AC_SUBST(USE_SIGNAL_MODULE)
 
1831
AC_SUBST(SIGNAL_OBJS)
 
1832
AC_MSG_CHECKING(for --with-signal-module)
 
1833
AC_ARG_WITH(signal-module,
 
1834
            AC_HELP_STRING(--with-signal-module, disable/enable signal module))
 
1835
 
 
1836
if test -z "$with_signal_module"
 
1837
then with_signal_module="yes"
 
1838
fi
 
1839
AC_MSG_RESULT($with_signal_module)
 
1840
 
 
1841
if test "${with_signal_module}" = "yes"; then
 
1842
        USE_SIGNAL_MODULE=""
 
1843
        SIGNAL_OBJS=""
 
1844
else
 
1845
        USE_SIGNAL_MODULE="#"
 
1846
        SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
 
1847
fi
 
1848
 
 
1849
# This is used to generate Setup.config
 
1850
AC_SUBST(USE_THREAD_MODULE)
 
1851
USE_THREAD_MODULE=""
 
1852
 
 
1853
AC_MSG_CHECKING(for --with-dec-threads)
 
1854
AC_SUBST(LDLAST)
 
1855
AC_ARG_WITH(dec-threads,
 
1856
            AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
 
1857
[
 
1858
AC_MSG_RESULT($withval)
 
1859
LDLAST=-threads
 
1860
if test "${with_thread+set}" != set; then
 
1861
   with_thread="$withval";
 
1862
fi],
 
1863
[AC_MSG_RESULT(no)])
 
1864
 
 
1865
# Templates for things AC_DEFINEd more than once.
 
1866
# For a single AC_DEFINE, no template is needed.
 
1867
AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
 
1868
AH_TEMPLATE(_REENTRANT,
 
1869
  [Define to force use of thread-safe errno, h_errno, and other functions])
 
1870
AH_TEMPLATE(WITH_THREAD,
 
1871
  [Define if you want to compile in rudimentary thread support])
 
1872
 
 
1873
AC_MSG_CHECKING(for --with-threads)
 
1874
dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
 
1875
AC_ARG_WITH(threads,
 
1876
            AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
 
1877
 
 
1878
# --with-thread is deprecated, but check for it anyway
 
1879
dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
 
1880
AC_ARG_WITH(thread,
 
1881
            AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
 
1882
            [with_threads=$with_thread])
 
1883
 
 
1884
if test -z "$with_threads"
 
1885
then with_threads="yes"
 
1886
fi
 
1887
AC_MSG_RESULT($with_threads)
 
1888
 
 
1889
AC_SUBST(THREADOBJ)
 
1890
if test "$with_threads" = "no"
 
1891
then
 
1892
    USE_THREAD_MODULE="#"
 
1893
elif test "$ac_cv_pthread_is_default" = yes
 
1894
then
 
1895
    AC_DEFINE(WITH_THREAD)
 
1896
    # Defining _REENTRANT on system with POSIX threads should not hurt.
 
1897
    AC_DEFINE(_REENTRANT)
 
1898
    posix_threads=yes
 
1899
    THREADOBJ="Python/thread.o"    
 
1900
elif test "$ac_cv_kpthread" = "yes"
 
1901
then
 
1902
    CC="$CC -Kpthread"
 
1903
    if test "$ac_cv_cxx_thread" = "yes"; then
 
1904
        CXX="$CXX -Kpthread"
 
1905
    fi
 
1906
    AC_DEFINE(WITH_THREAD)
 
1907
    posix_threads=yes
 
1908
    THREADOBJ="Python/thread.o"
 
1909
elif test "$ac_cv_kthread" = "yes"
 
1910
then
 
1911
    CC="$CC -Kthread"
 
1912
    if test "$ac_cv_cxx_thread" = "yes"; then
 
1913
        CXX="$CXX -Kthread"
 
1914
    fi
 
1915
    AC_DEFINE(WITH_THREAD)
 
1916
    posix_threads=yes
 
1917
    THREADOBJ="Python/thread.o"
 
1918
elif test "$ac_cv_pthread" = "yes"
 
1919
then
 
1920
    CC="$CC -pthread"
 
1921
    if test "$ac_cv_cxx_thread" = "yes"; then
 
1922
        CXX="$CXX -pthread"
 
1923
    fi
 
1924
    AC_DEFINE(WITH_THREAD)
 
1925
    posix_threads=yes
 
1926
    THREADOBJ="Python/thread.o"
 
1927
else
 
1928
    if test ! -z "$with_threads" -a -d "$with_threads"
 
1929
    then LDFLAGS="$LDFLAGS -L$with_threads"
 
1930
    fi
 
1931
    if test ! -z "$withval" -a -d "$withval"
 
1932
    then LDFLAGS="$LDFLAGS -L$withval"
 
1933
    fi
 
1934
 
 
1935
    # According to the POSIX spec, a pthreads implementation must
 
1936
    # define _POSIX_THREADS in unistd.h. Some apparently don't
 
1937
    # (e.g. gnu pth with pthread emulation)
 
1938
    AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
 
1939
    AC_EGREP_CPP(yes,
 
1940
    [
 
1941
#include <unistd.h>
 
1942
#ifdef _POSIX_THREADS
 
1943
yes
 
1944
#endif
 
1945
    ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
 
1946
    AC_MSG_RESULT($unistd_defines_pthreads)
 
1947
 
 
1948
    AC_DEFINE(_REENTRANT)
 
1949
    AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
 
1950
    AC_DEFINE(C_THREADS)
 
1951
    AC_DEFINE(HURD_C_THREADS, 1,
 
1952
    [Define if you are using Mach cthreads directly under /include])
 
1953
    LIBS="$LIBS -lthreads"
 
1954
    THREADOBJ="Python/thread.o"],[
 
1955
    AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
 
1956
    AC_DEFINE(C_THREADS)
 
1957
    AC_DEFINE(MACH_C_THREADS, 1,
 
1958
    [Define if you are using Mach cthreads under mach /])
 
1959
    THREADOBJ="Python/thread.o"],[
 
1960
    AC_MSG_CHECKING(for --with-pth)
 
1961
    AC_ARG_WITH([pth],
 
1962
                AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
 
1963
                [AC_MSG_RESULT($withval)
 
1964
                  AC_DEFINE([WITH_THREAD])
 
1965
                  AC_DEFINE([HAVE_PTH], 1,
 
1966
                            [Define if you have GNU PTH threads.])
 
1967
                  LIBS="-lpth $LIBS"
 
1968
                  THREADOBJ="Python/thread.o"],
 
1969
                [AC_MSG_RESULT(no)
 
1970
 
 
1971
    # Just looking for pthread_create in libpthread is not enough:
 
1972
    # on HP/UX, pthread.h renames pthread_create to a different symbol name.
 
1973
    # So we really have to include pthread.h, and then link.
 
1974
    _libs=$LIBS
 
1975
    LIBS="$LIBS -lpthread"
 
1976
    AC_MSG_CHECKING([for pthread_create in -lpthread])
 
1977
    AC_TRY_LINK([#include <pthread.h>
 
1978
 
 
1979
void * start_routine (void *arg) { exit (0); }], [
 
1980
pthread_create (NULL, NULL, start_routine, NULL)], [
 
1981
    AC_MSG_RESULT(yes)
 
1982
    AC_DEFINE(WITH_THREAD)
 
1983
    posix_threads=yes
 
1984
    THREADOBJ="Python/thread.o"],[
 
1985
    LIBS=$_libs
 
1986
    AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
 
1987
    posix_threads=yes
 
1988
    THREADOBJ="Python/thread.o"],[
 
1989
    AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
 
1990
    AC_DEFINE(ATHEOS_THREADS, 1,
 
1991
    [Define this if you have AtheOS threads.])
 
1992
    THREADOBJ="Python/thread.o"],[
 
1993
    AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
 
1994
    posix_threads=yes
 
1995
    LIBS="$LIBS -lpthreads"
 
1996
    THREADOBJ="Python/thread.o"], [
 
1997
    AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
 
1998
    posix_threads=yes
 
1999
    LIBS="$LIBS -lc_r"
 
2000
    THREADOBJ="Python/thread.o"], [
 
2001
    AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
 
2002
    posix_threads=yes
 
2003
    LIBS="$LIBS -lpthread"
 
2004
    THREADOBJ="Python/thread.o"], [
 
2005
    AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
 
2006
    posix_threads=yes
 
2007
    LIBS="$LIBS -lcma"
 
2008
    THREADOBJ="Python/thread.o"],[
 
2009
    USE_THREAD_MODULE="#"])
 
2010
    ])])])])])])])])])
 
2011
 
 
2012
    AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
 
2013
    LIBS="$LIBS -lmpc"
 
2014
    THREADOBJ="Python/thread.o"
 
2015
    USE_THREAD_MODULE=""])
 
2016
 
 
2017
    if test "$posix_threads" != "yes"; then     
 
2018
      AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
 
2019
      LIBS="$LIBS -lthread"
 
2020
      THREADOBJ="Python/thread.o"
 
2021
      USE_THREAD_MODULE=""])
 
2022
    fi
 
2023
 
 
2024
    if test "$USE_THREAD_MODULE" != "#"
 
2025
    then
 
2026
        # If the above checks didn't disable threads, (at least) OSF1
 
2027
        # needs this '-threads' argument during linking.
 
2028
        case $ac_sys_system in
 
2029
        OSF1) LDLAST=-threads;;
 
2030
        esac
 
2031
    fi
 
2032
fi
 
2033
 
 
2034
if test "$posix_threads" = "yes"; then
 
2035
      if test "$unistd_defines_pthreads" = "no"; then
 
2036
         AC_DEFINE(_POSIX_THREADS, 1,
 
2037
         [Define if you have POSIX threads, 
 
2038
          and your system does not define that.])
 
2039
      fi
 
2040
 
 
2041
      # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
 
2042
      case  $ac_sys_system/$ac_sys_release in
 
2043
  SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
 
2044
                       Defined for Solaris 2.6 bug in pthread header.)
 
2045
                       ;;
 
2046
      SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
 
2047
                       Define if the Posix semaphores do not work on your system)
 
2048
                       ;;
 
2049
      AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
 
2050
                       Define if the Posix semaphores do not work on your system)
 
2051
                       ;;
 
2052
      esac
 
2053
 
 
2054
      AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
 
2055
      AC_CACHE_VAL(ac_cv_pthread_system_supported,
 
2056
      [AC_TRY_RUN([#include <pthread.h>
 
2057
      void *foo(void *parm) {
 
2058
        return NULL;
 
2059
      }
 
2060
      main() {
 
2061
        pthread_attr_t attr;
 
2062
        pthread_t id;
 
2063
        if (pthread_attr_init(&attr)) exit(-1);
 
2064
        if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
 
2065
        if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
 
2066
        exit(0);
 
2067
      }],
 
2068
      ac_cv_pthread_system_supported=yes,
 
2069
      ac_cv_pthread_system_supported=no,
 
2070
      ac_cv_pthread_system_supported=no)
 
2071
      ])
 
2072
      AC_MSG_RESULT($ac_cv_pthread_system_supported)
 
2073
      if test "$ac_cv_pthread_system_supported" = "yes"; then
 
2074
        AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
 
2075
      fi
 
2076
      AC_CHECK_FUNCS(pthread_sigmask,
 
2077
        [case $ac_sys_system in
 
2078
        CYGWIN*)
 
2079
          AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
 
2080
            [Define if pthread_sigmask() does not work on your system.])
 
2081
            ;;
 
2082
        esac])
 
2083
fi
 
2084
 
 
2085
 
 
2086
# Check for enable-ipv6
 
2087
AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
 
2088
AC_MSG_CHECKING([if --enable-ipv6 is specified])
 
2089
AC_ARG_ENABLE(ipv6,
 
2090
[  --enable-ipv6           Enable ipv6 (with ipv4) support
 
2091
  --disable-ipv6          Disable ipv6 support],
 
2092
[ case "$enableval" in
 
2093
  no)
 
2094
       AC_MSG_RESULT(no)
 
2095
       ipv6=no
 
2096
       ;;
 
2097
  *)   AC_MSG_RESULT(yes)
 
2098
       AC_DEFINE(ENABLE_IPV6)
 
2099
       ipv6=yes
 
2100
       ;;
 
2101
  esac ],
 
2102
 
 
2103
[
 
2104
dnl the check does not work on cross compilation case...
 
2105
  AC_TRY_RUN([ /* AF_INET6 available check */
 
2106
#include <sys/types.h>
 
2107
#include <sys/socket.h>
 
2108
main()
 
2109
{
 
2110
 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
 
2111
   exit(1);
 
2112
 else
 
2113
   exit(0);
 
2114
}
 
2115
],
 
2116
  AC_MSG_RESULT(yes)
 
2117
  ipv6=yes,
 
2118
  AC_MSG_RESULT(no)
 
2119
  ipv6=no,
 
2120
  AC_MSG_RESULT(no)
 
2121
  ipv6=no
 
2122
)
 
2123
 
 
2124
if test "$ipv6" = "yes"; then
 
2125
        AC_MSG_CHECKING(if RFC2553 API is available)
 
2126
        AC_TRY_COMPILE([#include <sys/types.h>
 
2127
#include <netinet/in.h>],
 
2128
        [struct sockaddr_in6 x;
 
2129
x.sin6_scope_id;],
 
2130
                AC_MSG_RESULT(yes)
 
2131
                ipv6=yes,
 
2132
                AC_MSG_RESULT(no, IPv6 disabled)
 
2133
                ipv6=no)
 
2134
fi
 
2135
 
 
2136
if test "$ipv6" = "yes"; then
 
2137
        AC_DEFINE(ENABLE_IPV6)
 
2138
fi
 
2139
])
 
2140
 
 
2141
ipv6type=unknown
 
2142
ipv6lib=none
 
2143
ipv6trylibc=no
 
2144
 
 
2145
if test "$ipv6" = "yes"; then
 
2146
        AC_MSG_CHECKING([ipv6 stack type])
 
2147
        for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
 
2148
        do
 
2149
                case $i in
 
2150
                inria)
 
2151
                        dnl http://www.kame.net/
 
2152
                        AC_EGREP_CPP(yes, [
 
2153
#include <netinet/in.h>
 
2154
#ifdef IPV6_INRIA_VERSION
 
2155
yes
 
2156
#endif],
 
2157
                                [ipv6type=$i])
 
2158
                        ;;
 
2159
                kame)
 
2160
                        dnl http://www.kame.net/
 
2161
                        AC_EGREP_CPP(yes, [
 
2162
#include <netinet/in.h>
 
2163
#ifdef __KAME__
 
2164
yes
 
2165
#endif],
 
2166
                                [ipv6type=$i;
 
2167
                                ipv6lib=inet6
 
2168
                                ipv6libdir=/usr/local/v6/lib
 
2169
                                ipv6trylibc=yes])
 
2170
                        ;;
 
2171
                linux-glibc)
 
2172
                        dnl http://www.v6.linux.or.jp/
 
2173
                        AC_EGREP_CPP(yes, [
 
2174
#include <features.h>
 
2175
#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
 
2176
yes
 
2177
#endif],
 
2178
                                [ipv6type=$i;
 
2179
                                ipv6trylibc=yes])
 
2180
                        ;;
 
2181
                linux-inet6)
 
2182
                        dnl http://www.v6.linux.or.jp/
 
2183
                        if test -d /usr/inet6; then
 
2184
                                ipv6type=$i
 
2185
                                ipv6lib=inet6
 
2186
                                ipv6libdir=/usr/inet6/lib
 
2187
                                BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
 
2188
                        fi
 
2189
                        ;;
 
2190
                solaris)
 
2191
                        if test -f /etc/netconfig; then
 
2192
                          if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
 
2193
                                ipv6type=$i
 
2194
                                ipv6trylibc=yes
 
2195
                          fi
 
2196
                        fi
 
2197
                        ;;
 
2198
                toshiba)
 
2199
                        AC_EGREP_CPP(yes, [
 
2200
#include <sys/param.h>
 
2201
#ifdef _TOSHIBA_INET6
 
2202
yes
 
2203
#endif],
 
2204
                                [ipv6type=$i;
 
2205
                                ipv6lib=inet6;
 
2206
                                ipv6libdir=/usr/local/v6/lib])
 
2207
                        ;;
 
2208
                v6d)
 
2209
                        AC_EGREP_CPP(yes, [
 
2210
#include </usr/local/v6/include/sys/v6config.h>
 
2211
#ifdef __V6D__
 
2212
yes
 
2213
#endif],
 
2214
                                [ipv6type=$i;
 
2215
                                ipv6lib=v6;
 
2216
                                ipv6libdir=/usr/local/v6/lib;
 
2217
                                BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
 
2218
                        ;;
 
2219
                zeta)
 
2220
                        AC_EGREP_CPP(yes, [
 
2221
#include <sys/param.h>
 
2222
#ifdef _ZETA_MINAMI_INET6
 
2223
yes
 
2224
#endif],
 
2225
                                [ipv6type=$i;
 
2226
                                ipv6lib=inet6;
 
2227
                                ipv6libdir=/usr/local/v6/lib])
 
2228
                        ;;
 
2229
                esac
 
2230
                if test "$ipv6type" != "unknown"; then
 
2231
                        break
 
2232
                fi
 
2233
        done
 
2234
        AC_MSG_RESULT($ipv6type)
 
2235
fi
 
2236
 
 
2237
if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
 
2238
        if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
 
2239
                LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
 
2240
                echo "using lib$ipv6lib"
 
2241
        else
 
2242
                if test $ipv6trylibc = "yes"; then
 
2243
                        echo "using libc"
 
2244
                else
 
2245
                        echo 'Fatal: no $ipv6lib library found.  cannot continue.'
 
2246
                        echo "You need to fetch lib$ipv6lib.a from appropriate"
 
2247
                        echo 'ipv6 kit and compile beforehand.'
 
2248
                        exit 1
 
2249
                fi
 
2250
        fi
 
2251
fi
 
2252
 
 
2253
AC_MSG_CHECKING(for OSX 10.5 SDK or later)
 
2254
AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
 
2255
  AC_DEFINE(HAVE_OSX105_SDK, 1, Define if compiling using MacOS X 10.5 SDK or later.)
 
2256
  AC_MSG_RESULT(yes),
 
2257
  AC_MSG_RESULT(no)
 
2258
)
 
2259
 
 
2260
# Check for --with-doc-strings
 
2261
AC_MSG_CHECKING(for --with-doc-strings)
 
2262
AC_ARG_WITH(doc-strings,
 
2263
            AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
 
2264
 
 
2265
if test -z "$with_doc_strings"
 
2266
then with_doc_strings="yes"
 
2267
fi
 
2268
if test "$with_doc_strings" != "no"
 
2269
then
 
2270
    AC_DEFINE(WITH_DOC_STRINGS, 1,
 
2271
      [Define if you want documentation strings in extension modules])
 
2272
fi
 
2273
AC_MSG_RESULT($with_doc_strings)
 
2274
 
 
2275
# Check for Python-specific malloc support
 
2276
AC_MSG_CHECKING(for --with-tsc)
 
2277
AC_ARG_WITH(tsc,
 
2278
[  --with(out)-tsc         enable/disable timestamp counter profile], [
 
2279
if test "$withval" != no
 
2280
then 
 
2281
  AC_DEFINE(WITH_TSC, 1, 
 
2282
    [Define to profile with the Pentium timestamp counter]) 
 
2283
    AC_MSG_RESULT(yes)
 
2284
else AC_MSG_RESULT(no)
 
2285
fi],
 
2286
[AC_MSG_RESULT(no)])
 
2287
 
 
2288
# Check for Python-specific malloc support
 
2289
AC_MSG_CHECKING(for --with-pymalloc)
 
2290
AC_ARG_WITH(pymalloc,
 
2291
            AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
 
2292
 
 
2293
if test -z "$with_pymalloc"
 
2294
then with_pymalloc="yes"
 
2295
fi
 
2296
if test "$with_pymalloc" != "no"
 
2297
then
 
2298
    AC_DEFINE(WITH_PYMALLOC, 1, 
 
2299
     [Define if you want to compile in Python-specific mallocs])
 
2300
fi
 
2301
AC_MSG_RESULT($with_pymalloc)
 
2302
 
 
2303
# Check for --with-wctype-functions
 
2304
AC_MSG_CHECKING(for --with-wctype-functions)
 
2305
AC_ARG_WITH(wctype-functions, 
 
2306
            AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
 
2307
[
 
2308
if test "$withval" != no
 
2309
then 
 
2310
  AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
 
2311
  [Define if you want wctype.h functions to be used instead of the
 
2312
   one supplied by Python itself. (see Include/unicodectype.h).]) 
 
2313
  AC_MSG_RESULT(yes)
 
2314
else AC_MSG_RESULT(no)
 
2315
fi],
 
2316
[AC_MSG_RESULT(no)])
 
2317
 
 
2318
# -I${DLINCLDIR} is added to the compile rule for importdl.o
 
2319
AC_SUBST(DLINCLDIR)
 
2320
DLINCLDIR=.
 
2321
 
 
2322
# the dlopen() function means we might want to use dynload_shlib.o. some
 
2323
# platforms, such as AIX, have dlopen(), but don't want to use it.
 
2324
AC_CHECK_FUNCS(dlopen)
 
2325
 
 
2326
# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
 
2327
# loading of modules.
 
2328
AC_SUBST(DYNLOADFILE)
 
2329
AC_MSG_CHECKING(DYNLOADFILE)
 
2330
if test -z "$DYNLOADFILE"
 
2331
then
 
2332
        case $ac_sys_system/$ac_sys_release in
 
2333
        AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
 
2334
        if test "$ac_cv_func_dlopen" = yes
 
2335
        then DYNLOADFILE="dynload_shlib.o"
 
2336
        else DYNLOADFILE="dynload_aix.o"
 
2337
        fi
 
2338
        ;;
 
2339
        hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
 
2340
        # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
 
2341
        Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
 
2342
        atheos*) DYNLOADFILE="dynload_atheos.o";;
 
2343
        *)
 
2344
        # use dynload_shlib.c and dlopen() if we have it; otherwise stub
 
2345
        # out any dynamic loading
 
2346
        if test "$ac_cv_func_dlopen" = yes
 
2347
        then DYNLOADFILE="dynload_shlib.o"
 
2348
        else DYNLOADFILE="dynload_stub.o"
 
2349
        fi
 
2350
        ;;
 
2351
        esac
 
2352
fi
 
2353
AC_MSG_RESULT($DYNLOADFILE)
 
2354
if test "$DYNLOADFILE" != "dynload_stub.o"
 
2355
then
 
2356
        AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
 
2357
        [Defined when any dynamic module loading is enabled.])
 
2358
fi
 
2359
 
 
2360
# MACHDEP_OBJS can be set to platform-specific object files needed by Python
 
2361
 
 
2362
AC_SUBST(MACHDEP_OBJS)
 
2363
AC_MSG_CHECKING(MACHDEP_OBJS)
 
2364
if test -z "$MACHDEP_OBJS"
 
2365
then
 
2366
        MACHDEP_OBJS=$extra_machdep_objs
 
2367
else
 
2368
        MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
 
2369
fi
 
2370
AC_MSG_RESULT(MACHDEP_OBJS)
 
2371
 
 
2372
# checks for library functions
 
2373
AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
 
2374
 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
 
2375
 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
 
2376
 getpriority getpwent getspnam getspent getsid getwd \
 
2377
 kill killpg lchmod lchown lstat mkfifo mknod mktime \
 
2378
 mremap nice pathconf pause plock poll pthread_init \
 
2379
 putenv readlink realpath \
 
2380
 select setegid seteuid setgid \
 
2381
 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
 
2382
 sigaction siginterrupt sigrelse strftime strlcpy \
 
2383
 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
 
2384
 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll wcsxfrm _getpty)
 
2385
 
 
2386
# For some functions, having a definition is not sufficient, since
 
2387
# we want to take their address.
 
2388
AC_MSG_CHECKING(for chroot)
 
2389
AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
 
2390
  AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
 
2391
  AC_MSG_RESULT(yes),
 
2392
  AC_MSG_RESULT(no)
 
2393
)
 
2394
AC_MSG_CHECKING(for link)
 
2395
AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
 
2396
  AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
 
2397
  AC_MSG_RESULT(yes),
 
2398
  AC_MSG_RESULT(no)
 
2399
)
 
2400
AC_MSG_CHECKING(for symlink)
 
2401
AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
 
2402
  AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
 
2403
  AC_MSG_RESULT(yes),
 
2404
  AC_MSG_RESULT(no)
 
2405
)
 
2406
AC_MSG_CHECKING(for fchdir)
 
2407
AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
 
2408
  AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
 
2409
  AC_MSG_RESULT(yes),
 
2410
  AC_MSG_RESULT(no)
 
2411
)
 
2412
AC_MSG_CHECKING(for fsync)
 
2413
AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
 
2414
  AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
 
2415
  AC_MSG_RESULT(yes),
 
2416
  AC_MSG_RESULT(no)
 
2417
)
 
2418
AC_MSG_CHECKING(for fdatasync)
 
2419
AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
 
2420
  AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
 
2421
  AC_MSG_RESULT(yes),
 
2422
  AC_MSG_RESULT(no)
 
2423
)
 
2424
AC_MSG_CHECKING(for epoll)
 
2425
AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
 
2426
  AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
 
2427
  AC_MSG_RESULT(yes),
 
2428
  AC_MSG_RESULT(no)
 
2429
)
 
2430
AC_MSG_CHECKING(for kqueue)
 
2431
AC_TRY_COMPILE([
 
2432
#include <sys/types.h>
 
2433
#include <sys/event.h>
 
2434
    ], int x=kqueue(),
 
2435
  AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
 
2436
  AC_MSG_RESULT(yes),
 
2437
  AC_MSG_RESULT(no)
 
2438
)
 
2439
# On some systems (eg. FreeBSD 5), we would find a definition of the
 
2440
# functions ctermid_r, setgroups in the library, but no prototype
 
2441
# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
 
2442
# address to avoid compiler warnings and potential miscompilations
 
2443
# because of the missing prototypes.
 
2444
 
 
2445
AC_MSG_CHECKING(for ctermid_r)
 
2446
AC_TRY_COMPILE([
 
2447
#include "confdefs.h" 
 
2448
#include <stdio.h>
 
2449
], void* p = ctermid_r,
 
2450
  AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
 
2451
  AC_MSG_RESULT(yes),
 
2452
  AC_MSG_RESULT(no)
 
2453
)
 
2454
 
 
2455
AC_MSG_CHECKING(for flock)
 
2456
AC_TRY_COMPILE([
 
2457
#include "confdefs.h" 
 
2458
#include <sys/file.h>
 
2459
], void* p = flock,
 
2460
  AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
 
2461
  AC_MSG_RESULT(yes),
 
2462
  AC_MSG_RESULT(no)
 
2463
)
 
2464
 
 
2465
AC_MSG_CHECKING(for getpagesize)
 
2466
AC_TRY_COMPILE([
 
2467
#include "confdefs.h" 
 
2468
#include <unistd.h>
 
2469
], void* p = getpagesize,
 
2470
  AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
 
2471
  AC_MSG_RESULT(yes),
 
2472
  AC_MSG_RESULT(no)
 
2473
)
 
2474
 
 
2475
dnl check for true
 
2476
AC_CHECK_PROGS(TRUE, true, /bin/true)
 
2477
 
 
2478
dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
 
2479
dnl On others, they are in the C library, so we to take no action
 
2480
AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
 
2481
  AC_CHECK_LIB(resolv, inet_aton)
 
2482
)
 
2483
 
 
2484
# On Tru64, chflags seems to be present, but calling it will
 
2485
# exit Python
 
2486
AC_MSG_CHECKING(for chflags)
 
2487
AC_TRY_RUN([
 
2488
#include <sys/stat.h>
 
2489
#include <unistd.h>
 
2490
int main(int argc, char*argv[])
 
2491
{
 
2492
  if(chflags(argv[0], 0) != 0)
 
2493
    return 1;
 
2494
  return 0;
 
2495
}
 
2496
],AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
 
2497
  AC_MSG_RESULT(yes),
 
2498
  AC_MSG_RESULT(no)
 
2499
)
 
2500
 
 
2501
AC_MSG_CHECKING(for lchflags)
 
2502
AC_TRY_RUN([
 
2503
#include <sys/stat.h>
 
2504
#include <unistd.h>
 
2505
int main(int argc, char*argv[])
 
2506
{
 
2507
  if(lchflags(argv[0], 0) != 0)
 
2508
    return 1;
 
2509
  return 0;
 
2510
}
 
2511
],AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
 
2512
  AC_MSG_RESULT(yes),
 
2513
  AC_MSG_RESULT(no)
 
2514
)
 
2515
 
 
2516
dnl Check if system zlib has *Copy() functions
 
2517
dnl
 
2518
dnl On MacOSX the linker will search for dylibs on the entire linker path
 
2519
dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
 
2520
dnl to revert to a more traditional unix behaviour and make it possible to
 
2521
dnl override the system libz with a local static library of libz. Temporarily
 
2522
dnl add that flag to our CFLAGS as well to ensure that we check the version
 
2523
dnl of libz that will be used by setup.py. 
 
2524
dnl The -L/usr/local/lib is needed as wel to get the same compilation 
 
2525
dnl environment as setup.py (and leaving it out can cause configure to use the
 
2526
dnl wrong version of the library)
 
2527
case $ac_sys_system/$ac_sys_release in
 
2528
Darwin/*) 
 
2529
        _CUR_CFLAGS="${CFLAGS}"
 
2530
        _CUR_LDFLAGS="${LDFLAGS}"
 
2531
        CFLAGS="${CFLAGS} -Wl,-search_paths_first"
 
2532
        LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
 
2533
        ;;
 
2534
esac
 
2535
 
 
2536
AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
 
2537
 
 
2538
case $ac_sys_system/$ac_sys_release in
 
2539
Darwin/*) 
 
2540
        CFLAGS="${_CUR_CFLAGS}"
 
2541
        LDFLAGS="${_CUR_LDFLAGS}"
 
2542
        ;;
 
2543
esac
 
2544
 
 
2545
AC_MSG_CHECKING(for hstrerror)
 
2546
AC_TRY_LINK([
 
2547
#include "confdefs.h" 
 
2548
#include <netdb.h>
 
2549
], void* p = hstrerror; hstrerror(0),
 
2550
  AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
 
2551
  AC_MSG_RESULT(yes),
 
2552
  AC_MSG_RESULT(no)
 
2553
)
 
2554
 
 
2555
AC_MSG_CHECKING(for inet_aton)
 
2556
AC_TRY_LINK([
 
2557
#include "confdefs.h" 
 
2558
#include <sys/types.h>
 
2559
#include <sys/socket.h>
 
2560
#include <netinet/in.h>
 
2561
#include <arpa/inet.h>
 
2562
], void* p = inet_aton;inet_aton(0,0),
 
2563
  AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
 
2564
  AC_MSG_RESULT(yes),
 
2565
  AC_MSG_RESULT(no)
 
2566
)
 
2567
 
 
2568
AC_MSG_CHECKING(for inet_pton)
 
2569
AC_TRY_COMPILE([
 
2570
#include "confdefs.h" 
 
2571
#include <sys/types.h>
 
2572
#include <sys/socket.h>
 
2573
#include <netinet/in.h>
 
2574
#include <arpa/inet.h>
 
2575
], void* p = inet_pton,
 
2576
  AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
 
2577
  AC_MSG_RESULT(yes),
 
2578
  AC_MSG_RESULT(no)
 
2579
)
 
2580
 
 
2581
# On some systems, setgroups is in unistd.h, on others, in grp.h
 
2582
AC_MSG_CHECKING(for setgroups)
 
2583
AC_TRY_COMPILE([
 
2584
#include "confdefs.h" 
 
2585
#include <unistd.h>
 
2586
#ifdef HAVE_GRP_H
 
2587
#include <grp.h>
 
2588
#endif
 
2589
], 
 
2590
void* p = setgroups,
 
2591
  AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
 
2592
  AC_MSG_RESULT(yes),
 
2593
  AC_MSG_RESULT(no)
 
2594
)
 
2595
 
 
2596
# check for openpty and forkpty
 
2597
 
 
2598
AC_CHECK_FUNCS(openpty,, 
 
2599
   AC_CHECK_LIB(util,openpty,
 
2600
     [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
 
2601
     AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
 
2602
   )
 
2603
)
 
2604
AC_CHECK_FUNCS(forkpty,, 
 
2605
   AC_CHECK_LIB(util,forkpty, 
 
2606
     [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
 
2607
     AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
 
2608
   )
 
2609
)
 
2610
 
 
2611
# Stuff for expat.
 
2612
AC_CHECK_FUNCS(memmove)
 
2613
 
 
2614
# check for long file support functions
 
2615
AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
 
2616
 
 
2617
AC_REPLACE_FUNCS(dup2 getcwd strdup)
 
2618
AC_CHECK_FUNCS(getpgrp, 
 
2619
  AC_TRY_COMPILE([#include <unistd.h>], 
 
2620
   [getpgrp(0);], 
 
2621
   AC_DEFINE(GETPGRP_HAVE_ARG, 1,
 
2622
   [Define if getpgrp() must be called as getpgrp(0).])
 
2623
 )
 
2624
)
 
2625
AC_CHECK_FUNCS(setpgrp,
 
2626
  AC_TRY_COMPILE([#include <unistd.h>],
 
2627
    [setpgrp(0,0);],
 
2628
    AC_DEFINE(SETPGRP_HAVE_ARG, 1,
 
2629
    [Define if setpgrp() must be called as setpgrp(0, 0).])
 
2630
  )
 
2631
)
 
2632
AC_CHECK_FUNCS(gettimeofday, 
 
2633
  AC_TRY_COMPILE([#include <sys/time.h>], 
 
2634
    [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
 
2635
    AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
 
2636
    [Define if gettimeofday() does not have second (timezone) argument
 
2637
     This is the case on Motorola V4 (R40V4.2)])
 
2638
  )
 
2639
)
 
2640
 
 
2641
AC_MSG_CHECKING(for major, minor, and makedev)
 
2642
AC_TRY_LINK([
 
2643
#if defined(MAJOR_IN_MKDEV)
 
2644
#include <sys/mkdev.h>
 
2645
#elif defined(MAJOR_IN_SYSMACROS)
 
2646
#include <sys/sysmacros.h>
 
2647
#else
 
2648
#include <sys/types.h>
 
2649
#endif
 
2650
],[
 
2651
  makedev(major(0),minor(0));
 
2652
],[
 
2653
  AC_DEFINE(HAVE_DEVICE_MACROS, 1,
 
2654
            [Define to 1 if you have the device macros.])
 
2655
  AC_MSG_RESULT(yes)
 
2656
],[
 
2657
  AC_MSG_RESULT(no)
 
2658
])
 
2659
 
 
2660
# On OSF/1 V5.1, getaddrinfo is available, but a define
 
2661
# for [no]getaddrinfo in netdb.h. 
 
2662
AC_MSG_CHECKING(for getaddrinfo)
 
2663
AC_TRY_LINK([
 
2664
#include <sys/types.h>
 
2665
#include <sys/socket.h>
 
2666
#include <netdb.h>
 
2667
#include <stdio.h>
 
2668
],[
 
2669
getaddrinfo(NULL, NULL, NULL, NULL);
 
2670
], [
 
2671
AC_MSG_RESULT(yes)
 
2672
AC_MSG_CHECKING(getaddrinfo bug)
 
2673
AC_TRY_RUN([
 
2674
#include <sys/types.h>
 
2675
#include <netdb.h>
 
2676
#include <string.h>
 
2677
#include <sys/socket.h>
 
2678
#include <netinet/in.h>
 
2679
 
 
2680
main()
 
2681
{
 
2682
  int passive, gaierr, inet4 = 0, inet6 = 0;
 
2683
  struct addrinfo hints, *ai, *aitop;
 
2684
  char straddr[INET6_ADDRSTRLEN], strport[16];
 
2685
 
 
2686
  for (passive = 0; passive <= 1; passive++) {
 
2687
    memset(&hints, 0, sizeof(hints));
 
2688
    hints.ai_family = AF_UNSPEC;
 
2689
    hints.ai_flags = passive ? AI_PASSIVE : 0;
 
2690
    hints.ai_socktype = SOCK_STREAM;
 
2691
    hints.ai_protocol = IPPROTO_TCP;
 
2692
    if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
 
2693
      (void)gai_strerror(gaierr);
 
2694
      goto bad;
 
2695
    }
 
2696
    for (ai = aitop; ai; ai = ai->ai_next) {
 
2697
      if (ai->ai_addr == NULL ||
 
2698
          ai->ai_addrlen == 0 ||
 
2699
          getnameinfo(ai->ai_addr, ai->ai_addrlen,
 
2700
                      straddr, sizeof(straddr), strport, sizeof(strport),
 
2701
                      NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
 
2702
        goto bad;
 
2703
      }
 
2704
      switch (ai->ai_family) {
 
2705
      case AF_INET:
 
2706
        if (strcmp(strport, "54321") != 0) {
 
2707
          goto bad;
 
2708
        }
 
2709
        if (passive) {
 
2710
          if (strcmp(straddr, "0.0.0.0") != 0) {
 
2711
            goto bad;
 
2712
          }
 
2713
        } else {
 
2714
          if (strcmp(straddr, "127.0.0.1") != 0) {
 
2715
            goto bad;
 
2716
          }
 
2717
        }
 
2718
        inet4++;
 
2719
        break;
 
2720
      case AF_INET6:
 
2721
        if (strcmp(strport, "54321") != 0) {
 
2722
          goto bad;
 
2723
        }
 
2724
        if (passive) {
 
2725
          if (strcmp(straddr, "::") != 0) {
 
2726
            goto bad;
 
2727
          }
 
2728
        } else {
 
2729
          if (strcmp(straddr, "::1") != 0) {
 
2730
            goto bad;
 
2731
          }
 
2732
        }
 
2733
        inet6++;
 
2734
        break;
 
2735
      case AF_UNSPEC:
 
2736
        goto bad;
 
2737
        break;
 
2738
      default:
 
2739
        /* another family support? */
 
2740
        break;
 
2741
      }
 
2742
    }
 
2743
  }
 
2744
 
 
2745
  if (!(inet4 == 0 || inet4 == 2))
 
2746
    goto bad;
 
2747
  if (!(inet6 == 0 || inet6 == 2))
 
2748
    goto bad;
 
2749
 
 
2750
  if (aitop)
 
2751
    freeaddrinfo(aitop);
 
2752
  exit(0);
 
2753
 
 
2754
 bad:
 
2755
  if (aitop)
 
2756
    freeaddrinfo(aitop);
 
2757
  exit(1);
 
2758
}
 
2759
],
 
2760
AC_MSG_RESULT(good)
 
2761
buggygetaddrinfo=no,
 
2762
AC_MSG_RESULT(buggy)
 
2763
buggygetaddrinfo=yes,
 
2764
AC_MSG_RESULT(buggy)
 
2765
buggygetaddrinfo=yes)], [
 
2766
AC_MSG_RESULT(no)
 
2767
buggygetaddrinfo=yes
 
2768
])
 
2769
 
 
2770
if test "$buggygetaddrinfo" = "yes"; then
 
2771
        if test "$ipv6" = "yes"; then
 
2772
                echo 'Fatal: You must get working getaddrinfo() function.'
 
2773
                echo '       or you can specify "--disable-ipv6"'.
 
2774
                exit 1
 
2775
        fi
 
2776
else
 
2777
        AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
 
2778
fi
 
2779
AC_CHECK_FUNCS(getnameinfo)
 
2780
 
 
2781
# checks for structures
 
2782
AC_HEADER_TIME
 
2783
AC_STRUCT_TM
 
2784
AC_STRUCT_TIMEZONE
 
2785
AC_CHECK_MEMBERS([struct stat.st_rdev])
 
2786
AC_CHECK_MEMBERS([struct stat.st_blksize])
 
2787
AC_CHECK_MEMBERS([struct stat.st_flags])
 
2788
AC_CHECK_MEMBERS([struct stat.st_gen])
 
2789
AC_CHECK_MEMBERS([struct stat.st_birthtime])
 
2790
AC_STRUCT_ST_BLOCKS
 
2791
 
 
2792
AC_MSG_CHECKING(for time.h that defines altzone)
 
2793
AC_CACHE_VAL(ac_cv_header_time_altzone,
 
2794
[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
 
2795
  ac_cv_header_time_altzone=yes,
 
2796
  ac_cv_header_time_altzone=no)])
 
2797
AC_MSG_RESULT($ac_cv_header_time_altzone)
 
2798
if test $ac_cv_header_time_altzone = yes; then
 
2799
  AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
 
2800
fi
 
2801
 
 
2802
was_it_defined=no
 
2803
AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
 
2804
AC_TRY_COMPILE([
 
2805
#include <sys/types.h>
 
2806
#include <sys/select.h>
 
2807
#include <sys/time.h>
 
2808
], [;], [
 
2809
  AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
 
2810
  [Define if  you can safely include both <sys/select.h> and <sys/time.h>
 
2811
   (which you can't on SCO ODT 3.0).]) 
 
2812
  was_it_defined=yes
 
2813
])
 
2814
AC_MSG_RESULT($was_it_defined)
 
2815
 
 
2816
AC_MSG_CHECKING(for addrinfo)
 
2817
AC_CACHE_VAL(ac_cv_struct_addrinfo,
 
2818
AC_TRY_COMPILE([
 
2819
#               include <netdb.h>],
 
2820
        [struct addrinfo a],
 
2821
        ac_cv_struct_addrinfo=yes,
 
2822
        ac_cv_struct_addrinfo=no))
 
2823
AC_MSG_RESULT($ac_cv_struct_addrinfo)
 
2824
if test $ac_cv_struct_addrinfo = yes; then
 
2825
        AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
 
2826
fi
 
2827
 
 
2828
AC_MSG_CHECKING(for sockaddr_storage)
 
2829
AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
 
2830
AC_TRY_COMPILE([
 
2831
#               include <sys/types.h>
 
2832
#               include <sys/socket.h>],
 
2833
        [struct sockaddr_storage s],
 
2834
        ac_cv_struct_sockaddr_storage=yes,
 
2835
        ac_cv_struct_sockaddr_storage=no))
 
2836
AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
 
2837
if test $ac_cv_struct_sockaddr_storage = yes; then
 
2838
        AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
 
2839
fi
 
2840
 
 
2841
# checks for compiler characteristics
 
2842
 
 
2843
AC_C_CHAR_UNSIGNED
 
2844
AC_C_CONST
 
2845
 
 
2846
works=no
 
2847
AC_MSG_CHECKING(for working volatile)
 
2848
AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, 
 
2849
  AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
 
2850
)
 
2851
AC_MSG_RESULT($works)
 
2852
 
 
2853
works=no
 
2854
AC_MSG_CHECKING(for working signed char)
 
2855
AC_TRY_COMPILE([], [signed char c;], works=yes, 
 
2856
  AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
 
2857
)
 
2858
AC_MSG_RESULT($works)
 
2859
 
 
2860
have_prototypes=no
 
2861
AC_MSG_CHECKING(for prototypes)
 
2862
AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
 
2863
  AC_DEFINE(HAVE_PROTOTYPES, 1, 
 
2864
   [Define if your compiler supports function prototype]) 
 
2865
  have_prototypes=yes
 
2866
])
 
2867
AC_MSG_RESULT($have_prototypes)
 
2868
 
 
2869
works=no
 
2870
AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
 
2871
AC_TRY_COMPILE([
 
2872
#include <stdarg.h>
 
2873
int foo(int x, ...) {
 
2874
        va_list va;
 
2875
        va_start(va, x);
 
2876
        va_arg(va, int);
 
2877
        va_arg(va, char *);
 
2878
        va_arg(va, double);
 
2879
        return 0;
 
2880
}
 
2881
], [return foo(10, "", 3.14);], [
 
2882
  AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
 
2883
   [Define if your compiler supports variable length function prototypes
 
2884
   (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>]) 
 
2885
  works=yes
 
2886
])
 
2887
AC_MSG_RESULT($works)
 
2888
 
 
2889
# check for socketpair
 
2890
AC_MSG_CHECKING(for socketpair)
 
2891
AC_TRY_COMPILE([
 
2892
#include <sys/types.h>
 
2893
#include <sys/socket.h>
 
2894
], void *x=socketpair,
 
2895
  AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
 
2896
  AC_MSG_RESULT(yes),
 
2897
  AC_MSG_RESULT(no)
 
2898
)
 
2899
 
 
2900
# check if sockaddr has sa_len member
 
2901
AC_MSG_CHECKING(if sockaddr has sa_len member)
 
2902
AC_TRY_COMPILE([#include <sys/types.h>
 
2903
#include <sys/socket.h>],
 
2904
[struct sockaddr x;
 
2905
x.sa_len = 0;],
 
2906
        AC_MSG_RESULT(yes)
 
2907
        AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
 
2908
        AC_MSG_RESULT(no))
 
2909
 
 
2910
va_list_is_array=no
 
2911
AC_MSG_CHECKING(whether va_list is an array)
 
2912
AC_TRY_COMPILE([
 
2913
#ifdef HAVE_STDARG_PROTOTYPES
 
2914
#include <stdarg.h>
 
2915
#else
 
2916
#include <varargs.h>
 
2917
#endif
 
2918
], [va_list list1, list2; list1 = list2;], , [
 
2919
 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind]) 
 
2920
 va_list_is_array=yes
 
2921
])
 
2922
AC_MSG_RESULT($va_list_is_array)
 
2923
 
 
2924
# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
 
2925
AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
 
2926
  [Define this if you have some version of gethostbyname_r()])
 
2927
 
 
2928
AC_CHECK_FUNC(gethostbyname_r, [
 
2929
  AC_DEFINE(HAVE_GETHOSTBYNAME_R)
 
2930
  AC_MSG_CHECKING([gethostbyname_r with 6 args])
 
2931
  OLD_CFLAGS=$CFLAGS
 
2932
  CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
 
2933
  AC_TRY_COMPILE([
 
2934
#   include <netdb.h>
 
2935
  ], [
 
2936
    char *name;
 
2937
    struct hostent *he, *res;
 
2938
    char buffer[2048];
 
2939
    int buflen = 2048;
 
2940
    int h_errnop;
 
2941
 
 
2942
    (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
 
2943
  ], [
 
2944
    AC_DEFINE(HAVE_GETHOSTBYNAME_R)
 
2945
    AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
 
2946
    [Define this if you have the 6-arg version of gethostbyname_r().])
 
2947
    AC_MSG_RESULT(yes)
 
2948
  ], [
 
2949
    AC_MSG_RESULT(no)
 
2950
    AC_MSG_CHECKING([gethostbyname_r with 5 args])
 
2951
    AC_TRY_COMPILE([
 
2952
#     include <netdb.h>
 
2953
    ], [
 
2954
      char *name;
 
2955
      struct hostent *he;
 
2956
      char buffer[2048];
 
2957
      int buflen = 2048;
 
2958
      int h_errnop;
 
2959
 
 
2960
      (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
 
2961
    ], [
 
2962
      AC_DEFINE(HAVE_GETHOSTBYNAME_R)
 
2963
      AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
 
2964
      [Define this if you have the 5-arg version of gethostbyname_r().])
 
2965
      AC_MSG_RESULT(yes)
 
2966
    ], [
 
2967
      AC_MSG_RESULT(no)
 
2968
      AC_MSG_CHECKING([gethostbyname_r with 3 args])
 
2969
      AC_TRY_COMPILE([
 
2970
#       include <netdb.h>
 
2971
      ], [
 
2972
        char *name;
 
2973
        struct hostent *he;
 
2974
        struct hostent_data data;
 
2975
 
 
2976
        (void) gethostbyname_r(name, he, &data);
 
2977
      ], [
 
2978
        AC_DEFINE(HAVE_GETHOSTBYNAME_R)
 
2979
        AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
 
2980
        [Define this if you have the 3-arg version of gethostbyname_r().])
 
2981
        AC_MSG_RESULT(yes)
 
2982
      ], [
 
2983
        AC_MSG_RESULT(no)
 
2984
      ])
 
2985
    ])
 
2986
  ])
 
2987
  CFLAGS=$OLD_CFLAGS
 
2988
], [
 
2989
  AC_CHECK_FUNCS(gethostbyname)
 
2990
])
 
2991
AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
 
2992
AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
 
2993
AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
 
2994
AC_SUBST(HAVE_GETHOSTBYNAME_R)
 
2995
AC_SUBST(HAVE_GETHOSTBYNAME)
 
2996
 
 
2997
# checks for system services
 
2998
# (none yet)
 
2999
 
 
3000
# Linux requires this for correct f.p. operations
 
3001
AC_CHECK_FUNC(__fpu_control,
 
3002
  [],
 
3003
  [AC_CHECK_LIB(ieee, __fpu_control)
 
3004
])
 
3005
 
 
3006
# Check for --with-fpectl
 
3007
AC_MSG_CHECKING(for --with-fpectl)
 
3008
AC_ARG_WITH(fpectl,
 
3009
            AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
 
3010
[
 
3011
if test "$withval" != no
 
3012
then 
 
3013
  AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
 
3014
  [Define if you want SIGFPE handled (see Include/pyfpe.h).]) 
 
3015
  AC_MSG_RESULT(yes)
 
3016
else AC_MSG_RESULT(no)
 
3017
fi],
 
3018
[AC_MSG_RESULT(no)])
 
3019
 
 
3020
# check for --with-libm=...
 
3021
AC_SUBST(LIBM)
 
3022
case $ac_sys_system in
 
3023
Darwin) ;;
 
3024
*) LIBM=-lm
 
3025
esac
 
3026
AC_MSG_CHECKING(for --with-libm=STRING)
 
3027
AC_ARG_WITH(libm,
 
3028
            AC_HELP_STRING(--with-libm=STRING, math library),
 
3029
[
 
3030
if test "$withval" = no
 
3031
then LIBM=
 
3032
     AC_MSG_RESULT(force LIBM empty)
 
3033
elif test "$withval" != yes
 
3034
then LIBM=$withval
 
3035
     AC_MSG_RESULT(set LIBM="$withval")
 
3036
else AC_MSG_ERROR([proper usage is --with-libm=STRING])
 
3037
fi],
 
3038
[AC_MSG_RESULT(default LIBM="$LIBM")])
 
3039
 
 
3040
# check for --with-libc=...
 
3041
AC_SUBST(LIBC)
 
3042
AC_MSG_CHECKING(for --with-libc=STRING)
 
3043
AC_ARG_WITH(libc,
 
3044
            AC_HELP_STRING(--with-libc=STRING, C library),
 
3045
[
 
3046
if test "$withval" = no
 
3047
then LIBC=
 
3048
     AC_MSG_RESULT(force LIBC empty)
 
3049
elif test "$withval" != yes
 
3050
then LIBC=$withval
 
3051
     AC_MSG_RESULT(set LIBC="$withval")
 
3052
else AC_MSG_ERROR([proper usage is --with-libc=STRING])
 
3053
fi],
 
3054
[AC_MSG_RESULT(default LIBC="$LIBC")])
 
3055
 
 
3056
# ************************************
 
3057
# * Check for mathematical functions *
 
3058
# ************************************
 
3059
 
 
3060
LIBS_SAVE=$LIBS
 
3061
LIBS="$LIBS $LIBM"
 
3062
 
 
3063
# Detect whether system arithmetic is subject to x87-style double
 
3064
# rounding issues.  The result of this test has little meaning on non
 
3065
# IEEE 754 platforms.  On IEEE 754, test should return 1 if rounding
 
3066
# mode is round-to-nearest and double rounding issues are present, and
 
3067
# 0 otherwise.  See http://bugs.python.org/issue2937 for more info.
 
3068
AC_MSG_CHECKING(for x87-style double rounding)
 
3069
AC_CACHE_VAL(ac_cv_x87_double_rounding, [
 
3070
AC_TRY_RUN([
 
3071
#include <stdlib.h>
 
3072
#include <math.h>
 
3073
int main() {
 
3074
    volatile double x, y, z;
 
3075
    /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
 
3076
    x = 0.99999999999999989; /* 1-2**-53 */
 
3077
    y = 1./x;
 
3078
    if (y != 1.)
 
3079
        exit(0);
 
3080
    /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
 
3081
    x = 1e16;
 
3082
    y = 2.99999;
 
3083
    z = x + y;
 
3084
    if (z != 1e16+4.)
 
3085
        exit(0);
 
3086
    /* both tests show evidence of double rounding */
 
3087
    exit(1);
 
3088
}
 
3089
],
 
3090
ac_cv_x87_double_rounding=no,
 
3091
ac_cv_x87_double_rounding=yes,
 
3092
ac_cv_x87_double_rounding=no)])
 
3093
AC_MSG_RESULT($ac_cv_x87_double_rounding)
 
3094
if test "$ac_cv_x87_double_rounding" = yes
 
3095
then
 
3096
  AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
 
3097
  [Define if arithmetic is subject to x87-style double rounding issue])
 
3098
fi
 
3099
 
 
3100
 
 
3101
# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
 
3102
# -0. on some architectures.
 
3103
AC_MSG_CHECKING(whether tanh preserves the sign of zero)
 
3104
AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
 
3105
AC_TRY_RUN([
 
3106
#include <math.h>
 
3107
#include <stdlib.h>
 
3108
int main() {
 
3109
    /* return 0 if either negative zeros don't exist
 
3110
       on this platform or if negative zeros exist
 
3111
       and tanh(-0.) == -0. */
 
3112
  if (atan2(0., -1.) == atan2(-0., -1.) ||
 
3113
      atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
 
3114
  else exit(1);
 
3115
}
 
3116
],
 
3117
ac_cv_tanh_preserves_zero_sign=yes,
 
3118
ac_cv_tanh_preserves_zero_sign=no,
 
3119
ac_cv_tanh_preserves_zero_sign=no)])
 
3120
AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
 
3121
if test "$ac_cv_tanh_preserves_zero_sign" = yes
 
3122
then
 
3123
  AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
 
3124
  [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
 
3125
fi
 
3126
 
 
3127
AC_CHECK_FUNCS([acosh asinh atanh copysign expm1 finite hypot log1p])
 
3128
AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
 
3129
 
 
3130
LIBS=$LIBS_SAVE
 
3131
 
 
3132
# determine what size digit to use for Python's longs
 
3133
AC_MSG_CHECKING([digit size for Python's longs])
 
3134
AC_ARG_ENABLE(big-digits,
 
3135
AC_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
 
3136
[case $enable_big_digits in
 
3137
yes)
 
3138
  enable_big_digits=30 ;;
 
3139
no)
 
3140
  enable_big_digits=15 ;;
 
3141
[15|30])
 
3142
  ;;
 
3143
*)
 
3144
  AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
 
3145
esac
 
3146
AC_MSG_RESULT($enable_big_digits)
 
3147
AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
 
3148
],
 
3149
[AC_MSG_RESULT(no value specified)])
 
3150
 
 
3151
# check for wchar.h
 
3152
AC_CHECK_HEADER(wchar.h, [
 
3153
  AC_DEFINE(HAVE_WCHAR_H, 1, 
 
3154
  [Define if the compiler provides a wchar.h header file.]) 
 
3155
  wchar_h="yes"
 
3156
],
 
3157
wchar_h="no"
 
3158
)
 
3159
 
 
3160
# determine wchar_t size
 
3161
if test "$wchar_h" = yes
 
3162
then
 
3163
  AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
 
3164
fi
 
3165
 
 
3166
AC_MSG_CHECKING(for UCS-4 tcl)
 
3167
have_ucs4_tcl=no
 
3168
AC_TRY_COMPILE([
 
3169
#include <tcl.h>
 
3170
#if TCL_UTF_MAX != 6
 
3171
# error "NOT UCS4_TCL"
 
3172
#endif], [], [
 
3173
  AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
 
3174
  have_ucs4_tcl=yes
 
3175
])
 
3176
AC_MSG_RESULT($have_ucs4_tcl)
 
3177
 
 
3178
# check whether wchar_t is signed or not
 
3179
if test "$wchar_h" = yes
 
3180
then
 
3181
  # check whether wchar_t is signed or not
 
3182
  AC_MSG_CHECKING(whether wchar_t is signed)
 
3183
  AC_CACHE_VAL(ac_cv_wchar_t_signed, [
 
3184
  AC_TRY_RUN([
 
3185
  #include <wchar.h>
 
3186
  int main()
 
3187
  {
 
3188
        /* Success: exit code 0 */
 
3189
        exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
 
3190
  }
 
3191
  ],
 
3192
  ac_cv_wchar_t_signed=yes,
 
3193
  ac_cv_wchar_t_signed=no,
 
3194
  ac_cv_wchar_t_signed=yes)])
 
3195
  AC_MSG_RESULT($ac_cv_wchar_t_signed)
 
3196
fi
 
3197
 
 
3198
AC_MSG_CHECKING(what type to use for str)
 
3199
AC_ARG_WITH(wide-unicode, 
 
3200
            AC_HELP_STRING(--with-wide-unicode, Use 4-byte Unicode characters (default is 2 bytes)),
 
3201
[
 
3202
if test "$withval" != no
 
3203
then unicode_size="4"
 
3204
else unicode_size="2"
 
3205
fi
 
3206
],
 
3207
[
 
3208
case "$have_ucs4_tcl" in
 
3209
  yes) unicode_size="4" ;;
 
3210
  *)   unicode_size="2" ;;
 
3211
esac
 
3212
])
 
3213
 
 
3214
AH_TEMPLATE(Py_UNICODE_SIZE,
 
3215
  [Define as the size of the unicode type.])
 
3216
case "$unicode_size" in
 
3217
  4) AC_DEFINE(Py_UNICODE_SIZE, 4) ;;
 
3218
  *) AC_DEFINE(Py_UNICODE_SIZE, 2) ;;
 
3219
esac
 
3220
 
 
3221
AH_TEMPLATE(PY_UNICODE_TYPE,
 
3222
  [Define as the integral type used for Unicode representation.])
 
3223
 
 
3224
# wchar_t is only usable if it maps to an unsigned type
 
3225
if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
 
3226
          -a "$ac_cv_wchar_t_signed" = "no"
 
3227
then
 
3228
  PY_UNICODE_TYPE="wchar_t"
 
3229
  AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
 
3230
  [Define if you have a useable wchar_t type defined in wchar.h; useable
 
3231
   means wchar_t must be an unsigned type with at least 16 bits. (see
 
3232
   Include/unicodeobject.h).])
 
3233
  AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
 
3234
elif test "$ac_cv_sizeof_short" = "$unicode_size"
 
3235
then
 
3236
     PY_UNICODE_TYPE="unsigned short"
 
3237
     AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
 
3238
elif test "$ac_cv_sizeof_long" = "$unicode_size"
 
3239
then
 
3240
     PY_UNICODE_TYPE="unsigned long"
 
3241
     AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
 
3242
else
 
3243
     PY_UNICODE_TYPE="no type found"
 
3244
fi
 
3245
AC_MSG_RESULT($PY_UNICODE_TYPE)
 
3246
 
 
3247
# check for endianness
 
3248
AC_C_BIGENDIAN
 
3249
 
 
3250
# Check whether right shifting a negative integer extends the sign bit
 
3251
# or fills with zeros (like the Cray J90, according to Tim Peters).
 
3252
AC_MSG_CHECKING(whether right shift extends the sign bit)
 
3253
AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
 
3254
AC_TRY_RUN([
 
3255
int main()
 
3256
{
 
3257
        exit(((-1)>>3 == -1) ? 0 : 1);
 
3258
}
 
3259
],
 
3260
ac_cv_rshift_extends_sign=yes,
 
3261
ac_cv_rshift_extends_sign=no,
 
3262
ac_cv_rshift_extends_sign=yes)])
 
3263
AC_MSG_RESULT($ac_cv_rshift_extends_sign)
 
3264
if test "$ac_cv_rshift_extends_sign" = no
 
3265
then
 
3266
  AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
 
3267
  [Define if i>>j for signed int i does not extend the sign bit
 
3268
   when i < 0])
 
3269
fi
 
3270
 
 
3271
# check for getc_unlocked and related locking functions
 
3272
AC_MSG_CHECKING(for getc_unlocked() and friends)
 
3273
AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
 
3274
AC_TRY_LINK([#include <stdio.h>],[
 
3275
        FILE *f = fopen("/dev/null", "r");
 
3276
        flockfile(f);
 
3277
        getc_unlocked(f);
 
3278
        funlockfile(f);
 
3279
], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
 
3280
AC_MSG_RESULT($ac_cv_have_getc_unlocked)
 
3281
if test "$ac_cv_have_getc_unlocked" = yes
 
3282
then
 
3283
  AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
 
3284
  [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
 
3285
fi
 
3286
 
 
3287
# check where readline lives
 
3288
# save the value of LIBS so we don't actually link Python with readline
 
3289
LIBS_no_readline=$LIBS
 
3290
 
 
3291
# On some systems we need to link readline to a termcap compatible
 
3292
# library.  NOTE: Keep the precedence of listed libraries synchronised
 
3293
# with setup.py.
 
3294
py_cv_lib_readline=no
 
3295
AC_MSG_CHECKING([how to link readline libs])
 
3296
for py_libtermcap in "" ncursesw ncurses curses termcap; do
 
3297
  if test -z "$py_libtermcap"; then
 
3298
    READLINE_LIBS="-lreadline"
 
3299
  else
 
3300
    READLINE_LIBS="-lreadline -l$py_libtermcap"
 
3301
  fi
 
3302
  LIBS="$READLINE_LIBS $LIBS_no_readline"
 
3303
  AC_LINK_IFELSE(
 
3304
    [AC_LANG_CALL([],[readline])],
 
3305
    [py_cv_lib_readline=yes])
 
3306
  if test $py_cv_lib_readline = yes; then
 
3307
    break
 
3308
  fi
 
3309
done
 
3310
# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
 
3311
#AC_SUBST([READLINE_LIBS])
 
3312
if test $py_cv_lib_readline = no; then
 
3313
  AC_MSG_RESULT([none])
 
3314
else
 
3315
  AC_MSG_RESULT([$READLINE_LIBS])
 
3316
  AC_DEFINE(HAVE_LIBREADLINE, 1,
 
3317
    [Define if you have the readline library (-lreadline).])
 
3318
fi
 
3319
 
 
3320
# check for readline 2.1
 
3321
AC_CHECK_LIB(readline, rl_callback_handler_install,
 
3322
        AC_DEFINE(HAVE_RL_CALLBACK, 1,
 
3323
        [Define if you have readline 2.1]), ,$READLINE_LIBS)
 
3324
 
 
3325
# check for readline 2.2
 
3326
AC_TRY_CPP([#include <readline/readline.h>],
 
3327
have_readline=yes, have_readline=no)
 
3328
if test $have_readline = yes
 
3329
then
 
3330
  AC_EGREP_HEADER([extern int rl_completion_append_character;],
 
3331
  [readline/readline.h],
 
3332
  AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
 
3333
  [Define if you have readline 2.2]), )
 
3334
fi
 
3335
 
 
3336
# check for readline 4.0
 
3337
AC_CHECK_LIB(readline, rl_pre_input_hook,
 
3338
        AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
 
3339
        [Define if you have readline 4.0]), ,$READLINE_LIBS)
 
3340
 
 
3341
# also in 4.0
 
3342
AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
 
3343
        AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
 
3344
        [Define if you have readline 4.0]), ,$READLINE_LIBS)
 
3345
 
 
3346
# check for readline 4.2
 
3347
AC_CHECK_LIB(readline, rl_completion_matches,
 
3348
        AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
 
3349
        [Define if you have readline 4.2]), ,$READLINE_LIBS)
 
3350
 
 
3351
# also in readline 4.2
 
3352
AC_TRY_CPP([#include <readline/readline.h>],
 
3353
have_readline=yes, have_readline=no)
 
3354
if test $have_readline = yes
 
3355
then
 
3356
  AC_EGREP_HEADER([extern int rl_catch_signals;],
 
3357
  [readline/readline.h],
 
3358
  AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
 
3359
  [Define if you can turn off readline's signal handling.]), )
 
3360
fi
 
3361
 
 
3362
# End of readline checks: restore LIBS
 
3363
LIBS=$LIBS_no_readline
 
3364
 
 
3365
AC_MSG_CHECKING(for broken nice())
 
3366
AC_CACHE_VAL(ac_cv_broken_nice, [
 
3367
AC_TRY_RUN([
 
3368
int main()
 
3369
{
 
3370
        int val1 = nice(1);
 
3371
        if (val1 != -1 && val1 == nice(2))
 
3372
                exit(0);
 
3373
        exit(1);
 
3374
}
 
3375
],
 
3376
ac_cv_broken_nice=yes,
 
3377
ac_cv_broken_nice=no,
 
3378
ac_cv_broken_nice=no)])
 
3379
AC_MSG_RESULT($ac_cv_broken_nice)
 
3380
if test "$ac_cv_broken_nice" = yes
 
3381
then
 
3382
  AC_DEFINE(HAVE_BROKEN_NICE, 1,
 
3383
  [Define if nice() returns success/failure instead of the new priority.])
 
3384
fi
 
3385
 
 
3386
AC_MSG_CHECKING(for broken poll())
 
3387
AC_TRY_RUN([
 
3388
#include <poll.h>
 
3389
 
 
3390
int main (void)
 
3391
    {
 
3392
    struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
 
3393
    
 
3394
    close (42);
 
3395
 
 
3396
    int poll_test = poll (&poll_struct, 1, 0);
 
3397
 
 
3398
    if (poll_test < 0)
 
3399
        {
 
3400
        exit(0);
 
3401
        }
 
3402
    else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
 
3403
        {
 
3404
        exit(0);
 
3405
        }
 
3406
    else
 
3407
        {
 
3408
        exit(1);
 
3409
        }
 
3410
    }
 
3411
],
 
3412
ac_cv_broken_poll=yes,
 
3413
ac_cv_broken_poll=no,
 
3414
ac_cv_broken_poll=no)
 
3415
AC_MSG_RESULT($ac_cv_broken_poll)
 
3416
if test "$ac_cv_broken_poll" = yes
 
3417
then
 
3418
  AC_DEFINE(HAVE_BROKEN_POLL, 1,
 
3419
      [Define if poll() sets errno on invalid file descriptors.])
 
3420
fi
 
3421
 
 
3422
# Before we can test tzset, we need to check if struct tm has a tm_zone 
 
3423
# (which is not required by ISO C or UNIX spec) and/or if we support
 
3424
# tzname[]
 
3425
AC_STRUCT_TIMEZONE
 
3426
 
 
3427
# check tzset(3) exists and works like we expect it to
 
3428
AC_MSG_CHECKING(for working tzset())
 
3429
AC_CACHE_VAL(ac_cv_working_tzset, [
 
3430
AC_TRY_RUN([
 
3431
#include <stdlib.h>
 
3432
#include <time.h>
 
3433
#include <string.h>
 
3434
 
 
3435
#if HAVE_TZNAME
 
3436
extern char *tzname[];
 
3437
#endif
 
3438
 
 
3439
int main()
 
3440
{
 
3441
        /* Note that we need to ensure that not only does tzset(3)
 
3442
           do 'something' with localtime, but it works as documented
 
3443
           in the library reference and as expected by the test suite.
 
3444
           This includes making sure that tzname is set properly if
 
3445
           tm->tm_zone does not exist since it is the alternative way
 
3446
           of getting timezone info.
 
3447
 
 
3448
           Red Hat 6.2 doesn't understand the southern hemisphere 
 
3449
           after New Year's Day.
 
3450
        */
 
3451
 
 
3452
        time_t groundhogday = 1044144000; /* GMT-based */
 
3453
        time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
 
3454
 
 
3455
        putenv("TZ=UTC+0");
 
3456
        tzset();
 
3457
        if (localtime(&groundhogday)->tm_hour != 0)
 
3458
            exit(1);
 
3459
#if HAVE_TZNAME
 
3460
        /* For UTC, tzname[1] is sometimes "", sometimes "   " */
 
3461
        if (strcmp(tzname[0], "UTC") || 
 
3462
                (tzname[1][0] != 0 && tzname[1][0] != ' '))
 
3463
            exit(1);
 
3464
#endif
 
3465
 
 
3466
        putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
 
3467
        tzset();
 
3468
        if (localtime(&groundhogday)->tm_hour != 19)
 
3469
            exit(1);
 
3470
#if HAVE_TZNAME
 
3471
        if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
 
3472
            exit(1);
 
3473
#endif
 
3474
 
 
3475
        putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
 
3476
        tzset();
 
3477
        if (localtime(&groundhogday)->tm_hour != 11)
 
3478
            exit(1);
 
3479
#if HAVE_TZNAME
 
3480
        if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
 
3481
            exit(1);
 
3482
#endif
 
3483
 
 
3484
#if HAVE_STRUCT_TM_TM_ZONE
 
3485
        if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
 
3486
            exit(1);
 
3487
        if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
 
3488
            exit(1);
 
3489
#endif
 
3490
 
 
3491
        exit(0);
 
3492
}
 
3493
],
 
3494
ac_cv_working_tzset=yes,
 
3495
ac_cv_working_tzset=no,
 
3496
ac_cv_working_tzset=no)])
 
3497
AC_MSG_RESULT($ac_cv_working_tzset)
 
3498
if test "$ac_cv_working_tzset" = yes
 
3499
then
 
3500
  AC_DEFINE(HAVE_WORKING_TZSET, 1,
 
3501
  [Define if tzset() actually switches the local timezone in a meaningful way.])
 
3502
fi
 
3503
 
 
3504
# Look for subsecond timestamps in struct stat
 
3505
AC_MSG_CHECKING(for tv_nsec in struct stat)
 
3506
AC_CACHE_VAL(ac_cv_stat_tv_nsec,
 
3507
AC_TRY_COMPILE([#include <sys/stat.h>], [
 
3508
struct stat st;
 
3509
st.st_mtim.tv_nsec = 1;
 
3510
],
 
3511
ac_cv_stat_tv_nsec=yes,
 
3512
ac_cv_stat_tv_nsec=no,
 
3513
ac_cv_stat_tv_nsec=no))
 
3514
AC_MSG_RESULT($ac_cv_stat_tv_nsec)
 
3515
if test "$ac_cv_stat_tv_nsec" = yes
 
3516
then
 
3517
  AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
 
3518
  [Define if you have struct stat.st_mtim.tv_nsec])
 
3519
fi
 
3520
 
 
3521
# Look for BSD style subsecond timestamps in struct stat
 
3522
AC_MSG_CHECKING(for tv_nsec2 in struct stat)
 
3523
AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
 
3524
AC_TRY_COMPILE([#include <sys/stat.h>], [
 
3525
struct stat st;
 
3526
st.st_mtimespec.tv_nsec = 1;
 
3527
],
 
3528
ac_cv_stat_tv_nsec2=yes,
 
3529
ac_cv_stat_tv_nsec2=no,
 
3530
ac_cv_stat_tv_nsec2=no))
 
3531
AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
 
3532
if test "$ac_cv_stat_tv_nsec2" = yes
 
3533
then
 
3534
  AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
 
3535
  [Define if you have struct stat.st_mtimensec])
 
3536
fi
 
3537
 
 
3538
# On HP/UX 11.0, mvwdelch is a block with a return statement
 
3539
AC_MSG_CHECKING(whether mvwdelch is an expression)
 
3540
AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
 
3541
AC_TRY_COMPILE([#include <curses.h>], [
 
3542
  int rtn;
 
3543
  rtn = mvwdelch(0,0,0);
 
3544
], ac_cv_mvwdelch_is_expression=yes,
 
3545
   ac_cv_mvwdelch_is_expression=no,
 
3546
   ac_cv_mvwdelch_is_expression=yes))
 
3547
AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
 
3548
 
 
3549
if test "$ac_cv_mvwdelch_is_expression" = yes
 
3550
then
 
3551
  AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
 
3552
  [Define if mvwdelch in curses.h is an expression.])
 
3553
fi
 
3554
 
 
3555
AC_MSG_CHECKING(whether WINDOW has _flags)
 
3556
AC_CACHE_VAL(ac_cv_window_has_flags,
 
3557
AC_TRY_COMPILE([#include <curses.h>], [
 
3558
  WINDOW *w;
 
3559
  w->_flags = 0;
 
3560
], ac_cv_window_has_flags=yes,
 
3561
   ac_cv_window_has_flags=no,
 
3562
   ac_cv_window_has_flags=no))
 
3563
AC_MSG_RESULT($ac_cv_window_has_flags)
 
3564
 
 
3565
 
 
3566
if test "$ac_cv_window_has_flags" = yes
 
3567
then
 
3568
  AC_DEFINE(WINDOW_HAS_FLAGS, 1, 
 
3569
  [Define if WINDOW in curses.h offers a field _flags.])
 
3570
fi
 
3571
 
 
3572
AC_MSG_CHECKING(for is_term_resized)
 
3573
AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
 
3574
  AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
 
3575
  AC_MSG_RESULT(yes),
 
3576
  AC_MSG_RESULT(no)
 
3577
)
 
3578
 
 
3579
AC_MSG_CHECKING(for resize_term)
 
3580
AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
 
3581
  AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
 
3582
  AC_MSG_RESULT(yes),
 
3583
  AC_MSG_RESULT(no)
 
3584
)
 
3585
 
 
3586
AC_MSG_CHECKING(for resizeterm)
 
3587
AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
 
3588
  AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
 
3589
  AC_MSG_RESULT(yes),
 
3590
  AC_MSG_RESULT(no)
 
3591
)
 
3592
 
 
3593
AC_MSG_CHECKING(for /dev/ptmx)
 
3594
 
 
3595
if test -r /dev/ptmx
 
3596
then
 
3597
  AC_MSG_RESULT(yes)
 
3598
  AC_DEFINE(HAVE_DEV_PTMX, 1,
 
3599
  [Define if we have /dev/ptmx.])
 
3600
else
 
3601
  AC_MSG_RESULT(no)
 
3602
fi
 
3603
 
 
3604
AC_MSG_CHECKING(for /dev/ptc)
 
3605
 
 
3606
if test -r /dev/ptc
 
3607
then
 
3608
  AC_MSG_RESULT(yes)
 
3609
  AC_DEFINE(HAVE_DEV_PTC, 1,
 
3610
  [Define if we have /dev/ptc.])
 
3611
else
 
3612
  AC_MSG_RESULT(no)
 
3613
fi
 
3614
 
 
3615
AC_MSG_CHECKING(for %zd printf() format support)
 
3616
AC_TRY_RUN([#include <stdio.h>
 
3617
#include <stddef.h>
 
3618
#include <string.h>
 
3619
 
 
3620
#ifdef HAVE_SYS_TYPES_H
 
3621
#include <sys/types.h>
 
3622
#endif
 
3623
 
 
3624
#ifdef HAVE_SSIZE_T
 
3625
typedef ssize_t Py_ssize_t;
 
3626
#elif SIZEOF_VOID_P == SIZEOF_LONG
 
3627
typedef long Py_ssize_t;
 
3628
#else
 
3629
typedef int Py_ssize_t;
 
3630
#endif
 
3631
 
 
3632
int main()
 
3633
{
 
3634
    char buffer[256];
 
3635
 
 
3636
    if(sprintf(buffer, "%zd", (size_t)123) < 0)
 
3637
        return 1;
 
3638
 
 
3639
    if (strcmp(buffer, "123"))
 
3640
        return 1;
 
3641
 
 
3642
    if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
 
3643
        return 1;
 
3644
 
 
3645
    if (strcmp(buffer, "-123"))
 
3646
        return 1;
 
3647
 
 
3648
    return 0;
 
3649
}],
 
3650
[AC_MSG_RESULT(yes)
 
3651
 AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
 
3652
 AC_MSG_RESULT(no))
 
3653
 
 
3654
AC_CHECK_TYPE(socklen_t,,
 
3655
  AC_DEFINE(socklen_t,int,
 
3656
            Define to `int' if <sys/socket.h> does not define.),[
 
3657
#ifdef HAVE_SYS_TYPES_H
 
3658
#include <sys/types.h>
 
3659
#endif
 
3660
#ifdef HAVE_SYS_SOCKET_H
 
3661
#include <sys/socket.h>
 
3662
#endif
 
3663
])
 
3664
 
 
3665
AC_MSG_CHECKING(for broken mbstowcs)
 
3666
AC_TRY_RUN([
 
3667
#include<stdlib.h>
 
3668
int main() {
 
3669
    size_t len = -1;
 
3670
    const char *str = "text";
 
3671
    len = mbstowcs(NULL, str, 0);
 
3672
    return (len != 4);
 
3673
}
 
3674
],
 
3675
ac_cv_broken_mbstowcs=no,
 
3676
ac_cv_broken_mbstowcs=yes,
 
3677
ac_cv_broken_mbstowcs=no)
 
3678
AC_MSG_RESULT($ac_cv_broken_mbstowcs)
 
3679
if test "$ac_cv_broken_mbstowcs" = yes
 
3680
then
 
3681
  AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
 
3682
  [Define if mbstowcs(NULL, "text", 0) does not return the number of 
 
3683
   wide chars that would be converted.])
 
3684
fi
 
3685
 
 
3686
# Check for --with-computed-gotos
 
3687
AC_MSG_CHECKING(for --with-computed-gotos)
 
3688
AC_ARG_WITH(computed-gotos,
 
3689
            AC_HELP_STRING(--with-computed-gotos,
 
3690
                           Use computed gotos / threaded dispatch in evaluation loop (not available on all compilers)),
 
3691
[
 
3692
if test "$withval" != no
 
3693
then 
 
3694
  AC_DEFINE(USE_COMPUTED_GOTOS, 1,
 
3695
  [Define if you want to use computed gotos in ceval.c.]) 
 
3696
  AC_MSG_RESULT(yes)
 
3697
else AC_MSG_RESULT(no)
 
3698
fi],
 
3699
[AC_MSG_RESULT(no)])
 
3700
 
 
3701
 
 
3702
AC_SUBST(THREADHEADERS)
 
3703
 
 
3704
for h in `(cd $srcdir;echo Python/thread_*.h)`
 
3705
do
 
3706
  THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
 
3707
done
 
3708
 
 
3709
AC_SUBST(SRCDIRS)
 
3710
SRCDIRS="Parser Grammar Objects Python Modules Mac"
 
3711
AC_MSG_CHECKING(for build directories)
 
3712
for dir in $SRCDIRS; do
 
3713
    if test ! -d $dir; then
 
3714
        mkdir $dir
 
3715
    fi
 
3716
done
 
3717
AC_MSG_RESULT(done)
 
3718
 
 
3719
# generate output files
 
3720
AC_CONFIG_FILES(Makefile.pre Modules/Setup.config)
 
3721
AC_OUTPUT
 
3722
 
 
3723
echo "creating Modules/Setup"
 
3724
if test ! -f Modules/Setup
 
3725
then
 
3726
        cp $srcdir/Modules/Setup.dist Modules/Setup
 
3727
fi
 
3728
 
 
3729
echo "creating Modules/Setup.local"
 
3730
if test ! -f Modules/Setup.local
 
3731
then
 
3732
        echo "# Edit this file for local setup changes" >Modules/Setup.local
 
3733
fi
 
3734
 
 
3735
echo "creating Makefile"
 
3736
$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
 
3737
                        -s Modules Modules/Setup.config \
 
3738
                        Modules/Setup.local Modules/Setup
 
3739
mv config.c Modules