forked from fricas/fricas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
1192 lines (1063 loc) · 39.1 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
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
sinclude(config/fricas.m4)
AC_INIT([jlFriCAS], [1.3.12-dev],
[https://github.com/gvanuxem/jlfricas/issues],
[jlfricas],
[https://gvanuxem.github.io/jlfricas])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR(config)
AC_CONFIG_HEADERS([config/fricas_c_macros.h])
AC_PREREQ([2.59])
AC_CONFIG_SRCDIR(src/Makefile.in)
# FRICAS_CHECK_PROGS and FRICAS_CHECK_PROG signal error if the
# program is not found
AC_DEFUN([FRICAS_CHECK_PROGS],
[AC_CHECK_PROGS([$1], [$2])
test -n "$$1" || AC_MSG_ERROR([$3])])
AC_DEFUN([FRICAS_CHECK_PROG],
[AC_CHECK_PROG([$1], [$2], [$2])
test -n "$$1" || AC_MSG_ERROR([$3])])
fricas_src_subdirs="lib lisp boot interp algebra input etc"
AC_SUBST(fricas_src_subdirs)
AC_CANONICAL_TARGET
case $build in
*mingw*|*msys*)
fricas_pwd=`pwd -W`
fricas_top_srcdir=`cd "$srcdir" && pwd -W`
;;
*)
fricas_pwd=`pwd`
fricas_top_srcdir=`cd "$srcdir" && pwd`
;;
esac
AC_SUBST(fricas_top_srcdir)
if echo "$fricas_pwd" | grep ' ' ; then
AC_MSG_WARN([Please make sure that name of source directory])
AC_MSG_WARN([and name of build directory does not contain spaces.])
AC_MSG_ERROR([Name of build directory contains space.])
fi
if echo "$srcdir" | grep ' ' || echo "fricas_top_srcdir" | grep ' ' ; then
AC_MSG_WARN([Please make sure that name of source directory])
AC_MSG_WARN([and name of build directory does not contain spaces.])
AC_MSG_ERROR([Name of source directory contains space.])
fi
## Where tools for the build machine are built
fricas_builddir=$fricas_pwd/build/$build
AC_SUBST(fricas_builddir)
fricas_build_bindir=$fricas_builddir/bin
AC_SUBST(fricas_build_bindir)
## Prefix for the staging target installation directory
fricas_targetdir=$fricas_pwd/target/$target
AC_SUBST(fricas_targetdir)
if test $build != $target; then
AC_MSG_WARN([Cross build is not supported.])
AC_MSG_WARN([Please notify [email protected] if you succeed.])
fi
## Accumulate list of utils needed for the build platform
fricas_all_prerequisites=
case $build in
*linux*)
# GNU/Linux systems come equipped with GNU Make, called `make'
FRICAS_CHECK_PROGS([MAKE], [make], [Make utility missing.])
;;
*)
# Other systems tend to spell it `gmake' and such
FRICAS_CHECK_PROGS([MAKE], [gmake make],
[Make utility missing.])
if ! $MAKE --version | grep 'GNU' 2>/dev/null; then
AC_MSG_ERROR([jlFriCAS build system needs GNU Make.])
fi
;;
esac
## Check the C compiler
AC_PROG_CC
# fricas_cflags="-O2 -Wall -D_GNU_SOURCE"
# AC_SUBST(fricas_cflags)
## What is the extension of object files on this platform?
AC_OBJEXT
AC_PROG_INSTALL
# AC_PROG_LN_S
FRICAS_CHECK_PROG([TOUCH], [touch], ['touch' program is missing.])
AC_CHECK_PROGS([MKTEMP], [mktemp])
case $build in
*-solaris9)
FRICAS_CHECK_PROG([AWK], [gawk], [jlFriCAS needs gawk])
FRICAS_CHECK_PROG([TAR], [gtar], [jlFriCAS needs gtar])
;;
*)
AC_PROG_AWK
FRICAS_CHECK_PROGS([TAR], [gtar tar], [jlFriCAS needs a tar program])
;;
esac
AC_PROG_RANLIB
FRICAS_CHECK_PROG([AR], [ar], [program 'ar' is missing])
AC_PATH_PROG([LATEX], [latex])
AC_CHECK_PROGS([MAKEINDEX], [makeindex])
if test -z $AWK_FOR_TARGET ; then
AWK_FOR_TARGET=`which $AWK`
fi
AC_SUBST(AWK_FOR_TARGET)
## ---------------------------------
## -- Is there pregenerated data? --
## ---------------------------------
##
## FriCAS might come with precompiled files. In case there is a
## directory "pre-generated" in the source tree, the contents of
## directory is used instead of recompiling these files. If this
## directory exists, it is supposed to be sane, i.e., must have been
## generated via "make dist". If such a pre-generated directory lives
## outside the fricas source tree, it can be given to configure via
## --with-pre-generated=/absolute/path/to/pre-generated or given at
## build time via "make PREGENERATED=/absolute/path/to/pre-generated".
AC_SUBST(PREGENERATED)
PREGENERATED=
AC_MSG_CHECKING([PREGENERATED])
AC_ARG_WITH([pre-generated],
[AS_HELP_STRING([--with-pre-generated],
[Specify an absolute path to pre-generated fricas code.])],
# Action if --with-pre-generated is given.
[AS_IF([test -d "$withval"],
[PREGENERATED=$withval],
[AC_MSG_ERROR([--with-pre-generated directory does not exist.])])],
# Action if --with-pre-generated is not given.
[AS_IF([test -d $fricas_top_srcdir/pre-generated],
[PREGENERATED=$fricas_top_srcdir/pre-generated])]
)
AC_MSG_RESULT(["$PREGENERATED"])
if test -z "$PREGENERATED" ; then
AC_MSG_CHECKING([for in-tree build on case insensitive file system])
if test "$fricas_top_srcdir" = "$fricas_pwd"; then
rm -f ac_TEST_filenames_CASE_sensitive ac_test_filenames_case_sensitive
echo foo > ac_test_filenames_case_sensitive
if test -f ac_TEST_filenames_CASE_sensitive; then
rm ac_test_filenames_case_sensitive
AC_MSG_ERROR([in-tree build (without pre-generated) on case insensitive
file system is not supported. Use out-of-source-tree build instead.])
else
rm ac_test_filenames_case_sensitive
AC_MSG_RESULT([no])
fi
else
AC_MSG_RESULT([no])
fi
fi
## ------------------------
## -- Which Lisp to use? --
## ------------------------
##
## We will default to SBCL later, if no lisp implementation is specified.
fricas_lisp=
fricas_lisp_flavor=unknown
AC_ARG_WITH([lisp],
[AS_HELP_STRING([--with-lisp=L], [use L as Lisp platform])],
[fricas_lisp=$withval])
## Default to SBCL if no lisp given
if test -z "$fricas_lisp" ; then
AC_PATH_PROG([FRICAS_LISP], [sbcl])
if test -z $FRICAS_LISP ; then
AC_MSG_ERROR([SBCL not found and no Lisp specified.
Install supported Lisp implementation and
use --with-lisp option to tell jlFriCAS
how to invoke your Lisp])
fi
fricas_lisp=$FRICAS_LISP
else
## Honor use of Lisp image specified on command line
FRICAS_LISP=$fricas_lisp
AC_SUBST(FRICAS_LISP)
:
fi
AC_ARG_WITH([lisp-flavor],
[AS_HELP_STRING([--with-lisp-flavor=F],
[obsolete and ignored])],
[AC_MSG_WARN([--with-lisp-flavor is ignored now])]
)
AC_MSG_CHECKING([Lisp implementation])
rm -f config_cl.out
echo '(load "'"$fricas_top_srcdir"'/config.lisp")' | $fricas_lisp
if test x$fricas_lisp_flavor = xunknown ; then
fricas_lisp_flavor=`sed -n -e 's/fricas_lisp_flavor=//p' config_cl.out`
fi
if test -z "$fricas_lisp_flavor" ; then
AC_MSG_ERROR([Unable to determine Lisp flavor])
fi
AC_MSG_RESULT([$fricas_lisp_flavor])
fricas_fasl_type=`sed -n -e 's/fricas_fasl_type=//p' config_cl.out`
fricas_lisp_version=`sed -n -e 's/fricas_lisp_version=//p' config_cl.out`
AC_MSG_CHECKING([for suffix of compiled Lisp files])
if test -z $fricas_fasl_type; then
AC_MSG_ERROR([Could not determine extension for compiled Lisp files])
fi
AC_MSG_RESULT([$fricas_fasl_type])
fricas_fasl_type2=$fricas_fasl_type
case $fricas_lisp_flavor in
ECL)
fricas_fasl_type="o"
;;
*)
;;
esac
AC_SUBST(fricas_fasl_type)
AC_SUBST(fricas_fasl_type2)
if test -z "$fricas_lisp_version" ; then
AC_MSG_WARN([Unable to determine Lisp version.])
else
case $fricas_lisp_flavor in
CLISP)
if echo $fricas_lisp_version | grep '^[[0-1]]\.' > /dev/null || \
echo $fricas_lisp_version | grep '^2\.[[0-3]]' > /dev/null ; then
AC_MSG_ERROR([clisp $fricas_lisp_version is too old])
fi
;;
ECL)
case $fricas_lisp_version in
0.*)
case $fricas_lisp_version in
0.9j)
AC_MSG_WARN([You use old ECL, please consider upgrade])
;;
0.9l)
;;
*)
AC_MSG_ERROR([ECL $fricas_lisp_version is too old])
;;
esac
;;
esac
;;
'GNU Common Lisp (GCL)')
case $fricas_lisp_version in
2.6.1[[4-9]])
;;
2.7.0)
AC_MSG_WARN([FriCAS needs porting to GNU Common Lisp $fricas_lisp_version
please proceed with caution])
;;
*)
AC_MSG_ERROR([GNU Common Lisp $fricas_lisp_version is too old])
;;
esac
;;
'Clozure Common Lisp')
if echo $fricas_lisp_version | grep '^1\.1[[0-9]]' > /dev/null ; then
true
else if echo $fricas_lisp_version | grep '^0\.' > /dev/null || \
echo $fricas_lisp_version | grep '^1\.[[01]]' > /dev/null ; then
AC_MSG_ERROR([Clozure CL $fricas_lisp_version is too old])
fi
fi
;;
SBCL)
if echo $fricas_lisp_version | grep '^0\.' > /dev/null || \
echo $fricas_lisp_version | grep '^1\.0.[[0-6]]$' > /dev/null ; then
AC_MSG_ERROR([SBCL $fricas_lisp_version is too old])
fi
case $(uname -m) in
i*86)
case $fricas_lisp_version in
1.5.9|2.0.*|2.1.[[0-3]]|2.1.[[0-3]].*)
AC_MSG_ERROR([SBCL $fricas_lisp_version on $(uname -m) has a serious runtime issue. Please use different SBCL version])
;;
2.2.[[2-7]]*)
AC_MSG_ERROR([SBCL $fricas_lisp_version on $(uname -m) has a bug which does not allow building jlFriCAS.
Please use different SBCL version])
;;
esac
;;
esac
case $fricas_lisp_version in
1.0.29|1.3.1|1.3.1.*|1.3.2|1.3.3|1.3.4)
AC_MSG_ERROR([SBCL $fricas_lisp_version has a bug which does not allow building jlFriCAS.
Please use different SBCL version])
;;
esac
;;
esac
fi
AC_SUBST(fricas_lisp_flavor)
AC_SUBST(fricas_lisp_version)
## Check if we need shared libspad library.
case $fricas_lisp_flavor in
SBCL|'CMU Common Lisp'|CLISP|'Clozure Common Lisp'|lispworks)
LIBSPAD_SO_TARGET="libspad_so"
;;
*)
LIBSPAD_SO_TARGET=""
;;
esac
case $target in
*darwin*)
SOLIB_FLAGS="-dynamiclib -single_module"
;;
*)
SOLIB_FLAGS="-shared"
;;
esac
AC_SUBST(LIBSPAD_SO_TARGET)
AC_SUBST(SOLIB_FLAGS)
## In case our underlying lisp is SBCL or Closure CL, we provide a
## wrapper to enable GMP bignums in lisp
GMP_WRAP_SO_TARGET=""
GMP_CPPFLAGS=""
GMP_LDFLAGS=""
GMP_LIBDIR=""
## --with-gmp[=PATH]
AC_ARG_WITH([gmp],
[AS_HELP_STRING([--with-gmp=PATH],
[specify prefix directory for the installed GMP package.
Equivalent to --with-gmp-include=PATH/include
plus --with-gmp-lib=PATH/lib])],
[GMP_WRAP_SO_TARGET=gmp_wrap_so
if test x$withval = x; then
GMP_CPPFLAGS=""
GMP_LDFLAGS=""
GMP_LIBDIR=""
else
GMP_CPPFLAGS=-I$withval/include
GMP_LDFLAGS=-L$withval/lib
GMP_LIBDIR=$withval/lib/
fi])
AC_ARG_WITH([gmp-include],
[AS_HELP_STRING([--with-gmp-include=PATH],
[specify directory for installed GMP include files])],
[GMP_WRAP_SO_TARGET=gmp_wrap_so
GMP_CPPFLAGS="-I$withval"])
AC_ARG_WITH([gmp-lib],
[AS_HELP_STRING([--with-gmp-lib=PATH],
[specify directory for the installed GMP library])],
[GMP_WRAP_SO_TARGET=gmp_wrap_so
GMP_LDFLAGS="-L$withval"
GMP_LIBDIR="$withval/"])
AC_ARG_ENABLE([gmp],
[AS_HELP_STRING([--enable-gmp],
[use gmp for bignums with SBCL or Clozure CL])],
[case $enableval in
yes) GMP_WRAP_SO_TARGET=gmp_wrap_so ;;
no) GMP_WRAP_SO_TARGET="" ;;
*) AC_MSG_ERROR([--enable-gmp only allows yes or no as an argument]) ;;
esac])
## Check if GMP is really compatible with the Lisp flavour
if test -n "$GMP_WRAP_SO_TARGET" ; then
if test "$fricas_lisp_flavor" = SBCL ; then
true
elif test "$fricas_lisp_flavor" = 'Clozure Common Lisp' ; then
case $(uname -m) in
arm*|i386|i486|i586|i686|x86_64)
GMP_WRAP_SO_TARGET=gmp_wrap_so
;;
*)
AC_MSG_ERROR([GMP is valid only when using Clozure CL on AMD/Intel
or ARM processors])
esac
else
AC_MSG_ERROR([GMP is valid only when using SBCL or Clozure CL])
fi
fi
AC_SUBST(GMP_WRAP_SO_TARGET)
AC_SUBST(GMP_CPPFLAGS)
AC_SUBST(GMP_LDFLAGS)
AC_SUBST(GMP_LIBDIR)
GMP_EXT=so
## If it is possible to enable the gmp wrapper, we have to check
## whether gmp is actually installed.
AS_IF([test -n "$GMP_WRAP_SO_TARGET"],[
# temporarily save CPPFLAGS and LDFLAGS
fricas_save_CPPFLAGS=$CPPFLAGS
fricas_save_LDFLAGS=$LDFLAGS
# ask for shared library in AC_CHECK_LIB
LDFLAGS="$LDFLAGS $GMP_LDFLAGS -fPIC $SOLIB_FLAGS"
AC_CHECK_LIB(gmp, __gmpz_init, [true], [AC_MSG_ERROR(
[GNU MP not found])])
CPPFLAGS="$CPPFLAGS $GMP_CPPFLAGS"
AC_CHECK_HEADERS([gmp.h], [], [AC_MSG_ERROR(
[gmp.h not found])])
# reset CPPFLAGS and LDFLAGS
CPPFLAGS=$fricas_save_CPPFLAGS
LDFLAGS=$fricas_save_LDFLAGS
GMP_LIB=-lgmp
case $target in
*darwin*) GMP_EXT=dylib ;;
*) GMP_EXT=so ;;
esac
])
AC_SUBST(GMP_LIB)
AC_SUBST(GMP_EXT)
## The following is a horrible hack to arrange for GCL to successfully
## rebuild symbol tables with "rsym" on Windows platform. It should
## go away as soon as GCL upstream is fixed.
case $fricas_lisp_flavor,$target in
'GNU Common Lisp (GCL)',*mingw*)
fricas_gcl_rsym_hack='d=`echo "(format nil \"~a\" si::*system-directory*)" | $(FRICAS_LISP) | grep "/gcl.*/" | sed -e "s,\",,g"`; cp $$d/rsym$(EXEEXT) .'
;;
*)
fricas_gcl_rsym_hack=':'
;;
esac
AC_SUBST(fricas_gcl_rsym_hack)
## How are we supposed to tell the Lisp system to eval an expression
## in batch mode?
case $fricas_lisp_flavor in
'GNU Common Lisp (GCL)')
fricas_quiet_flags='-batch'
fricas_eval_flags='-eval'
;;
ECL)
fricas_quiet_flags='-norc'
fricas_eval_flags='-eval'
;;
SBCL)
fricas_quiet_flags='--noinform --noprint --no-sysinit --no-userinit'
fricas_eval_flags='--eval'
sbcl_memory_size=`echo "(princ (sb-ext:dynamic-space-size))" | $fricas_lisp $fricas_quiet_flags`
test $sbcl_memory_size -gt 4294967296 || fricas_quiet_flags="--dynamic-space-size 4096 $fricas_quiet_flags"
;;
'CMU Common Lisp')
fricas_quiet_flags='-batch -nositeinit -noinit'
fricas_eval_flags='-eval'
;;
CLISP)
fricas_quiet_flags='--quiet -norc'
fricas_eval_flags='-x'
;;
'Clozure Common Lisp')
fricas_quiet_flags='--no-init'
fricas_eval_flags='--eval'
;;
lispworks)
fricas_quiet_flags=
fricas_eval_flags='-init - -siteinit - -eval'
;;
*) AC_MSG_ERROR([We do not know how to build jlFriCAS with this Lisp: $fricas_lisp]) ;;
esac
AC_SUBST(fricas_quiet_flags)
fricas_debug_compiler='no'
AC_ARG_ENABLE([debug-compiler],
[AS_HELP_STRING([--enable-debug-compiler],
[(for BOOT or SPAD compiler developers) add debug
information to every component of a compiler])],
[fricas_debug_compiler=$enableval])
AC_SUBST(fricas_debug_compiler)
fricas_algebra_optimization=nil
AC_ARG_ENABLE([algebra-optimization],
[AS_HELP_STRING([--enable-algebra-optimization=S],
[use S as Lisp optimize declaration for compiling
the algebra])],
[fricas_algebra_optimization=$enableval])
AC_SUBST(fricas_algebra_optimization)
AC_SUBST(fricas_all_prerequisites)
fricas_has_directory_operations=no
fricas_has_dirfd_fchdir=no
AC_CHECK_HEADERS([dirent.h],[
fricas_has_directory_operations=yes
AC_CHECK_DECLS([closedir, opendir, readdir], [],
[fricas_has_directory_operations=no],
[#define _GNU_SOURCE
#include <dirent.h>]
)
fricas_has_dirfd_fchdir=yes
AC_CHECK_DECLS([dirfd], [],
[fricas_has_dirfd_fchdir=no],
[#define _GNU_SOURCE
#include <dirent.h>]
)
AC_CHECK_DECLS([fchdir], [],
[fricas_has_dirfd_fchdir=no],
[#define _GNU_SOURCE
#include <unistd.h>]
)
], [])
if test x$fricas_has_directory_operations = xyes ; then
AC_DEFINE([HOST_HAS_DIRECTORY_OPERATIONS], [1],
[Host has POSIX directory operations])
if test x$fricas_has_dirfd_fchdir = xyes ; then
AC_DEFINE([HOST_HAS_DIRFD_FCHDIR], [1],
[Host has dirfd and fchdir])
fi
else
AC_MSG_WARN([Can not find directory operations])
fi
AC_SUBST(fricas_has_directory_operations)
fricas_c_runtime=
AC_SUBST(fricas_c_runtime)
AC_CHECK_HEADERS([signal.h],
[],
[AC_MSG_ERROR([jlFriCAS needs signal support.])])
AC_CHECK_DECLS([sigaction], [], [],
[#include <signal.h>])
AC_CHECK_HEADERS([sys/stat.h],
[],
[AC_MSG_ERROR([jlFriCAS needs <sys/stat.h>.])])
AC_CHECK_HEADERS([unistd.h], [],
[AC_MSG_ERROR([jlFriCAS needs <unistd.h>])])
AC_CHECK_DECLS([getuid, geteuid, getgid, getegid], [], [],
[#include <unistd.h>])
AC_CHECK_DECLS([kill], [], [],
[#include <signal.h>])
case $host in
*mingw*)
AC_CHECK_HEADERS([winsock2.h],
[fricas_host_has_socket=yes],
[])
fricas_c_runtime_extra="-lwsock32"
;;
*)
AC_CHECK_HEADERS([sys/socket.h sys/un.h],
[fricas_host_has_socket=yes],
[])
;;
esac
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/socket.h>
]], [[
int flag = MSG_NOSIGNAL;
]])],
[AC_DEFINE([HAVE_MSG_NOSIGNAL], [1], [Host has MSG_NOSIGNAL])],[])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <sys/socket.h>
]], [[
int flag = SO_NOSIGPIPE;
]])],
[AC_DEFINE([HAVE_SO_NOSIGPIPE], [1], [Host has SO_NOSIGPIPE])],[])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <errno.h>
#include <sys/socket.h>
]], [[
int code = EPIPE;
]])],
[AC_DEFINE([HAVE_EPIPE], [1], [Host has EPIPE])],[])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/socket.h>
#include <sys/un.h>
]], [[
struct sockaddr_un uaddr;
]])],
[AC_DEFINE([HAVE_SOCKADDR_UN], [1], [Host has sockaddr_un])],[])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/stat.h>
#include <sys/types.h>
]], [[
int code = mkdir ("./foo", (S_IRWXU | S_IRWXO | S_IRWXG));
]])],
[AC_DEFINE([HAVE_TWO_ARG_MKDIR], [1], [Host has two arg mkdir])], [])
if test x$fricas_host_has_socket != xyes; then \
AC_MSG_ERROR([jlFriCAS needs support for sockets.])
fi
## solaris-based systems tend to hide the socket library.
case $host in
*solaris*)
AC_SEARCH_LIBS([accept], [socket],
[fricas_c_runtime_extra="-lsocket"],
[AC_MSG_ERROR([socket library not found])])
;;
*) ;;
esac
AC_EGREP_CPP([has_af_local],
[
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#else
# include <winsock2.h>
#endif
#ifdef AF_LOCAL
has_af_local
#endif
],
[AC_DEFINE([HAVE_AF_LOCAL], [1], [Host has AF_LOCAL])])
AC_EGREP_CPP([has_af_unix],
[
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#else
# include <winsock2.h>
#endif
#ifdef AF_UNIX
has_af_unix
#endif
],
[AC_DEFINE([HAVE_AF_UNIX], [1], [Host has AF_UNIX])])
AC_CHECK_HEADERS([util.h],
[],
[AC_CHECK_HEADERS([pty.h], [], [])
]) # HAVE_UTIL_H or HAVE_PTY_H
AC_CHECK_DECL([openpty],
[AC_DEFINE([HAVE_OPENPTY_DECL], [1],
[openpty is declared])], [],
[
#if defined(HAVE_UTIL_H)
# include <util.h>
#elif defined(HAVE_PTY_H)
# include <pty.h>
#endif
]) # HAVE_OPENPTY_DECL
AC_CHECK_LIB([c], [openpty],
[AC_DEFINE([HAVE_OPENPTY], [1],
[openpty is available])
],
AC_CHECK_LIB([util], [openpty],
[AC_DEFINE([HAVE_OPENPTY], [1],
[openpty is available])
fricas_c_runtime_extra="${fricas_c_runtime_extra} -lutil"
],
AC_CHECK_LIB([bsd], [openpty],
[AC_DEFINE([HAVE_OPENPTY], [1],
[openpty is available])
fricas_c_runtime_extra="${fricas_c_runtime_extra} -lbsd"
])
)) # HAVE_OPENPTY
AC_SUBST(fricas_c_runtime_extra)
AC_CHECK_HEADERS([sys/wait.h])
if test x"$ac_cv_header_sys_wait_h" = xyes; then \
AC_CHECK_DECLS([wait],
[],
[],
[#include <sys/wait.h>])
fi
AC_CHECK_DECLS([fork],
[],
[],
[#include <unistd.h>])
if test x"$ac_cv_have_decl_fork" = xyes \
-a x"$ac_cv_have_decl_wait" = xyes; then \
fricas_c_runtime="$fricas_c_runtime terminal_io"
fricas_src_all="$fricas_src_all all-sman all-clef"
fricas_src_subdirs="$fricas_src_subdirs clef sman"
FRICAS_MAKEFILE([src/clef/Makefile])
FRICAS_MAKEFILE([src/sman/Makefile])
else
AC_MSG_NOTICE([Superman component is disabled.])
fi
fricas_src_all="all-fricassys $fricas_src_all"
AC_PATH_XTRA
## Output directives for the C compiler
AC_SUBST(X_CFLAGS)
## Output directives for the linker
AC_SUBST(X_LIBS)
## Output any extra libraries required by X11
AC_SUBST(X_EXTRA_LIBS)
## Finally, output the list of libraries that need to appear before -lX11
## Some part of FriCAS depends on Xpm. That library has kind uncertain
## future. At some point in the past, it was deprecated, to be
## replaced by xpm-nox; then came back again. So, its support may
## vary from system to system. For the moment, we do a quick sanity
## check and disable X11 if Xpm is not present. Long term, FriCAS should
## get rid of dependence on Xpm. Another possibility is to (optionally)
## bundle Xpm source tarball and build Xpm if needed.
if test -z $no_x; then
AC_CHECK_LIB([Xpm], [XpmReadFileToImage],
[fricas_has_xpm=yes],
[fricas_has_xpm=no],
[$X_LIBS -lX11])
else
fricas_has_xpm=no
fi
X_PRE_LIBS="-lXpm $X_PRE_LIBS"
AC_SUBST(X_PRE_LIBS)
## If the system supports X11, then build graphics and hyperdoc
if test x"$fricas_has_xpm" = xyes; then
fricas_c_runtime="$fricas_c_runtime graphics"
fricas_src_all="$fricas_src_all all-graph"
fricas_src_subdirs="$fricas_src_subdirs graph"
FRICAS_MAKEFILE([src/graph/Makefile])
FRICAS_MAKEFILE([src/graph/Gdraws/Makefile])
FRICAS_MAKEFILE([src/graph/view2D/Makefile])
FRICAS_MAKEFILE([src/graph/view3D/Makefile])
FRICAS_MAKEFILE([src/graph/viewAlone/Makefile])
FRICAS_MAKEFILE([src/graph/viewman/Makefile])
else
AC_MSG_NOTICE([The Graphics and HyperDoc components are disabled.])
fi
AC_SUBST(fricas_src_all)
AC_SUBST(MAYBE_VIEWPORTS)
AC_SUBST(XVFB)
if test x"$fricas_has_xpm" = xyes; then
AC_CHECK_HEADER([regex.h],
[fricas_src_all="$fricas_src_all all-hyper all-doc"
fricas_src_subdirs="$fricas_src_subdirs hyper doc"
AC_CHECK_PROGS([XVFB_RUN], [xvfb-run])
if test -n "$XVFB_RUN"; then
MAYBE_VIEWPORTS=viewports
XVFB="xvfb-run -a -s '-screen 0 1024x768x24'"
else
AC_MSG_NOTICE([HyperDoc graphics must be built separately.])
fi
],
[AC_MSG_NOTICE([HyperDoc is disabled.])])
fi
# We need the Makefile (for util.ht) even if we do not build HyperDoc.
FRICAS_MAKEFILE([src/hyper/Makefile])
FRICAS_MAKEFILE([src/doc/Makefile])
BASE=""
AC_SUBST(BASE)
FRICAS=${BASE}${fricas_targetdir}
AC_SUBST(FRICAS)
CCF="-g -O2 -Wall -D_GNU_SOURCE"
LDF=
case $target in
*bsd*|*dragonfly*)
AC_DEFINE([BSDplatform], [], [BSD flavour])
CCF="-O2 -pipe -Wall -D_GNU_SOURCE -I/usr/local/include"
LDF="-L/usr/local/lib"
;;
*darwin*)
AC_DEFINE([MACOSXplatform], [], [MACOS flavour])
CCF="-O2 -Wall -D_GNU_SOURCE"
;;
esac
AC_SUBST(CCF)
AC_SUBST(LDF)
###################################################################
## The following section deals with the inclusion of the hunchentoot
## webserver which can be used for the jupyter interface for FriCAS.
## It is currently only supported on Linux for SBCL.
## This piece of configure code is courtesy of
## Ralf Hemmecke and Kurt Pagani.
## There are, in fact, two switches.
## --with-quicklisp="/absolute/path-to-quicklisp"
## and
## --enable-hunchentoot.
## Whereas --enable-hunchentoot deals with the actual inclusion of
## hunchentoot into FriCASsys, --with-quicklisp specifies that
## hunchentoot should be loaded via quicklisp.
## Since hunchentoot is not always available or not compatible
## we give another way to install it using quicklisp:
## curl -O https://beta.quicklisp.org/quicklisp.lisp
## sbcl --load quicklisp.lisp
## (quicklisp-quickstart:install)
## (ql:quickload "hunchentoot")
## (quit)
AC_ARG_WITH([quicklisp],
[AS_HELP_STRING([--with-quicklisp=PATH],
[use quicklisp installation path (default "~/quicklisp")])],
[USE_QUICKLISP=yes
AS_IF([test -d $withval],
[QUICKLISPPATH=$withval],
[AS_IF([test -d ~/quicklisp],
[QUICKLISPPATH=~/quicklisp],
[AC_MSG_ERROR([quicklisp path not available])])])],
[USE_QUICKLISP=no])
AC_ARG_WITH([system-asdf],
[AS_HELP_STRING([--with-system-asdf=PATH],
[use system or Debian ASDF installation path (default "/usr/share/common-lisp/source/cl-asdf/asdf.lisp")])],
[USE_SYSTEM_ASDF=yes
AS_IF([test -d $withval],
[ASDFPATH=$withval],
[AS_IF([test -d /usr/share/common-lisp/source/cl-asdf],
[ASDFPATH="/usr/share/common-lisp/source/cl-asdf/asdf.lisp"],
[AC_MSG_ERROR([System or Debian ASDF path not available, install the (cl-)asdf package])])])],
[USE_SYSTEM_ASDF=no])
###################################################################
## Default is --enable-hunchentoot=no which means hunchentoot will
## not be included into FRICASsys and thus jfricas will not work.
## With --enable-hunchentoot, configure checks whether hunchentoot is
## available for inclusion into FRICASsys.
## If hunchentoot is included into FRICASsys in the binary
## distribution, then the target system does not need to have
## hunchentoot installed, but must provide jupyter so that the jfricas
## interface can work.
INCLUDE_WEBSPAD=no
AC_ARG_ENABLE(hunchentoot,
[AS_HELP_STRING([--enable-hunchentoot],
[include the hunchentoot webserver into jlFriCASsys, (yes/no)])],
[AS_CASE([$enableval],
[yes], [AS_IF([test "$fricas_lisp_flavor" = SBCL \
|| test "$fricas_lisp_flavor" = 'Clozure Common Lisp' \
|| test "$fricas_lisp_flavor" = ECL],
[INCLUDE_WEBSPAD=yes],
[INCLUDE_WEBSPAD=no
AC_MSG_ERROR([hunchentoot is only available for SBCL, Clozure CL or ECL])])],
[no], [INCLUDE_WEBSPAD=no],
[AC_MSG_ERROR([only yes/no allowed as value for --enable-hunchentoot])]
)]
)
# Now Check that Hunchentoot is available.
WEBSPAD_REQUIREMENTS=
AS_IF([test x"$USE_QUICKLISP" = xyes],
AS_IF([test x"$USE_SYSTEM_ASDF" = xyes],
[WEBSPAD_REQUIREMENTS="(load \"$QUICKLISPPATH/setup.lisp\")(load \"$ASDFPATH\")(require (quote hunchentoot))"],
[WEBSPAD_REQUIREMENTS="(load \"$QUICKLISPPATH/setup.lisp\")(require (quote hunchentoot))"]),
AS_IF([test x"$USE_SYSTEM_ASDF" = xyes],
[WEBSPAD_REQUIREMENTS="(load \"$ASDFPATH\")(require (quote hunchentoot))"],
[WEBSPAD_REQUIREMENTS="(require :asdf)(require (quote hunchentoot))"]))
AS_IF([test x"$INCLUDE_WEBSPAD" = xyes],
[AC_MSG_CHECKING([for asdf and hunchentoot])
AS_IF([$fricas_lisp --eval "(progn $WEBSPAD_REQUIREMENTS)"],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([asdf and hunchentoot are required for --enable-hunchentoot])
INCLUDE_WEBSPAD=no])]
)
AS_IF([test x"$INCLUDE_WEBSPAD" = xyes],
[AC_MSG_NOTICE([Webserver hunchentoot will be included into FRICASsys.])],
[AC_MSG_WARN([No webserver will be included into FRICASsys.])
WEBSPAD_REQUIREMENTS=""]
)
JULIA_CPPFLAGS=""
JULIA_LDFLAGS=""
JULIA_LIB=""
JULIA_LIBDIR=""
JULIA_LISP_REQUIREMENTS=""
JULIA_USE_MLINK=no
JULIA_WRAP_SO_TARGET=""
AC_ARG_WITH([julia],
[AS_HELP_STRING([--with-julia=PATH],
[specify prefix directory for the installed Julia package.
Equivalent to --with-julia-include=PATH/include
plus --with-julia-lib=PATH/lib])],
[JULIA_WRAP_SO_TARGET=julia_wrap_so
if test x$withval = x; then
JULIA_CPPFLAGS=""
JULIA_LDFLAGS=""
JULIA_LIBDIR=""
else
JULIA_CPPFLAGS=-I$withval/include
JULIA_LDFLAGS=-L$withval/lib
JULIA_LIBDIR=$withval/lib/
fi])
AC_ARG_WITH([julia-include],
[AS_HELP_STRING([--with-julia-include=PATH],
[specify directory for installed Julia include files])],
[JULIA_WRAP_SO_TARGET=julia_wrap_so
JULIA_CPPFLAGS="-I$withval"])
AC_ARG_WITH([julia-lib],
[AS_HELP_STRING([--with-julia-lib=PATH],
[specify directory for the installed Julia library])],
[JULIA_WRAP_SO_TARGET=julia_wrap_so
JULIA_LDFLAGS="-L$withval"
JULIA_LIBDIR="$withval/"])
AC_ARG_ENABLE([julia],
[AS_HELP_STRING([--enable-julia],
[use Julia with Clozure CL or SBCL])],
[case $enableval in
yes) JULIA_WRAP_SO_TARGET=julia_wrap_so ;;
no) JULIA_WRAP_SO_TARGET="" ;;
*) AC_MSG_ERROR([--enable-julia only allows yes or no as an argument]) ;;
esac]
ac_julia_config=$(julia -e 'print(joinpath(Sys.BINDIR, "../share/julia/julia-config.jl"))')
JULIA_LIBDIR=$(julia -e 'print(joinpath(Sys.BINDIR, "../lib/"))')
JULIA_CPPFLAGS=$(julia $ac_julia_config --cflags)
JULIA_LDFLAGS=$(julia $ac_julia_config --ldflags)
JULIA_LIB=$(julia $ac_julia_config --ldlibs)
)
AC_ARG_ENABLE([mathlink],
[AS_HELP_STRING([--enable-mathlink],
[use MathLink.jl with Julia if enabled (yes/no)])],
[AS_CASE([$enableval],
[yes|no], [JULIA_USE_MLINK=$enableval],
[AC_MSG_ERROR([only yes/no allowed as value for --enable-mathlink])]
)]
)
## Check if Julia is really compatible with the Lisp flavour
## and add the Lisp requirements, if any
if test -n "$JULIA_WRAP_SO_TARGET" ; then
FRICAS_CHECK_PROG([JULIA], [julia], ['julia' not found in $PATH])
if test "$fricas_lisp_flavor" = SBCL ; then
JULIA_LISP_REQUIREMENTS="(require :asdf)(require :sb-concurrency)"
true
elif test "$fricas_lisp_flavor" = 'Clozure Common Lisp' ; then
case $(uname -m) in
arm*|i386|i486|i586|i686|x86_64)
AS_IF([test x"$USE_QUICKLISP" = xyes],
[JULIA_LISP_REQUIREMENTS="(load \"$QUICKLISPPATH/setup.lisp\")(require :queues)"],
[JULIA_LISP_REQUIREMENTS="(require :asdf)(require :queues)"])
;;
*)
AC_MSG_ERROR([Julia support is only valid with Clozure CL on AMD/Intel
or ARM processors])
esac
else
AC_MSG_ERROR([Julia support is only valid with SBCL or Clozure CL])
fi
fi
AC_ARG_WITH([julia-config],
[AS_HELP_STRING([--with-julia-config=PATH],
[use julia-config.jl script path given instead of the default one
to determine build parameters])],
[JULIA_WRAP_SO_TARGET=julia_wrap_so
JULIA_CPPFLAGS=$(julia $withval --cflags)
JULIA_LDFLAGS=$(julia $withval --ldflags)
JULIA_LIB=$(julia $withval --ldlibs)
JULIA_LIBDIR=$(julia -e 'print(joinpath(Sys.BINDIR, "../lib/"))')
])
# Now Check that Common Lisp requirements are available.
AS_IF([test x"$JULIA_LISP_REQUIREMENTS" = xyes],
[AC_MSG_CHECKING([Common Lisp requirements])
AS_IF([$fricas_lisp --eval "(progn $JULIA_LISP_REQUIREMENTS)"],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([Common Lisp requirements are not satified for --enable-julia])
])]
)
AC_SUBST(JULIA_WRAP_SO_TARGET)
AC_SUBST(JULIA_CPPFLAGS)
AC_SUBST(JULIA_LDFLAGS)
AC_SUBST(JULIA_LIB)