annotate Makefile.gen @ 86:cc7fcaf139ef

Add ASAN build flag.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 21 May 2020 09:20:24 +0300
parents 8a56cb177711
children 22774e3f2a89
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 ###
86
cc7fcaf139ef Add ASAN build flag.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
4 ifneq ($(ASAN),)
cc7fcaf139ef Add ASAN build flag.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
5 CXXFLAGS += -fsanitize=address
cc7fcaf139ef Add ASAN build flag.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
6 LDFLAGS += -lasan
cc7fcaf139ef Add ASAN build flag.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
7 else
cc7fcaf139ef Add ASAN build flag.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
8 CXXFLAGS += -O3
42
3c7e1d3fa5a2 Implement OpengL extension handling through new header file dmglexts.h to
Matti Hamalainen <ccr@tnsp.org>
parents: 41
diff changeset
9 LDFLAGS +=
86
cc7fcaf139ef Add ASAN build flag.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
10 endif
cc7fcaf139ef Add ASAN build flag.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
11
cc7fcaf139ef Add ASAN build flag.
Matti Hamalainen <ccr@tnsp.org>
parents: 79
diff changeset
12 CXXFLAGS += -g -W -Wall -std=c++11
40
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
13 CXXFLAGS += $(SDL_CFLAGS) $(GL_CFLAGS)
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
14
77
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
15
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
16 ###
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
17 ### Tools, paths and directories
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
18 ###
40
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
19 MKDIR ?= mkdir
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
20 MKDIR_P ?= $(MKDIR) -p
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
21 BINPATH ?= ./
34
c0b85b0615d2 Improve the makefiles.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22
c0b85b0615d2 Improve the makefiles.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23
77
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
24 ###
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
25 ### Main targets and objects
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
26 ###
41
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
27 BINARIES = gldragon ply2bin
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
28
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
29 TARGETS += \
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
30 $(addprefix $(BINPATH),$(addsuffix $(BINEXT),$(BINARIES)))
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
31
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
32 NOBUILD_TARGETS +=
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
33 NOINST_TARGETS +=
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
34 CLEAN_TARGETS +=
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
35 DISTCLEAN_TARGETS +=
eaa3e8575c12 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
36
34
c0b85b0615d2 Improve the makefiles.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
40
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
38 ###
77
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
39 ### Functions and compilation/link commands
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 ifneq ($(V),1)
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
42 DO_CMD=/bin/echo -E " $(1) $(2)" && $(3)
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
43 else
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
44 DO_CMD=/bin/echo -E $(3) && $(3)
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
45 endif
78
159cc5f14092 Check for empty target directory in DO_MKDIR Makefile macro.
Matti Hamalainen <ccr@tnsp.org>
parents: 77
diff changeset
46 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
47
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
48
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
49 COMPILE_C_OBJ = \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
50 @$(call DO_MKDIR,$(OBJPATH)) ; \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
51 $(call DO_CMD,CC,$<,$(CC) $(CFLAGS) $(DM_CFLAGS) -c -o $@ $< $(1))
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
52
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
53 LINK_C_BIN = \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
54 @$(call DO_MKDIR,$(BINPATH)) ; \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
55 $(call DO_CMD,LINK,$@,$(CC) -o $@ $(filter %.o %.a,$+) $(LDFLAGS) $(1))
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
56
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
57 COMPILE_CXX_OBJ = \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
58 @$(call DO_MKDIR,$(OBJPATH)) ; \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
59 $(call DO_CMD,CXX,$<,$(CXX) $(CXXFLAGS) $(DM_CFLAGS) -c -o $@ $< $(1))
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
60
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
61 LINK_CXX_BIN = \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
62 @$(call DO_MKDIR,$(BINPATH)) ; \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
63 $(call DO_CMD,LINK,$@,$(CXX) -o $@ $(filter %.o %.a,$+) $(LDFLAGS) $(1))
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 LINK_STATIC_LIB = \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
66 @$(call DO_MKDIR,$(OBJPATH)) ; \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
67 $(call DO_CMD,AR,$@ $(filter %.o,$+),$(AR) cru $@ $(filter %.o,$+)) ; \
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
68 $(call DO_CMD,RANLIB,$@,$(RANLIB) $@)
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
69
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
70
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
71 ###
cc1c35357e39 Build system cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 70
diff changeset
72 ### Generic target rules
40
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
73 ###
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
74 all: $(NOBUILD_TARGETS) $(NOINST_TARGETS) $(TARGETS)
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
75
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
76
79
8a56cb177711 Add dmglexts.h as depency to dmglrender.o
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
77 $(OBJPATH)dmglrender.o: dmglrender.cpp dmglrender.h dmglexts.h
8a56cb177711 Add dmglexts.h as depency to dmglrender.o
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
78 $(COMPILE_CXX_OBJ)
8a56cb177711 Add dmglexts.h as depency to dmglrender.o
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
79
40
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
80 $(OBJPATH)%.o: %.cpp %.h
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
81 $(COMPILE_CXX_OBJ)
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
82
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
83 $(OBJPATH)%.o: %.cpp
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
84 $(COMPILE_CXX_OBJ)
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
85
34
c0b85b0615d2 Improve the makefiles.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86
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
87 $(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
88 $(LINK_CXX_BIN) $(LDFLAGS) $(SDL_LDFLAGS) $(GL_LDFLAGS)
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
89
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
90 $(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
91 $(LINK_CXX_BIN) $(LDFLAGS) $(TOOL_LDFLAGS)
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
92
34
c0b85b0615d2 Improve the makefiles.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93
40
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
94 ###
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
95 ### Special targets
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
96 ###
34
c0b85b0615d2 Improve the makefiles.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 clean:
40
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
98 -$(RM) $(TARGETS) $(NOINST_TARGETS) $(CLEAN_TARGETS) $(OBJPATH)*.o
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
99
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
100 distclean: clean
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
101 -$(RM) $(DISTCLEAN_TARGETS) *~ core *.core
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
102
6905d02bca2d Build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
103 .PHONY: clean distclean all