home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Programming / Python2 / Python20_source / configure.in < prev    next >
Encoding:
Text File  |  2000-10-25  |  34.4 KB  |  1,305 lines

  1. dnl Process this file with autoconf 2.0 or later to make a configure script.
  2. AC_REVISION($Revision: 1.173 $)
  3. AC_PREREQ(2.0)
  4. AC_INIT(Include/object.h)
  5. AC_CONFIG_HEADER(config.h)
  6.  
  7. # Set VERSION so we only need to edit in one place (i.e., here)
  8. AC_SUBST(VERSION)
  9. VERSION=2.0
  10.  
  11. # NEXTSTEP|MacOSX|Darwin stuff
  12. if test -f /usr/lib/NextStep/software_version -o -f /System/Library/CoreServices/software_version ; then
  13.  
  14.     AC_MSG_CHECKING(for --with-next-archs)
  15.     AC_ARG_WITH(next-archs,
  16.      [  --with-next-archs='arch1 arch2 ..'   build MAB binary], [
  17.         if test -n "$withval"; then
  18.             ac_arch_flags=`/usr/lib/arch_tool -archify_list $withval`
  19.             # GCC does not currently support multi archs on the NeXT
  20.             with_gcc=no
  21.         fi
  22.         AC_MSG_RESULT($with_next_archs)
  23.     ], [AC_MSG_RESULT(none: using `arch`)])
  24.     
  25.     if test -z "$MACHDEP"
  26.     then
  27.         ac_sys_system=`uname -s`
  28.         if test "$ac_sys_system" = "Darwin" ; then
  29.         ac_sys_release=`uname -r`
  30.         else
  31.         set X `hostinfo | egrep '(NeXT Mach|Kernel Release).*:' | \
  32.             sed -e 's/://' -e 's/\./_/'` && \
  33.         ac_sys_system=next && ac_sys_release=$4
  34.         fi
  35.  
  36.         MACHDEP="$ac_sys_system$ac_sys_release"
  37.     fi
  38. fi
  39.  
  40. AC_ARG_WITH(next-framework,
  41. [  --with-next-framework           Build (OpenStep|Rhapsody|MacOSX|Darwin) framework],,)
  42. AC_ARG_WITH(dyld,
  43. [  --with-dyld                     Use (OpenStep|Rhapsody|MacOSX|Darwin) dynamic linker],,)
  44.  
  45. # Set name for machine-dependent library files
  46. AC_SUBST(MACHDEP)
  47. AC_MSG_CHECKING(MACHDEP)
  48. if test -z "$MACHDEP"
  49. then
  50.     ac_sys_system=`uname -s`
  51.     if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64"; then
  52.         ac_sys_release=`uname -v`
  53.     else
  54.         ac_sys_release=`uname -r`
  55.     fi
  56.     ac_md_system=`echo $ac_sys_system |
  57.                tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
  58.     ac_md_release=`echo $ac_sys_release |
  59.                tr -d '[/ ]' | sed 's/\..*//'`
  60.     MACHDEP="$ac_md_system$ac_md_release"
  61.  
  62.     case $MACHDEP in
  63.     '')    MACHDEP="unknown";;
  64.     esac
  65. fi
  66.  
  67. #
  68. # SGI compilers allow the specification of the both the ABI and the
  69. # ISA on the command line.  Depending on the values of these switches,
  70. # different and often incompatable code will be generated.
  71. #
  72. # The SGI_ABI variable can be used to modify the CC and LDFLAGS and
  73. # thus supply support for various ABI/ISA combinations.  The MACHDEP
  74. # variable is also adjusted.
  75. #
  76. AC_SUBST(SGI_ABI)
  77. if test ! -z "$SGI_ABI"
  78. then
  79.         CC="cc $SGI_ABI"
  80.         LDFLAGS="$SGI_ABI $LDFLAGS"
  81.         MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
  82. fi
  83. AC_MSG_RESULT($MACHDEP)
  84.  
  85. #
  86. # CCC is the command that compiles C++ programs
  87. #
  88. # Not all make programs have this predefined.
  89. #
  90. #AC_SUBST(SET_CCC)
  91. #AC_MSG_CHECKING(CCC)
  92. #if test -z "$CCC"
  93. #then
  94. #    case $ac_sys_system in
  95. #    IRIX*)    SET_CCC="CCC= CC ${SGI_ABI}";;
  96. #    Linux*) SET_CCC="CCC= g++";;
  97. #    *)    SET_CCC=""
  98. #    esac
  99. #else
  100. #        SET_CCC="CCC= ${CCC}"
  101. #fi
  102. #AC_MSG_RESULT($SET_CCC)
  103.  
  104.  
  105. # checks for alternative programs
  106. AC_MSG_CHECKING(for --without-gcc)
  107. AC_ARG_WITH(gcc, [  --without-gcc                   never use gcc], [
  108.     case $withval in
  109.     no)    CC=cc
  110.         without_gcc=yes;;
  111.     yes)    CC=gcc
  112.         without_gcc=no;;
  113.     *)    CC=$withval
  114.         without_gcc=$withval;;
  115.     esac], [
  116.     case $ac_sys_system in
  117.     OSF1)    CC=cc
  118.         without_gcc=;;
  119.     BeOS*)
  120.         case $BE_HOST_CPU in
  121.         ppc)
  122.             CC=mwcc
  123.             without_gcc=yes
  124.             OPT="-O -D'DL_EXPORT(RTYPE)=__declspec(dllexport) RTYPE' -D'DL_IMPORT(RTYPE)=__declspec(dllexport) RTYPE' -export pragma"
  125.             CCSHARED="UDL_IMPORT -D'DL_IMPORT(RTYPE)=__declspec(dllimport) RTYPE'"
  126.             LDFLAGS="$LDFLAGS -nodup"
  127.  
  128.             AR="$PWD/BeOS/ar-fake"
  129.             RANLIB=:
  130.             ;;
  131.         x86)
  132.             CC=gcc
  133.             without_gcc=no
  134.             OPT=-O
  135.             # Really should use srcdir instead of PWD
  136.             AR="$PWD/BeOS/ar-fake"
  137.             RANLIB=:
  138.             ;;
  139.         *)
  140.             AC_ERROR(Unknown BeOS platform \"$BE_HOST_CPU\")
  141.             ;;
  142.         esac
  143.         ;;
  144.     Monterey*)
  145.         RANLIB=:
  146.         without_gcc=;;
  147.     *)    without_gcc=no;;
  148.     esac])
  149. AC_MSG_RESULT($without_gcc)
  150.  
  151. AC_SUBST(SET_CXX)
  152. AC_SUBST(MAINOBJ)
  153. MAINOBJ=python.o
  154. AC_MSG_CHECKING(for --with-cxx=<compiler>)
  155. AC_ARG_WITH(cxx, [  --with-cxx=<compiler>           enable C++ support],[
  156.     case $withval in
  157.     no)    CXX=
  158.         with_cxx=no;;
  159.     *)    CXX=$withval
  160.         MAINOBJ=ccpython.o
  161.         with_cxx=$withval;;
  162.     esac], [
  163.     with_cxx=no
  164. ])
  165. AC_MSG_RESULT($with_cxx)
  166. SET_CXX="CXX=$CXX"
  167.  
  168. #AC_MSG_CHECKING(CCC)
  169. #if test -z "$CCC"
  170. #then
  171. #    case $ac_sys_system in
  172. #    IRIX*)    SET_CCC="CCC= CC ${SGI_ABI}";;
  173. #    Linux*) SET_CCC="CCC= g++";;
  174. #    *)    SET_CCC=""
  175. #    esac
  176. #else
  177. #        SET_CCC="CCC= ${CCC}"
  178. #fi
  179. #AC_MSG_RESULT($SET_CCC)
  180.  
  181. # If the user switches compilers, we can't believe the cache
  182. if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
  183. then
  184.   AC_ERROR(cached CC is different -- throw away $cache_file
  185. (it is also a good idea to do 'make clean' before compiling))
  186. fi
  187.  
  188. AC_PROG_CC
  189. AC_SUBST(EXE)
  190. AC_MSG_CHECKING(for --with-suffix)
  191. AC_ARG_WITH(suffix, [  --with-suffix=.exe              set executable suffix],[
  192.     case $withval in
  193.     no)    EXE=;;
  194.     yes)    EXE=.exe;;
  195.     *)    EXE=$withval;;
  196.     esac])
  197. AC_MSG_RESULT($EXE)
  198.  
  199. case $MACHDEP in
  200. bsdos*)
  201.     case $CC in
  202.     gcc) CC="$CC -D_HAVE_BSDI";;
  203.     esac;;
  204. esac
  205.  
  206. case $ac_sys_system in
  207. hp*|HP*)
  208.     case $CC in
  209.     cc|*/cc) CC="$CC -Ae";;
  210.     esac;;
  211. Monterey*)
  212.     case $CC in
  213.     cc) CC="$CC -Wl,-Bexport";;
  214.     esac;;
  215. esac
  216.  
  217. # LDLIBRARY is the name of the library to link against (as opposed to the
  218. # name of the library into which to insert object files). On systems
  219. # without shared libraries, LDLIBRARY is the same as LIBRARY (defined in
  220. # the Makefiles). 
  221. AC_SUBST(MAKE_LDLIBRARY)
  222. AC_SUBST(LDLIBRARY)
  223. LDLIBRARY=''
  224.  
  225. # LINKCC is the command that links the python executable -- default is $(CC).
  226. # This is altered for AIX in order to build the export list before 
  227. # linking.
  228. AC_SUBST(LINKCC)
  229. AC_MSG_CHECKING(LINKCC)
  230. if test -z "$LINKCC" -a ! -z "$CXX"
  231. then
  232.     LINKCC="$CXX"
  233. fi
  234. if test -z "$LINKCC"
  235. then
  236.     case $ac_sys_system in
  237.     AIX*)
  238.        LINKCC="\$(srcdir)/makexp_aix python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
  239.     dgux*)
  240.        LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";;
  241.     Monterey64*)
  242.        LINKCC="\$(PURIFY) \$(CC) -L/usr/lib/ia64l64";;
  243.     *) LINKCC="\$(PURIFY) \$(CC)";;
  244.     esac
  245. fi
  246. AC_MSG_RESULT($LINKCC)
  247.  
  248. AC_MSG_CHECKING(LDLIBRARY)
  249.  
  250. # NeXT framework builds require that the 'ar' library be converted into
  251. # a bundle using libtool.
  252. if test "$with_next_framework"
  253. then
  254.   LDLIBRARY='libpython$(VERSION).dylib'
  255. fi  
  256.  
  257. # DG/UX requires some fancy ld contortions to produce a .so from an .a
  258. case $MACHDEP in
  259. dguxR4)
  260.       LDLIBRARY='libpython$(VERSION).so'
  261.       OPT="$OPT -pic"
  262.       ;;
  263. beos*)
  264.       LDLIBRARY='libpython$(VERSION).so'
  265.       ;;
  266. esac
  267. AC_MSG_RESULT($LDLIBRARY)
  268.  
  269. # If LDLIBRARY is different from LIBRARY, emit a rule to build it.
  270. if test -z "$LDLIBRARY"
  271. then
  272.   LDLIBRARY='libpython$(VERSION).a'
  273.   MAKE_LDLIBRARY="true"
  274. else
  275.   MAKE_LDLIBRARY='$(MAKE) $(LDLIBRARY)'
  276. fi
  277.  
  278. AC_PROG_RANLIB
  279. AC_SUBST(AR)
  280. AC_CHECK_PROGS(AR, ar aal, ar)
  281. AC_SUBST(INSTALL)
  282. AC_SUBST(INSTALL_PROGRAM)
  283. AC_SUBST(INSTALL_DATA)
  284. # Install just never works :-(
  285. if test -z "$INSTALL"
  286. then
  287.     INSTALL=cp
  288.     INSTALL_PROGRAM=cp
  289.     INSTALL_DATA=cp
  290. else
  291.     INSTALL_PROGRAM="$INSTALL"
  292.     INSTALL_DATA="$INSTALL -m 644"
  293. fi
  294.  
  295. # Not every filesystem supports hard links
  296. AC_SUBST(LN)
  297. if test -z "$LN" ; then
  298.     case $ac_sys_system in
  299.         BeOS*) LN="ln -s";;
  300.         *) LN=ln;;
  301.     esac
  302. fi
  303.  
  304. # Optimizer/debugger flags passed between Makefiles
  305. AC_SUBST(OPT)
  306. if test -z "$OPT"
  307. then
  308.     case $GCC in
  309.     yes)
  310.         case $ac_cv_prog_cc_g in
  311.         yes)    OPT="-g -O2 -Wall -Wstrict-prototypes";;
  312.         *)    OPT="-O2 -Wall -Wstrict-prototypes";;
  313.         esac
  314.         ;;
  315.     *)    OPT="-O";;
  316.     esac
  317. fi
  318.  
  319. # The current (beta) Monterey compiler dies with optimizations
  320. case $ac_sys_system in
  321. Monterey*) OPT="";;
  322. esac
  323.  
  324. if test "$ac_arch_flags"
  325. then
  326.     OPT="$OPT $ac_arch_flags"
  327. fi
  328. # checks for UNIX variants that set C preprocessor variables
  329. AC_AIX
  330. AC_MINIX
  331.  
  332. AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
  333. AC_CACHE_VAL(ac_cv_opt_olimit_ok,
  334. [ac_save_cc="$CC"
  335. CC="$CC -OPT:Olimit=0"
  336. AC_TRY_RUN([int main() { return 0; }],
  337.   ac_cv_opt_olimit_ok=yes,
  338.   ac_cv_opt_olimit_ok=no)
  339. CC="$ac_save_cc"])
  340. AC_MSG_RESULT($ac_cv_opt_olimit_ok)
  341. if test $ac_cv_opt_olimit_ok = yes; then
  342.     case $ac_sys_system in
  343.       Darwin*) OPT="$OPT" ;;
  344.       *) OPT="$OPT -OPT:Olimit=0";;
  345.     esac
  346. else
  347.   AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
  348.   AC_CACHE_VAL(ac_cv_olimit_ok,
  349.   [ac_save_cc="$CC"
  350.   CC="$CC -Olimit 1500"
  351.   AC_TRY_RUN([int main() { return 0; }],
  352.     ac_cv_olimit_ok=yes,
  353.     ac_cv_olimit_ok=no)
  354.   CC="$ac_save_cc"])
  355.   AC_MSG_RESULT($ac_cv_olimit_ok)
  356.   if test $ac_cv_olimit_ok = yes; then
  357.     OPT="$OPT -Olimit 1500"
  358.   fi
  359. fi
  360.  
  361. dnl # check for ANSI or K&R ("traditional") preprocessor
  362. dnl AC_MSG_CHECKING(for C preprocessor type)
  363. dnl AC_TRY_COMPILE([
  364. dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
  365. dnl int foo;
  366. dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
  367. dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
  368. dnl AC_MSG_RESULT($cpp_type)
  369.  
  370. # checks for header files
  371. AC_HEADER_STDC
  372. AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h locale.h ncurses.h poll.h pthread.h \
  373. signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h \
  374. sys/audioio.h sys/file.h sys/lock.h db_185.h db.h \
  375. sys/param.h sys/select.h sys/socket.h sys/time.h sys/times.h \
  376. sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
  377. ndbm.h db1/ndbm.h gdbm/ndbm.h)
  378. AC_HEADER_DIRENT
  379.  
  380. # checks for typedefs
  381. was_it_defined=no
  382. AC_MSG_CHECKING(for clock_t in time.h)
  383. AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
  384. AC_MSG_RESULT($was_it_defined)
  385.  
  386. # Add some code to confdefs.h so that the test for off_t works on SCO
  387. cat >> confdefs.h <<\EOF
  388. #if defined(SCO_DS)
  389. #undef _OFF_T
  390. #endif
  391. EOF
  392.  
  393. # Type availability checks
  394. AC_TYPE_MODE_T
  395. AC_TYPE_OFF_T
  396. AC_TYPE_PID_T
  397. AC_TYPE_SIGNAL
  398. AC_TYPE_SIZE_T
  399. AC_TYPE_UID_T
  400.  
  401. # Sizes of various common basic types
  402. AC_CHECK_SIZEOF(int)
  403. AC_CHECK_SIZEOF(long)
  404. AC_CHECK_SIZEOF(void *)
  405. AC_CHECK_SIZEOF(char)
  406. AC_CHECK_SIZEOF(short)
  407. AC_CHECK_SIZEOF(float)
  408. AC_CHECK_SIZEOF(double)
  409. AC_CHECK_SIZEOF(fpos_t)
  410.  
  411. AC_MSG_CHECKING(for long long support)
  412. have_long_long=no
  413. AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
  414. AC_MSG_RESULT($have_long_long)
  415. if test "$have_long_long" = yes ; then
  416. AC_CHECK_SIZEOF(long long)
  417. fi
  418.  
  419. AC_MSG_CHECKING(for uintptr_t support)
  420. have_uintptr_t=no
  421. AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], AC_DEFINE(HAVE_UINTPTR_T) have_uintptr_t=yes)
  422. AC_MSG_RESULT($have_uintptr_t)
  423. if test "$have_uintptr_t" = yes ; then
  424. AC_CHECK_SIZEOF(uintptr_t)
  425. fi
  426.  
  427. # Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
  428. AC_MSG_CHECKING(size of off_t)
  429. AC_CACHE_VAL(ac_cv_sizeof_off_t,
  430. [AC_TRY_RUN([#include <stdio.h>
  431. #include <sys/types.h>
  432. main()
  433. {
  434.   FILE *f=fopen("conftestval", "w");
  435.   if (!f) exit(1);
  436.   fprintf(f, "%d\n", sizeof(off_t));
  437.   exit(0);
  438. }], ac_cv_sizeof_off_t=`cat conftestval`, ac_cv_sizeof_off_t=0)
  439. ])
  440. AC_MSG_RESULT($ac_cv_sizeof_off_t)
  441. AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
  442.  
  443. AC_MSG_CHECKING(whether to enable large file support)
  444. if test "$have_long_long" = yes -a \
  445.     "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
  446.     "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
  447.   AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
  448.   AC_MSG_RESULT(yes)
  449. else
  450.   AC_MSG_RESULT(no)
  451. fi
  452.  
  453. # AC_CHECK_SIZEOF() doesn't include <time.h>.
  454. AC_MSG_CHECKING(size of time_t)
  455. AC_CACHE_VAL(ac_cv_sizeof_time_t,
  456. [AC_TRY_RUN([#include <stdio.h>
  457. #include <time.h>
  458. main()
  459. {
  460.   FILE *f=fopen("conftestval", "w");
  461.   if (!f) exit(1);
  462.   fprintf(f, "%d\n", sizeof(time_t));
  463.   exit(0);
  464. }], ac_cv_sizeof_time_t=`cat conftestval`, ac_cv_sizeof_time_t=0)
  465. ])
  466. AC_MSG_RESULT($ac_cv_sizeof_time_t)
  467. AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t)
  468.  
  469.  
  470. # if have pthread_t then define SIZEOF_PTHREAD_T
  471. AC_MSG_CHECKING(for pthread_t)
  472. have_pthread_t=no
  473. AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
  474. AC_MSG_RESULT($have_pthread_t)
  475. if test "$have_pthread_t" = yes ; then
  476.   # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
  477.   AC_MSG_CHECKING(size of pthread_t)
  478.   AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
  479.   [AC_TRY_RUN([#include <stdio.h>
  480.   #include <pthread.h>
  481.   main()
  482.   {
  483.     FILE *f=fopen("conftestval", "w");
  484.     if (!f) exit(1);
  485.     fprintf(f, "%d\n", sizeof(pthread_t));
  486.     exit(0);
  487.   }], ac_cv_sizeof_pthread_t=`cat conftestval`, ac_cv_sizeof_pthread_t=0)
  488.   ])
  489.   AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
  490.   AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t)
  491. fi
  492.  
  493.  
  494. # Minor variations in building a framework between NextStep versions 4 and 5
  495. AC_SUBST(LIBTOOL_CRUFT)
  496. case $ac_sys_system/$ac_sys_release in
  497.   Darwin/*)
  498.     ns_undef_sym='_environ'
  499.     LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -U $ns_undef_sym" ;;
  500.   next/4*)
  501.     ns_undef_sym='__environ'
  502.     LIBTOOL_CRUFT="-U $ns_undef_sym" ;;
  503.   next/5*)
  504.     ns_undef_sym='_environ'
  505.     LIBTOOL_CRUFT="-lcc_dynamic -U $ns_undef_sym" ;;
  506. esac
  507.  
  508. AC_MSG_CHECKING(for --with-next-framework)
  509. if test "$with_next_framework"
  510. then
  511.     OPT="$OPT -fno-common"
  512.     # -U __environ is needed since bundles don't have access
  513.     # to crt0 when built but will always be linked against it
  514.     LDFLAGS="$LDFLAGS -Wl,-U,$ns_undef_sym"
  515.     AC_DEFINE(WITH_NEXT_FRAMEWORK)
  516.     AC_MSG_RESULT(yes)
  517. else
  518.     AC_MSG_RESULT(no)
  519. fi
  520.  
  521. AC_MSG_CHECKING(for --with-dyld)
  522. if test "$with_next_framework" -o "$with_dyld"
  523. then
  524.     if test "$with_dyld"
  525.     then
  526.         AC_MSG_RESULT(yes)
  527.     else
  528.         AC_MSG_RESULT(required for framework build)
  529.     fi
  530.     AC_DEFINE(WITH_DYLD)
  531.     ns_dyld='set'
  532. else
  533.     AC_MSG_RESULT(no)
  534. fi
  535.  
  536. # Set info about shared libraries.
  537. AC_SUBST(SO)
  538. AC_SUBST(LDSHARED)
  539. AC_SUBST(CCSHARED)
  540. AC_SUBST(LINKFORSHARED)
  541. # SO is the extension of shared libraries `(including the dot!)
  542. # -- usually .so, .sl on HP-UX
  543. AC_MSG_CHECKING(SO)
  544. if test -z "$SO"
  545. then
  546.     case $ac_sys_system in
  547.     hp*|HP*)   SO=.sl;;
  548.     *)       SO=.so;;
  549.     esac
  550. fi
  551. AC_MSG_RESULT($SO)
  552. # LDSHARED is the ld *command* used to create shared library
  553. # -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5
  554. # (Shared libraries in this instance are shared modules to be loaded into
  555. # Python, as opposed to building Python itself as a shared library.)
  556. AC_MSG_CHECKING(LDSHARED)
  557. if test -z "$LDSHARED"
  558. then
  559.     case $ac_sys_system/$ac_sys_release in
  560.     AIX*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";;
  561.     BeOS*) LDSHARED="\$(srcdir)/../BeOS/linkmodule -L.. -lpython\$(VERSION)";;
  562.     IRIX/5*) LDSHARED="ld -shared";;
  563.     IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
  564.     SunOS/4*) LDSHARED="ld";;
  565.     SunOS/5*) 
  566.         if test "$GCC" = "yes"
  567.         then LDSHARED='$(CC) -G'
  568.         else LDSHARED="ld -G";
  569.         fi ;;
  570.     hp*|HP*) LDSHARED="ld -b";;
  571.     OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
  572.     DYNIX/ptx*) LDSHARED="ld -G";;
  573.         Darwin/*|next/*) 
  574.         if test "$ns_dyld"
  575.         then 
  576.           if test "$ac_sys_system" = Darwin
  577.           then LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined suppress'
  578.           else LDSHARED='$(CC) $(LDFLAGS) -bundle -prebind'
  579.           fi
  580.         else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r';
  581.         fi
  582.     if test "$with_next_framework" ; then
  583.             LDSHARED="$LDSHARED \$(LDLIBRARY)"
  584.         fi ;;
  585.     Linux*) LDSHARED="gcc -shared";;
  586.     dgux*) LDSHARED="ld -G";;
  587.     BSD/OS*/4*) LDSHARED="gcc -shared";;
  588.     OpenBSD*) LDSHARED="ld -Bshareable";;
  589.     NetBSD*)
  590.         if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
  591.         then
  592.             LDSHARED="cc -shared"
  593.         else
  594.             LDSHARED="ld -Bshareable"
  595.         fi;;
  596.     FreeBSD*)
  597.         if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
  598.         then
  599.             LDSHARED="cc -shared ${LDFLAGS}"
  600.         else
  601.             LDSHARED="ld -Bshareable ${LDFLAGS}"
  602.         fi;;
  603.     SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
  604.     Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
  605.     *)    LDSHARED="ld";;
  606.     esac
  607. fi
  608. AC_MSG_RESULT($LDSHARED)
  609. # CCSHARED are the C *flags* used to create objects to go into a shared
  610. # library (module) -- this is only needed for a few systems
  611. AC_MSG_CHECKING(CCSHARED)
  612. if test -z "$CCSHARED"
  613. then
  614.     case $ac_sys_system/$ac_sys_release in
  615.     hp*|HP*) if test "$GCC" = yes;
  616.          then CCSHARED="-fpic";
  617.          else CCSHARED="+z";
  618.          fi;;
  619.     Linux*) CCSHARED="-fpic";;
  620.     BSD/OS*/4*) CCSHARED="-fpic";;
  621.     OpenBSD*) CCSHARED="-fpic";;
  622.     FreeBSD*|NetBSD*) CCSHARED="-fPIC";;
  623.     SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
  624.     Monterey*) CCSHARED="-G";;
  625.     IRIX*/6*)  case $CC in
  626.            *gcc*) CCSHARED="-shared";;
  627.            *) CCSHARED="";;
  628.            esac;;
  629.     esac
  630. fi
  631. AC_MSG_RESULT($CCSHARED)
  632. # LINKFORSHARED are the flags passed to the $(CC) command that links
  633. # the python executable -- this is only needed for a few systems
  634. AC_MSG_CHECKING(LINKFORSHARED)
  635. if test -z "$LINKFORSHARED"
  636. then
  637.     case $ac_sys_system/$ac_sys_release in
  638.     AIX*)    LINKFORSHARED='-Wl,-bE:python.exp -lld';;
  639.     hp*|HP*)
  640.         LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
  641.     BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
  642.     Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
  643.     # -u libsys_s pulls in all symbols in libsys
  644.     next/2*|next/3*) LINKFORSHARED="-u libsys_s";;
  645.     # -u __dummy makes the linker aware of the objc runtime
  646.     # in System.framework; otherwise, __objcInit (referenced in
  647.     # crt1.o) gets erroneously defined as common, which breaks dynamic
  648.     # loading of any modules which reference it in System.framework
  649.     next/4*|next/5*) LINKFORSHARED="-u __dummy -framework System" ;;
  650.     Darwin/*) LINKFORSHARED="-framework System" ;;
  651.     SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
  652.     ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
  653.     FreeBSD*|NetBSD*) 
  654.         if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
  655.         then
  656.             LINKFORSHARED="-Wl,--export-dynamic"
  657.         fi;;
  658.     SunOS/5*) case $CC in
  659.           *gcc*)
  660.             if $CC -Xlinker -V 2>&1 | grep BFD >/dev/null
  661.             then
  662.             LINKFORSHARED="-Xlinker --export-dynamic"
  663.             fi;;
  664.           esac;;
  665.     esac
  666. fi
  667. AC_MSG_RESULT($LINKFORSHARED)
  668.  
  669. # checks for libraries
  670. AC_CHECK_LIB(dl, dlopen)    # Dynamic linking for SunOS/Solaris and SYSV
  671. AC_CHECK_LIB(dld, shl_load)    # Dynamic linking for HP-UX
  672.  
  673. # Check for --with-pydebug
  674. AC_MSG_CHECKING(for --with-pydebug)
  675. AC_ARG_WITH(pydebug, 
  676. [  --with-pydebug                  build with Py_DEBUG defined], [
  677. if test "$withval" != no
  678. then AC_DEFINE(Py_DEBUG) AC_MSG_RESULT(yes)
  679. else AC_MSG_RESULT(no)
  680. fi],
  681. [AC_MSG_RESULT(no)])
  682.  
  683. # checks for system dependent C++ extensions support
  684. case "$ac_sys_system" in
  685.     AIX*)    AC_MSG_CHECKING(for genuine AIX C++ extensions support)
  686.         AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
  687.                 [loadAndInit("", 0, "")],
  688.                 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS)
  689.                  AC_MSG_RESULT(yes)],
  690.                 [AC_MSG_RESULT(no)]);;
  691.     *) ;;
  692. esac
  693.  
  694. # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
  695. # However on SGI IRIX, these exist but are broken.
  696. # BeOS' sockets are stashed in libnet.
  697. case "$ac_sys_system" in
  698. IRIX*) ;;
  699. *)
  700. AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
  701. AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
  702. ;;
  703. esac
  704. case "$ac_sys_system" in
  705. BeOS*)
  706. AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
  707. ;;
  708. esac
  709.  
  710. AC_MSG_CHECKING(for --with-libs)
  711. AC_ARG_WITH(libs,
  712. [  --with-libs='lib1 ...'          link against additional libs], [
  713. AC_MSG_RESULT($withval)
  714. LIBS="$withval $LIBS"
  715. ], AC_MSG_RESULT(no))
  716.  
  717. AC_SUBST(USE_THREAD_MODULE)
  718. USE_THREAD_MODULE=""
  719.  
  720. AC_MSG_CHECKING(for --with-dec-threads)
  721. AC_SUBST(LDLAST)
  722. AC_ARG_WITH(dec-threads,
  723. [  --with-dec-threads              use DEC Alpha/OSF1 thread-safe libraries], [
  724. AC_MSG_RESULT($withval)
  725. LDLAST=-threads
  726. if test "${with_thread+set}" != set; then
  727.    with_thread="$withval";
  728. fi],
  729. AC_MSG_RESULT(no))
  730.  
  731. AC_MSG_CHECKING(for --with-threads)
  732. AC_ARG_WITH(threads,
  733. [  --with(out)-threads[=DIRECTORY] disable/enable thread support])
  734.  
  735. # --with-thread is deprecated, but check for it anyway
  736. AC_ARG_WITH(thread,
  737. [  --with(out)-thread[=DIRECTORY]  deprecated; use --with(out)-threads],[
  738. with_threads=$with_thread])
  739.  
  740. if test -z "$with_threads"
  741. then with_threads="yes"
  742. fi
  743. AC_MSG_RESULT($with_threads)
  744.  
  745. if test "$with_threads" = "no"
  746. then
  747.     USE_THREAD_MODULE="#"
  748. else
  749.     if test ! -z "$with_threads" -a -d "$with_threads"
  750.     then LDFLAGS="$LDFLAGS -L$with_threads"
  751.     fi
  752.     if test ! -z "$withval" -a -d "$withval"
  753.     then LDFLAGS="$LDFLAGS -L$withval"
  754.     fi
  755.     AC_DEFINE(_REENTRANT)
  756.     AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
  757.     AC_DEFINE(C_THREADS)
  758.     LIBOBJS="$LIBOBJS thread.o"],[
  759.     AC_MSG_CHECKING(for --with-pth)
  760.     AC_ARG_WITH(pth,
  761.     [  --with-pth                      use GNU pth threading libraries], [
  762.     AC_MSG_RESULT($withval)
  763.     AC_DEFINE(WITH_THREAD)
  764.     AC_DEFINE(HAVE_PTH)
  765.     LIBS="-lpth $LIBS"
  766.     LIBOBJS="$LIBOBJS thread.o"],[
  767.     AC_MSG_RESULT(no)
  768.     AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
  769.     AC_DEFINE(_POSIX_THREADS)
  770.     LIBS="-lpthread $LIBS"
  771.     LIBOBJS="$LIBOBJS thread.o"],[
  772.     AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
  773.     case $ac_sys_system in
  774.       Darwin*) ;;
  775.       *) AC_DEFINE(_POSIX_THREADS);;
  776.     esac
  777.     LIBOBJS="$LIBOBJS thread.o"],[
  778.     AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
  779.     AC_DEFINE(BEOS_THREADS)
  780.     LIBOBJS="$LIBOBJS thread.o"],[
  781.     AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
  782.     AC_DEFINE(_POSIX_THREADS)
  783.     LIBS="$LIBS -lpthreads"
  784.     LIBOBJS="$LIBOBJS thread.o"], [
  785.     AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
  786.     AC_DEFINE(_POSIX_THREADS)
  787.     LIBS="$LIBS -lc_r"
  788.     LIBOBJS="$LIBOBJS thread.o"], [
  789.     AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
  790.     AC_DEFINE(_POSIX_THREADS)
  791.     LIBS="$LIBS -lthread"
  792.     LIBOBJS="$LIBOBJS thread.o"], [
  793.     AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
  794.     AC_DEFINE(_POSIX_THREADS)
  795.     LIBS="$LIBS -lcma"
  796.     LIBOBJS="$LIBOBJS thread.o"],[
  797.     USE_THREAD_MODULE="#"])
  798.     ])])])])])])])])
  799.  
  800.     AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
  801.     LIBS="$LIBS -lmpc"
  802.     LIBOBJS="$LIBOBJS thread.o"
  803.     USE_THREAD_MODULE=""])
  804.     AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
  805.     LIBS="$LIBS -lthread"
  806.     LIBOBJS="$LIBOBJS thread.o"
  807.     USE_THREAD_MODULE=""])
  808.  
  809.     if test "$USE_THREAD_MODULE" != "#"
  810.     then
  811.         # If the above checks didn't disable threads, (at least) OSF1
  812.         # needs this '-threads' argument during linking.
  813.         case $ac_sys_system in
  814.         OSF1) LDLAST=-threads;;
  815.         esac
  816.     fi
  817. fi
  818.  
  819. # Check for GC support
  820. AC_SUBST(USE_GC_MODULE)
  821. USE_GC_MODULE=""
  822. AC_MSG_CHECKING(for --with-cycle-gc)
  823. AC_ARG_WITH(cycle-gc,
  824. [  --with(out)-cycle-gc            disable/enable garbage collection])
  825.  
  826. if test -z "$with_cycle_gc"
  827. then with_cycle_gc="yes"
  828. fi
  829. if test "$with_cycle_gc" = "no"
  830. then
  831.     USE_GC_MODULE="#"
  832. else
  833.     AC_DEFINE(WITH_CYCLE_GC)
  834. fi
  835. AC_MSG_RESULT($with_cycle_gc)
  836.  
  837. # Check for LIBDB support
  838. # either --with-libdb or, in its absence, the presence of db.h
  839. AC_SUBST(USE_BSDDB_MODULE)
  840. USE_BSDDB_MODULE=""
  841. AC_MSG_CHECKING(for --with-libdb)
  842. AC_ARG_WITH(libdb,
  843. [  --with(out)-libdb               disable/enable bsddb module])
  844.  
  845. # enabled by default, but db.h must be found
  846. if test "$ac_cv_header_db_h" = "yes"
  847. then
  848.     if test "$with_libdb" != "no"
  849.     then with_libdb="yes"
  850.     fi
  851. else
  852.     # make sure user knows why bsddb support wasn't enabled even
  853.     # though s/he requested it
  854.     if test "$with_libdb" = "yes"
  855.     then echo $ac_n "(requested, but db.h was not found) $ac_c"
  856.     fi
  857.     with_libdb="no"
  858. fi
  859.  
  860. if test "$with_libdb" = "no"
  861. then
  862.     USE_BSDDB_MODULE="#"
  863. else
  864.     AC_DEFINE(WITH_LIBDB)
  865. fi
  866. AC_MSG_RESULT($with_libdb)
  867.  
  868. if test "$with_libdb" = "yes"
  869. then
  870.     # check for libdb; BSD systems have the DB routines in libc  --tg
  871.     AC_SUBST(HAVE_LIBDB)
  872.     # If dbopen is not in libc, then checking whether it is in libdb
  873.     # is difficult: db_185.h may #define it as __db185_open
  874.     # Instead, we just trust it is in libdb; linking will fail if it
  875.     # is not.
  876.     AC_CHECK_FUNC(dbopen, [HAVE_LIBDB=], [HAVE_LIBDB=-ldb])
  877. fi
  878.  
  879. # Check for --with-wctype-functions
  880. AC_MSG_CHECKING(for --with-wctype-functions)
  881. AC_ARG_WITH(wctype-functions, 
  882. [  --with-wctype-functions         use wctype.h functions], [
  883. if test "$withval" != no
  884. then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes)
  885. else AC_MSG_RESULT(no)
  886. fi],
  887. [AC_MSG_RESULT(no)])
  888.  
  889. # -I${DLINCLDIR} is added to the compile rule for importdl.o
  890. AC_SUBST(DLINCLDIR)
  891. DLINCLDIR=/
  892.  
  893. AC_MSG_CHECKING(for --with-sgi-dl)
  894. AC_ARG_WITH(sgi-dl,
  895. [  --with-sgi-dl=DIRECTORY         IRIX 4 dynamic linking], [
  896. AC_MSG_RESULT($withval)
  897. AC_DEFINE(WITH_SGI_DL)
  898. DYNLOADFILE="dynload_dl.o"
  899. dldir=$withval
  900. if test ! -z "$dldir" -a -d "$dldir"
  901. then LDFLAGS="$LDFLAGS -L$dldir"
  902. else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
  903. fi
  904. DLINCLDIR=${dldir}
  905. LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
  906.  
  907. AC_MSG_CHECKING(for --with-dl-dld)
  908. AC_ARG_WITH(dl-dld, [  --with-dl-dld=DL_DIR,DLD_DIR    GNU dynamic linking], [
  909. AC_MSG_RESULT($withval)
  910. AC_DEFINE(WITH_DL_DLD)
  911. DYNLOADFILE="dynload_dl.o"
  912. dldir=`echo "$withval" | sed 's/,.*//'`
  913. dlddir=`echo "$withval" | sed 's/.*,//'`
  914. if test ! -z "$dldir" -a -d "$dldir" -a ! -z "$dlddir" -a -d "$dlddir"
  915. then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
  916. else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
  917. fi
  918. DLINCLDIR=${dldir}
  919. LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
  920.  
  921. # the dlopen() function means we might want to use dynload_shlib.o. some
  922. # platforms, such as AIX, have dlopen(), but don't want to use it.
  923. AC_CHECK_FUNCS(dlopen)
  924.  
  925. # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
  926. # loading of modules.
  927. AC_SUBST(DYNLOADFILE)
  928. AC_MSG_CHECKING(DYNLOADFILE)
  929. if test -z "$DYNLOADFILE"
  930. then
  931.     case $ac_sys_system/$ac_sys_release in
  932.     AIX*) DYNLOADFILE="dynload_aix.o";;
  933.     BeOS*) DYNLOADFILE="dynload_beos.o";;
  934.     hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
  935.     Darwin/*|next/*) DYNLOADFILE="dynload_next.o";;
  936.     *)
  937.     # use dynload_shlib.c and dlopen() if we have it; otherwise stub
  938.     # out any dynamic loading
  939.     if test "$ac_cv_func_dlopen" = yes
  940.     then DYNLOADFILE="dynload_shlib.o"
  941.     else DYNLOADFILE="dynload_stub.o"
  942.     fi
  943.     ;;
  944.     esac
  945. fi
  946. AC_MSG_RESULT($DYNLOADFILE)
  947. if test "$DYNLOADFILE" != "dynload_stub.o"
  948. then
  949.     AC_DEFINE(HAVE_DYNAMIC_LOADING)
  950. fi
  951.  
  952. # checks for library functions
  953. AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
  954.  flock fork fsync fdatasync fpathconf ftime ftruncate \
  955.  getgroups getlogin getpeername getpid getpwent getwd \
  956.  kill link lstat mkfifo mktime mremap \
  957.  nice pathconf pause plock poll pthread_init \
  958.  putenv readlink \
  959.  select setegid seteuid setgid \
  960.  setlocale setregid setreuid setsid setpgid setuid setvbuf \
  961.  sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
  962.  tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
  963.  truncate uname waitpid _getpty)
  964.  
  965. # check for openpty and forkpty
  966.  
  967. AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"]))
  968. AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"]))
  969.  
  970. # check for long file support functions
  971. AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
  972.  
  973. AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
  974. AC_CHECK_FUNCS(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
  975. AC_CHECK_FUNCS(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
  976. AC_CHECK_FUNCS(gettimeofday, AC_TRY_COMPILE([#include <sys/time.h>], [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,AC_DEFINE(GETTIMEOFDAY_NO_TZ)))
  977.  
  978. # checks for structures
  979. AC_HEADER_TIME
  980. AC_STRUCT_TM
  981. AC_STRUCT_TIMEZONE
  982.  
  983. AC_MSG_CHECKING(for time.h that defines altzone)
  984. AC_CACHE_VAL(ac_cv_header_time_altzone,
  985. [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
  986.   ac_cv_header_time_altzone=yes,
  987.   ac_cv_header_time_altzone=no)])
  988. AC_MSG_RESULT($ac_cv_header_time_altzone)
  989. if test $ac_cv_header_time_altzone = yes; then
  990.   AC_DEFINE(HAVE_ALTZONE)
  991. fi
  992.  
  993. was_it_defined=no
  994. AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
  995. AC_TRY_COMPILE([
  996. #include <sys/types.h>
  997. #include <sys/select.h>
  998. #include <sys/time.h>
  999. ], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
  1000. AC_MSG_RESULT($was_it_defined)
  1001.  
  1002. # checks for compiler characteristics
  1003.  
  1004. AC_C_CHAR_UNSIGNED
  1005. AC_C_CONST
  1006. AC_C_INLINE
  1007.  
  1008. works=no
  1009. AC_MSG_CHECKING(for working volatile)
  1010. AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
  1011. AC_MSG_RESULT($works)
  1012.  
  1013. works=no
  1014. AC_MSG_CHECKING(for working signed char)
  1015. AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
  1016. AC_MSG_RESULT($works)
  1017.  
  1018. have_prototypes=no
  1019. AC_MSG_CHECKING(for prototypes)
  1020. AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
  1021. AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
  1022. AC_MSG_RESULT($have_prototypes)
  1023.  
  1024. works=no
  1025. AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
  1026. AC_TRY_COMPILE([
  1027. #include <stdarg.h>
  1028. int foo(int x, ...) {
  1029.     va_list va;
  1030.     va_start(va, x);
  1031.     va_arg(va, int);
  1032.     va_arg(va, char *);
  1033.     va_arg(va, double);
  1034.     return 0;
  1035. }
  1036. ], [return foo(10, "", 3.14);],
  1037. AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
  1038. AC_MSG_RESULT($works)
  1039.  
  1040. if test "$have_prototypes" = yes; then
  1041. bad_prototypes=no
  1042. AC_MSG_CHECKING(for bad exec* prototypes)
  1043. AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
  1044.     AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
  1045. AC_MSG_RESULT($bad_prototypes)
  1046. fi
  1047.  
  1048. bad_forward=no
  1049. AC_MSG_CHECKING(for bad static forward)
  1050. AC_TRY_RUN([
  1051. struct s { int a; int b; };
  1052. static struct s foo;
  1053. int foobar() {
  1054.  static int random;
  1055.  random = (int) &foo;
  1056.  return random;
  1057. }
  1058. static struct s foo = { 1, 2 };
  1059. main() {
  1060.  exit(!((int)&foo == foobar()));
  1061. }
  1062. ], , AC_DEFINE(BAD_STATIC_FORWARD) bad_forward=yes)
  1063. AC_MSG_RESULT($bad_forward)
  1064.  
  1065. va_list_is_array=no
  1066. AC_MSG_CHECKING(whether va_list is an array)
  1067. AC_TRY_COMPILE([
  1068. #ifdef HAVE_STDARG_PROTOTYPES
  1069. #include <stdarg.h>
  1070. #else
  1071. #include <varargs.h>
  1072. #endif
  1073. ], [va_list list1, list2; list1 = list2;], , 
  1074. AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
  1075. AC_MSG_RESULT($va_list_is_array)
  1076.  
  1077. # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
  1078. AC_CHECK_FUNC(gethostbyname_r, [
  1079.   AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  1080.   AC_MSG_CHECKING([gethostbyname_r with 6 args])
  1081.   OLD_CFLAGS=$CFLAGS
  1082.   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
  1083.   AC_TRY_COMPILE([
  1084. #   include <netdb.h>
  1085.   ], [
  1086.     char *name;
  1087.     struct hostent *he, *res;
  1088.     char buffer[2048];
  1089.     int buflen = 2048;
  1090.     int h_errnop;
  1091.  
  1092.     (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
  1093.   ], [
  1094.     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  1095.     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG)
  1096.     AC_MSG_RESULT(yes)
  1097.   ], [
  1098.     AC_MSG_RESULT(no)
  1099.     AC_MSG_CHECKING([gethostbyname_r with 5 args])
  1100.     AC_TRY_COMPILE([
  1101. #     include <netdb.h>
  1102.     ], [
  1103.       char *name;
  1104.       struct hostent *he;
  1105.       char buffer[2048];
  1106.       int buflen = 2048;
  1107.       int h_errnop;
  1108.  
  1109.       (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
  1110.     ], [
  1111.       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  1112.       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG)
  1113.       AC_MSG_RESULT(yes)
  1114.     ], [
  1115.       AC_MSG_RESULT(no)
  1116.       AC_MSG_CHECKING([gethostbyname_r with 3 args])
  1117.       AC_TRY_COMPILE([
  1118. #       include <netdb.h>
  1119.       ], [
  1120.         char *name;
  1121.         struct hostent *he;
  1122.         struct hostent_data data;
  1123.  
  1124.         (void) gethostbyname_r(name, he, &data);
  1125.       ], [
  1126.         AC_DEFINE(HAVE_GETHOSTBYNAME_R)
  1127.         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG)
  1128.         AC_MSG_RESULT(yes)
  1129.       ], [
  1130.         AC_MSG_RESULT(no)
  1131.       ])
  1132.     ])
  1133.   ])
  1134.   CFLAGS=$OLD_CFLAGS
  1135. ], [
  1136.   AC_CHECK_FUNCS(gethostbyname)
  1137. ])
  1138. AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
  1139. AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
  1140. AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
  1141. AC_SUBST(HAVE_GETHOSTBYNAME_R)
  1142. AC_SUBST(HAVE_GETHOSTBYNAME)
  1143.  
  1144. # checks for system services
  1145. # (none yet)
  1146.  
  1147. # Linux requires this for correct f.p. operations
  1148. AC_CHECK_FUNC(__fpu_control,
  1149.   [],
  1150.   [AC_CHECK_LIB(ieee, __fpu_control)
  1151. ])
  1152.  
  1153. # Check for --with-fpectl
  1154. AC_MSG_CHECKING(for --with-fpectl)
  1155. AC_ARG_WITH(fpectl,
  1156. [  --with-fpectl                   enable SIGFPE catching], [
  1157. if test "$withval" != no
  1158. then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
  1159. else AC_MSG_RESULT(no)
  1160. fi],
  1161. [AC_MSG_RESULT(no)])
  1162.  
  1163. # check for --with-libm=...
  1164. AC_SUBST(LIBM)
  1165. case $ac_sys_system in
  1166. Darwin) ;;
  1167. next) ;;
  1168. BeOS) ;;
  1169. *) LIBM=-lm
  1170. esac
  1171. AC_MSG_CHECKING(for --with-libm=STRING)
  1172. AC_ARG_WITH(libm, [  --with-libm=STRING              math library], [
  1173. if test "$withval" = no
  1174. then LIBM=
  1175.      AC_MSG_RESULT(force LIBM empty)
  1176. elif test "$withval" != yes
  1177. then LIBM=$withval
  1178.      AC_MSG_RESULT(set LIBM=\"$withval\")
  1179. else AC_ERROR(proper usage is --with-libm=STRING)
  1180. fi],
  1181. [AC_MSG_RESULT(default LIBM=\"$LIBM\")])
  1182.  
  1183. # check for --with-libc=...
  1184. AC_SUBST(LIBC)
  1185. AC_MSG_CHECKING(for --with-libc=STRING)
  1186. AC_ARG_WITH(libc, [  --with-libc=STRING              C library], [
  1187. if test "$withval" = no
  1188. then LIBC=
  1189.      AC_MSG_RESULT(force LIBC empty)
  1190. elif test "$withval" != yes
  1191. then LIBC=$withval
  1192.      AC_MSG_RESULT(set LIBC=\"$withval\")
  1193. else AC_ERROR(proper usage is --with-libc=STRING)
  1194. fi],
  1195. [AC_MSG_RESULT(default LIBC=\"$LIBC\")])
  1196.  
  1197. # check for hypot() in math library
  1198. LIBS_SAVE=$LIBS
  1199. LIBS="$LIBS $LIBM"
  1200. AC_REPLACE_FUNCS(hypot)
  1201. LIBS=$LIBS_SAVE
  1202.  
  1203. # check for getopt
  1204. AC_MSG_CHECKING(for genuine getopt)
  1205. AC_CACHE_VAL(ac_cv_func_getopt,
  1206. [AC_TRY_RUN([#include <stdio.h>
  1207. extern int optind, opterr, getopt();
  1208. extern char* optarg;
  1209. int main() {
  1210.     char* av[] = { "testprog", "parameter", "-fFlag", NULL };
  1211.     opterr = 0;
  1212.     if (getopt(3, av, "f:") == 'f') { exit(1); }
  1213.     exit(0);
  1214. }], ac_cv_func_getopt=yes, ac_cv_func_getopt=no, ac_cv_func_getopt=no)])dnl
  1215. AC_MSG_RESULT($ac_cv_func_getopt)
  1216. test $ac_cv_func_getopt = no && LIBOBJS="$LIBOBJS getopt.o"
  1217. AC_SUBST(LIBOBJS)dnl
  1218.  
  1219. # check whether malloc(0) returns NULL or not
  1220. AC_MSG_CHECKING(what malloc(0) returns)
  1221. AC_CACHE_VAL(ac_cv_malloc_zero,
  1222. [AC_TRY_RUN([#include <stdio.h>
  1223. #ifdef HAVE_STDLIB
  1224. #include <stdlib.h>
  1225. #else
  1226. char *malloc(), *realloc();
  1227. int *free();
  1228. #endif
  1229. main() {
  1230.     char *p;
  1231.     p = malloc(0);
  1232.     if (p == NULL) exit(1);
  1233.     p = realloc(p, 0);
  1234.     if (p == NULL) exit(1);
  1235.     free(p);
  1236.     exit(0);
  1237. }], ac_cv_malloc_zero=nonnull, ac_cv_malloc_zero=null)])
  1238. AC_MSG_RESULT($ac_cv_malloc_zero)
  1239. if test "$ac_cv_malloc_zero" = null
  1240. then
  1241.   AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
  1242. fi
  1243.  
  1244. # check for wchar.h
  1245. AC_CHECK_HEADER(wchar.h,
  1246. AC_DEFINE(HAVE_WCHAR_H) wchar_h="yes",
  1247. wchar_h="no"
  1248. )
  1249.  
  1250. # check for usable wchar_t
  1251. usable_wchar_t="unkown"
  1252. AC_MSG_CHECKING(for usable wchar_t)
  1253. AC_TRY_RUN([
  1254. #include "wchar.h"
  1255. #include "wctype.h"
  1256. main() {
  1257.  wchar_t s;
  1258.  if (sizeof(s) == 2)
  1259.   exit(0);
  1260.  else
  1261.   exit(1);
  1262. }
  1263. ], 
  1264. AC_DEFINE(HAVE_USABLE_WCHAR_T) usable_wchar_t="yes",
  1265. usable_wchar_t="no")
  1266. AC_MSG_RESULT($usable_wchar_t)
  1267.  
  1268. # check for endianness
  1269. AC_C_BIGENDIAN
  1270.  
  1271. # Check whether right shifting a negative integer extends the sign bit
  1272. # or fills with zeros (like the Cray J90, according to Tim Peters).
  1273. AC_MSG_CHECKING(whether right shift extends the sign bit)
  1274. AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
  1275. AC_TRY_RUN([
  1276. int main()
  1277. {
  1278.     exit(((-1)>>3 == -1) ? 0 : 1);
  1279. }
  1280. ], ac_cv_rshift_extends_sign=yes, ac_cv_rshift_extends_sign=no)])
  1281. AC_MSG_RESULT($ac_cv_rshift_extends_sign)
  1282. if test "$ac_cv_rshift_extends_sign" = no
  1283. then
  1284.   AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS)
  1285. fi
  1286.  
  1287.  
  1288. # THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
  1289. # Add sys/socket.h to confdefs.h
  1290. cat >> confdefs.h <<\EOF
  1291. #ifdef HAVE_SYS_SOCKET_H
  1292. #include <sys/socket.h>
  1293. #endif
  1294. EOF
  1295. AC_CHECK_TYPE(socklen_t, int)
  1296.  
  1297. # generate output files
  1298. AC_OUTPUT(Makefile \
  1299.  Objects/Makefile \
  1300.  Parser/Makefile \
  1301.  Grammar/Makefile \
  1302.  Python/Makefile \
  1303.  Modules/Makefile.pre \
  1304.  Modules/Setup.config)
  1305.