Lines Matching +full:n +full:- +full:- +full:-
3 # SPDX-License-Identifier: BSD-2-Clause
5 # Copyright (c) 2018-2025 Gavin D. Howard and contributors.
42 if [ $# -gt 0 ]; then
46 printf '%s\n\n' "$1"
52 printf 'usage:\n'
53 printf ' %s -h\n' "$script"
54 printf ' %s --help\n' "$script"
55 …printf ' %s [-a|-bD|-dB|-c] [-CeEfgGHilmMNPrtTvz] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\\\n' "$scri…
56 printf ' [-s SETTING] [-S SETTING] [-p TYPE]\n'
57 printf ' %s \\\n' "$script"
58 printf ' [--library|--bc-only --disable-dc|--dc-only --disable-bc] \\\n'
59 printf ' [--force --debug --disable-extra-math --disable-generated-tests] \\\n'
60 printf ' [--disable-history --disable-man-pages --disable-nls --disable-strip] \\\n'
61 printf ' [--enable-editline] [--enable-readline] [--enable-internal-history] \\\n'
62 printf ' [--disable-problematic-tests] [--install-all-locales] \\\n'
63 printf ' [--opt=OPT_LEVEL] [--karatsuba-len=KARATSUBA_LEN] \\\n'
64 printf ' [--set-default-on=SETTING] [--set-default-off=SETTING] \\\n'
65 printf ' [--predefined-build-type=TYPE] \\\n'
66 printf ' [--prefix=PREFIX] [--bindir=BINDIR] [--datarootdir=DATAROOTDIR] \\\n'
67 printf ' [--datadir=DATADIR] [--mandir=MANDIR] [--man1dir=MAN1DIR] \\\n'
68 printf ' [--man3dir=MAN3DIR]\n'
70 if [ "$_usage_val" -ne 0 ]; then
74 printf '\n'
75 printf ' -a, --library\n'
76 printf ' Build the libbcl instead of the programs. This is meant to be used with\n'
77 printf ' other software like programming languages that want to make use of the\n'
78 printf ' parsing and math capabilities. This option will install headers using\n'
79 printf ' `make install`.\n'
80 printf ' -b, --bc-only\n'
81 printf ' Build bc only. It is an error if "-d", "--dc-only", "-B", or\n'
82 printf ' "--disable-bc" are specified too.\n'
83 printf ' -B, --disable-bc\n'
84 printf ' Disable bc. It is an error if "-b", "--bc-only", "-D", or "--disable-dc"\n'
85 printf ' are specified too.\n'
86 printf ' -C, --disable-clean\n'
87 printf ' Disable the clean that configure.sh does before configure.\n'
88 printf ' -d, --dc-only\n'
89 printf ' Build dc only. It is an error if "-b", "--bc-only", "-D", or\n'
90 printf ' "--disable-dc" are specified too.\n'
91 printf ' -D, --disable-dc\n'
92 printf ' Disable dc. It is an error if "-d", "--dc-only", "-B", or "--disable-bc"\n'
93 printf ' are specified too.\n'
94 printf ' -e, --enable-editline\n'
95 printf ' Enable the use of libedit/editline. This is meant for those users that\n'
96 printf ' want vi-like or Emacs-like behavior in history. This option is ignored\n'
97 printf ' if history is disabled. If the -r or -i options are given with this\n'
98 printf ' option, the last occurrence of all of the three is used.\n'
99 printf ' -E, --disable-extra-math\n'
100 printf ' Disable extra math. This includes: "$" operator (truncate to integer),\n'
101 printf ' "@" operator (set number of decimal places), and r(x, p) (rounding\n'
102 printf ' function). Additionally, this option disables the extra printing\n'
103 printf ' functions in the math library.\n'
104 printf ' -f, --force\n'
105 printf ' Force use of all enabled options, even if they do not work. This\n'
106 printf ' option is to allow the maintainer a way to test that certain options\n'
107 printf ' are not failing invisibly. (Development only.)\n'
108 printf ' -g, --debug\n'
109 printf ' Build in debug mode. Adds the "-g" flag, and if there are no\n'
110 printf ' other CFLAGS, and "-O" was not given, this also adds the "-O0"\n'
111 printf ' flag. If this flag is *not* given, "-DNDEBUG" is added to CPPFLAGS\n'
112 printf ' and a strip flag is added to the link stage.\n'
113 printf ' -G, --disable-generated-tests\n'
114 printf ' Disable generating tests. This is for platforms that do not have a\n'
115 printf ' GNU bc-compatible bc to generate tests.\n'
116 printf ' -h, --help\n'
117 printf ' Print this help message and exit.\n'
118 printf ' -H, --disable-history\n'
119 printf ' Disable history.\n'
120 printf ' -i, --enable-internal-history\n'
121 printf ' Enable the internal history implementation and do not depend on either\n'
122 printf ' editline or readline. This option is ignored if history is disabled.\n'
123 printf ' If this option is given along with -e and -r, the last occurrence of\n'
124 printf ' all of the three is used.\n'
125 printf ' -k KARATSUBA_LEN, --karatsuba-len KARATSUBA_LEN\n'
126 printf ' Set the karatsuba length to KARATSUBA_LEN (default is 32).\n'
127 printf ' It is an error if KARATSUBA_LEN is not a number or is less than 16.\n'
128 printf ' -l, --install-all-locales\n'
129 printf ' Installs all locales, regardless of how many are on the system. This\n'
130 printf ' option is useful for package maintainers who want to make sure that\n'
131 printf ' a package contains all of the locales that end users might need.\n'
132 printf ' -M, --disable-man-pages\n'
133 printf ' Disable installing manpages.\n'
134 printf ' -N, --disable-nls\n'
135 printf ' Disable POSIX locale (NLS) support.\n'
136 printf ' ***WARNING***: Locales ignore the prefix because they *must* be\n'
137 printf ' installed at a fixed location to work at all. If you do not want that\n'
138 printf ' to happen, you must disable locales (NLS) completely.\n'
139 printf ' -O OPT_LEVEL, --opt OPT_LEVEL\n'
140 printf ' Set the optimization level. This can also be included in the CFLAGS,\n'
141 printf ' but it is provided, so maintainers can build optimized debug builds.\n'
142 printf ' This is passed through to the compiler, so it must be supported.\n'
143 printf ' -p TYPE, --predefined-build-type=TYPE\n'
144 printf ' Sets a given predefined build type with specific defaults. This is for\n'
145 printf ' easy setting of predefined builds. For example, to get a build that\n'
146 printf ' acts like the GNU bc by default, TYPE should be "GNU" (without the\n'
147 printf ' quotes) This option *must* come before any others that might change the\n'
148 printf ' build options. Currently supported values for TYPE include: "BSD" (for\n'
149 printf ' matching the BSD bc and BSD dc), "GNU" (for matching the GNU bc and\n'
150 printf ' dc), "GDH" (for the preferred build of the author, Gavin D. Howard),\n'
151 printf ' and "DBG" (for the preferred debug build of the author). This will\n'
152 printf ' also automatically enable a release build (except for "DBG").\n'
153 printf ' -P, --disable-problematic-tests\n'
154 printf ' Disables problematic tests. These tests usually include tests that\n'
155 printf ' can cause a SIGKILL because of too much memory usage.\n'
156 printf ' -r, --enable-readline\n'
157 printf ' Enable the use of libreadline/readline. This is meant for those users\n'
158 printf ' that want vi-like or Emacs-like behavior in history. This option is\n'
159 printf ' ignored if history is disabled. If this option is given along with -e\n'
160 printf ' and -i, the last occurrence of all of the three is used.\n'
161 printf ' -s SETTING, --set-default-on SETTING\n'
162 printf ' Set the default named by SETTING to on. See below for possible values\n'
163 printf ' for SETTING. For multiple instances of the -s or -S for the the same\n'
164 printf ' setting, the last one is used.\n'
165 printf ' -S SETTING, --set-default-off SETTING\n'
166 printf ' Set the default named by SETTING to off. See below for possible values\n'
167 printf ' for SETTING. For multiple instances of the -s or -S for the the same\n'
168 printf ' setting, the last one is used.\n'
169 printf ' -T, --disable-strip\n'
170 printf ' Disable stripping symbols from the compiled binary or binaries.\n'
171 printf ' Stripping symbols only happens when debug mode is off.\n'
172 printf ' --prefix PREFIX\n'
173 printf ' The prefix to install to. Overrides "$PREFIX" if it exists.\n'
174 printf ' If PREFIX is "/usr", install path will be "/usr/bin".\n'
175 printf ' Default is "/usr/local".\n'
176 printf ' ***WARNING***: Locales ignore the prefix because they *must* be\n'
177 printf ' installed at a fixed location to work at all. If you do not want that to\n'
178 printf ' happen, you must disable locales (NLS) completely.\n'
179 printf ' --bindir BINDIR\n'
180 printf ' The directory to install binaries in. Overrides "$BINDIR" if it exists.\n'
181 printf ' Default is "$PREFIX/bin".\n'
182 printf ' --includedir INCLUDEDIR\n'
183 printf ' The directory to install headers in. Overrides "$INCLUDEDIR" if it\n'
184 printf ' exists. Default is "$PREFIX/include".\n'
185 printf ' --libdir LIBDIR\n'
186 printf ' The directory to install libraries in. Overrides "$LIBDIR" if it exists.\n'
187 printf ' Default is "$PREFIX/lib".\n'
188 printf ' --datarootdir DATAROOTDIR\n'
189 printf ' The root location for data files. Overrides "$DATAROOTDIR" if it exists.\n'
190 printf ' Default is "$PREFIX/share".\n'
191 printf ' --datadir DATADIR\n'
192 printf ' The location for data files. Overrides "$DATADIR" if it exists.\n'
193 printf ' Default is "$DATAROOTDIR".\n'
194 printf ' --mandir MANDIR\n'
195 printf ' The location to install manpages to. Overrides "$MANDIR" if it exists.\n'
196 printf ' Default is "$DATADIR/man".\n'
197 printf ' --man1dir MAN1DIR\n'
198 printf ' The location to install Section 1 manpages to. Overrides "$MAN1DIR" if\n'
199 printf ' it exists. Default is "$MANDIR/man1".\n'
200 printf ' --man3dir MAN3DIR\n'
201 printf ' The location to install Section 3 manpages to. Overrides "$MAN3DIR" if\n'
202 printf ' it exists. Default is "$MANDIR/man3".\n'
203 printf '\n'
204 printf 'In addition, the following environment variables are used:\n'
205 printf '\n'
206 printf ' CC C compiler. Must be compatible with POSIX c99. If there is a\n'
207 printf ' space in the basename of the compiler, the items after the\n'
208 printf ' first space are assumed to be compiler flags, and in that case,\n'
209 printf ' the flags are automatically moved into CFLAGS. Default is\n'
210 printf ' "c99".\n'
211 printf ' HOSTCC Host C compiler. Must be compatible with POSIX c99. If there is\n'
212 printf ' a space in the basename of the compiler, the items after the\n'
213 printf ' first space are assumed to be compiler flags, and in the case,\n'
214 printf ' the flags are automatically moved into HOSTCFLAGS. Default is\n'
215 printf ' "$CC".\n'
216 printf ' HOST_CC Same as HOSTCC. If HOSTCC also exists, it is used.\n'
217 printf ' CFLAGS C compiler flags.\n'
218 printf ' HOSTCFLAGS CFLAGS for HOSTCC. Default is "$CFLAGS".\n'
219 printf ' HOST_CFLAGS Same as HOST_CFLAGS. If HOST_CFLAGS also exists, it is used.\n'
220 printf ' CPPFLAGS C preprocessor flags. Default is "".\n'
221 printf ' LDFLAGS Linker flags. Default is "".\n'
222 printf ' PREFIX The prefix to install to. Default is "/usr/local".\n'
223 printf ' If PREFIX is "/usr", install path will be "/usr/bin".\n'
224 printf ' ***WARNING***: Locales ignore the prefix because they *must* be\n'
225 printf ' installed at a fixed location to work at all. If you do not\n'
226 printf ' want that to happen, you must disable locales (NLS) completely.\n'
227 printf ' BINDIR The directory to install binaries in. Default is "$PREFIX/bin".\n'
228 printf ' INCLUDEDIR The directory to install header files in. Default is\n'
229 printf ' "$PREFIX/include".\n'
230 printf ' LIBDIR The directory to install libraries in. Default is\n'
231 printf ' "$PREFIX/lib".\n'
232 printf ' DATAROOTDIR The root location for data files. Default is "$PREFIX/share".\n'
233 printf ' DATADIR The location for data files. Default is "$DATAROOTDIR".\n'
234 printf ' MANDIR The location to install manpages to. Default is "$DATADIR/man".\n'
235 printf ' MAN1DIR The location to install Section 1 manpages to. Default is\n'
236 printf ' "$MANDIR/man1".\n'
237 printf ' MAN3DIR The location to install Section 3 manpages to. Default is\n'
238 printf ' "$MANDIR/man3".\n'
239 printf ' NLSPATH The location to install locale catalogs to. Must be an absolute\n'
240 printf ' path (or contain one). This is treated the same as the POSIX\n'
241 printf ' definition of $NLSPATH (see POSIX environment variables for\n'
242 printf ' more information). Default is "/usr/share/locale/%%L/%%N".\n'
243 printf ' PC_PATH The location to install pkg-config files to. Must be a\n'
244 printf ' path or contain one. Default is the first path given by the\n'
245 printf ' output of `pkg-config --variable=pc_path pkg-config`.\n'
246 printf ' EXECSUFFIX The suffix to append to the executable names, used to not\n'
247 printf ' interfere with other installed bc executables. Default is "".\n'
248 printf ' EXECPREFIX The prefix to prepend to the executable names, used to not\n'
249 printf ' interfere with other installed bc executables. Default is "".\n'
250 printf ' DESTDIR For package creation. Default is "". If it is empty when\n'
251 printf ' `%s` is run, it can also be passed to `make install`\n' "$script"
252 printf ' later as an environment variable. If both are specified,\n'
253 printf ' the one given to `%s` takes precedence.\n' "$script"
254 printf ' LONG_BIT The number of bits in a C `long` type. This is mostly for the\n'
255 printf ' embedded space since this `bc` uses `long`s internally for\n'
256 printf ' overflow checking. In C99, a `long` is required to be 32 bits.\n'
257 printf ' For most normal desktop systems, setting this is unnecessary,\n'
258 printf ' except that 32-bit platforms with 64-bit longs may want to set\n'
259 printf ' it to `32`. Default is the default of `LONG_BIT` for the target\n'
260 printf ' platform. Minimum allowed is `32`. It is a build time error if\n'
261 printf ' the specified value of `LONG_BIT` is greater than the default\n'
262 printf ' value of `LONG_BIT` for the target platform.\n'
263 printf ' GEN_HOST Whether to use `gen/strgen.c`, instead of `gen/strgen.sh`, to\n'
264 printf ' produce the C files that contain the help texts as well as the\n'
265 printf ' math libraries. By default, `gen/strgen.c` is used, compiled by\n'
266 printf ' "$HOSTCC" and run on the host machine. Using `gen/strgen.sh`\n'
267 printf ' removes the need to compile and run an executable on the host\n'
268 printf ' machine since `gen/strgen.sh` is a POSIX shell script. However,\n'
269 printf ' `gen/lib2.bc` is over 4095 characters, the max supported length\n'
270 printf ' of a string literal in C99, and `gen/strgen.sh` generates a\n'
271 printf ' string literal instead of an array, as `gen/strgen.c` does. For\n'
272 printf ' most production-ready compilers, this limit probably is not\n'
273 printf ' enforced, but it could be. Both options are still available for\n'
274 printf ' this reason. If you are sure your compiler does not have the\n'
275 printf ' limit and do not want to compile and run a binary on the host\n'
276 printf ' machine, set this variable to "0". Any other value, or a\n'
277 printf ' non-existent value, will cause the build system to compile and\n'
278 printf ' run `gen/strgen.c`. Default is "".\n'
279 printf ' GEN_EMU Emulator to run string generator code under (leave empty if not\n'
280 printf ' necessary). This is not necessary when using `gen/strgen.sh`.\n'
281 printf ' Default is "".\n'
282 printf '\n'
283 printf 'WARNING: even though `configure.sh` supports both option types, short and\n'
284 printf 'long, it does not support handling both at the same time. Use only one type.\n'
285 printf '\n'
286 printf 'Settings\n'
287 printf '========\n'
288 printf '\n'
289 printf 'bc and dc have some settings that, while they cannot be removed by build time\n'
290 printf 'options, can have their defaults changed at build time by packagers. Users are\n'
291 printf 'also able to change each setting with environment variables.\n'
292 printf '\n'
293 printf 'The following is a table of settings, along with their default values and the\n'
294 printf 'environment variables users can use to change them. (For the defaults, non-zero\n'
295 printf 'means on, and zero means off.)\n'
296 printf '\n'
297 printf '| Setting | Description | Default | Env Variable |\n'
298 printf '| =============== | ==================== | ============ | ==================== |\n'
299 printf '| bc.banner | Whether to display | 0 | BC_BANNER |\n'
300 printf '| | the bc version | | |\n'
301 printf '| | banner when in | | |\n'
302 printf '| | interactive mode. | | |\n'
303 printf '| --------------- | -------------------- | ------------ | -------------------- |\n'
304 printf '| bc.sigint_reset | Whether SIGINT will | 1 | BC_SIGINT_RESET |\n'
305 printf '| | reset bc, instead of | | |\n'
306 printf '| | exiting, when in | | |\n'
307 printf '| | interactive mode. | | |\n'
308 printf '| --------------- | -------------------- | ------------ | -------------------- |\n'
309 printf '| dc.sigint_reset | Whether SIGINT will | 1 | DC_SIGINT_RESET |\n'
310 printf '| | reset dc, instead of | | |\n'
311 printf '| | exiting, when in | | |\n'
312 printf '| | interactive mode. | | |\n'
313 printf '| --------------- | -------------------- | ------------ | -------------------- |\n'
314 printf '| bc.tty_mode | Whether TTY mode for | 1 | BC_TTY_MODE |\n'
315 printf '| | bc should be on when | | |\n'
316 printf '| | available. | | |\n'
317 printf '| --------------- | -------------------- | ------------ | -------------------- |\n'
318 printf '| dc.tty_mode | Whether TTY mode for | 0 | BC_TTY_MODE |\n'
319 printf '| | dc should be on when | | |\n'
320 printf '| | available. | | |\n'
321 printf '| --------------- | -------------------- | ------------ | -------------------- |\n'
322 printf '| bc.prompt | Whether the prompt | $BC_TTY_MODE | BC_PROMPT |\n'
323 printf '| | for bc should be on | | |\n'
324 printf '| | in tty mode. | | |\n'
325 printf '| --------------- | -------------------- | ------------ | -------------------- |\n'
326 printf '| dc.prompt | Whether the prompt | $DC_TTY_MODE | DC_PROMPT |\n'
327 printf '| | for dc should be on | | |\n'
328 printf '| | in tty mode. | | |\n'
329 printf '| --------------- | -------------------- | ------------ | -------------------- |\n'
330 printf '| bc.expr_exit | Whether to exit bc | 1 | BC_EXPR_EXIT |\n'
331 printf '| | if an expression or | | |\n'
332 printf '| | expression file is | | |\n'
333 printf '| | given with the -e or | | |\n'
334 printf '| | -f options. | | |\n'
335 printf '| --------------- | -------------------- | ------------ | -------------------- |\n'
336 printf '| dc.expr_exit | Whether to exit dc | 1 | DC_EXPR_EXIT |\n'
337 printf '| | if an expression or | | |\n'
338 printf '| | expression file is | | |\n'
339 printf '| | given with the -e or | | |\n'
340 printf '| | -f options. | | |\n'
341 printf '| --------------- | -------------------- | ------------ | -------------------- |\n'
342 printf '| bc.digit_clamp | Whether to have bc | 0 | BC_DIGIT_CLAMP |\n'
343 printf '| | clamp digits that | | |\n'
344 printf '| | are greater than or | | |\n'
345 printf '| | equal to the current | | |\n'
346 printf '| | ibase when parsing | | |\n'
347 printf '| | numbers. | | |\n'
348 printf '| --------------- | -------------------- | ------------ | -------------------- |\n'
349 printf '| dc.digit_clamp | Whether to have dc | 0 | DC_DIGIT_CLAMP |\n'
350 printf '| | clamp digits that | | |\n'
351 printf '| | are greater than or | | |\n'
352 printf '| | equal to the current | | |\n'
353 printf '| | ibase when parsing | | |\n'
354 printf '| | numbers. | | |\n'
355 printf '| --------------- | -------------------- | ------------ | -------------------- |\n'
356 printf '\n'
357 printf 'These settings are not meant to be changed on a whim. They are meant to ensure\n'
358 printf 'that this bc and dc will conform to the expectations of the user on each\n'
359 printf 'platform.\n'
373 if [ "$#" -ne 3 ]; then
383 printf '%s\n' "$_replace_ext_result"
387 # a space-separated list of words, so filenames are expected to *not* have
390 # @param files The list of space-separated filenames to replace extensions for.
395 if [ "$#" -ne 3 ]; then
408 printf '%s\n' "$_replace_exts_result"
424 if [ "$#" -ne 3 ]; then
442 if [ "$#" -ge 1 ] && [ "$1" != "" ]; then
444 while [ "$#" -ge 1 ]; do
447 …_find_src_files_args=$(printf '%s\n%s/src/%s\n' "$_find_src_files_args" "$scriptdir" "${_find_src_…
452 _find_src_files_files=$(find "$scriptdir/src" -depth -name "*.c" -print | LC_ALL=C sort)
463 _find_src_files_result=$(printf '%s\n%s\n' "$_find_src_files_result" "$_find_src_files_f")
467 printf '%s\n' "$_find_src_files_result"
477 if [ "$#" -lt 1 ]; then
484 if [ "$#" -ge 1 ]; then
493 _gen_file_list_replacement=$(find_src_files $_gen_file_list_unneeded | tr '\n' ' ')
508 printf '%s\n' "$_gen_file_list_contents"
520 # non-collision avoidance that the other variables do is that we *do* want
547 # non-collision avoidance that the other variables do is that we *do* want
609 CFLAGS="-Weverything -Wno-padded -Wno-unsafe-buffer-usage -Wno-poison-system-directories"
610 CFLAGS="$CFLAGS -Wno-unknown-warning-option -Wno-switch-default -Wno-pre-c11-compat"
611 CFLAGS="$CFLAGS -Werror -pedantic -std=c11"
640 CFLAGS="-Weverything -Wno-padded -Wno-unsafe-buffer-usage -Wno-poison-system-directories"
641 CFLAGS="$CFLAGS -Wno-unknown-warning-option -Wno-switch-default -Wno-pre-c11-compat"
642 CFLAGS="$CFLAGS -Werror -pedantic -std=c11"
714 while getopts "abBcdDeEfgGhHik:lMNO:p:PrS:s:T-" opt; do
734 N) nls=0 ;;
742 -)
744 arg="${arg#--}"
749 bc-only) bc_only=1 ;;
750 dc-only) dc_only=1 ;;
755 if [ "$#" -lt 2 ]; then
756 usage "No argument given for '--$arg' option"
762 if [ "$#" -lt 2 ]; then
763 usage "No argument given for '--$arg' option"
769 if [ "$#" -lt 2 ]; then
770 usage "No argument given for '--$arg' option"
776 if [ "$#" -lt 2 ]; then
777 usage "No argument given for '--$arg' option"
783 if [ "$#" -lt 2 ]; then
784 usage "No argument given for '--$arg' option"
790 if [ "$#" -lt 2 ]; then
791 usage "No argument given for '--$arg' option"
797 if [ "$#" -lt 2 ]; then
798 usage "No argument given for '--$arg' option"
804 if [ "$#" -lt 2 ]; then
805 usage "No argument given for '--$arg' option"
811 if [ "$#" -lt 2 ]; then
812 usage "No argument given for '--$arg' option"
816 karatsuba-len=?*) karatsuba_len="$LONG_OPTARG" ;;
817 karatsuba-len)
818 if [ "$#" -lt 2 ]; then
819 usage "No argument given for '--$arg' option"
825 if [ "$#" -lt 2 ]; then
826 usage "No argument given for '--$arg' option"
830 set-default-on=?*) set_default 1 "$LONG_OPTARG" ;;
831 set-default-on)
832 if [ "$#" -lt 2 ]; then
833 usage "No argument given for '--$arg' option"
837 set-default-off=?*) set_default 0 "$LONG_OPTARG" ;;
838 set-default-off)
839 if [ "$#" -lt 2 ]; then
840 usage "No argument given for '--$arg' option"
844 predefined-build-type=?*) predefined_build "$LONG_OPTARG" ;;
845 predefined-build-type)
846 if [ "$#" -lt 2 ]; then
847 usage "No argument given for '--$arg' option"
851 disable-bc) dc_only=1 ;;
852 disable-dc) bc_only=1 ;;
853 disable-clean) clean=0 ;;
854 disable-extra-math) extra_math=0 ;;
855 disable-generated-tests) generate_tests=0 ;;
856 disable-history) hist=0 ;;
857 disable-man-pages) install_manpages=0 ;;
858 disable-nls) nls=0 ;;
859 disable-strip) strip_bin=0 ;;
860 disable-problematic-tests) problematic_tests=0 ;;
861 enable-editline) hist_impl="editline" ;;
862 enable-readline) hist_impl="readline" ;;
863 enable-internal-history) hist_impl="internal" ;;
864 install-all-locales) all_locales=1 ;;
865 help* | bc-only* | dc-only* | debug*)
866 usage "No arg allowed for --$arg option" ;;
867 disable-bc* | disable-dc* | disable-clean*)
868 usage "No arg allowed for --$arg option" ;;
869 disable-extra-math*)
870 usage "No arg allowed for --$arg option" ;;
871 disable-history*)
872 usage "No arg allowed for --$arg option" ;;
873 disable-man-pages* | disable-nls* | disable-strip*)
874 usage "No arg allowed for --$arg option" ;;
875 disable-problematic-tests*)
876 usage "No arg allowed for --$arg option" ;;
877 install-all-locales*)
878 usage "No arg allowed for --$arg option" ;;
879 enable-editline* | enable-readline*)
880 usage "No arg allowed for --$arg option" ;;
881 enable-internal-history*)
882 usage "No arg allowed for --$arg option" ;;
883 '') break ;; # "--" terminates argument processing
895 if [ "$clean" -ne 0 ]; then
896 if [ -f ./Makefile ]; then
902 if [ "$bc_only" -eq 1 ] && [ "$dc_only" -eq 1 ]; then
903 usage "Can only specify one of -b(-D) or -d(-B)"
908 if [ "$library" -ne 0 ]; then
909 if [ "$bc_only" -eq 1 ] || [ "$dc_only" -eq 1 ]; then
910 usage "Must not specify -b(-D) or -d(-B) when building the library"
916 (*[!0-9]*|'') usage "KARATSUBA_LEN is not a number" ;;
920 if [ "$karatsuba_len" -lt 16 ]; then
924 set -e
926 if [ -z "${LONG_BIT+set}" ]; then
928 elif [ "$LONG_BIT" -lt 32 ]; then
931 LONG_BIT_DEFINE="-DBC_LONG_BIT=$LONG_BIT"
934 if [ -z "$CC" ]; then
960 if [ -z "$HOSTCC" ] && [ -z "$HOST_CC" ]; then
962 elif [ -z "$HOSTCC" ]; then
987 if [ -z "${HOSTCFLAGS+set}" ] && [ -z "${HOST_CFLAGS+set}" ]; then
989 elif [ -z "${HOSTCFLAGS+set}" ]; then
997 link="@printf 'No link necessary\\\\n'"
1001 karatsuba="@printf 'karatsuba cannot be run because one of bc or dc is not built\\\\n'"
1008 default_target_cmd="\$(CC) \$(CFLAGS) \$(OBJS) \$(LDFLAGS) -o \$(EXEC)"
1017 if [ "$library" -ne 0 ]; then
1026 default_target_cmd="ar -r -cu \$(LIBBC) \$(OBJ)"
1034 elif [ "$bc_only" -eq 1 ]; then
1051 elif [ "$dc_only" -eq 1 ]; then
1078 if [ "$library" -eq 0 ]; then
1097 if [ "$debug" -eq 1 ]; then
1099 if [ -z "$CFLAGS" ] && [ -z "$optimization" ]; then
1100 CFLAGS="-O0"
1103 CFLAGS="-g $CFLAGS"
1106 CPPFLAGS="-DNDEBUG $CPPFLAGS"
1110 if [ -n "$optimization" ]; then
1111 CFLAGS="-O$optimization $CFLAGS"
1115 if [ -z "${DESTDIR+set}" ]; then
1122 if [ -z "${PREFIX+set}" ]; then
1129 if [ -z "${BINDIR+set}" ]; then
1133 if [ -z "${INCLUDEDIR+set}" ]; then
1137 if [ -z "${LIBDIR+set}" ]; then
1141 if [ -z "${PC_PATH+set}" ]; then
1145 command -v pkg-config > /dev/null
1148 set -e
1150 if [ "$err" -eq 0 ]; then
1151 PC_PATH=$(pkg-config --variable=pc_path pkg-config)
1162 if [ "$install_manpages" -ne 0 ] || [ "$nls" -ne 0 ]; then
1163 if [ -z "${DATAROOTDIR+set}" ]; then
1169 if [ "$install_manpages" -ne 0 ]; then
1171 if [ -z "${DATADIR+set}" ]; then
1175 if [ -z "${MANDIR+set}" ]; then
1179 if [ -z "${MAN1DIR+set}" ]; then
1183 if [ -z "${MAN3DIR+set}" ]; then
1195 if [ "$nls" -ne 0 ]; then
1199 printf 'Testing NLS...\n'
1201 flags="-DBC_ENABLE_NLS=1 -DBC_ENABLED=$bc -DDC_ENABLED=$dc"
1202 flags="$flags -DBC_ENABLE_HISTORY=$hist -DBC_ENABLE_LIBRARY=0 -DBC_ENABLE_AFL=0"
1203 flags="$flags -DBC_ENABLE_EXTRA_MATH=$extra_math -DBC_ENABLE_OSSFUZZ=0"
1204 flags="$flags -I$scriptdir/include/ -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
1209 flags="$flags -Wno-unreachable-code"
1212 "$CC" $CPPFLAGS $CFLAGS $flags -c "$scriptdir/src/vm.c" -E > /dev/null
1216 rm -rf "./vm.o"
1220 if [ "$err" -ne 0 ]; then
1221 printf 'NLS does not work.\n'
1222 if [ $force -eq 0 ]; then
1223 printf 'Disabling NLS...\n\n'
1226 printf 'Forcing NLS...\n\n'
1229 printf 'NLS works.\n\n'
1231 printf 'Testing gencat...\n'
1236 rm -rf "./en_US.cat"
1238 if [ "$err" -ne 0 ]; then
1239 printf 'gencat does not work.\n'
1240 if [ $force -eq 0 ]; then
1241 printf 'Disabling NLS...\n\n'
1244 printf 'Forcing NLS...\n\n'
1248 printf 'gencat works.\n\n'
1254 printf 'Cross-compile detected.\n\n'
1255 printf 'WARNING: Catalog files generated with gencat may not be portable\n'
1256 printf ' across different architectures.\n\n'
1259 if [ -z "$NLSPATH" ]; then
1260 NLSPATH="/usr/share/locale/%L/%N"
1270 set -e
1278 if [ "$nls" -ne 0 ] && [ "$all_locales" -ne 0 ]; then
1279 install_locales="\$(LOCALE_INSTALL) -l \$(NLSPATH) \$(MAIN_EXEC) \$(DESTDIR)"
1285 if [ "$hist" -eq 1 ]; then
1300 printf 'Testing history...\n'
1302 flags="-DBC_ENABLE_HISTORY=1 -DBC_ENABLED=$bc -DDC_ENABLED=$dc"
1303 flags="$flags -DBC_ENABLE_NLS=$nls -DBC_ENABLE_LIBRARY=0 -DBC_ENABLE_AFL=0"
1304 flags="$flags -DBC_ENABLE_EDITLINE=$editline -DBC_ENABLE_READLINE=$readline"
1305 flags="$flags -DBC_ENABLE_EXTRA_MATH=$extra_math -DBC_ENABLE_OSSFUZZ=0"
1306 flags="$flags -I$scriptdir/include/ -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
1308 "$CC" $CPPFLAGS $CFLAGS $flags -c "$scriptdir/src/history.c" -E > /dev/null
1312 rm -rf "./history.o"
1316 if [ "$err" -ne 0 ]; then
1317 printf 'History does not work.\n'
1318 if [ $force -eq 0 ]; then
1319 printf 'Disabling history...\n\n'
1322 printf 'Forcing history...\n\n'
1325 printf 'History works.\n\n'
1328 set -e
1337 if [ "$hist" -eq 0 ]; then
1338 CFLAGS="$CFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=0"
1342 if [ "$editline" -ne 0 ]; then
1343 LDFLAGS="$LDFLAGS -ledit"
1344 CPPFLAGS="$CPPFLAGS -DBC_ENABLE_EDITLINE=1 -DBC_ENABLE_READLINE=0"
1345 elif [ "$readline" -ne 0 ]; then
1346 LDFLAGS="$LDFLAGS -lreadline"
1347 CPPFLAGS="$CPPFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=1"
1349 CPPFLAGS="$CPPFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=0"
1359 printf 'Testing for FreeBSD...\n'
1361 flags="-DBC_TEST_FREEBSD -DBC_ENABLE_AFL=0"
1362 "$CC" $CPPFLAGS $CFLAGS $flags "-I$scriptdir/include" -E "$scriptdir/scripts/os.c" > /dev/null
1366 if [ "$err" -ne 0 ]; then
1367 printf 'On FreeBSD. Not using _POSIX_C_SOURCE and _XOPEN_SOURCE.\n\n'
1369 printf 'Not on FreeBSD. Using _POSIX_C_SOURCE and _XOPEN_SOURCE.\n\n'
1370 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700"
1376 printf 'Testing for macOS...\n'
1378 flags="-DBC_TEST_APPLE -DBC_ENABLE_AFL=0"
1379 "$CC" $CPPFLAGS $CFLAGS $flags "-I$scriptdir/include" -E "$scriptdir/scripts/os.c" > /dev/null
1383 if [ "$err" -ne 0 ]; then
1384 printf 'On macOS. Using _DARWIN_C_SOURCE.\n\n'
1385 apple="-D_DARWIN_C_SOURCE"
1387 printf 'Not on macOS.\n\n'
1392 if [ "$debug" -eq 0 ] && [ "$apple" = "" ] && [ "$strip_bin" -ne 0 ]; then
1393 LDFLAGS="-s $LDFLAGS"
1400 # have to check at configure time and set it on the compiler command-line. And
1404 printf 'Testing for OpenBSD...\n'
1406 flags="-DBC_TEST_OPENBSD -DBC_ENABLE_AFL=0"
1407 "$CC" $CPPFLAGS $CFLAGS $flags "-I$scriptdir/include" -E "$scriptdir/scripts/os.c" > /dev/null
1411 if [ "$err" -ne 0 ]; then
1413 printf 'On OpenBSD. Using _BSD_SOURCE.\n\n'
1414 bsd="-D_BSD_SOURCE"
1417 if [ "$readline" -ne 0 ]; then
1422 printf 'Not on OpenBSD.\n\n'
1426 set -e
1428 if [ "$library" -eq 1 ]; then
1432 if [ "$extra_math" -eq 1 ] && [ "$bc" -ne 0 ] && [ "$library" -eq 0 ]; then
1443 GEN_EXEC_TARGET="\$(HOSTCC) -DBC_ENABLE_AFL=0 -DBC_ENABLE_OSSFUZZ=0 -I$scriptdir/include/ \$(HOSTCF…
1446 if [ -z "${GEN_HOST+set}" ]; then
1449 if [ "$GEN_HOST" -eq 0 ]; then
1451 GEN_EXEC_TARGET="@printf 'Do not need to build gen/strgen.c\\\\n'"
1461 if [ "$extra_math" -eq 0 ]; then
1473 if [ "$hist" -eq 0 ]; then
1480 if [ "$nls" -eq 0 ]; then
1481 manpage_args="${manpage_args}N"
1484 if [ "$bc" -eq 0 ]; then
1490 if [ "$dc" -eq 0 ]; then
1496 version=$(cat "$scriptdir/VERSION.txt" | head -n1)
1498 if [ "$library" -ne 0 ]; then
1514 printf '%s\n' "$contents" > "$scriptdir/bcl.pc"
1517 pkg_config_uninstall="\$(RM) -f \"\$(DESTDIR)\$(PC_PATH)/\$(BCL_PC)\""
1555 printf 'unneeded: %s\n' "$unneeded"
1558 printf 'Version: %s\n' "$version"
1560 if [ "$bc" -ne 0 ]; then
1561 printf 'Building bc\n'
1563 printf 'Not building bc\n'
1565 if [ "$dc" -ne 0 ]; then
1566 printf 'Building dc\n'
1568 printf 'Not building dc\n'
1570 printf '\n'
1571 printf 'BC_ENABLE_LIBRARY=%s\n\n' "$library"
1572 printf 'BC_ENABLE_HISTORY=%s\n' "$hist"
1573 printf 'BC_ENABLE_EXTRA_MATH=%s\n' "$extra_math"
1574 printf 'BC_ENABLE_NLS=%s\n\n' "$nls"
1575 printf '\n'
1576 printf 'BC_NUM_KARATSUBA_LEN=%s\n' "$karatsuba_len"
1577 printf '\n'
1578 printf 'CC=%s\n' "$CC"
1579 printf 'CFLAGS=%s\n' "$CFLAGS"
1580 printf 'HOSTCC=%s\n' "$HOSTCC"
1581 printf 'HOSTCFLAGS=%s\n' "$HOSTCFLAGS"
1582 printf 'CPPFLAGS=%s\n' "$CPPFLAGS"
1583 printf 'LDFLAGS=%s\n' "$LDFLAGS"
1584 printf 'PREFIX=%s\n' "$PREFIX"
1585 printf 'BINDIR=%s\n' "$BINDIR"
1586 printf 'INCLUDEDIR=%s\n' "$INCLUDEDIR"
1587 printf 'LIBDIR=%s\n' "$LIBDIR"
1588 printf 'DATAROOTDIR=%s\n' "$DATAROOTDIR"
1589 printf 'DATADIR=%s\n' "$DATADIR"
1590 printf 'MANDIR=%s\n' "$MANDIR"
1591 printf 'MAN1DIR=%s\n' "$MAN1DIR"
1592 printf 'MAN3DIR=%s\n' "$MAN3DIR"
1593 printf 'NLSPATH=%s\n' "$NLSPATH"
1594 printf 'PC_PATH=%s\n' "$PC_PATH"
1595 printf 'EXECSUFFIX=%s\n' "$EXECSUFFIX"
1596 printf 'EXECPREFIX=%s\n' "$EXECPREFIX"
1597 printf 'DESTDIR=%s\n' "$DESTDIR"
1598 printf 'LONG_BIT=%s\n' "$LONG_BIT"
1599 printf 'GEN_HOST=%s\n' "$GEN_HOST"
1600 printf 'GEN_EMU=%s\n' "$GEN_EMU"
1601 printf '\n'
1602 printf 'Setting Defaults\n'
1603 printf '================\n'
1604 printf 'bc.banner=%s\n' "$bc_default_banner"
1605 printf 'bc.sigint_reset=%s\n' "$bc_default_sigint_reset"
1606 printf 'dc.sigint_reset=%s\n' "$dc_default_sigint_reset"
1607 printf 'bc.tty_mode=%s\n' "$bc_default_tty_mode"
1608 printf 'dc.tty_mode=%s\n' "$dc_default_tty_mode"
1609 printf 'bc.prompt=%s\n' "$bc_default_prompt"
1610 printf 'dc.prompt=%s\n' "$dc_default_prompt"
1611 printf 'bc.expr_exit=%s\n' "$bc_default_expr_exit"
1612 printf 'dc.expr_exit=%s\n' "$dc_default_expr_exit"
1613 printf 'bc.digit_clamp=%s\n' "$bc_default_digit_clamp"
1614 printf 'dc.digit_clamp=%s\n' "$dc_default_digit_clamp"
1621 if [ "$nls" -ne 0 ] && [ "${NLSPATH#$PREFIX}" = "${NLSPATH}" ] && [ "$defprefix" -eq 0 ]; then
1622 printf '\n********************************************************************************\n\n'
1623 printf 'WARNING: Locales will *NOT* be installed in $PREFIX (%s).\n' "$PREFIX"
1624 printf '\n'
1625 printf ' This is because they *MUST* be installed at a fixed location to even\n'
1626 printf ' work, and that fixed location is $NLSPATH (%s).\n' "$NLSPATH"
1627 printf '\n'
1628 printf ' This location is *outside* of $PREFIX. If you do not wish to install\n'
1629 printf ' locales outside of $PREFIX, you must disable NLS with the -N or the\n'
1630 printf ' --disable-nls options.\n'
1631 printf '\n'
1632 printf ' The author apologizes for the inconvenience, but the need to install\n'
1633 printf ' the locales at a fixed location is mandated by POSIX, and it is not\n'
1634 printf ' possible for the author to change that requirement.\n'
1635 printf '\n********************************************************************************\n'
1661 SRC_TARGETS=$(printf '%s\n\nsrc/%s: src %s %s\n\t$(CC) $(CFLAGS) -o src/%s -c %s\n' \
1763 printf '%s\n%s\n\n' "$contents" "$SRC_TARGETS" > "Makefile"
1766 mkdir -p manuals
1767 cp -f "$scriptdir/manuals/bc/$manpage_args.1.md" manuals/bc.1.md
1768 cp -f "$scriptdir/manuals/bc/$manpage_args.1" manuals/bc.1
1769 cp -f "$scriptdir/manuals/dc/$manpage_args.1.md" manuals/dc.1.md
1770 cp -f "$scriptdir/manuals/dc/$manpage_args.1" manuals/dc.1