-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconfigure.ac
558 lines (491 loc) · 14.5 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
dnl Process this file with autoconf to produce a configure script.
dnl
dnl COPYRIGHT (c) 2019 The Manticore Project (manticore.cs.uchicago.edu)
dnl All rights reserved.
dnl
dnl NOTE: MANTICORE_DIST_VERSION is an M4 variable defined in config/aclocal.m4
dnl
AC_INIT(manticore,MANTICORE_DIST_VERSION,http://manticore.cs.uchicago.edu)
AC_PREREQ(2.59)
AC_CONFIG_AUX_DIR(config)
dnl
dnl include extra macros
dnl
sinclude(config/check_smlnj.m4)
sinclude(config/acx_pthread.m4)
sinclude(config/check_leading_uscore.m4)
dnl
dnl get host and target information
dnl
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
if test $target_cpu != $host_cpu ; then
CROSS_COMPILING=1
RUNTIME_DIR=
else
CROSS_COMPILING=0
RUNTIME_DIR=runtime
fi
AC_SUBST(CROSS_COMPILING)
case $target_cpu in
i386|i486|i586|i686) TARGET_CPU=TARGET_X86; ARCH=x86 ;;
x86_64) TARGET_CPU=TARGET_X86_64; ARCH=x86_64 ;;
*) AC_MSG_ERROR([target cpu ${target_cpu} is not supported]) ;;
esac
case $target_os in
linux|linux-gnu) TARGET_OS=TARGET_LINUX; OS=linux; LDFLAGS="$LDFLAGS -lm" ;;
darwin*) TARGET_OS=TARGET_DARWIN; OS=darwin ;;
cygwin) TARGET_OS=TARGET_CYGWIN; OS=cygwin ;;
*) AC_MSG_ERROR([target os ${target_os} is not supported]) ;;
esac
dnl
dnl check to see if a x86-darwin host supports 64-bit executables
dnl
if test $OS = darwin -a $ARCH = x86 -a $CROSS_COMPILING = 0; then
if test -x /usr/sbin/sysctl ; then
AC_MSG_CHECKING([for 64-bit support])
/usr/sbin/sysctl -n machdep.cpu.extfeatures | grep -q EM64T
if test $? = 0 ; then
TARGET_CPU=TARGET_X86_64; ARCH=x86_64
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
fi
fi
dnl
dnl FOr now, we only work on x86_64, so check that.
dnl
if test x"$TARGET_CPU" != xTARGET_X86_64 ; then
AC_MSG_ERROR([sorry, but we only support the x86-64 processor])
else
CFLAG_M64="-m64"
fi
AC_SUBST(CFLAG_M64)
TARGET=$ARCH-$OS
AC_SUBST(TARGET_CPU)
AC_SUBST(TARGET_OS)
AC_SUBST(TARGET)
AC_SUBST(OS)
dnl
dnl Manticore version information
dnl
case $PACKAGE_VERSION in
development) VERSION=0.0.0 ;;
*.*.*) VERSION=$PACKAGE_VERSION ;;
*.*) VERSION=$PACKAGE_VERSION.0 ;;
*) AC_MSG_ERROR([badly formed version number \"$PACKAGE_VERSION\"])
;;
esac
[MAJOR_VERSION=`echo $VERSION \
| sed -e 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'`]
[MINOR_VERSION=`echo $VERSION \
| sed -e 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'`]
[PATCH_VERSION=`echo $VERSION \
| sed -e 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'`]
MANTICORE_VERSION=$PACKAGE_VERSION
BUILD_DATE=`date +%Y-%m-%d`
dnl BUILD_VERSION and RELEASE_DATE are defined in config/aclocal.m4
dnl by the following macro:
MANTICORE_SET_VERSION
AC_SUBST(MANTICORE_VERSION)
AC_SUBST(MAJOR_VERSION)
AC_SUBST(MINOR_VERSION)
AC_SUBST(PATCH_VERSION)
AC_SUBST(BUILD_DATE)
AC_SUBST(REVISION)
dnl
dnl check for standard programs
dnl
AC_PROG_CC([clang gcc cc])
AC_PROG_CC_C99
AC_PROG_CXX
AC_GNU_SOURCE
AC_CHECK_PROG(AR, ar, ar)
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_PROG_MAKE_SET
dnl
dnl extra CFLAGS
dnl
CFLAGS="$CFLAGS -D_GNU_SOURCE -pedantic"
CXXFLAGS="$CXXFLAGS -D_GNU_SOURCE -D__STDC_FORMAT_MACROS"
dnl
dnl check for whether we should use the no_pie argument. LLVM has a
dnl new default that generates a warning for Manticore-compiled code.
dnl
save_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,-no_pie"
AC_MSG_CHECKING([Checking for -Wl,-no_pie])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[]])],
[ac_supports_no_pie=yes],
[ac_supports_no_pie=no])
AC_MSG_RESULT($ac_supports_no_pie)
if test "$ac_supports_no_pie" = "no" ; then
LDFLAGS=$save_LDFLAGS
fi
dnl
dnl For various reasons, "gcc -E" doesn't work as a cpp command, so we look for
dnl the old cpp.
dnl
AC_PATH_PROGS(CPP, cpp-4.2 cpp-4.0 cpp, NONE, $PATH:/lib:/usr/lib)
if test x$CPP = x ; then
AC_MSG_ERROR([no cpp found])
fi
dnl
dnl check for pthreads
dnl
ACX_PTHREAD()
dnl
dnl check for various library routines etc.
dnl
AC_CHECK_FUNCS(posix_memalign)
if test x"$ac_cv_func_posix_memalign" != xyes ; then
AC_CHECK_FUNCS(memalign)
if test x"$ac_cv_func_posix_memalign" != xyes ; then
AC_CHECK_FUNCS(valloc)
fi
fi
AC_CHECK_FUNCS(mach_absolute_time)
AC_CHECK_TYPES([struct timespec])
dnl
dnl check for clock_gettime. On Linux, this requires librt.
dnl
save_LIBS=$LIBS
LIBS="-lrt $LIBS"
AC_MSG_CHECKING([for clock_gettime])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <time.h>]],
[[struct timespec t; clock_gettime(CLOCK_REALTIME, &t); ]])],
[ ac_cv_func_clock_gettime=yes;
AC_DEFINE(HAVE_CLOCK_GETTIME, [1], [is clock_gettime available?])],
[ac_cv_func_clock_gettime=no])
AC_MSG_RESULT($ac_cv_func_clock_gettime)
if test "$ac_cv_func_clock_gettime" = "no" ; then
LIBS=$save_LIBS
fi
AC_CHECK_FUNCS(pthread_getcpuclockid)
AC_CHECK_FUNCS(sigtimedwait nanosleep)
dnl
dnl check for sched_setaffinity
dnl
AC_CHECK_FUNCS(sched_setaffinity)
dnl
dnl check for pthread_setaffinity_np
dnl
save_LIBS=$LIBS
save_CFLAGS=$CFLAGS
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
AC_MSG_CHECKING([for pthread_setaffinity_np])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <pthread.h>]],
[[cpu_set_t s; pthread_setaffinity_np(pthread_self(), sizeof(s), &s); ]])],
[ ac_cv_func_pthread_setaffinity_np=yes;
AC_DEFINE(HAVE_PTHREAD_SETAFFINITY_NP, [1], [is pthread_setaffinity_np available?])],
[ac_cv_func_pthread_setaffinity_np=no])
AC_MSG_RESULT($ac_cv_func_pthread_setaffinity_np)
LIBS=$save_LIBS
CFLAGS=$save_CFLAGS
dnl
dnl check for Linux NUMA support (libnuma)
dnl
AC_CHECK_LIB(numa,numa_available)
dnl check for /proc/cpuinfo
dnl
AC_CHECK_FILES(/proc/cpuinfo)
dnl check for asynchronous I/O support
dnl
AC_CHECK_FUNCS(aio_return)
dnl ******************** SML/NJ configuration ********************
dnl
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 95
then
AC_MSG_ERROR([installation requires SML/NJ version 110.95 or newer])
fi
AC_SUBST(SMLNJ_VERSION)
dnl look for ml-makedepend
dnl
AC_MSG_CHECKING([for ml-makedepend])
tmpPATH="$SMLNJ_PATH:$PATH"
AC_PATH_PROG(ML_MAKEDEPEND, ml-makedepend, ":", $tmpPATH)
if test $ML_MAKEDEPEND = none ; then
AC_MSG_ERROR([ml-makedepend not found])
else
AC_MSG_RESULT([$ML_MAKEDEPEND])
fi
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)
dnl
dnl allow the user to override the location of the LLVM installation
dnl
LLVM_DIR=""
AC_ARG_WITH(llvm,
AC_HELP_STRING([--with-llvm=PATH], [specify location of LLVM installation]),
dnl define an m4 variable for $with_llvm so we can pass it to m4_esyscmd
m4_define([with_llvm_m4], [$with_llvm])
dnl because OS X has no working realpath or readlink, use a shell script to canonicalize llvm path:
LLVM_DIR=[m4_esyscmd([./config/realpath.sh with_llvm_m4])])
if test x$with_llvm = xyes -o x$with_llvm = xno ; then
AC_MSG_ERROR([--with-llvm option must specify directory argument])
elif test x$with_llvm != x -a ! -r $LLVM_DIR/bin/llc ; then
AC_MSG_ERROR([llvm code generator (llc) not found at $LLVM_DIR])
elif test x$with_llvm != x -a ! -r $LLVM_DIR/bin/opt ; then
AC_MSG_ERROR([llvm optimizer (opt) not found at $LLVM_DIR])
fi
AC_SUBST(LLVM_DIR)
dnl
dnl allow the user to override the location of the MLRisc library
dnl
MLRISC_DIR=""
AC_ARG_WITH(mlrisc,
AC_HELP_STRING([--with-mlrisc=PATH], [specify location of MLRisc library]),
MLRISC_DIR=$with_mlrisc)
if test x$with_mlrisc = xyes -o x$with_mlrisc = xno ; then
AC_MSG_ERROR([--with-mlrisc option must specify directory argument])
elif test x$with_mlrisc != x -a ! -r $MLRISC_DIR/cm/MLRISC.cm ; then
AC_MSG_ERROR([MLRisc library not found at $MLRISC_DIR])
elif test x$MLRISC_DIR != x ; then
dnl
dnl verify that $MLRISC_DIR is an absolute path
dnl
case $MLRISC_DIR in
/*) ;;
*) AC_MSG_ERROR([--with-mlrisc argument must be absolute]) ;;
esac
fi
if test x$MLRISC_DIR = x ; then
if test $SMLNJ_MAJOR_VERSION -eq 110 \
-a $SMLNJ_MINOR_VERSION -eq 82
then
AC_MSG_ERROR([SML/NJ version 110.82 has an incompatible version of MLRISC. Please specify a different MLRISC path.])
fi
MLRISC_DIR="<builtin>"
MLRISC_CM_DIR='$SMLNJ-MLRISC'
else
MLRISC_CM_DIR=$MLRISC_DIR/cm
fi
AC_SUBST(MLRISC_DIR)
AC_SUBST(MLRISC_CM_DIR)
dnl ******************** Paths ********************
MANTICORE_ROOT=`pwd`
MANTICORE_DOCDIR=$MANTICORE_ROOT/doc
MANTICORE_SRCDIR=$MANTICORE_ROOT/src
MANTICORE_LIBDIR=$MANTICORE_ROOT/lib
MANTICORE_BINDIR=$MANTICORE_ROOT/bin
MANTICORE_MKDIR=$MANTICORE_ROOT/mk
dnl
dnl FIXME: the following should be relative to the MANTICORE_LIBDIR.
dnl
MANTICORE_BASISDIR=$MANTICORE_SRCDIR/lib/basis
MANTICORE_BASISINCDIR=$MANTICORE_SRCDIR/lib/basis
MANTICORE_RUNSRCDIR=$MANTICORE_SRCDIR/lib/parallel-rt
HEAP_IMAGE_DIR=$MANTICORE_BINDIR/.heap
INSTALL_SMLNJ_WRAPPER=$MANTICORE_BINDIR/install-sml-wrapper.sh
AC_SUBST(MANTICORE_ROOT)
AC_SUBST(MANTICORE_DOCDIR)
AC_SUBST(MANTICORE_SRCDIR)
AC_SUBST(MANTICORE_LIBDIR)
AC_SUBST(MANTICORE_BINDIR)
AC_SUBST(MANTICORE_MKDIR)
AC_SUBST(MANTICORE_RUNSRCDIR)
AC_SUBST(MANTICORE_BASISDIR)
AC_SUBST(HEAP_IMAGE_DIR)
AC_SUBST(INSTALL_SMLNJ_WRAPPER)
dnl
dnl the log-file descriptions
dnl
DEFAULT_LOG_EVENTS_PATH=$MANTICORE_ROOT/config/log-events.json
DEFAULT_LOG_VIEW_PATH=$MANTICORE_ROOT/config/log-view.json
AC_SUBST(DEFAULT_LOG_EVENTS_PATH)
AC_SUBST(DEFAULT_LOG_VIEW_PATH)
dnl ******************** Runtime system parameters ********************
AC_DEFINE([MAX_NUM_VPROCS], [64], [maximum number of virtual processors])
dnl VP_HEAP_SZB
dnl MEM_BLOCK_SZB
dnl ******************** C compiler properties ********************
dnl
dnl run the compiler tests in 64-bit mode
dnl
save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $CFLAG_M64"
dnl check for leading "_" on global names
dnl
CHECK_LEADING_UNDERSCORE
dnl
dnl check for gcc builtin atomic operations
dnl
AC_MSG_CHECKING([for builtin atomic operations])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([], [int foo1; int foo2 = __sync_fetch_and_add(&foo1, 1);])],
AC_MSG_RESULT(yes)
AC_DEFINE(
[HAVE_BUILTIN_ATOMIC_OPS], 1,
[Define to 1 if gcc compiler provides atomic operations.]),
AC_MSG_RESULT(no))
AC_C_BIGENDIAN
AC_C_INLINE
AC_C_CHAR_UNSIGNED
AC_C_LONG_DOUBLE
dnl
dnl Figure out the sizes of a few things; we use this information in
dnl manticore-config.h to determine the type of Word_t.
dnl
AC_CHECK_SIZEOF(char *)
AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(unsigned long)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(float)
AC_CHECK_SIZEOF(double)
if test x"$ac_cv_c_long_double" = xyes ; then
AC_CHECK_SIZEOF(long double)
else
AC_DEFINE(SIZEOF_LONG_DOUBLE, 8, [The number of bytes in a long double])
fi
dnl
dnl restore CFLAGS
dnl
CFLAGS=$save_CFLAGS
dnl
dnl config.h stuff
AH_TOP([
/*
* COPYRIGHT (c) 2009 Manticore project. (http://manticore.cs.uchicago.edu)
* All rights reserved.
*/
#ifndef _MANTICORE_CONFIG_H_
#define _MANTICORE_CONFIG_H_
#if defined(NO_GC_STATS) && (! defined(NDEBUG))
# define NDEBUG /* NO_GC_STATS implies NDEBUG */
#endif
])
AH_BOTTOM([
#ifndef NOT_C_SOURCE
typedef unsigned long Word_t;
typedef unsigned long Addr_t;
typedef struct manticore_value *Value_t;
#endif /* !NOT_C_SOURCE */
#endif /* !_MANTICORE_CONFIG_H_ */
])
dnl for the benchmark programs, we need the path to the PML compiler
dnl
PMLC=$MANTICORE_BINDIR/pmlc
AC_SUBST(PMLC)
dnl for the benchmark programs, we need the path to the MLton compiler
dnl
AC_ARG_WITH(mlton,
AC_HELP_STRING([--with-mlton=<path>], [specify path to mlton executable]),
[ac_cv_use_mlton=$withval], [ac_cv_use_mlton=no])
if test x"$ac_cv_use_mlton" = xno ; then
# look for mlton in the path
AC_PATH_PROG([MLTON], [mlton], [none],
[$PATH$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR/usr/local/bin])
else
AC_MSG_CHECKING([path to mlton ($ac_cv_use_mlton)])
case $ac_cv_use_mlton in
/*) ;;
*) AC_MSG_ERROR([path to mlton must be absolute]) ;;
esac
if test -x $ac_cv_use_mlton ; then
MLTON=$ac_cv_use_mlton
AC_MSG_RESULT([ okay])
else
MLTON=none
AC_MSG_RESULT([ invalid])
fi
fi
if test x"$MLTON" = xnone ; then
AC_MSG_WARN([unable to find mlton])
fi
AC_SUBST(MLTON)
dnl ******************** Output ********************
dnl
dnl generate run-time config files
dnl
AC_CONFIG_FILES(\
dnl ***** Makefiles *****
Makefile
src/Makefile
src/gen/log-gen/Makefile
src/lib/parallel-rt/build/Makefile
src/lib/parallel-rt/build/config/Makefile
src/lib/parallel-rt/build/mk/common.gmk:src/lib/parallel-rt/build/mk/common_gmk.in
src/tools/log-dump/Makefile
src/tools/log-work-stealing/Makefile
src/tools/log-view/build/Makefile
src/tools/mc/Makefile
dnl ***** SML source files *****
src/gen/log-gen/main.sml:src/gen/log-gen/main_sml.in
src/tools/mc/common/run-cpp.sml:src/tools/mc/common/run-cpp_sml.in
src/tools/mc/common/load-paths.sml:src/tools/mc/common/load-paths_sml.in
src/tools/mc/driver/build-executable.sml:src/tools/mc/driver/build-executable_sml.in
src/tools/mc/driver/version-fn.sml:src/tools/mc/driver/version-fn_sml.in
dnl ***** CM files *****
src/tools/mc/codegen/group.cm:src/tools/mc/codegen/group_cm.in
src/tools/mc/codegen/wrapper.cm:src/tools/mc/codegen/wrapper_cm.in
dnl ***** header files *****
src/tools/log-common/default-log-paths.h:src/tools/log-common/default-log-paths_h.in
)
AC_CONFIG_HEADERS(src/include/manticore-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])
dnl
dnl create machine-specific links
dnl
AC_CONFIG_LINKS([
src/lib/parallel-rt/machine:src/lib/parallel-rt/$ARCH
src/lib/parallel-rt/include/machine:src/lib/parallel-rt/include/$ARCH
])
dnl
dnl generate the runtime-constants files
dnl
AC_CONFIG_COMMANDS([runtime-consts], [config/gen-runtime-consts.sh])
dnl
dnl generate makefiles for runtime library builds
dnl
dnl usage: MK_BUILD_DIR(<build-dir>, <options>)
dnl
AC_DEFUN([MK_BUILD_DIR], [
if test ! -d src/lib/parallel-rt/build/$1 ; then
mkdir src/lib/parallel-rt/build/$1
fi
[sed -e 's,@BUILD_TARGET@,$1,g' -e 's,@BUILD_OPTIONS@,$2,g' \
src/lib/parallel-rt/build/mk/Makefile.in \
> src/lib/parallel-rt/build/$1/Makefile.in]
AC_CONFIG_FILES(src/lib/parallel-rt/build/$1/Makefile)
])
if test $CROSS_COMPILING = 0 ; then
MK_BUILD_DIR(mcrt, [])
MK_BUILD_DIR(mcrt-debug, [debug])
MK_BUILD_DIR(mcrt-log, [logging])
MK_BUILD_DIR(mcrt-log-debug, [logging debug])
MK_BUILD_DIR(mcrt-stats, [stats])
if test $OS != darwin; then
MK_BUILD_DIR(mcrt-perf, [perf])
fi
fi
AC_OUTPUT