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