aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
blob: cad9439051ea8edc67f3f3827d1a1ed67d2dffad (plain)
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
AC_INIT([Open Axiom], [1.5.1~dev], [pashev.igor@gmail.com])
AC_CANONICAL_TARGET

dnl clisp 2.49.92
dnl sbcl 2.1.1
dnl gcl 2.6.12
dnl ecl 20.4.24

AC_CONFIG_SRCDIR([src/algebra/boolean.spad.pamphlet])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])

AM_INIT_AUTOMAKE([-Wall dist-xz foreign subdir-objects])

dnl **** C++ and libraries ****
AC_PROG_CC
AX_CXX_COMPILE_STDCXX([20], [noext], [mandatory])
AC_CHECK_SIZEOF([void *])

AC_CHECK_HEADERS_ONCE([fcntl.h unistd.h])
AC_CHECK_HEADERS_ONCE([sys/ioctl.h sys/types.h sys/stat.h])

AC_CHECK_DECLS([fork, geteuid, getgid, getuid, mktemp, tempnam])

AC_CHECK_HEADERS_ONCE([sys/wait.h])
AC_CHECK_DECLS([wait], [], [], [[
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
]])

AC_CHECK_HEADERS_ONCE([sys/mman.h])
AC_CHECK_DECLS([MAP_ANONYMOUS, MAP_ANON], [], [], [[
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
]])


AC_CHECK_HEADERS_ONCE([sys/socket.h sys/un.h])
AC_CHECK_DECLS([AF_LOCAL, AF_UNIX], [], [], [[
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
#endif
]])

AC_CHECK_HEADERS_ONCE([libutil.h pty.h termios.h util.h])
AC_CHECK_DECLS([openpty], [], [], [[
#if HAVE_SYS_IOCTL_H
#  include <sys/ioctl.h>
#endif
#if HAVE_SYS_TYPESL_H
#  include <sys/types.h>
#endif
#if HAVE_LIBUTIL_H
#  include <libutil.h>
#endif
#if HAVE_PTY_H
#  include <pty.h>
#endif
#if HAVE_TERMIOS_H
#  include <termios.h>
#endif
#if HAVE_UTIL_H
#  include <util.h>
#endif
]])
AC_SEARCH_LIBS([openpty], [util])


dnl **** LISP ****

AC_ARG_WITH([lisp],
  [AS_HELP_STRING([--with-lisp=LISP], [use LISP to build Open Axiom])],
  [OA_LISP="$withval"],
  [AC_PATH_PROGS([OA_LISP], [sbcl gcl ecl clisp clozure], [none])])
AS_IF([test "x$OA_LISP" = xnone], [AC_MSG_ERROR([could not find suitable Lisp])])

AC_MSG_CHECKING([Lisp])
AC_MSG_RESULT([$OA_LISP])

AC_MSG_CHECKING([for Lisp flavor])
oa_lisp_impl_type=`echo '(lisp-implementation-type)' | $OA_LISP 2>&AS_MESSAGE_LOG_FD`
AS_CASE([$oa_lisp_impl_type],
  [*"SBCL"*], [oa_lisp_flavor="sbcl"],
  [*"GNU Common Lisp"*], [oa_lisp_flavor="gcl"],
  [*"Embeddable Common-Lisp"*], [oa_lisp_flavor="ecl"],
  [*"CLISP"*], [oa_lisp_flavor="clisp"],
  [*"Clozure Common Lisp"*], [oa_lisp_flavor="clozure"],
  [AC_MSG_RESULT([unknown])
   AC_MSG_ERROR([unsupported Lisp])])
AC_MSG_RESULT([$oa_lisp_flavor])

AS_CASE([$oa_lisp_flavor],
  [sbcl], [OA_LISP_BATCH_FLAGS='--noinform --noprint --no-sysinit --no-userinit --disable-debugger'
           OA_LISP_EVAL_FLAGS='--eval'
           oa_delay_ffi=yes
           char_type='char'
           double_type='double'
           float_type='float'
           int_type='int'
           pointer_type='(* t)'
           string_type='c-string'
           void_type='void'],
  [gcl], [OA_LISP_BATCH_FLAGS='-batch'
          OA_LISP_EVAL_FLAGS='-eval'
          oa_delay_ffi=no
          void_type='void'
          char_type='char'
          int_type='int'
          float_type='float'
          double_type='double'
          string_type='string'
          AS_IF([test "x$SIZEOF_VOID_P" = x4], [pointer_type='fixnum'], [pointer_type='(signed-integer 64)'])],
  [ecl], [OA_LISP_BATCH_FLAGS='--nodebug --norc'
          OA_LISP_EVAL_FLAGS='--eval'
          oa_delay_ffi=no
          void_type=':void'
          char_type=':char'
          int_type=':int'
          float_type=':float'
          double_type=':double'
          string_type=':cstring'
          pointer_type=':pointer-void'],
  [clisp], [OA_LISP_BATCH_FLAGS='-q -q -norc'
            OA_LISP_EVAL_FLAGS='-x'
            oa_delay_ffi=yes
            void_type='nil'
            char_type='character'
            int_type='int'
            float_type='single-float'
            double_type='double-float'
            string_type='c-string'
            pointer_type='c-pointer'],
  [clozure], [OA_LISP_BATCH_FLAGS='--quiet --no-init'
              OA_LISP_EVAL_FLAGS='--eval'
              oa_delay_ffi=yes
              void_type=':void'
              char_type=':unsigned-byte'
              int_type=':signed-fullword'
              float_type=':single-float'
              double_type=':double-float'
              string_type=':address'
              pointer_type=':address'],
  [AC_MSG_ERROR([unsupported Lisp flavor $oa_lisp_flavor])])

AC_MSG_CHECKING([how to invoke Lisp])
AC_MSG_RESULT([$OA_LISP $OA_LISP_BATCH_FLAGS $OA_LISP_EVAL_FLAGS])

AC_MSG_CHECKING([for compiled Lisp file extension])
oa_fasl_type=`$OA_LISP $OA_LISP_BATCH_FLAGS $OA_LISP_EVAL_FLAGS '(progn (format t "oa_fasl_type:~a" (pathname-type (compile-file-pathname "non-existing.lisp"))) (quit))' 2>&AS_MESSAGE_LOG_FD`
AS_IF([test "x$oa_fasl_type" = x], [AC_MSG_RESULT([failed])
                                    AC_MSG_ERROR([Lisp compiler does not work, see config.log for details])])
oa_fasl_type=`echo "$oa_fasl_type" | $AWK -F : '/oa_fasl_type:/{print $2}'`
AC_MSG_RESULT([$oa_fasl_type])

AC_SUBST([OA_LISP])
AC_SUBST([OA_LISP_BATCH_FLAGS])
AC_SUBST([OA_LISP_EVAL_FLAGS])
AC_SUBST([FASLEXT], [$oa_fasl_type])
AC_DEFINE_UNQUOTED([FASLEXT], ["$oa_fasl_type"], [Compiled Lisp file extension (usually "fasl").])
AC_DEFINE_UNQUOTED([OPENAXIOM_BASE_RTS], [Runtime::$oa_lisp_flavor], [The kind of base runtime system for this build.])

AC_MSG_CHECKING([Lisp char type])
AC_MSG_RESULT([$char_type])
AC_SUBST([char_type])

AC_MSG_CHECKING([Lisp double type])
AC_MSG_RESULT([$double_type])
AC_SUBST([double_type])

AC_SUBST([float_type])
AC_MSG_CHECKING([Lisp float type])
AC_MSG_RESULT([$float_type])

AC_MSG_CHECKING([Lisp int type])
AC_MSG_RESULT([$int_type])
AC_SUBST([int_type])

AC_MSG_CHECKING([Lisp pointer type])
AC_MSG_RESULT([$pointer_type])
AC_SUBST([pointer_type])

AC_MSG_CHECKING([Lisp string type])
AC_MSG_RESULT([$string_type])
AC_SUBST([string_type])

AC_MSG_CHECKING([Lisp void type])
AC_MSG_RESULT([$void_type])
AC_SUBST([void_type])


AC_SUBST([oa_delay_ffi])
AC_SUBST([oa_editor], [/usr/bin/editor])
AC_SUBST([oa_enable_profiling], [nil])
AC_SUBST([oa_keep_files], [])
AC_SUBST([oa_optimize_options], [speed])
AC_SUBST([oa_standard_linking], [no])
AC_SUBST([oa_use_llvm], [no])
AC_SUBST([oa_c_runtime_extra], [])


AC_DEFINE_UNQUOTED([OPENAXIOM_EXEEXT], ["$ac_cv_exeext"], [File extensions of the executables (e. g. ".exe").])
AC_DEFINE_UNQUOTED([OPENAXIOM_USE_GUI], [0], [Whether to use the Qt-base GUI as driver.])
AC_DEFINE_UNQUOTED([OPENAXIOM_USE_SMAN], [1], [Whether to use the session manager as driver.])

OA_DEPS=dependencies.mk
rm -f "$OA_DEPS"
OA_RESOLVE_DEPENDENCIES([src/boot], ["$OA_DEPS"])
OA_RESOLVE_DEPENDENCIES([src/boot/strap], ["$OA_DEPS"])
OA_RESOLVE_DEPENDENCIES([src/interp], ["$OA_DEPS"])
AC_SUBST_FILE([OA_DEPS])
AC_SUBST([OA_DEPS_FILE], [$OA_DEPS])

AC_CONFIG_LINKS([src/boot/stage1/ast.boot:src/boot/ast.boot
                 src/boot/stage1/includer.boot:src/boot/includer.boot
                 src/boot/stage1/parser.boot:src/boot/parser.boot
                 src/boot/stage1/pile.boot:src/boot/pile.boot
                 src/boot/stage1/scanner.boot:src/boot/scanner.boot
                 src/boot/stage1/tokens.boot:src/boot/tokens.boot
                 src/boot/stage1/translator.boot:src/boot/translator.boot
                 src/boot/stage1/utility.boot:src/boot/utility.boot])

AC_CONFIG_FILES([Makefile src/lisp/core.lisp])
AC_OUTPUT