-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·202 lines (164 loc) · 5.84 KB
/
configure
File metadata and controls
executable file
·202 lines (164 loc) · 5.84 KB
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
#!/bin/sh
# Variables
PROJDIR="$(dirname "$(readlink -e "$0")")"
BUILDDIR="${PROJDIR}/build"
MAKEFILE="${PROJDIR}/Makefile"
CONFIGFLAGS=""
CLEAN=0
die() {
echo "$1"
exit 1
}
diehelp() {
echo "$1"
printhelp
exit 1
}
printhelp() {
cat << EOF
Usage: $0 [OPTION]...
With arguments from
--clean delete files from previous build if existing
--incremental update files in case of existing previous build
--prefix <PATH> installation prefix
--with-docs build and install documentation
--without-docs omit documentation (default)
--with-addons build and install addons (default)
--without-addons omit addons
--simulator <SIMULATOR> set simulator for vpi headers and test, one of:
auto, icarus, cvc, ncsim, xcelium (default=auto)
--thread-implementation <IMPL> set thread implementation, one of:
libco-local, libco, pcl, boost1, boost2 (default=libco-local)
--valvector-max-stack <N> integer for maximum vpi on-stack vecval, 0 for default implementation
--thread-stack-size-default <SIZE> default stack size for coroutines, 0 for default implementation
--disable-cleanup disable end-of-simulation resource cleanup
--enable-cleanup enable end-of-simulation resource cleanup (default)
--warning-level <LEVEL> set compiler warning level to one of:
quiet, strict (default), error (strict, treat warnings as errors)
-h, --help print this help text
EOF
}
parse_options() {
local option
local value
local optshift
while [ $# -ge 1 ] ; do
option="$1"
value="$2"
optshift=2
if echo "${option}" | grep '=' ; then
value="$(echo "${option}" | sed -e 's/\(.*\)=\(.*\)/\2/')"
option="$(echo "${option}" | sed -e 's/\(.*\)=\(.*\)/\1/')"
optshift=1
fi
case "${option}" in
"--clean")
CLEAN=1
optshift=1
;;
"--incremental")
CLEAN=0
optshift=1
;;
"--prefix")
CONFIGFLAGS="${CONFIGFLAGS} -DCMAKE_INSTALL_PREFIX:PATH=${value}"
;;
"--with-docs")
CONFIGFLAGS="${CONFIGFLAGS} -DBUILD_DOC=1"
optshift=1
;;
"--without-docs")
CONFIGFLAGS="${CONFIGFLAGS} -DBUILD_DOC=0"
optshift=1
;;
"--with-addons")
CONFIGFLAGS="${CONFIGFLAGS} -DADDONS=1"
optshift=1
;;
"--without-addons")
CONFIGFLAGS="${CONFIGFLAGS} -DADDONS=0"
optshift=1
;;
"--simulator")
CONFIGFLAGS="${CONFIGFLAGS} -DSIMULATOR=${value}"
;;
"--thread-implementation")
CONFIGFLAGS="${CONFIGFLAGS} -DTHREAD_IMPL=${value}"
;;
"--valvector-max-stack")
CONFIGFLAGS="${CONFIGFLAGS} -DVALVECTOR_MAX_STATIC=${value}"
;;
"--thread-stack-size-default")
CONFIGFLAGS="${CONFIGFLAGS} -DTHREAD_STACK_SIZE_DEFAULT=${value}"
;;
"--disable-cleanup")
CONFIGFLAGS="${CONFIGFLAGS} -DDISABLE_CLEANUP=1"
optshift=1
;;
"--enable-cleanup")
CONFIGFLAGS="${CONFIGFLAGS} -DDISABLE_CLEANUP=0"
optshift=1
;;
"--warning-level")
CONFIGFLAGS="${CONFIGFLAGS} -DWARN_LEVEL=${value}"
;;
"-h"|"--help"|"-?"|"-help")
printhelp
exit 0
;;
*)
diehelp "invalid option ${option}"
;;
esac
[ $# -ge ${optshift} ] && shift ${optshift} || diehelp "missing argument for ${option}"
done
}
clean_build() {
[ -d "${BUILDDIR}" ] && rm -rf "${BUILDDIR}"
[ -f "${MAKEFILE}" ] && rm -f "${MAKEFILE}"
}
prepare_build() {
mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}" || die "could not enter ${BUILDDIR}"
cmake ${CONFIGFLAGS} ..
}
gen_makefile() {
cat > "${MAKEFILE}" << EOF
# adapted from https://gist.github.com/doitian/4978329
TARGET_BUILDDIR := build
TARGET_MAKEFILE := \$(TARGET_BUILDDIR)/Makefile
TARGET_TEST := test
TARGET_CLEAN := mrproper
NCPUS := \$(shell nproc)
# List targets defined in this file
TARGETS_SELF := \\
\$(TARGET_BUILDDIR) \\
\$(TARGET_MAKEFILE) \\
\$(TARGET_TEST) \\
\$(TARGET_CLEAN)
# Exclude targets defined in this file
TARGETS_OTHER := \$(filter-out \$(TARGETS_SELF), \$(MAKECMDGOALS))
# Call all targets using 'Makefile' in build directory in one 'make' command. It
# can depend on targets defined in this file, e.g., depending on a target to
# create the Makefile.
#
# If no targets are specified, use the dummy 'all' target
\$(or \$(lastword \$(TARGETS_OTHER)),all): \$(TARGET_MAKEFILE)
@\$(MAKE) --no-print-directory -C \$(TARGET_BUILDDIR) \$(TARGETS_OTHER)
.PHONY: \$(TARGETS_OTHER) all
# Do nothing for all targets but last. Also quiet the message "Nothing to be done on xxx"
\$(filter-out \$(lastword \$(TARGETS_OTHER)), \$(TARGETS_OTHER)):
@:
\$(TARGET_MAKEFILE):
cmake -B \$(TARGET_BUILDDIR)
\$(TARGET_TEST): all
ctest --test-dir \$(TARGET_BUILDDIR) -j\$(NCPUS)
\$(TARGET_CLEAN):
rm -rf \$(TARGET_BUILDDIR)
rm -f Makefile
.PHONY: \$(TARGET_TEST) \$(TARGET_CLEAN)
EOF
}
parse_options "$@"
[ "${CLEAN}" -eq 1 ] && clean_build
prepare_build && gen_makefile