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