PageRenderTime 62ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

/configure.in

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