1: dnl Process this file with autoconf to produce a configure script.
2: dnl $Id: configure.ac,v 1.105 2007/10/29 23:00:26 shirok Exp $
3: AC_PREREQ(2.54)
4: AC_INIT(Gauche, 0.8.12, shiro@acm.org)
5: AC_REVISION($Revision: 1.105 $)
6: AC_CANONICAL_SYSTEM
7: AC_CONFIG_HEADER(src/gauche/config.h ext/auxsys/auxsysconf.h)
8:
9: dnl ==========================================================
10: dnl Process args given to configure
11: dnl
12:
13: dnl ----------------------------------------------------------
14: dnl enable-multibyte
15: dnl
16: GAUCHE_CHAR_ENCODING=utf8
17: AC_ARG_ENABLE(multibyte,
18: AC_HELP_STRING([--enable-multibyte=ENCODING],
19: [Use ENCODING as the internal multibyte string encoding.
20: Following encodings are currently recognized:
21: 'euc-jp' (EUC-JP code), 'utf-8' (UTF-8), 'sjis' (Shift-JIS),
22: or 'none' (No multibyte support)]),
23: [
24: case $enable_multibyte in
25: euc-jp|eucjp|yes) GAUCHE_CHAR_ENCODING=eucjp;;
26: utf-8|utf8) GAUCHE_CHAR_ENCODING=utf8;;
27: sjis|shift-jis) GAUCHE_CHAR_ENCODING=sjis;;
28: no|none) GAUCHE_CHAR_ENCODING=none;;
29: *) echo "unrecognized encoding option: '$enable_multibyte'; type ./configure --help for available options"
30: exit 1;;
31: esac
32: ],
33: [
34: GAUCHE_CHAR_ENCODING=utf8
35: ac_configure_args="$ac_configure_args '--enable-multibyte=utf-8'"
36: ])
37:
38: case $GAUCHE_CHAR_ENCODING in
39: eucjp) AC_DEFINE(GAUCHE_CHAR_ENCODING_EUC_JP);;
40: utf8) AC_DEFINE(GAUCHE_CHAR_ENCODING_UTF_8);;
41: sjis) AC_DEFINE(GAUCHE_CHAR_ENCODING_SJIS);;
42: esac
43:
44: dnl ----------------------------------------------------------
45: dnl with-slib
46: dnl
47: SLIB_DIR=/usr/local/slib
48: AC_ARG_WITH(slib,
49: AC_HELP_STRING([--with-slib=PATH],
50: [Configure Gauche's slib module to use Aubrey Jaffer's SLIB
51: installed under PATH. If PATH is not specified, or this option is omitted,
52: Gauche still tries to find your slib installation from some typical places.]),
53: [
54: case $with_slib in
55: no) search_slib=no;;
56: yes) search_slib=yes;;
57: *) search_slib=no; SLIB_DIR=$with_slib;;
58: esac
59: ], [ search_slib=yes ])
60:
61: if test $search_slib = "yes"; then
62: AC_MSG_CHECKING(slib)
63: slib_found=no
64: for dir in /usr/share/slib /usr/local/slib /usr/local/lib/slib /usr/local/share/slib /usr/src/slib /opt/share/slib; do
65: if test -f $dir/require.scm; then
66: SLIB_DIR=$dir
67: AC_MSG_RESULT($SLIB_DIR)
68: slib_found=yes
69: break
70: fi
71: done
72: if test $slib_found = "no"; then
73: AC_MSG_RESULT([not found, using fallback $SLIB_DIR])
74: fi
75: fi
76: AC_SUBST(SLIB_DIR)
77:
78: dnl ----------------------------------------------------------
79: dnl with-local=PATH:...
80: dnl
81: AC_ARG_WITH(local,
82: AC_HELP_STRING([--with-local=PATH:PATH...],
83: [For each PATH, add PATH/include to the include search
84: paths and PATH/lib to the library search paths. Useful if you have some
85: libraries installed in non-standard places. ]),
86: [
87: case $with_local in
88: yes|no|"") ;;
89: *) paths=`echo $with_local | tr ':' ' '`
90: LOCAL_INC=`for p in $paths; do echo $ECHO_N "-I$p/include $ECHO_C"; done`
91: LOCAL_LIB=`for p in $paths; do echo $ECHO_N "-L$p/lib $ECHO_C"; done`;;
92: esac
93: ])
94: AC_SUBST(LOCAL_INC)
95: AC_SUBST(LOCAL_LIB)
96: dnl need to add here, for it may be used by the tests below.
97: INCLUDES="$INCLUDES $LOCAL_INC"
98: CPPFLAGS="$CPPFLAGS $LOCAL_INC"
99: LDFLAGS="$LDFLAGS $LOCAL_LIB"
100:
101: dnl ----------------------------------------------------------
102: dnl with-rpath=PATH:...
103: dnl
104: try_rpath=yes
105: rpath=
106: AC_ARG_WITH(rpath,
107: AC_HELP_STRING([--with-rpath=PATH:PATH...],
108: [Use -rpath option while building dynamically loadable objects (experimental).]),
109: [
110: case $with_rpath in
111: yes) ;;
112: no) try_rpath=no;;
113: *) rpath="`echo $with_rpath | sed -e 's/^/-Wl,-rpath /' -e 's/:/ -Wl,-rpath /g'`";;
114: esac
115: ])
116:
117: dnl ----------------------------------------------------------
118: dnl enable-thread=TYPE
119: dnl
120: GAUCHE_THREAD_TYPE=default
121: AC_ARG_ENABLE(threads,
122: AC_HELP_STRING([--enable-threads=TYPE],
123: [Choose thread type. Possible values are: 'none' for not using threads, 'pthreads' to use pthreads, and 'default' to choose system's suitable one (if any). ]),
124: [
125: case $enableval in
126: pthreads)
127: GAUCHE_THREAD_TYPE=pthreads
128: ;;
129: no|none)
130: GAUCHE_THREAD_TYPE=none
131: ;;
132: default)
133: GAUCHE_THREAD_TYPE=default
134: ;;
135: *)
136: AC_MSG_ERROR([invalid value $enableval for --enable-threads option (must be either none, pthreads, or default])
137: ;;
138: esac
139: ], [])
140:
141: dnl Platform-dependent thread configuration. This must be in sync
142: dnl with gc's configure.in.
143: case $GAUCHE_THREAD_TYPE in
144: pthreads|default)
145: case "$target" in
146: *-*-linux*)
147: AC_DEFINE(GC_LINUX_THREADS,1,[Define to use Linux threads])
148: AC_DEFINE(_REENTRANT,1,[Define to use reentrant libc])
149: THREADLIBS="-lpthread"
150: GAUCHE_THREAD_TYPE=pthreads
151: ;;
152: *-*-hpux*)
153: AC_MSG_WARN("Only HP/UX 11 threads are supported.")
154: AC_DEFINE(GC_HPUX_THREADS,1,[Define to use HP-UX threads])
155: AC_DEFINE(_POSIX_C_SOURCE,199506L,[Define POSIX C version])
156: THREADLIBS="-lpthread -lrt"
157: GAUCHE_THREAD_TYPE=pthreads
158: ;;
159: *-*-freebsd*|*-*-dragonfly*)
160: AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.")
161: AC_DEFINE(GC_FREEBSD_THREADS,1,[Define to use FreeBSD threads])
162: INCLUDES="$INCLUDES -pthread"
163: THREADLIBS="-pthread"
164: GAUCHE_THREAD_TYPE=pthreads
165: ;;
166: *-*-netbsd*)
167: AC_MSG_WARN("Only on NetBSD 2.0 or later.")
168: AC_DEFINE(GC_NETBSD_THREADS,1,[Define to use NetBSD threads])
169: AC_DEFINE(_REENTRANT)
170: AC_DEFINE(_PTHREADS)
171: THREADLIBS="-lpthread"
172: THREADDLLIBS="-lpthread -lrt"
173: GAUCHE_THREAD_TYPE=pthreads
174: ;;
175: *-*-solaris*)
176: AC_DEFINE(GC_SOLARIS_THREADS,1,[Define to use Solaris threads])
177: AC_DEFINE(GC_SOLARIS_PTHREADS,1,[Define to use Solaris pthreads])
178: AC_DEFINE(_POSIX_PTHREAD_SEMANTICS,1,[Define to use Solaris pthreads])
179: THREADLIBS="-lpthread"
180: GAUCHE_THREAD_TYPE=pthreads
181: ;;
182: *-*-irix*)
183: AC_DEFINE(GC_IRIX_THREADS,1,[Define to use IRIX threads])
184: THREADLIBS="-lpthread"
185: GAUCHE_THREAD_TYPE=pthreads
186: ;;
187: *-*-cygwin*)
188: AC_DEFINE(GC_WIN32_THREADS,1,[Define to use Win32 threads])
189: THREADLIBS="-lpthread"
190: GAUCHE_THREAD_TYPE=pthreads
191: ;;
192: *-*-darwin*)
193: AC_DEFINE(GC_DARWIN_THREADS,1,[Define to use Darwin threads])
194: AC_DEFINE(GC_PTHREADS,1,[Define to use pthreads])
195: INCLUDES="$INCLUDES -I/sw/include"
196: THREADLIBS="-lpthread"
197: GAUCHE_THREAD_TYPE=pthreads
198: ;;
199: *)
200: if test $GAUCHE_THREAD_TYPE = "pthreads"; then
201: AC_MSG_ERROR([pthread is not supported on $target])
202: else
203: GAUCHE_THREAD_TYPE=none
204: fi
205: ;;
206: esac
207: ;;
208: esac
209: case $GAUCHE_THREAD_TYPE in
210: pthreads)
211: AC_DEFINE(GAUCHE_USE_PTHREADS,1,[Define if we use pthreads])
212: ;;
213: *)
214: ;;
215: esac
216:
217: LIBS="$LIBS $THREADLIBS"
218: dnl Save thread model to be inherited by gc/ subdir.
219: echo $GAUCHE_THREAD_TYPE > config.threads
220:
221: dnl ----------------------------------------------------------
222: dnl enable-framework
223: dnl
224: ac_gauche_framework=no
225: AC_ARG_ENABLE(framework,
226: AC_HELP_STRING([--enable-framework],
227: [On MacOSX, build Gauche as a framework. This flag has no effect on other platforms.]),
228: [
229: case $enableval in
230: no)
231: ;;
232: *)
233: ac_gauche_framework=yes
234: ;;
235: esac
236: ], [])
237:
238: dnl ==========================================================
239: dnl Checks for programs.
240: AC_PROG_CC
241: AC_PROG_CC_STDC
242: AC_C_CONST
243: AC_PROG_MAKE_SET
244: AC_PROG_INSTALL
245: AC_CHECK_PROGS(AR, ar gar)
246: AC_CHECK_PROGS(AS, as gas)
247: AC_CHECK_PROGS(MAKEINFO, makeinfo)
248: AC_CHECK_PROGS(GZIP_PROGRAM, gzip)
249:
250: dnl Safe default CFLAGS (usually -g -O2 if you're using gcc, empty otherwise).
251: dnl If the user overrides CFLAGS during configure, which is recorded.
252: dnl This information is used when configuring extensions.
253: DEFAULT_CFLAGS="$CFLAGS"
254: AC_SUBST(DEFAULT_CFLAGS)
255:
256: dnl ===========================================================
257: dnl Checks for header files.
258: dnl We check sys/types.h merely to include it in the following tests,
259: dnl for some tests needs it.
260: AC_HEADER_STDC
261: AC_HEADER_TIME
262: AC_CHECK_HEADERS(sys/time.h sys/types.h glob.h dlfcn.h getopt.h sched.h unistd.h)
263: AC_CHECK_HEADERS(stdint.h inttypes.h rpc/types.h)
264: AC_CHECK_HEADERS(syslog.h crypt.h)
265: AC_CHECK_HEADERS(pty.h util.h libutil.h sys/loadavg.h)
266:
267: dnl solaris specific
268: AC_CHECK_HEADERS(sunmath.h)
269:
270: dnl ===========================================================
271: dnl Checks processor type, for processor-specific stuff
272: case $target in
273: i?86-*)
274: AC_DEFINE(SCM_TARGET_I386,1,[Define if uses i386 optimizations]) ;;
275: alpha*)
276: CFLAGS="$CFLAGS -mieee" ;;
277: arm*)
278: # ARM processor uses a special mixed endian for doubles.
279: AC_DEFINE(DOUBLE_ARMENDIAN,1) ;;
280: esac
281:
282: dnl ===========================================================
283: dnl Checks for typedefs, structures, and compiler characteristics.
284: AC_C_INLINE
285: AC_C_BIGENDIAN
286: AC_STRUCT_TM
287: AC_CHECK_SIZEOF(long)
288: AC_CHECK_SIZEOF(int)
289: AC_CHECK_SIZEOF(off_t)
290: AC_CHECK_TYPES([uint16_t, int32_t, uint32_t, int64_t, uint64_t, long double])
291: AC_CHECK_TYPES([struct timespec])
292:
293: if test "$GAUCHE_THREAD_TYPE" = pthreads; then
294: AC_CHECK_TYPES(pthread_spinlock_t,,,[#include <pthread.h>])
295: fi
296:
297: dnl Checks non-POSIX members of system structure
298: AC_CHECK_MEMBERS([struct group.gr_passwd],,,[#include <grp.h>])
299: AC_CHECK_MEMBERS([struct passwd.pw_passwd,
300: struct passwd.pw_gecos,
301: struct passwd.pw_class],,,[#include <pwd.h>])
302:
303: dnl checks if time_t is integer or flonum
304: AC_CACHE_CHECK(time_t is integral, ac_cv_type_time_t_integral, [
305: AC_TRY_RUN([
306: #include <time.h>
307: int main()
308: {
309: time_t t = 3.14;
310: return (t == 3.14);
311: }], ac_cv_type_time_t_integral=yes, ac_cv_type_time_t_integral=no,
312: ac_cv_type_time_t_integral=yes)])
313:
314: if test "$ac_cv_type_time_t_integral" = yes; then
315: AC_DEFINE(INTEGRAL_TIME_T,1,[Define if time_t is typedef'ed to an integral type])
316: fi
317:
318: dnl ===========================================================
319: dnl Checks for library functions.
320: AC_PROG_GCC_TRADITIONAL
321:
322: dnl This is required to test trunc and rint below
323: AC_CHECK_LIB(m, sin)
324:
325: dnl x86-solaris 9 requires this to use isinf
326: AC_CHECK_LIB(sunmath, isinf)
327:
328: dnl For Windows/MinGW, manually adds several libraries
329: case "$target" in
330: *mingw*) LIBS="$LIBS -lnetapi32 -lshlwapi";;
331: *) ;;
332: esac
333:
334: AC_FUNC_ALLOCA
335: AC_CHECK_FUNCS(isnan isinf trunc rint)
336: AC_CHECK_FUNCS(symlink readlink lchown mkstemp realpath nanosleep usleep)
337: AC_CHECK_FUNCS(random srandom lrand48 srand48)
338: AC_CHECK_FUNCS(putenv setenv unsetenv getpgid)
339: AC_CHECK_FUNCS(gethostname sethostname getdomainname setdomainname)
340: AC_CHECK_FUNCS(gettimeofday getloadavg)
341: AC_CHECK_FUNCS(syslog setlogmask)
342: AC_CHECK_FUNCS(sigwait)
343:
344: dnl Check for select(). HP-UX doesn't like the way configure tests
345: dnl select() existence, so we skip the test on it.
346: case "$target" in
347: *-hpux*)
348: AC_DEFINE(HAVE_SELECT, 1, [Define if you have select]) ;;
349: *)
350: AC_CHECK_FUNCS(select);;
351: esac
352:
353: dnl Checks for pty-related fns. It appears that recent Cygwin has them,
354: dnl but only in a static library. That prevents us from creating DLL
355: dnl version of gauche. Thus we explictly exclude them on cygwin.
356: case "$target" in
357: *cygwin*)
358: : ;;
359: *)
360: AC_SEARCH_LIBS(openpty, util, AC_DEFINE(HAVE_OPENPTY, 1, [Define if you have openpty]))
361: AC_SEARCH_LIBS(forkpty, util, AC_DEFINE(HAVE_FORKPTY, 1, [Define if you have forkpty]))
362: ;;
363: esac
364:
365: dnl Checks if crypt() exists and whether it's in libc or libcrypt.
366: dnl Note: on cygwin, libcrypt is only available as a static library,
367: dnl and prevents libgauche.dll from building. We explicitly excludes it.
368: dnl
369: case "$target" in
370: *cygwin*)
371: : ;;
372: *)
373: AC_SEARCH_LIBS(crypt, crypt, AC_DEFINE(HAVE_CRYPT,1,[Define if uses libcrypt]))
374: ;;
375: esac
376:
377: dnl Checks if dlopen exists, and if it's in libc or libdl.
378: AC_SEARCH_LIBS(dlopen, dl, AC_DEFINE(HAVE_DLOPEN,1,[Define if the system has dlopen()]))
379:
380: dnl Checks for sched_yield.
381: AC_SEARCH_LIBS(sched_yield, rt, AC_DEFINE(HAVE_SCHED_YIELD,1,[Define if uses librt]))
382:
383: dnl
384: dnl Checks compiler options for dynamic link and thread support.
385: dnl
386: dnl SHLIB_SO_SUFFIX Suffix of dlopen-able module. most systems doesn't
387: dnl have restriction for this. default "so".
388: dnl SHLIB_DYLIB_SUFFIX Suffix of dynamic linkable module. On Unices
389: dnl it is usuallly "so". On MacOSX it is "dylib".
390: dnl On Win32 it is "dll". If not explicitly specified,
391: dnl SHLIB_SO_SUFFIX is used.
392: dnl SHLIB_SO_CFLAGS flags to compile files which is dlopen-able
393: dnl e.g. "-fpic"
394: dnl SHLIB_SO_LDFLAGS flags to link files to create dlopen-able
395: dnl module, e.g. "-shared -o"
396: dnl SHLIB_DYLIB_LDFLAGS flags to link files to create dynamically linkable
397: dnl module. On most unices this is the same as
398: dnl SHLIB_SO_LDFLAGS.
399: dnl SHLIB_MAIN_LDFLAGS flags required to compile a main program which
400: dnl exposes symbols to be referred by the dynamically
401: dnl loaded module, e.g. "-rdynamic"
402: dnl LINK_HELPER A script that helps linking libgauche. Sort of
403: dnl simplified libtool. So far we only need this on
404: dnl MacOSX. We have absolutely no intention to
405: dnl re-invent libtool, though.
406: dnl LIBGAUCHE_SO defined as "libgauche.$(SHLIB_SO_SUFFIX)" if
407: dnl system supports dso. empty otherwise.
408: dnl GOSH_USE_SHLIB If set to "yes", gosh uses dynamic linkable version
409: dnl of libgauche, instead of statically links libgauche.a.
410: dnl On Win32 it is required to allow extensions to work.
411:
412: AC_MSG_CHECKING(how to make dynamic loadable module)
413:
414:
415:
416:
417: ext_use_libgauche=no
418:
419:
420:
421: libgauche_version_link=yes
422:
423:
424:
425:
426:
427: ext_use_uvector=no
428:
429:
430:
431: xtarget=$target
432:
433: case $target in
434: *freebsd2*)
435: SHLIB_SO_CFLAGS="-fpic -fPIC"
436: SHLIB_SO_LDFLAGS="-v;ld -Bshareable -o"
437: SHLIB_SO_SUFFIX="so"
438: SHLIB_MAIN_LDFLAGS=""
439: SHLIB_OK=ok
440: ;;
441: *-linux-gnu|*freebsd*|*dragonfly*)
442: SHLIB_SO_CFLAGS="-fPIC"
443: SHLIB_SO_LDFLAGS="$rpath -shared -o"
444: SHLIB_SO_SUFFIX="so"
445: SHLIB_MAIN_LDFLAGS="-rdynamic"
446: SHLIB_OK=ok
447: ;;
448: *netbsd*|*openbsd*)
449: SHLIB_SO_CFLAGS="-fPIC -DPIC"
450: SHLIB_SO_LDFLAGS="$rpath -shared -o"
451: SHLIB_SO_SUFFIX="so"
452: SHLIB_MAIN_LDFLAGS="-rdynamic"
453: SHLIB_OK=ok
454: ;;
455: *darwin*)
456:
457:
458:
459: case $target_os in
460: darwin1.[[012]]) FLAT_NAMESPACE="" ;;
461: *) FLAT_NAMESPACE="-flat_namespace" ;;
462: esac
463: CPPFLAGS="$CPPFLAGS -no-cpp-precomp"
464: SHLIB_SO_CFLAGS="-no-cpp-precomp -fPIC -fno-common"
465: SHLIB_SO_LDFLAGS="-bundle $FLAT_NAMESPACE -undefined suppress -o"
466: SHLIB_SO_SUFFIX="so"
467: if test "$ac_gauche_framework" = yes; then
468: SHLIB_DYLIB_LDFLAGS='-framework CoreFoundation -dynamiclib -o'
469: AC_DEFINE(GAUCHE_MACOSX_FRAMEWORK, 1, [Define 1 if building framework on MacOSX])
470: xtarget="${target}-framework"
471: else
472: SHLIB_DYLIB_LDFLAGS="-dynamiclib -o"
473: fi
474: SHLIB_DYLIB_SUFFIX="dylib"
475: SHLIB_LIBS_FOR_EXT=""
476: SHLIB_MAIN_LDFLAGS=""
477: SHLIB_OK=ok
478: LINK_HELPER='./link-dylib'
479: ext_use_libgauche=no
480: libgauche_version_link=no
481: ;;
482: mips-sgi-irix*)
483: if test "$CC" = gcc; then
484: SHLIB_SO_CFLAGS="-fPIC"
485: else
486: SHLIB_SO_CFLAGS="-KPIC"
487: fi
488: SHLIB_SO_LDFLAGS="$rpath -shared -o"
489: SHLIB_SO_SUFFIX="so"
490: SHLIB_MAIN_LDFLAGS=""
491: SHLIB_OK=ok
492: ;;
493: *solaris*)
494: if test "$CC" = gcc; then
495: SHLIB_SO_CFLAGS="-fPIC"
496: SHLIB_SO_LDFLAGS="-shared -o"
497: else
498: SHLIB_SO_CFLAGS="-Kpic"
499: SHLIB_SO_LDFLAGS="-G -h"
500: fi
501: SHLIB_SO_SUFFIX="so"
502: SHLIB_MAIN_LDFLAGS=""
503: SHLIB_OK=ok
504: ;;
505: *hp*)
506: if test "$CC" = gcc; then
507: SHLIB_SO_CFLAGS="-fPIC"
508: SHLIB_SO_LDFLAGS="-shared -o"
509: else
510: SHLIB_SO_CFLAGS="+z +Z"
511: SHLIB_SO_LDFLAGS=";ld -b -o"
512: fi
513: SHLIB_SO_SUFFIX="sl"
514: SHLIB_MAIN_LDFLAGS=""
515: SHLIB_OK=ok
516: LINK_HELPER='./link-hpux'
517: ;;
518: *cygwin*)
519: SHLIB_SO_CFLAGS=""
520: SHLIB_SO_LDFLAGS='-Wl,--export-all-symbols -Wl,--enable-auto-import -shared -o'
521: SHLIB_SO_SUFFIX="dll"
522: SHLIB_DYLIB_SUFFIX="dll"
523: SHLIB_MAIN_LDFLAGS="-Wl,--enable-auto-import"
524: SHLIB_OK=ok
525: GOSH_USE_SHLIB=yes
526: ext_use_uvector=yes
527: ext_use_libgauche=yes
528: libgauche_version_link=no
529: ;;
530: *mingw*)
531: SHLIB_SO_CFLAGS=""
532: SHLIB_SO_LDFLAGS='-Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc -shared -o'
533: SHLIB_SO_SUFFIX="dll"
534: SHLIB_DYLIB_SUFFIX="dll"
535: SHLIB_MAIN_LDFLAGS="-Wl,--enable-auto-import"
536: SHLIB_OK=ok
537: GOSH_USE_SHLIB=yes
538: ext_use_uvector=yes
539: ext_use_libgauche=yes
540: libgauche_version_link=no
541: ;;
542: *)
543: SHLIB_SO_CFLAGS=""
544: SHLIB_SO_LDFLAGS=""
545: SHLIB_SO_SUFFIX=""
546: SHLIB_MAIN_LDFLAGS=""
547: SHLIB_OK=unknown
548: ;;
549: esac
550: if test -z "$SHLIB_DYLIB_LDFLAGS"