Mercurial > hg > syntilista
annotate Makefile.gen @ 267:2400c2fac4b1
Add Makefile option for building with ASAN.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 13 Feb 2021 12:33:46 +0200 |
parents | f0e180b13e05 |
children | 7276fe5efff6 |
rev | line source |
---|---|
50 | 1 ### |
262 | 2 ### Compiler flags |
50 | 3 ### |
267
2400c2fac4b1
Add Makefile option for building with ASAN.
Matti Hamalainen <ccr@tnsp.org>
parents:
263
diff
changeset
|
4 CFLAGS += -W -Wall -Wextra |
2400c2fac4b1
Add Makefile option for building with ASAN.
Matti Hamalainen <ccr@tnsp.org>
parents:
263
diff
changeset
|
5 CXXFLAGS += -W -Wall -Wextra -std=c++11 |
2400c2fac4b1
Add Makefile option for building with ASAN.
Matti Hamalainen <ccr@tnsp.org>
parents:
263
diff
changeset
|
6 |
2400c2fac4b1
Add Makefile option for building with ASAN.
Matti Hamalainen <ccr@tnsp.org>
parents:
263
diff
changeset
|
7 ifneq ($(ASAN),) |
2400c2fac4b1
Add Makefile option for building with ASAN.
Matti Hamalainen <ccr@tnsp.org>
parents:
263
diff
changeset
|
8 XCFLAGS = -fsanitize=address |
2400c2fac4b1
Add Makefile option for building with ASAN.
Matti Hamalainen <ccr@tnsp.org>
parents:
263
diff
changeset
|
9 LDFLAGS += -lasan |
2400c2fac4b1
Add Makefile option for building with ASAN.
Matti Hamalainen <ccr@tnsp.org>
parents:
263
diff
changeset
|
10 else |
2400c2fac4b1
Add Makefile option for building with ASAN.
Matti Hamalainen <ccr@tnsp.org>
parents:
263
diff
changeset
|
11 XCFLAGS = -O2 |
2400c2fac4b1
Add Makefile option for building with ASAN.
Matti Hamalainen <ccr@tnsp.org>
parents:
263
diff
changeset
|
12 endif |
2400c2fac4b1
Add Makefile option for building with ASAN.
Matti Hamalainen <ccr@tnsp.org>
parents:
263
diff
changeset
|
13 |
2400c2fac4b1
Add Makefile option for building with ASAN.
Matti Hamalainen <ccr@tnsp.org>
parents:
263
diff
changeset
|
14 CFLAGS += $(XCFLAGS) |
2400c2fac4b1
Add Makefile option for building with ASAN.
Matti Hamalainen <ccr@tnsp.org>
parents:
263
diff
changeset
|
15 CXXFLAGS += $(XCFLAGS) |
184
87dfca9f704d
Move optimization and warning CFLAGS and CXXFLAGS to Makefile.gen
Matti Hamalainen <ccr@tnsp.org>
parents:
157
diff
changeset
|
16 |
262 | 17 |
18 ### | |
19 ### Tools, paths and directories | |
20 ### | |
208
e6a2658ae096
Enable building via clang++ (tested with 5.0).
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
21 ifneq ($(BINTOOL_PREFIX),) |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 CC = $(BINTOOL_PREFIX)gcc |
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 CXX = $(BINTOOL_PREFIX)g++ |
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 AR = $(BINTOOL_PREFIX)ar |
208
e6a2658ae096
Enable building via clang++ (tested with 5.0).
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
25 endif |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 RANLIB = $(BINTOOL_PREFIX)ranlib |
49 | 27 WINDRES = $(BINTOOL_PREFIX)windres |
28 | |
262 | 29 |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 INSTALL ?= install |
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 MKDIR ?= mkdir |
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 MKDIR_P ?= $(MKDIR) -p |
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 |
262 | 34 |
35 ### | |
36 ### Main targets and objects | |
37 ### | |
234 | 38 DEFINES += -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG \ |
39 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_SQL_LIB \ | |
40 -DQT_CORE_LIB | |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 |
50 | 42 # Application stuff |
80
c8fd927cd2c4
Restructure the project by placing source code, images into appropriate
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
43 APP_IMG=img/ |
263
f0e180b13e05
More build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
262
diff
changeset
|
44 APP_BIN=$(BINPATH)Syntilista$(BINEXT) |
233 | 45 |
46 APP_HDRS=\ | |
47 src/main.h \ | |
246
43a5e09bb832
Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
242
diff
changeset
|
48 src/util.h \ |
233 | 49 src/ui_viewtransactions.h \ |
50 src/ui_mainwindow.h \ | |
51 src/ui_editperson.h \ | |
52 src/ui_aboutwindow.h | |
53 | |
237
54ab3f3e28c0
Split EditPerson and ViewTransactions to separate source files.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
54 APP_OBJS=\ |
54ab3f3e28c0
Split EditPerson and ViewTransactions to separate source files.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
55 main.o \ |
246
43a5e09bb832
Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
242
diff
changeset
|
56 util.o \ |
237
54ab3f3e28c0
Split EditPerson and ViewTransactions to separate source files.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
57 editperson.o \ |
54ab3f3e28c0
Split EditPerson and ViewTransactions to separate source files.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
58 viewtransactions.o \ |
242
3d3ba5759cac
Move about-window code to separate file.
Matti Hamalainen <ccr@tnsp.org>
parents:
238
diff
changeset
|
59 aboutwindow.o \ |
237
54ab3f3e28c0
Split EditPerson and ViewTransactions to separate source files.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
60 sqlmodels.o \ |
54ab3f3e28c0
Split EditPerson and ViewTransactions to separate source files.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
61 printing.o \ |
54ab3f3e28c0
Split EditPerson and ViewTransactions to separate source files.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
62 resources.o \ |
54ab3f3e28c0
Split EditPerson and ViewTransactions to separate source files.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
63 moc_main.o \ |
54ab3f3e28c0
Split EditPerson and ViewTransactions to separate source files.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
64 runguard.o |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 |
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 LOGO_SVG ?= kampuscafe4.svg |
192
dfe5e8d7c58a
Use the finalized Cafe Kampus logo.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
67 LOGO_IMG ?= CafeKampus_logo_FINAL_RGB.png |
52 | 68 ICON_PNGS = icon-64.png icon-48.png icon-32.png icon-16.png |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 |
231
e90dba0cd12a
Implement HTML stuff for about dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
228
diff
changeset
|
70 APP_RESOURCES += $(addprefix $(APP_IMG),logo.png $(ICON_PNGS)) COPYING.html |
56 | 71 |
50 | 72 # And target lists |
49 | 73 TARGETS = $(APP_BIN) |
258 | 74 NOBUILD_TARGETS += |
81
810ca71af506
Improve 'clean' target handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
75 NOINST_TARGETS += |
233 | 76 CLEAN_TARGETS += icon.ico src/moc_*.cpp src/ui_*.h |
81
810ca71af506
Improve 'clean' target handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
77 DISTCLEAN_TARGETS += |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
78 |
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 |
233 | 80 # Version |
81 APP_VERSION := $(shell cat VERSION) | |
82 comma:= , | |
83 APP_VERSION_COM := $(subst .,$(comma),$(APP_VERSION)) | |
84 CXXFLAGS += -DAPP_VERSION=\"$(APP_VERSION)\" | |
85 | |
86 | |
262 | 87 ### |
88 ### Functions and compilation/link commands | |
89 ### | |
258 | 90 ifneq ($(V),1) |
262 | 91 DO_CMD=/bin/echo -E " $(1) $(2)" && $(3) |
258 | 92 else |
262 | 93 DO_CMD=/bin/echo -E $(3) && $(3) |
258 | 94 endif |
263
f0e180b13e05
More build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
262
diff
changeset
|
95 DO_MKDIR=if test ! -z "$(1)" -a ! -d "$(1)"; then /bin/echo -E " MKDIR $(1)"; mkdir -p "$(1)"; fi |
262 | 96 |
97 | |
98 COMPILE_C_OBJ = \ | |
99 @$(call DO_MKDIR,$(OBJPATH)) ; \ | |
100 $(call DO_CMD,CC,$<,$(CC) $(CFLAGS) $(DM_CFLAGS) -c -o $@ $< $(1)) | |
101 | |
102 LINK_C_BIN = \ | |
103 @$(call DO_MKDIR,$(BINPATH)) ; \ | |
104 $(call DO_CMD,LINK,$@,$(CC) -o $@ $(filter %.o %.a,$+) $(LDFLAGS) $(1)) | |
105 | |
106 COMPILE_CXX_OBJ = \ | |
107 @$(call DO_MKDIR,$(OBJPATH)) ; \ | |
108 $(call DO_CMD,CXX,$<,$(CXX) $(CXXFLAGS) $(DM_CFLAGS) -c -o $@ $< $(1)) | |
109 | |
110 LINK_CXX_BIN = \ | |
111 @$(call DO_MKDIR,$(BINPATH)) ; \ | |
112 $(call DO_CMD,LINK,$@,$(CXX) -o $@ $(filter %.o %.a,$+) $(LDFLAGS) $(1)) | |
113 | |
114 LINK_STATIC_LIB = \ | |
115 @$(call DO_MKDIR,$(OBJPATH)) ; \ | |
116 $(call DO_CMD,AR,$@ $(filter %.o,$+),$(AR) cru $@ $(filter %.o,$+)) ; \ | |
117 $(call DO_CMD,RANLIB,$@,$(RANLIB) $@) | |
258 | 118 |
119 | |
50 | 120 ### |
262 | 121 ### Generic target rules |
50 | 122 ### |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
123 all: $(NOBUILD_TARGETS) $(NOINST_TARGETS) $(TARGETS) |
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
124 |
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
125 |
50 | 126 moc_predefs.h: |
127 @echo "" > $(OBJPATH)dummy.cpp | |
263
f0e180b13e05
More build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
262
diff
changeset
|
128 @$(call DO_CMD,CXX,$@,$(CXX) $(CXXFLAGS) -dM -E -o $@ $(OBJPATH)dummy.cpp) |
50 | 129 |
130 moc_%.cpp: %.h $(QT_MOC_RULES) | |
263
f0e180b13e05
More build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
262
diff
changeset
|
131 @$(call DO_CMD,Qt:MOC,$@ $<,$(QT_MOC) $(DEFINES) $(QT_MOC_FLAGS) $(INCPATH) $< -o $@) |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
132 |
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
133 ui_%.h: %.ui |
263
f0e180b13e05
More build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
262
diff
changeset
|
134 @$(call DO_CMD,Qt:UIC,$@ $<,$(QT_UIC) $(QT_UIC_FLAGS) $< -o $@) |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
135 |
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
136 |
233 | 137 $(OBJPATH)%.o: src/%.cpp src/%.h |
258 | 138 $(COMPILE_CXX_OBJ) $(DEFINES) $(INCPATH) |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
139 |
233 | 140 $(OBJPATH)%.o: src/%.cpp |
258 | 141 $(COMPILE_CXX_OBJ) $(DEFINES) $(INCPATH) |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
142 |
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
143 |
50 | 144 ### |
145 ### Windows specific rules | |
146 ### | |
56 | 147 %.rc: %.rc.in icon.ico VERSION |
50 | 148 @sed -e "s/@APP_VERSION@/$(APP_VERSION)/g;s/@APP_VERSION_COM@/$(APP_VERSION_COM)/g;s#@APP_EXE@#$(notdir $(APP_BIN))#g" < $< > $@ |
49 | 149 |
233 | 150 $(OBJPATH)%.o: src/%.rc |
263
f0e180b13e05
More build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
262
diff
changeset
|
151 @$(call DO_CMD,WINDRES,$<,$(WINDRES) $< -O coff -o $@) |
49 | 152 |
153 | |
154 ### | |
155 ### Application rules | |
156 ### | |
192
dfe5e8d7c58a
Use the finalized Cafe Kampus logo.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
157 #$(APP_IMG)icon-%.png: $(addprefix $(APP_IMG),$(LOGO_SVG)) |
dfe5e8d7c58a
Use the finalized Cafe Kampus logo.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
158 # inkscape --export-area-page -w $(patsubst $(APP_IMG)icon-%.png,%,$@) -h $(patsubst $(APP_IMG)icon-%.png,%,$@) -e "$@" "$<" |
dfe5e8d7c58a
Use the finalized Cafe Kampus logo.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
159 |
dfe5e8d7c58a
Use the finalized Cafe Kampus logo.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
160 #$(APP_IMG)logo.png: $(addprefix $(APP_IMG),$(LOGO_SVG)) |
dfe5e8d7c58a
Use the finalized Cafe Kampus logo.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
161 # inkscape --export-area-page -w 258 -h 220 -e "$@" "$<" |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
162 |
192
dfe5e8d7c58a
Use the finalized Cafe Kampus logo.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
163 $(APP_IMG)icon-%.png: $(addprefix $(APP_IMG),$(LOGO_IMG)) |
dfe5e8d7c58a
Use the finalized Cafe Kampus logo.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
164 convert "$<" -scale "$(patsubst $(APP_IMG)icon-%.png,%,$@)x$(patsubst $(APP_IMG)icon-%.png,%,$@)" "$@" |
dfe5e8d7c58a
Use the finalized Cafe Kampus logo.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
165 |
dfe5e8d7c58a
Use the finalized Cafe Kampus logo.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
166 $(APP_IMG)logo.png: $(addprefix $(APP_IMG),$(LOGO_IMG)) |
dfe5e8d7c58a
Use the finalized Cafe Kampus logo.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
167 convert "$<" -scale "258x220" "$@" |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
168 |
80
c8fd927cd2c4
Restructure the project by placing source code, images into appropriate
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
169 icon.ico: $(addprefix $(APP_IMG),$(ICON_PNGS)) |
263
f0e180b13e05
More build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
262
diff
changeset
|
170 @$(call DO_CMD,CONVERT,$+ -> $@,convert $+ $@) |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
171 |
233 | 172 src/%.cpp: src/%.qrc $(APP_RESOURCES) |
263
f0e180b13e05
More build system improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
262
diff
changeset
|
173 @$(call DO_CMD,Qt:RCC,$@ $<,$(QT_RCC) -name "Syntilista" $< -o $@) |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
174 |
233 | 175 $(OBJPATH)main.o: src/main.cpp $(APP_HDRS) VERSION |
258 | 176 $(COMPILE_CXX_OBJ) $(DEFINES) $(INCPATH) |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
177 |
52 | 178 $(APP_BIN): $(addprefix $(OBJPATH),$(APP_OBJS)) $(APP_DEP_LIBS) | $(APP_DEPS) |
259 | 179 $(LINK_CXX_BIN) $(APP_LIBS) |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
180 |
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
181 |
50 | 182 ### |
183 ### Special targets | |
184 ### | |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
185 clean: |
81
810ca71af506
Improve 'clean' target handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
186 -$(RM) $(TARGETS) $(NOINST_TARGETS) $(CLEAN_TARGETS) $(OBJPATH)*.o |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
187 |
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
188 distclean: clean |
52 | 189 -$(RM) $(DISTCLEAN_TARGETS) *~ core *.core |
48
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
190 |
200ec310660a
Begin revamp of the buildsystem, don't use qmake anymore.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
191 .PHONY: clean distclean all |