forked from shirok/Gauche
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
882 lines (815 loc) · 28.2 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.54)
AC_INIT(Gauche, 0.9.5_pre1, [email protected])
AC_CANONICAL_SYSTEM
AC_CONFIG_HEADER(src/gauche/config.h)
# ABI_VERSION is set to major.minor of Gauche version by default.
# It can be overridden by uncommenting the following line.
# (This may be useful for "prerelease", such as 0.99.x as pre-1.0)
# GAUCHE_ABI_VERSION=X.Y
dnl ==========================================================
dnl Process args given to configure
dnl
dnl ----------------------------------------------------------
dnl enable-multibyte
dnl
GAUCHE_CHAR_ENCODING=utf8
AC_ARG_ENABLE(multibyte,
AC_HELP_STRING([--enable-multibyte=ENCODING],
[Use ENCODING as the internal multibyte string encoding.
Following encodings are currently recognized:
'euc-jp' (EUC-JP code), 'utf-8' (UTF-8), 'sjis' (Shift-JIS),
or 'none' (No multibyte support)]),
[
case $enable_multibyte in
euc-jp|eucjp) GAUCHE_CHAR_ENCODING=eucjp;;
utf-8|utf8|yes) GAUCHE_CHAR_ENCODING=utf8;;
sjis|shift-jis) GAUCHE_CHAR_ENCODING=sjis;;
no|none) GAUCHE_CHAR_ENCODING=none;;
*) echo "unrecognized encoding option: '$enable_multibyte'; type ./configure --help for available options"
exit 1;;
esac
],
[
GAUCHE_CHAR_ENCODING=utf8
ac_configure_args="$ac_configure_args '--enable-multibyte=utf-8'"
])
case $GAUCHE_CHAR_ENCODING in
eucjp) AC_DEFINE(GAUCHE_CHAR_ENCODING_EUC_JP);;
utf8) AC_DEFINE(GAUCHE_CHAR_ENCODING_UTF_8);;
sjis) AC_DEFINE(GAUCHE_CHAR_ENCODING_SJIS);;
esac
dnl ----------------------------------------------------------
dnl with-slib
dnl
SLIB_DIR=/usr/local/slib
AC_ARG_WITH(slib,
AC_HELP_STRING([--with-slib=PATH],
[Configure Gauche's slib module to use Aubrey Jaffer's SLIB
installed under PATH. If PATH is not specified, or this option is omitted,
Gauche still tries to find your slib installation from some typical places.]),
[
case $with_slib in
no) search_slib=no;;
yes) search_slib=yes;;
*) search_slib=no; SLIB_DIR=$with_slib;;
esac
], [ search_slib=yes ])
if test $search_slib = "yes"; then
AC_MSG_CHECKING(slib)
slib_found=no
for dir in /usr/share/slib /usr/local/slib /usr/local/lib/slib /usr/local/share/slib /usr/src/slib /opt/share/slib; do
if test -f $dir/require.scm; then
SLIB_DIR=$dir
AC_MSG_RESULT($SLIB_DIR)
slib_found=yes
break
fi
done
if test $slib_found = "no"; then
AC_MSG_RESULT([not found, using fallback $SLIB_DIR])
fi
fi
AC_SUBST(SLIB_DIR)
dnl ----------------------------------------------------------
dnl with-local=PATH:...
dnl
AC_ARG_WITH(local,
AC_HELP_STRING([--with-local=PATH:PATH...],
[For each PATH, add PATH/include to the include search
paths and PATH/lib to the library search paths. Useful if you have some
libraries installed in non-standard places. On MinGW/MSYS, use ';' as a
separator instead of ':'.]),
[
case $with_local in
yes|no|"") ;; #no effect
*) IFS_save=$IFS
case $host in *mingw*) IFS=";" ;; *) IFS=":" ;; esac
sep0=""
sep1=""
for p in $with_local; do
LOCAL_INC="${LOCAL_INC}${sep0}-I$p/include"
LOCAL_LIB="${LOCAL_LIB}${sep0}-L$p/lib"
LOCAL_INCDIRS="${LOCAL_INCDIRS}${sep1}$p/include"
LOCAL_LIBDIRS="${LOCAL_LIBDIRS}${sep1}$p/lib"
sep0=" "
sep1="$IFS"
done
IFS=$IFS_save ;;
esac
])
AC_SUBST(LOCAL_INC)
AC_SUBST(LOCAL_LIB)
AC_SUBST(LOCAL_INCDIRS)
AC_SUBST(LOCAL_LIBDIRS)
dnl need to add here, for it may be used by the tests below.
INCLUDES="$INCLUDES $LOCAL_INC"
CPPFLAGS="$CPPFLAGS $LOCAL_INC"
LDFLAGS="$LDFLAGS $LOCAL_LIB"
dnl ----------------------------------------------------------
dnl with-rpath=PATH:...
dnl
try_rpath=yes
rpath=
AC_ARG_WITH(rpath,
AC_HELP_STRING([--with-rpath=PATH:PATH...],
[Use -rpath option while building dynamically loadable objects (experimental).]),
[
case $with_rpath in
yes) ;;
no) try_rpath=no;;
*) rpath="`echo $with_rpath | sed -e 's/^/-Wl,-rpath /' -e 's/:/ -Wl,-rpath /g'`";;
esac
])
dnl ----------------------------------------------------------
dnl enable-thread=TYPE
dnl
GAUCHE_THREAD_TYPE=default
AC_ARG_ENABLE(threads,
AC_HELP_STRING([--enable-threads=TYPE],
[Choose thread type. Possible values are: 'none' for not using threads, 'pthreads' to use pthreads, and 'default' to choose system's suitable one (if any). ]),
[
case $enableval in
pthreads)
GAUCHE_THREAD_TYPE=pthreads;;
win32)
GAUCHE_THREAD_TYPE=win32;;
no|none)
GAUCHE_THREAD_TYPE=none;;
default)
GAUCHE_THREAD_TYPE=default;;
*)
AC_MSG_ERROR([invalid value $enableval for --enable-threads option (must be either none, pthreads, win32, or default])
;;
esac
], [])
dnl Platform-dependent thread configuration. This must be in sync
dnl with gc's configure.in.
case $GAUCHE_THREAD_TYPE in
pthreads|default)
case "$host" in
*-*-linux*)
AC_DEFINE(GC_LINUX_THREADS,1,[Define to use Linux threads])
AC_DEFINE(_REENTRANT,1,[Define to use reentrant libc])
THREADLIBS="-lpthread"
GAUCHE_THREAD_TYPE=pthreads
;;
*-*-hpux*)
AC_MSG_WARN("Only HP/UX 11 threads are supported.")
AC_DEFINE(GC_HPUX_THREADS,1,[Define to use HP-UX threads])
AC_DEFINE(_POSIX_C_SOURCE,199506L,[Define POSIX C version])
THREADLIBS="-lpthread -lrt"
GAUCHE_THREAD_TYPE=pthreads
;;
*-*-*freebsd*|*-*-dragonfly*)
AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.")
AC_DEFINE(GC_FREEBSD_THREADS,1,[Define to use FreeBSD threads])
INCLUDES="$INCLUDES -pthread"
THREADLIBS="-pthread"
GAUCHE_THREAD_TYPE=pthreads
;;
*-*-kfreebsd*-gnu)
AC_DEFINE(GC_FREEBSD_THREADS,1,[Define to use FreeBSD threads])
INCLUDES="$INCLUDES -pthread"
THREADDLLIBS=-pthread
AC_DEFINE(_REENTRANT,1,[Define to use reentrant libc])
;;
*-*-gnu*)
AC_DEFINE(GC_GNU_THREADS,1,[Define to use GNU threads])
AC_DEFINE(_REENTRANT,1,[Define to use reentrant libc])
THREADLIBS="-lpthread"
GAUCHE_THREAD_TYPE=pthreads
;;
*-*-netbsd*)
AC_MSG_WARN("Only on NetBSD 2.0 or later.")
AC_DEFINE(GC_NETBSD_THREADS,1,[Define to use NetBSD threads])
AC_DEFINE(_REENTRANT)
AC_DEFINE(_PTHREADS)
THREADLIBS="-lpthread"
THREADDLLIBS="-lpthread -lrt"
GAUCHE_THREAD_TYPE=pthreads
;;
*-*-solaris*)
AC_DEFINE(GC_SOLARIS_THREADS,1,[Define to use Solaris threads])
AC_DEFINE(GC_SOLARIS_PTHREADS,1,[Define to use Solaris pthreads])
AC_DEFINE(_POSIX_PTHREAD_SEMANTICS,1,[Define to use Solaris pthreads])
THREADLIBS="-lpthread"
GAUCHE_THREAD_TYPE=pthreads
;;
*-*-irix*)
AC_DEFINE(GC_IRIX_THREADS,1,[Define to use IRIX threads])
THREADLIBS="-lpthread"
GAUCHE_THREAD_TYPE=pthreads
;;
*-*-cygwin*)
AC_DEFINE(GC_WIN32_THREADS,1,[Define to use Win32 threads])
THREADLIBS="-lpthread"
GAUCHE_THREAD_TYPE=pthreads
;;
*-*-darwin*)
AC_DEFINE(GC_DARWIN_THREADS,1,[Define to use Darwin threads])
AC_DEFINE(GC_PTHREADS,1,[Define to use pthreads])
INCLUDES="$INCLUDES -I/sw/include"
THREADLIBS="-lpthread"
GAUCHE_THREAD_TYPE=pthreads
;;
*-*-mingw32*)
if test $GAUCHE_THREAD_TYPE = "pthreads"; then
AC_MSG_ERROR([pthread can't be used on Windows. Use --enable-threads=win32 to enable threads])
else
GAUCHE_THREAD_TYPE=win32
fi
;;
*)
if test $GAUCHE_THREAD_TYPE = "pthreads"; then
AC_MSG_ERROR([pthread is not supported on $host])
else
GAUCHE_THREAD_TYPE=none
fi
;;
esac
;;
esac
case $GAUCHE_THREAD_TYPE in
pthreads)
AC_DEFINE(GAUCHE_USE_PTHREADS,1,[Define if we use pthreads])
;;
win32)
AC_DEFINE(GAUCHE_USE_WTHREADS,1,[Define if we use windows threads])
;;
*)
;;
esac
LIBS="$LIBS $THREADLIBS"
dnl Save thread model to be inherited by gc/ subdir.
echo $GAUCHE_THREAD_TYPE > config.threads
dnl ----------------------------------------------------------
dnl enable-framework
dnl
ac_gauche_framework=no
AC_ARG_ENABLE(framework,
AC_HELP_STRING([--enable-framework],
[On MacOSX, build Gauche as a framework. This flag has no effect on other platforms.]),
[
case $enableval in
no)
;;
*)
ac_gauche_framework=yes
;;
esac
], [])
dnl ===========================================================
dnl Set up version-related macros
GAUCHE_VERSION=$PACKAGE_VERSION
AC_SUBST(GAUCHE_VERSION)
AC_DEFINE_UNQUOTED(GAUCHE_VERSION, "$GAUCHE_VERSION")
changequote(<<, >>)dnl
GAUCHE_VERSION_TRUNC=`echo $GAUCHE_VERSION | sed 's/[-_].*//'`
changequote([, ])dnl
OLD_IFS=$IFS; IFS="."; set $GAUCHE_VERSION_TRUNC; IFS=$OLD_IFS
GAUCHE_MAJOR_VERSION=$1
GAUCHE_MINOR_VERSION=$2
GAUCHE_MICRO_VERSION=$3
if test -z "$GAUCHE_MICRO_VERSION"; then GAUCHE_MICRO_VERSION=0; fi
AC_SUBST(GAUCHE_MAJOR_VERSION)
AC_SUBST(GAUCHE_MINOR_VERSION)
AC_SUBST(GAUCHE_MICRO_VERSION)
AC_DEFINE_UNQUOTED(GAUCHE_MAJOR_VERSION, $GAUCHE_MAJOR_VERSION,[Gauche major version number])
AC_DEFINE_UNQUOTED(GAUCHE_MINOR_VERSION, $GAUCHE_MINOR_VERSION,[Gauche minor version number])
AC_DEFINE_UNQUOTED(GAUCHE_MICRO_VERSION, $GAUCHE_MICRO_VERSION,[Gauche patch level number])
if test -z "$GAUCHE_ABI_VERSION"; then
GAUCHE_ABI_VERSION="$GAUCHE_MAJOR_VERSION.$GAUCHE_MINOR_VERSION"
fi
AC_SUBST(GAUCHE_ABI_VERSION)
AC_DEFINE_UNQUOTED(GAUCHE_ABI_VERSION, "$GAUCHE_ABI_VERSION")
GAUCHE_SIGNATURE="$GAUCHE_ABI_VERSION,$GAUCHE_CHAR_ENCODING,$GAUCHE_THREAD_TYPE"
AC_DEFINE_UNQUOTED(GAUCHE_SIGNATURE, "$GAUCHE_SIGNATURE")
LIBGAUCHE=libgauche-$GAUCHE_ABI_VERSION
AC_SUBST(LIBGAUCHE)
LIBGAUCHE_STATIC=libgauche-static-$GAUCHE_ABI_VERSION
AC_SUBST(LIBGAUCHE_STATIC)
LINKGAUCHE=gauche-$GAUCHE_ABI_VERSION
AC_SUBST(LINKGAUCHE)
dnl put the args to the configure in gauche-config script for later use.
dnl the use of ac_configure_args depends on autoconf 2.52.
GAUCHE_CONFIGURE_ARGS="`echo ""$ac_configure_args"" | sed 's/[\\""\`\$]/\\\&/g'`"
AC_SUBST(GAUCHE_CONFIGURE_ARGS)
dnl ==========================================================
dnl Checks for programs.
dnl Kludge for Solaris. We need this setup before start checking with
dnl the compiler. NB: These flags do not coexist with -std=gnu99 flag.
dnl Be careful when we start using C99 features.
case $host in
*-pc-solaris2.*)
CFLAGS="$CFLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__" ;;
esac
AC_PROG_CC
AC_PROG_CC_STDC
AC_C_CONST
AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_PROG_LN_S
AC_CHECK_PROGS(AR, ar gar)
AC_CHECK_PROGS(AS, as gas)
AC_CHECK_PROGS(MAKEINFO, makeinfo)
AC_CHECK_PROGS(GZIP_PROGRAM, gzip)
dnl for cross build
AC_CHECK_PROGS(BUILD_CC, ${build}-gcc ${build_alias}-gcc gcc cc)
dnl for build from repo, we need preinstalled gosh
dnl NB: The third arg is the value when we don't detect preinstalled gosh.
dnl In such case, building from repo fails anyway; shall we use alternative
dnl name or something to tell the builder that she needs preinstalled gosh?
AC_PATH_PROG(BUILD_GOSH, gosh, gosh)
dnl Safe default CFLAGS (usually -g -O2 if you're using gcc, empty otherwise).
dnl If the user overrides CFLAGS during configure, which is recorded.
dnl This information is used when configuring extensions.
DEFAULT_CFLAGS="$CFLAGS"
AC_SUBST(DEFAULT_CFLAGS)
dnl ===========================================================
dnl Checks for header files.
dnl We check sys/types.h merely to include it in the following tests,
dnl for some tests needs it.
AC_HEADER_STDC
AC_HEADER_TIME
AC_CHECK_HEADERS(time.h sys/time.h sys/types.h glob.h dlfcn.h getopt.h sched.h)
AC_CHECK_HEADERS(unistd.h stdint.h inttypes.h rpc/types.h malloc.h)
AC_CHECK_HEADERS(syslog.h crypt.h)
AC_CHECK_HEADERS(pty.h util.h bsd/libutil.h libutil.h sys/loadavg.h sys/resource.h)
dnl glibc specific
AC_CHECK_HEADERS(fpu_control.h)
dnl solaris specific
AC_CHECK_HEADERS(sunmath.h)
dnl OSX specific. If this header exists, we assume that extern char **environ
dnl isn't available and we should use _NSGetEnviron().
AC_CHECK_HEADERS(crt_externs.h)
dnl ===========================================================
dnl Checks processor type, for processor-specific stuff
case $host in
i?86-apple-darwin*)
AC_CHECK_DEFINED(i386,
AC_DEFINE(SCM_TARGET_I386,1,[Define to use i386 optimizations])) ;;
i?86-*)
AC_DEFINE(SCM_TARGET_I386,1,[Define to use i386 optimizations]) ;;
x86_64-*)
AC_DEFINE(SCM_TARGET_X86_64,1,[Define to use x86_64 optimizations]) ;;
alpha*)
CFLAGS="$CFLAGS -mieee" ;;
arm*)
# ARM processor may use a special mixed endian for doubles. It can
# be switched by processor configuration. So we check it at runtime.
AC_DEFINE(DOUBLE_ARMENDIAN,1) ;;
esac
dnl ===========================================================
dnl Checks for typedefs, structures, and compiler characteristics.
AC_SYS_LARGEFILE
AC_C_INLINE
AC_C_BIGENDIAN
AC_STRUCT_TM
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(off_t)
AC_CHECK_TYPES([uint16_t, int32_t, uint32_t, int64_t, uint64_t, long long, long double])
AC_CHECK_TYPES([struct timespec])
if test "$GAUCHE_THREAD_TYPE" = pthreads; then
AC_CHECK_TYPES(pthread_spinlock_t,,,[#include <pthread.h>])
fi
AC_CHECK_SIZEOF(rlim_t,,[
#if HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#if HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#endif
])
dnl Checks non-POSIX members of system structure
AC_CHECK_MEMBERS([struct group.gr_passwd],,,[#include <grp.h>])
AC_CHECK_MEMBERS([struct passwd.pw_passwd,
struct passwd.pw_gecos,
struct passwd.pw_class],,,[#include <pwd.h>])
dnl checks if time_t is integer or flonum
AC_CACHE_CHECK(time_t is integral, ac_cv_type_time_t_integral, [
AC_TRY_RUN([
#include <time.h>
int main()
{
time_t t = 3.14;
return (t == 3.14);
}], ac_cv_type_time_t_integral=yes, ac_cv_type_time_t_integral=no,
ac_cv_type_time_t_integral=yes)])
if test "$ac_cv_type_time_t_integral" = yes; then
AC_DEFINE(INTEGRAL_TIME_T,1,[Define if time_t is typedef'ed to an integral type])
fi
dnl ===========================================================
dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
dnl This is required to test trunc and rint below
AC_CHECK_LIB(m, sin)
dnl x86-solaris 9 requires this to use isinf
AC_CHECK_LIB(sunmath, isinf)
dnl clock_gettime may be in librt
AC_CHECK_LIB(rt, clock_gettime)
dnl For Windows/MinGW, manually adds several libraries
dnl Also adds -DUNICODE to CFLAGS enable Windows wchar API,
dnl if GAUCHE_CHAR_ENCODING is UTF_8.
dnl ALTERNATIVE_GOSH is no-console version of gosh; only built on Windows.
case "$host" in
*mingw*) LIBS="$LIBS -lnetapi32 -lshlwapi -lws2_32"
ALTERNATIVE_GOSH="gosh-noconsole.exe"
case "$GAUCHE_CHAR_ENCODING" in
utf8) CFLAGS="$CFLAGS -DUNICODE" ;;
esac ;;
*) ALTERNATIVE_GOSH="" ;;
esac
AC_SUBST(ALTERNATIVE_GOSH)
AC_FUNC_ALLOCA
AC_CHECK_FUNCS(isnan isinf trunc rint tgamma lgamma)
AC_CHECK_FUNCS(symlink readlink lchown mkstemp realpath nanosleep usleep)
AC_CHECK_FUNCS(random srandom lrand48 srand48)
AC_CHECK_FUNCS(putenv setenv unsetenv clearenv getpgid setgroups)
AC_CHECK_FUNCS(gethostname sethostname getdomainname setdomainname)
AC_CHECK_FUNCS(gettimeofday getloadavg clock_gettime clock_getres)
AC_CHECK_FUNCS(syslog setlogmask)
AC_CHECK_FUNCS(sigwait)
AC_CHECK_FUNCS(fpsetprec)
dnl Check for select(). HP-UX and MinGW doesn't like the way configure tests
dnl select() existence and we know they have one, so we skip the test on them.
case "$host" in
*-hpux*|*mingw*)
AC_DEFINE(HAVE_SELECT, 1, [Define if you have select]) ;;
*)
AC_CHECK_FUNCS(select);;
esac
dnl Checks for pty-related fns. It appears that recent Cygwin has them,
dnl but only in a static library. That prevents us from creating DLL
dnl version of gauche. Thus we explictly exclude them on cygwin.
case "$host" in
*cygwin*)
: ;;
*)
AC_SEARCH_LIBS(openpty, util, AC_DEFINE(HAVE_OPENPTY, 1, [Define if you have openpty]))
AC_SEARCH_LIBS(forkpty, util, AC_DEFINE(HAVE_FORKPTY, 1, [Define if you have forkpty]))
;;
esac
dnl Checks if crypt() exists and whether it's in libc or libcrypt.
dnl Note: on cygwin, libcrypt is only available as a static library,
dnl and prevents libgauche.dll from building. We explicitly excludes it.
dnl
case "$host" in
*cygwin*)
: ;;
*)
AC_SEARCH_LIBS(crypt, crypt, AC_DEFINE(HAVE_CRYPT,1,[Define if uses libcrypt]))
;;
esac
dnl Checks if dlopen exists, and if it's in libc or libdl.
AC_SEARCH_LIBS(dlopen, dl, AC_DEFINE(HAVE_DLOPEN,1,[Define if the system has dlopen()]))
dnl Checks for sched_yield.
AC_SEARCH_LIBS(sched_yield, rt, AC_DEFINE(HAVE_SCHED_YIELD,1,[Define if uses librt]))
dnl
dnl Checks compiler options for dynamic link and thread support.
dnl
dnl SHLIB_SO_SUFFIX Suffix of dlopen-able module. most systems doesn't
dnl have restriction for this. default "so".
dnl SHLIB_DYLIB_SUFFIX Suffix of dynamic linkable module. On Unices
dnl it is usuallly "so". On MacOSX it is "dylib".
dnl On Win32 it is "dll". If not explicitly specified,
dnl SHLIB_SO_SUFFIX is used.
dnl SHLIB_SO_CFLAGS flags to compile files which is dlopen-able
dnl e.g. "-fpic"
dnl SHLIB_SO_LDFLAGS flags to link files to create dlopen-able
dnl module, e.g. "-shared -o"
dnl SHLIB_DYLIB_LDFLAGS flags to link files to create dynamically linkable
dnl module. On most unices this is the same as
dnl SHLIB_SO_LDFLAGS.
dnl SHLIB_MAIN_LDFLAGS flags required to compile a main program which
dnl exposes symbols to be referred by the dynamically
dnl loaded module, e.g. "-rdynamic"
dnl LINK_HELPER A script that helps linking libgauche. Sort of
dnl simplified libtool. So far we only need this on
dnl MacOSX. We have absolutely no intention to
dnl re-invent libtool, though.
dnl LIBGAUCHE_SO defined as "libgauche.$(SHLIB_SO_SUFFIX)" if
dnl system supports dso. empty otherwise.
dnl GOSH_USE_SHLIB If set to "yes", gosh uses dynamic linkable version
dnl of libgauche, instead of statically links libgauche.a.
dnl On Win32 it is required to allow extensions to work.
AC_MSG_CHECKING(how to make dynamic loadable module)
# A flag to indicate libgauche can be linked when building extension module.
# It is required on cygwin; it has to be omitted on MacOS X; Other unices
# generally don't care.
ext_use_libgauche=no
# A flag to indicate we need to create a link with version numbers to
# libgauche.so after building it.
libgauche_version_link=yes
# A flag to indicate uvector.so should be added when linking extension module
# that refers to uvector. It is required if we want to resolve all symbols,
# and although it's the usual case, we can't add it on MacOS X, on which
# we only build the static version of libgauche.
ext_use_uvector=no
# We put additional information, such as whether we use Framework for
# darwin, in this variable.
xhost=$host
# On cygwin, we likely to need rebaseall to make dlls work with sys-fork.
CYGWIN_FIXDLL=:
case $host in
*freebsd2*)
SHLIB_SO_CFLAGS="-fpic -fPIC"
SHLIB_SO_LDFLAGS="-v;ld -Bshareable -o"
SHLIB_SO_SUFFIX="so"
SHLIB_MAIN_LDFLAGS=""
SHLIB_OK=ok
;;
*-linux-gnu*|*-*-gnu*|*freebsd*|*dragonfly*)
SHLIB_SO_CFLAGS="-fPIC"
SHLIB_SO_LDFLAGS="$rpath -shared -o"
SHLIB_SO_SUFFIX="so"
SHLIB_MAIN_LDFLAGS="-rdynamic"
SHLIB_OK=ok
;;
*netbsd*|*openbsd*)
SHLIB_SO_CFLAGS="-fPIC -DPIC"
SHLIB_SO_LDFLAGS="$rpath -shared -o"
SHLIB_SO_SUFFIX="so"
SHLIB_MAIN_LDFLAGS="-rdynamic"
SHLIB_OK=ok
;;
*darwin*)
# -no-cpp-precomp is not related to shared library, but needed to
# get src/{vm.c,char.c} compiled -skimu
# [Shiro] Darwin 1.3 and later needs different flags
CPPFLAGS="$CPPFLAGS -no-cpp-precomp"
case $host_os in
darwin1.[[012]]) FLAT_NAMESPACE="" ;;
*) FLAT_NAMESPACE="-flat_namespace" ;;
esac
case $host_os in
darwin9.8.*) ;; dnl Leopard doesn't like -no_pie
*) SHLIB_MAIN_LDFLAGS="-Wl,-no_pie";;
esac
SHLIB_SO_CFLAGS="-no-cpp-precomp -fPIC -fno-common"
SHLIB_SO_LDFLAGS="-bundle $FLAT_NAMESPACE -undefined suppress -o"
SHLIB_SO_SUFFIX="so"
SHLIB_DYLIB_LDFLAGS='-framework CoreFoundation -dynamiclib -o'
if test "$ac_gauche_framework" = yes; then
AC_DEFINE(GAUCHE_MACOSX_FRAMEWORK, 1, [Define 1 if building framework on MacOSX])
xhost="${host}-framework"
fi
SHLIB_DYLIB_SUFFIX="dylib"
SHLIB_LIBS_FOR_EXT=""
SHLIB_OK=ok
LINK_HELPER='$(srcdir)/link-dylib'
ext_use_libgauche=no
libgauche_version_link=no
;;
mips-sgi-irix*)
if test "$GCC" = yes; then
SHLIB_SO_CFLAGS="-fPIC"
else
SHLIB_SO_CFLAGS="-KPIC"
fi
SHLIB_SO_LDFLAGS="$rpath -shared -o"
SHLIB_SO_SUFFIX="so"
SHLIB_MAIN_LDFLAGS=""
SHLIB_OK=ok
;;
*solaris*)
if test "$GCC" = yes; then
SHLIB_SO_CFLAGS="-fPIC"
SHLIB_SO_LDFLAGS="-shared -o"
else
SHLIB_SO_CFLAGS="-Kpic"
SHLIB_SO_LDFLAGS="-G -o"
fi
SHLIB_SO_SUFFIX="so"
SHLIB_MAIN_LDFLAGS=""
SHLIB_OK=ok
;;
*hp*)
if test "$GCC" = yes; then
SHLIB_SO_CFLAGS="-fPIC"
SHLIB_SO_LDFLAGS="-shared -o"
else
SHLIB_SO_CFLAGS="+z +Z"
SHLIB_SO_LDFLAGS=";ld -b -o"
fi
SHLIB_SO_SUFFIX="sl"
SHLIB_MAIN_LDFLAGS=""
SHLIB_OK=ok
LINK_HELPER='$(srcdir)/link-hpux'
;;
*cygwin*)
SHLIB_SO_CFLAGS=""
SHLIB_SO_LDFLAGS='-Wl,--export-all-symbols -Wl,--enable-auto-import -shared -o'
SHLIB_SO_SUFFIX="dll"
SHLIB_DYLIB_SUFFIX="dll"
SHLIB_MAIN_LDFLAGS="-Wl,--enable-auto-import"
SHLIB_OK=ok
GOSH_USE_SHLIB=yes
ext_use_uvector=yes
ext_use_libgauche=yes
libgauche_version_link=no
CYGWIN_FIXDLL='$(srcdir)/src/cygwin-fixdll.sh'
;;
*mingw*)
# Kludge: We add -static-libgcc flag when creating dll, in order to avoid
# inroducing dependency to libgcc_s_dw2-1.dll.
SHLIB_SO_CFLAGS=""
SHLIB_SO_LDFLAGS='-Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc -static-libgcc -shared -o'
SHLIB_SO_SUFFIX="dll"
SHLIB_DYLIB_SUFFIX="dll"
SHLIB_MAIN_LDFLAGS="-Wl,--enable-auto-import -static-libgcc"
SHLIB_OK=ok
GOSH_USE_SHLIB=yes
ext_use_uvector=yes
ext_use_libgauche=yes
libgauche_version_link=no
;;
*)
SHLIB_SO_CFLAGS=""
SHLIB_SO_LDFLAGS=""
SHLIB_SO_SUFFIX=""
SHLIB_MAIN_LDFLAGS=""
SHLIB_OK=unknown
;;
esac
if test -z "$SHLIB_DYLIB_LDFLAGS"; then
SHLIB_DYLIB_LDFLAGS=$SHLIB_SO_LDFLAGS
fi
if test -z "$SHLIB_DYLIB_SUFFIX"; then
SHLIB_DYLIB_SUFFIX=$SHLIB_SO_SUFFIX
fi
if test "$SHLIB_OK" = ok; then
LIBGAUCHE_SO="$LIBGAUCHE.$SHLIB_DYLIB_SUFFIX"
else
LIBGAUCHE_SO=
fi
if test "$ext_use_libgauche" = yes; then
EXT_LIBGAUCHE="-l$LINKGAUCHE"
else
EXT_LIBGAUCHE=
fi
if test "$ext_use_uvector" = yes; then
EXT_UVECTOR='$(top_builddir)/ext/uvector/libgauche-uvector.$(SOEXT)'
else
EXT_UVECTOR=
fi
if test "$libgauche_version_link" = yes -a "$SHLIB_OK" = ok; then
MAKEVERSLINK='$(SHELL) ./makeverslink'
else
MAKEVERSLINK=:
fi
AC_SUBST(xhost)
AC_SUBST(SHLIB_SO_CFLAGS)
AC_SUBST(SHLIB_SO_LDFLAGS)
AC_SUBST(SHLIB_SO_SUFFIX)
AC_SUBST(SHLIB_LIBS_FOR_EXT)
AC_SUBST(SHLIB_DYLIB_LDFLAGS)
AC_SUBST(SHLIB_DYLIB_SUFFIX)
AC_SUBST(SHLIB_MAIN_LDFLAGS)
AC_SUBST(EXT_LIBGAUCHE)
AC_SUBST(EXT_UVECTOR)
AC_SUBST(LIBGAUCHE_SO)
AC_SUBST(GOSH_USE_SHLIB)
AC_DEFINE_UNQUOTED(SHLIB_SO_SUFFIX, "$SHLIB_SO_SUFFIX")
AC_SUBST(LINK_HELPER)
AC_SUBST(MAKEVERSLINK)
AC_SUBST(CYGWIN_FIXDLL)
AC_MSG_RESULT($SHLIB_OK)
dnl Check to see if the linker takes --rpath flag via -Wl.
RPATH_FLAG=
if test "$try_rpath" = "yes"; then
cflags_save="$CFLAGS"
CFLAGS="$CFLAGS -Wl,--rpath -Wl,/"
AC_CACHE_CHECK([linker takes --rpath flag], ac_cv_linker_rpath_flag, [
AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])],
ac_cv_linker_rpath_flag=yes,
ac_cv_linker_rpath_flag=no)
])
CFLAGS="$cflags_save"
if test "$ac_cv_linker_rpath_flag" = "yes"; then
RPATH_FLAG='-Wl,--rpath -Wl,'
else
# solaris' ld uses -R instead of --rpath
CFLAGS="$CFLAGS -Wl,-R -Wl,/"
AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])],
ac_cv_linker_rpath_flag=yes,
ac_cv_linker_rpath_flag=no)
CFLAGS="$cflags_save"
if test "$ac_cv_linker_rpath_flag" = "yes"; then
RPATH_FLAG='-Wl,-R -Wl,'
fi
fi
if test "$RPATH_FLAG" != ""; then
RPATH_TMP=$RPATH_FLAG'`pwd`'
RPATH_REAL=$RPATH_FLAG'$(LIB_INSTALL_DIR)'
fi
fi
AC_SUBST(RPATH_FLAG)
AC_SUBST(RPATH_TMP)
AC_SUBST(RPATH_REAL)
dnl Check to see if the linker takes --soname flag
cflags_save="$CFLAGS"
CFLAGS="$CFLAGS -Wl,--soname,libgauche.so.0"
AC_CACHE_CHECK([linker takes --soname flag], ac_cv_linker_soname_flag, [
AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])],
ac_cv_linker_soname_flag=yes,
ac_cv_linker_soname_flag=no)
])
CFLAGS="$cflags_save"
if test "$ac_cv_linker_soname_flag" = "yes"; then
SONAME_FLAG="-Wl,--soname,$LIBGAUCHE.so.0.$GAUCHE_MICRO_VERSION"
fi
AC_SUBST(SONAME_FLAG)
dnl Sets some optimization flags by heuristics.
AC_GAUCHE_OPTFLAGS
dnl ===========================================================
dnl Tests for extensions
EXT_LIBS=
# Those *.ac's may add libraries to EXT_LIBS.
m4_include([ext/charconv/charconv.ac])
m4_include([ext/dbm/dbm.ac])
m4_include([ext/net/net.ac])
m4_include([ext/zlib/zlib.ac])
m4_include([ext/tls/tls.ac])
dnl Setup STATIC_LIBS
STATIC_LIBS=
for lib in $EXT_LIBS $LIBS; do
if [ echo "$STATIC_LIBS" | grep -e $lib > /dev/null 2>&1 ]
then
: # lib is alreay in STATIC_LIBS. do nothing
else
STATIC_LIBS="$STATIC_LIBS $lib"
fi
done
STATIC_LIBS="`echo $LIBGAUCHE_STATIC | sed s/^lib/-l/` $STATIC_LIBS"
AC_SUBST(STATIC_LIBS)
dnl ===========================================================
dnl Cross compiling
if test ${cross_compiling} = no ; then
# self compile
CROSS_COMPILING_yes="#"
CROSS_COMPILING_no=
else
# cross compile
CROSS_COMPILING_yes=
CROSS_COMPILING_no="#"
fi
AC_SUBST(CROSS_COMPILING_yes)
AC_SUBST(CROSS_COMPILING_no)
dnl ===========================================================
dnl Configure gc
AC_CONFIG_SUBDIRS(gc)
dnl ===========================================================
dnl Create output files
echo $GAUCHE_VERSION > VERSION
AC_OUTPUT(Makefile
src/Makefile src/genconfig src/makeverslink
lib/Makefile lib/slib.scm
doc/gosh.1 doc/gauche-config.1 doc/gauche-cesconv.1
doc/gauche-install.1 doc/gauche-package.1 doc/Makefile
ext/Makefile ext/Makefile.ext
ext/bcrypt/Makefile
ext/binary/Makefile
ext/charconv/Makefile ext/charconv/charconv.h
ext/data/Makefile
ext/dbm/Makefile
ext/digest/Makefile
ext/fcntl/Makefile
ext/file/Makefile
ext/gauche/Makefile
ext/mt-random/Makefile
ext/net/Makefile
ext/peg/Makefile
ext/sparse/Makefile
ext/srfi/Makefile
ext/sxml/Makefile
ext/syslog/Makefile
ext/tls/Makefile
ext/termios/Makefile
ext/text/Makefile
ext/threads/Makefile
ext/util/Makefile
ext/uvector/Makefile
ext/vport/Makefile
ext/rfc/Makefile
ext/zlib/Makefile
ext/windows/Makefile
examples/Makefile
examples/standalone/Makefile
)
dnl ===========================================================
dnl Show some of the configuration results, for developer's
dnl convenience.
[OPTDBMS=`echo "$DBM_SCMFILES" | sed 's/\.sci//g'`]
if test "$ac_cv_use_zlib" = yes; then OPTZLIB=" zlib"; else OPTZLIB=" "; fi
AC_MSG_RESULT(
[
This Gauche has been configured with the following parameters:
version: $GAUCHE_VERSION
multibyte: $GAUCHE_CHAR_ENCODING
slib: $SLIB_DIR
thread: $GAUCHE_THREAD_TYPE
tls/ssl: $GAUCHE_TLS_TYPE
optional modules: $OPTDBMS$OPTZLIB
])