~ubuntu-branches/debian/sid/gcl/sid

« back to all changes in this revision

Viewing changes to .pc/2.6.10pre-test-15/configure.in

  • Committer: Package Import Robot
  • Author(s): Camm Maguire
  • Date: 2013-11-02 22:21:16 UTC
  • Revision ID: package-import@ubuntu.com-20131102222116-il6bkpeplfns2xea
Tags: 2.6.9-15
2.6.10preĀ testĀ 15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
AC_INIT()
 
2
AC_PREREQ([2.61])
 
3
AC_CONFIG_HEADER(h/gclincl.h)
 
4
 
 
5
VERSION=`cat majvers`.`cat minvers`
 
6
AC_SUBST(VERSION)
 
7
 
 
8
# some parts of this configure script are taken from the tcl configure.in
 
9
 
 
10
#
 
11
# Arguments
 
12
#
 
13
 
 
14
dnl help="--enable-maxpage=XXXX will compile in a page table of size XXX (default ${default_maxpage})"
 
15
 
 
16
dnl AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
17
dnl         #include <stdio.h>
 
18
dnl             #include <unistd.h>
 
19
dnl         ]],[[
 
20
dnl         FILE *fp=fopen("conftest1","w");
 
21
dnl         fprintf(fp,"%u",262144*( SIZEOF_LONG >>2)/(1<<($PAGEWIDTH-12)));
 
22
dnl         return 0;]])],[def_maxpage=`cat conftest1`],[def_maxpage=262144])
 
23
 
 
24
dnl AC_ARG_ENABLE(maxpage,
 
25
dnl [ --enable-maxpage=XXXX  will compile in a page table of size XXX
 
26
dnl                          (eg '--enable-maxpage=64*1024' would produce
 
27
dnl                      64K pages allowing 256 MB if pages are 4K each)],
 
28
dnl ,enable_maxpage=$def_maxpage)
 
29
 
 
30
AC_ARG_ENABLE(widecons,[use a three word cons with simplified typing],[AC_DEFINE([WIDE_CONS],[1],[three word cons])])
 
31
 
 
32
 
 
33
AC_ARG_ENABLE(safecdr,[protect cdr from immfix and speed up type processing],,[enable_safecdr="no"])
 
34
if test "$enable_safecdr" = "yes" ; then
 
35
   AC_DEFINE([USE_SAFE_CDR],[1],[protect cdr from immfix and speed up type processing])
 
36
fi
 
37
AC_ARG_ENABLE(safecdrdbg,[debug safecdr code],[AC_DEFINE([DEBUG_SAFE_CDR],[1],[debug safecdr code])])
 
38
 
 
39
AC_ARG_ENABLE([fastimmfix],[--enable-fastimmfix=XXXX will reject low immediate fixnums unless 1<<XXXX can be attained],
 
40
,[enable_fastimmfix=64])
 
41
 
 
42
 
 
43
AC_ARG_ENABLE(holepage,[ --enable-holepage=XXXX will compile in a XXX-sized hole between the heap and relocatable memory area (eg '--enable-holepage=64*1024' would give 64K pages allowing 256 MB if pages are 4K each)] ,
 
44
[AC_DEFINE_UNQUOTED(HOLEPAGE,$enable_holepage,[number of pages to use for hole])])
 
45
 
 
46
AC_ARG_ENABLE(vssize,[ --enable-vssize=XXXX will compile in a value stack of size XXX] ,
 
47
,enable_vssize=262144)
 
48
AC_DEFINE_UNQUOTED(VSSIZE,$enable_vssize,[value stack size])
 
49
 
 
50
AC_ARG_ENABLE(bdssize,[ --enable-bdssize=XXXX will compile in a binding stack of size XXX] ,
 
51
,enable_bdssize=2048)
 
52
AC_DEFINE_UNQUOTED(BDSSIZE,$enable_bdssize,[binding stack size])
 
53
 
 
54
AC_ARG_ENABLE(ihssize,[ --enable-ihssize=XXXX will compile in a invocation history stack of size XXX] ,
 
55
,enable_ihssize=4096)
 
56
AC_DEFINE_UNQUOTED(IHSSIZE,$enable_ihssize,[invocation history stack size])
 
57
 
 
58
AC_ARG_ENABLE(frssize,[ --enable-frssize=XXXX will compile in a frame stack of size XXX] ,
 
59
,enable_frssize=4096)
 
60
AC_DEFINE_UNQUOTED(FRSSIZE,$enable_frssize,[frame stack size])
 
61
 
 
62
AC_ARG_ENABLE(machine,[ --enable-machine=XXXX will force the use of one of the definitions in h/XXXX.defs] ,
 
63
[enable_machine=$enableval],[enable_machine=""])
 
64
 
 
65
AC_ARG_ENABLE(immfix,
 
66
[ --enable-immfix        will enable an immediate fixnum table
 
67
                         above the C stack],
 
68
,enable_immfix=yes)
 
69
 
 
70
#AC_ARG_ENABLE(gmp,[ --enable-gmp=no will disable use of GMP gnu multiprecision arithmetic, (default is =yes)] ,
 
71
#[use_gmp=$enableval],[use_gmp="yes"])
 
72
 
 
73
use_gmp="yes"
 
74
 
 
75
AC_ARG_ENABLE(notify,[ --enable-notify=no will disable the automatic notification of gcl maintainers of successful builds/problems] ,
 
76
[enable_notify=$enableval],[enable_notify="yes"])
 
77
 
 
78
AC_ARG_ENABLE(tcltk,[ try to build gcl-tk ] ,
 
79
[enable_tcltk=$enableval],[enable_tcltk="yes"])
 
80
 
 
81
AC_ARG_ENABLE(tkconfig,[ --enable-tkconfig=XXXX will force the use of a TK_CONFIG_PREFIX=XXXXX as place to look for tkConfig.sh and tclConfig.sh ] ,
 
82
[TK_CONFIG_PREFIX=$enableval],[TK_CONFIG_PREFIX="unknown"])
 
83
 
 
84
 
 
85
AC_ARG_ENABLE(tclconfig,[ --enable-tclconfig=XXXX will force the use of a TCL_CONFIG_PREFIX=XXXXX as place to look for tclConfig.sh and tclConfig.sh ] ,
 
86
[TCL_CONFIG_PREFIX=$enableval],[TCL_CONFIG_PREFIX="unknown"])
 
87
 
 
88
AC_ARG_ENABLE(infodir,[ --enable-infodir=XXXX will force the use of a INFO_DIR=XXXXX as place to look for info ] ,
 
89
[INFO_DIR=$enableval],[INFO_DIR=$prefix/share/info])
 
90
INFO_DIR=`eval echo $INFO_DIR/`
 
91
 
 
92
AC_ARG_ENABLE(emacsdir,[ --enable-emacsdir=XXXX will manually specify the location for elisp files ] ,
 
93
[EMACS_SITE_LISP=$enableval],[EMACS_SITE_LISP=$prefix/share/emacs/site-lisp])
 
94
EMACS_SITE_LISP=`eval echo $EMACS_SITE_LISP/`
 
95
 
 
96
AC_ARG_ENABLE(common-binary,[ --enable-common-binary=yes forces use of lowest common denominator instruction sets, (default is =yes)] ,
 
97
[use_common_binary=$enableval],[use_common_binary="yes"])
 
98
 
 
99
AC_ARG_ENABLE(japi,[ --enable-japi=yes will compile in support for the JAPI graphical interface if present on your system],
 
100
[try_japi=$enableval],[try_japi="no"])
 
101
 
 
102
AC_ARG_ENABLE(xdr,[ --enable-xdr=yes will compile in support for XDR],
 
103
[enable_xdr=$enableval],[enable_xdr="yes"])
 
104
 
 
105
AC_ARG_ENABLE(xgcl,[ --enable-xgcl=yes will compile in support for XGCL],
 
106
[enable_xgcl=$enableval],[enable_xgcl="yes"])
 
107
 
 
108
#
 
109
# Host information 
 
110
#
 
111
 
 
112
 
 
113
AC_CANONICAL_HOST
 
114
canonical=$host
 
115
my_host_kernel=`echo $host_os | awk '{j=split($1,A,"-");print A[[1]]}'`
 
116
my_host_system=`echo $host_os | awk '{j=split($1,A,"-");if (j>=2) print A[[2]]}'`
 
117
AC_DEFINE_UNQUOTED(HOST_CPU,"`echo $host_cpu | awk '{print toupper($0)}'`",[Host cpu])
 
118
AC_DEFINE_UNQUOTED(HOST_KERNEL,"`echo $my_host_kernel | awk '{print toupper($0)}'`",[Host kernel])
 
119
if test "$my_host_system" != "" ; then 
 
120
        AC_DEFINE_UNQUOTED(HOST_SYSTEM,"`echo $my_host_system | awk '{print toupper($0)}'`",[Host system])
 
121
fi
 
122
## host=CPU-COMPANY-SYSTEM
 
123
AC_MSG_RESULT(host=$host)
 
124
 
 
125
PROCESSOR_FLAGS=${PROCESSOR_FLAGS:-""}
 
126
 
 
127
use=unknown
 
128
TLDFLAGS=""
 
129
case $canonical in
 
130
     older)
 
131
     use=386-bsd;;
 
132
 
 
133
     sh4*linux*)
 
134
        use=sh4-linux;;
 
135
 
 
136
     *x86_64*linux*)
 
137
        use=amd64-linux;;
 
138
 
 
139
     *x86_64*kfreebsd*)
 
140
        use=amd64-kfreebsd;;
 
141
 
 
142
     *86*linux*)
 
143
        use=386-linux;;
 
144
 
 
145
     *86*kfreebsd*)
 
146
        use=386-kfreebsd;;
 
147
 
 
148
     *86*gnu*)
 
149
        use=386-gnu;;
 
150
 
 
151
# m6800 not working with gcc-3.2
 
152
     m68k*linux*)
 
153
       if test "$use_common_binary" = "yes"; then
 
154
         host=m68020-unknown-linux-gnu
 
155
         echo "The host is canonicalised to $host"
 
156
       fi
 
157
        use=m68k-linux;;
 
158
 
 
159
     alpha*linux*)
 
160
        use=alpha-linux;;
 
161
 
 
162
     mips*linux*)
 
163
        use=mips-linux;;
 
164
 
 
165
     mipsel*linux*)
 
166
        use=mipsel-linux;;
 
167
 
 
168
     sparc*linux*)
 
169
        use=sparc-linux;;
 
170
 
 
171
     arm*linux*)
 
172
        use=arm-linux;;
 
173
 
 
174
     s390*linux*)
 
175
        use=s390-linux;;
 
176
 
 
177
     ia64*linux*)
 
178
        use=ia64-linux;;
 
179
 
 
180
     hppa*linux*)
 
181
        use=hppa-linux;;
 
182
 
 
183
     powerpc*linux*)
 
184
        use=powerpc-linux;;
 
185
 
 
186
     powerpc-*-darwin*)
 
187
        use=powerpc-macosx;;
 
188
     
 
189
     *86*darwin*)
 
190
        use=386-macosx
 
191
        if test "$build_cpu" = "x86_64" ; then 
 
192
           CFLAGS="-m64 $CFLAGS";
 
193
           LDFLAGS="-m64 -Wl,-headerpad,72 $LDFLAGS"; 
 
194
        else 
 
195
           CFLAGS="-m32 $CFLAGS";
 
196
           LDFLAGS="-m32  -Wl,-headerpad,56 $LDFLAGS"; 
 
197
        fi;;
 
198
     
 
199
     alpha-dec-osf)
 
200
     use=alpha-osf1;;
 
201
 
 
202
     mips-dec-ultrix)
 
203
     use=dec3100;;
 
204
 
 
205
     old)
 
206
     use=dos-go32;;
 
207
 
 
208
     *86*-freebsd*)
 
209
     use=FreeBSD;;
 
210
 
 
211
     hp3*-*hpux*)
 
212
     use=hp300;;
 
213
 
 
214
     hp3*-*-*bsd*)
 
215
     use=hp300-bsd;;
 
216
 
 
217
     hppa*-*hpux*)
 
218
     use=hp800;;
 
219
 
 
220
     mips-sgi-irix)
 
221
       case $system in
 
222
           IRIX5*)
 
223
            use=irix5;;
 
224
           IRIX6*)
 
225
            use=irix6;;
 
226
           IRIX3*)
 
227
            use=sgi4d;;
 
228
       esac ;;
 
229
 
 
230
 
 
231
     m68k-apple-aux*)
 
232
     use=mac2;;
 
233
 
 
234
     old)
 
235
     use=mp386;;
 
236
 
 
237
     *86-ncr-sysv4)
 
238
     use=ncr;;
 
239
 
 
240
     *[3-9]86-*netbsd*)
 
241
     use=NetBSD;;
 
242
 
 
243
     old)
 
244
     use=NeXT;;
 
245
 
 
246
     old)
 
247
     use=NeXT30-m68k;;
 
248
 
 
249
     *86-*nextstep*)
 
250
     use=NeXT32-i386;;
 
251
 
 
252
     *m68*-*nextstep*)
 
253
     use=NeXT32-m68k;;
 
254
 
 
255
     *rs6000-*-aix4*)
 
256
     use=rios;;
 
257
 
 
258
     *rs6000-*-aix3*)
 
259
     use=rios-aix3;;
 
260
 
 
261
     old)
 
262
     use=rt_aix;;
 
263
 
 
264
     old)
 
265
     use=sgi;;
 
266
 
 
267
     sparc-sun-solaris*)
 
268
     use=solaris;;
 
269
 
 
270
     i?86-pc-solaris*)
 
271
     use=solaris-i386;;
 
272
 
 
273
     old)
 
274
     use=sun2r3;;
 
275
 
 
276
     old)
 
277
     use=sun3;;
 
278
 
 
279
     m68*-sunos*)
 
280
     use=sun3-os4;;
 
281
 
 
282
     old)
 
283
     use=sun386i;;
 
284
 
 
285
     sparc*sunos*)
 
286
     use=sun4;;
 
287
 
 
288
     *86-sequent-dynix)
 
289
     use=symmetry;;
 
290
 
 
291
     u370*aix)
 
292
     use=u370_aix;;
 
293
 
 
294
     old)
 
295
     use=vax;;
 
296
 
 
297
     i*mingw*)
 
298
       if test "$use_common_binary" = "yes"; then
 
299
         host=i386-pc-mingw32
 
300
         PROCESSOR_FLAGS="-march=i386 "
 
301
         echo "The host is canonicalised to $host"
 
302
       fi
 
303
     use=mingw;;
 
304
 
 
305
     i*cygwin*)
 
306
        if $CC -v 2>&1 | fgrep ming > /dev/null ;
 
307
            then use=mingw
 
308
          else  use=gnuwin95
 
309
        fi;;
 
310
 
 
311
     *openbsd*)
 
312
        # 'ld -Z' means disable W^X
 
313
        TLDFLAGS="$TLDFLAGS -Z"
 
314
        use=FreeBSD;;
 
315
  
 
316
esac
 
317
 
 
318
AC_SUBST(PROCESSOR_FLAGS)
 
319
 
 
320
echo enable_machine=$enable_machine
 
321
if test "x$enable_machine" != "x" ; then
 
322
  use=$enable_machine
 
323
fi
 
324
 
 
325
def_dlopen="no"
 
326
def_statsysbfd="no"
 
327
def_custreloc="yes"
 
328
#def_statsysbfd="yes"
 
329
#def_custreloc="no"
 
330
def_locbfd="no"
 
331
def_oldgmp="no"
 
332
def_pic="no";
 
333
def_static="no";
 
334
def_debug="no";
 
335
case $use in 
 
336
     *kfreebsd)
 
337
        ln -snf linux.defs h/$use.defs;;
 
338
     *gnu)
 
339
        ln -snf linux.defs h/$use.defs;;
 
340
     *linux)
 
341
        ln -snf linux.defs h/$use.defs;
 
342
        case $use in
 
343
# def_static -- Function descriptors are currently realized at runtime in a non-reproducible fashion
 
344
# on these architectures -- CM                  
 
345
                powerpc*)
 
346
                        if test "$host_cpu" = "powerpc64" ; then def_dlopen="yes" ; def_custreloc="no" ; fi
 
347
                        ;;
 
348
                ia64*)
 
349
                        def_dlopen="yes" ; def_custreloc="no" ;;
 
350
                hppa*)
 
351
                        def_pic="yes" ;;
 
352
#                       def_dlopen="yes" ; def_custreloc="no" ; def_pic="yes" ;;
 
353
        esac;;
 
354
esac
 
355
 
 
356
AC_ARG_ENABLE(dlopen,
 
357
        [ --enable-dlopen uses dlopen for loading objects, which can then not be retained  in saved images ]
 
358
        ,,enable_dlopen="$def_dlopen")
 
359
AC_ARG_ENABLE(statsysbfd,
 
360
        [ --enable-statsysbfd uses a static sytem bfd library for loading and relocationing object files ]
 
361
        ,,enable_statsysbfd="$def_statsysbfd")
 
362
AC_ARG_ENABLE(dynsysbfd,
 
363
        [ --enable-dynsysbfd uses a dynamic shared sytem bfd library for loading and relocationing object files ]
 
364
        ,,enable_dynsysbfd="no")
 
365
#AC_ARG_ENABLE(locbfd,
 
366
#       [ --enable-locbfd uses a static bfd library built from this source tree for loading and relocationing object files ]
 
367
#       ,,enable_locbfd="$def_locbfd")
 
368
AC_ARG_ENABLE(custreloc,
 
369
        [ --enable-custreloc uses custom gcl code if available for loading  and relocationing object files ]
 
370
        ,,enable_custreloc="$def_custreloc")
 
371
AC_ARG_ENABLE(debug,
 
372
        [ --enable-debug builds gcl with -g in CFLAGS to enable running under gdb ]
 
373
        ,,enable_debug="$def_debug")
 
374
AC_ARG_ENABLE(gprof,
 
375
        [ --enable-gprof builds gcl with -pg in CFLAGS to enable profiling with gprof ]
 
376
        ,,enable_gprof="no")
 
377
AC_ARG_ENABLE(static,[ --enable-static will link your GCL against static as opposed to shared system libraries ] ,
 
378
        [enable_static=$enableval],[enable_static="$def_static"])
 
379
AC_ARG_ENABLE(pic,
 
380
        [ --enable-pic builds gcl with -fPIC in CFLAGS ]
 
381
        ,,enable_pic="$def_pic")
 
382
 
 
383
AC_ARG_ENABLE(oldgmp,
 
384
        [ --enable-oldgmp will link against gmp2 instead of gmp3 ]
 
385
        ,,enable_oldgmp="$def_oldgmp")
 
386
 
 
387
AC_ARG_ENABLE(dynsysgmp,
 
388
        [ --enable-dynsysgmp will link against the system libgmp3 overriding certain functions with patched versions from the local source ]
 
389
        ,,enable_dynsysgmp="yes")
 
390
 
 
391
load_opt="0"
 
392
if test "$enable_dlopen" = "yes" ; then
 
393
   load_opt=1
 
394
fi
 
395
if test "$enable_statsysbfd" = "yes" ; then
 
396
   case $load_opt in
 
397
   0) load_opt=1;;
 
398
   1) load_opt=2;;
 
399
   esac
 
400
fi
 
401
if test "$enable_dynsysbfd" = "yes" ; then
 
402
   case $load_opt in
 
403
   0) load_opt=1;;
 
404
   1) load_opt=2;;
 
405
   2) load_opt=3;;
 
406
   esac
 
407
fi
 
408
if test "$enable_locbfd" = "yes" ; then
 
409
   case $load_opt in
 
410
   0) load_opt=1;;
 
411
   1) load_opt=2;;
 
412
   2) load_opt=3;;
 
413
   3) load_opt=4;;
 
414
   esac
 
415
fi
 
416
if test "$enable_custreloc" = "yes" ; then
 
417
   case $load_opt in
 
418
   0) load_opt=1;;
 
419
   1) load_opt=2;;
 
420
   2) load_opt=3;;
 
421
   3) load_opt=4;;
 
422
   4) load_opt=5;;
 
423
   esac
 
424
fi
 
425
 
 
426
if test "$load_opt" != "1" ; then
 
427
        echo "Exactly one loader option must be chosen: dlopen=$enable_dlopen statsysbfd=$enable_statsysbfd dynsysbfd=$enable_dynsysbfd locbfd=$enable_locbfd custreloc=$enable_custreloc"
 
428
        exit 1
 
429
fi
 
430
 
 
431
TLDFLAGS=""
 
432
if test "$enable_static" = "yes" ; then
 
433
   TLDFLAGS="-static -Wl,-zmuldefs $TLDFLAGS"; #FIXME should be in unixport/makefile
 
434
   AC_DEFINE(STATIC_LINKING,1,[staticly linked images])
 
435
fi
 
436
 
 
437
 
 
438
## finally warn if we did not find a recognized machine.s
 
439
##
 
440
#if test "$use" = "unknown" ; then
 
441
#types=`echo h/*.defs` | sed -e "s:h/::g" -e "s:\.defs:g"`
 
442
#echo got canonical=$canonical, but was not recognized. 
 
443
#echo Unable to guess type to use.  Try one of 
 
444
#exit(1)
 
445
#fi
 
446
 
 
447
AC_MSG_RESULT([use=$use])       
 
448
 
 
449
 
 
450
#
 
451
# System programs
 
452
#
 
453
 
 
454
# We set the default CFLAGS below, and don't want the autoconf default
 
455
# CM 20040106
 
456
if test "$CFLAGS" = "" ; then
 
457
        CFLAGS=" "
 
458
fi
 
459
if test "$LDFLAGS" = "" ; then
 
460
        LDFLAGS=" "
 
461
fi
 
462
 
 
463
AC_PROG_CC
 
464
AC_PROG_CPP
 
465
AC_SUBST(CC)
 
466
 
 
467
 
 
468
# can only test for numbers -- CM
 
469
# if test "${GCC}" -eq "yes" ; then
 
470
#if [[ "${GCC}" = "yes" ]] ; then
 
471
# Allog for environment variable overrides on compiler selection -- CM
 
472
#GCC=$CC
 
473
#else
 
474
#GCC=""
 
475
#fi
 
476
# subst GCC not only under 386-linux, but where available -- CM
 
477
 
 
478
if test "$GCC" = "yes" ; then
 
479
 
 
480
   TCFLAGS="-Wall -DVOL=volatile -fsigned-char"
 
481
 
 
482
   #FIXME -Wno-unused-but-set-variable when time
 
483
   TMPF=-Wno-unused-but-set-variable
 
484
   AC_MSG_CHECKING([for CFLAG $TMPF])
 
485
   CFLAGS_ORI=$CFLAGS
 
486
   CFLAGS="$CFLAGS $TMPF"
 
487
   AC_TRY_RUN([int main() {return 0;}],TCFLAGS="$TCFLAGS $TMPF";AC_MSG_RESULT(yes),AC_MSG_RESULT(no))
 
488
   CFLAGS=$CFLAGS_ORI
 
489
 
 
490
else
 
491
   TCFLAGS="-DVOL=volatile -fsigned-char"
 
492
fi
 
493
if test "$GCC" = "yes" ; then
 
494
        TCFLAGS="$TCFLAGS -pipe"
 
495
        case $use in
 
496
             *mingw*)
 
497
                echo "WARNING: Remove -fno-zero-initialized-in-bss from makedefs if gcc less than 3.3.1."
 
498
                echo "         It is ptherwise needed for the Unexec stuff to work."
 
499
#               if test "$enable_debug" = "yes" ; then TCFLAGS="$TCFLAGS -gstabs" ; fi
 
500
                TCFLAGS="$TCFLAGS -fno-zero-initialized-in-bss -mms-bitfields";;
 
501
        esac
 
502
fi
 
503
#if test -f /proc/sys/kernel/exec-shield ; then
 
504
#       exec_stat=`cat /proc/sys/kernel/exec-shield`
 
505
#       if test "$exec_stat" != "0" ; then
 
506
#               # CFLAGS here to hopefully cover the DBEGIN routine below
 
507
#               CFLAGS="$CFLAGS -Wa,--execstack"
 
508
#       fi
 
509
#fi
 
510
 
 
511
TO3FLAGS=""
 
512
TO2FLAGS=""
 
513
 
 
514
#TFPFLAG="-fomit-frame-pointer"
 
515
# FIXME -- remove when mingw compiler issues are fixed
 
516
case "$use" in
 
517
  *mingw*)
 
518
        TFPFLAG="";;
 
519
  m68k*)#FIXME gcc 4.x bug workaround
 
520
        TFPFLAG="";;
 
521
  *)
 
522
        TFPFLAG="-fomit-frame-pointer";;
 
523
esac
 
524
 
 
525
AC_CHECK_PROGS(AWK,[gawk nawk awk])
 
526
 
 
527
# Work around system/gprof mips/hppa hang
 
528
case $use in
 
529
  sh4*)  enable_gprof="no";;
 
530
  ia64*)  enable_gprof="no";;
 
531
#  mips*) enable_gprof="no";;
 
532
  hppa*) enable_gprof="no";;
 
533
  arm*)  enable_gprof="no";;#FIXME mcount compiled as a 24/22 bit reloc even with -mlong-calls, marginally accessible
 
534
  *gnu)  enable_gprof="no";;
 
535
esac                 
 
536
 
 
537
if test "$enable_gprof" = "yes" ; then
 
538
        AC_MSG_CHECKING(for text start)
 
539
        echo 'int main () {return(0);}' >foo.c
 
540
        $CC foo.c -o foo
 
541
        GCL_GPROF_START=`nm foo | $AWK  '/  *[[TD]]  *__*start$/ {print $NF}'` # D for ppc64 -- FIXME custreloc
 
542
        rm -f foo.c foo
 
543
        if test "$GCL_GPROF_START" != "" ; then
 
544
                AC_MSG_RESULT($GCL_GPROF_START)
 
545
                AC_DEFINE_UNQUOTED(GCL_GPROF_START,$GCL_GPROF_START,[starting address for gprof])
 
546
                case "$use" in  
 
547
                   arm*)        
 
548
                     #FIXME report and remove this when done
 
549
                     AC_MSG_RESULT(Reducing optimization on profiling arm build to workaround gcc bug)
 
550
                     enable_debug=yes;;
 
551
                esac
 
552
                TCFLAGS="$TCFLAGS -pg";
 
553
                TLIBS="$TLIBS -pg";
 
554
                TFPFLAG=""
 
555
                AC_DEFINE(GCL_GPROF,1,[use gprof profiling])
 
556
        else                       
 
557
                enable_gprof="no";
 
558
        fi                         
 
559
fi
 
560
 
 
561
if $CC -v 2>&1 | tail -n 1 | grep -q "gcc version 4.6.1" ; then
 
562
   case "$use" in       
 
563
     arm*)      
 
564
     #FIXME report and remove this when done
 
565
        AC_MSG_RESULT(Reducing optimization on arm build to workaround gcc 4.6 bug)
 
566
        enable_debug=yes;;
 
567
   esac
 
568
fi
 
569
 
 
570
 
 
571
if test "$enable_debug" = "yes" ; then
 
572
        TCFLAGS="$TCFLAGS -g"
 
573
        # for subconfigurations
 
574
        CFLAGS="$CFLAGS -g"
 
575
else
 
576
        TO3FLAGS="-O3 $TFPFLAG"
 
577
        TO2FLAGS="-O"
 
578
fi
 
579
 
 
580
# gcc on ppc cannot compile our new_init.c with full opts --CM
 
581
TONIFLAGS=""
 
582
case $use in 
 
583
     powerpc*macosx)
 
584
           TCFLAGS="$TCFLAGS -mlongcall";;
 
585
     *linux)
 
586
        case $use in
 
587
#               amd64*) # stack-boundary option does not work
 
588
#                       TCFLAGS="$TCFLAGS -m64 -mpreferred-stack-boundary=8";;  
 
589
                alpha*)
 
590
                        TCFLAGS="$TCFLAGS -mieee"
 
591
                        if test "$enable_debug" != "yes" ; then TO3FLAGS="-O0" ; fi #FIXME needed asof gcc 4.8.1
 
592
                        ;;
 
593
#               m68k*)
 
594
#                       TCFLAGS="$TCFLAGS -ffloat-store";;
 
595
                hppa*)
 
596
                        TCFLAGS="$TCFLAGS -mlong-calls "
 
597
#                       TCFLAGS="$TCFLAGS -ffunction-sections"
 
598
#                       if test "$enable_debug" != "yes" ; then TO3FLAGS="-O $TFPFLAG" ; fi
 
599
#                       if test "$enable_debug" != "yes" ; then TO2FLAGS="-O" ; fi
 
600
                        ;;
 
601
                mips*)
 
602
#                       if test "$enable_debug" != "yes" ; then TO3FLAGS="-O0" ; fi #FIXME needed asof gcc 4.6.2
 
603
                        ;;
 
604
                ia64*)
 
605
                        if test "$enable_debug" != "yes" ; then TO3FLAGS="-O" ; fi #FIXME needed asof gcc 4.8.1
 
606
                        ;;
 
607
                arm*)
 
608
                        TCFLAGS="$TCFLAGS -mlong-calls -fdollars-in-identifiers -g "
 
609
#                       if test "$enable_debug" != "yes" ; then TO3FLAGS="-O" ; fi #FIXME needed asof gcc 4.6.2
 
610
#                       if test "$enable_debug" != "yes" ; then TO2FLAGS="-O" ; fi
 
611
                        ;;
 
612
                powerpc*) 
 
613
                        TCFLAGS="$TCFLAGS -mlongcall"
 
614
                        ;;
 
615
#                       if $CC -v 2>&1 | grep -q "gcc version 3.2" ; then
 
616
#                          echo Reducing optimization for buggy gcc-3.2
 
617
#                          if test "$enable_debug" != "yes" ; then TONIFLAGS="-O $TFPFLAG" ; fi
 
618
#                       fi;
 
619
#                       echo Probing for longcall
 
620
#                       if ! $CC -v 2>&1 | $AWK '/^gcc version / {split($3,A,".");if (A[[1]]+0>3 || (A[[1]]+0>=3 && A[[2]]+0>=3)) exit 1;}'; then
 
621
#                          echo Enabling longcall on gcc 3.3 or later
 
622
#                          TCFLAGS="$TCFLAGS -mlongcall"
 
623
#                          echo Reducing optimization for buggy gcc 3.3 or later
 
624
#                          if test "$enable_debug" != "yes" ; then TONIFLAGS="-O $TFPFLAG" ; fi
 
625
#                       fi;;
 
626
        esac;;
 
627
esac
 
628
if test "$enable_pic" = "yes" ; then
 
629
        TCFLAGS="$TCFLAGS -fPIC"
 
630
fi
 
631
 
 
632
FDEBUG=`echo $CFLAGS | tr ' ' '\012' |grep "^\-g$"|tr '\012' ' '`
 
633
#CFLAGS=`echo $CFLAGS | tr ' ' '\012' |grep -v "^\-g$"`
 
634
FOMITF=`echo $CFLAGS | tr ' ' '\012' |grep "^\-fomit-frame-pointer$"|tr '\012' ' '`
 
635
CFLAGS=`echo $CFLAGS | tr ' ' '\012' |grep -v "^\-fomit-frame-pointer$"|tr '\012' ' '`
 
636
FOOPT3=`echo $CFLAGS | tr ' ' '\012' |grep "^\-O3$"|tr '\012' ' '`
 
637
CFLAGS=`echo $CFLAGS | tr ' ' '\012' |grep -v "^\-O3$"|tr '\012' ' '`
 
638
FOOPT2=`echo $CFLAGS | tr ' ' '\012' |grep "^\-O2$"|tr '\012' ' '`
 
639
CFLAGS=`echo $CFLAGS | tr ' ' '\012' |grep -v "^\-O2$"|tr '\012' ' '`
 
640
FOOPT1=`echo $CFLAGS | tr ' ' '\012' |grep "^\-O1$"|tr '\012' ' '`
 
641
TMP=`echo $CFLAGS | tr ' ' '\012' |grep "^\-O$"|tr '\012' ' '`
 
642
FOOPT1="$FOOPT1$TMP"
 
643
CFLAGS=`echo $CFLAGS | tr ' ' '\012' |grep -v "^\-O1$"|grep -v "^\-O$"|tr '\012' ' '`
 
644
FOOPT0=`echo $CFLAGS | tr ' ' '\012' |grep "^\-O0$"|tr '\012' ' '`
 
645
CFLAGS=`echo $CFLAGS | tr ' ' '\012' |grep -v "^\-O0$"|tr '\012' ' '`
 
646
 
 
647
if test "$FOOPT0" != "" ; then
 
648
   TO3FLAGS=`echo $TO3FLAGS | sed 's,\-O[[123 ]],-O0 ,g' | sed 's,\-O$,-O0 ,g'`
 
649
   TO2FLAGS=`echo $TO2FLAGS | sed 's,\-O[[123 ]],-O0 ,g' | sed 's,\-O$,-O0 ,g'`
 
650
else 
 
651
if test "$FOOPT1" != "" ; then
 
652
   TO3FLAGS=`echo $TO3FLAGS | sed 's,\-O[[2-3]],-O1,g'`
 
653
   TO2FLAGS=`echo $TO2FLAGS | sed 's,\-O[[2-3]],-O1,g'`
 
654
else 
 
655
if test "$FOOPT2" != "" ; then
 
656
   TO3FLAGS=`echo "$TO3FLAGS" | sed 's,\-O3,-O2,g'`
 
657
   TO2FLAGS=`echo "$TO2FLAGS" | sed 's,\-O3,-O2,g'`
 
658
fi
 
659
fi
 
660
fi
 
661
 
 
662
if test "$FDEBUG" != "" ; then
 
663
   TO3FLAGS=`echo $TO3FLAGS | sed 's,\-fomit-frame-pointer,,g'`
 
664
   TO2FLAGS=`echo $TO2FLAGS | sed 's,\-fomit-frame-pointer,,g'`
 
665
fi
 
666
 
 
667
if test "$FOMITF" != "" ; then
 
668
   TO3FLAGS="$TO3FLAGS $FOMITF"
 
669
fi
 
670
 
 
671
# Step 1: set the variable "system" to hold the name and version number
 
672
# for the system.  This can usually be done via the "uname" command, but
 
673
# there are a few systems, like Next, where this doesn't work.
 
674
 
 
675
AC_MSG_CHECKING([system version (for dynamic loading)])
 
676
if machine=`uname -m` ; then true; else machine=unknown ; fi
 
677
 
 
678
AC_CHECK_PROGS(MAKEINFO,makeinfo,"false")
 
679
AC_SUBST(MAKEINFO)
 
680
 
 
681
if test -f /usr/lib/NextStep/software_version; then
 
682
    system=NEXTSTEP-`${AWK} '/3/,/3/' /usr/lib/NextStep/software_version`
 
683
else
 
684
    system=`uname -s`-`uname -r`
 
685
    if test "$?" -ne 0 ; then
 
686
        AC_MSG_RESULT([unknown (can't find uname command)])
 
687
        system=unknown
 
688
    else
 
689
        # Special check for weird MP-RAS system (uname returns weird
 
690
        # results, and the version is kept in special file).
 
691
    
 
692
        if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
 
693
            system="MP-RAS-`${AWK} '{print $3}' '/etc/.relid'`"
 
694
        fi
 
695
        if test "`uname -s`" = "AIX" ; then
 
696
            system=AIX-`uname -v`.`uname -r`
 
697
        fi
 
698
        AC_MSG_RESULT($system)
 
699
    fi
 
700
fi
 
701
 
 
702
case $use in
 
703
     *macosx)
 
704
        AC_CHECK_HEADERS(malloc/malloc.h,,[AC_MSG_ERROR([need malloc.h on macosx])])
 
705
        AC_CHECK_MEMBER([struct _malloc_zone_t.memalign],
 
706
                AC_DEFINE(HAVE_MALLOC_ZONE_MEMALIGN,1,[memalign element present]), [], 
 
707
                [
 
708
                #include <malloc/malloc.h>
 
709
                ])
 
710
        AC_SUBST(HAVE_MALLOC_ZONE_MEMALIGN)
 
711
        ;;
 
712
esac
 
713
 
 
714
 
 
715
        
 
716
 
 
717
# sysconf
 
718
 
 
719
AC_CHECK_HEADERS(unistd.h,
 
720
        AC_CHECK_LIB(c,sysconf,
 
721
                AC_MSG_CHECKING(_SC_CLK_TCK)
 
722
                AC_TRY_RUN([#include <unistd.h>
 
723
                            #include <stdio.h>
 
724
                            int
 
725
                            main() {
 
726
                                FILE *fp=fopen("conftest1","w");
 
727
                                fprintf(fp,"%lu\n",sysconf(_SC_CLK_TCK));
 
728
                                fclose(fp);
 
729
                                return 0;
 
730
                            }],
 
731
                            hz=`cat conftest1`
 
732
                            AC_DEFINE_UNQUOTED(HZ,$hz,[time system constant])
 
733
                            ,hz=0,hz=0)
 
734
                [AC_MSG_RESULT($hz)]
 
735
                AC_MSG_CHECKING(_SC_PHYS_PAGES)
 
736
                AC_RUN_IFELSE([
 
737
                        AC_LANG_SOURCE([[
 
738
                        #include <stdio.h>
 
739
                        #include <unistd.h>
 
740
                        int main() {
 
741
                           FILE *fp=fopen("conftest1","w");
 
742
                           fprintf(fp,"%lu\n",sysconf(_SC_PHYS_PAGES));
 
743
                           fclose(fp);
 
744
                           return 0;
 
745
                        }]])],
 
746
                        [phys=`cat conftest1`
 
747
                         AC_MSG_RESULT($phys)
 
748
                         AC_DEFINE(HAVE_SYSCONF_PHYS_PAGES,$phys,[probe runtime phys pages for gc performance])],
 
749
                         [AC_MSG_RESULT(no)])))
 
750
 
 
751
 
 
752
#MY_SUBDIRS=
 
753
 
 
754
#
 
755
# GMP
 
756
#
 
757
 
 
758
rm -f makedefsafter
 
759
 
 
760
MP_INCLUDE=""
 
761
if test $use_gmp = yes ; then
 
762
 
 
763
 PATCHED_SYMBOLS=""
 
764
 if test "$enable_dynsysgmp" = "yes" ; then
 
765
        AC_CHECK_HEADERS(gmp.h,
 
766
                AC_CHECK_LIB(gmp,__gmpz_init,
 
767
                        AC_MSG_CHECKING("for external gmp version")
 
768
                        AC_TRY_RUN([#include <gmp.h>
 
769
                                    int main() {
 
770
                                    #if __GNU_MP_VERSION == 4 || __GNU_MP_VERSION == 5
 
771
                                        return 0;
 
772
                                    #else
 
773
                                        return -1;
 
774
                                    #endif
 
775
                                    }],
 
776
#                               MPFILES=$GMPDIR/mpn/mul_n.o
 
777
#                               PATCHED_SYMBOLS=__gmpn_toom3_mul_n
 
778
                                MPFILES=
 
779
                                PATCHED_SYMBOLS=
 
780
#                               if test "$use" = "m68k-linux" ; then
 
781
#                                       MPFILES="$MPFILES $GMPDIR/mpn/lshift.o $GMPDIR/mpn/rshift.o"
 
782
#                                       PATCHED_SYMBOLS="$PATCHED_SYMBOLS __gmpn_lshift __gmpn_rshift"
 
783
#                               fi
 
784
                                TLIBS="$TLIBS -lgmp"
 
785
                                echo "#include \"gmp.h\"" >foo.c
 
786
                                echo "int main() {return 0;}" >>foo.c
 
787
                                MP_INCLUDE=`cpp foo.c | grep /gmp.h | head -n 1 | $AWK '{print $3}' | tr -d '"'`
 
788
                                rm -f foo.c,
 
789
                                echo "Cannot use dynamic gmp lib" , echo "Cannot use dynamic gmp lib" ),
 
790
                        echo "Cannot use dynamic gmp lib" ,),
 
791
                echo "Cannot use dynamic gmp lib" ,)
 
792
fi
 
793
 
 
794
NEED_LOCAL_GMP=''
 
795
if test "$MP_INCLUDE" = "" ; then                       
 
796
        NEED_LOCAL_GMP=1;
 
797
fi
 
798
if test "$PATCHED_SYMBOLS" != "" ; then                 
 
799
        NEED_LOCAL_GMP=1;
 
800
fi
 
801
 
 
802
if test "$NEED_LOCAL_GMP" != "" ; then                  
 
803
 
 
804
         GMPDIR=gmp4
 
805
         AC_MSG_CHECKING([use_gmp=yes, doing configure in gmp directory])
 
806
         echo
 
807
         echo "#"
 
808
         echo "#"
 
809
         echo "# -------------------"
 
810
         echo "# Subconfigure of GMP"
 
811
         echo "#"
 
812
         echo "#"
 
813
 
 
814
         if test "$use_common_binary" = "yes"; then
 
815
           cd $GMPDIR && ./configure --build=$host && cd ..
 
816
         else
 
817
           cd $GMPDIR && ./configure && cd ..
 
818
         fi
 
819
        #MY_SUBDIRS="$MY_SUBDIRS $GMPDIR" 
 
820
 
 
821
         echo "#"
 
822
         echo "#"
 
823
         echo "#"
 
824
         echo "# Subconfigure of GMP done"
 
825
         echo "# ------------------------"
 
826
         echo "#"
 
827
 
 
828
        if test "$MP_INCLUDE" = "" ; then
 
829
                cp $GMPDIR/gmp.h h/gmp.h
 
830
                MP_INCLUDE=h/gmp.h
 
831
                MPFILES=gmp_all
 
832
        fi
 
833
 
 
834
fi
 
835
 
 
836
AC_MSG_CHECKING("for leading underscore in object symbols")
 
837
cat>foo.c <<EOFF
 
838
#include <math.h>
 
839
#include <stdio.h>
 
840
int main() {FILE *f;double d=0.0;getc(f);cos(d);return 0;}
 
841
EOFF
 
842
$CC -c foo.c -o foo.o
 
843
if nm foo.o |grep " U " | grep "_cos" >/dev/null || nm foo.o |grep " U " | grep " _getc" >/dev/null ; then
 
844
        LEADING_UNDERSCORE=1
 
845
        AC_DEFINE(LEADING_UNDERSCORE,1,[symbol name mangling convention])
 
846
        AC_MSG_RESULT("yes")
 
847
else
 
848
        LEADING_UNDERSCORE=""
 
849
        AC_MSG_RESULT("no")
 
850
fi
 
851
 
 
852
 
 
853
AC_MSG_CHECKING("for GNU ld option -Map")
 
854
touch map
 
855
$CC -o foo [ -Wl,-Map ] map foo.o >/dev/null 2>&1
 
856
if test `cat map | wc -l` != "0" ; then
 
857
        AC_MSG_RESULT("yes")
 
858
        AC_DEFINE(HAVE_GNU_LD,1,[gnu linker present])
 
859
        GNU_LD=1
 
860
else
 
861
        AC_MSG_RESULT("no")
 
862
        GNU_LD=
 
863
fi
 
864
rm -f foo.c foo.o foo map
 
865
 
 
866
AC_MSG_CHECKING([for size of gmp limbs])
 
867
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
868
        #include <stdio.h>
 
869
        #include "$MP_INCLUDE"
 
870
        ]],[[
 
871
        FILE *fp=fopen("conftest1","w");
 
872
        fprintf(fp,"%u",sizeof(mp_limb_t));
 
873
        fclose(fp);
 
874
        return 0;
 
875
        ]])],[mpsize=`cat conftest1`],[AC_MSG_ERROR([Cannot determine mpsize])])
 
876
AC_DEFINE_UNQUOTED(MP_LIMB_BYTES,$mpsize,[sizeof mp_limb in gmp library])
 
877
AC_MSG_RESULT($mpsize) 
 
878
 
 
879
AC_MSG_CHECKING([_SHORT_LIMB])
 
880
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
881
        #include <stdio.h>
 
882
        #include "$MP_INCLUDE"
 
883
        ]],[[
 
884
        #ifdef _SHORT_LIMB
 
885
        return 0;
 
886
        #else
 
887
        return 1;
 
888
        #endif
 
889
        ]])],[AC_DEFINE(__SHORT_LIMB,1,[short gmp3 limbs]) AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
 
890
 
 
891
AC_MSG_CHECKING([_LONG_LONG_LIMB])
 
892
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
893
        #include <stdio.h>
 
894
        #include "$MP_INCLUDE"
 
895
        ]],[[
 
896
        #ifdef _LONG_LONG_LIMB
 
897
        return 0;
 
898
        #else
 
899
        return 1;
 
900
        #endif
 
901
        ]])],[AC_DEFINE(__LONG_LONG_LIMB,1,[long gmp3 limbs]) AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
 
902
 
 
903
 GMP=1
 
904
 AC_DEFINE(GMP,1,[using gmp])
 
905
 AC_SUBST(GMP)
 
906
 AC_SUBST(GMPDIR)
 
907
 echo > makedefsafter
 
908
 echo "MPFILES=$MPFILES" >> makedefsafter
 
909
 echo "PATCHED_SYMBOLS=$PATCHED_SYMBOLS" >> makedefsafter
 
910
 echo >> makedefsafter
 
911
fi
 
912
 
 
913
 
 
914
#
 
915
# X windows
 
916
 
917
 
 
918
if test "$enable_xgcl" = "yes" ; then 
 
919
 
 
920
   AC_PATH_X
 
921
#   AC_PATH_XTRA
 
922
#   echo $X_CFLAGS
 
923
#   echo $X_LIBS
 
924
#   echo $X_EXTRA_LIBS
 
925
#   echo $X_PRE_LIBS
 
926
 
 
927
   miss=0
 
928
#   AC_CHECK_LIB(Xmu,main,X_LIBS="$X_LIBS",miss=1,$X_LIBS)#FIXME remove these
 
929
#   AC_CHECK_LIB(Xt,main,X_LIBS="$X_LIBS",miss=1,$X_LIBS)
 
930
#   AC_CHECK_LIB(Xext,main,X_LIBS="$X_LIBS",miss=1,$X_LIBS)
 
931
#   AC_CHECK_LIB(Xaw,main,X_LIBS="$X_LIBS",miss=1,$X_LIBS)#until here
 
932
   AC_CHECK_LIB(X11,main,X_LIBS="$X_LIBS -lX11",miss=1,$X_LIBS)
 
933
 
 
934
   if test "$miss" = "1" ; then
 
935
      X_CFLAGS=
 
936
      X_LIBS=
 
937
      X_EXTRA_LIBS=
 
938
      X_PRE_LIBS=
 
939
      echo missing x libraries -- cannot compile xgcl
 
940
   else
 
941
      AC_DEFINE(HAVE_XGCL,1,[using xgcl])
 
942
   fi
 
943
fi
 
944
 
 
945
 
 
946
AC_SUBST(X_LIBS)
 
947
AC_SUBST(X_CFLAGS)
 
948
 
 
949
#
 
950
# Dynamic loading
 
951
#
 
952
 
 
953
if test "$enable_dlopen" = "yes" ; then
 
954
 
 
955
        AC_CHECK_LIB(dl,dlopen,have_dl=1,have_dl=0)
 
956
        if test "$have_dl" = "0" ; then
 
957
                echo "Cannot find dlopen in -dl"
 
958
                exit 1
 
959
        fi
 
960
dnl     AC_SEARCH_LIBS(dlopen, dl, have_dl=1, AC_ERROR(dlopen not found))
 
961
dnl LIBS and TLIBS - why not merged from the beginning?
 
962
 
 
963
        TLIBS="$TLIBS -ldl -rdynamic"
 
964
dnl     TLIBS="$TLIBS -rdynamic"
 
965
        AC_DEFINE(USE_DLOPEN,1,[link compiled objects via libdl])
 
966
fi
 
967
 
 
968
if test "$enable_statsysbfd" = "yes" || test "$enable_dynsysbfd" = "yes" ; then
 
969
        AC_CHECK_HEADERS(bfd.h,
 
970
                AC_CHECK_LIB(bfd,bfd_init,
 
971
                #
 
972
                # Old binutils appear to need CONST defined to const
 
973
                #
 
974
                        AC_MSG_CHECKING(if need to define CONST for bfd)
 
975
                        AC_TRY_RUN([#define IN_GCC
 
976
                                    #include <bfd.h>
 
977
                                    int main() { symbol_info t; return 0;}],
 
978
                                AC_MSG_RESULT(no),
 
979
                                AC_TRY_RUN([#define CONST const
 
980
                                            #define IN_GCC
 
981
                                            #include <bfd.h>
 
982
                                            int main() {symbol_info t; return 0;}],
 
983
                                        AC_MSG_RESULT(yes) 
 
984
                                        AC_DEFINE(NEED_CONST,1,[binutils requires CONST definition]),
 
985
                                        AC_MSG_ERROR([cannot use bfd]),
 
986
                                        AC_MSG_ERROR([cannot use bfd])),
 
987
                                AC_MSG_ERROR([cannot use bfd]))
 
988
                        ,,-liberty))
 
989
 
 
990
        AC_DEFINE(HAVE_LIBBFD,1,[use libbfd])
 
991
 
 
992
#
 
993
# BFD boolean syntax
 
994
#
 
995
 
 
996
        AC_MSG_CHECKING(for useable bfd_boolean)
 
997
        AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
998
                #define IN_GCC
 
999
                #include <bfd.h>
 
1000
                bfd_boolean foo() {return FALSE;}
 
1001
                ]],[[return 0;]])],
 
1002
                [AC_MSG_RESULT(yes) 
 
1003
                AC_DEFINE(HAVE_BFD_BOOLEAN,1,[bfd_boolean defined])],
 
1004
                [AC_MSG_RESULT(no)])
 
1005
 
 
1006
#
 
1007
# bfd_link_info.output_bfd minimal configure change check
 
1008
#
 
1009
 
 
1010
        AC_CHECK_MEMBER([struct bfd_link_info.output_bfd],
 
1011
                AC_DEFINE(HAVE_OUTPUT_BFD,1,[output_bfd element present]), [], 
 
1012
                [
 
1013
                #include <bfd.h>
 
1014
                #include <bfdlink.h>
 
1015
                ])
 
1016
        AC_SUBST(HAVE_OUTPUT_BFD)
 
1017
 
 
1018
#
 
1019
# FIXME: Need to workaround mingw before this point -- CM
 
1020
#
 
1021
        if test "$enable_statsysbfd" = "yes" && ! $CC -v 2>&1 | fgrep ming > /dev/null ; then
 
1022
                echo 'int main() {bfd_init();bfd_openr("/dev/null",0);return 0;}' >foo.c
 
1023
                MP=`$CC [ -Wl,-M ] -static -o foo foo.c -lbfd -liberty -ldl 2>&1 | grep -v : | tr '()' '\012\012' | $AWK '{print $NF}' | sort | uniq`
 
1024
                rm -f foo.c foo
 
1025
                if echo $MP | tr ' ' '\012' | grep -q libbfd.a ; then
 
1026
                   LIBBFD="`echo $MP | tr ' ' '\012' | grep libbfd.a | $AWK '{i=split($1,A,"/");for (j=1;j<=i;j++) if (j>1 && A[[j]]=="..") {j--;i-=2;for (k=j;k<=i;k++) A[[k]]=A[[k+2]];j--;}} END {for (j=1;j<=i;j++) printf("%s%s",A[[j]],j!=i ? "/" : "")}'`"
 
1027
                else
 
1028
                   echo Guessing path to libbfd.a due to gcc bug
 
1029
                   LIBBFD="/usr/lib/libbfd.a"
 
1030
                fi   
 
1031
                if echo $MP | tr ' ' '\012' | grep -q libiberty.a ; then
 
1032
                   LIBIBERTY="`echo $MP | tr ' ' '\012' | grep libiberty.a | $AWK '{i=split($1,A,"/");for (j=1;j<=i;j++) if (j>1 && A[[j]]=="..") {j--;i-=2;for (k=j;k<=i;k++) A[[k]]=A[[k+2]];j--;}} END {for (j=1;j<=i;j++) printf("%s%s",A[[j]],j!=i ? "/" : "")}'`"
 
1033
                else
 
1034
                   echo Guessing path to libiberty.a due to gcc bug
 
1035
                   LIBIBERTY="/usr/lib/libiberty.a"
 
1036
                fi   
 
1037
                BUILD_BFD=copy_bfd
 
1038
                AC_CHECK_LIB(z,inflate,
 
1039
                        [TLIBS="$TLIBS -lz"],
 
1040
                        AC_MSG_ERROR([Need zlib for bfd linking]),[])
 
1041
                AC_CHECK_LIB(dl,dlsym,
 
1042
                        [TLIBS="$TLIBS -ldl"],
 
1043
                        AC_MSG_ERROR([Need libdl for bfd linking]),[])
 
1044
                AC_SUBST(BUILD_BFD)
 
1045
                AC_SUBST(LIBBFD)
 
1046
                AC_SUBST(LIBIBERTY)
 
1047
 
 
1048
        else
 
1049
                TLIBS="$TLIBS -lbfd -liberty -ldl"
 
1050
        fi
 
1051
fi
 
1052
 
 
1053
if test "$enable_locbfd" = "yes" ; then
 
1054
 
 
1055
        # check for gettext.  It is part of glibc, but others
 
1056
        # need GNU gettext separately.
 
1057
#       AC_CHECK_HEADERS(libintl.h, true,
 
1058
#                          AC_MSG_ERROR(libintl.h (gettext) not found))
 
1059
#       AC_SEARCH_LIBS(dgettext, intl, true, AC_MSG_ERROR(gettext library not found))
 
1060
 
 
1061
        echo "#"
 
1062
        echo "#"
 
1063
        echo "# -------------------------"
 
1064
        echo "# Subconfigure of LIBINTL"
 
1065
        echo "#"
 
1066
        echo "#"
 
1067
        cd binutils/intl && chmod +x configure && ./configure --disable-nls && cd ../..
 
1068
#       MY_SUBDIRS="$MY_SUBDIRS binutils/libiberty " 
 
1069
        echo "#"
 
1070
        echo "#"
 
1071
        echo "#"
 
1072
        echo "# Subconfigure of LIBINTL done"
 
1073
        echo "# ------------------------------"
 
1074
        echo "#"
 
1075
        echo "#"
 
1076
        echo "#"
 
1077
        echo "# -------------------------"
 
1078
        echo "# Subconfigure of LIBIBERTY"
 
1079
        echo "#"
 
1080
        echo "#"
 
1081
        cd binutils/libiberty && chmod +x configure && ./configure --disable-nls && cd ../..
 
1082
#       MY_SUBDIRS="$MY_SUBDIRS binutils/libiberty " 
 
1083
        echo "#"
 
1084
        echo "#"
 
1085
        echo "#"
 
1086
        echo "# Subconfigure of LIBIBERTY done"
 
1087
        echo "# ------------------------------"
 
1088
        echo "#"
 
1089
        echo "#"
 
1090
        echo "#"
 
1091
        echo "# -------------------"
 
1092
        echo "# Subconfigure of BFD"
 
1093
        echo "#"
 
1094
        echo "#"
 
1095
        cd binutils/bfd && chmod +x configure && ./configure --with-included-gettext --disable-nls && cd ../..
 
1096
#       MY_SUBDIRS="$MY_SUBDIRS binutils/bfd " 
 
1097
        echo "#"
 
1098
        echo "#"
 
1099
        echo "#"
 
1100
        echo "# Subconfigure of BFD done"
 
1101
        echo "# ------------------------"
 
1102
        echo "#"
 
1103
#       TLIBS="$TLIBS `pwd`/binutils/bfd/libbfd.a `pwd`/binutils/libiberty/libiberty.a"
 
1104
        AC_DEFINE(HAVE_LIBBFD,1,[use libbfd])
 
1105
        BUILD_BFD="h/bfd.h h/bfdlink.h h/ansidecl.h h/symcat.h"
 
1106
        AC_SUBST(BUILD_BFD)
 
1107
fi
 
1108
 
 
1109
 
 
1110
if test "$enable_xdr" = "yes" ; then
 
1111
   AC_CHECK_FUNC(xdr_double,AC_DEFINE(HAVE_XDR,1,[have xdr extensions]),
 
1112
           AC_CHECK_LIB(tirpc,xdr_double,AC_DEFINE(HAVE_XDR,1,[have xdr extensions]) TLIBS="$TLIBS -ltirpc",
 
1113
           AC_CHECK_LIB(rpc,xdr_double,AC_DEFINE(HAVE_XDR,1,[have xdr extensions]) TLIBS="$TLIBS -lrpc",
 
1114
           AC_CHECK_LIB(oncrpc,xdr_double,AC_DEFINE(HAVE_XDR,1,[have xdr extensions]) TLIBS="$TLIBS -loncrpc"))))
 
1115
fi
 
1116
 
 
1117
 
 
1118
AC_MSG_CHECKING([__builtin_clzl])
 
1119
AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
1120
  #include <stdio.h>
 
1121
  #include <unistd.h>
 
1122
  int main() {
 
1123
      unsigned long u;
 
1124
      long j;
 
1125
      if (__builtin_clzl(0)!=sizeof(long)*8)
 
1126
         return -1;
 
1127
      for (u=1,j=sizeof(long)*8-1;j>=0;j--,u<<=1)
 
1128
          if (__builtin_clzl(u)!=j)
 
1129
             return -1;
 
1130
      return 0;
 
1131
   }]])],[AC_MSG_RESULT([yes])
 
1132
          AC_DEFINE(HAVE_CLZL,[1],[clzl instruction])],
 
1133
          [AC_MSG_RESULT([no])])
 
1134
 
 
1135
AC_MSG_CHECKING([__builtin_ctzl])
 
1136
AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
1137
  #include <stdio.h>
 
1138
  #include <unistd.h>
 
1139
  int main() {
 
1140
      unsigned long u;
 
1141
      long j;
 
1142
      if (__builtin_ctzl(0)!=sizeof(long)*8)
 
1143
         return -1;
 
1144
      for (u=1,j=0;j<sizeof(long)*8-1;j++,u<<=1)
 
1145
          if (__builtin_ctzl(u)!=j)
 
1146
             return -1;
 
1147
      return 0;
 
1148
   }]])],[AC_MSG_RESULT([yes])
 
1149
          AC_DEFINE(HAVE_CTZL,[1],[ctzl instruction])],
 
1150
          [AC_MSG_RESULT([no])])
 
1151
 
 
1152
 
 
1153
case $use in
 
1154
     sh4*) ;;     #FIXME, these exceptions needed as of gcc 4.7
 
1155
     hppa*) ;;    #FIXME
 
1156
     powerpc*) ;; #FIXME
 
1157
     alpha*) ;;   #FIXME
 
1158
     ia64*) ;;    #FIXME
 
1159
     *) 
 
1160
     AC_MSG_CHECKING(__builtin___clear_cache)
 
1161
                AC_TRY_COMPILE([],
 
1162
                               [void *v,*ve;
 
1163
                                __builtin___clear_cache(v,ve);
 
1164
                                ],
 
1165
                                [AC_DEFINE(HAVE_BUILTIN_CLEAR_CACHE,1,[have __builtin__clear_cache instruction])
 
1166
                                 AC_MSG_RESULT(yes)],
 
1167
                                 AC_MSG_RESULT(no));;
 
1168
esac
 
1169
 
 
1170
#AC_CONFIG_SUBDIRS($MY_SUBDIRS)
 
1171
 
 
1172
# Find where Data begins.  This is used by the storage allocation
 
1173
# mechanism, in the PAGE macro.  This offset is subtracted from
 
1174
# addresses, in calculating a page for an address in the heap.
 
1175
 
 
1176
AC_CHECK_SIZEOF(long,0)
 
1177
 
 
1178
####  Memory areas and alignment
 
1179
 
 
1180
AC_MSG_CHECKING(for byte order)
 
1181
AC_RUN_IFELSE([
 
1182
        AC_LANG_PROGRAM([[
 
1183
                ]],[[
 
1184
 
 
1185
                /* Are we little or big endian?  Adapted from Harbison&Steele.  */
 
1186
                union {long l;char c[sizeof(long)];} u;
 
1187
                u.l = 1;
 
1188
                return u.c[sizeof(long)-1] ? 1 : 0;
 
1189
        ]])],[
 
1190
        AC_MSG_RESULT(little)],
 
1191
        [AC_MSG_RESULT(big) 
 
1192
        AC_DEFINE(WORDS_BIGENDIAN,1,[big endian byte order])])
 
1193
AC_SUBST(WORDS_BIGENDIAN)
 
1194
 
 
1195
 
 
1196
AC_MSG_CHECKING(for word order)
 
1197
AC_RUN_IFELSE([
 
1198
        AC_LANG_PROGRAM([[
 
1199
                ]],[[
 
1200
                /* Are we little or big endian?  Adapted from Harbison&Steele.  */
 
1201
                union {double d;int l[sizeof(double)/sizeof(int)];} u;
 
1202
                u.d = 1.0;
 
1203
                return u.l[sizeof(double)/sizeof(int)-1] ? 0 : 1;
 
1204
        ]])],
 
1205
        [AC_MSG_RESULT(little)],
 
1206
        [AC_MSG_RESULT(big) 
 
1207
        AC_DEFINE(DOUBLE_BIGENDIAN,1,[big endian word order])])
 
1208
AC_SUBST(DOUBLE_BIGENDIAN)
 
1209
 
 
1210
# pagewidth
 
1211
AC_MSG_CHECKING(for pagewidth)
 
1212
case $use in
 
1213
     mips*) min_pagewidth=14;;
 
1214
     *) min_pagewidth=12;;
 
1215
esac
 
1216
AC_RUN_IFELSE([
 
1217
        AC_LANG_PROGRAM([[
 
1218
            #include <stdio.h>
 
1219
            #include <unistd.h>
 
1220
            ]],[[
 
1221
            size_t i=getpagesize(),j; 
 
1222
            FILE *fp=fopen("conftest1","w");
 
1223
            for (j=0;i>>=1;j++);
 
1224
            j=j<$min_pagewidth ? $min_pagewidth : j;
 
1225
            fprintf(fp,"%u",j);
 
1226
            return 0;
 
1227
        ]])],
 
1228
        [PAGEWIDTH=`cat conftest1`],
 
1229
        [PAGEWIDTH=0])
 
1230
AC_MSG_RESULT($PAGEWIDTH)
 
1231
AC_DEFINE_UNQUOTED(PAGEWIDTH,$PAGEWIDTH,[system pagewidth])
 
1232
AC_SUBST(PAGEWIDTH)
 
1233
 
 
1234
AC_MSG_CHECKING([for required object alignment])
 
1235
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
1236
        #include <stdio.h>
 
1237
        #define EXTER
 
1238
        #include "$MP_INCLUDE"
 
1239
        #include "./h/enum.h"
 
1240
        #include "./h/bits.h"
 
1241
        #define OBJ_ALIGN
 
1242
        #include "./h/object.h"
 
1243
        ]],[[
 
1244
        unsigned long i;
 
1245
        FILE *fp=fopen("conftest1","w");
 
1246
        for (i=1;i && NOT_OBJECT_ALIGNED(i); i<<=1);
 
1247
        if (!i) return -1;
 
1248
        fprintf(fp,"%lu",i);
 
1249
        fclose(fp);
 
1250
        return 0;
 
1251
        ]])],
 
1252
         [obj_align=`cat conftest1`
 
1253
         AC_MSG_RESULT($obj_align)
 
1254
         AC_DEFINE_UNQUOTED(OBJ_ALIGNMENT,$obj_align,[needed object alignment in bytes])],
 
1255
         [AC_MSG_ERROR([Cannot find object alignent])])
 
1256
 
 
1257
AC_MSG_CHECKING([for C extension variable alignment])
 
1258
AC_RUN_IFELSE([AC_LANG_PROGRAM([[]],[[
 
1259
            char *v __attribute__ ((aligned ($obj_align)));
 
1260
            return 0;]])],[obj_align="__attribute__ ((aligned ($obj_align)))"],[obj_align=])
 
1261
AC_MSG_RESULT($obj_align)
 
1262
AC_DEFINE_UNQUOTED(OBJ_ALIGN,$obj_align,[can use C extension for object alignment])
 
1263
 
 
1264
AC_MSG_CHECKING(sizeof struct contblock)
 
1265
 
 
1266
# work around MSYS pwd result incompatibility
 
1267
if test "$use" = "mingw" ; then
 
1268
AC_TRY_RUN([#include <stdio.h>
 
1269
        #define EXTER
 
1270
        #include "$MP_INCLUDE"
 
1271
        #include "h/enum.h"
 
1272
        #include "h/bits.h"
 
1273
        #include "h/object.h"
 
1274
        int main(int argc,char **argv,char **envp) {
 
1275
        FILE *f=fopen("conftest1","w");
 
1276
        fprintf(f,"%u",sizeof(struct contblock));
 
1277
        fclose(f);
 
1278
        return 0;
 
1279
        }],sizeof_contblock=`cat conftest1`,
 
1280
           echo Cannot find sizeof struct contblock;exit 1,
 
1281
           echo Cannot find sizeof struct contblock;exit 1)
 
1282
else
 
1283
AC_TRY_RUN([#include <stdio.h>
 
1284
        #define EXTER
 
1285
        #include "$MP_INCLUDE"
 
1286
        #include "`pwd`/h/enum.h"
 
1287
        #include "`pwd`/h/bits.h"
 
1288
        #include "`pwd`/h/object.h"
 
1289
        int main(int argc,char **argv,char **envp) {
 
1290
        FILE *f=fopen("conftest1","w");
 
1291
        fprintf(f,"%u",sizeof(struct contblock));
 
1292
        fclose(f);
 
1293
        return 0;
 
1294
        }],sizeof_contblock=`cat conftest1`,
 
1295
           echo Cannot find sizeof struct contblock;exit 1,
 
1296
           echo Cannot find sizeof struct contblock;exit 1)
 
1297
fi
 
1298
AC_MSG_RESULT($sizeof_contblock)
 
1299
AC_DEFINE_UNQUOTED(SIZEOF_CONTBLOCK,$sizeof_contblock,[sizeof linked list for contiguous pages])
 
1300
 
 
1301
AC_MSG_CHECKING([for sbrk])
 
1302
HAVE_SBRK=""
 
1303
AC_TRY_RUN([#include <unistd.h>
 
1304
            #include <stdio.h>
 
1305
            int main() {
 
1306
                FILE *f;
 
1307
                if (!(f=fopen("conftest1","w")))
 
1308
                        return -1;
 
1309
                fprintf(f,"%u",sbrk(0));
 
1310
                return 0;
 
1311
                }],
 
1312
                HAVE_SBRK=1
 
1313
                AC_MSG_RESULT(yes),
 
1314
                AC_MSG_RESULT([no: WARNING you must be able to emulate sbrk: as on mingw or macosx]),
 
1315
                AC_MSG_RESULT([no: WARNING you must be able to emulate sbrk: as on mingw or macosx]))
 
1316
 
 
1317
if test "$use" = "386-macosx" ; then
 
1318
   AC_MSG_RESULT(emulating sbrk for mac);
 
1319
   HAVE_SBRK=0
 
1320
fi
 
1321
 
 
1322
if test "$HAVE_SBRK" = "1" ; then
 
1323
 
 
1324
   AC_MSG_CHECKING([for ADDR_NO_RANDOMIZE constant])
 
1325
   AC_RUN_IFELSE([
 
1326
        AC_LANG_PROGRAM([[
 
1327
            #include <sys/personality.h>
 
1328
            #include <stdio.h>
 
1329
            ]],[[
 
1330
            FILE *f;
 
1331
            if (!(f=fopen("conftest1","w"))) return -1;
 
1332
            fprintf(f,"%x",ADDR_NO_RANDOMIZE);
 
1333
            return 0;
 
1334
        ]])],
 
1335
        [ADDR_NO_RANDOMIZE=`cat conftest1`
 
1336
        AC_MSG_RESULT([yes $ADDR_NO_RANDOMIZE])],
 
1337
        [ADDR_NO_RANDOMIZE=0
 
1338
        AC_MSG_RESULT([no assuming 0x40000])
 
1339
        AC_DEFINE_UNQUOTED(ADDR_NO_RANDOMIZE,0x40000,[punt guess for no randomize value])])
 
1340
 
 
1341
   AC_MSG_CHECKING([for ADDR_COMPAT_LAYOUT constant])
 
1342
   AC_RUN_IFELSE([
 
1343
        AC_LANG_PROGRAM([[
 
1344
            #include <sys/personality.h>
 
1345
            #include <stdio.h>
 
1346
            ]],[[
 
1347
            FILE *f;
 
1348
            if (!(f=fopen("conftest1","w"))) return -1;
 
1349
            fprintf(f,"%x",ADDR_COMPAT_LAYOUT);
 
1350
            return 0;
 
1351
        ]])],
 
1352
        [ADDR_COMPAT_LAYOUT=`cat conftest1`
 
1353
        AC_MSG_RESULT([yes $ADDR_COMPAT_LAYOUT])],
 
1354
        [ADDR_COMPAT_LAYOUT=0
 
1355
        AC_MSG_RESULT([no])]
 
1356
        AC_DEFINE_UNQUOTED(ADDR_COMPAT_LAYOUT,0,[constant to reserve upper 3Gb for C stack]))
 
1357
 
 
1358
   AC_MSG_CHECKING([for ADDR_LIMIT_3GB constant])
 
1359
   AC_RUN_IFELSE([
 
1360
        AC_LANG_PROGRAM([[
 
1361
            #include <sys/personality.h>
 
1362
            #include <stdio.h>
 
1363
            ]],[[
 
1364
            FILE *f;
 
1365
            if (!(f=fopen("conftest1","w"))) return -1;
 
1366
            fprintf(f,"%x",ADDR_LIMIT_3GB);
 
1367
            return 0;
 
1368
        ]])],
 
1369
        [ADDR_LIMIT_3GB=`cat conftest1`
 
1370
        AC_MSG_RESULT([yes $ADDR_LIMIT_3GB])],
 
1371
        [ADDR_LIMIT_3GB=0
 
1372
        AC_MSG_RESULT([no])]
 
1373
        AC_DEFINE_UNQUOTED(ADDR_LIMIT_3GB,0,[only 3Gb of address space]))
 
1374
 
 
1375
   AC_MSG_CHECKING([for personality(ADDR_NO_RANDOMIZE) support])
 
1376
   AC_RUN_IFELSE([
 
1377
        AC_LANG_SOURCE([[
 
1378
                #include <stdio.h>
 
1379
                #include <stdlib.h>
 
1380
                void gprof_cleanup() {};
 
1381
                int main(int argc,char **argv,char **envp) {
 
1382
                #include "h/unrandomize.h"
 
1383
                return 0;}]])],
 
1384
        [AC_MSG_RESULT(yes)
 
1385
        AC_DEFINE(CAN_UNRANDOMIZE_SBRK,1,[can prevent sbrk from returning random values])],
 
1386
        [AC_MSG_RESULT(no)])
 
1387
 
 
1388
        AC_MSG_CHECKING([that sbrk is (now) non-random])
 
1389
        AC_TRY_RUN([#include <stdio.h>
 
1390
                    #include <stdlib.h>
 
1391
                    void gprof_cleanup() {};
 
1392
                    int main(int argc,char * argv[],char * envp[]) {
 
1393
                        FILE *f;
 
1394
                        #ifdef CAN_UNRANDOMIZE_SBRK
 
1395
                        #include "h/unrandomize.h"
 
1396
                        #endif
 
1397
                        if (!(f=fopen("conftest1","w"))) return -1;
 
1398
                        fprintf(f,"%u",sbrk(0));
 
1399
                        return 0;}],SBRK=`cat conftest1`,SBRK=0,SBRK=0)
 
1400
        if test "$SBRK" = "0" ; then
 
1401
                AC_MSG_RESULT(cannot trap sbrk)
 
1402
                exit 1
 
1403
        fi
 
1404
        AC_TRY_RUN([#include <stdio.h>
 
1405
                    #include <stdlib.h>
 
1406
                    void gprof_cleanup() {};
 
1407
                    int main(int argc,char * argv[],char * envp[]) {
 
1408
                        FILE *f;
 
1409
                        #ifdef CAN_UNRANDOMIZE_SBRK
 
1410
                        #include "h/unrandomize.h"
 
1411
                        #endif
 
1412
                        if (!(f=fopen("conftest1","w"))) return -1;
 
1413
                        fprintf(f,"%u",sbrk(0));
 
1414
                        return 0;}],SBRK1=`cat conftest1`,SBRK1=0,SBRK1=0)
 
1415
        if test "$SBRK1" = "0" ; then
 
1416
                AC_MSG_RESULT(cannot trap sbrk)
 
1417
                exit 1
 
1418
        fi
 
1419
        if test "$SBRK" = "$SBRK1" ; then
 
1420
                AC_MSG_RESULT(yes)
 
1421
        else
 
1422
                AC_MSG_RESULT(no)
 
1423
                echo "Cannot build with randomized sbrk. Your options:"
 
1424
                echo " - upgrade to a kernel/libc that knows about personality(ADDR_NO_RANDOMIZE)"
 
1425
                echo " - recompile your kernel with CONFIG_COMPAT_BRK (if it has that option)"
 
1426
                echo " - run sysctl kernel.randomize_va_space=0 before using gcl"
 
1427
                exit 1
 
1428
        fi
 
1429
fi
 
1430
 
 
1431
dnl AC_MSG_CHECKING(DBEGIN)
 
1432
dnl AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
1433
dnl   #include <stdio.h>
 
1434
dnl   #include <stdlib.h>
 
1435
dnl   #include <unistd.h>
 
1436
dnl   void gprof_cleanup() {};
 
1437
 
 
1438
dnl   int main(int argc,char **argv,char **envp) {
 
1439
 
 
1440
dnl   void *b;
 
1441
dnl   FILE *fp;
 
1442
 
 
1443
dnl   #ifdef CAN_UNRANDOMIZE_SBRK
 
1444
dnl   #include "h/unrandomize.h"
 
1445
dnl   #endif
 
1446
                        
 
1447
dnl   fp = fopen("conftest1","w");
 
1448
 
 
1449
dnl   #ifdef _WIN32
 
1450
dnl   fprintf ( fp,"0x%lx", 0x3000000 );  /* Windows custom allocation from this point up */
 
1451
dnl   #else
 
1452
dnl   #if defined (__APPLE__) && defined (__MACH__)
 
1453
dnl   fprintf(fp,"0x0");
 
1454
dnl   #else
 
1455
dnl   b = sbrk(0);
 
1456
dnl   fprintf(fp,"0x%lx",((unsigned long) b) & ~(unsigned long)((1<<PAGEWIDTH)-1));
 
1457
dnl   #endif
 
1458
dnl   #endif
 
1459
dnl   fclose(fp);
 
1460
dnl   return 0;}]])],
 
1461
dnl   [dbegin=`cat conftest1`],[dbegin=0])
 
1462
 
 
1463
dnl AC_MSG_RESULT($dbegin)
 
1464
 
 
1465
dnl AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
1466
dnl         #include <stdio.h>
 
1467
dnl             #include <unistd.h>
 
1468
dnl         ]],[[
 
1469
dnl         FILE *fp=fopen("conftest1","w");
 
1470
dnl         fprintf(fp,"%u",262144*( SIZEOF_LONG >>2)/(1<<($PAGEWIDTH-12)));
 
1471
dnl         return 0;]])],[def_maxpage=`cat conftest1`],[def_maxpage=262144])
 
1472
 
 
1473
dnl AC_ARG_ENABLE(maxpage,
 
1474
dnl [ --enable-maxpage=XXXX  will compile in a page table of size XXX
 
1475
dnl                          (eg '--enable-maxpage=64*1024' would produce
 
1476
dnl                      64K pages allowing 256 MB if pages are 4K each)],
 
1477
dnl ,enable_maxpage=$def_maxpage)
 
1478
 
 
1479
 
 
1480
AC_MSG_CHECKING(CSTACK_ADDRESS)
 
1481
AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
1482
        #include <stdio.h>
 
1483
        #include <stdlib.h>
 
1484
        void *
 
1485
        foo() {
 
1486
              int i;
 
1487
              return (void *)&i;
 
1488
        }
 
1489
 
 
1490
        void gprof_cleanup() {};
 
1491
        int main(int argc,char **argv,char **envp) {
 
1492
        void *v ;
 
1493
        FILE *fp = fopen("conftest1","w");
 
1494
        unsigned long i,j;
 
1495
 
 
1496
        #ifdef CAN_UNRANDOMIZE_SBRK
 
1497
        #include "h/unrandomize.h"
 
1498
        #endif
 
1499
        j=1;
 
1500
        j<<=$PAGEWIDTH;
 
1501
        j<<=16;
 
1502
        i=(unsigned long)&v;
 
1503
        if (foo()>i) i-=j;
 
1504
        j--;
 
1505
        i+=j;
 
1506
        i&=~j;
 
1507
        fprintf(fp,"0x%lx",i-1);
 
1508
        fclose(fp);
 
1509
        return 0;
 
1510
}]])],[cstack_address=`cat conftest1`],[cstack_address=0])
 
1511
AC_DEFINE_UNQUOTED(CSTACK_ADDRESS,$cstack_address,[starting C stack address])
 
1512
AC_MSG_RESULT($cstack_address)
 
1513
 
 
1514
AC_MSG_CHECKING([cstack bits])
 
1515
AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
1516
        #include <stdio.h>
 
1517
        #include <stdlib.h>
 
1518
        void *
 
1519
        foo() {
 
1520
              int i;
 
1521
              return (void *)&i;
 
1522
        }
 
1523
 
 
1524
        void gprof_cleanup() {};
 
1525
        int main(int argc,char **argv,char **envp) {
 
1526
        void *v ;
 
1527
        FILE *fp = fopen("conftest1","w");
 
1528
        unsigned long i,j;
 
1529
 
 
1530
        #ifdef CAN_UNRANDOMIZE_SBRK
 
1531
        #include "h/unrandomize.h"
 
1532
        #endif
 
1533
        j=1;
 
1534
        j<<=$PAGEWIDTH;
 
1535
        j<<=16;
 
1536
        i=(unsigned long)&v;
 
1537
        if (foo()>i) i-=j;
 
1538
        j--;
 
1539
        i+=j;
 
1540
        i&=~j;
 
1541
        for (j=0;(i>>j)!=(i>>(sizeof(long)*8-1));j++);
 
1542
        fprintf(fp,"%d",j);
 
1543
        fclose(fp);
 
1544
        return 0;
 
1545
}]])],[cstack_bits=`cat conftest1`],[cstack_bits=0])
 
1546
AC_DEFINE_UNQUOTED(CSTACK_BITS,$cstack_bits,[log starting C stack address])
 
1547
AC_MSG_RESULT($cstack_bits)
 
1548
 
 
1549
AC_MSG_CHECKING(NEG_CSTACK_ADDRESS)
 
1550
AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
1551
        #include <stdio.h>
 
1552
        #include <stdlib.h>
 
1553
        void gprof_cleanup() {};
 
1554
        int main(int argc,char **argv,char **envp) {
 
1555
        #ifdef CAN_UNRANDOMIZE_SBRK
 
1556
        #include "h/unrandomize.h"
 
1557
        #endif
 
1558
        return (long)$cstack_address<0 ? 0 : -1;
 
1559
}]])],[AC_MSG_RESULT(yes)
 
1560
        neg_cstack_address=1
 
1561
        AC_DEFINE(NEG_CSTACK_ADDRESS,1,[C stack address is negative])],
 
1562
      [AC_MSG_RESULT(no)
 
1563
        neg_cstack_address=0])
 
1564
 
 
1565
 
 
1566
AC_MSG_CHECKING([finding CSTACK_ALIGNMENT])
 
1567
AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
1568
        #include <stdio.h>
 
1569
        #include <stdlib.h>
 
1570
        void gprof_cleanup() {};
 
1571
        int main(int argc,char **argv,char **envp) {
 
1572
        void *b,*c;
 
1573
        FILE *fp = fopen("conftest1","w");
 
1574
        long n;
 
1575
        #ifdef CAN_UNRANDOMIZE_SBRK
 
1576
        #include "h/unrandomize.h"
 
1577
        #endif
 
1578
        b=alloca(sizeof(b));
 
1579
        c=alloca(sizeof(c));
 
1580
        n=b>c ? b-c : c-b;
 
1581
        n=n>sizeof(c) ? n : 1;
 
1582
        fprintf(fp,"%ld",n);
 
1583
        fclose(fp);
 
1584
        return 0;
 
1585
}]])],[cstack_alignment=`cat conftest1`],[cstack_alignment=0])
 
1586
AC_DEFINE_UNQUOTED(CSTACK_ALIGNMENT,$cstack_alignment,[C stack alignment])
 
1587
AC_MSG_RESULT($cstack_alignment)
 
1588
 
 
1589
AC_MSG_CHECKING(CSTACK_DIRECTION)
 
1590
AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
1591
        #include <stdio.h>
 
1592
        #include <stdlib.h>
 
1593
        void *
 
1594
        foo(void) {
 
1595
        int i;
 
1596
        return (void *)&i;
 
1597
        }
 
1598
 
 
1599
        void gprof_cleanup() {};
 
1600
        int main(int argc,char **argv,char **envp) {
 
1601
        char *b;
 
1602
        FILE *fp = fopen("conftest1","w");
 
1603
        #ifdef CAN_UNRANDOMIZE_SBRK
 
1604
        #include "h/unrandomize.h"
 
1605
        #endif
 
1606
        fprintf(fp,"%d",((long) &b) > ((long) foo()) ? -1 : 1);
 
1607
        fclose(fp);
 
1608
        return 0;
 
1609
}]])],[cstack_direction=`cat conftest1`],[cstack_direction=0])
 
1610
AC_DEFINE_UNQUOTED(CSTACK_DIRECTION,$cstack_direction,[whether C stack grows up or down])
 
1611
AC_MSG_RESULT($cstack_direction)
 
1612
 
 
1613
 
 
1614
dnl AC_MSG_CHECKING(for shared library/C stack ceiling to heap)
 
1615
dnl if test "$use" = "mingw" ; then
 
1616
dnl   heap_ceiling=2000000000
 
1617
dnl else
 
1618
dnl if test "$use" = "solaris-i386" ; then
 
1619
dnl   heap_ceiling=0x0
 
1620
dnl else
 
1621
dnl if test "$enable_static" = "yes" ; then
 
1622
dnl   heap_ceiling=0x0
 
1623
dnl else
 
1624
dnl if ! test -x `which ldd` && ! test -f /proc/self/maps ; then
 
1625
dnl    heap_ceiling=0x0
 
1626
dnl else
 
1627
dnl if test -f /proc/self/maps ; then
 
1628
dnl    heap_ceiling=0x`/bin/cat /proc/self/maps | grep "/lib.*/ld-" | cut -f1 -d- | head -1`
 
1629
dnl else 
 
1630
dnl if test "`which ldd`" = "" ; then 
 
1631
dnl    heap_ceiling=0x0
 
1632
dnl else
 
1633
dnl #echo -e "#include <stdio.h>\n int main() {printf(\"foo\");return 0;}" >foo.c
 
1634
dnl #$CC foo.c -o foo
 
1635
dnl    AAWK=`which awk`
 
1636
dnl # | grep -v ld-kfreebsd needed on some strange bsd amd64 boxes
 
1637
dnl    heap_ceiling=`ldd $AAWK | tail -n 1 | $AWK '{print $NF}' | tr -d '()'`
 
1638
dnl fi
 
1639
dnl fi
 
1640
dnl AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
1641
dnl     #include <stdio.h>
 
1642
dnl     ]],[[
 
1643
dnl     FILE *fp=fopen("conftest1","w");
 
1644
dnl     unsigned long h=$heap_ceiling,d=$dbegin,c=$cstack_address;
 
1645
dnl     h=h<d ? 0 : h;
 
1646
dnl     h=c>d && c<h ? c : h;
 
1647
dnl     fprintf(fp,"0x%lx",h);
 
1648
dnl     return 0;]])],[heap_ceiling=`cat conftest1`],[AC_MSG_ERROR([failed])])
 
1649
dnl fi
 
1650
dnl fi
 
1651
dnl fi
 
1652
dnl fi
 
1653
dnl AC_MSG_RESULT($heap_ceiling)
 
1654
dnl AC_DEFINE_UNQUOTED(SHARED_LIB_HEAP_CEILING,$heap_ceiling,
 
1655
dnl     [address at which shared lib placement terminates heap growth])
 
1656
 
 
1657
dnl ## Don't lower heap start if C stack is below default dbegin, as we're
 
1658
dnl # likely to get more heap this way.
 
1659
dnl if test "$enable_static" = "yes" ; then 
 
1660
dnl    echo "int main() {return !((unsigned long)$dbegin < (unsigned long)$cstack_address);}" >foo.c
 
1661
dnl else
 
1662
dnl    echo "int main() {return !($heap_ceiling && (unsigned long)$dbegin < (unsigned long)$cstack_address);}" >foo.c
 
1663
dnl fi
 
1664
dnl $CC foo.c -o foo
 
1665
dnl if ./foo ; then
 
1666
 
 
1667
if test "$use" != "386-gnu" ; then #hurd can push .data below C stack, but sbrk(0) remains above, foiling unexec
 
1668
 
 
1669
   AC_MSG_CHECKING([finding default linker script])
 
1670
   touch unixport/gcl.script
 
1671
   echo "int main() {return 0;}" >foo.c
 
1672
   $CC -Wl,--verbose foo.c -o foo 2>&1 | \
 
1673
       $AWK '/==================================================/ {i=1-i;next} {if (i) print}' >gcl.script
 
1674
   rm -rf foo.c foo
 
1675
 
 
1676
   if test "`cat gcl.script | wc -l`" != "0" ; then
 
1677
      AC_MSG_RESULT(got it)
 
1678
      AC_MSG_NOTICE([trying to adjust text start])
 
1679
      cp gcl.script gcl.script.def
 
1680
 
 
1681
      n=-1;
 
1682
      k=0;
 
1683
      lim=`$AWK 'END {printf("%d\n",m*8-2)}' m=$ac_cv_sizeof_long`;
 
1684
      max=0;
 
1685
      min=$lim;
 
1686
      while test $n -lt $lim ; do
 
1687
        j=`$AWK 'END {for (i=j=0;j<=n;j++) i=i ? i*2 : 1;printf("%x\n",3*i)}' n=$n </dev/null`
 
1688
        cat gcl.script.def | $AWK '/SIZEOF_HEADERS/ {gsub("0x[[0-9]]*","0x" j,$0);} {print}' j=$j >gcl.script
 
1689
#        diff -u gcl.script.def gcl.script
 
1690
        echo "int main() {return 0;}" >foo.c
 
1691
        if ( $CC -Wl,-T gcl.script foo.c -o foo && ./foo ) >/dev/null 2>&1 ; then
 
1692
         if test $n -lt $min ; then min=$n; fi; 
 
1693
         if test $n -gt $max; then max=$n; fi; 
 
1694
        elif test $max -gt 0 ; then
 
1695
         break;
 
1696
        fi;
 
1697
        n=`$AWK 'END {print n+1}' n=$n </dev/null`
 
1698
      done        
 
1699
 
 
1700
      AC_MSG_NOTICE([min log text start $min])
 
1701
      AC_MSG_NOTICE([max log text start $max])
 
1702
 
 
1703
      if test $neg_cstack_address -eq 1 ; then #FIXME test this
 
1704
         if test $cstack_bits -lt $max ; then
 
1705
            max=$cstack_bits;
 
1706
            AC_MSG_NOTICE([max log text start reduced to $max considering c stack address])
 
1707
         fi     
 
1708
      fi
 
1709
 
 
1710
      j=-1;
 
1711
      low_shft="";
 
1712
      if test $min -le $max ; then
 
1713
            if test $max -ge $enable_fastimmfix && test "$enable_immfix" = "yes" ; then
 
1714
                j=`$AWK 'END {for (i=j=0;j<=n;j++) i=i ? i*2 : 1;printf("%x\n",3*i)}' n=$max </dev/null`
 
1715
                low_shft=`$AWK 'END {print n+1}' n=$max </dev/null`;
 
1716
                AC_MSG_NOTICE([raising log text to $j for a $max bit wide low immfix table])
 
1717
            else                                        
 
1718
                j=`$AWK 'END {for (i=j=0;j<=n;j++) i=i ? i*2 : 1;printf("%x\n",3*i)}' n=$min </dev/null`
 
1719
                AC_MSG_NOTICE([lowering log text to $j to maximize data area])
 
1720
            fi
 
1721
      fi
 
1722
 
 
1723
      if test "$low_shft" != "" ; then
 
1724
            AC_DEFINE_UNQUOTED(LOW_SHFT,$low_shft,[upper immediate fixnum bound])        
 
1725
            AC_DEFINE_UNQUOTED(OBJNULL,(object)0x$j,[lowest address non-object])         
 
1726
      else                                 
 
1727
            AC_DEFINE_UNQUOTED(OBJNULL,NULL,[lowest address non-object])         
 
1728
      fi                                             
 
1729
 
 
1730
#      echo $j;
 
1731
      AC_MSG_CHECKING([our linker script])
 
1732
      if test "$j" -ne "-1" ; then
 
1733
            cat gcl.script.def | $AWK '/SIZEOF_HEADERS/ {gsub("0x[[0-9]]*","0x" j,$0);} {print}' j=$j >gcl.script
 
1734
            AC_MSG_RESULT([done])
 
1735
            rm -f gcl.script.def
 
1736
            LDFLAGS="$LDFLAGS -Wl,-T gcl.script "
 
1737
            cp gcl.script unixport
 
1738
      else
 
1739
         AC_MSG_RESULT([none found or not needed])
 
1740
         rm -f gcl.script gcl.script.def
 
1741
      fi
 
1742
      rm -rf foo.c foo
 
1743
  else
 
1744
      AC_MSG_RESULT([not found])
 
1745
  fi 
 
1746
 
 
1747
else
 
1748
 
 
1749
     AC_DEFINE_UNQUOTED(OBJNULL,NULL,[lowest address non-object])        
 
1750
 
 
1751
fi
 
1752
 
 
1753
   dnl old_LDFLAGS="$LDFLAGS"
 
1754
   dnl LDFLAGS="$LDFLAGS $TLDFLAGS"
 
1755
   dnl AC_MSG_CHECKING([revised DBEGIN])
 
1756
   dnl AC_RUN_IFELSE([AC_LANG_SOURCE([[
 
1757
   dnl  #include <stdio.h>
 
1758
   dnl  #include <stdlib.h>
 
1759
   dnl  #include <unistd.h>
 
1760
 
 
1761
   dnl  int main(int argc,char **argv,char **envp) {
 
1762
 
 
1763
   dnl      void *b;
 
1764
   dnl      FILE *fp;
 
1765
 
 
1766
   dnl      #ifdef CAN_UNRANDOMIZE_SBRK
 
1767
   dnl      #include "h/unrandomize.h"
 
1768
   dnl      #endif
 
1769
   dnl      fp = fopen("conftest1","w");
 
1770
 
 
1771
   dnl      #ifdef _WIN32
 
1772
   dnl      fprintf ( fp,"0x%lx", 0x1a000000 );  /* Windows custom allocation from this point up */
 
1773
   dnl      #else
 
1774
   dnl      #if defined (__APPLE__) && defined (__MACH__)
 
1775
   dnl      fprintf(fp,"((unsigned long)get_dbegin())");
 
1776
   dnl      #else
 
1777
   dnl      b = sbrk(0);
 
1778
   dnl      fprintf(fp,"0x%lx",((unsigned long) b) & ~(unsigned long)0xffffff);
 
1779
   dnl      #endif
 
1780
   dnl      #endif
 
1781
   dnl      fclose(fp);
 
1782
   dnl      return 0;}]])],[dbegin=`cat conftest1`],[dbegin=0])
 
1783
   dnl AC_MSG_RESULT($dbegin)
 
1784
   dnl LDFLAGS="$old_LDFLAGS"
 
1785
dnl fi
 
1786
dnl dnl AC_DEFINE_UNQUOTED(DBEGIN,$dbegin,[down-rounded beginning address of lisp data])
 
1787
dnl rm -rf foo*
 
1788
 
 
1789
dnl AC_MSG_CHECKING(for maxpage revision)
 
1790
dnl AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
1791
dnl     #include <stdio.h>
 
1792
dnl     ]],[[
 
1793
dnl     char *b;
 
1794
dnl     unsigned long i,j;
 
1795
dnl     FILE *fp = fopen("conftest1","w");
 
1796
dnl     j=((unsigned long)$enable_maxpage <<$PAGEWIDTH) + $dbegin;
 
1797
dnl     j=$heap_ceiling && j>$heap_ceiling ? $heap_ceiling : j;
 
1798
dnl     j-=$dbegin;
 
1799
dnl     /*  for (i=1;i<<1 && i<=j;i<<=1); */
 
1800
dnl     /*  if (i>j) i>>=1; */
 
1801
dnl     i=j;
 
1802
dnl     fprintf(fp,"%ld",i>>$PAGEWIDTH);
 
1803
dnl     fclose(fp);
 
1804
dnl     return 0;
 
1805
dnl ]])],[tmp_maxpage=`cat conftest1`],[tmp_maxpage=0])
 
1806
dnl if test "$tmp_maxpage" != "$enable_maxpage" ; then
 
1807
dnl    enable_maxpage=$tmp_maxpage
 
1808
dnl    AC_MSG_RESULT($enable_maxpage)
 
1809
dnl else
 
1810
dnl    AC_MSG_RESULT($enable_maxpage is OK)
 
1811
dnl fi
 
1812
dnl AC_DEFINE_UNQUOTED(MAXPAGE,$enable_maxpage,[maximum number of pages to be allocated])
 
1813
 
 
1814
dnl AC_MSG_CHECKING(for C stack size floor from heap)
 
1815
dnl AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
1816
dnl     #include <stdio.h>
 
1817
dnl     ]],[[
 
1818
dnl     char *b;
 
1819
dnl     FILE *fp = fopen("conftest1","w");
 
1820
dnl     unsigned long j,k;
 
1821
 
 
1822
dnl     j=$cstack_address + $cstack_direction * $enable_cssize;
 
1823
dnl     k=($dbegin + ((unsigned long)$enable_maxpage << $PAGEWIDTH));
 
1824
dnl     j=abs(j-$cstack_address)!=$enable_cssize || (j<k && $dbegin < $cstack_address) ? k : j;
 
1825
dnl     j-=$cstack_address;
 
1826
dnl     j*=$cstack_direction;
 
1827
dnl     fprintf(fp,"%lu",j);
 
1828
dnl     fclose(fp);
 
1829
dnl     return 0;
 
1830
dnl ]])],[tmp_cssize=`cat conftest1`],[tmp_cssize=0])
 
1831
dnl if test "$tmp_cssize" != "$enable_cssize" ; then
 
1832
dnl    enable_cssize=$tmp_cssize;
 
1833
dnl    AC_MSG_RESULT($enable_cssize)
 
1834
dnl else
 
1835
dnl    AC_MSG_RESULT($enable_cssize is OK)
 
1836
dnl fi
 
1837
 
 
1838
dnl AC_MSG_CHECKING(for C stack size limit from fixnum table)
 
1839
dnl AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
1840
dnl     #include <stdio.h>
 
1841
dnl     ]],[[
 
1842
dnl     char *b;
 
1843
dnl     FILE *fp = fopen("conftest1","w");
 
1844
dnl     unsigned long j,k;
 
1845
 
 
1846
dnl     j=$cstack_address + $cstack_direction * $enable_cssize;
 
1847
dnl     if ($cstack_direction>0) {
 
1848
dnl       k=$cstack_address + ((-(unsigned long)$cstack_address)>>1);
 
1849
dnl       j=j<$cstack_address || j > k ? k : j;
 
1850
dnl       j=$cstack_address < $dbegin && j > $dbegin ? $dbegin : j;
 
1851
dnl     }
 
1852
dnl     j-=$cstack_address;
 
1853
dnl     j*=$cstack_direction;
 
1854
dnl     fprintf(fp,"%lu",j);
 
1855
dnl     fclose(fp);
 
1856
dnl     return 0;
 
1857
dnl ]])],[tmp_cssize=`cat conftest1`],[tmp_cssize=0])
 
1858
dnl if test "$tmp_cssize" != "$enable_cssize" ; then
 
1859
dnl    enable_cssize=$tmp_cssize;
 
1860
dnl    AC_MSG_RESULT($enable_cssize)
 
1861
dnl else
 
1862
dnl    AC_MSG_RESULT($enable_cssize is OK)
 
1863
dnl fi
 
1864
 
 
1865
dnl AC_MSG_CHECKING(for C stack size limit from address wrap)
 
1866
dnl AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
1867
dnl     #include <stdio.h>
 
1868
dnl     ]],[[
 
1869
dnl     char *b;
 
1870
dnl     FILE *fp = fopen("conftest1","w");
 
1871
dnl     unsigned long j,k;
 
1872
 
 
1873
dnl     j=-$cstack_address * $cstack_direction;
 
1874
dnl     j=j>$enable_cssize ? $enable_cssize : j;
 
1875
dnl     fprintf(fp,"%lu",j);
 
1876
dnl     fclose(fp);
 
1877
dnl     return 0;
 
1878
dnl ]])],[tmp_cssize=`cat conftest1`],[tmp_cssize=0])
 
1879
dnl if test "$tmp_cssize" != "$enable_cssize" ; then
 
1880
dnl    enable_cssize=$tmp_cssize;
 
1881
dnl    AC_MSG_RESULT($enable_cssize)
 
1882
dnl else
 
1883
dnl    AC_MSG_RESULT($enable_cssize is OK)
 
1884
dnl fi
 
1885
dnl AC_DEFINE_UNQUOTED(CSSIZE,$enable_cssize,[maximum C stack size])
 
1886
 
 
1887
dnl AC_MSG_CHECKING(for fast NULL_OR_ON_CSTACK macro)
 
1888
dnl AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
1889
dnl     #include <stdio.h>
 
1890
dnl     ]],[[
 
1891
dnl     return ((long)$dbegin>=0 &&
 
1892
dnl            ((long)$dbegin+(long)($enable_maxpage<<$PAGEWIDTH)) >=0 &&
 
1893
dnl            ((long)$cstack_address<0)) ? 0 : 1;
 
1894
dnl ]])],[tmp_fnocm=yes],[tmp_fnocm=no])
 
1895
dnl if test "$tmp_fnocm" = "yes" ; then
 
1896
dnl    AC_MSG_RESULT(yes)
 
1897
dnl    AC_DEFINE(USE_FAST_NULL_OR_ON_CSTACK_MACRO,1,[whether one instruction heap address check can be used])
 
1898
dnl else
 
1899
dnl    AC_MSG_RESULT(no)
 
1900
dnl fi
 
1901
 
 
1902
mem_top=0
 
1903
mem_range=0
 
1904
AC_MSG_CHECKING(mem top)
 
1905
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
1906
        #include <stdio.h>
 
1907
        ]],[[
 
1908
        void *v;
 
1909
        unsigned long i,j,k,l,m;
 
1910
        FILE *fp = fopen("conftest1","w");
 
1911
 
 
1912
        for (i=2,k=1;i;k=i,i<<=1);
 
1913
        l=$cstack_address;
 
1914
        l=$cstack_direction==1 ? (l<k ? k-1 : -1) : l;
 
1915
        for (i=j=k;j && i<l;j>>=1,i|=j);
 
1916
        if (j<(k>>3)) i=0;
 
1917
        j=1;
 
1918
        j<<=$PAGEWIDTH;
 
1919
        j<<=4;
 
1920
        j--;
 
1921
        i+=j;
 
1922
        i&=~j;
 
1923
        fprintf(fp,"0x%lx",i);
 
1924
        fclose(fp);
 
1925
        return 0;
 
1926
]])],[mem_top=`cat conftest1`],[mem_top="0x0"])
 
1927
AC_MSG_RESULT($mem_top)
 
1928
if test "$mem_top" != "0x0" ; then
 
1929
   AC_MSG_CHECKING(finding upper mem half range)
 
1930
   AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
1931
   #include <stdio.h>
 
1932
   ]],[[
 
1933
   unsigned long j;
 
1934
   FILE *fp = fopen("conftest1","w");
 
1935
 
 
1936
   for (j=1;j && !(j& $mem_top);j<<=1);
 
1937
   fprintf(fp,"0x%lx",j>>1);
 
1938
   fclose(fp);
 
1939
   return 0;
 
1940
   ]])],[mem_range=`cat conftest1`],[mem_range="0x0"])
 
1941
   AC_MSG_RESULT($mem_range)
 
1942
   if test "$mem_range" != "0x0" ; then 
 
1943
        AC_DEFINE_UNQUOTED(MEM_TOP,$mem_top,[beginning address for immediate fixnum range])
 
1944
        AC_DEFINE_UNQUOTED(MEM_RANGE,$mem_range,[size of immediate fixnum address space])
 
1945
   fi
 
1946
fi
 
1947
 
 
1948
if test "$enable_immfix" = "yes" ; then
 
1949
  if test "$mem_top" != "0x0" ; then
 
1950
     if test "$mem_range" != "0x0" ; then 
 
1951
        AC_DEFINE_UNQUOTED(IM_FIX_BASE,$mem_top,[beginning address for immediate fixnum range])
 
1952
        AC_DEFINE_UNQUOTED(IM_FIX_LIM,$mem_range,[size of immediate fixnum address space])
 
1953
     fi
 
1954
  fi
 
1955
fi
 
1956
 
 
1957
 
 
1958
dnl AC_MSG_CHECKING(for word order)
 
1959
dnl AC_TRY_RUN([int main () {
 
1960
dnl   /* Are we little or big endian?  Adapted from Harbison&Steele.  */
 
1961
dnl   union
 
1962
dnl   {
 
1963
dnl     double d;
 
1964
dnl     int l[sizeof(double)/sizeof(int)];
 
1965
dnl   } u;
 
1966
dnl   u.d = 1.0;
 
1967
dnl   return u.l[sizeof(double)/sizeof(int)-1] ? 0 : 1;
 
1968
dnl }],AC_MSG_RESULT(little) 
 
1969
dnl    AC_DEFINE(LITTLE_END),
 
1970
dnl    AC_MSG_RESULT(big),
 
1971
dnl    AC_MSG_RESULT([WARNING: ASSUMING LITTLE ENDIAN FOR CROSS COMPILING !!!]
 
1972
dnl    AC_DEFINE(LITTLE_END)))
 
1973
dnl AC_SUBST(LITTLE_END)
 
1974
 
 
1975
 
 
1976
# On systems with execshield, brk is randomized.  We need to catch
 
1977
# this and restore the traditional behavior here
 
1978
 
 
1979
dnl old_LDFLAGS="$LDFLAGS"
 
1980
dnl LDFLAGS="$TLDFLAGS"
 
1981
dnl AC_MSG_CHECKING("finding DBEGIN")
 
1982
dnl AC_TRY_RUN([#include <stdio.h>
 
1983
dnl             #include <stdlib.h>
 
1984
 
 
1985
dnl void gprof_cleanup() {};
 
1986
dnl int
 
1987
dnl main(int argc,char * argv[],char *envp[])
 
1988
dnl {
 
1989
dnl   char *b,*b1;
 
1990
dnl   FILE *fp;
 
1991
 
 
1992
dnl #ifdef CAN_UNRANDOMIZE_SBRK
 
1993
dnl #include "h/unrandomize.h"
 
1994
dnl #endif
 
1995
dnl   b = (void *) malloc(1000);
 
1996
dnl   fp = fopen("conftest1","w");
 
1997
 
 
1998
dnl #ifdef _WIN32
 
1999
dnl   fprintf(fp,"_dbegin");
 
2000
dnl #else
 
2001
dnl #if defined (__APPLE__) && defined (__MACH__)
 
2002
dnl   fprintf(fp,"mach_mapstart");
 
2003
dnl #else
 
2004
dnl   b1=((unsigned long) b) & ~(unsigned long)0xffffff;b=(void *)b1<(void *)&b1 && (void *)b>(void *)&b ? ((unsigned long) b) & ~(unsigned long)((1<<PAGEWIDTH)-1) : b1;
 
2005
dnl   fprintf(fp,"0x%lx",b);
 
2006
dnl #endif
 
2007
dnl #endif
 
2008
dnl   fclose(fp);
 
2009
dnl   return 0;
 
2010
dnl }],dbegin=`cat conftest1`,dbegin=0,dbegin=0)
 
2011
dnl AC_DEFINE_UNQUOTED(DBEGIN,$dbegin /* where data begins */)
 
2012
dnl AC_MSG_RESULT(got $dbegin)
 
2013
dnl LDFLAGS="$old_LDFLAGS"
 
2014
 
 
2015
 
 
2016
dnl AC_MSG_CHECKING("finding CSTACK_ADDRESS")
 
2017
dnl AC_TRY_RUN([#include <stdio.h>
 
2018
dnl main()
 
2019
dnl {
 
2020
dnl   char *b ;
 
2021
dnl   FILE *fp = fopen("conftest1","w");
 
2022
dnl   fprintf(fp,"%ld",((long) &b));
 
2023
dnl   fclose(fp);
 
2024
dnl   return 0;
 
2025
dnl }],cstack_address=`cat conftest1`,cstack_address=0,cstack_address=0)
 
2026
dnl AC_DEFINE_UNQUOTED(CSTACK_ADDRESS,$cstack_address \
 
2027
dnl )
 
2028
dnl AC_MSG_RESULT(got $cstack_address)
 
2029
 
 
2030
 
 
2031
 
 
2032
AC_MSG_CHECKING([sizeof long long int])
 
2033
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
2034
        #include <stdio.h>
 
2035
        ]],[[
 
2036
        if (sizeof(long long int) == 2*sizeof(long)) return 0;
 
2037
        return 1;
 
2038
]])],[AC_DEFINE(HAVE_LONG_LONG,1,[long long is available]) AC_MSG_RESULT(yes)],
 
2039
    [AC_MSG_RESULT(no)])
 
2040
 
 
2041
AC_SUBST(HAVE_LONG_LONG)
 
2042
 
 
2043
# readline
 
2044
AC_ARG_ENABLE(readline,
 
2045
        [--enable-readline    enables command line completion via the readline library ],,
 
2046
        enable_readline="yes")
 
2047
 
 
2048
# ansi lisp
 
2049
AC_ARG_ENABLE(ansi,[--enable-ansi builds a large gcl aiming for ansi compliance, 
 
2050
                    --disable-ansi builds the smaller traditional CLtL1 image],,enable_ansi="no")
 
2051
 
 
2052
if test "$enable_ansi" = "yes" ; then
 
2053
        SYSTEM=ansi_gcl
 
2054
        AC_DEFINE(ANSI_COMMON_LISP,1,[compile ansi compliant image])
 
2055
        CLSTANDARD=ANSI
 
2056
else
 
2057
        SYSTEM=gcl
 
2058
        CLSTANDARD=CLtL1
 
2059
fi
 
2060
 
 
2061
FLISP="saved_$SYSTEM"
 
2062
AC_SUBST(FLISP)
 
2063
AC_SUBST(SYSTEM)
 
2064
AC_SUBST(CLSTANDARD)
 
2065
 
 
2066
# Maximum number of pages
 
2067
 
 
2068
 
 
2069
 
 
2070
# Check if Posix compliant getcwd exists, if not we'll use getwd.
 
2071
AC_CHECK_FUNCS(getcwd)
 
2072
AC_CHECK_FUNCS(getwd)
 
2073
AC_CHECK_FUNC(uname, , AC_DEFINE(NO_UNAME,1,[no uname call]))
 
2074
AC_CHECK_FUNC(gettimeofday, , AC_DEFINE(NO_GETTOD))
 
2075
 
 
2076
 
 
2077
AC_CHECK_HEADERS(sys/ioctl.h)
 
2078
 
 
2079
# OpenBSD has elf_abi.h instead of elf.h
 
2080
AC_CHECK_HEADERS(elf.h elf_abi.h)
 
2081
 
 
2082
AC_CHECK_HEADERS(sys/sockio.h)
 
2083
 
 
2084
 
 
2085
#--------------------------------------------------------------------
 
2086
#       The code below deals with several issues related to gettimeofday:
 
2087
#       1. Some systems don't provide a gettimeofday function at all
 
2088
#          (set NO_GETTOD if this is the case).
 
2089
#       2. SGI systems don't use the BSD form of the gettimeofday function,
 
2090
#          but they have a BSDgettimeofday function that can be used instead.
 
2091
#       3. See if gettimeofday is declared in the <sys/time.h> header file.
 
2092
#          if not, set the GETTOD_NOT_DECLARED flag so that tclPort.h can
 
2093
#          declare it.
 
2094
#--------------------------------------------------------------------
 
2095
 
 
2096
AC_CHECK_FUNC([BSDgettimeofday],
 
2097
              [AC_DEFINE(HAVE_BSDGETTIMEOFDAY,1,[have bsdgettimeofday])],
 
2098
              [AC_CHECK_FUNC([gettimeofday], ,
 
2099
                             [AC_DEFINE([NO_GETTOD],1,[no gettimeofday call])])])
 
2100
 
 
2101
AC_MSG_CHECKING([for gettimeofday declaration])
 
2102
 
 
2103
AC_EGREP_HEADER([gettimeofday],
 
2104
                [sys/time.h],
 
2105
                [AC_MSG_RESULT([present])],
 
2106
                [AC_MSG_RESULT([missing])
 
2107
                AC_DEFINE(GETTOD_NOT_DECLARED,1,[No gettimeofday call -- fixme])])
 
2108
 
 
2109
 
 
2110
AC_CHECK_LIB(m,sin,LIBS="${LIBS} -lm",true)
 
2111
AC_CHECK_LIB(mingwex,main,LIBS="${LIBS} -lmingwex",true)
 
2112
 
 
2113
EXTRA_LOBJS=
 
2114
if test "$try_japi" = "yes" ; then
 
2115
   AC_CHECK_HEADERS(japi.h,[AC_DEFINE(HAVE_JAPI_H)
 
2116
                                 EXTRA_LOBJS="${EXTRA_LOBJS} gcl_japi.o"
 
2117
                                 LIBS="${LIBS} -ljapi -lwsock32"] )
 
2118
fi
 
2119
dnl if test "$use" = "mingw" ; then
 
2120
dnl  if test "$try_xdr" = "yes" ; then
 
2121
dnl    AC_CHECK_HEADERS(rpc/rpc.h,[AC_DEFINE(HAVE_XDR)
 
2122
dnl                              LIBS="${LIBS} -loncrpc"] )
 
2123
dnl  fi
 
2124
dnl else
 
2125
dnl  if test "$try_xdr" = "yes" ; then
 
2126
dnl    AC_CHECK_HEADERS(rpc/rpc.h,[AC_DEFINE(HAVE_XDR)
 
2127
dnl                              LIBS="${LIBS} -lrpc"] )
 
2128
dnl  fi
 
2129
dnl fi
 
2130
 
 
2131
# Should really find a way to check for prototypes, but this 
 
2132
# basically works for now.  CM
 
2133
#
 
2134
AC_CHECK_HEADERS(math.h,AC_DEFINE(HAVE_MATH_H,1,[have math.h]))
 
2135
AC_CHECK_HEADERS(complex.h,AC_DEFINE(HAVE_COMPLEX_H,1,[have complex.h]))
 
2136
 
 
2137
#
 
2138
# For DBL_MAX et. al. on (only) certain Linux arches, apparently CM
 
2139
#
 
2140
AC_CHECK_HEADERS(values.h,AC_DEFINE(HAVE_VALUES_H,1,[have values.h]))
 
2141
 
 
2142
#
 
2143
# Sparc solaris keeps this in float.h, rework either/or with values.h later
 
2144
#
 
2145
AC_CHECK_HEADERS(float.h,AC_DEFINE(HAVE_FLOAT_H,1,[have float.h]))
 
2146
 
 
2147
#
 
2148
# The second alternative is for solaris.  This needs to be
 
2149
# a more comprehensive later, i.e. checking that the fpclass
 
2150
# test makes sense.  CM
 
2151
#
 
2152
AC_MSG_CHECKING([for isnormal])
 
2153
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
2154
            #define _GNU_SOURCE
 
2155
            #include <math.h>
 
2156
            ]],[[
 
2157
            float f;
 
2158
            return isnormal(f) || !isnormal(f) ? 0 : 1;
 
2159
            ]])],
 
2160
                [AC_DEFINE(HAVE_ISNORMAL,1,[Have isnormal function]) AC_MSG_RESULT(yes)],
 
2161
                [AC_MSG_CHECKING([for fpclass in ieeefp.h])
 
2162
                 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
2163
                        #include <ieeefp.h>
 
2164
                        ]],[[
 
2165
                        float f;
 
2166
                        return fpclass(f)>=FP_NZERO || fpclass(f)<FP_NZERO ? 0 : 1;
 
2167
                        ]])],[AC_DEFINE(HAVE_IEEEFP,1,[Have ieeefp fpclass function]) AC_MSG_RESULT(yes)],
 
2168
                             [AC_MSG_RESULT(no)])])
 
2169
 
 
2170
AC_MSG_CHECKING([for isfinite])
 
2171
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
2172
        #define _GNU_SOURCE
 
2173
        #include <math.h>
 
2174
        ]],[[
 
2175
        float f;
 
2176
        return isfinite(f) || !isfinite(f) ? 0 : 1;
 
2177
        ]])],[AC_DEFINE(HAVE_ISFINITE,1,[Have isfinite function]) AC_MSG_RESULT(yes)],
 
2178
             [AC_MSG_CHECKING([for finite()])
 
2179
              AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
2180
                #include <math.h>
 
2181
                #include <ieeefp.h>
 
2182
                ]],[[
 
2183
                float f;
 
2184
                return finite(f) || !finite(f) ? 0 : 1;
 
2185
                ]])],[AC_DEFINE(HAVE_FINITE,1,[Have finite function]) AC_MSG_RESULT(yes)],
 
2186
                     [AC_MSG_ERROR(no)])])
 
2187
 
 
2188
dnl AC_MSG_CHECKING([for INFINITY])
 
2189
dnl AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
2190
dnl         #define _GNU_SOURCE
 
2191
dnl     #include <math.h>
 
2192
dnl     ]],[[
 
2193
dnl     double d=INFINITY;
 
2194
dnl     return 0;
 
2195
dnl     ]])],[AC_MSG_RESULT(yes)],
 
2196
dnl         [AC_MSG_CHECKING([for builtin_inf()])
 
2197
dnl         AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
2198
dnl             #include <math.h>
 
2199
dnl             #include <ieeefp.h>
 
2200
dnl             ]],[[
 
2201
dnl             double d=__builtin_inf();
 
2202
dnl             return 0;
 
2203
dnl             ]])],[AC_DEFINE_UNQUOTED(INFINITY,__builtin_inf(),[Have builtin_inf]) AC_MSG_RESULT(yes)],
 
2204
dnl                 [AC_MSG_ERROR(no)])])
 
2205
 
 
2206
dnl AC_MSG_CHECKING([for NAN])
 
2207
dnl AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
2208
dnl         #define _GNU_SOURCE
 
2209
dnl     #include <math.h>
 
2210
dnl     ]],[[
 
2211
dnl     double d=NAN;
 
2212
dnl     return 0;
 
2213
dnl     ]])],[AC_MSG_RESULT(yes)],
 
2214
dnl         [AC_MSG_CHECKING([for builtin_nan()])
 
2215
dnl         AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
2216
dnl             #include <math.h>
 
2217
dnl             #include <ieeefp.h>
 
2218
dnl             ]],[[
 
2219
dnl             double d=__builtin_nan("0x0");
 
2220
dnl             return 0;
 
2221
dnl             ]])],[AC_DEFINE_UNQUOTED(NAN,__builtin_nan("0x0"),[Have builtin_nan]) AC_MSG_RESULT(yes)],
 
2222
dnl                 [AC_MSG_ERROR(no)])])
 
2223
 
 
2224
#--------------------------------------------------------------------
 
2225
#       Check for the existence of the -lsocket and -lnsl libraries.
 
2226
#       The order here is important, so that they end up in the right
 
2227
#       order in the command line generated by make.  Here are some
 
2228
#       special considerations:
 
2229
#       1. Use "connect" and "accept" to check for -lsocket, and
 
2230
#          "gethostbyname" to check for -lnsl.
 
2231
#       2. Use each function name only once:  can't redo a check because
 
2232
#          autoconf caches the results of the last check and won't redo it.
 
2233
#       3. Use -lnsl and -lsocket only if they supply procedures that
 
2234
#          aren't already present in the normal libraries.  This is because
 
2235
#          IRIX 5.2 has libraries, but they aren't needed and they're
 
2236
#          bogus:  they goof up name resolution if used.
 
2237
#       4. On some SVR4 systems, can't use -lsocket without -lnsl too.
 
2238
#          To get around this problem, check for both libraries together
 
2239
#          if -lsocket doesn't work by itself.
 
2240
#--------------------------------------------------------------------
 
2241
AC_MSG_CHECKING([for sockets])
 
2242
tcl_checkBoth=0
 
2243
AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
 
2244
if test "$tcl_checkSocket" = 1; then
 
2245
    AC_CHECK_LIB(socket, main, TLIBS="$TLIBS -lsocket", tcl_checkBoth=1)
 
2246
fi
 
2247
 
 
2248
 
 
2249
if test "$tcl_checkBoth" = 1; then
 
2250
    tk_oldLibs=$TLIBS
 
2251
    TLIBS="$TLIBS -lsocket -lnsl"
 
2252
    AC_CHECK_FUNC(accept, tcl_checkNsl=0, [TLIBS=$tk_oldLibs])
 
2253
fi
 
2254
AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [TLIBS="$TLIBS -lnsl"]))
 
2255
 
 
2256
RL_OBJS=""
 
2257
RL_LIB=""
 
2258
if test "$enable_readline" = "yes" ; then
 
2259
        AC_CHECK_HEADERS(readline/readline.h,
 
2260
                AC_CHECK_LIB(readline,rl_initialize,
 
2261
                        AC_DEFINE(HAVE_READLINE,1,[have readline library]) 
 
2262
                        TLIBS="$TLIBS -lreadline" #some machines don't link this, e.g. Slackware
 
2263
                        RL_OBJS=gcl_readline.o
 
2264
# Readline support now initialized automatically when compiled in, this lisp
 
2265
# object no longer needed -- 20040102 CM
 
2266
#                       RL_LIB=lsp/gcl_readline.o
 
2267
                        ))
 
2268
 
 
2269
# These tests discover differences between readline 4.1 and 4.3
 
2270
        AC_CHECK_LIB(readline,rl_completion_matches,
 
2271
                        AC_DEFINE(HAVE_DECL_RL_COMPLETION_MATCHES,1,[have readline completion matches])
 
2272
                        AC_DEFINE(HAVE_RL_COMPENTRY_FUNC_T,1,[have readline completion matches]),,)
 
2273
fi
 
2274
 
 
2275
AC_SUBST(RL_OBJS)
 
2276
AC_SUBST(RL_LIB)
 
2277
 
 
2278
AC_MSG_CHECKING(For network code for nsocket.c)
 
2279
AC_TRY_LINK([
 
2280
#include <sys/time.h>
 
2281
#include <sys/types.h>
 
2282
#include <unistd.h>
 
2283
 
 
2284
#include <errno.h>
 
2285
#include <fcntl.h>
 
2286
#include <stdio.h>
 
2287
 
 
2288
/************* for the sockets ******************/ 
 
2289
#include <sys/socket.h>         /* struct sockaddr, SOCK_STREAM, ... */
 
2290
#ifndef NO_UNAME
 
2291
#   include <sys/utsname.h>     /* uname system call. */
 
2292
#endif
 
2293
#include <netinet/in.h>         /* struct in_addr, struct sockaddr_in */
 
2294
#include <arpa/inet.h>          /* inet_ntoa() */
 
2295
#include <netdb.h>              /* gethostbyname() */
 
2296
],[ connect(0,(struct sockaddr *)0,0);
 
2297
    gethostbyname("jil");
 
2298
    socket(AF_INET, SOCK_STREAM, 0);
 
2299
        ],
 
2300
[AC_DEFINE(HAVE_NSOCKET,1,[can use nsocket library])
 
2301
 AC_MSG_RESULT(yes)],
 
2302
AC_MSG_RESULT(no))
 
2303
 
 
2304
 
 
2305
AC_MSG_CHECKING(check for listen using fcntl)
 
2306
AC_TRY_COMPILE([#include <stdio.h>
 
2307
#include <fcntl.h>
 
2308
],
 
2309
[FILE *fp=fopen("configure.in","r");
 
2310
  int orig;
 
2311
  orig = fcntl(fileno(fp), F_GETFL);
 
2312
  if (! (orig & O_NONBLOCK )) return 0;
 
2313
],
 
2314
[AC_DEFINE(LISTEN_USE_FCNTL,1,[can use fcntl for listen function])
 
2315
 AC_MSG_RESULT(yes)],
 
2316
AC_MSG_RESULT(no))
 
2317
 
 
2318
 
 
2319
 
 
2320
 
 
2321
AC_CHECK_FUNC(profil, ,[AC_DEFINE(NO_PROFILE,1,[no profil system call])])
 
2322
AC_SUBST(NO_PROFILE)
 
2323
AC_CHECK_FUNC(setenv,[AC_DEFINE(HAVE_SETENV,1,[have setenv call])],no_setenv=1 )
 
2324
AC_SUBST(HAVE_SETENV)
 
2325
if test "$no_setenv" = "1" ; then
 
2326
AC_CHECK_FUNC(putenv,[AC_DEFINE(HAVE_PUTENV,1,[have putenv call])],)
 
2327
AC_SUBST(HAVE_PUTENV)
 
2328
fi
 
2329
 
 
2330
AC_CHECK_FUNC(_cleanup, [AC_DEFINE(USE_CLEANUP,1,[have _cleanup function])],)
 
2331
AC_SUBST(USE_CLEANUP)
 
2332
gcl_ok=no
 
2333
 
 
2334
dnl AC_HEADER_EGREP(LITTLE_ENDIAN, ctype.h, gcl_ok=yes, gcl_ok=noo)
 
2335
dnl if test $gcl_ok = yes ; then
 
2336
dnl AC_DEFINE(ENDIAN_ALREADY_DEFINED)
 
2337
dnl fi
 
2338
 
 
2339
dnl AC_SUBST(ENDIAN_ALREADY_DEFINED)
 
2340
 
 
2341
 
 
2342
 
 
2343
 
 
2344
# if test "x$enable_machine" = "x" ; then
 
2345
AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])
 
2346
 
 
2347
case $system in
 
2348
       OSF*)
 
2349
        AC_DEFINE(USE_FIONBIO,1,[use fionbio for non-blocking io])
 
2350
        AC_MSG_RESULT(FIONBIO)
 
2351
        ;;
 
2352
    SunOS-4*)
 
2353
        AC_DEFINE(USE_FIONBIO,1,[use fionbio for non-blocking io])
 
2354
        AC_MSG_RESULT(FIONBIO)
 
2355
        ;;
 
2356
    ULTRIX-4.*)
 
2357
        AC_DEFINE(USE_FIONBIO,1,[use fionbio for non-blocking io])
 
2358
        AC_MSG_RESULT(FIONBIO)
 
2359
        ;;
 
2360
    *)
 
2361
        AC_MSG_RESULT(O_NONBLOCK)
 
2362
        ;;
 
2363
esac
 
2364
 
 
2365
 
 
2366
AC_MSG_CHECKING(check for SV_ONSTACK)
 
2367
AC_TRY_COMPILE([#include <signal.h>
 
2368
int joe=SV_ONSTACK;
 
2369
],
 
2370
[],
 
2371
[AC_DEFINE(HAVE_SV_ONSTACK,1,[have sv_onstack])
 
2372
 AC_SUBST(HAVE_SV_ONSTACK)
 
2373
 AC_MSG_RESULT(yes)],
 
2374
AC_MSG_RESULT(no))
 
2375
 
 
2376
AC_MSG_CHECKING(check for SIGSYS)
 
2377
AC_TRY_COMPILE([#include <signal.h>
 
2378
int joe=SIGSYS;
 
2379
],
 
2380
[],
 
2381
[AC_DEFINE(HAVE_SIGSYS,1,[have SIGSYS signal])
 
2382
 AC_SUBST(HAVE_SIGSYS)
 
2383
 AC_MSG_RESULT(yes)],
 
2384
AC_MSG_RESULT(no))
 
2385
 
 
2386
 
 
2387
AC_MSG_CHECKING(check for SIGEMT)
 
2388
AC_TRY_COMPILE([#include <signal.h>
 
2389
int joe=SIGEMT;
 
2390
],
 
2391
[],
 
2392
[AC_DEFINE(HAVE_SIGEMT,1,[have SIGEMT signal])
 
2393
 AC_SUBST(HAVE_SIGEMT)
 
2394
 AC_MSG_RESULT(yes)],
 
2395
AC_MSG_RESULT(no))
 
2396
 
 
2397
 
 
2398
 
 
2399
 
 
2400
#if test $use = "386-linux" ; then
 
2401
        AC_CHECK_HEADERS(asm/sigcontext.h)
 
2402
        AC_CHECK_HEADERS(asm/signal.h)
 
2403
        AC_MSG_CHECKING([for sigcontext...])
 
2404
        AC_TRY_COMPILE([#include <signal.h>
 
2405
       ],
 
2406
       [
 
2407
        struct sigcontext foo;
 
2408
       ],
 
2409
       [
 
2410
        sigcontext_works=1;
 
2411
        AC_DEFINE(SIGNAL_H_HAS_SIGCONTEXT,1,[have sigcontext in signal.h])
 
2412
        AC_MSG_RESULT(sigcontext in signal.h)
 
2413
       ],
 
2414
        
 
2415
        [sigcontext_works=0;
 
2416
         AC_MSG_RESULT(sigcontext NOT in signal.h)]
 
2417
       )
 
2418
       if test "$sigcontext_works" = 0 ; then
 
2419
       AC_MSG_CHECKING([for sigcontext...])
 
2420
       AC_TRY_COMPILE([#include <signal.h>
 
2421
             #ifdef HAVE_ASM_SIGCONTEXT_H     
 
2422
             #include <asm/sigcontext.h>
 
2423
             #endif
 
2424
             #ifdef HAVE_ASM_SIGNAL_H          
 
2425
             #include <asm/signal.h>
 
2426
             #endif
 
2427
          ],
 
2428
        [ 
 
2429
        struct sigcontext foo;
 
2430
        ],
 
2431
        [
 
2432
        AC_DEFINE(HAVE_SIGCONTEXT,1,[have sigcontext])
 
2433
        AC_MSG_RESULT(sigcontext in asm files)
 
2434
        ],
 
2435
        [
 
2436
        AC_MSG_RESULT(no sigcontext found)
 
2437
     ])
 
2438
 
 
2439
 
 
2440
       fi
 
2441
#       echo 'foo() {}' > conftest1.c
 
2442
#       $CC -S conftest1.c
 
2443
#       use_underscore=0        
 
2444
#       if fgrep _foo conftest1.s ; then use_underscore=1 ; fi
 
2445
#       if test $use_underscore = 0 ; then
 
2446
#            MPI_FILE=mpi-386_no_under.o
 
2447
#          else
 
2448
#            MPI_FILE=mpi-386d.o
 
2449
#        fi
 
2450
#       AC_SUBST(MPI_FILE)
 
2451
#       GCC=$CC
 
2452
#        if test -x  /usr/bin/i386-glibc20-linux-gcc ; then
 
2453
#          GCC=/usr/bin/i386-glibc20-linux-gcc
 
2454
#       fi
 
2455
#       AC_SUBST(GCC)
 
2456
 
 
2457
#fi
 
2458
 
 
2459
AC_PATH_PROG(EMACS,emacs)
 
2460
 
 
2461
 
 
2462
# check for where the emacs site lisp directory is.
 
2463
rm -f conftest.el
 
2464
cat >> conftest.el <<EOF
 
2465
(let ((ans ".") (tem load-path) cur)
 
2466
 (while (setq cur (car tem))
 
2467
   (setq tem (cdr tem))
 
2468
   (cond ((and (string-match "site-lisp/?$" cur) (file-directory-p cur))
 
2469
          (setq ans cur)
 
2470
           (if (string-match "-[0-9.]+$" cur) nil
 
2471
               (setq tem nil)))))
 
2472
  (message ans))
 
2473
EOF
 
2474
 
 
2475
AC_MSG_CHECKING([emacs site lisp directory])
 
2476
if [[ "$EMACS_SITE_LISP" = "unknown" ]] ; then
 
2477
        if [[ "$EMACS" != "" ]] ; then
 
2478
                EMACS_SITE_LISP=`$EMACS -q -batch --no-site-file -l conftest.el 2>&1 | grep -v ^Warning: | sed -e /Loading/d | sed -e /load/d `
 
2479
        else
 
2480
                EMACS_SITE_LISP=""
 
2481
        fi
 
2482
fi
 
2483
AC_MSG_RESULT($EMACS_SITE_LISP)
 
2484
AC_SUBST(EMACS_SITE_LISP)
 
2485
 
 
2486
# check for where the emacs site lisp default.el is
 
2487
rm -f conftest.el
 
2488
cat >> conftest.el <<EOF
 
2489
(let ((ans "./default.el") file (tem load-path))
 
2490
 (while tem
 
2491
   (cond ((file-exists-p
 
2492
           (setq file (expand-file-name "/default.el" (car tem))))
 
2493
          (setq tem nil) (setq ans file)))
 
2494
   (setq tem (cdr tem)))
 
2495
  (message ans))
 
2496
EOF
 
2497
 
 
2498
AC_MSG_CHECKING([emacs default.el])
 
2499
if [[ "$EMACS" != "" ]] ; then
 
2500
        EMACS_DEFAULT_EL=`$EMACS -q -batch --no-site-file -l conftest.el 2>&1 | sed -e /Loading/d | sed -e /load/d `
 
2501
else
 
2502
        EMACS_DEFAULT_EL=""
 
2503
fi
 
2504
if  test -f "${EMACS_DEFAULT_EL}"  ; then true;else
 
2505
  if test -d $EMACS_SITE_LISP ; then
 
2506
     EMACS_DEFAULT_EL=${EMACS_SITE_LISP}/default.el
 
2507
  fi
 
2508
fi
 
2509
AC_MSG_RESULT($EMACS_DEFAULT_EL)
 
2510
AC_SUBST(EMACS_DEFAULT_EL)
 
2511
 
 
2512
 
 
2513
 
 
2514
# check for where the emacs site lisp info/dir is
 
2515
rm -f conftest.el
 
2516
cat >> conftest.el <<EOF
 
2517
(let ((ans "") file (tem Info-default-directory-list))
 
2518
 (while tem
 
2519
   (cond ((file-exists-p (setq file (expand-file-name "dir" (car tem))))
 
2520
          (setq ans (file-name-as-directory (car tem)))         
 
2521
          (setq tem nil) ))
 
2522
   (setq tem (cdr tem)))
 
2523
  (message ans))
 
2524
EOF
 
2525
 
 
2526
AC_MSG_CHECKING([emacs info/dir])
 
2527
if test "$use" = "mingw" ; then
 
2528
    INFO_DIR=\$\(prefix\)/lib/gcl-$VERSION/info/
 
2529
else
 
2530
    if [[ "$EMACS" != "" ]] && [[ "$INFO_DIR" = "unknown" ]] ; then
 
2531
        INFO_DIR=`$EMACS -q -batch --no-site-file -l conftest.el 2>&1 | sed -e /Loading/d | sed -e /load/d `
 
2532
    fi
 
2533
fi
 
2534
 
 
2535
AC_MSG_RESULT($INFO_DIR)
 
2536
AC_SUBST(INFO_DIR)
 
2537
 
 
2538
if test "$enable_tcltk" = "yes" ; then
 
2539
 
 
2540
AC_MSG_CHECKING([for tcl/tk])
 
2541
 
 
2542
 
 
2543
if test -d "${TCL_CONFIG_PREFIX}"  ; then true ; else
 
2544
rm -f conftest.tcl
 
2545
cat >> conftest.tcl <<EOF
 
2546
[
 
2547
set dir [set tcl_library]
 
2548
if { [file exists [file join [set dir] tclConfig.sh]] } {
 
2549
      puts  [set dir]
 
2550
      exit      
 
2551
  }
 
2552
set dir [file dirname [set tcl_library]]
 
2553
if { [file exists [file join [set dir] tclConfig.sh]] } {
 
2554
      puts  [set dir]
 
2555
  }
 
2556
]
 
2557
EOF
 
2558
#cp conftest.tcl foo.tcl
 
2559
 
 
2560
AC_CHECK_PROG(TCLSH,tclsh,tclsh,${TCLSH})
 
2561
#AC_CHECK_PROG(TCLSH,tclsh8.0,tclsh8.0,${TCLSH})
 
2562
 
 
2563
if test "${TCLSH}" = "" ; then true ; else
 
2564
TCL_CONFIG_PREFIX=`${TCLSH} < conftest.tcl`
 
2565
fi
 
2566
fi
 
2567
if test -f ${TCL_CONFIG_PREFIX}/tclConfig.sh  ; then . ${TCL_CONFIG_PREFIX}/tclConfig.sh ; fi
 
2568
 
 
2569
 
 
2570
if test -d "${TK_CONFIG_PREFIX}"  ; then true ; else
 
2571
if test -f ${TCL_CONFIG_PREFIX}/tkConfig.sh ; then
 
2572
TK_CONFIG_PREFIX=${TCL_CONFIG_PREFIX}
 
2573
else
 
2574
#rm -f conftest.tcl
 
2575
#cat >> conftest.tcl <<EOF
 
2576
#[
 
2577
#set dir [set tk_library]
 
2578
#if { [file exists [file join [set dir] tkConfig.sh]] } {
 
2579
#      puts  [set dir]
 
2580
#      exit
 
2581
#  }
 
2582
#set dir [file dirname [set tk_library]]
 
2583
#if { [file exists [file join [set dir] tkConfig.sh]] } {
 
2584
#      puts  [set dir]
 
2585
#  }
 
2586
#exit 0
 
2587
#]
 
2588
#EOF
 
2589
#cp conftest.tcl foo.tcl
 
2590
#AC_CHECK_PROG(TKSH,wish,wish,${TKSH})
 
2591
##AC_CHECK_PROG(TKSH,wish8.0,wish8.0,${TKSH})
 
2592
#if test "${TKSH}" = "" ; then true ; else
 
2593
#TK_CONFIG_PREFIX=`${TKSH} < conftest.tcl`
 
2594
#fi
 
2595
 
 
2596
if test "${TCLSH}" = "" ; then true ; else
 
2597
        TK_CONFIG_PREFIX=`echo tcl_findLibrary \"tk\" \"${TCL_VERSION}\" \"\" \"tkConfig.sh\" \"TK_LIBRARY\" tk_library | ${TCLSH} 2>&1 | ${AWK} '/"source / {if (i++) next;sub("/[[^/]]*$","",$2);print $2}'`
 
2598
fi
 
2599
 
 
2600
fi
 
2601
fi
 
2602
#AC_MSG_CHECKING(TK_CONFIG_PREFIX=${TK_CONFIG_PREFIX})
 
2603
if test -f ${TK_CONFIG_PREFIX}/tkConfig.sh  ; then . ${TK_CONFIG_PREFIX}/tkConfig.sh ; fi
 
2604
 
 
2605
if test -d ${TK_CONFIG_PREFIX}/tk${TK_VERSION} ; then
 
2606
  TK_LIBRARY=${TK_CONFIG_PREFIX}/tk${TK_VERSION}
 
2607
  else
 
2608
  if test -d ${TK_CONFIG_PREFIX}/../tk${TK_VERSION} ; then
 
2609
    TK_LIBRARY=${TK_CONFIG_PREFIX}/../tk${TK_VERSION}
 
2610
  fi
 
2611
fi
 
2612
if test -d ${TK_CONFIG_PREFIX}/tcl${TCL_VERSION} ; then
 
2613
  TCL_LIBRARY=${TK_CONFIG_PREFIX}/tcl${TCL_VERSION}
 
2614
  else
 
2615
  if test -d ${TK_CONFIG_PREFIX}/../tcl${TCL_VERSION} ; then
 
2616
    TCL_LIBRARY=${TK_CONFIG_PREFIX}/../tcl${TCL_VERSION}
 
2617
  fi
 
2618
fi
 
2619
if test -f ${TK_CONFIG_PREFIX}/../include/tk.h ; then
 
2620
  TK_INCLUDE=-I${TK_CONFIG_PREFIX}/../include
 
2621
  else
 
2622
  if test -f /usr/include/tcl${TCL_VERSION}/tk.h ; then
 
2623
    TK_INCLUDE=-I/usr/include/tcl${TCL_VERSION}
 
2624
  fi    
 
2625
fi
 
2626
if test -f ${TCL_CONFIG_PREFIX}/../include/tcl.h ; then
 
2627
  TCL_INCLUDE=-I${TCL_CONFIG_PREFIX}/../include
 
2628
  else
 
2629
  if test -f /usr/include/tcl${TCL_VERSION}/tcl.h ; then
 
2630
    TCL_INCLUDE=-I/usr/include/tcl${TCL_VERSION}
 
2631
  fi
 
2632
fi
 
2633
 
 
2634
fi
 
2635
 
 
2636
AC_CHECK_LIB(lieee,main,have_ieee=1,have_ieee=0)
 
2637
if test "$have_ieee" = "0" ; then
 
2638
 TCL_LIBS=`echo ${TCL_LIBS} | sed -e "s:-lieee::g" `
 
2639
fi
 
2640
if test "$have_dl" = "0" ; then
 
2641
 TCL_LIBS=`echo ${TCL_LIBS} | sed -e "s:-ldl::g"`
 
2642
fi
 
2643
 
 
2644
 
 
2645
AC_SUBST(TK_CONFIG_PREFIX)
 
2646
AC_SUBST(TK_LIBRARY)
 
2647
AC_SUBST(TCL_LIBRARY)
 
2648
AC_SUBST(TK_XINCLUDES)
 
2649
AC_SUBST(TK_INCLUDE)
 
2650
AC_SUBST(TCL_INCLUDE)
 
2651
AC_SUBST(TK_LIB_SPEC)
 
2652
AC_SUBST(TK_BUILD_LIB_SPEC)
 
2653
AC_SUBST(TK_XLIBSW)
 
2654
AC_SUBST(TK_XINCLUDES)
 
2655
AC_SUBST(TCL_LIB_SPEC)
 
2656
AC_SUBST(TCL_DL_LIBS)
 
2657
AC_SUBST(TCL_LIBS)
 
2658
 
 
2659
 
 
2660
 
 
2661
 
 
2662
 
 
2663
 
 
2664
if test -d "${TK_CONFIG_PREFIX}" ; then
 
2665
AC_MSG_RESULT([using TK_VERSION=${TK_VERSION} in ${TK_CONFIG_PREFIX}])
 
2666
else
 
2667
AC_MSG_RESULT([not found])
 
2668
fi
 
2669
 
 
2670
NOTIFY=$enable_notify
 
2671
AC_SUBST(NOTIFY)
 
2672
 
 
2673
      
 
2674
 
 
2675
 
 
2676
# for sgbc the mprotect capabilities.
 
2677
 
 
2678
# the time handling for unixtime, add timezone
 
2679
 
 
2680
AC_FUNC_ALLOCA
 
2681
 
 
2682
# alloca
 
2683
 
 
2684
# dlopen etc
 
2685
# idea make it so you do something dlopen(libX.so,RTLD_GLOBAL)
 
2686
# then dlload("foo.o") a lisp file can refer to things in libX.so
 
2687
 
2688
 
 
2689
# what machine this is, and include then a machine specific hdr.
 
2690
# and machine specific defs.
 
2691
 
 
2692
# check bzero,
 
2693
 
 
2694
# check getcwd, getwd etc..
 
2695
 
 
2696
 
 
2697
 
 
2698
 
 
2699
# check socket stuff..
 
2700
 
 
2701
# getrlimit
 
2702
 
 
2703
# fionread or block
 
2704
 
 
2705
# redhat/cygnus released for some reason a buggy version of gcc,
 
2706
# which no one else released.   Catch that here.
 
2707
dnl AC_MSG_CHECKING([Checking for buggy gcc version from redhat])
 
2708
dnl if  2>&1 $CC -v | fgrep "gcc version 2.96" > /dev/null 
 
2709
dnl    then 
 
2710
dnl         BROKEN_O4_OPT=1
 
2711
dnl         AC_DEFINE(BROKEN_O4_OPT)
 
2712
dnl         AC_SUBST(BROKEN_O4_OPT)
 
2713
dnl         echo ODIR_DEBUG=-O >> makedefsafter
 
2714
dnl     echo >> makedefsafter
 
2715
dnl     AC_MSG_RESULT([yes .. turning off -O4])
 
2716
dnl    else
 
2717
dnl     AC_MSG_RESULT([no])
 
2718
dnl fi 
 
2719
 
 
2720
LDFLAGS="`echo $LDFLAGS | sed 's,gcl.script,../unixport/gcl.script,g'`"
 
2721
AC_SUBST(LDFLAGS)
 
2722
LIBS="$X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS $TLDFLAGS $LIBS $TLIBS"
 
2723
AC_SUBST(LIBS)
 
2724
FINAL_CFLAGS="$CFLAGS $X_CFLAGS $TCFLAGS $PROCESSOR_FLAGS"
 
2725
AC_SUBST(FINAL_CFLAGS)
 
2726
# Work around bug with gcc on ppc -- CM
 
2727
NIFLAGS="$CFLAGS $TCFLAGS $TONIFLAGS $PROCESSOR_FLAGS -I\$(GCLDIR)/o"
 
2728
AC_SUBST(NIFLAGS)
 
2729
CFLAGS="$CFLAGS $TCFLAGS $TO3FLAGS $PROCESSOR_FLAGS -I\$(GCLDIR)/o"
 
2730
AC_SUBST(CFLAGS)
 
2731
O3FLAGS=$TO3FLAGS
 
2732
AC_SUBST(O3FLAGS)
 
2733
O2FLAGS=$TO2FLAGS
 
2734
AC_SUBST(O2FLAGS)
 
2735
 
 
2736
AC_SUBST(EXTRA_LOBJS)
 
2737
AC_SUBST(LEADING_UNDERSCORE)
 
2738
AC_SUBST(GNU_LD)
 
2739
if test -f h/$use.defs  ; then
 
2740
 
 
2741
  AC_SUBST(use)
 
2742
  AC_OUTPUT(makedefc windows/gcl.iss windows/sysdir.bat windows/install.lsp )
 
2743
  echo makedefc
 
2744
  cat makedefc
 
2745
 
 
2746
  echo    add-defs1 $use
 
2747
  CC=$CC ./add-defs1 $use
 
2748
 
 
2749
else
 
2750
  echo "Unable to guess machine type"
 
2751
  echo use configure --enable-machine=XXX,  for XXX such that h/XXX.defs exists, ie in h/*.defs
 
2752
fi