]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bc/Makefile.in
Upgrade to version 3.3.0
[FreeBSD/FreeBSD.git] / contrib / bc / Makefile.in
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
32 VERSION = 3.3.0
33
34 SRC = %%SRC%%
35 OBJ = %%OBJ%%
36 GCDA = %%GCDA%%
37 GCNO = %%GCNO%%
38
39 BC_ENABLED_NAME = BC_ENABLED
40 BC_ENABLED = %%BC_ENABLED%%
41 DC_ENABLED_NAME = DC_ENABLED
42 DC_ENABLED = %%DC_ENABLED%%
43
44 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
45 BC_HEADERS = include/bc.h
46 DC_HEADERS = include/dc.h
47 HISTORY_HEADERS = include/history.h
48 EXTRA_MATH_HEADERS = include/rand.h
49 LIBRARY_HEADERS = include/bcl.h include/library.h
50
51 GEN_DIR = gen
52 GEN = %%GEN%%
53 GEN_EXEC = $(GEN_DIR)/$(GEN)
54 GEN_C = $(GEN_DIR)/$(GEN).c
55
56 GEN_EMU = %%GEN_EMU%%
57
58 BC_LIB = $(GEN_DIR)/lib.bc
59 BC_LIB_C = $(GEN_DIR)/lib.c
60 BC_LIB_O = %%BC_LIB_O%%
61 BC_LIB_GCDA = $(GEN_DIR)/lib.gcda
62 BC_LIB_GCNO = $(GEN_DIR)/lib.gcno
63
64 BC_LIB2 = $(GEN_DIR)/lib2.bc
65 BC_LIB2_C = $(GEN_DIR)/lib2.c
66 BC_LIB2_O = %%BC_LIB2_O%%
67 BC_LIB2_GCDA = $(GEN_DIR)/lib2.gcda
68 BC_LIB2_GCNO = $(GEN_DIR)/lib2.gcno
69
70 BC_HELP = $(GEN_DIR)/bc_help.txt
71 BC_HELP_C = $(GEN_DIR)/bc_help.c
72 BC_HELP_O = %%BC_HELP_O%%
73 BC_HELP_GCDA = $(GEN_DIR)/bc_help.gcda
74 BC_HELP_GCNO = $(GEN_DIR)/bc_help.gcno
75
76 DC_HELP = $(GEN_DIR)/dc_help.txt
77 DC_HELP_C = $(GEN_DIR)/dc_help.c
78 DC_HELP_O = %%DC_HELP_O%%
79 DC_HELP_GCDA = $(GEN_DIR)/dc_help.gcda
80 DC_HELP_GCNO = $(GEN_DIR)/dc_help.gcno
81
82 BIN = bin
83 LOCALES = locales
84 EXEC_SUFFIX = %%EXECSUFFIX%%
85 EXEC_PREFIX = %%EXECPREFIX%%
86
87 BC = bc
88 DC = dc
89 BC_EXEC = $(BIN)/$(EXEC_PREFIX)$(BC)
90 DC_EXEC = $(BIN)/$(EXEC_PREFIX)$(DC)
91
92 BC_TEST_OUTPUTS = tests/bc_outputs
93 BC_FUZZ_OUTPUTS = tests/fuzzing/bc_outputs1 tests/fuzzing/bc_outputs2 tests/fuzzing/bc_outputs3
94 DC_TEST_OUTPUTS = tests/dc_outputs
95 DC_FUZZ_OUTPUTS = tests/fuzzing/dc_outputs
96
97 LIB = libbcl
98 LIB_NAME = $(LIB).a
99 LIBBC = $(BIN)/$(LIB_NAME)
100 BCL = bcl
101 BCL_TEST = $(BIN)/$(BCL)
102 BCL_TEST_C = tests/$(BCL).c
103
104 MANUALS = manuals
105 BC_MANPAGE_NAME = $(EXEC_PREFIX)$(BC)$(EXEC_SUFFIX).1
106 BC_MANPAGE = $(MANUALS)/$(BC).1
107 BC_MD = $(BC_MANPAGE).md
108 DC_MANPAGE_NAME = $(EXEC_PREFIX)$(DC)$(EXEC_SUFFIX).1
109 DC_MANPAGE = $(MANUALS)/$(DC).1
110 DC_MD = $(DC_MANPAGE).md
111 BCL_MANPAGE_NAME = bcl.3
112 BCL_MANPAGE = $(MANUALS)/$(BCL_MANPAGE_NAME)
113 BCL_MD = $(BCL_MANPAGE).md
114
115 MANPAGE_INSTALL_ARGS = -Dm644
116 BINARY_INSTALL_ARGS = -Dm755
117
118 BCL_HEADER_NAME = bcl.h
119 BCL_HEADER = include/$(BCL_HEADER_NAME)
120
121 %%DESTDIR%%
122 BINDIR = %%BINDIR%%
123 INCLUDEDIR = %%INCLUDEDIR%%
124 LIBDIR = %%LIBDIR%%
125 MAN1DIR = %%MAN1DIR%%
126 MAN3DIR = %%MAN3DIR%%
127 MAIN_EXEC = $(EXEC_PREFIX)$(%%MAIN_EXEC%%)$(EXEC_SUFFIX)
128 EXEC = $(%%EXEC%%)
129 NLSPATH = %%NLSPATH%%
130
131 BC_ENABLE_LIBRARY = %%LIBRARY%%
132
133 BC_ENABLE_HISTORY = %%HISTORY%%
134 BC_ENABLE_EXTRA_MATH_NAME = BC_ENABLE_EXTRA_MATH
135 BC_ENABLE_EXTRA_MATH = %%EXTRA_MATH%%
136 BC_ENABLE_NLS = %%NLS%%
137 BC_ENABLE_PROMPT = %%PROMPT%%
138 BC_LONG_BIT = %%LONG_BIT%%
139
140 BC_ENABLE_AFL = %%FUZZ%%
141 BC_ENABLE_MEMCHECK = %%MEMCHECK%%
142
143 RM = rm
144 MKDIR = mkdir
145
146 INSTALL = ./exec-install.sh
147 SAFE_INSTALL = ./safe-install.sh
148 LINK = ./link.sh
149 MANPAGE = ./manpage.sh
150 KARATSUBA = ./karatsuba.py
151 LOCALE_INSTALL = ./locale_install.sh
152 LOCALE_UNINSTALL = ./locale_uninstall.sh
153
154 VALGRIND_ARGS = --error-exitcode=100 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all
155
156 TEST_STARS = "***********************************************************************"
157
158 BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%%
159
160 CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED)
161 CPPFLAGS2 = $(CPPFLAGS1) -I./include/ -DVERSION=$(VERSION) %%LONG_BIT_DEFINE%%
162 CPPFLAGS3 = $(CPPFLAGS2) -DEXECPREFIX=$(EXEC_PREFIX) -DMAINEXEC=$(MAIN_EXEC)
163 CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
164 CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN)
165 CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS) -DBC_ENABLE_PROMPT=$(BC_ENABLE_PROMPT)
166 CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH)
167 CPPFLAGS8 = $(CPPFLAGS7) -DBC_ENABLE_HISTORY=$(BC_ENABLE_HISTORY) -DBC_ENABLE_LIBRARY=$(BC_ENABLE_LIBRARY)
168 CPPFLAGS = $(CPPFLAGS8) -DBC_ENABLE_MEMCHECK=$(BC_ENABLE_MEMCHECK) -DBC_ENABLE_AFL=$(BC_ENABLE_AFL)
169 CFLAGS = $(CPPFLAGS) %%CPPFLAGS%% %%CFLAGS%%
170 LDFLAGS = %%LDFLAGS%%
171
172 HOSTCFLAGS = %%HOSTCFLAGS%%
173
174 CC = %%CC%%
175 HOSTCC = %%HOSTCC%%
176
177 BC_LIB_C_ARGS = bc_lib bc_lib_name $(BC_ENABLED_NAME) 1
178 BC_LIB2_C_ARGS = bc_lib2 bc_lib2_name "$(BC_ENABLED_NAME) && $(BC_ENABLE_EXTRA_MATH_NAME)" 1
179
180 OBJS = $(DC_HELP_O) $(BC_HELP_O) $(BC_LIB_O) $(BC_LIB2_O) $(OBJ)
181
182 all: %%DEFAULT_TARGET%%
183
184 %%DEFAULT_TARGET%%: %%DEFAULT_TARGET_PREREQS%%
185         %%DEFAULT_TARGET_CMD%%
186
187 %%SECOND_TARGET%%: %%SECOND_TARGET_PREREQS%%
188         %%SECOND_TARGET_CMD%%
189
190 $(GEN_EXEC):
191         %%GEN_EXEC_TARGET%%
192
193 $(BC_LIB_C): $(GEN_EXEC) $(BC_LIB)
194         $(GEN_EMU) $(GEN_EXEC) $(BC_LIB) $(BC_LIB_C) $(BC_LIB_C_ARGS)
195
196 $(BC_LIB_O): $(BC_LIB_C)
197         $(CC) $(CFLAGS) -o $@ -c $<
198
199 $(BC_LIB2_C): $(GEN_EXEC) $(BC_LIB2)
200         $(GEN_EMU) $(GEN_EXEC) $(BC_LIB2) $(BC_LIB2_C) $(BC_LIB2_C_ARGS)
201
202 $(BC_LIB2_O): $(BC_LIB2_C)
203         $(CC) $(CFLAGS) -o $@ -c $<
204
205 $(BC_HELP_C): $(GEN_EXEC) $(BC_HELP)
206         $(GEN_EMU) $(GEN_EXEC) $(BC_HELP) $(BC_HELP_C) bc_help "" $(BC_ENABLED_NAME)
207
208 $(BC_HELP_O): $(BC_HELP_C)
209         $(CC) $(CFLAGS) -o $@ -c $<
210
211 $(DC_HELP_C): $(GEN_EXEC) $(DC_HELP)
212         $(GEN_EMU) $(GEN_EXEC) $(DC_HELP) $(DC_HELP_C) dc_help "" $(DC_ENABLED_NAME)
213
214 $(DC_HELP_O): $(DC_HELP_C)
215         $(CC) $(CFLAGS) -o $@ -c $<
216
217 $(BIN):
218         $(MKDIR) -p $(BIN)
219
220 headers: %%HEADERS%%
221
222 help:
223         @printf 'available targets:\n'
224         @printf '\n'
225         @printf '    all (default)   builds %%EXECUTABLES%%\n'
226         @printf '    check           alias for `make test`\n'
227         @printf '    clean           removes all build files\n'
228         @printf '    clean_config    removes all build files as well as the generated Makefile\n'
229         @printf '    clean_tests     removes all build files, the generated Makefile,\n'
230         @printf '                    and generated tests\n'
231         @printf '    install         installs binaries to "%s%s"\n' "$(DESTDIR)" "$(BINDIR)"
232         @printf '                    and (if enabled) manpages to "%s%s"\n' "$(DESTDIR)" "$(MAN1DIR)"
233         @printf '    karatsuba       runs the karatsuba script (requires Python 3)\n'
234         @printf '    karatsuba_test  runs the karatsuba script while running tests\n'
235         @printf '                    (requires Python 3)\n'
236         @printf '    uninstall       uninstalls binaries from "%s%s"\n' "$(DESTDIR)" "$(BINDIR)"
237         @printf '                    and (if enabled) manpages from "%s%s"\n' "$(DESTDIR)" "$(MAN1DIR)"
238         @printf '    test            runs the test suite\n'
239         @printf '    test_bc         runs the bc test suite, if bc has been built\n'
240         @printf '    test_dc         runs the dc test suite, if dc has been built\n'
241         @printf '    time_test       runs the test suite, displaying times for some things\n'
242         @printf '    time_test_bc    runs the bc test suite, displaying times for some things\n'
243         @printf '    time_test_dc    runs the dc test suite, displaying times for some things\n'
244         @printf '    timeconst       runs the test on the Linux timeconst.bc script,\n'
245         @printf '                    if it exists and bc has been built\n'
246         @printf '    valgrind        runs the test suite through valgrind\n'
247         @printf '    valgrind_bc     runs the bc test suite, if bc has been built,\n'
248         @printf '                    through valgrind\n'
249         @printf '    valgrind_dc     runs the dc test suite, if dc has been built,\n'
250         @printf '                    through valgrind\n'
251
252 run_all_tests:
253         %%BC_ALL_TESTS%%
254         %%TIMECONST_ALL_TESTS%%
255         %%DC_ALL_TESTS%%
256
257 check: test
258
259 test: %%TESTS%%
260
261 test_bc: test_bc_header test_bc_tests test_bc_scripts test_bc_stdin test_bc_read test_bc_errors test_bc_other
262         @printf '\nAll bc tests passed.\n\n$(TEST_STARS)\n'
263
264 test_bc_tests:%%BC_TESTS%%
265
266 test_bc_scripts:%%BC_SCRIPT_TESTS%%
267
268 test_bc_stdin:
269         @sh tests/stdin.sh bc %%BC_TEST_EXEC%%
270
271 test_bc_read:
272         @sh tests/read.sh bc %%BC_TEST_EXEC%%
273
274 test_bc_errors:
275         @sh tests/errors.sh bc %%BC_TEST_EXEC%%
276
277 test_bc_other:
278         @sh tests/other.sh bc %%BC_TEST_EXEC%%
279
280 test_bc_header:
281         @printf '$(TEST_STARS)\n\nRunning bc tests...\n\n'
282
283 test_dc: test_dc_header test_dc_tests test_dc_scripts test_dc_stdin test_dc_read test_dc_errors test_dc_other
284         @printf '\nAll dc tests passed.\n\n$(TEST_STARS)\n'
285
286 test_dc_tests:%%DC_TESTS%%
287
288 test_dc_scripts:%%DC_SCRIPT_TESTS%%
289
290 test_dc_stdin:
291         @sh tests/stdin.sh dc %%DC_TEST_EXEC%%
292
293 test_dc_read:
294         @sh tests/read.sh dc %%DC_TEST_EXEC%%
295
296 test_dc_errors:
297         @sh tests/errors.sh dc %%DC_TEST_EXEC%%
298
299 test_dc_other:
300         @sh tests/other.sh dc %%DC_TEST_EXEC%%
301
302 test_dc_header:
303         @printf '$(TEST_STARS)\n\nRunning dc tests...\n\n'
304
305 timeconst:
306         %%TIMECONST%%
307
308 library_test: $(LIBBC)
309         $(CC) $(CFLAGS) $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST)
310
311 test_library: library_test
312         $(BCL_TEST)
313
314 karatsuba:
315         %%KARATSUBA%%
316
317 karatsuba_test:
318         %%KARATSUBA_TEST%%
319
320 coverage_output:
321         %%COVERAGE_OUTPUT%%
322
323 coverage:%%COVERAGE_PREREQS%%
324
325 version:
326         @printf '%s' "$(VERSION)"
327
328 libcname:
329         @printf '%s' "$(BC_LIB_C)"
330
331 extra_math:
332         @printf '%s' "$(BC_ENABLE_EXTRA_MATH)"
333
334 manpages:
335         $(MANPAGE) bc
336         $(MANPAGE) dc
337         $(MANPAGE) bcl
338
339 clean_gen:
340         @$(RM) -f $(GEN_EXEC)
341
342 clean:%%CLEAN_PREREQS%%
343         @printf 'Cleaning files...\n'
344         @$(RM) -f $(OBJ)
345         @$(RM) -f $(BC_EXEC)
346         @$(RM) -f $(DC_EXEC)
347         @$(RM) -fr $(BIN)
348         @$(RM) -f $(LOCALES)/*.cat
349         @$(RM) -f $(BC_LIB_C) $(BC_LIB_O)
350         @$(RM) -f $(BC_LIB2_C) $(BC_LIB2_O)
351         @$(RM) -f $(BC_HELP_C) $(BC_HELP_O)
352         @$(RM) -f $(DC_HELP_C) $(DC_HELP_O)
353         @$(RM) -fr $(BC_TEST_OUTPUTS) $(DC_TEST_OUTPUTS)
354         @$(RM) -fr $(BC_FUZZ_OUTPUTS) $(DC_FUZZ_OUTPUTS)
355
356 clean_config: clean
357         @printf 'Cleaning config...\n'
358         @$(RM) -f Makefile
359         @$(RM) -f $(BC_MD) $(DC_MD)
360         @$(RM) -f $(BC_MANPAGE) $(DC_MANPAGE)
361
362 clean_coverage:
363         @printf 'Cleaning coverage files...\n'
364         @$(RM) -f *.gcov
365         @$(RM) -f *.html
366         @$(RM) -f *.gcda *.gcno
367         @$(RM) -f *.profraw
368         @$(RM) -f $(GCDA) $(GCNO)
369         @$(RM) -f $(BC_GCDA) $(BC_GCNO)
370         @$(RM) -f $(DC_GCDA) $(DC_GCNO)
371         @$(RM) -f $(HISTORY_GCDA) $(HISTORY_GCNO)
372         @$(RM) -f $(RAND_GCDA) $(RAND_GCNO)
373         @$(RM) -f $(BC_LIB_GCDA) $(BC_LIB_GCNO)
374         @$(RM) -f $(BC_LIB2_GCDA) $(BC_LIB2_GCNO)
375         @$(RM) -f $(BC_HELP_GCDA) $(BC_HELP_GCNO)
376         @$(RM) -f $(DC_HELP_GCDA) $(DC_HELP_GCNO)
377
378 clean_tests: clean clean_config clean_coverage
379         @printf 'Cleaning test files...\n'
380         @$(RM) -f tests/bc/parse.txt tests/bc/parse_results.txt
381         @$(RM) -f tests/bc/print.txt tests/bc/print_results.txt
382         @$(RM) -f tests/bc/bessel.txt tests/bc/bessel_results.txt
383         @$(RM) -f tests/bc/scripts/bessel.txt
384         @$(RM) -f tests/bc/scripts/parse.txt
385         @$(RM) -f tests/bc/scripts/print.txt
386         @$(RM) -f tests/bc/scripts/add.txt
387         @$(RM) -f tests/bc/scripts/divide.txt
388         @$(RM) -f tests/bc/scripts/multiply.txt
389         @$(RM) -f tests/bc/scripts/subtract.txt
390         @$(RM) -f tests/dc/scripts/prime.txt tests/dc/scripts/stream.txt
391         @$(RM) -f .log_*.txt
392         @$(RM) -f .math.txt .results.txt .ops.txt
393         @$(RM) -f .test.txt
394         @$(RM) -f tags .gdbbreakpoints .gdb_history .gdbsetup
395         @$(RM) -f cscope.*
396         @$(RM) -f bc.old
397
398 install_locales:
399         %%INSTALL_LOCALES%%
400
401 install_bc_manpage:
402         $(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(BC_MANPAGE) $(DESTDIR)$(MAN1DIR)/$(BC_MANPAGE_NAME)
403
404 install_dc_manpage:
405         $(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(DC_MANPAGE) $(DESTDIR)$(MAN1DIR)/$(DC_MANPAGE_NAME)
406
407 install_bcl_manpage:
408         $(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(BCL_MANPAGE) $(DESTDIR)$(MAN3DIR)/$(BCL_MANPAGE_NAME)
409
410 install_bcl_header:
411         $(SAFE_INSTALL) $(MANPAGE_INSTALL_ARGS) $(BCL_HEADER) $(DESTDIR)$(INCLUDEDIR)/$(BCL_HEADER_NAME)
412
413 install_execs:
414         $(INSTALL) $(DESTDIR)$(BINDIR) "$(EXEC_SUFFIX)"
415
416 install_library:
417         $(SAFE_INSTALL) $(BINARY_INSTALL_ARGS) $(LIBBC) $(DESTDIR)$(LIBDIR)/$(LIB_NAME)
418
419 install:%%INSTALL_LOCALES_PREREQS%%%%INSTALL_MAN_PREREQS%%%%INSTALL_PREREQS%%
420
421 uninstall_locales:
422         $(LOCALE_UNINSTALL) $(NLSPATH) $(MAIN_EXEC) $(DESTDIR)
423
424 uninstall_bc_manpage:
425         $(RM) -f $(DESTDIR)$(MAN1DIR)/$(BC_MANPAGE_NAME)
426
427 uninstall_bc:
428         $(RM) -f $(DESTDIR)$(BINDIR)/$(EXEC_PREFIX)$(BC)$(EXEC_SUFFIX)
429
430 uninstall_dc_manpage:
431         $(RM) -f $(DESTDIR)$(MAN1DIR)/$(DC_MANPAGE_NAME)
432
433 uninstall_dc:
434         $(RM) -f $(DESTDIR)$(BINDIR)/$(EXEC_PREFIX)$(DC)$(EXEC_SUFFIX)
435
436 uninstall_library:
437         $(RM) -f $(DESTDIR)$(LIBDIR)/$(LIB_NAME)
438
439 uninstall_bcl_header:
440         $(RM) -f $(DESTDIR)$(INCLUDEDIR)/$(BCL_HEADER_NAME)
441
442 uninstall_bcl_manpage:
443         $(RM) -f $(DESTDIR)$(MAN3DIR)/$(BCL_MANPAGE_NAME)
444
445 uninstall:%%UNINSTALL_LOCALES_PREREQS%%%%UNINSTALL_MAN_PREREQS%%%%UNINSTALL_PREREQS%%