aboutsummaryrefslogtreecommitdiff
path: root/Makefile.in
blob: 3d6780d6ac95b1df048da822aa865f48a47c8502 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
#
# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2018-2021 Gavin D. Howard and contributors.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
#   list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
#   this list of conditions and the following disclaimer in the documentation
#   and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# %%WARNING%%
#
.POSIX:

SRC = %%SRC%%
OBJ = %%OBJ%%
GCDA = %%GCDA%%
GCNO = %%GCNO%%

BC_ENABLED_NAME = BC_ENABLED
BC_ENABLED = %%BC_ENABLED%%
DC_ENABLED_NAME = DC_ENABLED
DC_ENABLED = %%DC_ENABLED%%

HEADERS = 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
BC_HEADERS = include/bc.h
DC_HEADERS = include/dc.h
HISTORY_HEADERS = include/history.h
EXTRA_MATH_HEADERS = include/rand.h
LIBRARY_HEADERS = include/bcl.h include/library.h

GEN_DIR = gen
GEN = %%GEN%%
GEN_EXEC = $(GEN_DIR)/$(GEN)
GEN_C = $(GEN_DIR)/$(GEN).c

GEN_EMU = %%GEN_EMU%%

BC_LIB = $(GEN_DIR)/lib.bc
BC_LIB_C = $(GEN_DIR)/lib.c
BC_LIB_O = %%BC_LIB_O%%
BC_LIB_GCDA = $(GEN_DIR)/lib.gcda
BC_LIB_GCNO = $(GEN_DIR)/lib.gcno

BC_LIB2 = $(GEN_DIR)/lib2.bc
BC_LIB2_C = $(GEN_DIR)/lib2.c
BC_LIB2_O = %%BC_LIB2_O%%
BC_LIB2_GCDA = $(GEN_DIR)/lib2.gcda
BC_LIB2_GCNO = $(GEN_DIR)/lib2.gcno

BC_HELP = $(GEN_DIR)/bc_help.txt
BC_HELP_C = $(GEN_DIR)/bc_help.c
BC_HELP_O = %%BC_HELP_O%%
BC_HELP_GCDA = $(GEN_DIR)/bc_help.gcda
BC_HELP_GCNO = $(GEN_DIR)/bc_help.gcno

DC_HELP = $(GEN_DIR)/dc_help.txt
DC_HELP_C = $(GEN_DIR)/dc_help.c
DC_HELP_O = %%DC_HELP_O%%
DC_HELP_GCDA = $(GEN_DIR)/dc_help.gcda
DC_HELP_GCNO = $(GEN_DIR)/dc_help.gcno

BIN = bin
LOCALES = locales
EXEC_SUFFIX = %%EXECSUFFIX%%
EXEC_PREFIX = %%EXECPREFIX%%

BC = bc
DC = dc
BC_EXEC = $(BIN)/$(EXEC_PREFIX)$(BC)
DC_EXEC = $(BIN)/$(EXEC_PREFIX)$(DC)

BC_TEST_OUTPUTS = tests/bc_outputs
BC_FUZZ_OUTPUTS = tests/fuzzing/bc_outputs1 tests/fuzzing/bc_outputs2 tests/fuzzing/bc_outputs3
DC_TEST_OUTPUTS = tests/dc_outputs
DC_FUZZ_OUTPUTS = tests/fuzzing/dc_outputs

LIB = libbcl
LIB_NAME = $(LIB).a
LIBBC = $(BIN)/$(LIB_NAME)
BCL = bcl
BCL_TEST = $(BIN)/$(BCL)
BCL_TEST_C = tests/$(BCL).c

MANUALS = manuals
BC_MANPAGE_NAME = $(EXEC_PREFIX)$(BC)$(EXEC_SUFFIX).1
BC_MANPAGE = $(MANUALS)/$(BC).1
BC_MD = $(BC_MANPAGE).md
DC_MANPAGE_NAME = $(EXEC_PREFIX)$(DC)$(EXEC_SUFFIX).1
DC_MANPAGE = $(MANUALS)/$(DC).1
DC_MD = $(DC_MANPAGE).md
BCL_MANPAGE_NAME = bcl.3
BCL_MANPAGE = $(MANUALS)/$(BCL_MANPAGE_NAME)
BCL_MD = $(BCL_MANPAGE).md

MANPAGE_INSTALL_ARGS = -Dm644
BINARY_INSTALL_ARGS = -Dm755

BCL_HEADER_NAME = bcl.h
BCL_HEADER = include/$(BCL_HEADER_NAME)

%%DESTDIR%%
BINDIR = %%BINDIR%%
INCLUDEDIR = %%INCLUDEDIR%%
LIBDIR = %%LIBDIR%%
MAN1DIR = %%MAN1DIR%%
MAN3DIR = %%MAN3DIR%%
MAIN_EXEC = $(EXEC_PREFIX)$(%%MAIN_EXEC%%)$(EXEC_SUFFIX)
EXEC = $(%%EXEC%%)
NLSPATH = %%NLSPATH%%

BC_BUILD_TYPE = %%BUILD_TYPE%%

BC_ENABLE_LIBRARY = %%LIBRARY%%

BC_ENABLE_HISTORY = %%HISTORY%%
BC_ENABLE_EXTRA_MATH_NAME = BC_ENABLE_EXTRA_MATH
BC_ENABLE_EXTRA_MATH = %%EXTRA_MATH%%
BC_ENABLE_NLS = %%NLS%%
BC_LONG_BIT = %%LONG_BIT%%

BC_ENABLE_AFL = %%FUZZ%%
BC_ENABLE_MEMCHECK = %%MEMCHECK%%

BC_DEFAULT_BANNER = %%BC_DEFAULT_BANNER%%
BC_DEFAULT_SIGINT_RESET = %%BC_DEFAULT_SIGINT_RESET%%
DC_DEFAULT_SIGINT_RESET = %%DC_DEFAULT_SIGINT_RESET%%
BC_DEFAULT_TTY_MODE = %%BC_DEFAULT_TTY_MODE%%
DC_DEFAULT_TTY_MODE = %%DC_DEFAULT_TTY_MODE%%
BC_DEFAULT_PROMPT = %%BC_DEFAULT_PROMPT%%
DC_DEFAULT_PROMPT = %%DC_DEFAULT_PROMPT%%

RM = rm
MKDIR = mkdir

SCRIPTS = ./scripts

MINISTAT = ministat
MINISTAT_EXEC = $(SCRIPTS)/$(MINISTAT)

BITFUNCGEN = bitfuncgen
BITFUNCGEN_EXEC = $(SCRIPTS)/$(BITFUNCGEN)

INSTALL = $(SCRIPTS)/exec-install.sh
SAFE_INSTALL = $(SCRIPTS)/safe-install.sh
LINK = $(SCRIPTS)/link.sh
MANPAGE = $(SCRIPTS)/manpage.sh
KARATSUBA = $(SCRIPTS)/karatsuba.py
LOCALE_INSTALL = $(SCRIPTS)/locale_install.sh
LOCALE_UNINSTALL = $(SCRIPTS)/locale_uninstall.sh

VALGRIND_ARGS = --error-exitcode=100 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all

TEST_STARS = ***********************************************************************

BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%%

BC_DEFS0 = -DBC_DEFAULT_BANNER=$(BC_DEFAULT_BANNER)
BC_DEFS1 = -DBC_DEFAULT_SIGINT_RESET=$(BC_DEFAULT_SIGINT_RESET)
BC_DEFS2 = -DBC_DEFAULT_TTY_MODE=$(BC_DEFAULT_TTY_MODE)
BC_DEFS3 = -DBC_DEFAULT_PROMPT=$(BC_DEFAULT_PROMPT)
BC_DEFS = $(BC_DEFS0) $(BC_DEFS1) $(BC_DEFS2) $(BC_DEFS3)
DC_DEFS1 = -DDC_DEFAULT_SIGINT_RESET=$(DC_DEFAULT_SIGINT_RESET)
DC_DEFS2 = -DDC_DEFAULT_TTY_MODE=$(DC_DEFAULT_TTY_MODE)
DC_DEFS3 = -DDC_DEFAULT_PROMPT=$(DC_DEFAULT_PROMPT)
DC_DEFS = $(DC_DEFS1) $(DC_DEFS2) $(DC_DEFS3)

CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED)
CPPFLAGS2 = $(CPPFLAGS1) -I./include/ -DBUILD_TYPE=$(BC_BUILD_TYPE) %%LONG_BIT_DEFINE%%
CPPFLAGS3 = $(CPPFLAGS2) -DEXECPREFIX=$(EXEC_PREFIX) -DMAINEXEC=$(MAIN_EXEC)
CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 %%BSD%%
CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN)
CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS)
CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH)
CPPFLAGS8 = $(CPPFLAGS7) -DBC_ENABLE_HISTORY=$(BC_ENABLE_HISTORY) -DBC_ENABLE_LIBRARY=$(BC_ENABLE_LIBRARY)
CPPFLAGS = $(CPPFLAGS8) -DBC_ENABLE_MEMCHECK=$(BC_ENABLE_MEMCHECK) -DBC_ENABLE_AFL=$(BC_ENABLE_AFL)
CFLAGS = $(CPPFLAGS) $(BC_DEFS) $(DC_DEFS) %%CPPFLAGS%% %%CFLAGS%%
LDFLAGS = %%LDFLAGS%%

HOSTCFLAGS = %%HOSTCFLAGS%%

CC = %%CC%%
HOSTCC = %%HOSTCC%%

BC_LIB_C_ARGS = bc_lib bc_lib_name $(BC_ENABLED_NAME) 1
BC_LIB2_C_ARGS = bc_lib2 bc_lib2_name "$(BC_ENABLED_NAME) && $(BC_ENABLE_EXTRA_MATH_NAME)" 1

OBJS = $(DC_HELP_O) $(BC_HELP_O) $(BC_LIB_O) $(BC_LIB2_O) $(OBJ)

all: %%DEFAULT_TARGET%%

%%DEFAULT_TARGET%%: %%DEFAULT_TARGET_PREREQS%%
	%%DEFAULT_TARGET_CMD%%

%%SECOND_TARGET%%: %%SECOND_TARGET_PREREQS%%
	%%SECOND_TARGET_CMD%%

$(GEN_EXEC):
	%%GEN_EXEC_TARGET%%

$(BC_LIB_C): $(GEN_EXEC) $(BC_LIB)
	$(GEN_EMU) $(GEN_EXEC) $(BC_LIB) $(BC_LIB_C) $(BC_LIB_C_ARGS)

$(BC_LIB_O): $(BC_LIB_C)
	$(CC) $(CFLAGS) -o $@ -c $<

$(BC_LIB2_C): $(GEN_EXEC) $(BC_LIB2)
	$(GEN_EMU) $(GEN_EXEC) $(BC_LIB2) $(BC_LIB2_C) $(BC_LIB2_C_ARGS)

$(BC_LIB2_O): $(BC_LIB2_C)
	$(CC) $(CFLAGS) -o $@ -c $<

$(BC_HELP_C): $(GEN_EXEC) $(BC_HELP)
	$(GEN_EMU) $(GEN_EXEC) $(BC_HELP) $(BC_HELP_C) bc_help "" $(BC_ENABLED_NAME)

$(BC_HELP_O): $(BC_HELP_C)
	$(CC) $(CFLAGS) -o $@ -c $<

$(DC_HELP_C): $(GEN_EXEC) $(DC_HELP)
	$(GEN_EMU) $(GEN_EXEC) $(DC_HELP) $(DC_HELP_C) dc_help "" $(DC_ENABLED_NAME)

$(DC_HELP_O): $(DC_HELP_C)
	$(CC) $(CFLAGS) -o $@ -c $<

$(BIN):
	$(MKDIR) -p $(BIN)

headers: %%HEADERS%%

$(MINISTAT):
	$(HOSTCC) $(HOSTCFLAGS) -lm -o $(MINISTAT_EXEC) scripts/ministat.c

$(BITFUNCGEN):
	$(HOSTCC) $(HOSTCFLAGS) -lm -o $(BITFUNCGEN_EXEC) scripts/bitfuncgen.c

help:
	@printf 'available targets:\n'
	@printf '\n'
	@printf '    all (default)   builds %%EXECUTABLES%%\n'
	@printf '    check           alias for `make test`\n'
	@printf '    clean           removes all build files\n'
	@printf '    clean_config    removes all build files as well as the generated Makefile\n'
	@printf '    clean_tests     removes all build files, the generated Makefile,\n'
	@printf '                    and generated tests\n'
	@printf '    install         installs binaries to "%s%s"\n' "$(DESTDIR)" "$(BINDIR)"
	@printf '                    and (if enabled) manpages to "%s%s"\n' "$(DESTDIR)" "$(MAN1DIR)"
	@printf '    karatsuba       runs the karatsuba script (requires Python 3)\n'
	@printf '    karatsuba_test  runs the karatsuba script while running tests\n'
	@printf '                    (requires Python 3)\n'
	@printf '    uninstall       uninstalls binaries from "%s%s"\n' "$(DESTDIR)" "$(BINDIR)"
	@printf '                    and (if enabled) manpages from "%s%s"\n' "$(DESTDIR)" "$(MAN1DIR)"
	@printf '    test            runs the test suite\n'
	@printf '    test_bc         runs the bc test suite, if bc has been built\n'
	@printf '    test_dc         runs the dc test suite, if dc has been built\n'
	@printf '    time_test       runs the test suite, displaying times for some things\n'
	@printf '    time_test_bc    runs the bc test suite, displaying times for some things\n'
	@printf '    time_test_dc    runs the dc test suite, displaying times for some things\n'
	@printf '    timeconst       runs the test on the Linux timeconst.bc script,\n'
	@printf '                    if it exists and bc has been built\n'
	@printf '    valgrind        runs the test suite through valgrind\n'
	@printf '    valgrind_bc     runs the bc test suite, if bc has been built,\n'
	@printf '                    through valgrind\n'
	@printf '    valgrind_dc     runs the dc test suite, if dc has been built,\n'
	@printf '                    through valgrind\n'

run_all_tests: bc_all_tests timeconst_all_tests dc_all_tests

run_all_tests_np: bc_all_tests_np timeconst_all_tests dc_all_tests_np

bc_all_tests:
	%%BC_ALL_TESTS%%

bc_all_tests_np:
	%%BC_ALL_TESTS_NP%%

timeconst_all_tests:
	%%TIMECONST_ALL_TESTS%%

dc_all_tests:
	%%DC_ALL_TESTS%%

dc_all_tests_np:
	%%DC_ALL_TESTS_NP%%

history_all_tests:
	%%HISTORY_TESTS%%

check: test

test: %%TESTS%%

test_bc: test_bc_header test_bc_tests test_bc_scripts test_bc_errors test_bc_stdin test_bc_read test_bc_other
	@printf '\nAll bc tests passed.\n\n$(TEST_STARS)\n'

test_bc_tests:%%BC_TESTS%%

test_bc_scripts:%%BC_SCRIPT_TESTS%%

test_bc_stdin:
	@sh tests/stdin.sh bc %%BC_TEST_EXEC%%

test_bc_read:
	@sh tests/read.sh bc %%BC_TEST_EXEC%%

test_bc_errors: test_bc_error_lines%%BC_ERROR_TESTS%%

test_bc_error_lines:
	@sh tests/errors.sh bc %%BC_TEST_EXEC%%

test_bc_other:
	@sh tests/other.sh bc $(BC_ENABLE_EXTRA_MATH) %%BC_TEST_EXEC%%

test_bc_header:
	@printf '$(TEST_STARS)\n\nRunning bc tests...\n\n'

test_dc: test_dc_header test_dc_tests test_dc_scripts test_dc_errors test_dc_stdin test_dc_read test_dc_other
	@printf '\nAll dc tests passed.\n\n$(TEST_STARS)\n'

test_dc_tests:%%DC_TESTS%%

test_dc_scripts:%%DC_SCRIPT_TESTS%%

test_dc_stdin:
	@sh tests/stdin.sh dc %%DC_TEST_EXEC%%

test_dc_read:
	@sh tests/read.sh dc %%DC_TEST_EXEC%%

test_dc_errors: test_dc_error_lines%%DC_ERROR_TESTS%%

test_dc_error_lines:
	@sh tests/errors.sh dc %%DC_TEST_EXEC%%

test_dc_other:
	@sh tests/other.sh dc $(BC_ENABLE_EXTRA_MATH) %%DC_TEST_EXEC%%

test_dc_header:
	@printf '$(TEST_STARS)\n\nRunning dc tests...\n\n'

timeconst:
	%%TIMECONST%%

test_history: test_history_header test_bc_history test_dc_history
	@printf '\nAll history tests passed.\n\n$(TEST_STARS)\n'

test_bc_history:%%BC_HISTORY_TEST_PREREQS%%

test_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

test_bc_history_skip:
	@printf 'No bc history tests to run\n'

test_bc_history0:
	@sh tests/history.sh bc 0 %%BC_TEST_EXEC%%

test_bc_history1:
	@sh tests/history.sh bc 1 %%BC_TEST_EXEC%%

test_bc_history2:
	@sh tests/history.sh bc 2 %%BC_TEST_EXEC%%

test_bc_history3:
	@sh tests/history.sh bc 3 %%BC_TEST_EXEC%%

test_bc_history4:
	@sh tests/history.sh bc 4 %%BC_TEST_EXEC%%

test_bc_history5:
	@sh tests/history.sh bc 5 %%BC_TEST_EXEC%%

test_bc_history6:
	@sh tests/history.sh bc 6 %%BC_TEST_EXEC%%

test_bc_history7:
	@sh tests/history.sh bc 7 %%BC_TEST_EXEC%%

test_bc_history8:
	@sh tests/history.sh bc 8 %%BC_TEST_EXEC%%

test_bc_history9:
	@sh tests/history.sh bc 9 %%BC_TEST_EXEC%%

test_bc_history10:
	@sh tests/history.sh bc 10 %%BC_TEST_EXEC%%

test_bc_history11:
	@sh tests/history.sh bc 11 %%BC_TEST_EXEC%%

test_bc_history12:
	@sh tests/history.sh bc 12 %%BC_TEST_EXEC%%

test_bc_history13:
	@sh tests/history.sh bc 13 %%BC_TEST_EXEC%%

test_bc_history14:
	@sh tests/history.sh bc 14 %%BC_TEST_EXEC%%

test_bc_history15:
	@sh tests/history.sh bc 15 %%BC_TEST_EXEC%%

test_bc_history16:
	@sh tests/history.sh bc 16 %%BC_TEST_EXEC%%

test_bc_history17:
	@sh tests/history.sh bc 17 %%BC_TEST_EXEC%%

test_bc_history18:
	@sh tests/history.sh bc 18 %%BC_TEST_EXEC%%

test_bc_history19:
	@sh tests/history.sh bc 19 %%BC_TEST_EXEC%%

test_bc_history20:
	@sh tests/history.sh bc 20 %%BC_TEST_EXEC%%

test_bc_history21:
	@sh tests/history.sh bc 21 %%BC_TEST_EXEC%%

test_dc_history:%%DC_HISTORY_TEST_PREREQS%%

test_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_history_skip:
	@printf 'No dc history tests to run\n'

test_dc_history0:
	@sh tests/history.sh dc 0 %%DC_TEST_EXEC%%

test_dc_history1:
	@sh tests/history.sh dc 1 %%DC_TEST_EXEC%%

test_dc_history2:
	@sh tests/history.sh dc 2 %%DC_TEST_EXEC%%

test_dc_history3:
	@sh tests/history.sh dc 3 %%DC_TEST_EXEC%%

test_dc_history4:
	@sh tests/history.sh dc 4 %%DC_TEST_EXEC%%

test_dc_history5:
	@sh tests/history.sh dc 5 %%DC_TEST_EXEC%%

test_dc_history6:
	@sh tests/history.sh dc 6 %%DC_TEST_EXEC%%

test_dc_history7:
	@sh tests/history.sh dc 7 %%DC_TEST_EXEC%%

test_dc_history8:
	@sh tests/history.sh dc 8 %%DC_TEST_EXEC%%

test_dc_history9:
	@sh tests/history.sh dc 9 %%DC_TEST_EXEC%%

test_history_header:
	@printf '$(TEST_STARS)\n\nRunning history tests...\n\n'

library_test: $(LIBBC)
	$(CC) $(CFLAGS) $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST)

test_library: library_test
	$(BCL_TEST)

karatsuba:
	%%KARATSUBA%%

karatsuba_test:
	%%KARATSUBA_TEST%%

coverage_output:
	%%COVERAGE_OUTPUT%%

coverage:%%COVERAGE_PREREQS%%

manpages:
	$(MANPAGE) bc
	$(MANPAGE) dc
	$(MANPAGE) bcl

clean_gen:
	@$(RM) -f $(GEN_EXEC)

clean:%%CLEAN_PREREQS%%
	@printf 'Cleaning files...\n'
	@$(RM) -f src/*.tmp gen/*.tmp
	@$(RM) -f $(OBJ)
	@$(RM) -f $(BC_EXEC)
	@$(RM) -f $(DC_EXEC)
	@$(RM) -fr $(BIN)
	@$(RM) -f $(LOCALES)/*.cat
	@$(RM) -f $(BC_LIB_C) $(BC_LIB_O)
	@$(RM) -f $(BC_LIB2_C) $(BC_LIB2_O)
	@$(RM) -f $(BC_HELP_C) $(BC_HELP_O)
	@$(RM) -f $(DC_HELP_C) $(DC_HELP_O)
	@$(RM) -fr Debug/ Release/

clean_benchmarks:
	@printf 'Cleaning benchmarks...\n'
	@$(RM) -f $(MINISTAT_EXEC)
	@$(RM) -f benchmarks/bc/*.txt
	@$(RM) -f benchmarks/dc/*.txt

clean_config: clean clean_benchmarks
	@printf 'Cleaning config...\n'
	@$(RM) -f Makefile
	@$(RM) -f $(BC_MD) $(BC_MANPAGE)
	@$(RM) -f $(DC_MD) $(DC_MANPAGE)

clean_coverage:
	@printf 'Cleaning coverage files...\n'
	@$(RM) -f *.gcov
	@$(RM) -f *.html
	@$(RM) -f *.gcda *.gcno
	@$(RM) -f *.profraw
	@$(RM) -f $(GCDA) $(GCNO)
	@$(RM) -f $(BC_GCDA) $(BC_GCNO)
	@$(RM) -f $(DC_GCDA) $(DC_GCNO)
	@$(RM) -f $(HISTORY_GCDA) $(HISTORY_GCNO)
	@$(RM) -f $(RAND_GCDA) $(RAND_GCNO)
	@$(RM) -f $(BC_LIB_GCDA) $(BC_LIB_GCNO)
	@$(RM) -f $(BC_LIB2_GCDA) $(BC_LIB2_GCNO)
	@$(RM) -f $(BC_HELP_GCDA) $(BC_HELP_GCNO)
	@$(RM) -f $(DC_HELP_GCDA) $(DC_HELP_GCNO)

clean_tests: clean clean_config clean_coverage
	@printf 'Cleaning test files...\n'
	@$(RM) -fr $(BC_TEST_OUTPUTS) $(DC_TEST_OUTPUTS)
	@$(RM) -fr $(BC_FUZZ_OUTPUTS) $(DC_FUZZ_OUTPUTS)
	@$(RM) -f tests/bc/parse.txt tests/bc/parse_results.txt
	@$(RM) -f tests/bc/print.txt tests/bc/print_results.txt
	@$(RM) -f tests/bc/bessel.txt tests/bc/bessel_results.txt
	@$(RM) -f tests/bc/strings2.txt tests/bc/strings2_results.txt
	@$(RM) -f tests/bc/scripts/bessel.txt
	@$(RM) -f tests/bc/scripts/parse.txt
	@$(RM) -f tests/bc/scripts/print.txt
	@$(RM) -f tests/bc/scripts/add.txt
	@$(RM) -f tests/bc/scripts/divide.txt
	@$(RM) -f tests/bc/scripts/multiply.txt
	@$(RM) -f tests/bc/scripts/subtract.txt
	@$(RM) -f tests/bc/scripts/strings2.txt
	@$(RM) -f tests/dc/scripts/prime.txt
	@$(RM) -f .log_*.txt
	@$(RM) -f .math.txt .results.txt .ops.txt
	@$(RM) -f .test.txt
	@$(RM) -f tags .gdbbreakpoints .gdb_history .gdbsetup
	@$(RM) -f cscope.*
	@$(RM) -f bc.old
	@$(RM) -f $(BITFUNCGEN_EXEC)

install_locales:
	%%INSTALL_LOCALES%%

install_bc_manpage:
	$(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(BC_MANPAGE) $(DESTDIR)$(MAN1DIR)/$(BC_MANPAGE_NAME)

install_dc_manpage:
	$(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(DC_MANPAGE) $(DESTDIR)$(MAN1DIR)/$(DC_MANPAGE_NAME)

install_bcl_manpage:
	$(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(BCL_MANPAGE) $(DESTDIR)$(MAN3DIR)/$(BCL_MANPAGE_NAME)

install_bcl_header:
	$(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(BCL_HEADER) $(DESTDIR)$(INCLUDEDIR)/$(BCL_HEADER_NAME)

install_execs:
	$(INSTALL) $(DESTDIR)$(BINDIR) "$(EXEC_SUFFIX)"

install_library:
	$(SAFE_INSTALL) $(BINARY_INSTALL_ARGS) $(LIBBC) $(DESTDIR)$(LIBDIR)/$(LIB_NAME)

install:%%INSTALL_LOCALES_PREREQS%%%%INSTALL_MAN_PREREQS%%%%INSTALL_PREREQS%%

uninstall_locales:
	$(LOCALE_UNINSTALL) $(NLSPATH) $(MAIN_EXEC) $(DESTDIR)

uninstall_bc_manpage:
	$(RM) -f $(DESTDIR)$(MAN1DIR)/$(BC_MANPAGE_NAME)

uninstall_bc:
	$(RM) -f $(DESTDIR)$(BINDIR)/$(EXEC_PREFIX)$(BC)$(EXEC_SUFFIX)

uninstall_dc_manpage:
	$(RM) -f $(DESTDIR)$(MAN1DIR)/$(DC_MANPAGE_NAME)

uninstall_dc:
	$(RM) -f $(DESTDIR)$(BINDIR)/$(EXEC_PREFIX)$(DC)$(EXEC_SUFFIX)

uninstall_library:
	$(RM) -f $(DESTDIR)$(LIBDIR)/$(LIB_NAME)

uninstall_bcl_header:
	$(RM) -f $(DESTDIR)$(INCLUDEDIR)/$(BCL_HEADER_NAME)

uninstall_bcl_manpage:
	$(RM) -f $(DESTDIR)$(MAN3DIR)/$(BCL_MANPAGE_NAME)

uninstall:%%UNINSTALL_LOCALES_PREREQS%%%%UNINSTALL_MAN_PREREQS%%%%UNINSTALL_PREREQS%%