Lines Matching +full:- +full:replace
3 # SPDX-License-Identifier: BSD-2-Clause
5 # Copyright (c) 2018-2021 Gavin D. Howard and contributors.
40 if [ $# -gt 0 ]; then
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"
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'
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'
74 printf ' -c, --coverage\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'
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'
86 printf ' -E, --disable-extra-math\n'
91 printf ' -f, --force\n'
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'
100 printf ' -G, --disable-generated-tests\n'
102 printf ' GNU bc-compatible bc to generate tests.\n'
103 printf ' -h, --help\n'
105 printf ' -H, --disable-history\n'
107 printf ' -k KARATSUBA_LEN, --karatsuba-len KARATSUBA_LEN\n'
110 printf ' -l, --install-all-locales\n'
114 printf ' -m, --enable-memcheck\n'
116 printf ' -M, --disable-man-pages\n'
118 printf ' -N, --disable-nls\n'
120 printf ' -O OPT_LEVEL, --opt OPT_LEVEL\n'
124 printf ' -P, --disable-prompt\n'
128 printf ' -t, --enable-test-timing\n'
130 printf ' -T, --disable-strip\n'
133 printf ' -v, --enable-valgrind\n'
135 printf ' -z, --enable-fuzz-mode\n'
137 printf ' --prefix PREFIX\n'
141 printf ' --bindir BINDIR\n'
144 printf ' --includedir INCLUDEDIR\n'
147 printf ' --libdir LIBDIR\n'
150 printf ' --datarootdir DATAROOTDIR\n'
153 printf ' --datadir DATADIR\n'
156 printf ' --mandir MANDIR\n'
159 printf ' --man1dir MAN1DIR\n'
162 printf ' --man3dir MAN3DIR\n'
214 printf ' except that 32-bit platforms with 64-bit longs may want to set\n'
229 printf ' production-ready compilers, this limit probably is not\n'
234 printf ' non-existent value, will cause the build system to compile and\n'
248 if [ "$#" -ne 3 ]; then
263 if [ "$#" -ne 3 ]; then
279 replace() {
281 if [ "$#" -ne 3 ]; then
294 if [ "$#" -ge 1 ] && [ "$1" != "" ]; then
296 while [ "$#" -ge 1 ]; do
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
322 if [ "$#" -ge 1 ]; then
334 _gen_file_list_contents=$(replace "$_gen_file_list_contents" \
338 _gen_file_list_contents=$(replace "$_gen_file_list_contents" \
342 _gen_file_list_contents=$(replace "$_gen_file_list_contents" \
346 _gen_file_list_contents=$(replace "$_gen_file_list_contents" \
372 if [ "$_gen_tests_extra_math" -eq 0 ]; then
374 if [ -z "${_gen_tests_extra_required##*$_gen_tests_t*}" ]; then
471 while getopts "abBcdDEfgGhHk:lMmNO:PStTvz-" opt; do
498 -)
500 arg="${arg#--}"
505 bc-only) bc_only=1 ;;
506 dc-only) dc_only=1 ;;
512 if [ "$#" -lt 2 ]; then
513 usage "No argument given for '--$arg' option"
519 if [ "$#" -lt 2 ]; then
520 usage "No argument given for '--$arg' option"
526 if [ "$#" -lt 2 ]; then
527 usage "No argument given for '--$arg' option"
533 if [ "$#" -lt 2 ]; then
534 usage "No argument given for '--$arg' option"
540 if [ "$#" -lt 2 ]; then
541 usage "No argument given for '--$arg' option"
547 if [ "$#" -lt 2 ]; then
548 usage "No argument given for '--$arg' option"
554 if [ "$#" -lt 2 ]; then
555 usage "No argument given for '--$arg' option"
561 if [ "$#" -lt 2 ]; then
562 usage "No argument given for '--$arg' option"
568 if [ "$#" -lt 2 ]; then
569 usage "No argument given for '--$arg' option"
575 if [ "$#" -lt 2 ]; then
576 usage "No argument given for '--$arg' option"
580 karatsuba-len=?*) karatsuba_len="$LONG_OPTARG" ;;
581 karatsuba-len)
582 if [ "$#" -lt 2 ]; then
583 usage "No argument given for '--$arg' option"
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" ;;
613 disable-extra-math*)
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
633 if [ "$clean" -ne 0 ]; then
634 if [ -f ./Makefile ]; then
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"
650 (*[!0-9]*|'') usage "KARATSUBA_LEN is not a number" ;;
654 if [ "$karatsuba_len" -lt 16 ]; then
658 set -e
660 if [ -z "${LONG_BIT+set}" ]; then
662 elif [ "$LONG_BIT" -lt 32 ]; then
665 LONG_BIT_DEFINE="-DBC_LONG_BIT=\$(BC_LONG_BIT)"
668 if [ -z "$CC" ]; then
689 if [ -z "$HOSTCC" ] && [ -z "$HOST_CC" ]; then
691 elif [ -z "$HOSTCC" ]; then
714 if [ -z "${HOSTCFLAGS+set}" ] && [ -z "${HOST_CFLAGS+set}" ]; then
716 elif [ -z "${HOSTCFLAGS+set}" ]; then
733 if [ "$vg" -ne 0 ]; then
750 default_target_cmd="\$(CC) \$(CFLAGS) \$(OBJS) \$(LDFLAGS) -o \$(EXEC)"
757 if [ "$library" -ne 0 ]; then
767 default_target_cmd="ar -r -cu \$(LIBBC) \$(OBJ)"
771 elif [ "$bc_only" -eq 1 ]; then
791 elif [ "$dc_only" -eq 1 ]; then
825 if [ "$library" -eq 0 ]; then
844 if [ "$fuzz" -ne 0 ]; then
852 if [ "$debug" -eq 1 ]; then
854 if [ -z "$CFLAGS" ] && [ -z "$optimization" ]; then
855 CFLAGS="-O0"
858 CFLAGS="-g $CFLAGS"
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"
890 if [ -z "${DESTDIR+set}" ]; then
896 if [ -z "${PREFIX+set}" ]; then
900 if [ -z "${BINDIR+set}" ]; then
904 if [ -z "${INCLUDEDIR+set}" ]; then
908 if [ -z "${LIBDIR+set}" ]; then
912 if [ "$install_manpages" -ne 0 ] || [ "$nls" -ne 0 ]; then
913 if [ -z "${DATAROOTDIR+set}" ]; then
918 if [ "$install_manpages" -ne 0 ]; then
920 if [ -z "${DATADIR+set}" ]; then
924 if [ -z "${MANDIR+set}" ]; then
928 if [ -z "${MAN1DIR+set}" ]; then
932 if [ -z "${MAN3DIR+set}" ]; then
941 if [ "$nls" -ne 0 ]; then
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"
960 if [ "$err" -ne 0 ]; then
962 if [ $force -eq 0 ]; then
976 rm -rf "$scriptdir/en_US.cat"
978 if [ "$err" -ne 0 ]; then
980 if [ $force -eq 0 ]; then
991 printf 'Cross-compile detected.\n\n'
996 if [ -z "$NLSPATH" ]; then
1007 set -e
1015 if [ "$nls" -ne 0 ] && [ "$all_locales" -ne 0 ]; then
1016 install_locales="\$(LOCALE_INSTALL) -l \$(NLSPATH) \$(MAIN_EXEC) \$(DESTDIR)"
1021 if [ "$hist" -eq 1 ]; then
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"
1040 if [ "$err" -ne 0 ]; then
1042 if [ $force -eq 0 ]; then
1052 set -e
1056 if [ "$library" -eq 1 ]; then
1060 if [ "$extra_math" -eq 1 ] && [ "$bc" -ne 0 ] && [ "$library" -eq 0 ]; then
1067 GEN_EXEC_TARGET="\$(HOSTCC) \$(HOSTCFLAGS) -o \$(GEN_EXEC) \$(GEN_C)"
1070 if [ -z "${GEN_HOST+set}" ]; then
1073 if [ "$GEN_HOST" -eq 0 ]; then
1084 if [ "$extra_math" -eq 0 ]; then
1091 if [ "$hist" -eq 0 ]; then
1098 if [ "$nls" -eq 0 ]; then
1102 if [ "$prompt" -eq 0 ]; then
1106 if [ "$bc" -eq 0 ]; then
1112 if [ "$dc" -eq 0 ]; then
1118 if [ "$library" -ne 0 ]; then
1132 if [ "$vg" -ne 0 ]; then
1142 if [ "$bc" -ne 0 ]; then
1147 if [ "$dc" -ne 0 ]; then
1190 contents=$(replace "$contents" "$needle" "$replacement")
1204 SRC_TARGETS=$(printf '%s\n\n%s: %s %s\n\t$(CC) $(CFLAGS) -o %s -c %s\n' \
1208 contents=$(replace "$contents" "HEADERS" "$headers")
1210 contents=$(replace "$contents" "BC_ENABLED" "$bc")
1211 contents=$(replace "$contents" "DC_ENABLED" "$dc")
1213 contents=$(replace "$contents" "BC_ALL_TESTS" "$bc_test")
1214 contents=$(replace "$contents" "BC_TESTS" "$bc_tests")
1215 contents=$(replace "$contents" "BC_SCRIPT_TESTS" "$bc_script_tests")
1216 contents=$(replace "$contents" "BC_TEST_EXEC" "$bc_test_exec")
1217 contents=$(replace "$contents" "TIMECONST_ALL_TESTS" "$timeconst")
1219 contents=$(replace "$contents" "DC_ALL_TESTS" "$dc_test")
1220 contents=$(replace "$contents" "DC_TESTS" "$dc_tests")
1221 contents=$(replace "$contents" "DC_SCRIPT_TESTS" "$dc_script_tests")
1222 contents=$(replace "$contents" "DC_TEST_EXEC" "$dc_test_exec")
1224 contents=$(replace "$contents" "BUILD_TYPE" "$manpage_args")
1226 contents=$(replace "$contents" "LIBRARY" "$library")
1227 contents=$(replace "$contents" "HISTORY" "$hist")
1228 contents=$(replace "$contents" "EXTRA_MATH" "$extra_math")
1229 contents=$(replace "$contents" "NLS" "$nls")
1230 contents=$(replace "$contents" "PROMPT" "$prompt")
1231 contents=$(replace "$contents" "FUZZ" "$fuzz")
1232 contents=$(replace "$contents" "MEMCHECK" "$memcheck")
1234 contents=$(replace "$contents" "BC_LIB_O" "$bc_lib")
1235 contents=$(replace "$contents" "BC_HELP_O" "$bc_help")
1236 contents=$(replace "$contents" "DC_HELP_O" "$dc_help")
1237 contents=$(replace "$contents" "BC_LIB2_O" "$BC_LIB2_O")
1238 contents=$(replace "$contents" "KARATSUBA_LEN" "$karatsuba_len")
1240 contents=$(replace "$contents" "NLSPATH" "$NLSPATH")
1241 contents=$(replace "$contents" "DESTDIR" "$destdir")
1242 contents=$(replace "$contents" "EXECSUFFIX" "$EXECSUFFIX")
1243 contents=$(replace "$contents" "EXECPREFIX" "$EXECPREFIX")
1244 contents=$(replace "$contents" "BINDIR" "$BINDIR")
1245 contents=$(replace "$contents" "INCLUDEDIR" "$INCLUDEDIR")
1246 contents=$(replace "$contents" "LIBDIR" "$LIBDIR")
1247 contents=$(replace "$contents" "MAN1DIR" "$MAN1DIR")
1248 contents=$(replace "$contents" "MAN3DIR" "$MAN3DIR")
1249 contents=$(replace "$contents" "CFLAGS" "$CFLAGS")
1250 contents=$(replace "$contents" "HOSTCFLAGS" "$HOSTCFLAGS")
1251 contents=$(replace "$contents" "CPPFLAGS" "$CPPFLAGS")
1252 contents=$(replace "$contents" "LDFLAGS" "$LDFLAGS")
1253 contents=$(replace "$contents" "CC" "$CC")
1254 contents=$(replace "$contents" "HOSTCC" "$HOSTCC")
1255 contents=$(replace "$contents" "COVERAGE_OUTPUT" "$COVERAGE_OUTPUT")
1256 contents=$(replace "$contents" "COVERAGE_PREREQS" "$COVERAGE_PREREQS")
1257 contents=$(replace "$contents" "INSTALL_PREREQS" "$install_prereqs")
1258 contents=$(replace "$contents" "INSTALL_MAN_PREREQS" "$install_man_prereqs")
1259 contents=$(replace "$contents" "INSTALL_LOCALES" "$install_locales")
1260 contents=$(replace "$contents" "INSTALL_LOCALES_PREREQS" "$install_locales_prereqs")
1261 contents=$(replace "$contents" "UNINSTALL_MAN_PREREQS" "$uninstall_man_prereqs")
1262 contents=$(replace "$contents" "UNINSTALL_PREREQS" "$uninstall_prereqs")
1263 contents=$(replace "$contents" "UNINSTALL_LOCALES_PREREQS" "$uninstall_locales_prereqs")
1265 contents=$(replace "$contents" "DEFAULT_TARGET" "$default_target")
1266 contents=$(replace "$contents" "DEFAULT_TARGET_PREREQS" "$default_target_prereqs")
1267 contents=$(replace "$contents" "DEFAULT_TARGET_CMD" "$default_target_cmd")
1268 contents=$(replace "$contents" "SECOND_TARGET" "$second_target")
1269 contents=$(replace "$contents" "SECOND_TARGET_PREREQS" "$second_target_prereqs")
1270 contents=$(replace "$contents" "SECOND_TARGET_CMD" "$second_target_cmd")
1272 contents=$(replace "$contents" "ALL_PREREQ" "$ALL_PREREQ")
1273 contents=$(replace "$contents" "BC_EXEC_PREREQ" "$bc_exec_prereq")
1274 contents=$(replace "$contents" "BC_EXEC_CMD" "$bc_exec_cmd")
1275 contents=$(replace "$contents" "DC_EXEC_PREREQ" "$dc_exec_prereq")
1276 contents=$(replace "$contents" "DC_EXEC_CMD" "$dc_exec_cmd")
1278 contents=$(replace "$contents" "EXECUTABLES" "$executables")
1279 contents=$(replace "$contents" "MAIN_EXEC" "$main_exec")
1280 contents=$(replace "$contents" "EXEC" "$executable")
1281 contents=$(replace "$contents" "TESTS" "$tests")
1283 contents=$(replace "$contents" "BC_TEST" "$bc_test")
1284 contents=$(replace "$contents" "DC_TEST" "$dc_test")
1286 contents=$(replace "$contents" "VG_BC_TEST" "$vg_bc_test")
1287 contents=$(replace "$contents" "VG_DC_TEST" "$vg_dc_test")
1289 contents=$(replace "$contents" "TIMECONST" "$timeconst")
1291 contents=$(replace "$contents" "KARATSUBA" "$karatsuba")
1292 contents=$(replace "$contents" "KARATSUBA_TEST" "$karatsuba_test")
1294 contents=$(replace "$contents" "LONG_BIT" "$LONG_BIT")
1295 contents=$(replace "$contents" "LONG_BIT_DEFINE" "$LONG_BIT_DEFINE")
1297 contents=$(replace "$contents" "GEN" "$GEN")
1298 contents=$(replace "$contents" "GEN_EXEC_TARGET" "$GEN_EXEC_TARGET")
1299 contents=$(replace "$contents" "CLEAN_PREREQS" "$CLEAN_PREREQS")
1300 contents=$(replace "$contents" "GEN_EMU" "$GEN_EMU")
1304 if [ "$bc" -ne 0 ]; then
1309 if [ "$dc" -ne 0 ]; then
1316 cp -f manuals/bc/$manpage_args.1.md manuals/bc.1.md
1317 cp -f manuals/bc/$manpage_args.1 manuals/bc.1
1318 cp -f manuals/dc/$manpage_args.1.md manuals/dc.1.md
1319 cp -f manuals/dc/$manpage_args.1 manuals/dc.1