1: dnl Process this file with autoconf to produce a configure script.
2:
3: #Copyright (C) 1995,1996,1997,1998,2000,2003 Free Software Foundation, Inc.
4:
5: #This file is part of Gforth.
6:
7: #Gforth is free software; you can redistribute it and/or
8: #modify it under the terms of the GNU General Public License
9: #as published by the Free Software Foundation; either version 2
10: #of the License, or (at your option) any later version.
11:
12: #This program is distributed in the hope that it will be useful,
13: #but WITHOUT ANY WARRANTY; without even the implied warranty of
14: #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.#See the
15: #GNU General Public License for more details.
16:
17: #You should have received a copy of the GNU General Public License
18: #along with this program; if not, write to the Free Software
19: #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
20:
21:
22: dnl We use some automake macros here,
23: dnl but don't use automake for creating Makefile.in
24: AC_INIT([gforth],[0.6.2],[https://savannah.gnu.org/bugs/?func=addbug&group=gforth])
25: AC_PREREQ(2.54)
26: #snapshots have numbers major.minor.release-YYYYMMDD
27: #note that lexicographic ordering must be heeded.
28: #I.e., 0.4.1-YYYYMMDD must not exist before 0.4.1!
29: UPDATED="August 25, 2003"
30: AC_SUBST(UPDATED)
31: AC_CONFIG_HEADERS(engine/config.h)
32:
33: #suppress the "-g -O2" default
34: test "$CFLAGS" || CFLAGS=-O2
35:
36: #default setting that may be changed later:
37: test "$no_dynamic_default" || no_dynamic_default=0
38:
39: AC_ARG_ENABLE(force-reg,
40: [ --enable-force-reg Use explicit register declarations if they appear in
41: the machine.h file. This can cause a good speedup,
42: but also incorrect code with some gcc versions on
43: some processors (default disabled).],
44: AC_DEFINE(FORCE_REG,,[Define if you want to use explicit register declarations for better performance or for more convenient CODE words (does not work with all GCC versions on all machines)]))
45: AC_SUBST(PROFEXES)
46: AC_SUBST(PROFOBJS)
47: AC_ARG_ENABLE(prof,
48: [ --enable-prof Build gforth-prof, which outputs frequently occuring
49: sequences of primitives.],
50: PROFEXES="gforth-prof\$(EXE)"; PROFOBJS="engine-prof.o main-prof.o profile.o")
51:
52: AC_ARG_WITH(debug,
53: [ --with-debug specifies option -g to compile with debug info
54: --without-debug omits the -g switch and creates smaller images on
55: machines where "strip" has problems with gcc style
56: debugging informations.],
57: if test "$withval" = "yes"; then DEBUGFLAG=-g; fi)
58:
59: dnl PEEPHOLE="yes"
60: dnl AC_ARG_WITH(peephole,
61: dnl [ --with-peephole Enable peephole optimization (default)
62: dnl --without-peephole disables peephole optimization. Creates smaller,
63: dnl but slower images.],
64: dnl PEEPHOLE="$withval")
65:
66: #variables mentioned in INSTALL
67: AC_ARG_VAR(CC, [The C compiler (must support GNU C 2.x); gcc-2.95 recommended.])
68: AC_ARG_VAR(FORTHSIZES, [Gforth command line options for the default stack and dictionary sizes (see INSTALL).])
69: AC_ARG_VAR(ac_cv_sizeof_char_p, [sizeof(char *)])
70: AC_ARG_VAR(ac_cv_sizeof_char, [sizeof(char)])
71: AC_ARG_VAR(ac_cv_sizeof_short, [sizeof(short)])
72: AC_ARG_VAR(ac_cv_sizeof_int, [sizeof(int)])
73: AC_ARG_VAR(ac_cv_sizeof_long, [sizeof(long)])
74: AC_ARG_VAR(ac_cv_sizeof_long_long, [sizeof(long long)])
75: AC_ARG_VAR(ac_cv_sizeof_intptr_t, [sizeof(intptr_t)])
76: AC_ARG_VAR(ac_cv_sizeof_int128_t, [sizeof(int128_t)])
77: AC_ARG_VAR(ac_cv_c_bigendian, [Is the target big-endian ("yes" or "no")?])
78: AC_ARG_VAR(no_dynamic_default, [run gforth with --dynamic (0) or --no-dynamic (1) by default])
79:
80: #set up feature test macros, so the tests get them right:
81: # turn on all POSIX, SUSv3, and GNU features if available
82: AC_GNU_SOURCE
83: dnl AC_DEFINE_UNQUOTED([_GNU_SOURCE],1,[feature test macro])
84:
85: dnl Don't define _POSIX_SOURCE etc. because some OSs (in particular
86: dnl MacOSX) disable some features then (MacOSX checks for _POSIX_SOURCE,
87: dnl but not for _XOPEN_SOURCE)
88: dnl AC_DEFINE_UNQUOTED([_POSIX_SOURCE],1,[feature test macro])
89: dnl AC_DEFINE_UNQUOTED([_POSIX_C_SOURCE],199506L,[feature test macro])
90: dnl AC_DEFINE_UNQUOTED([_XOPEN_SOURCE],600,[feature test macro])
91: # turn on large file support with 64-bit off_t where available
92: AC_SYS_LARGEFILE
93: dnl AC_DEFINE_UNQUOTED([_LARGEFILE_SOURCE],1,[feature test macro])
94: dnl AC_DEFINE_UNQUOTED([_FILE_OFFSET_BITS],64,[feature test macro])
95:
96: #currently we force direct threading this way. Eventually we should
97: #setup in the arch and engine files right
98:
99: AC_PROG_CC
100:
101: test "$GCC" = "yes" || AC_MSG_ERROR(Gforth uses GNU C extensions and requires GCC 2.0 or higher)
102:
103: AC_SUBST(CC)
104: AC_SUBST(DEBUGFLAG)
105:
106: AC_MSG_CHECKING(make type)
107: make_type=`make -v 2>&1|grep 'ake version'|sed 's/ version .*//'`
108:
109: GNUMAKE='#'
110: test "$make_type" = "GNU Make" && GNUMAKE=''
111:
112: AC_MSG_RESULT($make_type)
113:
114: AC_SUBST(GNUMAKE)
115:
116: dnl gcc-3.2 seems to work fine now
117: dnl AC_MSG_CHECKING(gcc version)
118: dnl gcc_version=`$CC -v 2>&1|grep 'gcc version'|sed 's/.*gcc version //'`
119: dnl AC_MSG_RESULT($gcc_version)
120: dnl if expr "$gcc_version" \> 3.0.4 >/dev/null && expr "$gcc_version" \< 3.2.1 >/dev/null
121: dnl then
122: dnl no_dynamic_default=1
123: dnl AC_MSG_WARN(Disabling dynamic native code generation by default (speed penalty factor ~2))
124: dnl fi
125:
126: AC_MSG_CHECKING([whether the linker accepts -export-dynamic])
127: OLDLDFLAGS=$LDFLAGS
128: LDFLAGS="$LDFLAGS -export-dynamic"
129: dnl AC_TRY_LINK gives false positive on rs6000-ibm-aix4.2.1.0
130: dnl AC_TRY_LINK(,,ac_export_dynamic=yes,ac_export_dynamic=no)
131: AC_TRY_RUN(main(){exit(0);},ac_export_dynamic=yes,ac_export_dynamic=no,ac_export_dynamic=no)
132: test $ac_export_dynamic = yes|| LDFLAGS=$OLDLDFLAGS
133: AC_MSG_RESULT($ac_export_dynamic)
134:
135: #terminology is a bit unusual here: The host is the system on which
136: #gforth will run; the system on which configure will run is the `build'
137: AC_CANONICAL_HOST
138: case "$host_cpu" in
139: hppa*)
140: machine=hppa
141: $srcdir/mkinstalldirs arch/hppa
142: AC_LIBOBJ(../arch/hppa/cache)
143: #-N needed for --dynamic <M4U3b.3790$9d.317@news.cpqcorp.net>
144: LDFLAGS="$LDFLAGS -Xlinker -N"
145: LIBS="$LIBS -L/lib/pa1.1/"
146: ;;
147: sparc*)
148: machine=sparc
149: ;;
150: i386)
151: machine=386
152: CFLAGS="$CFLAGS -fomit-frame-pointer -fforce-addr -fforce-mem"
153: ;;
154: i486)
155: machine=386
156: CFLAGS="$CFLAGS -fomit-frame-pointer -fforce-addr -fforce-mem -m486"
157: ;;
158: i*86)
159: machine=386
160: CFLAGS="$CFLAGS -fomit-frame-pointer -fforce-addr -fforce-mem"
161: CFLAGS_1="$CFLAGS"
162: CFLAGS="$CFLAGS -march=pentium"
163: AC_TRY_COMPILE(,,,CFLAGS="$CFLAGS_1 -m486")
164: ;;
165: x86_64)
166: machine=amd64
167: ;;
168: #generic should work for IA64
169: # ia64*)
170: # machine=ia64
171: # ;;
172: m68k)
173: machine=m68k
174: CFLAGS="$CFLAGS -fomit-frame-pointer"
175: if test "$host_os" = "nextstep3"
176: then
177: AC_LIBOBJ(termios)
178: fi
179: ;;
180: mips*)
181: machine=mips
182: #dynamic native code has the following problems on MIPS:
183: #
184: #1) J/JAL seems relocatable, but is are only
185: #relocatable within a 256MB-segment. While we try to
186: #get the linker to arrange this, there is no guarantee
187: #that this will succeed (and if the user uses a lot of
188: #memory, it is likely to fail).
189: #
190: #2) The way we generate dynamic native code may
191: #violate MIPS architectural restrictions (in
192: #particular, the delay slots of LW, MFLO, etc.)
193: #
194: #Therefore we disable dynamic native code by default:
195: no_dynamic_default=1
196: AC_MSG_WARN(Disabling dynamic native code generation by default (speed penalty factor ~2))
197: ;;
198: alpha*)
199: machine=alpha
200: #full IEEE FP support for more uniformity across platforms:
201: CFLAGS="$CFLAGS -mieee"
202: ;;
203: power*|rs6000)
204: machine=power
205: $srcdir/mkinstalldirs arch/power
206: AC_CHECK_FUNC(_sync_cache_range,true,AC_LIBOBJ(../arch/power/_sync_cache_range))
207: #long long is broken on (at least) gcc-2.95.* for PPC
208: test x$ac_cv_sizeof_long_long = x && ac_cv_sizeof_long_long=0
209: ;;
210: *)
211: AC_MSG_WARN([Using a generic machine description])
212: AC_MSG_WARN([Assuming C floats and doubles are IEEE floats and doubles (for SF@ DF@ SF! DF!)])
213: AC_MSG_WARN([FLUSH-ICACHE will do nothing, so END-CODE may not work properly!])
214: machine=generic
215: #I-cache flushing would be needed for dynamic code generation
216: no_dynamic_default=1
217: AC_MSG_WARN(Disabling dynamic native code generation by default (speed penalty factor ~2))
218: esac
219: AC_SUBST(host)
220:
221: dnl the following macro produces a warning with autoconf-2.1
222: AC_CHECK_SIZEOF(char *)
223: case "$ac_cv_sizeof_char_p" in
224: 2)
225: wordsize=16
226: ;;
227: 4)
228: wordsize=32
229: ;;
230: 8)
231: wordsize=64
232: ;;
233: esac
234:
235: AC_CHECK_SIZEOF(char)
236: AC_CHECK_SIZEOF(short)
237: AC_CHECK_SIZEOF(int)
238: AC_CHECK_SIZEOF(long)
239: AC_CHECK_SIZEOF(long long)
240: AC_CHECK_SIZEOF(intptr_t)
241: AC_CHECK_SIZEOF(int128_t)
242:
243: AC_MSG_CHECKING([for a C type for cells])
244: ac_cv_int_type_cell=none
245: case "$ac_cv_sizeof_char_p" in
246: $ac_cv_sizeof_int)
247: ac_cv_int_type_cell=int
248: ;;
249: $ac_cv_sizeof_short)
250: ac_cv_int_type_cell=short
251: ;;
252: $ac_cv_sizeof_char)
253: ac_cv_int_type_cell=char
254: ;;
255: $ac_cv_sizeof_long)
256: ac_cv_int_type_cell=long
257: ;;
258: $ac_cv_sizeof_long_long)
259: ac_cv_int_type_cell="long long"
260: ;;
261: $ac_cv_sizeof_intptr_t)
262: ac_cv_int_type_cell="intptr_t"
263: ;;
264: $ac_cv_sizeof_int128_t)
265: ac_cv_int_type_cell="int128_t"
266: ;;
267: esac
268: AC_MSG_RESULT($ac_cv_int_type_cell)
269: AC_DEFINE_UNQUOTED(CELL_TYPE,$ac_cv_int_type_cell,[an integer type that is as long as a pointer])
270:
271: AC_MSG_CHECKING([for a C type for double-cells])
272: ac_cv_int_type_double_cell=none
273: case `expr 2 '*' "$ac_cv_sizeof_char_p"` in
274: $ac_cv_sizeof_short)
275: ac_cv_int_type_double_cell=short
276: ;;
277: $ac_cv_sizeof_int)
278: ac_cv_int_type_double_cell=int
279: ;;
280: $ac_cv_sizeof_long)
281: ac_cv_int_type_double_cell=long
282: ;;
283: $ac_cv_sizeof_long_long)
284: ac_cv_int_type_double_cell="long long"
285: ;;
286: $ac_cv_sizeof_intptr_t)
287: ac_cv_int_type_double_cell="intptr_t"
288: ;;
289: $ac_cv_sizeof_int128_t)
290: ac_cv_int_type_double_cell="int128_t"
291: ;;
292: esac
293: AC_MSG_RESULT($ac_cv_int_type_double_cell)
294: if test "$ac_cv_int_type_double_cell" = none; then
295: AC_MSG_WARN([Emulating double-cell arithmetic. This may be slow.])
296: AC_LIBOBJ(dblsub)
297: AC_DEFINE(BUGGY_LONG_LONG,,[define this if there is no working DOUBLE_CELL_TYPE on your machine])
298: else
299: AC_DEFINE_UNQUOTED(DOUBLE_CELL_TYPE,$ac_cv_int_type_double_cell,[an integer type that is twice as long as a pointer])
300: fi
301:
302: AC_TYPE_OFF_T
303: AC_CHECK_SIZEOF(off_t)
304: test $ac_cv_sizeof_off_t -gt $ac_cv_sizeof_char_p
305: ac_small_off_t=$?
306: AC_DEFINE_UNQUOTED(SMALL_OFF_T,$ac_small_off_t,[1 if off_t fits in a Cell])
307:
308: ENGINE_FLAGS=
309: AC_SUBST(ENGINE_FLAGS)
310:
311: # Try if GCC understands -fno-gcse
312:
313: AC_MSG_CHECKING([if $CC understands -fno-gcse])
314: CFLAGS_1="$CFLAGS"
315: CFLAGS="$CFLAGS -fno-gcse"
316: AC_TRY_COMPILE(,,ac_nogcse=yes;ENGINE_FLAGS="$ENGINE_FLAGS -fno-gcse",ac_nogcse=no)
317: CFLAGS="$CFLAGS_1"
318: AC_MSG_RESULT($ac_nogcse)
319:
320: # Try if GCC understands -fno-strict-aliasing
321: AC_MSG_CHECKING([if $CC understands -fno-strict-aliasing])
322: CFLAGS_1="$CFLAGS"
323: CFLAGS="$CFLAGS -fno-strict-aliasing"
324: AC_TRY_COMPILE(,,ac_nostrictaliasing=yes;ENGINE_FLAGS="$ENGINE_FLAGS -fno-strict-aliasing",ac_nostrictaliasing=no)
325: CFLAGS="$CFLAGS_1"
326: AC_MSG_RESULT($ac_nostrictaliasing)
327:
328: # Try if GCC understands -fno-crossjumping
329: AC_MSG_CHECKING([if $CC understands -fno-crossjumping])
330: CFLAGS_1="$CFLAGS"
331: CFLAGS="$CFLAGS -fno-crossjumping"
332: AC_TRY_COMPILE(,,ac_nocrossjumping=yes;ENGINE_FLAGS="$ENGINE_FLAGS -fno-crossjumping",ac_nocrossjumping=no)
333: CFLAGS="$CFLAGS_1"
334: AC_MSG_RESULT($ac_nocrossjumping)
335:
336: # Try if GCC understands __attribute__((unused))
337: AC_MSG_CHECKING([how to suppress 'unused variable' warnings])
338: AC_TRY_COMPILE(,[int __attribute__((unused)) foo;], MAYBE_UNUSED='__attribute__((unused))',)
339: AC_DEFINE_UNQUOTED(MAYBE_UNUSED,$MAYBE_UNUSED,[attribute for possibly unused variables])
340: AC_MSG_RESULT($MAYBE_UNUSED)
341:
342: AC_CHECK_PROG(asm_fs,asm.fs,arch/$machine/asm.fs,,$srcdir/arch/$machine)
343: AC_SUBST(asm_fs)
344:
345: AC_CHECK_PROG(disasm_fs,disasm.fs,arch/$machine/disasm.fs,,$srcdir/arch/$machine)
346: AC_SUBST(disasm_fs)
347:
348: AC_PATH_PROG(INSTALL_INFO,install-info,[echo '>>>>Please make info dir entry:'],$PATH:/sbin:/usr/sbin:/usr/local/sbin)
349:
350: case "$host_os" in
351: *win32|cygwin)
352: DIRSEP="\\\\"
353: PATHSEP=";"
354: ;;
355: *darwin*)
356: #Darwin uses some funny preprocessor by default; eliminate it:
357: AC_MSG_NOTICE([using -no-cpp-precomp on Darwin])
358: CFLAGS="$CFLAGS -no-cpp-precomp"
359: DIRSEP="/"
360: PATHSEP=":"
361: ;;
362: *)
363: DIRSEP="/"
364: PATHSEP=":"
365: ;;
366: esac
367: AC_SUBST(DIRSEP)
368: AC_DEFINE_UNQUOTED(DIRSEP,'$DIRSEP',[a directory separator character])
369: AC_SUBST(PATHSEP)
370: AC_DEFINE_UNQUOTED(PATHSEP,'$PATHSEP',[a path separator character])
371:
372:
373: dnl Now a little support for DOS/DJGCC
374: AC_SUBST(GFORTH_EXE)
375: GFORTH_EXE=""
376: AC_SUBST(GFORTHFAST_EXE)
377: GFORTHFAST_EXE=""
378: AC_SUBST(GFORTHITC_EXE)
379: GFORTHITC_EXE=""
380: AC_SUBST(GFORTHDITC_EXE)
381: GFORTHDITC_EXE=""
382:
383: AC_SUBST(FORTHSIZES)
384:
385: dnl if test "$PEEPHOLE" = "yes"
386: dnl then
387: dnl PEEPHOLEFLAG="true"
388: dnl AC_DEFINE(HAS_PEEPHOLE,,[Define if you want to use peephole optimization])
389: dnl else
390: dnl PEEPHOLEFLAG="false"
391: dnl fi
392: PEEPHOLEFLAG="true"
393: AC_SUBST(PEEPHOLEFLAG)
394:
395: dnl copy commands for systems that don't have links
396: AC_SUBST(LINK_KERNL)
397: LINK_KERNL=""
398:
399: #if test $host_os=dos
400: #then
401: # echo Configuring for DOS!!!
402: # MAKE_EXE="coff2exe gforth"
403: # LINK_KERNL='$(CP) kernl32l.fi kernel.fi'
404: #fi
405:
406: dnl the following macro produces a warning with autoconf-2.1
407: AC_C_BIGENDIAN
408: AC_SUBST(KERNEL)
409: dnl ac_cv_c_bigendian is an undocumented variable of autoconf-2.1
410: if test $ac_cv_c_bigendian = yes; then
411: bytesex=b
412: KERNEL="kernl16b.fi kernl16l.fi kernl32b.fi kernl32l.fi kernl64b.fi kernl64l.fi"
413: else
414: bytesex=l
415: KERNEL="kernl16l.fi kernl16b.fi kernl32l.fi kernl32b.fi kernl64l.fi kernl64b.fi"
416: fi
417:
418: #check how to do asm(".skip 16")
419: AC_MSG_CHECKING([if and how we can waste code space])
420: skipcode=no
421: for i in ".skip 16" ".block 16" ".org .+16" ".=.+16" ".space 16"
422: do
423: AC_TRY_RUN(
424: int foo(int);
425: main()
426: {
427: exit(foo(0)!=16);
428: }
429: int foo(int x)
430: {
431: if (x) {
432: label1:
433: asm("$i");
434: label2:
435: }
436: return (&&label2)-(&&label1);
437: }
438: ,skipcode=$i; break
439: ,,)
440: done
441: AC_MSG_RESULT($skipcode)
442: if test "$skipcode" = no
443: then
444: no_dynamic_default=1
445: AC_DEFINE_UNQUOTED(SKIP16,((void)0),statement for skipping 16 bytes)
446: AC_MSG_WARN(Disabling dynamic native code generation by default (speed penalty factor ~2))
447: else
448: AC_DEFINE_UNQUOTED(SKIP16,asm("$skipcode"),statement for skipping 16 bytes)
449: fi
450:
451: AC_DEFINE_UNQUOTED(NO_DYNAMIC_DEFAULT,$no_dynamic_default,default value for no_dynamic)
452:
453: dnl Checks for programs.
454: AC_PROG_LN_S
455: AC_PROG_INSTALL
456:
457: dnl Checks for library functions
458: dnl This check is just for making later checks link with libm.
459: dnl using sin here is no good idea since it is built-into gcc and typechecked
460: AC_CHECK_LIB(m,asin)
461: AC_CHECK_LIB(dl,dlopen)
462: dnl check for ffcall libraries
463: dnl unfortunately, these four calls are separated out into a library each.
464: AC_CHECK_LIB(avcall,__builtin_avcall)
465: AC_CHECK_LIB(callback,__vacall_r)
466: AC_CHECK_LIB(vacall,vacall)
467: AC_CHECK_LIB(trampoline,alloc_trampoline)
468: FFCALLFLAG="false"
469: OLDCALLFLAG="true"
470: test $ac_cv_lib_avcall___builtin_avcall = yes && FFCALLFLAG="true" && OLDCALLFLAG="false" && AC_DEFINE(HAS_FFCALL,,[define this if you want to use the ffcall libraries])
471: test $ac_cv_lib_avcall___builtin_avcall = no && AC_DEFINE(HAS_OLDCALL,,[define this if you want to use the old call libraries])
472: AC_SUBST(FFCALLFLAG)
473: AC_SUBST(OLDCALLFLAG)
474: if test "$host_os" != "nextstep3"
475: then
476: AC_FUNC_MEMCMP
477: fi
478: AC_REPLACE_FUNCS(memmove strtoul pow10 strerror strsignal atanh)
479: AC_FUNC_FSEEKO
480: AC_CHECK_FUNCS(ftello dlopen sys_siglist getrusage)
481: AC_CHECK_TYPES(stack_t,,,[#include <signal.h>])
482: AC_DECL_SYS_SIGLIST
483: AC_CHECK_FUNC(getopt_long,true,AC_LIBOBJ(getopt); AC_LIBOBJ(getopt1))
484: AC_CHECK_FUNCS(expm1 log1p)
485: AC_REPLACE_FUNCS(rint ecvt)
486: dnl No check for select, because our replacement is no good under
487: dnl anything but DOS
488: AC_CHECK_HEADERS(sys/mman.h fnmatch.h)
489: AC_FUNC_FNMATCH
490: test $ac_cv_func_fnmatch_works = yes || AC_LIBOBJ(fnmatch)
491: AC_CHECK_FUNCS(mmap sysconf getpagesize)
492: AM_PATH_LISPDIR
493:
494: kernel_fi=kernl${wordsize}${bytesex}.fi
495: AC_SUBST(kernel_fi)
496:
497: #this breaks bindists
498: #dnl replace srource directory by absolute value
499: #if test $srcdir = "."; then srcdir=`pwd`
500: #fi
501:
502: AC_SUBST(machine)
503: AC_CONFIG_FILES([
504: Makefile
505: Makedist
506: gforthmi
507: vmgen
508: machpc.fs
509: engine/Makefile
510: doc/version.texi ])
511: AC_CONFIG_COMMANDS([stamp-h],[[echo timestamp > stamp-h
512: chmod +x gforthmi
513: chmod +x vmgen
514: test -d kernel||mkdir kernel]],[[]])
515: AC_OUTPUT
516:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>