annotate Makefile.inc @ 600:492633200ddd

Check for empty target directory in DO_MKDIR Makefile macro.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 14 Jan 2020 03:28:53 +0200
parents ee165ef28b6f
children 5ec903f366b5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
0a2f32b8a26e Improve the build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 425
diff changeset
5 CC = $(BINTOOL_PREFIX)gcc
0a2f32b8a26e Improve the build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 425
diff changeset
6 CXX = $(BINTOOL_PREFIX)g++
0a2f32b8a26e Improve the build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 425
diff changeset
7 AR = $(BINTOOL_PREFIX)ar
0a2f32b8a26e Improve the build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 425
diff changeset
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
0a2f32b8a26e Improve the build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 425
diff changeset
16 INSTALL ?= install
0a2f32b8a26e Improve the build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 425
diff changeset
17 MKDIR ?= mkdir
0a2f32b8a26e Improve the build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 425
diff changeset
18 MKDIR_P ?= $(MKDIR) -p
0a2f32b8a26e Improve the build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 425
diff changeset
19
474
b3b8f90bbbe6 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 472
diff changeset
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
b3b8f90bbbe6 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 472
diff changeset
24 THLIBS_A = $(OBJPATH)thlibs.a
b3b8f90bbbe6 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 472
diff changeset
25 THLIBS_DEP += $(THLIBS)th_types.h $(THLIBS)th_util.h
b3b8f90bbbe6 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 472
diff changeset
26
b3b8f90bbbe6 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 472
diff changeset
27
b3b8f90bbbe6 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 472
diff changeset
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
b3b8f90bbbe6 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 472
diff changeset
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
1013ddd2759b Add verbose build option.
Matti Hamalainen <ccr@tnsp.org>
parents: 474
diff changeset
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
1013ddd2759b Add verbose build option.
Matti Hamalainen <ccr@tnsp.org>
parents: 474
diff changeset
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
1013ddd2759b Add verbose build option.
Matti Hamalainen <ccr@tnsp.org>
parents: 474
diff changeset
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
531
f43c961cc85d Move bulk of the printf() implementation into a separate file th_printf.c from th_string.c
Matti Hamalainen <ccr@tnsp.org>
parents: 482
diff changeset
71 $(THLIBS)th_string.c: $(addprefix $(THLIBS), th_printf.c th_printf1.c th_strmatch.c th_string.h)
433
0a2f32b8a26e Improve the build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 425
diff changeset
72 @touch $@
419
ec109cbaddfb Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73
474
b3b8f90bbbe6 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 472
diff changeset
74
b3b8f90bbbe6 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 472
diff changeset
75 $(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
76 $(COMPILE_C_OBJ)
419
ec109cbaddfb Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77
ec109cbaddfb Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 $(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
79 $(COMPILE_C_OBJ) -I$(THLIBS)
419
ec109cbaddfb Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80
ec109cbaddfb Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 $(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
82 $(COMPILE_C_OBJ) -I$(THLIBS)
419
ec109cbaddfb Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83
ec109cbaddfb Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 $(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
85 $(COMPILE_C_OBJ) -I$(THLIBS)
419
ec109cbaddfb Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86
ec109cbaddfb Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 $(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
88 $(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
89
419
ec109cbaddfb Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90
597
00ad3f0e208b Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
91 ###
00ad3f0e208b Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
92 ### 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
93 ###
474
b3b8f90bbbe6 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 472
diff changeset
94 $(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
95 $(COMPILE_C_OBJ)
474
b3b8f90bbbe6 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 472
diff changeset
96
b3b8f90bbbe6 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 472
diff changeset
97 $(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
98 $(LINK_C_BIN)
420
070fcb008e63 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
99
070fcb008e63 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
100 config.h: $(ENDIANCHK_BIN)
070fcb008e63 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
101 $(ENDIANCHK_BIN) > $@
070fcb008e63 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
102
070fcb008e63 Improve build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
103
597
00ad3f0e208b Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
104 ###
00ad3f0e208b Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
105 ### Special targets
00ad3f0e208b Improve build system, clean up the functions and improve V=1 verbosity.
Matti Hamalainen <ccr@tnsp.org>
parents: 531
diff changeset
106 ###
419
ec109cbaddfb Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 clean:
ec109cbaddfb Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 $(RM) $(TARGETS) $(NOINST_TARGETS) $(OBJPATH)*.o
ec109cbaddfb Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109
ec109cbaddfb Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 srcclean: clean
ec109cbaddfb Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 $(RM) *~
ec109cbaddfb Split some build stuff into Makefile.inc
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112
433
0a2f32b8a26e Improve the build system.
Matti Hamalainen <ccr@tnsp.org>
parents: 425
diff changeset
113 .PHONY: clean srcclean all