This commit was manufactured by cvs2svn to create tag 'cnrisync'.
[python/dscho.git] / configure.in
blob7dc63c8468fbbcaa84ef4b1e4d55478ea9200693
1 dnl Process this file with autoconf 2.0 or later to make a configure script.
2 AC_REVISION($Revision$)
3 AC_PREREQ(2.0)
4 AC_INIT(Include/object.h)
5 AC_CONFIG_HEADER(config.h)
7 # checks for alternative programs
8 AC_MSG_CHECKING(for --without-gcc)
9 AC_ARG_WITH(gcc, [--without-gcc             never use gcc], [
10         case $withval in
11         no)     CC=cc
12                 without_gcc=yes;;
13         yes)    CC=gcc
14                 without_gcc=no;;
15         *)      CC=$withval
16                 without_gcc=$withval;;
17         esac], [
18         case `uname -s` in
19         OSF1)   CC=cc
20                 without_gcc=;;
21         *)      without_gcc=no;;
22         esac])
23 AC_MSG_RESULT($without_gcc)
25 # If the user switches compilers, we can't believe the cache
26 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
27 then
28   AC_ERROR(cached CC is different -- throw away $cache_file
29 (it is also a good idea to do 'make clean' before compiling))
32 AC_PROG_CC
33 AC_PROG_RANLIB
34 AC_SUBST(AR)
35 AC_CHECK_PROGS(AR, ar aal, ar)
36 AC_SUBST(INSTALL)
37 AC_SUBST(INSTALL_PROGRAM)
38 AC_SUBST(INSTALL_DATA)
39 # Install just never works :-(
40 if test -z "$INSTALL"
41 then
42         INSTALL=cp
43         INSTALL_PROGRAM=cp
44         INSTALL_DATA=cp
45 else
46         INSTALL_PROGRAM="$INSTALL"
47         INSTALL_DATA="$INSTALL -m 644"
49 AC_SUBST(OPT)
50 # Optimizer/debugger flags passed between Makefiles
51 if test -z "$OPT"
52 then OPT=-O
55 # checks for UNIX variants that set C preprocessor variables
56 AC_AIX
57 AC_MINIX
59 # checks for header files
60 AC_HEADER_STDC
61 AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h sys/audioio.h sys/param.h sys/select.h sys/time.h sys/times.h sys/un.h sys/utsname.h sys/wait.h)
62 AC_HEADER_DIRENT
64 # checks for typedefs
65 was_it_defined=no
66 AC_MSG_CHECKING(for clock_t in time.h)
67 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
68 AC_MSG_RESULT($was_it_defined)
70 AC_TYPE_MODE_T
71 AC_TYPE_OFF_T
72 AC_TYPE_PID_T
73 AC_TYPE_SIGNAL
74 AC_TYPE_SIZE_T
75 AC_TYPE_UID_T
77 # Set name for machine-dependent library files
78 AC_SUBST(MACHDEP)
79 AC_MSG_CHECKING(MACHDEP)
80 if test -z "$MACHDEP"
81 then
82         ac_sys_system=`uname -s | tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
83         ac_sys_release=`uname -r | tr -d '[/ ]' | sed 's/\..*//'`
84         ac_sys_cpu=`(uname -p 2>/dev/null || uname -m) |
85                      tr '[[A-Z]]' '[[a-z]]'`
86 ##      MACHDEP="$ac_sys_system$ac_sys_release$ac_sys_cpu"
87         MACHDEP="$ac_sys_system$ac_sys_release"
88         case MACHDEP in
89         '')     MACHDEP=unknown;;
90         esac
92 AC_MSG_RESULT($MACHDEP)
94 # Set info about shared libraries.
95 # XXX This should try things out instead of testing uname!
96 AC_SUBST(SO)
97 AC_SUBST(LDSHARED)
98 AC_SUBST(CCSHARED)
99 AC_SUBST(LINKFORSHARED)
100 ac_sys_system=`uname -s`
101 ac_sys_release=`uname -r`
102 # SO is the extension of shared libraries `(including the dot!)
103 # -- usually .so, .sl on HP-UX
104 AC_MSG_CHECKING(SO)
105 if test -z "$SO"
106 then
107         case $ac_sys_system in
108         hp*|HP*) SO=.sl;;
109         *)      SO=.so;;
110         esac
112 AC_MSG_RESULT($SO)
113 # LDSHARED is the ld *command* used to create shared library
114 # -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5
115 AC_MSG_CHECKING(LDSHARED)
116 if test -z "$LDSHARED"
117 then
118         case $ac_sys_system/$ac_sys_release in
119         IRIX*) LDSHARED="ld -shared";;
120         SunOS/4*) LDSHARED="ld";;
121         SunOS/5*) LDSHARED="ld -G";;
122         hp*|HP*) LDSHARED="ld -b";;
123         OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
124         DYNIX/ptx*) LDSHARED="ld -G";;
125         Linux*) LDSHARED="gcc-elf -shared";;
126         *)      LDSHARED="ld";;
127         esac
129 AC_MSG_RESULT($LDSHARED)
130 # CCSHARED are the C *flags* used to create objects to go into a shared
131 # library -- this is only needed for a few systems
132 AC_MSG_CHECKING(CCSHARED)
133 if test -z "$CCSHARED"
134 then
135         case $ac_sys_system in
136         hp*|HP*) if test "$GCC" = yes;
137                  then CCSHARED="-fpic";
138                  else CCSHARED="+z";
139                  fi;;
140         Linux*) CCSHARED="-fpic";;
141         esac
143 AC_MSG_RESULT($CCSHARED)
144 # LINKFORSHARED are the flags passed to the $(CC) command that links
145 # the python executable -- this is only needed for a few systems
146 AC_MSG_CHECKING(LINKFORSHARED)
147 if test -z "$LINKFORSHARED"
148 then
149         case $ac_sys_system in
150         hp*|HP*) LINKFORSHARED="-Wl,-E";;
151         Linux*) LINKFORSHARED="-rdynamic";;
152         esac
154 AC_MSG_RESULT($LINKFORSHARED)
156 # checks for libraries
157 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
158 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
159 AC_CHECK_LIB(sun, getpwnam)     # NIS (== YP) interface for IRIX 4
160 # The following three (nsl,inet,socket) are needed on Sequent;
161 # the order of checking must be this.  Most SVR4 platforms will
162 # need -lsocket and -lnsl.  However on SGI IRIX 5, these exist but
163 # broken.  I see no elegant solution (probably CHECK_LIB should be
164 # fixed to only add the library if the given entry point is not
165 # satisfied without it).
166 if test "`uname -s`" != IRIX
167 then
168 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
169 AC_CHECK_LIB(inet, gethostbyname, [LIBS="-linet $LIBS"], [], -lnsl) # Sequent
170 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
173 AC_MSG_CHECKING(for --with-readline)
174 AC_ARG_WITH(readline, [--with-readline=DIRECTORY GNU readline], [
175 AC_MSG_RESULT($withval)
176 AC_DEFINE(WITH_READLINE)
177 if test ! -d "$withval"
178 then AC_ERROR(proper usage is --with-readline=DIRECTORY)
180 termcap=
181 AC_CHECK_LIB(termcap, tgetent, [termcap=termcap], [
182 AC_CHECK_LIB(termlib, tgetent, [termcap=termlib])])
183 if test ! -z "$termcap"
184 then LIBS="$LIBS $withval/libreadline.a"
185      # Avoid possible conflict between shared libraries termcap and gl
186      # on IRIX 5: both contain a routine called clear.
187      if test -f /usr/lib/lib$termcap.a
188      then LIBS="$LIBS /usr/lib/lib$termcap.a"
189      else LIBS="$LIBS -l$termcap"
190      fi
191 else AC_ERROR(no working termcap/termlib, do not use --with-readline)
192 fi], AC_MSG_RESULT(no))
194 AC_MSG_CHECKING(for --with-thread)
195 AC_ARG_WITH(thread, [--with-thread[=DIRECTORY] make interpreter thread-safe], [
196 AC_MSG_RESULT($withval)
197 if test -d "$withval"
198 then LIBS="$LIBS -L$withval"
200 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
201 AC_DEFINE(_POSIX_THREADS)
202 LIBS="$LIBS -lpthreads"
203 LIBOBJS="$LIBOBJS thread.o"])
204 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
205 LIBS="$LIBS -lmpc"
206 LIBOBJS="$LIBOBJS thread.o"])
207 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
208 LIBS="$LIBS -lthread"
209 LIBOBJS="$LIBOBJS thread.o"])
210 ], AC_MSG_RESULT(no))
212 # -I${DLINCLDIR} is added to the compile rule for import.o
213 AC_SUBST(DLINCLDIR)
214 DLINCLDIR=/
216 AC_MSG_CHECKING(for --with-sgi-dl)
217 AC_ARG_WITH(sgi-dl, [--with-sgi-dl=DIRECTORY   IRIX 4 dynamic linking], [
218 AC_MSG_RESULT($withval)
219 AC_DEFINE(WITH_SGI_DL)
220 dldir=$withval
221 if test -d "$dldir"
222 then LIBS="$LIBS -L$dldir"
223 else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
225 DLINCLDIR=${dldir}
226 LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
228 AC_MSG_CHECKING(for --with-dl-dld)
229 AC_ARG_WITH(dl-dld, [--with-dl-dld=DL_DIR,DLD_DIR  GNU dynamic linking], [
230 AC_MSG_RESULT($withval)
231 AC_DEFINE(WITH_DL_DLD)
232 dldir=`echo "$withval" | sed 's/,.*//'`
233 dlddir=`echo "$withval" | sed 's/.*,//'`
234 if test -d "$dldir" -a -d "$dlddir"
235 then LIBS="$LIBS -L$dldir -L$dlddir"
236 else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
238 DLINCLDIR=${dldir}
239 LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
241 # checks for library functions
242 AC_CHECK_FUNCS(chown clock dlopen ftime ftruncate gethostname_r gettimeofday getpeername getpgrp getpid getwd link lstat nice readlink select setgid setuid setsid setpgid setpgrp setvbuf siginterrupt strftime symlink tcgetpgrp tcsetpgrp times truncate uname waitpid)
243 AC_REPLACE_FUNCS(dup2 getcwd strerror memmove)
244 AC_CHECK_FUNC(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
245 AC_CHECK_FUNC(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
246 AC_CHECK_FUNC(gettimeofday, AC_TRY_COMPILE([#include <sys/time.h>], [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,AC_DEFINE(GETTIMEOFDAY_NO_TZ)))
248 # checks for structures
249 AC_HEADER_TIME
250 AC_STRUCT_TM
251 AC_STRUCT_TIMEZONE
253 AC_MSG_CHECKING(for time.h that defines altzone)
254 AC_CACHE_VAL(ac_cv_header_time_altzone,
255 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
256   ac_cv_header_time_altzone=yes,
257   ac_cv_header_time_altzone=no)])
258 AC_MSG_RESULT($ac_cv_header_time_altzone)
259 if test $ac_cv_header_time_altzone = yes; then
260   AC_DEFINE(HAVE_ALTZONE)
263 was_it_defined=no
264 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
265 AC_TRY_COMPILE([
266 #include <sys/types.h>
267 #include <sys/select.h>
268 #include <sys/time.h>
269 ], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
270 AC_MSG_RESULT($was_it_defined)
272 # checks for compiler characteristics
274 AC_C_CHAR_UNSIGNED
276 AC_C_CONST
278 works=no
279 AC_MSG_CHECKING(for working volatile)
280 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
281 AC_MSG_RESULT($works)
283 works=no
284 AC_MSG_CHECKING(for working signed char)
285 AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
286 AC_MSG_RESULT($works)
288 have_prototypes=no
289 AC_MSG_CHECKING(for prototypes)
290 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
291 AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
292 AC_MSG_RESULT($have_prototypes)
294 works=no
295 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
296 AC_TRY_COMPILE([
297 #include <stdarg.h>
298 int foo(int x, ...) { return 0; }
299 ], [return foo(10, 11, 12);],
300 AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
301 AC_MSG_RESULT($works)
303 if test "$have_prototypes" = yes; then
304 bad_prototypes=no
305 AC_MSG_CHECKING(for bad exec* prototypes)
306 AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
307         AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
308 AC_MSG_RESULT($bad_prototypes)
311 bad_forward=no
312 AC_MSG_CHECKING(for bad static forward)
313 AC_TRY_RUN([
314 struct s { int a; int b; };
315 static struct s foo;
316 int foobar() {
317  static int random;
318  random = (int) &foo;
319  return random;
321 static struct s foo = { 1, 2 };
322 main() {
323  exit(!((int)&foo == foobar()));
325 ], , AC_DEFINE(BAD_STATIC_FORWARD) bad_forward=yes)
326 AC_MSG_RESULT($bad_forward)
328 va_list_is_array=no
329 AC_MSG_CHECKING(whether va_list is an array)
330 AC_TRY_COMPILE([
331 #ifdef HAVE_STDARG_PROTOTYPES
332 #include <stdarg.h>
333 #else
334 #include <varargs.h>
335 #endif
336 ], [va_list list1, list2; list1 = list2;], , 
337 AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
338 AC_MSG_RESULT($va_list_is_array)
340 # checks for system services
341 # (none yet)
343 # Linux requires this for correct f.p. operations
344 AC_CHECK_LIB(ieee, __fpu_control)
346 # check for --with-libm=...
347 AC_SUBST(LIBM)
348 LIBM=-lm
349 AC_ARG_WITH(libm, [--with-libm=STRING        math library], [
350 if test "$withval" != yes
351 then LIBM=$withval
352 else AC_ERROR(proper usage is --with-libm=STRING)
353 fi])
355 # check for --with-libc=...
356 AC_SUBST(LIBC)
357 AC_ARG_WITH(libc, [--with-libc=STRING        C library], [
358 if test "$withval" != yes
359 then LIBC=$withval
360 else AC_ERROR(proper usage is --with-libc=STRING)
361 fi])
363 # check for hypot() in math library
364 LIBS_SAVE=$LIBS
365 LIBS="$LIBS $LIBM"
366 AC_CHECK_FUNCS(hypot)
367 LIBS=$LIBS_SAVE
369 # check for getopt
370 AC_MSG_CHECKING(for genuine getopt)
371 AC_CACHE_VAL(ac_cv_func_getopt,
372 [AC_TRY_RUN([#include <stdio.h>
373 extern int optind, opterr, getopt();
374 extern char* optarg;
375 int main() {
376         char* av[] = { "testprog", "parameter", "-fFlag", NULL };
377         opterr = 0;
378         if (getopt(3, av, "f:") == 'f') { exit(1); }
379         exit(0);
380 }], ac_cv_func_getopt=yes, ac_cv_func_getopt=no, ac_cv_func_getopt=no)])dnl
381 AC_MSG_RESULT($ac_cv_func_getopt)
382 test $ac_cv_func_getopt = no && LIBOBJS="$LIBOBJS getopt.o"
383 AC_SUBST(LIBOBJS)dnl
385 # generate output files
386 AC_OUTPUT(Makefile Objects/Makefile Parser/Makefile Python/Makefile Modules/Makefile.pre)