-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
263 lines (221 loc) · 6.19 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
dnl Process this file with autoconf to produce a configure script.
dnl
dnl This code is part of the SML/NJ system (http://smlnj.org)
dnl
dnl COPYRIGHT (c) 2018 The Fellowship of SML/NJ
dnl All rights reserved.
dnl
AC_INIT(asdl,3.0,)
AC_PREREQ(2.60)
AC_COPYRIGHT([[COPYRIGHT (c) 2018 The Fellowship of SML/NJ]])
AC_CONFIG_SRCDIR(src/lib/asdl/std-types.asdl)
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR(config)
dnl
dnl include additional macros
dnl
sinclude(config/check_smlnj.m4)
sinclude(config/check_smlnj_heap_suffix.m4)
sinclude(config/ax_cxx_compile_stdcxx.m4)
dnl
dnl get host information
dnl
AC_CANONICAL_HOST
dnl
dnl define various directory paths
dnl
ASDL_ROOT=`pwd`
ASDL_MKDIR=$ASDL_ROOT/mk
ASDL_BINDIR=$ASDL_ROOT/bin
ASDL_LIBDIR=$ASDL_ROOT/lib
ASDL_INCDIR=$ASDL_ROOT/include
ASDL_SRCDIR=$ASDL_ROOT/src
ASDLGEN_SRCDIR=$ASDL_SRCDIR/asdlgen
AC_SUBST(ASDL_ROOT)
AC_SUBST(ASDL_MKDIR)
AC_SUBST(ASDL_BINDIR)
AC_SUBST(ASDL_LIBDIR)
AC_SUBST(ASDL_INCDIR)
AC_SUBST(ASDL_SRCDIR)
AC_SUBST(ASDLGEN_SRCDIR)
dnl check for standard programs
dnl
AC_PROG_CPP
AC_PROG_CC([clang gcc cc])
AC_PROG_CXX([clang++ g++ c++])
AX_CXX_COMPILE_STDCXX(11,[],[mandatory])
AC_PROG_INSTALL
AC_PROG_MAKE_SET
## TODO --enable options for other target languages: Java, Haskell, OCaml, ...
## also check for language implementations
#################### SML configuration ####################
dnl
dnl We support building with both SML/NJ (the default) or MLton.
dnl
dnl first check for --with-mlton=path flag
dnl
AC_ARG_WITH([mlton],
[AS_HELP_STRING([--with-mlton=<path-to-mlton>],
[use the MLton Standard ML compiler to build Diderot])],
[with_mlton=yes],[with_mlton=no])
if test x"$with_mlton" = xyes ; then
if test x"$ac_cv_path_with_mlton" = x ; then
# look for mlton in the PATH
AC_PATH_PROGS(with_mlton, mlton, no)
if test x"$MLTON" = xno ; then
AC_MSG_ERROR([unable to find mlton executable; please specify the path])
fi
else
with_mlton=$ac_cv_path_with_mlton
case $with_mlton in
/*) ;;
*) AC_MSG_ERROR([please specify absolute path for mlton executable]) ;;
esac
if test ! -x $with_mlton ; then
AC_MSG_ERROR([invalid path for mlton; $with_mlton is not executable])
fi
fi
fi
if test x"$with_mlton" = xno ; then
# we are using SML/NJ
#
dnl check that we have a compatible version of SML/NJ
dnl
CHECK_SMLNJ([AC_MSG_ERROR([unable to find SML/NJ installation; check your PATH or set SMLNJ_CMD])])
if test $SMLNJ_MAJOR_VERSION -lt 110 \
-o $SMLNJ_MINOR_VERSION -lt 83
then
AC_MSG_ERROR([installation requires SML/NJ version 110.83+ (available from smlnj.org)])
fi
dnl determine the heap-image suffix
dnl
CHECK_SMLNJ_HEAP_SUFFIX([
AC_MSG_ERROR([unsupported configuration ${host_cpu}-${host_os}])])
dnl look for ml-makedepend
dnl
tmpPATH="$SMLNJ_PATH:$PATH"
AC_PATH_PROG(ML_MAKEDEPEND, ml-makedepend, ":", $tmpPATH)
AC_SUBST(ML_MAKEDEPEND)
dnl
dnl look for ml-build
dnl
tmpPATH="$SMLNJ_PATH:$PATH"
AC_PATH_PROG(ML_BUILD, ml-build, none, $tmpPATH)
if test $ML_BUILD = none ; then
AC_MSG_ERROR([ml-build not found])
fi
AC_SUBST(ML_BUILD)
SML=smlnj
HEAP_IMAGE_DIR=$DIDEROT_BINDIR/.heap
INSTALL_SMLNJ_WRAPPER=$DIDEROT_BINDIR/install-sml-wrapper.sh
AC_SUBST(HEAP_IMAGE_DIR)
AC_SUBST(INSTALL_SMLNJ_WRAPPER)
else
# we are using MLton
MLTON=$with_mlton
AC_SUBST(MLTON)
SML=mlton
fi
AC_SUBST(SML)
#################### end SML configuration ####################
#################### Multiprecision integer configuration ####################
# HACK: for now we just hardwire gmp from MacPorts
#
AC_DEFINE(
[ASDL_USE_GNU_MP], 1,
[Define to 1 to use the GNU Multiprecision Library.])
CPPFLAGS="$CPPFLAGS -I/opt/local/include"
LDFLAGS="$LDFLAGS -L/opt/local/lib"
LIBS="-lgmp"
#################### end Multiprecision integer configuration ####################
#################### Library configuration ####################
dnl FIXME: this works for now, but we should probably switch to libtool
dnl
AC_PATH_PROG(LD, [ld], [none])
if test x$LD = xnone ; then
AC_MSG_ERROR([cannot find ld command])
fi
AC_SUBST(LD)
dnl
dnl OS-specific linking issues
dnl
CXXFLAG_fPIC=""
case "$host_os" in
darwin*)
DSLEXT="dylib"
LD_STATIC=$LD
LD_DYNAMIC="$CXX -dynamiclib"
;;
linux*)
# On Linux we include the -rpath option to pick up dynamically-loaded libraries
# and the -fPIC compiler flag to generate position-indenpendent code
CXXFLAG_fPIC="-fPIC"
DSLEXT="so"
LD_STATIC=$LD
LD_DYNAMIC="$CXX -shared"
;;
esac
AC_SUBST(LD_STATIC)
AC_SUBST(LD_DYNAMIC)
AC_SUBST(CXXFLAG_fPIC)
AC_SUBST(DSLEXT)
#################### end Library configuration ####################
#################### config.h ####################
AH_TOP([
/*
* This code is part of the SML/NJ System (http://smlnj.org)
*
* COPYRIGHT (c) 2018 The Fellowship of SML/NJ.
*/
#ifndef _ASDL_CONFIG_H_
#define _ASDL_CONFIG_H_
])
AH_BOTTOM([
#endif /* !_ASDL_CONFIG_H_ */
])
#################### end config.h ####################
#################### write output ####################
dnl The compiler Makefile depends on which SML system we are
dnl using.
if test x"$SML" = xmlton ; then
SRC_MAKEFILE_IN=":src/asdlgen/Makefile_mlton.in"
FRAGMENTS_MAKEFILE="src/gen/fragments/Makefile"
else
SRC_MAKEFILE_IN=""
FRAGMENTS_MAKEFILE=""
fi
AC_CONFIG_FILES(
dnl
dnl ***** Makefiles *****
Makefile
doc/Makefile
doc/manual-2.0/Makefile
doc/manual-3.0/Makefile
examples/Makefile
src/Makefile
src/asdlgen/Makefile$SRC_MAKEFILE_IN
$FRAGMENTS_MAKEFILE
src/lib/Makefile
src/lib/cxx/Makefile
src/tests/Makefile
src/tests/basics/Makefile
src/tests/primitives/Makefile
dnl
dnl
src/asdlgen/common/config.sml:src/asdlgen/common/config_sml.in
)
AC_CONFIG_HEADERS(src/lib/cxx/include/asdl/config.h:config/config_h.in)
dnl
dnl shell scripts
dnl
AC_CONFIG_FILES([
bin/install-sml-wrapper.sh:config/install-sml-wrapper_sh.in
], [chmod +x bin/install-sml-wrapper.sh])
AC_CONFIG_FILES([
src/gen/fragments/mkfrags.sh:src/gen/fragments/mkfrags_sh.in
], [chmod +x src/gen/fragments/mkfrags.sh])
AC_CONFIG_FILES([
src/gen/fragments/mkmk.sh:src/gen/fragments/mkmk_sh.in
], [chmod +x src/gen/fragments/mkmk.sh])
AC_OUTPUT
#################### end write output ####################