This repository has been archived by the owner on Feb 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconfigure.ac
155 lines (134 loc) · 4.31 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
AC_PREREQ([2.69])
AC_INIT([asm2bf], [v1.5.1], [[email protected]])
AC_CONFIG_SRCDIR([bfasm.c])
AC_CONFIG_HEADERS([config.h])
AC_COPYRIGHT([Copyright (C) Kamila Szewczyk, 2020. Licensed under the terms of MIT license.])
AC_LANG([C])
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$4 $1"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS
AC_DEFUN([CHK_FLAG2], [
AX_CHECK_COMPILE_FLAG([$1],
[AC_SUBST([$2], ["$$2 $1"])], [
AC_MSG_WARN([$1 is beneficial for debug builds, but it's not present.])
], [-Werror])
])
AC_DEFUN([CHK_FLAG], [
CHK_FLAG2($1, [LOC_F])
])
AC_DEFUN([PROG_SWITCH], [
AC_ARG_ENABLE([$1],
AS_HELP_STRING([--enable-$1], [$2]), [
AC_DEFINE([$3], [], [$2])
])
])
# Checks for programs.
AC_PROG_YACC
AC_PROG_CC
AC_PROG_LEX
AC_PROG_MAKE_SET
# Checks for header files.
AC_CHECK_HEADERS([inttypes.h limits.h stddef.h stdint.h stdlib.h string.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT8_T
AC_TYPE_SIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
AC_CHECK_SIZEOF([size_t])
AC_ARG_ENABLE([version], AS_HELP_STRING([--enable-version], [Sets the dist version for asm2bf]), [
AC_SUBST([VERSION], [$enableval])
], [
AC_SUBST([VERSION], [trunk])
])
AC_ARG_WITH([target],
AS_HELP_STRING([--with-target=@<:@auto/release/debug/coverage@:>@],
[Build target (default: auto)]),
[asmbf_distro_target=$withval],
[asmbf_distro_target=auto])
case "$asmbf_distro_target" in
"release")
AC_SUBST([DISTRO], ["-Ofast -march=native -funroll-loops -fomit-frame-pointer"])
;;
"debug")
AC_SUBST([LOC_F], [])
CHK_FLAG([-fsanitize=pointer-compare])
CHK_FLAG([-fsanitize=pointer-subtract])
CHK_FLAG([-fsanitize=address])
CHK_FLAG([-fsanitize=leak])
CHK_FLAG([-fsanitize=undefined])
CHK_FLAG([-fcf-protection=full])
CHK_FLAG([-fstack-protector-strong])
CHK_FLAG([-fstack-check])
AC_SUBST([DISTRO], m4_normalize(["
-Wall -Wextra
-g3 -O2
$LOC_F
"]))
;;
"coverage")
AX_CHECK_COMPILE_FLAG([-coverage],
,
[AC_MSG_FAILURE([-coverage is required for coverage builds.])],
[-Werror])
AC_SUBST([DISTRO], ["-g3 -O0 -coverage"])
;;
*)
AC_SUBST([DISTRO], ["-O2"])
;;
esac
PROG_SWITCH([nocheck-bfi], [
Skip all checks in bfi (making it a tiny bit faster).
], [BFI_NOCHECKS])
AC_ARG_WITH([jobs],
AS_HELP_STRING([--with-jobs=N],
[Set the amount of make jobs. Must be greater than zero and lesser or equal to 8.]),
[asmbf_jobs=$withval],
[asmbf_jobs=1])
case "$asmbf_jobs" in
1)
AC_SUBST([MSFLAGS], [""])
;;
2|3|4|5|6|7|8)
AC_SUBST([MSFLAGS], ["-j $asmbf_jobs "])
;;
*)
AC_MSG_FAILURE([Pass a number in range 1-8 to --with-jobs.])
;;
esac
# Checks for library functions.
AC_FUNC_ERROR_AT_LINE
AC_FUNC_MALLOC
AC_FUNC_MKTIME
AC_FUNC_REALLOC
AC_FUNC_STRCOLL
AC_CHECK_FUNCS([asprintf floor memchr memset pow sqrt strchr strcspn strdup strerror strpbrk strrchr strstr strtoul])
dnl Autoconf should have put it before, no clue how to force it to do so.
test "x$prefix" = xNONE && prefix=$ac_default_prefix
AC_SUBST([PREFIX], ["$prefix/"])
AC_CONFIG_FILES([Makefile
bfpp/Makefile
hla/Makefile
redpower/Makefile
bfadbg/Makefile
preprocessor/Makefile
bfmake
lib-bfm/lib-bfm-stub.lua
lib-bfm/lib-bfm.lua
microcode/bfvm-prelude.h])
AC_OUTPUT