xref: /freebsd/contrib/bc/Makefile.in (revision 0197ba465f275a32975d5c93b811e7caaec5b438)
1#
2# SPDX-License-Identifier: BSD-2-Clause
3#
4# Copyright (c) 2018-2021 Gavin D. Howard and contributors.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are met:
8#
9# * Redistributions of source code must retain the above copyright notice, this
10#   list of conditions and the following disclaimer.
11#
12# * Redistributions in binary form must reproduce the above copyright notice,
13#   this list of conditions and the following disclaimer in the documentation
14#   and/or other materials provided with the distribution.
15#
16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26# POSSIBILITY OF SUCH DAMAGE.
27#
28# %%WARNING%%
29#
30.POSIX:
31
32ROOTDIR = %%ROOTDIR%%
33INCDIR = $(ROOTDIR)/include
34SRCDIR = $(ROOTDIR)/src
35TESTSDIR = $(ROOTDIR)/tests
36SCRIPTSDIR = $(ROOTDIR)/scripts
37GENDIR = $(ROOTDIR)/gen
38
39BUILDDIR = %%BUILDDIR%%
40
41SRC = %%SRC%%
42OBJ = %%OBJ%%
43GCDA = %%GCDA%%
44GCNO = %%GCNO%%
45
46BC_ENABLED_NAME = BC_ENABLED
47BC_ENABLED = %%BC_ENABLED%%
48DC_ENABLED_NAME = DC_ENABLED
49DC_ENABLED = %%DC_ENABLED%%
50
51HEADERS = $(INCDIR)/args.h $(INCDIR)/file.h $(INCDIR)/lang.h $(INCDIR)/lex.h $(INCDIR)/num.h $(INCDIR)/opt.h $(INCDIR)/parse.h $(INCDIR)/program.h $(INCDIR)/read.h $(INCDIR)/status.h $(INCDIR)/vector.h $(INCDIR)/vm.h
52BC_HEADERS = $(INCDIR)/bc.h
53DC_HEADERS = $(INCDIR)/dc.h
54HISTORY_HEADERS = $(INCDIR)/history.h
55EXTRA_MATH_HEADERS = $(INCDIR)/rand.h
56LIBRARY_HEADERS = $(INCDIR)/bcl.h $(INCDIR)/library.h
57
58GEN_DIR = gen
59GEN = %%GEN%%
60GEN_EXEC = $(GEN_DIR)/$(GEN)
61GEN_C = $(GENDIR)/$(GEN).c
62
63GEN_EMU = %%GEN_EMU%%
64
65BC_LIB = $(GENDIR)/lib.bc
66BC_LIB_C = $(GEN_DIR)/lib.c
67BC_LIB_O = %%BC_LIB_O%%
68BC_LIB_GCDA = $(GEN_DIR)/lib.gcda
69BC_LIB_GCNO = $(GEN_DIR)/lib.gcno
70
71BC_LIB2 = $(GENDIR)/lib2.bc
72BC_LIB2_C = $(GEN_DIR)/lib2.c
73BC_LIB2_O = %%BC_LIB2_O%%
74BC_LIB2_GCDA = $(GEN_DIR)/lib2.gcda
75BC_LIB2_GCNO = $(GEN_DIR)/lib2.gcno
76
77BC_HELP = $(GENDIR)/bc_help.txt
78BC_HELP_C = $(GEN_DIR)/bc_help.c
79BC_HELP_O = %%BC_HELP_O%%
80BC_HELP_GCDA = $(GEN_DIR)/bc_help.gcda
81BC_HELP_GCNO = $(GEN_DIR)/bc_help.gcno
82
83DC_HELP = $(GENDIR)/dc_help.txt
84DC_HELP_C = $(GEN_DIR)/dc_help.c
85DC_HELP_O = %%DC_HELP_O%%
86DC_HELP_GCDA = $(GEN_DIR)/dc_help.gcda
87DC_HELP_GCNO = $(GEN_DIR)/dc_help.gcno
88
89BIN = bin
90EXEC_SUFFIX = %%EXECSUFFIX%%
91EXEC_PREFIX = %%EXECPREFIX%%
92
93BC = bc
94DC = dc
95BC_EXEC = $(BIN)/$(EXEC_PREFIX)$(BC)
96DC_EXEC = $(BIN)/$(EXEC_PREFIX)$(DC)
97
98BC_TEST_OUTPUTS = tests/bc_outputs
99BC_FUZZ_OUTPUTS = tests/fuzzing/bc_outputs1 tests/fuzzing/bc_outputs2 tests/fuzzing/bc_outputs3
100DC_TEST_OUTPUTS = tests/dc_outputs
101DC_FUZZ_OUTPUTS = tests/fuzzing/dc_outputs
102
103LIB = libbcl
104LIB_NAME = $(LIB).a
105LIBBC = $(BIN)/$(LIB_NAME)
106BCL = bcl
107BCL_TEST = $(BIN)/$(BCL)
108BCL_TEST_C = $(TESTSDIR)/$(BCL).c
109
110MANUALS = manuals
111BC_MANPAGE_NAME = $(EXEC_PREFIX)$(BC)$(EXEC_SUFFIX).1
112BC_MANPAGE = $(MANUALS)/$(BC).1
113BC_MD = $(BC_MANPAGE).md
114DC_MANPAGE_NAME = $(EXEC_PREFIX)$(DC)$(EXEC_SUFFIX).1
115DC_MANPAGE = $(MANUALS)/$(DC).1
116DC_MD = $(DC_MANPAGE).md
117BCL_MANPAGE_NAME = bcl.3
118BCL_MANPAGE = $(MANUALS)/$(BCL_MANPAGE_NAME)
119BCL_MD = $(BCL_MANPAGE).md
120
121MANPAGE_INSTALL_ARGS = -Dm644
122BINARY_INSTALL_ARGS = -Dm755
123PC_INSTALL_ARGS = $(MANPAGE_INSTALL_ARGS)
124
125BCL_PC = $(BCL).pc
126PC_PATH = %%PC_PATH%%
127
128BCL_HEADER_NAME = bcl.h
129BCL_HEADER = $(INCDIR)/$(BCL_HEADER_NAME)
130
131%%DESTDIR%%
132BINDIR = %%BINDIR%%
133INCLUDEDIR = %%INCLUDEDIR%%
134LIBDIR = %%LIBDIR%%
135MAN1DIR = %%MAN1DIR%%
136MAN3DIR = %%MAN3DIR%%
137MAIN_EXEC = $(EXEC_PREFIX)$(%%MAIN_EXEC%%)$(EXEC_SUFFIX)
138EXEC = $(%%EXEC%%)
139NLSPATH = %%NLSPATH%%
140
141BC_BUILD_TYPE = %%BUILD_TYPE%%
142
143BC_ENABLE_LIBRARY = %%LIBRARY%%
144
145BC_ENABLE_HISTORY = %%HISTORY%%
146BC_ENABLE_EXTRA_MATH_NAME = BC_ENABLE_EXTRA_MATH
147BC_ENABLE_EXTRA_MATH = %%EXTRA_MATH%%
148BC_ENABLE_NLS = %%NLS%%
149BC_LONG_BIT = %%LONG_BIT%%
150
151BC_ENABLE_AFL = %%FUZZ%%
152BC_ENABLE_MEMCHECK = %%MEMCHECK%%
153
154BC_DEFAULT_BANNER = %%BC_DEFAULT_BANNER%%
155BC_DEFAULT_SIGINT_RESET = %%BC_DEFAULT_SIGINT_RESET%%
156DC_DEFAULT_SIGINT_RESET = %%DC_DEFAULT_SIGINT_RESET%%
157BC_DEFAULT_TTY_MODE = %%BC_DEFAULT_TTY_MODE%%
158DC_DEFAULT_TTY_MODE = %%DC_DEFAULT_TTY_MODE%%
159BC_DEFAULT_PROMPT = %%BC_DEFAULT_PROMPT%%
160DC_DEFAULT_PROMPT = %%DC_DEFAULT_PROMPT%%
161BC_DEFAULT_EXPR_EXIT = %%BC_DEFAULT_EXPR_EXIT%%
162DC_DEFAULT_EXPR_EXIT = %%DC_DEFAULT_EXPR_EXIT%%
163
164RM = rm
165MKDIR = mkdir
166
167SCRIPTS = ./scripts
168
169MINISTAT = ministat
170MINISTAT_EXEC = $(SCRIPTS)/$(MINISTAT)
171
172BITFUNCGEN = bitfuncgen
173BITFUNCGEN_EXEC = $(SCRIPTS)/$(BITFUNCGEN)
174
175INSTALL = $(SCRIPTSDIR)/exec-install.sh
176SAFE_INSTALL = $(SCRIPTSDIR)/safe-install.sh
177LINK = $(SCRIPTSDIR)/link.sh
178MANPAGE = $(SCRIPTSDIR)/manpage.sh
179KARATSUBA = $(SCRIPTSDIR)/karatsuba.py
180LOCALE_INSTALL = $(SCRIPTSDIR)/locale_install.sh
181LOCALE_UNINSTALL = $(SCRIPTSDIR)/locale_uninstall.sh
182
183VALGRIND_ARGS = --error-exitcode=100 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all
184
185TEST_STARS = ***********************************************************************
186
187BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%%
188
189BC_DEFS0 = -DBC_DEFAULT_BANNER=$(BC_DEFAULT_BANNER)
190BC_DEFS1 = -DBC_DEFAULT_SIGINT_RESET=$(BC_DEFAULT_SIGINT_RESET)
191BC_DEFS2 = -DBC_DEFAULT_TTY_MODE=$(BC_DEFAULT_TTY_MODE)
192BC_DEFS3 = -DBC_DEFAULT_PROMPT=$(BC_DEFAULT_PROMPT)
193BC_DEFS4 = -DBC_DEFAULT_EXPR_EXIT=$(BC_DEFAULT_EXPR_EXIT)
194BC_DEFS = $(BC_DEFS0) $(BC_DEFS1) $(BC_DEFS2) $(BC_DEFS3) $(BC_DEFS4)
195DC_DEFS1 = -DDC_DEFAULT_SIGINT_RESET=$(DC_DEFAULT_SIGINT_RESET)
196DC_DEFS2 = -DDC_DEFAULT_TTY_MODE=$(DC_DEFAULT_TTY_MODE)
197DC_DEFS3 = -DDC_DEFAULT_PROMPT=$(DC_DEFAULT_PROMPT)
198DC_DEFS4 = -DDC_DEFAULT_EXPR_EXIT=$(DC_DEFAULT_EXPR_EXIT)
199DC_DEFS = $(DC_DEFS1) $(DC_DEFS2) $(DC_DEFS3) $(DC_DEFS4)
200
201CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED)
202CPPFLAGS2 = $(CPPFLAGS1) -I$(INCDIR)/ -DBUILD_TYPE=$(BC_BUILD_TYPE) %%LONG_BIT_DEFINE%%
203CPPFLAGS3 = $(CPPFLAGS2) -DEXECPREFIX=$(EXEC_PREFIX) -DMAINEXEC=$(MAIN_EXEC)
204CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 %%BSD%%
205CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN)
206CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS)
207CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH)
208CPPFLAGS8 = $(CPPFLAGS7) -DBC_ENABLE_HISTORY=$(BC_ENABLE_HISTORY) -DBC_ENABLE_LIBRARY=$(BC_ENABLE_LIBRARY)
209CPPFLAGS = $(CPPFLAGS8) -DBC_ENABLE_MEMCHECK=$(BC_ENABLE_MEMCHECK) -DBC_ENABLE_AFL=$(BC_ENABLE_AFL)
210CFLAGS = $(CPPFLAGS) $(BC_DEFS) $(DC_DEFS) %%CPPFLAGS%% %%CFLAGS%%
211LDFLAGS = %%LDFLAGS%%
212
213HOSTCFLAGS = %%HOSTCFLAGS%%
214
215CC = %%CC%%
216HOSTCC = %%HOSTCC%%
217
218BC_LIB_C_ARGS = bc_lib bc_lib_name $(BC_ENABLED_NAME) 1
219BC_LIB2_C_ARGS = bc_lib2 bc_lib2_name "$(BC_ENABLED_NAME) && $(BC_ENABLE_EXTRA_MATH_NAME)" 1
220
221OBJS = $(DC_HELP_O) $(BC_HELP_O) $(BC_LIB_O) $(BC_LIB2_O) $(OBJ)
222
223all: %%DEFAULT_TARGET%%
224
225%%DEFAULT_TARGET%%: %%DEFAULT_TARGET_PREREQS%%
226	%%DEFAULT_TARGET_CMD%%
227
228%%SECOND_TARGET%%: %%SECOND_TARGET_PREREQS%%
229	%%SECOND_TARGET_CMD%%
230
231$(GEN_DIR):
232	mkdir -p $(GEN_DIR)
233
234$(GEN_EXEC): $(GEN_DIR)
235	%%GEN_EXEC_TARGET%%
236
237$(BC_LIB_C): $(GEN_EXEC) $(BC_LIB)
238	$(GEN_EMU) $(GEN_EXEC) $(BC_LIB) $(BC_LIB_C) $(BC_LIB_C_ARGS)
239
240$(BC_LIB_O): $(BC_LIB_C)
241	$(CC) $(CFLAGS) -o $@ -c $<
242
243$(BC_LIB2_C): $(GEN_EXEC) $(BC_LIB2)
244	$(GEN_EMU) $(GEN_EXEC) $(BC_LIB2) $(BC_LIB2_C) $(BC_LIB2_C_ARGS)
245
246$(BC_LIB2_O): $(BC_LIB2_C)
247	$(CC) $(CFLAGS) -o $@ -c $<
248
249$(BC_HELP_C): $(GEN_EXEC) $(BC_HELP)
250	$(GEN_EMU) $(GEN_EXEC) $(BC_HELP) $(BC_HELP_C) bc_help "" $(BC_ENABLED_NAME)
251
252$(BC_HELP_O): $(BC_HELP_C)
253	$(CC) $(CFLAGS) -o $@ -c $<
254
255$(DC_HELP_C): $(GEN_EXEC) $(DC_HELP)
256	$(GEN_EMU) $(GEN_EXEC) $(DC_HELP) $(DC_HELP_C) dc_help "" $(DC_ENABLED_NAME)
257
258$(DC_HELP_O): $(DC_HELP_C)
259	$(CC) $(CFLAGS) -o $@ -c $<
260
261$(BIN):
262	$(MKDIR) -p $(BIN)
263
264src:
265	$(MKDIR) -p src
266
267headers: %%HEADERS%%
268
269$(MINISTAT):
270	mkdir -p $(SCRIPTS)
271	$(HOSTCC) $(HOSTCFLAGS) -lm -o $(MINISTAT_EXEC) $(ROOTDIR)/scripts/ministat.c
272
273$(BITFUNCGEN):
274	mkdir -p $(SCRIPTS)
275	$(HOSTCC) $(HOSTCFLAGS) -lm -o $(BITFUNCGEN_EXEC) $(ROOTDIR)/scripts/bitfuncgen.c
276
277help:
278	@printf 'available targets:\n'
279	@printf '\n'
280	@printf '    all (default)   builds %%EXECUTABLES%%\n'
281	@printf '    check           alias for `make test`\n'
282	@printf '    clean           removes all build files\n'
283	@printf '    clean_config    removes all build files as well as the generated Makefile\n'
284	@printf '    clean_tests     removes all build files, the generated Makefile,\n'
285	@printf '                    and generated tests\n'
286	@printf '    install         installs binaries to "%s%s"\n' "$(DESTDIR)" "$(BINDIR)"
287	@printf '                    and (if enabled) manpages to "%s%s"\n' "$(DESTDIR)" "$(MAN1DIR)"
288	@printf '    karatsuba       runs the karatsuba script (requires Python 3)\n'
289	@printf '    karatsuba_test  runs the karatsuba script while running tests\n'
290	@printf '                    (requires Python 3)\n'
291	@printf '    uninstall       uninstalls binaries from "%s%s"\n' "$(DESTDIR)" "$(BINDIR)"
292	@printf '                    and (if enabled) manpages from "%s%s"\n' "$(DESTDIR)" "$(MAN1DIR)"
293	@printf '    test            runs the test suite\n'
294	@printf '    test_bc         runs the bc test suite, if bc has been built\n'
295	@printf '    test_dc         runs the dc test suite, if dc has been built\n'
296	@printf '    time_test       runs the test suite, displaying times for some things\n'
297	@printf '    time_test_bc    runs the bc test suite, displaying times for some things\n'
298	@printf '    time_test_dc    runs the dc test suite, displaying times for some things\n'
299	@printf '    timeconst       runs the test on the Linux timeconst.bc script,\n'
300	@printf '                    if it exists and bc has been built\n'
301	@printf '    valgrind        runs the test suite through valgrind\n'
302	@printf '    valgrind_bc     runs the bc test suite, if bc has been built,\n'
303	@printf '                    through valgrind\n'
304	@printf '    valgrind_dc     runs the dc test suite, if dc has been built,\n'
305	@printf '                    through valgrind\n'
306
307run_all_tests: bc_all_tests timeconst_all_tests dc_all_tests
308
309run_all_tests_np: bc_all_tests_np timeconst_all_tests dc_all_tests_np
310
311bc_all_tests:
312	%%BC_ALL_TESTS%%
313
314bc_all_tests_np:
315	%%BC_ALL_TESTS_NP%%
316
317timeconst_all_tests:
318	%%TIMECONST_ALL_TESTS%%
319
320dc_all_tests:
321	%%DC_ALL_TESTS%%
322
323dc_all_tests_np:
324	%%DC_ALL_TESTS_NP%%
325
326history_all_tests:
327	%%HISTORY_TESTS%%
328
329check: test
330
331test: %%TESTS%%
332
333test_bc: test_bc_header test_bc_tests test_bc_scripts test_bc_errors test_bc_stdin test_bc_read test_bc_other
334	@printf '\nAll bc tests passed.\n\n$(TEST_STARS)\n'
335
336test_bc_tests:%%BC_TESTS%%
337
338test_bc_scripts:%%BC_SCRIPT_TESTS%%
339
340test_bc_stdin:
341	@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/stdin.sh bc %%BC_TEST_EXEC%%
342
343test_bc_read:
344	@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/read.sh bc %%BC_TEST_EXEC%%
345
346test_bc_errors: test_bc_error_lines%%BC_ERROR_TESTS%%
347
348test_bc_error_lines:
349	@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/errors.sh bc %%BC_TEST_EXEC%%
350
351test_bc_other:
352	@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/other.sh bc $(BC_ENABLE_EXTRA_MATH) %%BC_TEST_EXEC%%
353
354test_bc_header:
355	@printf '$(TEST_STARS)\n\nRunning bc tests...\n\n'
356
357test_dc: test_dc_header test_dc_tests test_dc_scripts test_dc_errors test_dc_stdin test_dc_read test_dc_other
358	@printf '\nAll dc tests passed.\n\n$(TEST_STARS)\n'
359
360test_dc_tests:%%DC_TESTS%%
361
362test_dc_scripts:%%DC_SCRIPT_TESTS%%
363
364test_dc_stdin:
365	@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/stdin.sh dc %%DC_TEST_EXEC%%
366
367test_dc_read:
368	@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/read.sh dc %%DC_TEST_EXEC%%
369
370test_dc_errors: test_dc_error_lines%%DC_ERROR_TESTS%%
371
372test_dc_error_lines:
373	@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/errors.sh dc %%DC_TEST_EXEC%%
374
375test_dc_other:
376	@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/other.sh dc $(BC_ENABLE_EXTRA_MATH) %%DC_TEST_EXEC%%
377
378test_dc_header:
379	@printf '$(TEST_STARS)\n\nRunning dc tests...\n\n'
380
381timeconst:
382	%%TIMECONST%%
383
384test_history: test_history_header test_bc_history test_dc_history
385	@printf '\nAll history tests passed.\n\n$(TEST_STARS)\n'
386
387test_bc_history:%%BC_HISTORY_TEST_PREREQS%%
388
389test_bc_history_all: test_bc_history0 test_bc_history1 test_bc_history2 test_bc_history3 test_bc_history4 test_bc_history5 test_bc_history6 test_bc_history7 test_bc_history8 test_bc_history9 test_bc_history10 test_bc_history11 test_bc_history12 test_bc_history13 test_bc_history14 test_bc_history15 test_bc_history16 test_bc_history17 test_bc_history18 test_bc_history19 test_bc_history20 test_bc_history21
390
391test_bc_history_skip:
392	@printf 'No bc history tests to run\n'
393
394test_bc_history0:
395	@sh $(TESTSDIR)/history.sh bc 0 %%BC_TEST_EXEC%%
396
397test_bc_history1:
398	@sh $(TESTSDIR)/history.sh bc 1 %%BC_TEST_EXEC%%
399
400test_bc_history2:
401	@sh $(TESTSDIR)/history.sh bc 2 %%BC_TEST_EXEC%%
402
403test_bc_history3:
404	@sh $(TESTSDIR)/history.sh bc 3 %%BC_TEST_EXEC%%
405
406test_bc_history4:
407	@sh $(TESTSDIR)/history.sh bc 4 %%BC_TEST_EXEC%%
408
409test_bc_history5:
410	@sh $(TESTSDIR)/history.sh bc 5 %%BC_TEST_EXEC%%
411
412test_bc_history6:
413	@sh $(TESTSDIR)/history.sh bc 6 %%BC_TEST_EXEC%%
414
415test_bc_history7:
416	@sh $(TESTSDIR)/history.sh bc 7 %%BC_TEST_EXEC%%
417
418test_bc_history8:
419	@sh $(TESTSDIR)/history.sh bc 8 %%BC_TEST_EXEC%%
420
421test_bc_history9:
422	@sh $(TESTSDIR)/history.sh bc 9 %%BC_TEST_EXEC%%
423
424test_bc_history10:
425	@sh $(TESTSDIR)/history.sh bc 10 %%BC_TEST_EXEC%%
426
427test_bc_history11:
428	@sh $(TESTSDIR)/history.sh bc 11 %%BC_TEST_EXEC%%
429
430test_bc_history12:
431	@sh $(TESTSDIR)/history.sh bc 12 %%BC_TEST_EXEC%%
432
433test_bc_history13:
434	@sh $(TESTSDIR)/history.sh bc 13 %%BC_TEST_EXEC%%
435
436test_bc_history14:
437	@sh $(TESTSDIR)/history.sh bc 14 %%BC_TEST_EXEC%%
438
439test_bc_history15:
440	@sh $(TESTSDIR)/history.sh bc 15 %%BC_TEST_EXEC%%
441
442test_bc_history16:
443	@sh $(TESTSDIR)/history.sh bc 16 %%BC_TEST_EXEC%%
444
445test_bc_history17:
446	@sh $(TESTSDIR)/history.sh bc 17 %%BC_TEST_EXEC%%
447
448test_bc_history18:
449	@sh $(TESTSDIR)/history.sh bc 18 %%BC_TEST_EXEC%%
450
451test_bc_history19:
452	@sh $(TESTSDIR)/history.sh bc 19 %%BC_TEST_EXEC%%
453
454test_bc_history20:
455	@sh $(TESTSDIR)/history.sh bc 20 %%BC_TEST_EXEC%%
456
457test_bc_history21:
458	@sh $(TESTSDIR)/history.sh bc 21 %%BC_TEST_EXEC%%
459
460test_dc_history:%%DC_HISTORY_TEST_PREREQS%%
461
462test_dc_history_all: test_dc_history0 test_dc_history1 test_dc_history2 test_dc_history3 test_dc_history4 test_dc_history5 test_dc_history6 test_dc_history7 test_dc_history8 test_dc_history9 test_dc_history10
463
464test_dc_history_skip:
465	@printf 'No dc history tests to run\n'
466
467test_dc_history0:
468	@sh $(TESTSDIR)/history.sh dc 0 %%DC_TEST_EXEC%%
469
470test_dc_history1:
471	@sh $(TESTSDIR)/history.sh dc 1 %%DC_TEST_EXEC%%
472
473test_dc_history2:
474	@sh $(TESTSDIR)/history.sh dc 2 %%DC_TEST_EXEC%%
475
476test_dc_history3:
477	@sh $(TESTSDIR)/history.sh dc 3 %%DC_TEST_EXEC%%
478
479test_dc_history4:
480	@sh $(TESTSDIR)/history.sh dc 4 %%DC_TEST_EXEC%%
481
482test_dc_history5:
483	@sh $(TESTSDIR)/history.sh dc 5 %%DC_TEST_EXEC%%
484
485test_dc_history6:
486	@sh $(TESTSDIR)/history.sh dc 6 %%DC_TEST_EXEC%%
487
488test_dc_history7:
489	@sh $(TESTSDIR)/history.sh dc 7 %%DC_TEST_EXEC%%
490
491test_dc_history8:
492	@sh $(TESTSDIR)/history.sh dc 8 %%DC_TEST_EXEC%%
493
494test_dc_history9:
495	@sh $(TESTSDIR)/history.sh dc 9 %%DC_TEST_EXEC%%
496
497test_dc_history10:
498	@sh $(TESTSDIR)/history.sh dc 10 %%DC_TEST_EXEC%%
499
500test_history_header:
501	@printf '$(TEST_STARS)\n\nRunning history tests...\n\n'
502
503library_test: $(LIBBC)
504	$(CC) $(CFLAGS) $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST)
505
506test_library: library_test
507	$(BCL_TEST)
508
509karatsuba:
510	%%KARATSUBA%%
511
512karatsuba_test:
513	%%KARATSUBA_TEST%%
514
515coverage_output:
516	%%COVERAGE_OUTPUT%%
517
518coverage:%%COVERAGE_PREREQS%%
519
520manpages:
521	$(MANPAGE) bc
522	$(MANPAGE) dc
523	$(MANPAGE) bcl
524
525clean_gen:
526	@$(RM) -f $(GEN_EXEC)
527
528clean:%%CLEAN_PREREQS%%
529	@printf 'Cleaning files...\n'
530	@$(RM) -f src/*.tmp gen/*.tmp
531	@$(RM) -f $(OBJ)
532	@$(RM) -f $(BC_EXEC)
533	@$(RM) -f $(DC_EXEC)
534	@$(RM) -fr $(BIN)
535	@$(RM) -f $(BC_LIB_C) $(BC_LIB_O)
536	@$(RM) -f $(BC_LIB2_C) $(BC_LIB2_O)
537	@$(RM) -f $(BC_HELP_C) $(BC_HELP_O)
538	@$(RM) -f $(DC_HELP_C) $(DC_HELP_O)
539	@$(RM) -fr vs/bin/ vs/lib/
540
541clean_benchmarks:
542	@printf 'Cleaning benchmarks...\n'
543	@$(RM) -f $(MINISTAT_EXEC)
544	@$(RM) -f $(ROOTDIR)/benchmarks/bc/*.txt
545	@$(RM) -f $(ROOTDIR)/benchmarks/dc/*.txt
546
547clean_config: clean clean_benchmarks
548	@printf 'Cleaning config...\n'
549	@$(RM) -f Makefile
550	@$(RM) -f $(BC_MD) $(BC_MANPAGE)
551	@$(RM) -f $(DC_MD) $(DC_MANPAGE)
552
553clean_coverage:
554	@printf 'Cleaning coverage files...\n'
555	@$(RM) -f *.gcov
556	@$(RM) -f *.html
557	@$(RM) -f *.gcda *.gcno
558	@$(RM) -f *.profraw
559	@$(RM) -f $(GCDA) $(GCNO)
560	@$(RM) -f $(BC_GCDA) $(BC_GCNO)
561	@$(RM) -f $(DC_GCDA) $(DC_GCNO)
562	@$(RM) -f $(HISTORY_GCDA) $(HISTORY_GCNO)
563	@$(RM) -f $(RAND_GCDA) $(RAND_GCNO)
564	@$(RM) -f $(BC_LIB_GCDA) $(BC_LIB_GCNO)
565	@$(RM) -f $(BC_LIB2_GCDA) $(BC_LIB2_GCNO)
566	@$(RM) -f $(BC_HELP_GCDA) $(BC_HELP_GCNO)
567	@$(RM) -f $(DC_HELP_GCDA) $(DC_HELP_GCNO)
568
569clean_tests: clean clean_config clean_coverage
570	@printf 'Cleaning test files...\n'
571	@$(RM) -fr $(BC_TEST_OUTPUTS) $(DC_TEST_OUTPUTS)
572	@$(RM) -fr $(BC_FUZZ_OUTPUTS) $(DC_FUZZ_OUTPUTS)
573	@$(RM) -f $(TESTSDIR)/bc/parse.txt $(TESTSDIR)/bc/parse_results.txt
574	@$(RM) -f $(TESTSDIR)/bc/print.txt $(TESTSDIR)/bc/print_results.txt
575	@$(RM) -f $(TESTSDIR)/bc/bessel.txt $(TESTSDIR)/bc/bessel_results.txt
576	@$(RM) -f $(TESTSDIR)/bc/strings2.txt $(TESTSDIR)/bc/strings2_results.txt
577	@$(RM) -f $(TESTSDIR)/bc/scripts/bessel.txt
578	@$(RM) -f $(TESTSDIR)/bc/scripts/parse.txt
579	@$(RM) -f $(TESTSDIR)/bc/scripts/print.txt
580	@$(RM) -f $(TESTSDIR)/bc/scripts/add.txt
581	@$(RM) -f $(TESTSDIR)/bc/scripts/divide.txt
582	@$(RM) -f $(TESTSDIR)/bc/scripts/multiply.txt
583	@$(RM) -f $(TESTSDIR)/bc/scripts/subtract.txt
584	@$(RM) -f $(TESTSDIR)/bc/scripts/strings2.txt
585	@$(RM) -f $(TESTSDIR)/dc/scripts/prime.txt
586	@$(RM) -f .log_*.txt
587	@$(RM) -f .math.txt .results.txt .ops.txt
588	@$(RM) -f .test.txt
589	@$(RM) -f tags .gdbbreakpoints .gdb_history .gdbsetup
590	@$(RM) -f cscope.*
591	@$(RM) -f bc.old
592	@$(RM) -f $(BITFUNCGEN_EXEC)
593
594install_locales:
595	%%INSTALL_LOCALES%%
596
597install_bc_manpage:
598	$(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(BC_MANPAGE) $(DESTDIR)$(MAN1DIR)/$(BC_MANPAGE_NAME)
599
600install_dc_manpage:
601	$(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(DC_MANPAGE) $(DESTDIR)$(MAN1DIR)/$(DC_MANPAGE_NAME)
602
603install_bcl_manpage:
604	$(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(BCL_MANPAGE) $(DESTDIR)$(MAN3DIR)/$(BCL_MANPAGE_NAME)
605
606install_bcl_header:
607	$(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(BCL_HEADER) $(DESTDIR)$(INCLUDEDIR)/$(BCL_HEADER_NAME)
608
609install_execs:
610	$(INSTALL) $(DESTDIR)$(BINDIR) "$(EXEC_SUFFIX)" "$(BUILDDIR)/bin"
611
612install_library: install_bcl_header
613	$(SAFE_INSTALL) $(BINARY_INSTALL_ARGS) $(LIBBC) $(DESTDIR)$(LIBDIR)/$(LIB_NAME)
614	%%PKG_CONFIG_INSTALL%%
615
616install:%%INSTALL_LOCALES_PREREQS%%%%INSTALL_MAN_PREREQS%%%%INSTALL_PREREQS%%
617
618uninstall_locales:
619	$(LOCALE_UNINSTALL) $(NLSPATH) $(MAIN_EXEC) $(DESTDIR)
620
621uninstall_bc_manpage:
622	$(RM) -f $(DESTDIR)$(MAN1DIR)/$(BC_MANPAGE_NAME)
623
624uninstall_bc:
625	$(RM) -f $(DESTDIR)$(BINDIR)/$(EXEC_PREFIX)$(BC)$(EXEC_SUFFIX)
626
627uninstall_dc_manpage:
628	$(RM) -f $(DESTDIR)$(MAN1DIR)/$(DC_MANPAGE_NAME)
629
630uninstall_dc:
631	$(RM) -f $(DESTDIR)$(BINDIR)/$(EXEC_PREFIX)$(DC)$(EXEC_SUFFIX)
632
633uninstall_library: uninstall_bcl_header
634	$(RM) -f $(DESTDIR)$(LIBDIR)/$(LIB_NAME)
635	%%PKG_CONFIG_UNINSTALL%%
636
637uninstall_bcl_header:
638	$(RM) -f $(DESTDIR)$(INCLUDEDIR)/$(BCL_HEADER_NAME)
639
640uninstall_bcl_manpage:
641	$(RM) -f $(DESTDIR)$(MAN3DIR)/$(BCL_MANPAGE_NAME)
642
643uninstall:%%UNINSTALL_LOCALES_PREREQS%%%%UNINSTALL_MAN_PREREQS%%%%UNINSTALL_PREREQS%%
644