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