diff options
Diffstat (limited to 'contrib/bc/configure.sh')
-rwxr-xr-x | contrib/bc/configure.sh | 477 |
1 files changed, 24 insertions, 453 deletions
diff --git a/contrib/bc/configure.sh b/contrib/bc/configure.sh index 442165d15693..92ff45cca84a 100755 --- a/contrib/bc/configure.sh +++ b/contrib/bc/configure.sh @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: BSD-2-Clause # -# Copyright (c) 2018-2024 Gavin D. Howard and contributors. +# Copyright (c) 2018-2025 Gavin D. Howard and contributors. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -55,7 +55,7 @@ usage() { printf ' %s [-a|-bD|-dB|-c] [-CeEfgGHilmMNPrtTvz] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\\\n' "$script" printf ' [-s SETTING] [-S SETTING] [-p TYPE]\n' printf ' %s \\\n' "$script" - printf ' [--library|--bc-only --disable-dc|--dc-only --disable-bc|--coverage] \\\n' + printf ' [--library|--bc-only --disable-dc|--dc-only --disable-bc] \\\n' printf ' [--force --debug --disable-extra-math --disable-generated-tests] \\\n' printf ' [--disable-history --disable-man-pages --disable-nls --disable-strip] \\\n' printf ' [--enable-editline] [--enable-readline] [--enable-internal-history] \\\n' @@ -74,7 +74,7 @@ usage() { printf '\n' printf ' -a, --library\n' printf ' Build the libbcl instead of the programs. This is meant to be used with\n' - printf ' Other software like programming languages that want to make use of the\n' + printf ' other software like programming languages that want to make use of the\n' printf ' parsing and math capabilities. This option will install headers using\n' printf ' `make install`.\n' printf ' -b, --bc-only\n' @@ -83,10 +83,6 @@ usage() { printf ' -B, --disable-bc\n' printf ' Disable bc. It is an error if "-b", "--bc-only", "-D", or "--disable-dc"\n' printf ' are specified too.\n' - printf ' -c, --coverage\n' - printf ' Generate test coverage code. Requires gcov and gcovr.\n' - printf ' It is an error if either "-b" ("-D") or "-d" ("-B") is specified.\n' - printf ' Requires a compiler that use gcc-compatible coverage options\n' printf ' -C, --disable-clean\n' printf ' Disable the clean that configure.sh does before configure.\n' printf ' -d, --dc-only\n' @@ -133,8 +129,6 @@ usage() { printf ' Installs all locales, regardless of how many are on the system. This\n' printf ' option is useful for package maintainers who want to make sure that\n' printf ' a package contains all of the locales that end users might need.\n' - printf ' -m, --enable-memcheck\n' - printf ' Enable memcheck mode, to ensure no memory leaks. For development only.\n' printf ' -M, --disable-man-pages\n' printf ' Disable installing manpages.\n' printf ' -N, --disable-nls\n' @@ -172,17 +166,9 @@ usage() { printf ' Set the default named by SETTING to off. See below for possible values\n' printf ' for SETTING. For multiple instances of the -s or -S for the the same\n' printf ' setting, the last one is used.\n' - printf ' -t, --enable-test-timing\n' - printf ' Enable the timing of tests. This is for development only.\n' printf ' -T, --disable-strip\n' printf ' Disable stripping symbols from the compiled binary or binaries.\n' printf ' Stripping symbols only happens when debug mode is off.\n' - printf ' -v, --enable-valgrind\n' - printf ' Enable a build appropriate for valgrind. For development only.\n' - printf ' -z, --enable-fuzz-mode\n' - printf ' Enable fuzzing mode. THIS IS FOR DEVELOPMENT ONLY.\n' - printf ' -Z, --enable-ossfuzz-mode\n' - printf ' Enable fuzzing mode for OSS-Fuzz. THIS IS FOR DEVELOPMENT ONLY.\n' printf ' --prefix PREFIX\n' printf ' The prefix to install to. Overrides "$PREFIX" if it exists.\n' printf ' If PREFIX is "/usr", install path will be "/usr/bin".\n' @@ -254,12 +240,12 @@ usage() { printf ' path (or contain one). This is treated the same as the POSIX\n' printf ' definition of $NLSPATH (see POSIX environment variables for\n' printf ' more information). Default is "/usr/share/locale/%%L/%%N".\n' - printf ' PC_PATH The location to install pkg-config files to. Must be an\n' + printf ' PC_PATH The location to install pkg-config files to. Must be a\n' printf ' path or contain one. Default is the first path given by the\n' printf ' output of `pkg-config --variable=pc_path pkg-config`.\n' printf ' EXECSUFFIX The suffix to append to the executable names, used to not\n' printf ' interfere with other installed bc executables. Default is "".\n' - printf ' EXECPREFIX The prefix to append to the executable names, used to not\n' + printf ' EXECPREFIX The prefix to prepend to the executable names, used to not\n' printf ' interfere with other installed bc executables. Default is "".\n' printf ' DESTDIR For package creation. Default is "". If it is empty when\n' printf ' `%s` is run, it can also be passed to `make install`\n' "$script" @@ -482,7 +468,7 @@ find_src_files() { } # This function generates a list of files to go into the Makefile. It generates -# the list of object files, as well as the list of test coverage files. +# the list of object files. # # @param contents The contents of the Makefile template to put the list of # files into. @@ -503,8 +489,6 @@ gen_file_list() { _gen_file_list_needle_src="SRC" _gen_file_list_needle_obj="OBJ" - _gen_file_list_needle_gcda="GCDA" - _gen_file_list_needle_gcno="GCNO" _gen_file_list_replacement=$(find_src_files $_gen_file_list_unneeded | tr '\n' ' ') _gen_file_list_contents=$(replace "$_gen_file_list_contents" \ @@ -521,151 +505,9 @@ gen_file_list() { _gen_file_list_contents=$(replace "$_gen_file_list_contents" \ "$_gen_file_list_needle_obj" "$_gen_file_list_replacement") - _gen_file_list_replacement=$(replace_exts "$_gen_file_list_replacement" "o" "gcda") - _gen_file_list_contents=$(replace "$_gen_file_list_contents" \ - "$_gen_file_list_needle_gcda" "$_gen_file_list_replacement") - - _gen_file_list_replacement=$(replace_exts "$_gen_file_list_replacement" "gcda" "gcno") - _gen_file_list_contents=$(replace "$_gen_file_list_contents" \ - "$_gen_file_list_needle_gcno" "$_gen_file_list_replacement") - printf '%s\n' "$_gen_file_list_contents" } -# Generates the proper test targets for each test to have its own target. This -# allows `make test` to run in parallel. -# -# @param name Which calculator to generate tests for. -# @param extra_math An integer that, if non-zero, activates extra math tests. -# @param time_tests An integer that, if non-zero, tells the test suite to time -# the execution of each test. -gen_std_tests() { - - _gen_std_tests_name="$1" - shift - - _gen_std_tests_extra_math="$1" - shift - - _gen_std_tests_time_tests="$1" - shift - - _gen_std_tests_extra_required=$(cat "$scriptdir/tests/extra_required.txt") - - for _gen_std_tests_t in $(cat "$scriptdir/tests/$_gen_std_tests_name/all.txt"); do - - if [ "$_gen_std_tests_extra_math" -eq 0 ]; then - - if [ -z "${_gen_std_tests_extra_required##*$_gen_std_tests_t*}" ]; then - printf 'test_%s_%s:\n\t@printf "Skipping %s %s\\n"\n\n' \ - "$_gen_std_tests_name" "$_gen_std_tests_t" "$_gen_std_tests_name" \ - "$_gen_std_tests_t" >> "Makefile" - continue - fi - - fi - - printf 'test_%s_%s:\n\t@export BC_TEST_OUTPUT_DIR="%s/tests"; sh $(TESTSDIR)/test.sh %s %s %s %s %s\n\n' \ - "$_gen_std_tests_name" "$_gen_std_tests_t" "$builddir" "$_gen_std_tests_name" \ - "$_gen_std_tests_t" "$generate_tests" "$time_tests" \ - "$*" >> "Makefile" - - done -} - -# Generates a list of test targets that will be used as prerequisites for other -# targets. -# -# @param name The name of the calculator to generate test targets for. -gen_std_test_targets() { - - _gen_std_test_targets_name="$1" - shift - - _gen_std_test_targets_tests=$(cat "$scriptdir/tests/${_gen_std_test_targets_name}/all.txt") - - for _gen_std_test_targets_t in $_gen_std_test_targets_tests; do - printf ' test_%s_%s' "$_gen_std_test_targets_name" "$_gen_std_test_targets_t" - done - - printf '\n' -} - -# Generates the proper test targets for each error test to have its own target. -# This allows `make test_bc_errors` and `make test_dc_errors` to run in -# parallel. -# -# @param name Which calculator to generate tests for. -gen_err_tests() { - - _gen_err_tests_name="$1" - shift - - _gen_err_tests_fs=$(ls "$scriptdir/tests/$_gen_err_tests_name/errors/") - - for _gen_err_tests_t in $_gen_err_tests_fs; do - - printf 'test_%s_error_%s:\n\t@export BC_TEST_OUTPUT_DIR="%s/tests"; sh $(TESTSDIR)/error.sh %s %s %s %s\n\n' \ - "$_gen_err_tests_name" "$_gen_err_tests_t" "$builddir" "$_gen_err_tests_name" \ - "$_gen_err_tests_t" "$problematic_tests" "$*" >> "Makefile" - - done - -} - -# Generates a list of error test targets that will be used as prerequisites for -# other targets. -# -# @param name The name of the calculator to generate test targets for. -gen_err_test_targets() { - - _gen_err_test_targets_name="$1" - shift - - _gen_err_test_targets_tests=$(ls "$scriptdir/tests/$_gen_err_test_targets_name/errors/") - - for _gen_err_test_targets_t in $_gen_err_test_targets_tests; do - printf ' test_%s_error_%s' "$_gen_err_test_targets_name" "$_gen_err_test_targets_t" - done - - printf '\n' -} - -# Generates the proper script test targets for each script test to have its own -# target. This allows `make test` to run in parallel. -# -# @param name Which calculator to generate tests for. -# @param extra_math An integer that, if non-zero, activates extra math tests. -# @param generate An integer that, if non-zero, activates generated tests. -# @param time_tests An integer that, if non-zero, tells the test suite to time -# the execution of each test. -gen_script_tests() { - - _gen_script_tests_name="$1" - shift - - _gen_script_tests_extra_math="$1" - shift - - _gen_script_tests_generate="$1" - shift - - _gen_script_tests_time="$1" - shift - - _gen_script_tests_tests=$(cat "$scriptdir/tests/$_gen_script_tests_name/scripts/all.txt") - - for _gen_script_tests_f in $_gen_script_tests_tests; do - - _gen_script_tests_b=$(basename "$_gen_script_tests_f" ".${_gen_script_tests_name}") - - printf 'test_%s_script_%s:\n\t@export BC_TEST_OUTPUT_DIR="%s/tests"; sh $(TESTSDIR)/script.sh %s %s %s 1 %s %s %s\n\n' \ - "$_gen_script_tests_name" "$_gen_script_tests_b" "$builddir" "$_gen_script_tests_name" \ - "$_gen_script_tests_f" "$_gen_script_tests_extra_math" "$_gen_script_tests_generate" \ - "$_gen_script_tests_time" "$*" >> "Makefile" - done -} - set_default() { _set_default_on="$1" @@ -710,7 +552,6 @@ predefined_build() { BSD) bc_only=0 dc_only=0 - coverage=0 debug=0 optimization="3" hist=1 @@ -723,11 +564,6 @@ predefined_build() { strip_bin=1 all_locales=0 library=0 - fuzz=0 - ossfuzz=0 - time_tests=0 - vg=0 - memcheck=0 clean=1 bc_default_banner=0 bc_default_sigint_reset=1 @@ -744,7 +580,6 @@ predefined_build() { GNU) bc_only=0 dc_only=0 - coverage=0 debug=0 optimization="3" hist=1 @@ -757,11 +592,6 @@ predefined_build() { strip_bin=1 all_locales=0 library=0 - fuzz=0 - ossfuzz=0 - time_tests=0 - vg=0 - memcheck=0 clean=1 bc_default_banner=1 bc_default_sigint_reset=1 @@ -777,10 +607,10 @@ predefined_build() { GDH) CFLAGS="-Weverything -Wno-padded -Wno-unsafe-buffer-usage -Wno-poison-system-directories" - CFLAGS="$CFLAGS -Wno-switch-default -Werror -pedantic -std=c11" + CFLAGS="$CFLAGS -Wno-unknown-warning-option -Wno-switch-default -Wno-pre-c11-compat" + CFLAGS="$CFLAGS -Werror -pedantic -std=c11" bc_only=0 dc_only=0 - coverage=0 debug=0 optimization="3" hist=1 @@ -793,11 +623,6 @@ predefined_build() { strip_bin=1 all_locales=0 library=0 - fuzz=0 - ossfuzz=0 - time_tests=0 - vg=0 - memcheck=0 clean=1 bc_default_banner=1 bc_default_sigint_reset=1 @@ -813,10 +638,10 @@ predefined_build() { DBG) CFLAGS="-Weverything -Wno-padded -Wno-unsafe-buffer-usage -Wno-poison-system-directories" - CFLAGS="$CFLAGS -Wno-switch-default -Werror -pedantic -std=c11" + CFLAGS="$CFLAGS -Wno-unknown-warning-option -Wno-switch-default -Wno-pre-c11-compat" + CFLAGS="$CFLAGS -Werror -pedantic -std=c11" bc_only=0 dc_only=0 - coverage=0 debug=1 optimization="0" hist=1 @@ -829,11 +654,6 @@ predefined_build() { strip_bin=1 all_locales=0 library=0 - fuzz=0 - ossfuzz=0 - time_tests=0 - vg=0 - memcheck=1 clean=1 bc_default_banner=1 bc_default_sigint_reset=1 @@ -852,36 +672,12 @@ predefined_build() { esac } -# Generates a list of script test targets that will be used as prerequisites for -# other targets. -# -# @param name The name of the calculator to generate script test targets for. -gen_script_test_targets() { - - _gen_script_test_targets_name="$1" - shift - - _gen_script_test_targets_tests=$(cat "$scriptdir/tests/$_gen_script_test_targets_name/scripts/all.txt") - - for _gen_script_test_targets_f in $_gen_script_test_targets_tests; do - _gen_script_test_targets_b=$(basename "$_gen_script_test_targets_f" \ - ".$_gen_script_test_targets_name") - printf ' test_%s_script_%s' "$_gen_script_test_targets_name" \ - "$_gen_script_test_targets_b" - done - - printf '\n' -} - # This is a list of defaults, but it is also the list of possible options for # users to change. # -# The development options are: force (force options even if they fail), valgrind -# (build in a way suitable for valgrind testing), memcheck (same as valgrind), -# and fuzzing (build in a way suitable for fuzzing). +# The development options are: force (force options even if they fail). bc_only=0 dc_only=0 -coverage=0 karatsuba_len=32 debug=0 hist=1 @@ -895,11 +691,6 @@ force=0 strip_bin=1 all_locales=0 library=0 -fuzz=0 -ossfuzz=0 -time_tests=0 -vg=0 -memcheck=0 clean=1 problematic_tests=1 @@ -920,13 +711,12 @@ dc_default_digit_clamp=0 # getopts is a POSIX utility, but it cannot handle long options. Thus, the # handling of long options is done by hand, and that's the reason that short and # long options cannot be mixed. -while getopts "abBcdDeEfgGhHik:lMmNO:p:PrS:s:tTvzZ-" opt; do +while getopts "abBcdDeEfgGhHik:lMNO:p:PrS:s:T-" opt; do case "$opt" in a) library=1 ;; b) bc_only=1 ;; B) dc_only=1 ;; - c) coverage=1 ;; C) clean=0 ;; d) dc_only=1 ;; D) bc_only=1 ;; @@ -940,7 +730,6 @@ while getopts "abBcdDeEfgGhHik:lMmNO:p:PrS:s:tTvzZ-" opt; do i) hist_impl="internal" ;; k) karatsuba_len="$OPTARG" ;; l) all_locales=1 ;; - m) memcheck=1 ;; M) install_manpages=0 ;; N) nls=0 ;; O) optimization="$OPTARG" ;; @@ -949,11 +738,7 @@ while getopts "abBcdDeEfgGhHik:lMmNO:p:PrS:s:tTvzZ-" opt; do r) hist_impl="readline" ;; S) set_default 0 "$OPTARG" ;; s) set_default 1 "$OPTARG" ;; - t) time_tests=1 ;; T) strip_bin=0 ;; - v) vg=1 ;; - z) fuzz=1 ;; - Z) ossfuzz=1 ;; -) arg="$1" arg="${arg#--}" @@ -963,7 +748,6 @@ while getopts "abBcdDeEfgGhHik:lMmNO:p:PrS:s:tTvzZ-" opt; do library) library=1 ;; bc-only) bc_only=1 ;; dc-only) dc_only=1 ;; - coverage) coverage=1 ;; debug) debug=1 ;; force) force=1 ;; prefix=?*) PREFIX="$LONG_OPTARG" ;; @@ -1077,27 +861,20 @@ while getopts "abBcdDeEfgGhHik:lMmNO:p:PrS:s:tTvzZ-" opt; do enable-editline) hist_impl="editline" ;; enable-readline) hist_impl="readline" ;; enable-internal-history) hist_impl="internal" ;; - enable-test-timing) time_tests=1 ;; - enable-valgrind) vg=1 ;; - enable-fuzz-mode) fuzz=1 ;; - enable-ossfuzz-mode) ossfuzz=1 ;; - enable-memcheck) memcheck=1 ;; install-all-locales) all_locales=1 ;; - help* | bc-only* | dc-only* | coverage* | debug*) + help* | bc-only* | dc-only* | debug*) usage "No arg allowed for --$arg option" ;; disable-bc* | disable-dc* | disable-clean*) usage "No arg allowed for --$arg option" ;; disable-extra-math*) usage "No arg allowed for --$arg option" ;; - disable-generated-tests* | disable-history*) + disable-history*) usage "No arg allowed for --$arg option" ;; disable-man-pages* | disable-nls* | disable-strip*) usage "No arg allowed for --$arg option" ;; disable-problematic-tests*) usage "No arg allowed for --$arg option" ;; - enable-fuzz-mode* | enable-test-timing* | enable-valgrind*) - usage "No arg allowed for --$arg option" ;; - enable-memcheck* | install-all-locales*) + install-all-locales*) usage "No arg allowed for --$arg option" ;; enable-editline* | enable-readline*) usage "No arg allowed for --$arg option" ;; @@ -1221,33 +998,7 @@ link="@printf 'No link necessary\\\\n'" main_exec="BC" executable="BC_EXEC" -tests="test_bc timeconst test_dc" - -bc_test="@export BC_TEST_OUTPUT_DIR=\"$builddir/tests\"; \$(TESTSDIR)/all.sh bc $extra_math 1 $generate_tests $problematic_tests $time_tests \$(BC_EXEC)" -bc_test_np="@export BC_TEST_OUTPUT_DIR=\"$builddir/tests\"; \$(TESTSDIR)/all.sh -n bc $extra_math 1 $generate_tests $problematic_tests $time_tests \$(BC_EXEC)" -dc_test="@export BC_TEST_OUTPUT_DIR=\"$builddir/tests\"; \$(TESTSDIR)/all.sh dc $extra_math 1 $generate_tests $problematic_tests $time_tests \$(DC_EXEC)" -dc_test_np="@export BC_TEST_OUTPUT_DIR=\"$builddir/tests\"; \$(TESTSDIR)/all.sh -n dc $extra_math 1 $generate_tests $problematic_tests $time_tests \$(DC_EXEC)" - -timeconst="@export BC_TEST_OUTPUT_DIR=\"$builddir/tests\"; \$(TESTSDIR)/bc/timeconst.sh \$(TESTSDIR)/bc/scripts/timeconst.bc \$(BC_EXEC)" - -# In order to have cleanup at exit, we need to be in -# debug mode, so don't run valgrind without that. -if [ "$vg" -ne 0 ]; then - debug=1 - bc_test_exec='valgrind $(VALGRIND_ARGS) $(BC_EXEC)' - dc_test_exec='valgrind $(VALGRIND_ARGS) $(DC_EXEC)' - bcl_test_exec='valgrind $(VALGRIND_ARGS) $(BCL_TEST)' -else - bc_test_exec='$(BC_EXEC)' - dc_test_exec='$(DC_EXEC)' - bcl_test_exec='$(BCL_TEST)' -fi - -test_bc_history_prereqs="test_bc_history_all" -test_dc_history_prereqs="test_dc_history_all" - karatsuba="@printf 'karatsuba cannot be run because one of bc or dc is not built\\\\n'" -karatsuba_test="@printf 'karatsuba cannot be run because one of bc or dc is not built\\\\n'" bc_lib="\$(GEN_DIR)/lib.o" bc_help="\$(GEN_DIR)/bc_help.o" @@ -1274,9 +1025,6 @@ if [ "$library" -ne 0 ]; then default_target_prereqs="\$(BIN) \$(OBJ)" default_target_cmd="ar -r -cu \$(LIBBC) \$(OBJ)" default_target="\$(LIBBC)" - tests="test_library" - test_bc_history_prereqs=" test_bc_history_skip" - test_dc_history_prereqs=" test_dc_history_skip" install_prereqs=" install_library" uninstall_prereqs=" uninstall_library" @@ -1292,10 +1040,6 @@ elif [ "$bc_only" -eq 1 ]; then executables="bc" - dc_test="@printf 'No dc tests to run\\\\n'" - dc_test_np="@printf 'No dc tests to run\\\\n'" - test_dc_history_prereqs=" test_dc_history_skip" - install_prereqs=" install_execs" install_man_prereqs=" install_bc_manpage" uninstall_prereqs=" uninstall_bc" @@ -1303,7 +1047,6 @@ elif [ "$bc_only" -eq 1 ]; then default_target="\$(BC_EXEC)" second_target="\$(DC_EXEC)" - tests="test_bc timeconst" elif [ "$dc_only" -eq 1 ]; then @@ -1318,58 +1061,11 @@ elif [ "$dc_only" -eq 1 ]; then main_exec="DC" executable="DC_EXEC" - bc_test="@printf 'No bc tests to run\\\\n'" - bc_test_np="@printf 'No bc tests to run\\\\n'" - test_bc_history_prereqs=" test_bc_history_skip" - - timeconst="@printf 'timeconst cannot be run because bc is not built\\\\n'" - install_prereqs=" install_execs" install_man_prereqs=" install_dc_manpage" uninstall_prereqs=" uninstall_dc" uninstall_man_prereqs=" uninstall_dc_manpage" - tests="test_dc" - -elif [ "$ossfuzz" -eq 1 ]; then - - if [ "$bc_only" -ne 0 ] || [ "$dc_only" -ne 0 ]; then - usage "An OSS-Fuzz build must build both fuzzers." - fi - - bc=1 - dc=1 - - # Expressions *cannot* exit in an OSS-Fuzz build. - bc_default_expr_exit=0 - dc_default_expr_exit=0 - - executables="bc_fuzzer and dc_fuzzer" - - karatsuba="@\$(KARATSUBA) 30 0 \$(BC_EXEC)" - karatsuba_test="@\$(KARATSUBA) 1 100 \$(BC_EXEC)" - - if [ "$library" -eq 0 ]; then - install_prereqs=" install_execs" - install_man_prereqs=" install_bc_manpage install_dc_manpage" - uninstall_prereqs=" uninstall_bc uninstall_dc" - uninstall_man_prereqs=" uninstall_bc_manpage uninstall_dc_manpage" - else - install_prereqs=" install_library install_bcl_header" - install_man_prereqs=" install_bcl_manpage" - uninstall_prereqs=" uninstall_library uninstall_bcl_header" - uninstall_man_prereqs=" uninstall_bcl_manpage" - tests="test_library" - fi - - second_target_prereqs="src/bc_fuzzer.o $default_target_prereqs" - default_target_prereqs="\$(BC_FUZZER) src/dc_fuzzer.o $default_target_prereqs" - default_target_cmd="\$(CXX) \$(CFLAGS) src/dc_fuzzer.o \$(LIB_FUZZING_ENGINE) \$(OBJS) \$(LDFLAGS) -o \$(DC_FUZZER) \&\& ln -sf ./dc_fuzzer_c \$(DC_FUZZER_C)" - second_target_cmd="\$(CXX) \$(CFLAGS) src/bc_fuzzer.o \$(LIB_FUZZING_ENGINE) \$(OBJS) \$(LDFLAGS) -o \$(BC_FUZZER) \&\& ln -sf ./bc_fuzzer_c \$(BC_FUZZER_C)" - - default_target="\$(DC_FUZZER) \$(DC_FUZZER_C)" - second_target="\$(BC_FUZZER) \$(BC_FUZZER_C)" - else bc=1 @@ -1378,7 +1074,6 @@ else executables="bc and dc" karatsuba="@\$(KARATSUBA) 30 0 \$(BC_EXEC)" - karatsuba_test="@\$(KARATSUBA) 1 100 \$(BC_EXEC)" if [ "$library" -eq 0 ]; then install_prereqs=" install_execs" @@ -1390,7 +1085,6 @@ else install_man_prereqs=" install_bcl_manpage" uninstall_prereqs=" uninstall_library uninstall_bcl_header" uninstall_man_prereqs=" uninstall_bcl_manpage" - tests="test_library" fi second_target_prereqs="$default_target_prereqs" @@ -1399,18 +1093,6 @@ else fi -if [ "$fuzz" -ne 0 ] && [ "$ossfuzz" -ne 0 ]; then - usage "Fuzzing mode and OSS-Fuzz mode are mutually exclusive" -fi - -# We need specific stuff for fuzzing. -if [ "$fuzz" -ne 0 ] || [ "$ossfuzz" -ne 0 ]; then - debug=1 - hist=0 - nls=0 - optimization="3" -fi - # This sets some necessary things for debug mode. if [ "$debug" -eq 1 ]; then @@ -1429,26 +1111,6 @@ if [ -n "$optimization" ]; then CFLAGS="-O$optimization $CFLAGS" fi -# Set test coverage defaults. -if [ "$coverage" -eq 1 ]; then - - if [ "$bc_only" -eq 1 ] || [ "$dc_only" -eq 1 ]; then - usage "Can only specify -c without -b or -d" - fi - - CFLAGS="-fprofile-arcs -ftest-coverage -g -O0 $CFLAGS" - CPPFLAGS="-DNDEBUG $CPPFLAGS" - - COVERAGE_OUTPUT="@gcov -pabcdf \$(GCDA) \$(BC_GCDA) \$(DC_GCDA) \$(HISTORY_GCDA) \$(RAND_GCDA)" - COVERAGE_OUTPUT="$COVERAGE_OUTPUT;\$(RM) -f \$(GEN)*.gc*" - COVERAGE_OUTPUT="$COVERAGE_OUTPUT;gcovr --exclude-unreachable-branches --exclude-throw-branches --html-details --output index.html" - COVERAGE_PREREQS=" test coverage_output" - -else - COVERAGE_OUTPUT="@printf 'Coverage not generated\\\\n'" - COVERAGE_PREREQS="" -fi - # Set some defaults. if [ -z "${DESTDIR+set}" ]; then destdir="" @@ -1567,7 +1229,7 @@ if [ "$nls" -ne 0 ]; then printf 'NLS works.\n\n' printf 'Testing gencat...\n' - gencat "./en_US.cat" "$scriptdir/locales/en_US.msg" > /dev/null + gencat "./en_US.cat" "$scriptdir/locales/en_US.msg" 2>&1 err="$?" @@ -1672,26 +1334,10 @@ else fi -# We have to disable the history tests if it is disabled or valgrind is on. Or -# if we are using editline or readline. -if [ "$hist" -eq 0 ] || [ "$vg" -ne 0 ]; then - test_bc_history_prereqs=" test_bc_history_skip" - test_dc_history_prereqs=" test_dc_history_skip" - history_tests="@printf 'Skipping history tests...\\\\n'" +if [ "$hist" -eq 0 ]; then CFLAGS="$CFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=0" else - if [ "$editline" -eq 0 ] && [ "$readline" -eq 0 ]; then - history_tests="@printf '\$(TEST_STARS)\\\\n\\\\nRunning history tests...\\\\n\\\\n'" - history_tests="$history_tests \&\& \$(TESTSDIR)/history.sh bc -a \&\&" - history_tests="$history_tests \$(TESTSDIR)/history.sh dc -a \&\& printf" - history_tests="$history_tests '\\\\nAll history tests passed.\\\\n\\\\n\$(TEST_STARS)\\\\n'" - else - test_bc_history_prereqs=" test_bc_history_skip" - test_dc_history_prereqs=" test_dc_history_skip" - history_tests="@printf 'Skipping history tests...\\\\n'" - fi - # We are also setting the CFLAGS and LDFLAGS here. if [ "$editline" -ne 0 ]; then LDFLAGS="$LDFLAGS -ledit" @@ -1795,7 +1441,7 @@ GEN_DIR="$scriptdir/gen" # `gen/strgen.sh` is used. GEN="strgen" GEN_EXEC_TARGET="\$(HOSTCC) -DBC_ENABLE_AFL=0 -DBC_ENABLE_OSSFUZZ=0 -I$scriptdir/include/ \$(HOSTCFLAGS) -o \$(GEN_EXEC) \$(GEN_C)" -CLEAN_PREREQS=" clean_gen clean_coverage" +CLEAN_PREREQS=" clean_gen" if [ -z "${GEN_HOST+set}" ]; then GEN_HOST=1 @@ -1803,7 +1449,6 @@ else if [ "$GEN_HOST" -eq 0 ]; then GEN="strgen.sh" GEN_EXEC_TARGET="@printf 'Do not need to build gen/strgen.c\\\\n'" - CLEAN_PREREQS=" clean_coverage" fi fi @@ -1848,9 +1493,7 @@ else headers="$headers \$(DC_HEADERS)" fi -# This convoluted mess does pull the version out. If you change the format of -# include/version.h, you may have to change this line. -version=$(cat "$scriptdir/include/version.h" | grep "VERSION " - | awk '{ print $3 }' -) +version=$(cat "$scriptdir/VERSION.txt" | head -n1) if [ "$library" -ne 0 ]; then @@ -1880,14 +1523,6 @@ if [ "$library" -ne 0 ]; then fi -elif [ "$ossfuzz" -ne 0 ]; then - - unneeded="$unneeded library.c main.c" - - PC_PATH="" - pkg_config_install="" - pkg_config_uninstall="" - else unneeded="$unneeded library.c" @@ -1909,10 +1544,6 @@ if [ "$manpage_args" = "" ]; then manpage_args="A" fi -if [ "$vg" -ne 0 ] || [ "$ossfuzz" -ne 0 ]; then - memcheck=1 -fi - if [ "$bc_default_prompt" = "" ]; then bc_default_prompt="$bc_default_tty_mode" fi @@ -1921,14 +1552,6 @@ if [ "$dc_default_prompt" = "" ]; then dc_default_prompt="$dc_default_tty_mode" fi -# Generate the test targets and prerequisites. -bc_tests=$(gen_std_test_targets bc) -bc_script_tests=$(gen_script_test_targets bc) -bc_err_tests=$(gen_err_test_targets bc) -dc_tests=$(gen_std_test_targets dc) -dc_script_tests=$(gen_script_test_targets dc) -dc_err_tests=$(gen_err_test_targets dc) - printf 'unneeded: %s\n' "$unneeded" # Print out the values; this is for debugging. @@ -1949,7 +1572,6 @@ printf 'BC_ENABLE_LIBRARY=%s\n\n' "$library" printf 'BC_ENABLE_HISTORY=%s\n' "$hist" printf 'BC_ENABLE_EXTRA_MATH=%s\n' "$extra_math" printf 'BC_ENABLE_NLS=%s\n\n' "$nls" -printf 'BC_ENABLE_AFL=%s\n' "$fuzz" printf '\n' printf 'BC_NUM_KARATSUBA_LEN=%s\n' "$karatsuba_len" printf '\n' @@ -2046,26 +1668,11 @@ contents=$(replace "$contents" "BUILDDIR" "$builddir") contents=$(replace "$contents" "HEADERS" "$headers") +contents=$(replace "$contents" "VERSION" "$version") + contents=$(replace "$contents" "BC_ENABLED" "$bc") contents=$(replace "$contents" "DC_ENABLED" "$dc") -contents=$(replace "$contents" "BC_ALL_TESTS" "$bc_test") -contents=$(replace "$contents" "BC_ALL_TESTS_NP" "$bc_test_np") -contents=$(replace "$contents" "BC_TESTS" "$bc_tests") -contents=$(replace "$contents" "BC_SCRIPT_TESTS" "$bc_script_tests") -contents=$(replace "$contents" "BC_ERROR_TESTS" "$bc_err_tests") -contents=$(replace "$contents" "BC_TEST_EXEC" "$bc_test_exec") -contents=$(replace "$contents" "TIMECONST_ALL_TESTS" "$timeconst") - -contents=$(replace "$contents" "DC_ALL_TESTS" "$dc_test") -contents=$(replace "$contents" "DC_ALL_TESTS_NP" "$dc_test_np") -contents=$(replace "$contents" "DC_TESTS" "$dc_tests") -contents=$(replace "$contents" "DC_SCRIPT_TESTS" "$dc_script_tests") -contents=$(replace "$contents" "DC_ERROR_TESTS" "$dc_err_tests") -contents=$(replace "$contents" "DC_TEST_EXEC" "$dc_test_exec") - -contents=$(replace "$contents" "BCL_TEST_EXEC" "$bcl_test_exec") - contents=$(replace "$contents" "BUILD_TYPE" "$manpage_args") contents=$(replace "$contents" "EXCLUDE_EXTRA_MATH" "$exclude_extra_math") @@ -2073,10 +1680,6 @@ contents=$(replace "$contents" "LIBRARY" "$library") contents=$(replace "$contents" "HISTORY" "$hist") contents=$(replace "$contents" "EXTRA_MATH" "$extra_math") contents=$(replace "$contents" "NLS" "$nls") -contents=$(replace "$contents" "FUZZ" "$fuzz") -contents=$(replace "$contents" "OSSFUZZ" "$ossfuzz") -contents=$(replace "$contents" "MEMCHECK" "$memcheck") -contents=$(replace "$contents" "LIB_FUZZING_ENGINE" "$LIB_FUZZING_ENGINE") contents=$(replace "$contents" "BC_LIB_O" "$bc_lib") contents=$(replace "$contents" "BC_HELP_O" "$bc_help") @@ -2099,8 +1702,6 @@ contents=$(replace "$contents" "CPPFLAGS" "$CPPFLAGS") contents=$(replace "$contents" "LDFLAGS" "$LDFLAGS") contents=$(replace "$contents" "CC" "$CC") contents=$(replace "$contents" "HOSTCC" "$HOSTCC") -contents=$(replace "$contents" "COVERAGE_OUTPUT" "$COVERAGE_OUTPUT") -contents=$(replace "$contents" "COVERAGE_PREREQS" "$COVERAGE_PREREQS") contents=$(replace "$contents" "INSTALL_PREREQS" "$install_prereqs") contents=$(replace "$contents" "INSTALL_MAN_PREREQS" "$install_man_prereqs") contents=$(replace "$contents" "INSTALL_LOCALES" "$install_locales") @@ -2126,22 +1727,14 @@ contents=$(replace "$contents" "BC_EXEC_CMD" "$bc_exec_cmd") contents=$(replace "$contents" "DC_EXEC_PREREQ" "$dc_exec_prereq") contents=$(replace "$contents" "DC_EXEC_CMD" "$dc_exec_cmd") +contents=$(replace "$contents" "GENERATE_TESTS" "$generate_tests") +contents=$(replace "$contents" "PROBLEMATIC_TESTS" "$problematic_tests") + contents=$(replace "$contents" "EXECUTABLES" "$executables") contents=$(replace "$contents" "MAIN_EXEC" "$main_exec") contents=$(replace "$contents" "EXEC" "$executable") -contents=$(replace "$contents" "TESTS" "$tests") - -contents=$(replace "$contents" "BC_HISTORY_TEST_PREREQS" "$test_bc_history_prereqs") -contents=$(replace "$contents" "DC_HISTORY_TEST_PREREQS" "$test_dc_history_prereqs") -contents=$(replace "$contents" "HISTORY_TESTS" "$history_tests") - -contents=$(replace "$contents" "VG_BC_TEST" "$vg_bc_test") -contents=$(replace "$contents" "VG_DC_TEST" "$vg_dc_test") - -contents=$(replace "$contents" "TIMECONST" "$timeconst") contents=$(replace "$contents" "KARATSUBA" "$karatsuba") -contents=$(replace "$contents" "KARATSUBA_TEST" "$karatsuba_test") contents=$(replace "$contents" "LONG_BIT_DEFINE" "$LONG_BIT_DEFINE") @@ -2169,28 +1762,6 @@ contents=$(replace "$contents" "DC_DEFAULT_DIGIT_CLAMP" "$dc_default_digit_clamp # Do the first print to the Makefile. printf '%s\n%s\n\n' "$contents" "$SRC_TARGETS" > "Makefile" -# Generate the individual test targets. -if [ "$bc" -ne 0 ]; then - gen_std_tests bc "$extra_math" "$time_tests" $bc_test_exec - gen_script_tests bc "$extra_math" "$generate_tests" "$time_tests" $bc_test_exec - gen_err_tests bc $bc_test_exec -fi - -if [ "$dc" -ne 0 ]; then - gen_std_tests dc "$extra_math" "$time_tests" $dc_test_exec - gen_script_tests dc "$extra_math" "$generate_tests" "$time_tests" $dc_test_exec - gen_err_tests dc $dc_test_exec -fi - -if [ "$ossfuzz" -ne 0 ]; then - - printf 'bc_fuzzer_c: $(BC_FUZZER)\n\tln -sf $(BC_FUZZER) bc_fuzzer_c\n' >> Makefile - printf 'bc_fuzzer_C: $(BC_FUZZER)\n\tln -sf $(BC_FUZZER) bc_fuzzer_C\n' >> Makefile - printf 'dc_fuzzer_c: $(DC_FUZZER)\n\tln -sf $(DC_FUZZER) dc_fuzzer_c\n' >> Makefile - printf 'dc_fuzzer_C: $(DC_FUZZER)\n\tln -sf $(DC_FUZZER) dc_fuzzer_C\n' >> Makefile - -fi - # Copy the correct manuals to the expected places. mkdir -p manuals cp -f "$scriptdir/manuals/bc/$manpage_args.1.md" manuals/bc.1.md |