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