annotate Makefile.gen @ 78:159cc5f14092

Check for empty target directory in DO_MKDIR Makefile macro.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 14 Jan 2020 03:28:06 +0200
parents cc1c35357e39
children 8a56cb177711
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
77
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
1 ###
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
2 ### Compiler flags
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
3 ###
42
3c7e1d3fa5a2 Implement OpengL extension handling through new header file dmglexts.h to
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
4 CXXFLAGS += -O3 -W -Wall -std=c++11
3c7e1d3fa5a2 Implement OpengL extension handling through new header file dmglexts.h to
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
5 LDFLAGS +=
40
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
6 CXXFLAGS += $(SDL_CFLAGS) $(GL_CFLAGS)
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
7
77
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
8
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
9 ###
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
10 ### Tools, paths and directories
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
11 ###
40
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
12 MKDIR ?= mkdir
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
13 MKDIR_P ?= $(MKDIR) -p
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
14 BINPATH ?= ./
34
c0b85b0615d2 Improve the makefiles.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15
c0b85b0615d2 Improve the makefiles.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16
77
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
17 ###
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
18 ### Main targets and objects
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
19 ###
41
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
20 BINARIES = gldragon ply2bin
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
21
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
22 TARGETS += \
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
23 $(addprefix $(BINPATH),$(addsuffix $(BINEXT),$(BINARIES)))
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
24
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
25 NOBUILD_TARGETS +=
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
26 NOINST_TARGETS +=
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
27 CLEAN_TARGETS +=
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
28 DISTCLEAN_TARGETS +=
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
29
34
c0b85b0615d2 Improve the makefiles.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30
40
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
31 ###
77
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
32 ### Functions and compilation/link commands
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
33 ###
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
34 ifneq ($(V),1)
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
35 DO_CMD=/bin/echo -E " $(1) $(2)" && $(3)
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
36 else
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
37 DO_CMD=/bin/echo -E $(3) && $(3)
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
38 endif
78
159cc5f14092 Check for empty target directory in DO_MKDIR Makefile macro.
Matti Hamalainen <ccr@tnsp.org>
parents: 77
diff changeset
39 DO_MKDIR=if test ! -z "$(1)" -a ! -d "$(1)"; then /bin/echo -E " MKDIR $(1)"; mkdir -p "$(1)"; fi
77
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
40
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
41
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
42 COMPILE_C_OBJ = \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
43 @$(call DO_MKDIR,$(OBJPATH)) ; \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
44 $(call DO_CMD,CC,$<,$(CC) $(CFLAGS) $(DM_CFLAGS) -c -o $@ $< $(1))
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
45
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
46 LINK_C_BIN = \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
47 @$(call DO_MKDIR,$(BINPATH)) ; \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
48 $(call DO_CMD,LINK,$@,$(CC) -o $@ $(filter %.o %.a,$+) $(LDFLAGS) $(1))
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
49
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
50 COMPILE_CXX_OBJ = \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
51 @$(call DO_MKDIR,$(OBJPATH)) ; \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
52 $(call DO_CMD,CXX,$<,$(CXX) $(CXXFLAGS) $(DM_CFLAGS) -c -o $@ $< $(1))
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
53
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
54 LINK_CXX_BIN = \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
55 @$(call DO_MKDIR,$(BINPATH)) ; \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
56 $(call DO_CMD,LINK,$@,$(CXX) -o $@ $(filter %.o %.a,$+) $(LDFLAGS) $(1))
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
57
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
58 LINK_STATIC_LIB = \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
59 @$(call DO_MKDIR,$(OBJPATH)) ; \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
60 $(call DO_CMD,AR,$@ $(filter %.o,$+),$(AR) cru $@ $(filter %.o,$+)) ; \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
61 $(call DO_CMD,RANLIB,$@,$(RANLIB) $@)
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
62
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
63
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
64 ###
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
65 ### Generic target rules
40
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
66 ###
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
67 all: $(NOBUILD_TARGETS) $(NOINST_TARGETS) $(TARGETS)
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
68
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
69
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
70 $(OBJPATH)%.o: %.cpp %.h
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
71 $(COMPILE_CXX_OBJ)
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
72
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
73 $(OBJPATH)%.o: %.cpp
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
74 $(COMPILE_CXX_OBJ)
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
75
34
c0b85b0615d2 Improve the makefiles.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76
70
03aa729a9e90 Refactor PLY file parsing from dmscene.* to dmply.* and some helper functions into dmutil.h
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
77 $(BINPATH)gldragon$(BINEXT): $(addprefix $(OBJPATH), gldragon.o dmglrender.o dmscene.o dmply.o dmutil.o)
40
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
78 $(LINK_CXX_BIN) $(LDFLAGS) $(SDL_LDFLAGS) $(GL_LDFLAGS)
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
79
70
03aa729a9e90 Refactor PLY file parsing from dmscene.* to dmply.* and some helper functions into dmutil.h
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
80 $(BINPATH)ply2bin$(BINEXT): $(addprefix $(OBJPATH), ply2bin.o dmscene.o dmply.o dmutil.o)
40
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
81 $(LINK_CXX_BIN) $(LDFLAGS) $(TOOL_LDFLAGS)
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
82
34
c0b85b0615d2 Improve the makefiles.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83
40
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
84 ###
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
85 ### Special targets
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
86 ###
34
c0b85b0615d2 Improve the makefiles.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 clean:
40
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
88 -$(RM) $(TARGETS) $(NOINST_TARGETS) $(CLEAN_TARGETS) $(OBJPATH)*.o
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
89
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
90 distclean: clean
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
91 -$(RM) $(DISTCLEAN_TARGETS) *~ core *.core
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
92
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
93 .PHONY: clean distclean all