-
Notifications
You must be signed in to change notification settings - Fork 17
/
configure.ac
484 lines (414 loc) · 17.6 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
#
# MGSim, the Microgrids simulator.
#
# Copyright (C) 2008,2009,2010,2011 Universiteit van Amsterdam..
# All rights reserved.
#
AC_PREREQ([2.61])
AC_INIT([mgsim],
m4_esyscmd([build-aux/git-version-gen build-aux/tarball-version s/mgsim-/v/ mgsim]),
[microgrids@svp-home.org])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([sys_config.h])
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([1.11 tar-ustar no-define foreign dist-bzip2 subdir-objects
parallel-tests color-tests silent-rules])
AM_SILENT_RULES([yes])
## extra programs
AC_PROG_RANLIB
AC_PROG_SED
AM_PATH_PYTHON([2.6], [], [AC_MSG_WARN([The 'readtrace' utility requires Python >= 2.6.])])
m4_define([MY_OPT_PROG],
[AC_ARG_VAR(m4_toupper([$1]), [$2])
AC_CHECK_PROGS(m4_toupper([$1]), [m4_default([$3], [$1])],
[$am_aux_dir/missing $1])
])
MY_OPT_PROG([help2man], [--help output to manpage converter], [help2man])
MY_OPT_PROG([rst2man], [reStructuredText to manpage converter], [rst2man rst2man.py])
MY_OPT_PROG([tbl], [Troff table converter], [tbl])
MY_OPT_PROG([groff], [GNU roff formatter], [groff])
MY_OPT_PROG([ps2pdf], [Postscript to PDF converter], [ps2pdf])
## language / library tests
AC_LANG_PUSH([C++])
AC_PROG_CXX
WARN_CXXFLAGS=
if test "x$GXX" = xyes; then
WARN_CXXFLAGS="-W -Wall -Wextra -Weffc++ -Wundef -Wshadow -Wpointer-arith -Wmissing-declarations -Wwrite-strings"
fi
AC_SUBST([WARN_CXXFLAGS])
# enable extensions for the non-standard tests below
AC_USE_SYSTEM_EXTENSIONS
# check support for abi::__cxa_demangle
AX_CXX_GCC_ABI_DEMANGLE
# check support for C++11
AX_CXX_COMPILE_STDCXX_11(, mandatory)
# check whether std::thread uses POSIX behind the scenes, then
# whether pthread_sigmask is available.
AX_PTHREAD
if test "x$ax_pthread_ok" = "xyes"; then
AC_CACHE_CHECK([whether std::thread is based on pthread_t],
[mg_cv_stdthread_is_pthread],
[mg_cv_stdthread_is_pthread=no
save_CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <thread>
#include <pthread.h>
#include <type_traits>
int main() {
static_assert(std::is_same<std::thread::native_handle_type, pthread_t>::value == true,
"std::thread::native_handle_type and pthread_t are different types");
return 0;
}
])], [mg_cv_stdthread_is_pthread=yes])
CXXFLAGS=$save_CXXFLAGS
])
if test x$mg_cv_stdthread_is_pthread = xyes; then
AC_SEARCH_LIBS([pthread_sigmask], [pthread])
AC_CHECK_FUNCS([pthread_sigmask])
if test x$ac_cv_func_pthread_sigmask = xyes; then
AC_DEFINE([CAN_USE_SIGMASK_ON_STD_THREAD], [1], [Define to 1 if std::thread uses pthreads and pthread_sigmask is available])
AM_CXXFLAGS="$AM_CXXFLAGS $PTHREAD_CFLAGS"
AM_LDFLAGS="$AM_LDFLAGS $PTHREAD_LIBS"
fi
fi
fi
# ensure requisite C++ features are available
CHECK_CXX11
# check for extensions
AC_CACHE_CHECK([for __builtin_unreachable],
[mg_cv_unreachable],
[
mg_cv_unreachable=no
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
[__builtin_unreachable();])],
[mg_cv_unreachable=yes])
])
if test x$mg_cv_unreachable = xyes; then
AC_DEFINE([HAVE___BUILTIN_UNREACHABLE],[1],[Define to 1 if __builtin_unreachable() is available.])
fi
AC_CACHE_CHECK([which template to use for unique pointers],
[mg_cv_uniqueptr],
[
mg_cv_uniqueptr=none
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <memory>],
[std::unique_ptr<int> x; x.reset(0); return 0;])],
[mg_cv_uniqueptr=unique_ptr])
if test x$mg_cv_uniqueptr = xnone; then
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <memory>],
[std::auto_ptr<int> x; x.reset(0); return 0;])],
[mg_cv_uniqueptr=auto_ptr])
fi
])
if test x$mg_cv_uniqueptr = xnone; then
AC_MSG_ERROR([Support for std::unique_ptr or std::auto_ptr is required.])
fi
AC_DEFINE_UNQUOTED([UNIQUE_PTR], [$mg_cv_uniqueptr], [Define to unique_ptr if available, otherwise auto_ptr])
AC_MSG_CHECKING([for the number of bits in a char])
AC_COMPUTE_INT([char_size], [CHAR_BIT], [@%:@include <limits.h>], [char_size=unknown])
AC_MSG_RESULT([$char_size])
if test x$char_size != x8; then
AC_MSG_ERROR([This program requires CHAR_BIT == 8, found $char_size.])
fi
# non-standard POSIX functions
AC_CHECK_FUNCS([getdtablesize fsync fdopendir getrusage])
AC_CHECK_MEMBERS([struct rusage.ru_maxrss],[],[],[@%:@include <sys/resource.h>])
if test x$ac_cv_member_struct_rusage_ru_maxrss = xyes; then
# the field exists, but is it populated? At least some versions
# of Linux (2.x?) do not populate maxrss, which stays zero. Check this.
maxrss_useful=maybe
AC_MSG_CHECKING([whether rusage.ru_maxrss contains useful values])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([@%:@include <sys/resource.h>],
[struct rusage ru;
getrusage(RUSAGE_SELF, &ru);
if (ru.ru_maxrss == 0)
return 1;
return 0;
])],
[maxrss_useful=yes], [maxrss_useful=no],
[maxrss_useful=maybe])
AC_MSG_RESULT([$maxrss_useful])
if test $maxrss_useful = no; then
AC_DEFINE([RUSAGE_MAX_RSS_EMPTY], [1], [Define to 1 if rusage.ru_maxrss stays 0, eg on Linux 2.x])
# no maxrss from getrusage, but maybe from /proc? check this
AC_MSG_CHECKING([whether /proc/self/statm can be used])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([@%:@include <fcntl.h>
@%:@include <unistd.h>],
[int fd; char buf@<:@64@:>@ = {0};
if (-1 == (fd = open("/proc/self/statm", O_RDONLY)))
return 1;
if (-1 == read(fd, buf, 63))
return 1;
return 0;
])],
[proc_statm_useful=yes], [proc_statm_useful=no],
[proc_statm_useful=maybe])
AC_MSG_RESULT([$proc_statm_useful])
if test $proc_statm_useful = yes; then
AC_DEFINE([HAVE_PROC_STATM], [1], [Define to 1 if /proc/self/statm should be used for memory statistics])
fi
else
# gerusage populates maxrss, but what is its unit?
# Linux/BSD use kilobytes; OS X uses bytes. Need to detect.
# If using bytes, we assume that a process that does nothing
# else but request 1MB from malloc() should not weigh
# more than 1GB of resident size.
AC_MSG_CHECKING([which unit rusage.ru_maxrss uses])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([@%:@include <sys/resource.h>
@%:@include <stdlib.h>
@%:@include <string.h>],
[struct rusage ru;
char *c = (char*)malloc(1024*1024);
memset(c, 42, 1024*1024);
getrusage(RUSAGE_SELF, &ru);
if (ru.ru_maxrss >= 1024*1024ll)
return 1;
return 0;
])],
[maxrssunit=kbytes], [maxrssunit=bytes], [maxrssunit=unknown])
AC_MSG_RESULT([$maxrssunit])
AC_DEFINE_UNQUOTED([RUSAGE_MAX_RSS_DIVIDER],
[`if test $maxrssunit = bytes; then echo 1024; else echo 1; fi`],
[Define to the value by which to divide rusage.ru_maxrss to obtain kilobytes])
fi
fi
AC_MSG_CHECKING([for dirfd])
AC_TRY_LINK([@%:@include <dirent.h>],
[DIR *p; int d = dirfd(p);],
[AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_DIRFD],[1],[Define to 1 if dirfd(DIR*) is available.])],
[AC_MSG_RESULT([no])])
AC_CHECK_MEMBERS([DIR.d_fd],[],[],[@%:@include <dirent.h>])
AC_CHECK_MEMBERS([struct dirent.d_ino],[],[],[@%:@include <dirent.h>])
AC_CHECK_MEMBERS([struct dirent.d_type],[],[],[@%:@include <dirent.h>])
AC_CHECK_MEMBERS([struct stat.st_blocks],[],[],[@%:@include <sys/stat.h>])
AC_CHECK_MEMBERS([struct stat.st_blksize],[],[],[@%:@include <sys/stat.h>])
AC_CHECK_MEMBERS([struct stat.st_atimespec],[],[],[@%:@include <sys/stat.h>])
AC_CHECK_MEMBERS([struct stat.st_mtimespec],[],[],[@%:@include <sys/stat.h>])
AC_CHECK_MEMBERS([struct stat.st_ctimespec],[],[],[@%:@include <sys/stat.h>])
AC_CHECK_MEMBERS([struct tm.tm_gmtoff],[],[],[@%:@include <sys/time.h>
@%:@include <time.h>])
AC_SEARCH_LIBS([nanosleep], [rt])
AC_CHECK_FUNCS([nanosleep usleep])
# support for PTYs
AC_SYS_POSIX_TERMIOS
AC_CHECK_FUNCS([tcsetattr tcgetattr])
if test $ac_cv_sys_posix_termios = yes; then
AC_DEFINE([HAVE_POSIX_TERMIOS], [1], [Define to 1 if termios.h is available])
fi
AC_CHECK_FUNCS([posix_openpt unlockpt ptsname grantpt getpt])
AC_MSG_CHECKING([for /dev/ptmx])
if test -c /dev/ptmx -a -r /dev/ptmx -a -w /dev/ptmx; then
AC_DEFINE([HAVE_DEV_PTMX], [1], [Define to 1 if /dev/ptmx is supported])
have_dev_ptmx=yes
else
have_dev_ptmx=no
fi
AC_MSG_RESULT([$have_dev_ptmx])
# --enable-assert
AC_HEADER_ASSERT
# argp
AC_SEARCH_LIBS([argp_parse], [c argp])
if test "x$ac_cv_search_argp_parse" = xno; then
AC_MSG_ERROR([Unable to find argp. Is it installed? If necessary use CPPFLAGS=... LDFLAGS=... to specify its location.])
fi
# libev
AC_SEARCH_LIBS([ev_version_minor], [ev])
if test "x$ac_cv_search_ev_version_minor" = xno; then
AC_MSG_ERROR([Unable to find libev. Is it it installed? If necessary use CPPFLAGS=... LDFLAGS=... to specify its location.])
fi
# libreadline / libhistory
AC_LIB_READLINE
if test "x$ac_cv_lib_readline" = xno; then
AC_MSG_WARN([The readline library or development header could not be found.])
AC_MSG_WARN([The simulator prompt will not support advanced command editing.])
fi
# libsdl
AC_ARG_ENABLE([sdl],
[AC_HELP_STRING([--disable-sdl],
[disable support for graphics output using SDL (default is try to enable)])],
[], [enable_sdl=yes])
if test "x$enable_sdl" = "xyes"; then
AM_PATH_SDL2
if test "x$no_sdl" = xyes; then
AC_MSG_ERROR([SDL not found])
enable_sdl=no
fi
fi
AM_CONDITIONAL([ENABLE_SDL], [test "x$enable_sdl" = "xyes"])
AC_LANG_POP([C++])
## Feature checks
memory_list=""
m4_define([ENABLE_MEMORY], [dnl
AC_ARG_ENABLE([mem_$1],
[AC_HELP_STRING([--disable-mem-$1], [disable support for the $2 memory type (default enable)])],
[], [enable_mem_$1=yes])
if test "x$enable_mem_$1" = "xyes"; then
memory_list="$memory_list $1"
AC_DEFINE([ENABLE_MEM_$2], [1],[Define to enable the $1 memory model])
fi
AM_CONDITIONAL([ENABLE_MEM_$2], [test "x$enable_mem_$1" = "xyes"])
])
ENABLE_MEMORY([serial], [SERIAL])
ENABLE_MEMORY([banked], [BANKED])
ENABLE_MEMORY([parallel], [PARALLEL])
ENABLE_MEMORY([ddr], [DDR])
ENABLE_MEMORY([cdma], [CDMA])
ENABLE_MEMORY([zlcdma], [ZLCDMA])
AC_ARG_ENABLE([trace-checks],
[AC_HELP_STRING([--disable-trace-checks],
[disable checking of the allowed storage traces upon failed trace checks])],
[], [enable_trace_checks=yes])
if test "x$enable_trace_checks" = xno; then
AC_DEFINE([DISABLE_TRACE_CHECKS], [1],
[Define if storage trace checks should be disabled])
fi
AC_ARG_ENABLE([verbose-trace-checks],
[AC_HELP_STRING([--disable-verbose-trace-checks],
[disable printing of the allowed storage traces upon failed trace checks])],
[], [enable_verbose_trace_checks=yes])
if test "x$enable_verbose_trace_checks" = xyes; then
AC_DEFINE([VERBOSE_TRACE_CHECKS], [1],
[Define if storage trace checks should fail verbosely])
fi
AC_ARG_ENABLE([abort-on-trace-failure],
[AC_HELP_STRING([--disable-abort-on-trace-failure],
[do not abort the simulation upon failed trace checks])],
[], [enable_abort_on_trace_failure=yes])
if test "x$enable_abort_on_trace_failure" = xyes; then
AC_DEFINE([ABORT_ON_TRACE_FAILURE], [1],
[Define if failed storage trace checks should abort the simulation])
fi
AC_ARG_ENABLE([softfpu],
[AC_HELP_STRING([--enable-softfpu],
[enable software emulation of IEEE 754 (default is disabled)])],
[], [enable_softfpu=no])
if test "x$enable_softfpu" = "xyes"; then
AC_DEFINE([EMULATE_IEEE754], [1],
[Define to 1 if IEEE 754 software emulation should be used])
fi
AC_ARG_ENABLE([profile],
[AC_HELP_STRING([--enable-profile],
[enable profiling during execution (default is disabled)])],
[], [enable_profile=no])
if test "x$enable_profile" = "xyes"; then
AM_CXXFLAGS="$AM_CXXFLAGS -pg"
fi
AC_ARG_ENABLE([cacti],
[AC_HELP_STRING([--disable-cacti], [disable support for area calculations with CACTI (default is try to enable)])],
[], [enable_cacti=yes])
if test "x$enable_cacti" = "xyes"; then
if ! test -r "$srcdir/cacti/cacti_interface.h"; then
AC_MSG_WARN([CACTI sources not available, cannot use CACTI.])
enable_cacti=no
fi
if test "x$ax_pthread_ok" != "xyes"; then
AC_MSG_WARN([POSIX threads not available, cannot use CACTI.])
enable_cacti=no
fi
fi
AM_CONDITIONAL([ENABLE_CACTI], [test "x$enable_cacti" = "xyes"])
## Check if 'slc' is available.
AC_PATH_PROG([SLC], [slc], [no], [$prefix/bin$PATH_SEPARATOR$PATH])
## Target selection
m4_define([MGS_TARGET_CHECK],
[dnl
AC_ARG_VAR([AS_$2], [Location of the `as' utility configured for the $3 binary format.])
AC_ARG_VAR([LD_$2], [Location of the `ld' utility configured for the $3 binary format.])
AC_ARG_VAR([OBJDUMP_$2],
[Location of the `objdump' utility configured for the $3 binary format.])
enable_[$1]_tests=no
enable_compiled_[$1]_tests=no
have_[$1]_binutils=no
if test "x$target_cpu" = "x$1"; then
AC_PATH_PROG([AS_$2], [$4-as], [no], [$prefix/bin$PATH_SEPARATOR$PATH])
AC_PATH_PROG([LD_$2], [$4-ld], [no], [$prefix/bin$PATH_SEPARATOR$PATH])
if test "x$AS_$2" != "xno" -a "x$LD_$2" != "xno"; then
have_[$1]_binutils=yes
fi
if test "x$have_[$1]_binutils" != xyes; then
AC_MSG_WARN([Some $3 utilities are missing. Cannot run the $3 test suite.])
else
enable_[$1]_tests=yes
fi
AC_PATH_PROG([OBJDUMP_$2], [$4-objdump], [no], [$prefix/bin$PATH_SEPARATOR$PATH])
if test "x$OBJDUMP_$2" != xno; then
AC_DEFINE_UNQUOTED([OBJDUMP_$2], ["$OBJDUMP_$2"],
[Define to the location of the `objdump' utility for $3.])
fi
if test "x$SLC" != "x:" ; then
AC_MSG_CHECKING([whether $SLC supports -b $5])
AC_LANG_CONFTEST([AC_LANG_SOURCE([int main(void) { return 0; }])])
if $SLC -b $5 -c -o conftest.o conftest.c >/dev/null 2>&1; then
AC_MSG_RESULT([yes])
enable_compiled_[$1]_tests=yes
else
AC_MSG_RESULT([no])
AC_MSG_WARN([borked $SLC -b $5. Cannot run the compiled $3 test suite.])
fi
else
AC_MSG_WARN([slc not found. Cannot run the compiled $3 test suite.])
fi
target_found=yes
AC_DEFINE([TARGET_$2], [1],
[Define when building a simulator using the $3 core model.])
fi
AM_CONDITIONAL([HAVE_$2_BINUTILS], [test x$have_$1_binutils = xyes])
AM_CONDITIONAL([ENABLE_$2_TESTS], [test x$enable_$1_tests = xyes])
AM_CONDITIONAL([ENABLE_COMPILED_$2_TESTS], [test x$enable_compiled_$1_tests = xyes])
])
enable_compiled_tests=no
target_found=no
MGS_TARGET_CHECK([mtalpha], [MTALPHA], [MT-Alpha], [mtalpha-linux-gnu], [mta_n])
MGS_TARGET_CHECK([mtsparc], [MTSPARC], [MT-SPARC], [mtsparc-linux-gnu], [mtsn_n])
MGS_TARGET_CHECK([mips], [MIPS32], [MIPS (no MT)], [mips-linux-gnu], [mips_s])
MGS_TARGET_CHECK([mipsel], [MIPS32EL], [MIPSel (no MT)], [mipsel-linux-gnu], [mipsel_s])
MGS_TARGET_CHECK([or1k], [OR1K], [OpenRISC 1000 (no MT)], [or1knd-elf], [or1k_s])
if test $target_found = no; then
AC_MSG_ERROR([Unsupported simulated core model: $target_cpu (did you use --target?)])
fi
AC_SUBST([GET_TEST_LIST],['$(TEST_LIST)'])
AC_CONFIG_FILES([
Makefile
tools/Makefile
programs/Makefile
doc/Makefile
])
AC_CONFIG_FILES([tools/preproc], [chmod +x tools/preproc])
AC_CONFIG_FILES([tools/readtrace], [chmod +x tools/readtrace])
AC_CONFIG_FILES([tools/viewlog], [chmod +x tools/viewlog])
AC_OUTPUT
cat <<EOF
*
* Configuration done.
*
* ISA target: $target_cpu
* Memory models: $memory_list
*
* CACTI area computation: $enable_cacti
* SDL output: $enable_sdl
* Trace checks: $enable_trace_checks
* Verbose trace checks: $enable_verbose_trace_checks
* Abort on trace failure: $enable_abort_on_trace_failure
* Software IEEE754: $enable_softfpu
* Area calculation: $enable_cacti
*
* MT-Alpha tests: (asm) $enable_mtalpha_tests (compiled) $enable_compiled_mtalpha_tests
* MT-SPARC tests: (asm) $enable_mtsparc_tests (compiled) $enable_compiled_mtsparc_tests
* MIPS tests: (asm) $enable_mips_tests (compiled) $enable_compiled_mips_tests
* MIPSel tests: (asm) $enable_mipsel_tests (compiled) $enable_compiled_mipsel_tests
* OpenRISC tests: (asm) $enable_or1k_tests (compiled) $enable_compiled_or1k_tests
*
* C++ compiler: $CXX $CPPFLAGS $WARN_CXXFLAGS $AM_CXXFLAGS $CXXFLAGS $LDFLAGS
* Destination dir: $prefix
*
Now run:
make all
make check
# then optionally:
make install
# to generate PDF versions of the manual pages:
cd doc && make pdf
EOF