Mercurial > hg > th-libs
annotate Makefile.inc @ 727:b415b70254fa
Add set_bit/test_bit helpers.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 06 Jan 2022 13:12:16 +0200 |
parents | 81714d54689c |
children | 18a19d052f94 |
rev | line source |
---|---|
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
1 ### |
599
ee165ef28b6f
Improve few Makefile comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
598
diff
changeset
|
2 ### Tools, paths and directories |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
3 ### |
446
e0cead622dce
Possibly fix external build things and llvm static analyzer runs.
Matti Hamalainen <ccr@tnsp.org>
parents:
433
diff
changeset
|
4 ifneq ($(BINTOOL_PREFIX),) |
433 | 5 CC = $(BINTOOL_PREFIX)gcc |
6 CXX = $(BINTOOL_PREFIX)g++ | |
7 AR = $(BINTOOL_PREFIX)ar | |
8 RANLIB = $(BINTOOL_PREFIX)ranlib | |
446
e0cead622dce
Possibly fix external build things and llvm static analyzer runs.
Matti Hamalainen <ccr@tnsp.org>
parents:
433
diff
changeset
|
9 else |
e0cead622dce
Possibly fix external build things and llvm static analyzer runs.
Matti Hamalainen <ccr@tnsp.org>
parents:
433
diff
changeset
|
10 CC ?= $(BINTOOL_PREFIX)gcc |
e0cead622dce
Possibly fix external build things and llvm static analyzer runs.
Matti Hamalainen <ccr@tnsp.org>
parents:
433
diff
changeset
|
11 CXX ?= $(BINTOOL_PREFIX)g++ |
e0cead622dce
Possibly fix external build things and llvm static analyzer runs.
Matti Hamalainen <ccr@tnsp.org>
parents:
433
diff
changeset
|
12 AR ?= $(BINTOOL_PREFIX)ar |
e0cead622dce
Possibly fix external build things and llvm static analyzer runs.
Matti Hamalainen <ccr@tnsp.org>
parents:
433
diff
changeset
|
13 RANLIB ?= $(BINTOOL_PREFIX)ranlib |
e0cead622dce
Possibly fix external build things and llvm static analyzer runs.
Matti Hamalainen <ccr@tnsp.org>
parents:
433
diff
changeset
|
14 endif |
e0cead622dce
Possibly fix external build things and llvm static analyzer runs.
Matti Hamalainen <ccr@tnsp.org>
parents:
433
diff
changeset
|
15 |
433 | 16 INSTALL ?= install |
17 MKDIR ?= mkdir | |
18 MKDIR_P ?= $(MKDIR) -p | |
19 | |
474 | 20 |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
21 ### |
599
ee165ef28b6f
Improve few Makefile comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
598
diff
changeset
|
22 ### Main th-libs targets |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
23 ### |
474 | 24 THLIBS_A = $(OBJPATH)thlibs.a |
25 THLIBS_DEP += $(THLIBS)th_types.h $(THLIBS)th_util.h | |
26 | |
27 | |
28 NOBUILD_TARGETS += | |
419
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 NOINST_TARGETS += $(THLIBS_A) |
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 |
474 | 31 |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
32 ### |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
33 ### Functions and compilation/link commands |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
34 ### |
482 | 35 ifneq ($(V),1) |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
36 DO_CMD=/bin/echo -E " $(1) $(2)" && $(3) |
482 | 37 else |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
38 DO_CMD=/bin/echo -E $(3) && $(3) |
482 | 39 endif |
600
492633200ddd
Check for empty target directory in DO_MKDIR Makefile macro.
Matti Hamalainen <ccr@tnsp.org>
parents:
599
diff
changeset
|
40 DO_MKDIR=if test ! -z "$(1)" -a ! -d "$(1)"; then /bin/echo -E " MKDIR $(1)"; mkdir -p "$(1)"; fi |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
41 |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
42 |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
43 COMPILE_C_OBJ = \ |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
44 @$(call DO_MKDIR,$(OBJPATH)) ; \ |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
45 $(call DO_CMD,CC,$<,$(CC) $(CFLAGS) $(DM_CFLAGS) -c -o $@ $< $(1)) |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
46 |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
47 LINK_C_BIN = \ |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
48 @$(call DO_MKDIR,$(BINPATH)) ; \ |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
49 $(call DO_CMD,LINK,$@,$(CC) -o $@ $(filter %.o %.a,$+) $(LDFLAGS) $(1)) |
419
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
51 COMPILE_CXX_OBJ = \ |
598
a6196e19465b
Oops, a output suppressor was missing from COMPILE_CXX_OBJ macro in the build system.
Matti Hamalainen <ccr@tnsp.org>
parents:
597
diff
changeset
|
52 @$(call DO_MKDIR,$(OBJPATH)) ; \ |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
53 $(call DO_CMD,CXX,$<,$(CXX) $(CXXFLAGS) $(DM_CFLAGS) -c -o $@ $< $(1)) |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
54 |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
55 LINK_CXX_BIN = \ |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
56 @$(call DO_MKDIR,$(BINPATH)) ; \ |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
57 $(call DO_CMD,LINK,$@,$(CXX) -o $@ $(filter %.o %.a,$+) $(LDFLAGS) $(1)) |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
58 |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
59 LINK_STATIC_LIB = \ |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
60 @$(call DO_MKDIR,$(OBJPATH)) ; \ |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
61 $(call DO_CMD,AR,$@ $(filter %.o,$+),$(AR) cru $@ $(filter %.o,$+)) ; \ |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
62 $(call DO_CMD,RANLIB,$@,$(RANLIB) $@) |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
63 |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
64 |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
65 ### |
599
ee165ef28b6f
Improve few Makefile comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
598
diff
changeset
|
66 ### Generic target rules |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
67 ### |
419
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 all: $(NOBUILD_TARGETS) $(NOINST_TARGETS) $(TARGETS) |
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 |
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 |
662
81714d54689c
Improve th_string.o depency chain checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
71 $(OBJPATH)th_string.o: $(addprefix $(THLIBS), \ |
81714d54689c
Improve th_string.o depency chain checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
72 th_string.c th_printf.c th_printf1.c \ |
81714d54689c
Improve th_string.o depency chain checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
73 th_strglob.c th_string.h) $(THLIBS_DEP) |
81714d54689c
Improve th_string.o depency chain checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
74 $(COMPILE_C_OBJ) |
419
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 |
474 | 76 |
77 $(OBJPATH)%.o: $(THLIBS)%.c $(THLIBS_DEP) | |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
78 $(COMPILE_C_OBJ) |
419
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 |
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
80 $(OBJPATH)%.o: $(THLIBS)%.c $(THLIBS)%.h $(THLIBS_DEP) |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
81 $(COMPILE_C_OBJ) -I$(THLIBS) |
419
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
82 |
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
83 $(OBJPATH)%.o: %.c %.h $(THLIBS_DEP) |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
84 $(COMPILE_C_OBJ) -I$(THLIBS) |
419
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 |
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 $(OBJPATH)%.o: %.c $(THLIBS_DEP) |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
87 $(COMPILE_C_OBJ) -I$(THLIBS) |
419
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
88 |
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 $(THLIBS_A): $(addprefix $(OBJPATH),$(THLIBS_OBJ)) |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
90 $(LINK_STATIC_LIB) |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
91 |
419
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
93 ### |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
94 ### Generate endian check and config.h |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
95 ### |
474 | 96 $(OBJPATH)endianchk.o: $(THLIBS)endianchk.c |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
97 $(COMPILE_C_OBJ) |
474 | 98 |
99 $(ENDIANCHK_BIN): $(OBJPATH)endianchk.o | |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
100 $(LINK_C_BIN) |
420 | 101 |
102 config.h: $(ENDIANCHK_BIN) | |
103 $(ENDIANCHK_BIN) > $@ | |
104 | |
105 | |
597
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
106 ### |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
107 ### Special targets |
00ad3f0e208b
Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents:
531
diff
changeset
|
108 ### |
419
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 clean: |
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
110 $(RM) $(TARGETS) $(NOINST_TARGETS) $(OBJPATH)*.o |
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
111 |
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
112 srcclean: clean |
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
113 $(RM) *~ |
ec109cbaddfb
Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
114 |
433 | 115 .PHONY: clean srcclean all |