-
Notifications
You must be signed in to change notification settings - Fork 5
/
finale.mak
384 lines (315 loc) · 11.8 KB
/
finale.mak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# Copyright (C) 2011 Erik Rainey
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Set the default values if not defined or empty string
ifndef VERSION
VERSION := 1.0
else ifeq ($(VERSION),)
VERSION := 1.0
endif
POST_MODULE_PLUGINS:=$(call rwildcard,$(CONCERTO_ROOT)/components/post-module-plugins/,*.mak)
ifeq ($(SHOW_MAKEDEBUG),1)
$(info POST_MODULE_PLUGINS=$(POST_MODULE_PLUGINS))
endif
-include $(POST_MODULE_PLUGINS)
-include $(CONCERTO_ROOT)/packages.mak
# Users may use the new syntax of all variables starting with "MODULE_" but may not quite
# yet so don't erase the value if it's set.
#$(foreach mvar,$(_MODULE_VARS),$(if $(MODULE_$(mvar)),,$(eval MODULE_$(mvar):=$(value $(mvar)))))
ifeq ($(SHOW_MAKEDEBUG),1)
$(info #### $(_MODULE) ########################################################)
$(foreach mvar,$(sort $(_MODULE_VARS)),\
$(if $(value $(mvar)),\
$(info $(mvar)=$(value $(mvar)))))
$(foreach mvar,$(sort $(filter MODULE_%,$(.VARIABLES))), \
$(if $(value $(mvar)),\
$(info $(mvar)=$(value $(mvar)))))
endif
$(_MODULE)_TARGET := $(TARGET)
CONCERTO_TARGETS += $(if $(filter $(CONCERTO_TARGETS),$(TARGET)),,$($(_MODULE)_TARGET))
# Add the paths from the makefile
$(_MODULE)_IDIRS += $(SYSIDIRS) $(IDIRS)
$(_MODULE)_LDIRS += $(LDIRS) $($(TARGET_COMBO_NAME)_LDIRS) $(SYSLDIRS)
# Add any additional libraries which are in this build system
$(_MODULE)_STATIC_LIBS += $(STATIC_LIBS)
$(if $(filter library,$(TARGETTYPE)),\
$(eval $(TARGET)_DEPENDENT_LIBS=$($(_MODULE)_STATIC_LIBS) \
$(foreach lib,$($(_MODULE)_STATIC_LIBS),$($(lib)_DEPENDENT_LIBS) )) \
,)
$(_MODULE)_SHARED_LIBS += $(SHARED_LIBS)
$(_MODULE)_SYS_STATIC_LIBS += $(SYS_STATIC_LIBS)
$(_MODULE)_SYS_SHARED_LIBS += $(SYS_SHARED_LIBS)
$(_MODULE)_JAVA_LIBS += $(JAVA_LIBS)
$(_MODULE)_BINS += $(BINS)
$(_MODULE)_INCS += $(INCS)
ifdef INC_SUBPATH
$(_MODULE)_INC_SUBPATH := $(INC_SUBPATH)
else
$(_MODULE)_INC_SUBPATH := $(TARGET)
endif
$(_MODULE)_HEADERS := $(HEADERS)
# Copy over the rest of the variables
$(_MODULE)_TYPE := $(strip $(TARGETTYPE))
$(_MODULE)_TDEFS := $(TARGET_DEFS)
$(_MODULE)_DEFS := $(SYSDEFS) $(DEFS) $($(TARGET_COMBO_NAME)_DEFS)
$(_MODULE)_TESTPRGM := $(TESTPRGM)
$(_MODULE)_TESTOPTS := $(TESTOPTS)
$(_MODULE)_TESTPATH := $(TESTPATH)
$(_MODULE)_VERSION := $(VERSION)
# Set the Install Path
$(_MODULE)_INSTALL_PATH = $(INSTALL_PATH)
# Create a big list of all sources files
$(_MODULE)_SRCS := $(strip $(CSOURCES) $(CPPSOURCES) $(ASSEMBLY) $(JSOURCES) $(CUSOURCES) $(SOURCES))
ifneq ($(SKIPBUILD),1)
NEEDS_COMPILER:=
NEEDS_INSTALL :=
ifeq ($($(_MODULE)_TYPE),library)
NEEDS_COMPILER=1
# no install for libs
else ifeq ($($(_MODULE)_TYPE),dsmo)
NEEDS_COMPILER=1
NEEDS_INSTALL=1
else ifeq ($($(_MODULE)_TYPE),exe)
NEEDS_COMPILER=1
NEEDS_INSTALL=1
else ifeq ($($(_MODULE)_TYPE),jar)
include $(CONCERTO_ROOT)/compilers/java.mak
else ifeq ($($(_MODULE)_TYPE),opencl_kernel)
include $(CONCERTO_ROOT)/compilers/opencl.mak
else ifeq ($($(_MODULE)_TYPE),deb)
include $(CONCERTO_ROOT)/tools/dpkg.mak
else ifeq ($($(_MODULE)_TYPE),tar)
include $(CONCERTO_ROOT)/tools/tar.mak
else ifeq ($($(_MODULE)_TYPE),doxygen)
include $(CONCERTO_ROOT)/tools/doxygen.mak
else ifeq ($($(_MODULE)_TYPE),latex)
include $(CONCERTO_ROOT)/tools/latex.mak
else ifeq ($($(_MODULE)_TYPE),prebuilt)
NEEDS_COMPILER=0
NEEDS_INSTALL=1
else
$(error Unknown module type $($(_MODULE)_TYPE) from $(THIS_MAKEFILE))
# \todo add new build types here!
endif
ifeq ($(NEEDS_COMPILER),1)
# which compiler does this need?
ifeq ($(SHOW_MAKEDEBUG),1)
$(info Using HOST_COMPILER = '$(HOST_COMPILER)' for $(_MODULE))
endif
ifdef LOGFILE
LOGGING:= $(REDIR)$(LOGFILE)
else
LOGGING:=
endif
ifeq ($(HOST_COMPILER),GCC)
include $(CONCERTO_ROOT)/compilers/gcc.mak
else ifeq ($(HOST_COMPILER),CLANG)
include $(CONCERTO_ROOT)/compilers/clang.mak
else ifeq ($(HOST_COMPILER),CL)
include $(CONCERTO_ROOT)/compilers/cl.mak
else ifeq ($(HOST_COMPILER),RVCT)
include $(CONCERTO_ROOT)/compilers/rvct.mak
else ifeq ($(HOST_COMPILER),CGT6X)
include $(CONCERTO_ROOT)/compilers/cgt6x.mak
else ifeq ($(HOST_COMPILER),CGTPRU)
include $(CONCERTO_ROOT)/compilers/cgtpru.mak
else ifeq ($(HOST_COMPILER),QCC)
include $(CONCERTO_ROOT)/compilers/qcc.mak
else ifeq ($(HOST_COMPILER),TMS470)
include $(CONCERTO_ROOT)/compilers/tms470.mak
else ifeq ($(HOST_COMPILER),TIARMCGT)
include $(CONCERTO_ROOT)/compilers/tiarmcgt.mak
else ifeq ($(HOST_COMPILER),NVCC)
include $(CONCERTO_ROOT)/compilers/nvcc.mak
else ifeq ($(HOST_COMPILER),)
$(error HOST_COMPILER $(origin HOST_COMPILER))
else ifeq ($(filter $(HOST_COMPILER),GCC CLANG CL RVCT CGT6X CGTPRU QCC TMS470 TIARMCGT NVCC),)
$(error HOST_COMPILER => $(HOST_COMPILER) is unknown)
endif
endif
ifeq ($(NEEDS_INSTALL),1)
ifeq ($(TARGET_OS),Windows_NT)
include $(CONCERTO_ROOT)/os/windows.mak
else
include $(CONCERTO_ROOT)/os/posix.mak
endif
endif
else # SKIPBUILD=1
$(info Build Skipped for $(_MODULE):$($(_MODULE)_TARGET))
endif # ifneq SKIPBUILD
# Reset Skipbuild
SKIPBUILD:=
###################################################
# RULES
###################################################
.PHONY: $(_MODULE)_copy
# assume that $2 is a directory name
define $(_MODULE)_copy_op
$(_MODULE)_copy:: $(1)
$(Q)$(MKDIR) $(2)
$(Q)$(COPY) $(1) $(2)
endef
.PHONY: $(_MODULE)_output
define $(_MODULE)_output_list
$(_MODULE)_output::
@echo $(1)
endef
$(foreach bin,$($(_MODULE)_BIN),$(eval $(call $(_MODULE)_output_list,$(bin))))
.PHONY: $(TARGET)
$(TARGET):: $(_MODULE)
.PHONY: $(_MODULE)
$(_MODULE):: $($(_MODULE)_BIN)
ifneq ($($(_MODULE)_TESTPRGM),)
TESTABLE_MODULES += $(_MODULE)
TESTABLE_TARGETS += $($(_MODULE)_TARGET)
.PHONY: $(_MODULE).test
define $(_MODULE)_TESTCASE
$(_MODULE).test:: $($(_MODULE)_TDIR)/$($(_MODULE)_TESTPRGM)
$(PRINT) Running $($(_MODULE)_TESTPRGM) $($(_MODULE)_TESTOPTS)
ifeq ($(HOST_OS),Windows_NT)
$(Q)cd $($(_MODULE)_TESTPATH) && PATH=$(PATH)\;$($(_MODULE)_TDIR) $($(_MODULE)_TDIR)/$($(_MODULE)_TESTPRGM) $($(_MODULE)_TESTOPTS)
else
$(Q)cd $($(_MODULE)_TESTPATH) && LD_LIBRARY_PATH=$($(_MODULE)_TDIR) $($(_MODULE)_TDIR)/$($(_MODULE)_TESTPRGM) $($(_MODULE)_TESTOPTS)
endif
endef
$(eval $(call $(_MODULE)_TESTCASE))
endif
ifeq ($($(_MODULE)_TYPE),library)
define $(_MODULE)_BUILD_LIB
$($(_MODULE)_BIN): $($(_MODULE)_OBJS) $($(_MODULE)_STATIC_LIBS)
$(PRINT) Linking $$@
-$(Q)$(call $(_MODULE)_LINK_LIB) $(LOGGING)
endef
$(eval $(call $(_MODULE)_BUILD_LIB))
$(eval $(call $(_MODULE)_INSTALL))
$(eval $(call $(_MODULE)_BUILD))
$(eval $(call $(_MODULE)_UNINSTALL))
$(if $($(_MODULE)_BIN), \
$(if $(RELEASE_DIR), \
$(eval $(call $(_MODULE)_copy_op, $($(_MODULE)_BIN), $(RELEASE_DIR)/lib)),))
else ifeq ($($(_MODULE)_TYPE),exe)
define $(_MODULE)_BUILD_EXE
$($(_MODULE)_BIN): $($(_MODULE)_OBJS) $($(_MODULE)_STATIC_LIBS) $($(_MODULE)_SHARED_LIBS) $($(_MODULE)_DEPS)
$(PRINT) Linking $$@
-$(Q)$(call $(_MODULE)_LINK_EXE,$(call dependent-static-libs,$(_MODULE))) $(LOGGING)
endef
$(eval $(call $(_MODULE)_BUILD_EXE))
$(eval $(call $(_MODULE)_INSTALL))
$(eval $(call $(_MODULE)_BUILD))
$(eval $(call $(_MODULE)_UNINSTALL))
$(if $($(_MODULE)_BIN), \
$(if $(RELEASE_DIR), \
$(eval $(call $(_MODULE)_copy_op, $($(_MODULE)_BIN), $(RELEASE_DIR)/bin)),))
else ifeq ($($(_MODULE)_TYPE),dsmo)
define $(_MODULE)_BUILD_DSO
$($(_MODULE)_BIN): $($(_MODULE)_OBJS) $($(_MODULE)_STATIC_LIBS) $($(_MODULE)_SHARED_LIBS) $($(_MODULE)_DEPS)
$(PRINT) Linking $$@
$(Q)$(call $(_MODULE)_LINK_DSO) $(LOGGING)
-$(Q)$(call $(_MODULE)_LN_DSO)
endef
$(eval $(call $(_MODULE)_BUILD_DSO))
$(eval $(call $(_MODULE)_INSTALL))
$(eval $(call $(_MODULE)_BUILD))
$(eval $(call $(_MODULE)_UNINSTALL))
$(if $($(_MODULE)_BIN), \
$(if $(RELEASE_DIR), \
$(eval $(call $(_MODULE)_copy_op, $($(_MODULE)_BIN).$($(_MODULE)_VERSION), $(RELEASE_DIR)/lib)) \
$(eval $(call $(_MODULE)_copy_op, $($(_MODULE)_BIN), $(RELEASE_DIR)/lib)),))
else ifeq ($($(_MODULE)_TYPE),objects)
$($(_MODULE)_BIN): $($(_MODULE)_OBJS)
else ifeq ($($(_MODULE)_TYPE),prebuilt)
$(_MODULE)_BIN := $($(_MODULE)_TDIR)/$(TARGET)$(suffix $(PREBUILT))
build:: $($(_MODULE)_BIN)
#In Windows, copy does not update the timestamp, so we have to do an extra step below to update the timestamp
define $(_MODULE)_PREBUILT
$($(_MODULE)_BIN): $($(_MODULE)_SDIR)/$(1) $($(_MODULE)_TDIR)/.gitignore
@echo Copying Prebuilt binary $($(_MODULE)_SDIR)/$(1) to $($(_MODULE)_BIN)
-$(Q)$(COPY) $(call PATH_CONV,$($(_MODULE)_SDIR)/$(1) $($(_MODULE)_BIN))
ifeq ($(HOST_OS),Windows_NT)
-$(Q)cd $($(_MODULE)_TDIR) && $(COPY) $(call PATH_CONV,$($(_MODULE)_BIN))+,,
endif
$(_MODULE)_CLEAN_LNK =
endef
$(eval $(call $(_MODULE)_PREBUILT,$(PREBUILT)))
else ifeq ($($(_MODULE)_TYPE),jar)
$(eval $(call $(_MODULE)_BUILD))
else ifneq ($(filter $($(_MODULE)_TYPE),deb tar),)
$(eval $(call $(_MODULE)_PACKAGE))
else ifeq ($($(_MODULE)_TYPE),doxygen)
$(eval $(call $(_MODULE)_DOCUMENTS))
else ifeq ($($(_MODULE)_TYPE),latex)
# $($(_MODULE)_COMPILE_TOOLS) will pickup the rules
endif
define $(_MODULE)_PLATFORM_DEPS
.PHONY: $($(_MODULE)_PLATFORM_LIBS)
endef
$(eval $(call $(_MODULE)_PLATFORM_DEPS))
define $(_MODULE)_CLEAN
.PHONY: clean_target clean $(_MODULE)_clean $(_MODULE)_clean_target
clean_target:: $(_MODULE)_clean_target
clean:: $(_MODULE)_clean
$(_MODULE)_clean_target::
$(PRINT) Cleaning $(_MODULE) target $($(_MODULE)_BIN)
-$(Q)$(CLEAN) $(call PATH_CONV,$($(_MODULE)_BIN))
ifneq ($($(_MODULE)_MAP),)
$(PRINT) Cleaning $(_MODULE) target mapfile $($(_MODULE)_MAP)
-$(Q)$(CLEAN) $(call PATH_CONV,$($(_MODULE)_MAP))
endif
$(_MODULE)_clean:: $(_MODULE)_clean_target
$(PRINT) Cleaning $($(_MODULE)_ODIR)
-$(Q)$(CLEANDIR) $(call PATH_CONV,$($(_MODULE)_ODIR))
endef
# Include compiler generated dependency rules
# Second rule is to support module source sub-directories
define $(_MODULE)_DEPEND
-include $(1).dep
$(1)$(2): $(dir $(1)).gitignore
endef
$(foreach obj,$($(_MODULE)_OBJS),$(eval $(call $(_MODULE)_DEPEND,$(basename $(obj)),$(suffix $(obj)))))
$(eval $(call $(_MODULE)_CLEAN))
$(eval $(call $(_MODULE)_CLEAN_LNK))
$(eval $(call $(_MODULE)_COMPILE_TOOLS))
$(eval $(call $(_MODULE)_ANALYZER))
define $(_MODULE)_VARDEF
$(_MODULE)_vars::
$(PRINT) =============================================
$(PRINT) _MODULE=$(_MODULE)
$(PRINT) $(_MODULE)_TARGET=$($(_MODULE)_TARGET)
$(PRINT) $(_MODULE)_BIN =$($(_MODULE)_BIN)
$(PRINT) $(_MODULE)_OUT =$($(_MODULE)_OUT)
$(PRINT) $(_MODULE)_TYPE=$($(_MODULE)_TYPE)
$(PRINT) $(_MODULE)_OBJS=$($(_MODULE)_OBJS)
$(PRINT) $(_MODULE)_SDIR=$($(_MODULE)_SDIR)
$(PRINT) $(_MODULE)_ODIR=$($(_MODULE)_ODIR)
$(PRINT) $(_MODULE)_TDIR=$($(_MODULE)_TDIR)
$(PRINT) $(_MODULE)_SRCS=$($(_MODULE)_SRCS)
$(PRINT) $(_MODULE)_IDIRS=$($(_MODULE)_IDIRS)
$(PRINT) $(_MODULE)_LDIRS=$($(_MODULE)_LDIRS)
$(PRINT) $(_MODULE)_STATIC_LIBS=$($(_MODULE)_STATIC_LIBS)
$(PRINT) $(_MODULE)_SHARED_LIBS=$($(_MODULE)_SHARED_LIBS)
$(PRINT) $(_MODULE)_SYS_STATIC_LIBS=$($(_MODULE)_SYS_STATIC_LIBS)
$(PRINT) $(_MODULE)_SYS_SHARED_LIBS=$($(_MODULE)_SYS_SHARED_LIBS)
$(PRINT) $(_MODULE)_CLASSES=$($(_MODULES)_CLASSES)
$(PRINT) $(_MODULE)_TESTPRGM=$($(_MODULE)_TESTPRGM)
$(PRINT) $(_MODULE)_TESTOPTS=$($(_MODULE)_TESTOPTS)
$(PRINT) $(_MODULE)_TESTPATH=$($(_MODULE)_TESTPATH)
$(PRINT) $(_MODULE)_DEFS=$($(_MODULE)_DEFS)
$(PRINT) =============================================
endef
$(eval $(call $(_MODULE)_VARDEF))
ifeq ($(SHOW_MAKEDEBUG),1)
$(foreach mvar,$(sort $(filter $(_MODULE)_%,$(.VARIABLES))),$(if $(value $(mvar)),$(info $(mvar)=$(value $(mvar)))))
$(info #### $(_MODULE) ########################################################)
endif
# Now clear out the module variable for repeat definitions
_MODULE :=