3 # SPDX-License-Identifier: BSD-2-Clause
5 # Copyright (c) 2018-2021 Gavin D. Howard and contributors.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are met:
10 # * Redistributions of source code must retain the above copyright notice, this
11 # list of conditions and the following disclaimer.
13 # * Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
31 scriptdir=$(dirname "$script")
32 script=$(basename "$script")
34 . "$scriptdir/functions.sh"
51 printf ' %s -h\n' "$script"
52 printf ' %s --help\n' "$script"
53 printf ' %s [-a|-bD|-dB|-c] [-CEfgGHlmMNPtTvz] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\n' "$script"
54 printf ' %s \\\n' "$script"
55 printf ' [--library|--bc-only --disable-dc|--dc-only --disable-bc|--coverage]\\\n'
56 printf ' [--force --debug --disable-extra-math --disable-generated-tests] \\\n'
57 printf ' [--disable-history --disable-man-pages --disable-nls] \\\n'
58 printf ' [--disable-prompt --disable-strip] [--install-all-locales] \\\n'
59 printf ' [--opt=OPT_LEVEL] [--karatsuba-len=KARATSUBA_LEN] \\\n'
60 printf ' [--prefix=PREFIX] [--bindir=BINDIR] [--datarootdir=DATAROOTDIR] \\\n'
61 printf ' [--datadir=DATADIR] [--mandir=MANDIR] [--man1dir=MAN1DIR] \\\n'
63 printf ' -a, --library\n'
64 printf ' Build the libbc instead of the programs. This is meant to be used with\n'
65 printf ' Other software like programming languages that want to make use of the\n'
66 printf ' parsing and math capabilities. This option will install headers using\n'
67 printf ' `make install`.\n'
68 printf ' -b, --bc-only\n'
69 printf ' Build bc only. It is an error if "-d", "--dc-only", "-B", or\n'
70 printf ' "--disable-bc" are specified too.\n'
71 printf ' -B, --disable-bc\n'
72 printf ' Disable bc. It is an error if "-b", "--bc-only", "-D", or "--disable-dc"\n'
73 printf ' are specified too.\n'
74 printf ' -c, --coverage\n'
75 printf ' Generate test coverage code. Requires gcov and regcovr.\n'
76 printf ' It is an error if either "-b" ("-D") or "-d" ("-B") is specified.\n'
77 printf ' Requires a compiler that use gcc-compatible coverage options\n'
78 printf ' -C, --disable-clean\n'
79 printf ' Disable the clean that configure.sh does before configure.\n'
80 printf ' -d, --dc-only\n'
81 printf ' Build dc only. It is an error if "-b", "--bc-only", "-D", or\n'
82 printf ' "--disable-dc" are specified too.\n'
83 printf ' -D, --disable-dc\n'
84 printf ' Disable dc. It is an error if "-d", "--dc-only", "-B", or "--disable-bc"\n'
85 printf ' are specified too.\n'
86 printf ' -E, --disable-extra-math\n'
87 printf ' Disable extra math. This includes: "$" operator (truncate to integer),\n'
88 printf ' "@" operator (set number of decimal places), and r(x, p) (rounding\n'
89 printf ' function). Additionally, this option disables the extra printing\n'
90 printf ' functions in the math library.\n'
91 printf ' -f, --force\n'
92 printf ' Force use of all enabled options, even if they do not work. This\n'
93 printf ' option is to allow the maintainer a way to test that certain options\n'
94 printf ' are not failing invisibly. (Development only.)'
95 printf ' -g, --debug\n'
96 printf ' Build in debug mode. Adds the "-g" flag, and if there are no\n'
97 printf ' other CFLAGS, and "-O" was not given, this also adds the "-O0"\n'
98 printf ' flag. If this flag is *not* given, "-DNDEBUG" is added to CPPFLAGS\n'
99 printf ' and a strip flag is added to the link stage.\n'
100 printf ' -G, --disable-generated-tests\n'
101 printf ' Disable generating tests. This is for platforms that do not have a\n'
102 printf ' GNU bc-compatible bc to generate tests.\n'
103 printf ' -h, --help\n'
104 printf ' Print this help message and exit.\n'
105 printf ' -H, --disable-history\n'
106 printf ' Disable history.\n'
107 printf ' -k KARATSUBA_LEN, --karatsuba-len KARATSUBA_LEN\n'
108 printf ' Set the karatsuba length to KARATSUBA_LEN (default is 64).\n'
109 printf ' It is an error if KARATSUBA_LEN is not a number or is less than 16.\n'
110 printf ' -l, --install-all-locales\n'
111 printf ' Installs all locales, regardless of how many are on the system. This\n'
112 printf ' option is useful for package maintainers who want to make sure that\n'
113 printf ' a package contains all of the locales that end users might need.\n'
114 printf ' -m, --enable-memcheck\n'
115 printf ' Enable memcheck mode, to ensure no memory leaks. For development only.\n'
116 printf ' -M, --disable-man-pages\n'
117 printf ' Disable installing manpages.\n'
118 printf ' -N, --disable-nls\n'
119 printf ' Disable POSIX locale (NLS) support.\n'
120 printf ' -O OPT_LEVEL, --opt OPT_LEVEL\n'
121 printf ' Set the optimization level. This can also be included in the CFLAGS,\n'
122 printf ' but it is provided, so maintainers can build optimized debug builds.\n'
123 printf ' This is passed through to the compiler, so it must be supported.\n'
124 printf ' -P, --disable-prompt\n'
125 printf ' Disables the prompt in the built bc. The prompt will never show up,\n'
126 printf ' or in other words, it will be permanently disabled and cannot be\n'
128 printf ' -t, --enable-test-timing\n'
129 printf ' Enable the timing of tests. This is for development only.\n'
130 printf ' -T, --disable-strip\n'
131 printf ' Disable stripping symbols from the compiled binary or binaries.\n'
132 printf ' Stripping symbols only happens when debug mode is off.\n'
133 printf ' -v, --enable-valgrind\n'
134 printf ' Enable a build appropriate for valgrind. For development only.\n'
135 printf ' -z, --enable-fuzz-mode\n'
136 printf ' Enable fuzzing mode. THIS IS FOR DEVELOPMENT ONLY.\n'
137 printf ' --prefix PREFIX\n'
138 printf ' The prefix to install to. Overrides "$PREFIX" if it exists.\n'
139 printf ' If PREFIX is "/usr", install path will be "/usr/bin".\n'
140 printf ' Default is "/usr/local".\n'
141 printf ' --bindir BINDIR\n'
142 printf ' The directory to install binaries in. Overrides "$BINDIR" if it exists.\n'
143 printf ' Default is "$PREFIX/bin".\n'
144 printf ' --includedir INCLUDEDIR\n'
145 printf ' The directory to install headers in. Overrides "$INCLUDEDIR" if it\n'
146 printf ' exists. Default is "$PREFIX/include".\n'
147 printf ' --libdir LIBDIR\n'
148 printf ' The directory to install libraries in. Overrides "$LIBDIR" if it exists.\n'
149 printf ' Default is "$PREFIX/lib".\n'
150 printf ' --datarootdir DATAROOTDIR\n'
151 printf ' The root location for data files. Overrides "$DATAROOTDIR" if it exists.\n'
152 printf ' Default is "$PREFIX/share".\n'
153 printf ' --datadir DATADIR\n'
154 printf ' The location for data files. Overrides "$DATADIR" if it exists.\n'
155 printf ' Default is "$DATAROOTDIR".\n'
156 printf ' --mandir MANDIR\n'
157 printf ' The location to install manpages to. Overrides "$MANDIR" if it exists.\n'
158 printf ' Default is "$DATADIR/man".\n'
159 printf ' --man1dir MAN1DIR\n'
160 printf ' The location to install Section 1 manpages to. Overrides "$MAN1DIR" if\n'
161 printf ' it exists. Default is "$MANDIR/man1".\n'
162 printf ' --man3dir MAN3DIR\n'
163 printf ' The location to install Section 3 manpages to. Overrides "$MAN3DIR" if\n'
164 printf ' it exists. Default is "$MANDIR/man3".\n'
166 printf 'In addition, the following environment variables are used:\n'
168 printf ' CC C compiler. Must be compatible with POSIX c99. If there is a\n'
169 printf ' space in the basename of the compiler, the items after the\n'
170 printf ' first space are assumed to be compiler flags, and in that case,\n'
171 printf ' the flags are automatically moved into CFLAGS. Default is\n'
173 printf ' HOSTCC Host C compiler. Must be compatible with POSIX c99. If there is\n'
174 printf ' a space in the basename of the compiler, the items after the\n'
175 printf ' first space are assumed to be compiler flags, and in the case,\n'
176 printf ' the flags are automatically moved into HOSTCFLAGS. Default is\n'
178 printf ' HOST_CC Same as HOSTCC. If HOSTCC also exists, it is used.\n'
179 printf ' CFLAGS C compiler flags.\n'
180 printf ' HOSTCFLAGS CFLAGS for HOSTCC. Default is "$CFLAGS".\n'
181 printf ' HOST_CFLAGS Same as HOST_CFLAGS. If HOST_CFLAGS also exists, it is used.\n'
182 printf ' CPPFLAGS C preprocessor flags. Default is "".\n'
183 printf ' LDFLAGS Linker flags. Default is "".\n'
184 printf ' PREFIX The prefix to install to. Default is "/usr/local".\n'
185 printf ' If PREFIX is "/usr", install path will be "/usr/bin".\n'
186 printf ' BINDIR The directory to install binaries in. Default is "$PREFIX/bin".\n'
187 printf ' INCLUDEDIR The directory to install header files in. Default is\n'
188 printf ' "$PREFIX/include".\n'
189 printf ' LIBDIR The directory to install libraries in. Default is\n'
190 printf ' "$PREFIX/lib".\n'
191 printf ' DATAROOTDIR The root location for data files. Default is "$PREFIX/share".\n'
192 printf ' DATADIR The location for data files. Default is "$DATAROOTDIR".\n'
193 printf ' MANDIR The location to install manpages to. Default is "$DATADIR/man".\n'
194 printf ' MAN1DIR The location to install Section 1 manpages to. Default is\n'
195 printf ' "$MANDIR/man1".\n'
196 printf ' MAN3DIR The location to install Section 3 manpages to. Default is\n'
197 printf ' "$MANDIR/man3".\n'
198 printf ' NLSPATH The location to install locale catalogs to. Must be an absolute\n'
199 printf ' path (or contain one). This is treated the same as the POSIX\n'
200 printf ' definition of $NLSPATH (see POSIX environment variables for\n'
201 printf ' more information). Default is "/usr/share/locale/%%L/%%N".\n'
202 printf ' EXECSUFFIX The suffix to append to the executable names, used to not\n'
203 printf ' interfere with other installed bc executables. Default is "".\n'
204 printf ' EXECPREFIX The prefix to append to the executable names, used to not\n'
205 printf ' interfere with other installed bc executables. Default is "".\n'
206 printf ' DESTDIR For package creation. Default is "". If it is empty when\n'
207 printf ' `%s` is run, it can also be passed to `make install`\n' "$script"
208 printf ' later as an environment variable. If both are specified,\n'
209 printf ' the one given to `%s` takes precedence.\n' "$script"
210 printf ' LONG_BIT The number of bits in a C `long` type. This is mostly for the\n'
211 printf ' embedded space since this `bc` uses `long`s internally for\n'
212 printf ' overflow checking. In C99, a `long` is required to be 32 bits.\n'
213 printf ' For most normal desktop systems, setting this is unnecessary,\n'
214 printf ' except that 32-bit platforms with 64-bit longs may want to set\n'
215 printf ' it to `32`. Default is the default of `LONG_BIT` for the target\n'
216 printf ' platform. Minimum allowed is `32`. It is a build time error if\n'
217 printf ' the specified value of `LONG_BIT` is greater than the default\n'
218 printf ' value of `LONG_BIT` for the target platform.\n'
219 printf ' GEN_HOST Whether to use `gen/strgen.c`, instead of `gen/strgen.sh`, to\n'
220 printf ' produce the C files that contain the help texts as well as the\n'
221 printf ' math libraries. By default, `gen/strgen.c` is used, compiled by\n'
222 printf ' "$HOSTCC" and run on the host machine. Using `gen/strgen.sh`\n'
223 printf ' removes the need to compile and run an executable on the host\n'
224 printf ' machine since `gen/strgen.sh` is a POSIX shell script. However,\n'
225 printf ' `gen/lib2.bc` is perilously close to 4095 characters, the max\n'
226 printf ' supported length of a string literal in C99 (and it could be\n'
227 printf ' added to in the future), and `gen/strgen.sh` generates a string\n'
228 printf ' literal instead of an array, as `gen/strgen.c` does. For most\n'
229 printf ' production-ready compilers, this limit probably is not\n'
230 printf ' enforced, but it could be. Both options are still available for\n'
231 printf ' this reason. If you are sure your compiler does not have the\n'
232 printf ' limit and do not want to compile and run a binary on the host\n'
233 printf ' machine, set this variable to "0". Any other value, or a\n'
234 printf ' non-existent value, will cause the build system to compile and\n'
235 printf ' run `gen/strgen.c`. Default is "".\n'
236 printf ' GEN_EMU Emulator to run string generator code under (leave empty if not\n'
237 printf ' necessary). This is not necessary when using `gen/strgen.sh`.\n'
238 printf ' Default is "".\n'
240 printf 'WARNING: even though `configure.sh` supports both option types, short and\n'
241 printf 'long, it does not support handling both at the same time. Use only one type.\n'
248 if [ "$#" -ne 3 ]; then
249 err_exit "Invalid number of args to $0"
252 _replace_ext_file="$1"
253 _replace_ext_ext1="$2"
254 _replace_ext_ext2="$3"
256 _replace_ext_result=${_replace_ext_file%.$_replace_ext_ext1}.$_replace_ext_ext2
258 printf '%s\n' "$_replace_ext_result"
263 if [ "$#" -ne 3 ]; then
264 err_exit "Invalid number of args to $0"
267 _replace_exts_files="$1"
268 _replace_exts_ext1="$2"
269 _replace_exts_ext2="$3"
271 for _replace_exts_file in $_replace_exts_files; do
272 _replace_exts_new_name=$(replace_ext "$_replace_exts_file" "$_replace_exts_ext1" "$_replace_exts_ext2")
273 _replace_exts_result="$_replace_exts_result $_replace_exts_new_name"
276 printf '%s\n' "$_replace_exts_result"
281 if [ "$#" -ne 3 ]; then
282 err_exit "Invalid number of args to $0"
287 _replace_replacement="$3"
289 substring_replace "$_replace_str" "%%$_replace_needle%%" "$_replace_replacement"
294 if [ "$#" -ge 1 ] && [ "$1" != "" ]; then
296 while [ "$#" -ge 1 ]; do
297 _find_src_files_a="${1## }"
299 _find_src_files_args="$_find_src_files_args ! -path src/${_find_src_files_a}"
303 _find_src_files_args="-print"
306 printf '%s\n' $(find src/ -depth -name "*.c" $_find_src_files_args)
311 if [ "$#" -lt 1 ]; then
312 err_exit "Invalid number of args to $0"
315 _gen_file_list_contents="$1"
322 if [ "$#" -ge 1 ]; then
323 _gen_file_list_unneeded="$@"
325 _gen_file_list_unneeded=""
328 _gen_file_list_needle_src="SRC"
329 _gen_file_list_needle_obj="OBJ"
330 _gen_file_list_needle_gcda="GCDA"
331 _gen_file_list_needle_gcno="GCNO"
333 _gen_file_list_replacement=$(find_src_files $_gen_file_list_unneeded | tr '\n' ' ')
334 _gen_file_list_contents=$(replace "$_gen_file_list_contents" \
335 "$_gen_file_list_needle_src" "$_gen_file_list_replacement")
337 _gen_file_list_replacement=$(replace_exts "$_gen_file_list_replacement" "c" "o")
338 _gen_file_list_contents=$(replace "$_gen_file_list_contents" \
339 "$_gen_file_list_needle_obj" "$_gen_file_list_replacement")
341 _gen_file_list_replacement=$(replace_exts "$_gen_file_list_replacement" "o" "gcda")
342 _gen_file_list_contents=$(replace "$_gen_file_list_contents" \
343 "$_gen_file_list_needle_gcda" "$_gen_file_list_replacement")
345 _gen_file_list_replacement=$(replace_exts "$_gen_file_list_replacement" "gcda" "gcno")
346 _gen_file_list_contents=$(replace "$_gen_file_list_contents" \
347 "$_gen_file_list_needle_gcno" "$_gen_file_list_replacement")
351 printf '%s\n' "$_gen_file_list_contents"
359 _gen_tests_uname="$1"
362 _gen_tests_extra_math="$1"
365 _gen_tests_time_tests="$1"
368 _gen_tests_extra_required=$(cat tests/extra_required.txt)
370 for _gen_tests_t in $(cat "$scriptdir/tests/$_gen_tests_name/all.txt"); do
372 if [ "$_gen_tests_extra_math" -eq 0 ]; then
374 if [ -z "${_gen_tests_extra_required##*$_gen_tests_t*}" ]; then
375 printf 'test_%s_%s:\n\t@printf "Skipping %s %s\\n"\n\n' \
376 "$_gen_tests_name" "$_gen_tests_t" "$_gen_tests_name" \
377 "$_gen_tests_t" >> "$scriptdir/Makefile"
383 printf 'test_%s_%s:\n\t@sh tests/test.sh %s %s %s %s %s\n\n' \
384 "$_gen_tests_name" "$_gen_tests_t" "$_gen_tests_name" \
385 "$_gen_tests_t" "$generate_tests" "$time_tests" \
386 "$*" >> "$scriptdir/Makefile"
393 _gen_test_targets_name="$1"
396 _gen_test_targets_tests=$(cat "$scriptdir/tests/${_gen_test_targets_name}/all.txt")
398 for _gen_test_targets_t in $_gen_test_targets_tests; do
399 printf ' test_%s_%s' "$_gen_test_targets_name" "$_gen_test_targets_t"
407 _gen_script_tests_name="$1"
410 _gen_script_tests_extra_math="$1"
413 _gen_script_tests_generate="$1"
416 _gen_script_tests_time="$1"
419 _gen_script_tests_tests=$(cat "$scriptdir/tests/$_gen_script_tests_name/scripts/all.txt")
421 for _gen_script_tests_f in $_gen_script_tests_tests; do
423 _gen_script_tests_b=$(basename "$_gen_script_tests_f" ".${_gen_script_tests_name}")
425 printf 'test_%s_script_%s:\n\t@sh tests/script.sh %s %s %s 1 %s %s %s\n\n' \
426 "$_gen_script_tests_name" "$_gen_script_tests_b" "$_gen_script_tests_name" \
427 "$_gen_script_tests_f" "$_gen_script_tests_extra_math" "$_gen_script_tests_generate" \
428 "$_gen_script_tests_time" "$*" >> "$scriptdir/Makefile"
432 gen_script_test_targets() {
434 _gen_script_test_targets_name="$1"
437 _gen_script_test_targets_tests=$(cat "$scriptdir/tests/$_gen_script_test_targets_name/scripts/all.txt")
439 for _gen_script_test_targets_f in $_gen_script_test_targets_tests; do
440 _gen_script_test_targets_b=$(basename "$_gen_script_test_targets_f" \
441 ".$_gen_script_test_targets_name")
442 printf ' test_%s_script_%s' "$_gen_script_test_targets_name" \
443 "$_gen_script_test_targets_b"
471 while getopts "abBcdDEfgGhHk:lMmNO:PStTvz-" opt; do
484 G) generate_tests=0 ;;
487 k) karatsuba_len="$OPTARG" ;;
490 M) install_manpages=0 ;;
492 O) optimization="$OPTARG" ;;
501 LONG_OPTARG="${arg#*=}"
504 library) library=1 ;;
505 bc-only) bc_only=1 ;;
506 dc-only) dc_only=1 ;;
507 coverage) coverage=1 ;;
510 prefix=?*) PREFIX="$LONG_OPTARG" ;;
512 if [ "$#" -lt 2 ]; then
513 usage "No argument given for '--$arg' option"
517 bindir=?*) BINDIR="$LONG_OPTARG" ;;
519 if [ "$#" -lt 2 ]; then
520 usage "No argument given for '--$arg' option"
524 includedir=?*) INCLUDEDIR="$LONG_OPTARG" ;;
526 if [ "$#" -lt 2 ]; then
527 usage "No argument given for '--$arg' option"
531 libdir=?*) LIBDIR="$LONG_OPTARG" ;;
533 if [ "$#" -lt 2 ]; then
534 usage "No argument given for '--$arg' option"
538 datarootdir=?*) DATAROOTDIR="$LONG_OPTARG" ;;
540 if [ "$#" -lt 2 ]; then
541 usage "No argument given for '--$arg' option"
545 datadir=?*) DATADIR="$LONG_OPTARG" ;;
547 if [ "$#" -lt 2 ]; then
548 usage "No argument given for '--$arg' option"
552 mandir=?*) MANDIR="$LONG_OPTARG" ;;
554 if [ "$#" -lt 2 ]; then
555 usage "No argument given for '--$arg' option"
559 man1dir=?*) MAN1DIR="$LONG_OPTARG" ;;
561 if [ "$#" -lt 2 ]; then
562 usage "No argument given for '--$arg' option"
566 man3dir=?*) MAN3DIR="$LONG_OPTARG" ;;
568 if [ "$#" -lt 2 ]; then
569 usage "No argument given for '--$arg' option"
573 localedir=?*) LOCALEDIR="$LONG_OPTARG" ;;
575 if [ "$#" -lt 2 ]; then
576 usage "No argument given for '--$arg' option"
580 karatsuba-len=?*) karatsuba_len="$LONG_OPTARG" ;;
582 if [ "$#" -lt 2 ]; then
583 usage "No argument given for '--$arg' option"
587 opt=?*) optimization="$LONG_OPTARG" ;;
589 if [ "$#" -lt 2 ]; then
590 usage "No argument given for '--$arg' option"
594 disable-bc) dc_only=1 ;;
595 disable-dc) bc_only=1 ;;
596 disable-clean) clean=0 ;;
597 disable-extra-math) extra_math=0 ;;
598 disable-generated-tests) generate_tests=0 ;;
599 disable-history) hist=0 ;;
600 disable-man-pages) install_manpages=0 ;;
601 disable-nls) nls=0 ;;
602 disable-prompt) prompt=0 ;;
603 disable-strip) strip_bin=0 ;;
604 enable-test-timing) time_tests=1 ;;
605 enable-valgrind) vg=1 ;;
606 enable-fuzz-mode) fuzz=1 ;;
607 enable-memcheck) memcheck=1 ;;
608 install-all-locales) all_locales=1 ;;
609 help* | bc-only* | dc-only* | coverage* | debug*)
610 usage "No arg allowed for --$arg option" ;;
611 disable-bc* | disable-dc* | disable-clean*)
612 usage "No arg allowed for --$arg option" ;;
614 usage "No arg allowed for --$arg option" ;;
615 disable-generated-tests* | disable-history*)
616 usage "No arg allowed for --$arg option" ;;
617 disable-man-pages* | disable-nls* | disable-strip*)
618 usage "No arg allowed for --$arg option" ;;
619 enable-fuzz-mode* | enable-test-timing* | enable-valgrind*)
620 usage "No arg allowed for --$arg option" ;;
621 enable-memcheck* | install-all-locales*)
622 usage "No arg allowed for --$arg option" ;;
623 '') break ;; # "--" terminates argument processing
624 * ) usage "Invalid option $LONG_OPTARG" ;;
628 ?) usage "Invalid option $opt" ;;
633 if [ "$clean" -ne 0 ]; then
634 if [ -f ./Makefile ]; then
635 make clean_config > /dev/null
639 if [ "$bc_only" -eq 1 ] && [ "$dc_only" -eq 1 ]; then
640 usage "Can only specify one of -b(-D) or -d(-B)"
643 if [ "$library" -ne 0 ]; then
644 if [ "$bc_only" -eq 1 ] || [ "$dc_only" -eq 1 ]; then
645 usage "Must not specify -b(-D) or -d(-B) when building the library"
649 case $karatsuba_len in
650 (*[!0-9]*|'') usage "KARATSUBA_LEN is not a number" ;;
654 if [ "$karatsuba_len" -lt 16 ]; then
655 usage "KARATSUBA_LEN is less than 16"
660 if [ -z "${LONG_BIT+set}" ]; then
662 elif [ "$LONG_BIT" -lt 32 ]; then
663 usage "LONG_BIT is less than 32"
665 LONG_BIT_DEFINE="-DBC_LONG_BIT=\$(BC_LONG_BIT)"
668 if [ -z "$CC" ]; then
671 ccbase=$(basename "$CC")
675 if [ "${ccbase%%$suffix}" != "$ccbase" ]; then
676 ccflags="${ccbase#$prefix}"
677 cc="${ccbase%%$suffix}"
678 ccdir=$(dirname "$CC")
679 if [ "$ccdir" = "." ] && [ "${CC#.}" = "$CC" ]; then
685 CFLAGS="$CFLAGS $ccflags"
689 if [ -z "$HOSTCC" ] && [ -z "$HOST_CC" ]; then
691 elif [ -z "$HOSTCC" ]; then
695 if [ "$HOSTCC" != "$CC" ]; then
696 ccbase=$(basename "$HOSTCC")
700 if [ "${ccbase%%$suffix}" != "$ccbase" ]; then
701 ccflags="${ccbase#$prefix}"
702 cc="${ccbase%%$suffix}"
703 ccdir=$(dirname "$HOSTCC")
704 if [ "$ccdir" = "." ] && [ "${HOSTCC#.}" = "$HOSTCC" ]; then
709 HOSTCC="${ccdir}${cc}"
710 HOSTCFLAGS="$HOSTCFLAGS $ccflags"
714 if [ -z "${HOSTCFLAGS+set}" ] && [ -z "${HOST_CFLAGS+set}" ]; then
716 elif [ -z "${HOSTCFLAGS+set}" ]; then
717 HOSTCFLAGS="$HOST_CFLAGS"
720 link="@printf 'No link necessary\\\\n'"
724 tests="test_bc timeconst test_dc"
726 bc_test="@tests/all.sh bc $extra_math 1 $generate_tests 0 \$(BC_EXEC)"
727 dc_test="@tests/all.sh dc $extra_math 1 $generate_tests 0 \$(DC_EXEC)"
729 timeconst="@tests/bc/timeconst.sh tests/bc/scripts/timeconst.bc \$(BC_EXEC)"
731 # In order to have cleanup at exit, we need to be in
732 # debug mode, so don't run valgrind without that.
733 if [ "$vg" -ne 0 ]; then
735 bc_test_exec='valgrind $(VALGRIND_ARGS) $(BC_EXEC)'
736 dc_test_exec='valgrind $(VALGRIND_ARGS) $(DC_EXEC)'
738 bc_test_exec='$(BC_EXEC)'
739 dc_test_exec='$(DC_EXEC)'
742 karatsuba="@printf 'karatsuba cannot be run because one of bc or dc is not built\\\\n'"
743 karatsuba_test="@printf 'karatsuba cannot be run because one of bc or dc is not built\\\\n'"
745 bc_lib="\$(GEN_DIR)/lib.o"
746 bc_help="\$(GEN_DIR)/bc_help.o"
747 dc_help="\$(GEN_DIR)/dc_help.o"
749 default_target_prereqs="\$(BIN) \$(OBJS)"
750 default_target_cmd="\$(CC) \$(CFLAGS) \$(OBJS) \$(LDFLAGS) -o \$(EXEC)"
751 default_target="\$(DC_EXEC)"
753 second_target_prereqs=""
754 second_target_cmd="$default_target_cmd"
755 second_target="\$(BC_EXEC)"
757 if [ "$library" -ne 0 ]; then
766 default_target_prereqs="\$(BIN) \$(OBJ)"
767 default_target_cmd="ar -r -cu \$(LIBBC) \$(OBJ)"
768 default_target="\$(LIBBC)"
771 elif [ "$bc_only" -eq 1 ]; then
780 dc_test="@printf 'No dc tests to run\\\\n'"
782 install_prereqs=" install_execs"
783 install_man_prereqs=" install_bc_manpage"
784 uninstall_prereqs=" uninstall_bc"
785 uninstall_man_prereqs=" uninstall_bc_manpage"
787 default_target="\$(BC_EXEC)"
788 second_target="\$(DC_EXEC)"
789 tests="test_bc timeconst"
791 elif [ "$dc_only" -eq 1 ]; then
804 bc_test="@printf 'No bc tests to run\\\\n'"
806 timeconst="@printf 'timeconst cannot be run because bc is not built\\\\n'"
808 install_prereqs=" install_execs"
809 install_man_prereqs=" install_dc_manpage"
810 uninstall_prereqs=" uninstall_dc"
811 uninstall_man_prereqs=" uninstall_dc_manpage"
820 executables="bc and dc"
822 karatsuba="@\$(KARATSUBA) 30 0 \$(BC_EXEC)"
823 karatsuba_test="@\$(KARATSUBA) 1 100 \$(BC_EXEC)"
825 if [ "$library" -eq 0 ]; then
826 install_prereqs=" install_execs"
827 install_man_prereqs=" install_bc_manpage install_dc_manpage"
828 uninstall_prereqs=" uninstall_bc uninstall_dc"
829 uninstall_man_prereqs=" uninstall_bc_manpage uninstall_dc_manpage"
831 install_prereqs=" install_library install_bcl_header"
832 install_man_prereqs=" install_bcl_manpage"
833 uninstall_prereqs=" uninstall_library uninstall_bcl_header"
834 uninstall_man_prereqs=" uninstall_bcl_manpage"
838 second_target_prereqs="$default_target_prereqs"
839 default_target_prereqs="$second_target"
840 default_target_cmd="\$(LINK) \$(BIN) \$(EXEC_PREFIX)\$(DC)"
844 if [ "$fuzz" -ne 0 ]; then
852 if [ "$debug" -eq 1 ]; then
854 if [ -z "$CFLAGS" ] && [ -z "$optimization" ]; then
861 CPPFLAGS="-DNDEBUG $CPPFLAGS"
862 if [ "$strip_bin" -ne 0 ]; then
863 LDFLAGS="-s $LDFLAGS"
867 if [ -n "$optimization" ]; then
868 CFLAGS="-O$optimization $CFLAGS"
871 if [ "$coverage" -eq 1 ]; then
873 if [ "$bc_only" -eq 1 ] || [ "$dc_only" -eq 1 ]; then
874 usage "Can only specify -c without -b or -d"
877 CFLAGS="-fprofile-arcs -ftest-coverage -g -O0 $CFLAGS"
878 CPPFLAGS="-DNDEBUG $CPPFLAGS"
880 COVERAGE_OUTPUT="@gcov -pabcdf \$(GCDA) \$(BC_GCDA) \$(DC_GCDA) \$(HISTORY_GCDA) \$(RAND_GCDA)"
881 COVERAGE_OUTPUT="$COVERAGE_OUTPUT;\$(RM) -f \$(GEN)*.gc*"
882 COVERAGE_OUTPUT="$COVERAGE_OUTPUT;gcovr --html-details --output index.html"
883 COVERAGE_PREREQS=" test coverage_output"
886 COVERAGE_OUTPUT="@printf 'Coverage not generated\\\\n'"
890 if [ -z "${DESTDIR+set}" ]; then
893 destdir="DESTDIR = $DESTDIR"
896 if [ -z "${PREFIX+set}" ]; then
900 if [ -z "${BINDIR+set}" ]; then
904 if [ -z "${INCLUDEDIR+set}" ]; then
905 INCLUDEDIR="$PREFIX/include"
908 if [ -z "${LIBDIR+set}" ]; then
912 if [ "$install_manpages" -ne 0 ] || [ "$nls" -ne 0 ]; then
913 if [ -z "${DATAROOTDIR+set}" ]; then
914 DATAROOTDIR="$PREFIX/share"
918 if [ "$install_manpages" -ne 0 ]; then
920 if [ -z "${DATADIR+set}" ]; then
921 DATADIR="$DATAROOTDIR"
924 if [ -z "${MANDIR+set}" ]; then
925 MANDIR="$DATADIR/man"
928 if [ -z "${MAN1DIR+set}" ]; then
929 MAN1DIR="$MANDIR/man1"
932 if [ -z "${MAN3DIR+set}" ]; then
933 MAN3DIR="$MANDIR/man3"
937 install_man_prereqs=""
938 uninstall_man_prereqs=""
941 if [ "$nls" -ne 0 ]; then
945 printf 'Testing NLS...\n'
947 flags="-DBC_ENABLE_NLS=1 -DBC_ENABLED=$bc -DDC_ENABLED=$dc"
948 flags="$flags -DBC_ENABLE_HISTORY=$hist"
949 flags="$flags -DBC_ENABLE_EXTRA_MATH=$extra_math -I./include/"
950 flags="$flags -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
952 "$CC" $CPPFLAGS $CFLAGS $flags -c "src/vm.c" -o "$scriptdir/vm.o" > /dev/null 2>&1
956 rm -rf "$scriptdir/vm.o"
958 # If this errors, it is probably because of building on Windows,
959 # and NLS is not supported on Windows, so disable it.
960 if [ "$err" -ne 0 ]; then
961 printf 'NLS does not work.\n'
962 if [ $force -eq 0 ]; then
963 printf 'Disabling NLS...\n\n'
966 printf 'Forcing NLS...\n\n'
969 printf 'NLS works.\n\n'
971 printf 'Testing gencat...\n'
972 gencat "$scriptdir/en_US.cat" "$scriptdir/locales/en_US.msg" > /dev/null 2>&1
976 rm -rf "$scriptdir/en_US.cat"
978 if [ "$err" -ne 0 ]; then
979 printf 'gencat does not work.\n'
980 if [ $force -eq 0 ]; then
981 printf 'Disabling NLS...\n\n'
984 printf 'Forcing NLS...\n\n'
988 printf 'gencat works.\n\n'
990 if [ "$HOSTCC" != "$CC" ]; then
991 printf 'Cross-compile detected.\n\n'
992 printf 'WARNING: Catalog files generated with gencat may not be portable\n'
993 printf ' across different architectures.\n\n'
996 if [ -z "$NLSPATH" ]; then
997 NLSPATH="/usr/share/locale/%L/%N"
1000 install_locales_prereqs=" install_locales"
1001 uninstall_locales_prereqs=" uninstall_locales"
1010 install_locales_prereqs=""
1011 uninstall_locales_prereqs=""
1015 if [ "$nls" -ne 0 ] && [ "$all_locales" -ne 0 ]; then
1016 install_locales="\$(LOCALE_INSTALL) -l \$(NLSPATH) \$(MAIN_EXEC) \$(DESTDIR)"
1018 install_locales="\$(LOCALE_INSTALL) \$(NLSPATH) \$(MAIN_EXEC) \$(DESTDIR)"
1021 if [ "$hist" -eq 1 ]; then
1025 printf 'Testing history...\n'
1027 flags="-DBC_ENABLE_HISTORY=1 -DBC_ENABLED=$bc -DDC_ENABLED=$dc"
1028 flags="$flags -DBC_ENABLE_NLS=$nls -DBC_ENABLE_LIBRARY=0"
1029 flags="$flags -DBC_ENABLE_EXTRA_MATH=$extra_math -I./include/"
1030 flags="$flags -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
1032 "$CC" $CPPFLAGS $CFLAGS $flags -c "src/history.c" -o "$scriptdir/history.o" > /dev/null 2>&1
1036 rm -rf "$scriptdir/history.o"
1038 # If this errors, it is probably because of building on Windows,
1039 # and history is not supported on Windows, so disable it.
1040 if [ "$err" -ne 0 ]; then
1041 printf 'History does not work.\n'
1042 if [ $force -eq 0 ]; then
1043 printf 'Disabling history...\n\n'
1046 printf 'Forcing history...\n\n'
1049 printf 'History works.\n\n'
1056 if [ "$library" -eq 1 ]; then
1060 if [ "$extra_math" -eq 1 ] && [ "$bc" -ne 0 ] && [ "$library" -eq 0 ]; then
1061 BC_LIB2_O="\$(GEN_DIR)/lib2.o"
1067 GEN_EXEC_TARGET="\$(HOSTCC) \$(HOSTCFLAGS) -o \$(GEN_EXEC) \$(GEN_C)"
1068 CLEAN_PREREQS=" clean_gen"
1070 if [ -z "${GEN_HOST+set}" ]; then
1073 if [ "$GEN_HOST" -eq 0 ]; then
1075 GEN_EXEC_TARGET="@printf 'Do not need to build gen/strgen.c\\\\n'"
1082 headers="\$(HEADERS)"
1084 if [ "$extra_math" -eq 0 ]; then
1086 unneeded="$unneeded rand.c"
1088 headers="$headers \$(EXTRA_MATH_HEADERS)"
1091 if [ "$hist" -eq 0 ]; then
1092 manpage_args="${manpage_args}H"
1093 unneeded="$unneeded history.c"
1095 headers="$headers \$(HISTORY_HEADERS)"
1098 if [ "$nls" -eq 0 ]; then
1099 manpage_args="${manpage_args}N"
1102 if [ "$prompt" -eq 0 ]; then
1103 manpage_args="${manpage_args}P"
1106 if [ "$bc" -eq 0 ]; then
1107 unneeded="$unneeded bc.c bc_lex.c bc_parse.c"
1109 headers="$headers \$(BC_HEADERS)"
1112 if [ "$dc" -eq 0 ]; then
1113 unneeded="$unneeded dc.c dc_lex.c dc_parse.c"
1115 headers="$headers \$(DC_HEADERS)"
1118 if [ "$library" -ne 0 ]; then
1119 unneeded="$unneeded args.c opt.c read.c file.c main.c"
1120 unneeded="$unneeded lang.c lex.c parse.c program.c"
1121 unneeded="$unneeded bc.c bc_lex.c bc_parse.c"
1122 unneeded="$unneeded dc.c dc_lex.c dc_parse.c"
1123 headers="$headers \$(LIBRARY_HEADERS)"
1125 unneeded="$unneeded library.c"
1128 if [ "$manpage_args" = "" ]; then
1132 if [ "$vg" -ne 0 ]; then
1136 bc_tests=$(gen_test_targets bc)
1137 bc_script_tests=$(gen_script_test_targets bc)
1138 dc_tests=$(gen_test_targets dc)
1139 dc_script_tests=$(gen_script_test_targets dc)
1141 # Print out the values; this is for debugging.
1142 if [ "$bc" -ne 0 ]; then
1143 printf 'Building bc\n'
1145 printf 'Not building bc\n'
1147 if [ "$dc" -ne 0 ]; then
1148 printf 'Building dc\n'
1150 printf 'Not building dc\n'
1153 printf 'BC_ENABLE_LIBRARY=%s\n\n' "$library"
1154 printf 'BC_ENABLE_HISTORY=%s\n' "$hist"
1155 printf 'BC_ENABLE_EXTRA_MATH=%s\n' "$extra_math"
1156 printf 'BC_ENABLE_NLS=%s\n' "$nls"
1157 printf 'BC_ENABLE_PROMPT=%s\n' "$prompt"
1158 printf 'BC_ENABLE_AFL=%s\n' "$fuzz"
1160 printf 'BC_NUM_KARATSUBA_LEN=%s\n' "$karatsuba_len"
1162 printf 'CC=%s\n' "$CC"
1163 printf 'CFLAGS=%s\n' "$CFLAGS"
1164 printf 'HOSTCC=%s\n' "$HOSTCC"
1165 printf 'HOSTCFLAGS=%s\n' "$HOSTCFLAGS"
1166 printf 'CPPFLAGS=%s\n' "$CPPFLAGS"
1167 printf 'LDFLAGS=%s\n' "$LDFLAGS"
1168 printf 'PREFIX=%s\n' "$PREFIX"
1169 printf 'BINDIR=%s\n' "$BINDIR"
1170 printf 'INCLUDEDIR=%s\n' "$INCLUDEDIR"
1171 printf 'LIBDIR=%s\n' "$LIBDIR"
1172 printf 'DATAROOTDIR=%s\n' "$DATAROOTDIR"
1173 printf 'DATADIR=%s\n' "$DATADIR"
1174 printf 'MANDIR=%s\n' "$MANDIR"
1175 printf 'MAN1DIR=%s\n' "$MAN1DIR"
1176 printf 'MAN3DIR=%s\n' "$MAN3DIR"
1177 printf 'NLSPATH=%s\n' "$NLSPATH"
1178 printf 'EXECSUFFIX=%s\n' "$EXECSUFFIX"
1179 printf 'EXECPREFIX=%s\n' "$EXECPREFIX"
1180 printf 'DESTDIR=%s\n' "$DESTDIR"
1181 printf 'LONG_BIT=%s\n' "$LONG_BIT"
1182 printf 'GEN_HOST=%s\n' "$GEN_HOST"
1183 printf 'GEN_EMU=%s\n' "$GEN_EMU"
1185 contents=$(cat "$scriptdir/Makefile.in")
1188 replacement='*** WARNING: Autogenerated from Makefile.in. DO NOT MODIFY ***'
1190 contents=$(replace "$contents" "$needle" "$replacement")
1192 if [ "$unneeded" = "" ]; then
1193 unneeded="library.c"
1196 contents=$(gen_file_list "$contents" $unneeded)
1200 src_files=$(find_src_files $unneeded)
1205 for f in $src_files; do
1206 o=$(replace_ext "$f" "c" "o")
1207 SRC_TARGETS=$(printf '%s\n\n%s: %s %s\n\t$(CC) $(CFLAGS) -o %s -c %s\n' \
1208 "$SRC_TARGETS" "$o" "$headers" "$f" "$o" "$f")
1213 contents=$(replace "$contents" "HEADERS" "$headers")
1215 contents=$(replace "$contents" "BC_ENABLED" "$bc")
1216 contents=$(replace "$contents" "DC_ENABLED" "$dc")
1218 contents=$(replace "$contents" "BC_ALL_TESTS" "$bc_test")
1219 contents=$(replace "$contents" "BC_TESTS" "$bc_tests")
1220 contents=$(replace "$contents" "BC_SCRIPT_TESTS" "$bc_script_tests")
1221 contents=$(replace "$contents" "BC_TEST_EXEC" "$bc_test_exec")
1222 contents=$(replace "$contents" "TIMECONST_ALL_TESTS" "$timeconst")
1224 contents=$(replace "$contents" "DC_ALL_TESTS" "$dc_test")
1225 contents=$(replace "$contents" "DC_TESTS" "$dc_tests")
1226 contents=$(replace "$contents" "DC_SCRIPT_TESTS" "$dc_script_tests")
1227 contents=$(replace "$contents" "DC_TEST_EXEC" "$dc_test_exec")
1229 contents=$(replace "$contents" "LIBRARY" "$library")
1230 contents=$(replace "$contents" "HISTORY" "$hist")
1231 contents=$(replace "$contents" "EXTRA_MATH" "$extra_math")
1232 contents=$(replace "$contents" "NLS" "$nls")
1233 contents=$(replace "$contents" "PROMPT" "$prompt")
1234 contents=$(replace "$contents" "FUZZ" "$fuzz")
1235 contents=$(replace "$contents" "MEMCHECK" "$memcheck")
1237 contents=$(replace "$contents" "BC_LIB_O" "$bc_lib")
1238 contents=$(replace "$contents" "BC_HELP_O" "$bc_help")
1239 contents=$(replace "$contents" "DC_HELP_O" "$dc_help")
1240 contents=$(replace "$contents" "BC_LIB2_O" "$BC_LIB2_O")
1241 contents=$(replace "$contents" "KARATSUBA_LEN" "$karatsuba_len")
1243 contents=$(replace "$contents" "NLSPATH" "$NLSPATH")
1244 contents=$(replace "$contents" "DESTDIR" "$destdir")
1245 contents=$(replace "$contents" "EXECSUFFIX" "$EXECSUFFIX")
1246 contents=$(replace "$contents" "EXECPREFIX" "$EXECPREFIX")
1247 contents=$(replace "$contents" "BINDIR" "$BINDIR")
1248 contents=$(replace "$contents" "INCLUDEDIR" "$INCLUDEDIR")
1249 contents=$(replace "$contents" "LIBDIR" "$LIBDIR")
1250 contents=$(replace "$contents" "MAN1DIR" "$MAN1DIR")
1251 contents=$(replace "$contents" "MAN3DIR" "$MAN3DIR")
1252 contents=$(replace "$contents" "CFLAGS" "$CFLAGS")
1253 contents=$(replace "$contents" "HOSTCFLAGS" "$HOSTCFLAGS")
1254 contents=$(replace "$contents" "CPPFLAGS" "$CPPFLAGS")
1255 contents=$(replace "$contents" "LDFLAGS" "$LDFLAGS")
1256 contents=$(replace "$contents" "CC" "$CC")
1257 contents=$(replace "$contents" "HOSTCC" "$HOSTCC")
1258 contents=$(replace "$contents" "COVERAGE_OUTPUT" "$COVERAGE_OUTPUT")
1259 contents=$(replace "$contents" "COVERAGE_PREREQS" "$COVERAGE_PREREQS")
1260 contents=$(replace "$contents" "INSTALL_PREREQS" "$install_prereqs")
1261 contents=$(replace "$contents" "INSTALL_MAN_PREREQS" "$install_man_prereqs")
1262 contents=$(replace "$contents" "INSTALL_LOCALES" "$install_locales")
1263 contents=$(replace "$contents" "INSTALL_LOCALES_PREREQS" "$install_locales_prereqs")
1264 contents=$(replace "$contents" "UNINSTALL_MAN_PREREQS" "$uninstall_man_prereqs")
1265 contents=$(replace "$contents" "UNINSTALL_PREREQS" "$uninstall_prereqs")
1266 contents=$(replace "$contents" "UNINSTALL_LOCALES_PREREQS" "$uninstall_locales_prereqs")
1268 contents=$(replace "$contents" "DEFAULT_TARGET" "$default_target")
1269 contents=$(replace "$contents" "DEFAULT_TARGET_PREREQS" "$default_target_prereqs")
1270 contents=$(replace "$contents" "DEFAULT_TARGET_CMD" "$default_target_cmd")
1271 contents=$(replace "$contents" "SECOND_TARGET" "$second_target")
1272 contents=$(replace "$contents" "SECOND_TARGET_PREREQS" "$second_target_prereqs")
1273 contents=$(replace "$contents" "SECOND_TARGET_CMD" "$second_target_cmd")
1275 contents=$(replace "$contents" "ALL_PREREQ" "$ALL_PREREQ")
1276 contents=$(replace "$contents" "BC_EXEC_PREREQ" "$bc_exec_prereq")
1277 contents=$(replace "$contents" "BC_EXEC_CMD" "$bc_exec_cmd")
1278 contents=$(replace "$contents" "DC_EXEC_PREREQ" "$dc_exec_prereq")
1279 contents=$(replace "$contents" "DC_EXEC_CMD" "$dc_exec_cmd")
1281 contents=$(replace "$contents" "EXECUTABLES" "$executables")
1282 contents=$(replace "$contents" "MAIN_EXEC" "$main_exec")
1283 contents=$(replace "$contents" "EXEC" "$executable")
1284 contents=$(replace "$contents" "TESTS" "$tests")
1286 contents=$(replace "$contents" "BC_TEST" "$bc_test")
1287 contents=$(replace "$contents" "DC_TEST" "$dc_test")
1289 contents=$(replace "$contents" "VG_BC_TEST" "$vg_bc_test")
1290 contents=$(replace "$contents" "VG_DC_TEST" "$vg_dc_test")
1292 contents=$(replace "$contents" "TIMECONST" "$timeconst")
1294 contents=$(replace "$contents" "KARATSUBA" "$karatsuba")
1295 contents=$(replace "$contents" "KARATSUBA_TEST" "$karatsuba_test")
1297 contents=$(replace "$contents" "LONG_BIT" "$LONG_BIT")
1298 contents=$(replace "$contents" "LONG_BIT_DEFINE" "$LONG_BIT_DEFINE")
1300 contents=$(replace "$contents" "GEN" "$GEN")
1301 contents=$(replace "$contents" "GEN_EXEC_TARGET" "$GEN_EXEC_TARGET")
1302 contents=$(replace "$contents" "CLEAN_PREREQS" "$CLEAN_PREREQS")
1303 contents=$(replace "$contents" "GEN_EMU" "$GEN_EMU")
1305 printf '%s\n%s\n\n' "$contents" "$SRC_TARGETS" > "$scriptdir/Makefile"
1307 if [ "$bc" -ne 0 ]; then
1308 gen_tests bc BC "$extra_math" "$time_tests" $bc_test_exec
1309 gen_script_tests bc "$extra_math" "$generate_tests" "$time_tests" $bc_test_exec
1312 if [ "$dc" -ne 0 ]; then
1313 gen_tests dc DC "$extra_math" "$time_tests" $dc_test_exec
1314 gen_script_tests dc "$extra_math" "$generate_tests" "$time_tests" $dc_test_exec
1319 cp -f manuals/bc/$manpage_args.1.md manuals/bc.1.md
1320 cp -f manuals/bc/$manpage_args.1 manuals/bc.1
1321 cp -f manuals/dc/$manpage_args.1.md manuals/dc.1.md
1322 cp -f manuals/dc/$manpage_args.1 manuals/dc.1
1324 make clean > /dev/null