1 #############################################################################
2 #############################################################################
4 ## Here are the mmakefile macros that are used as commands in the body ##
6 ## They are used to help the portability of mmakefiles to different ##
7 ## platforms and also will handle the error handling in a standard way. ##
9 #############################################################################
10 #############################################################################
12 #------------------------------------------------------------------------------
13 # Convert the ISO-8859-1 string in %(string) to the host's locale (if necessary)
14 %define localisestr string= var=
15 ifeq (,$(findstring "ISO-8859-1",$(LOCALE)))
16 %(var) := $(shell echo %(string) | iconv -f iso-8859-1 )
22 #------------------------------------------------------------------------------
23 # Compile the file %(from) to %(to) with %(cmd). Write any errors to %(err)
24 # and use the options in %(opt). Use %(iquote) and %(iquote_end) for supplying -iquote or -I- flags
25 %define compile_q cmd="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" opt="$(strip $(CFLAGS) $(CPPFLAGS))" from=$< to=$@ iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
26 $(Q)$(ECHO) "Compiling $(if $(filter /%,%(from)),$(if $(filter $(SRCDIR)/%,$(abspath %(from))),$(patsubst $(SRCDIR)/%,%,$(abspath %(from))),$(patsubst $(TOP)/%,%,$(abspath %(from)))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/%(from))))"
27 $(Q)$(IF) %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -D__SRCFILENAME__="\"$(subst $(TOP)/,,$(subst $(SRCDIR)/,,$(abspath %(from))))"\" -c %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
28 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
29 $(ECHO) "%(from): %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -D__SRCFILENAME__=\"$(subst $(TOP)/,,$(subst $(SRCDIR)/,,$(abspath %(from))))\" -c %(from) -o %(to)" >> $(GENDIR)/errors ; \
30 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors ; \
35 $(ECHO) "Compile failed: %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -D__SRCFILENAME__=\"$(subst $(TOP)/,,$(subst $(SRCDIR)/,,$(abspath %(from))))\" -c %(from) -o %(to)" 1>&2 ; \
36 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
40 #------------------------------------------------------------------------------
43 #------------------------------------------------------------------------------
44 # Assemble the file %(from) to %(to) with %(cmd) with the options in %(opt).
45 %define assemble_q cmd="$(strip $(CC) $(TARGET_SYSROOT))" opt="$(strip $(AFLAGS) $(CPPFLAGS))" from=$< to=$@
46 $(Q)$(ECHO) "Assembling $(notdir %(from))..."
47 $(Q)$(IF) %(cmd) %(opt) %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
48 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
49 $(ECHO) "$(notdir %(from)): %(cmd) %(opt) %(from) -o %(to)" >> $(GENDIR)/errors ; \
50 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
55 $(ECHO) "Assemble failed: %(cmd) %(opt) %(from) -o %(to)" 1>&2 ; \
56 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
60 #-------------------------------------------------------------------------
63 #------------------------------------------------------------------------------
64 # Link a specified number of objects to an executable
65 %define link_q cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" opt=$(LDFLAGS) from=$< to=$@ libs=$(LIBS) strip=$(STRIP) objdir=$(GENDIR)/$(CURDIR) coverageinstr=
66 $(Q)$(eval LINKTARGET=%(to))
67 $(Q)$(ECHO) "Linking $(subst $(TARGETDIR)/,,$(LINKTARGET))..."
68 $(Q)$(eval LINKTMPFILE=%(objdir)/$(notdir $(LINKTARGET)))
69 $(Q)$(IF) %(cmd) %(from) -o $(LINKTMPFILE) %(opt) %(libs) 2>&1 > $(GENDIR)/cerrors 2>&1 ; then \
70 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
71 $(ECHO) "$(LINKTARGET): %(cmd) %(from) -o $(LINKTARGET) %(opt) %(libs)" >> $(GENDIR)/errors ; \
72 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
76 $(CP) $(LINKTMPFILE) $(LINKTARGET) ; \
78 $(ECHO) "Link failed: %(cmd) %(from) -o $(LINKTARGET) %(opt) %(libs)" 1>&2 ; \
79 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
82 $(Q)$(IF) [ "$(DEBUG)" = "yes" ]; then \
83 %(strip) $(LINKTARGET) --only-keep-debug -o $(LINKTARGET).dbg ; \
85 $(Q)%(strip) $(LINKTARGET)
86 $(Q)$(IF) [ "$(DEBUG)" = "yes" ]; then \
87 $(IF) $(TEST) -s $(LINKTARGET).dbg ; then \
88 $(OBJCOPY) --add-gnu-debuglink=$(LINKTARGET).dbg $(LINKTARGET) ; \
91 $(Q)$(IF) [ "%(coverageinstr)" = "yes" ]; then \
92 LINKBASEFILES="$(strip $(notdir $(basename %(from))))" ; \
93 $(FOR) covext in $(TARGET_COVERAGEINSTR_EXTS) ; do \
94 $(FOR) file in $$LINKBASEFILES ; do \
95 COVERAGEFILE=`echo $$file$$covext` ; \
96 $(IF) $(TEST) -s %(objdir)/$$COVERAGEFILE ; then \
97 $(CP) %(objdir)/$$COVERAGEFILE $(dir $(LINKTARGET))$$COVERAGEFILE ; \
103 #------------------------------------------------------------------------------
106 #-------------------------------------------------------------------------
107 # Link a module based upon a number of arguments and the standard $(LIBS)
108 # and $(DEPLIBS) make variables.
110 %define link_module_q cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" err="$(notdir $@).err" objs=/A endtag= module=$(MODULE) ldflags=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
111 $(Q)$(ECHO) "Building $(subst $(TARGETDIR)/,,$@) ..."
112 $(Q)$(IF) %(cmd) $(NOSTARTUP_LDFLAGS) \
113 $(GENMAP) %(objdir)/%(module).map \
114 %(objs) %(libs) %(ldflags) %(endtag) \
115 -o $@ 2>&1 > %(objdir)/%(err) 2>&1 ; \
117 cat %(objdir)/%(err); \
119 echo "%(cmd) $(NOSTARTUP_LDFLAGS) $(GENMAP) %(objdir)/%(module).map %(objs) %(libs) %(ldflags) %(endtag) -o $@"; \
120 cat %(objdir)/%(err); \
123 $(Q)$(IF) $(TEST) ! -s %(objdir)/%(err) ; then $(RM) %(objdir)/%(err) ; fi
124 $(Q)$(IF) [ "$(DEBUG)" = "yes" ]; then \
125 $(STRIP) $@ --only-keep-debug -o $@.dbg; \
128 $(Q)$(IF) [ "$(DEBUG)" = "yes" ]; then \
129 $(IF) $(TEST) -s $@.dbg ; then \
130 $(OBJCOPY) --add-gnu-debuglink=$@.dbg $@; \
134 #------------------------------------------------------------------------------
137 #------------------------------------------------------------------------------
139 %define mklib_q ar=$(AR) ranlib=$(RANLIB) to=$@ from=$(OBJS)
140 $(Q)$(ECHO) "Creating $(subst $(TARGETDIR)/,,%(to))..."
141 $(Q)%(ar) %(to) %(from)
144 #------------------------------------------------------------------------------
147 #------------------------------------------------------------------------------
148 # Create the dependency file %(to) for %(from)
149 %define mkdepend_q flags="$(strip $(CFLAGS) $(CPPFLAGS))" from=$< to=$@ cc="$(strip $(AROS_CC) $(TARGET_SYSROOT))"
150 %mkdir_q dir="$(dir %(to))"
151 $(Q)$(ECHO) "Makedepend $(if $(filter /%,%(from)),$(if $(filter $(SRCDIR)/%,$(abspath %(from))),$(patsubst $(SRCDIR)/%,%,$(abspath %(from))),$(patsubst $(TOP)/%,%,$(abspath %(from)))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/%(from))))..."
152 $(Q)AROS_CC="%(cc)" $(MKDEPEND) %(flags) -I$(TOP)/$(CURDIR) -I$(SRCDIR)/$(CURDIR) %(from) -o %(to)
154 #------------------------------------------------------------------------------
157 #------------------------------------------------------------------------------
158 # Create one directory without any output
159 %define mkdir_q dir=.
160 $(Q)$(IF) $(TEST) ! -d %(dir) ; then $(MKDIR) %(dir) ; else $(NOP) ; fi
162 #------------------------------------------------------------------------------
165 #------------------------------------------------------------------------------
166 # Create several directories without any output
167 %define mkdirs_q dirs=/M
168 $(Q)$(FOR) dir in %(dirs) ; do \
169 $(IF) $(TEST) ! -d $$dir ; then $(MKDIR) $$dir ; else $(NOP) ; fi ; \
172 #------------------------------------------------------------------------------
175 #############################################################################
176 #############################################################################
178 ## Here are the mmakefile macros that are used to do certain tasks in a ##
179 ## mmakefile. They consist of one or more full makefile rules. ##
180 ## In general the files generated in these macros are also defined as ##
181 ## make targets so that they can be used as a dependency in other rules ##
183 #############################################################################
184 #############################################################################
186 #------------------------------------------------------------------------------
187 # Generate a unique id for each of the %build... rules
188 %define buildid targets=/A
190 ifneq ($(filter $(TARGET),%(targets)),)
191 BDTARGETID := $(BDID)
194 #------------------------------------------------------------------------------
197 #------------------------------------------------------------------------------
198 # Copy file %(from) to %(to) in a makefile rule
199 %define rule_copy from=/A to=/A
203 #------------------------------------------------------------------------------
206 #------------------------------------------------------------------------------
207 # Copy the files %(files) to %(targetdir). For each file in %(files),
208 # %(srcdir)/file is copied to %(targetdir)/file. The targetdir and the
209 # appropriate subdirs are not generated by this rule so they have to be
211 %define rule_copy_multi files=/A targetdir=/A srcdir=.
213 $(addprefix %(targetdir)/,%(files)) : %(targetdir)/% : %(srcdir)/%
216 #------------------------------------------------------------------------------
219 #------------------------------------------------------------------------------
220 # Copy the files %(files) to %(targetdir). For each file in %(files),
221 # %(srcdir)/file is copied to %(targetdir)/file if these files are different.
222 # %(stampfile) is used to keep track of when the last time the comparison has
223 # been done. The targetdir and the appropriate subdirs are not generated by
224 # this rule so they have to be present.
225 %define rule_copy_diff_multi files=/A targetdir=/A srcdir=. \
226 stampfile=$(TMP_SRCDIR)/.copy_stamp
228 TMP_SRCDIR := %(srcdir)
230 $(addprefix %(targetdir)/,%(files)) : | %(stampfile)
232 %(stampfile) : COPYSRCDIR := %(srcdir)
233 %(stampfile) : TGTDIR := %(targetdir)
234 %(stampfile) : FILES := %(files)
235 %(stampfile) : $(addprefix %(srcdir)/,%(files))
236 $(Q)for f in $(FILES); do \
237 $(IF) ! $(CMP) -s $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; then \
238 $(CP) $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; \
243 #------------------------------------------------------------------------------
246 #------------------------------------------------------------------------------
247 # Will join all the files in %(from) to %(to). When text is specified it will
249 # Restriction: at the moment when using a non-empty target dir %(from) may
251 %define rule_join to=/A from=/A text=
259 #------------------------------------------------------------------------------
262 #------------------------------------------------------------------------------
263 # Include the dependency files and add some internal rules
264 # When depstargets is provided the depencies will only be included when one of
265 # these targets is the $(TARGET). Otherwise the dependencies will only be
266 # included when the $(TARGET) is not for setup or clean
267 %define include_deps deps=$(DEPS)/M depstargets=
269 ifneq (%(depstargets),)
270 ifneq ($(findstring $(TARGET),%(depstargets)),)
274 ifeq (,$(filter clean% %clean %clean% setup% includes% %setup,$(TARGET)))
280 #------------------------------------------------------------------------------
283 #------------------------------------------------------------------------------
284 # Create the directories %(dirs). The creation will be done by adding rules to
285 # the %(setuptarget) make target with setup as the default.
286 %define rule_makedirs dirs=/A setuptarget=setup
288 %(setuptarget) :: %(dirs)
290 GLOB_MKDIRS += %(dirs)
293 #------------------------------------------------------------------------------
296 #------------------------------------------------------------------------------
297 # Generate a rule to compile a C source file to an object file and generate
298 # the dependency file. Basename may contain a directory part, then the source
299 # file has to be in that directory. The generated file will be put in the
300 # object directory without the directory.
302 # - basename: the basename of the file to compile. Use % for a wildcard rule
303 # - cflags (default $(CFLAGS)): the C flags to use for compilation
304 # - dflags: the flags used during creation of dependency file. If not specified
305 # the same value as cflags will be used
306 # - targetdir: the directory to put the .o file and the .d file. By default
307 # it is put in the same directory as the .c file
308 %define rule_compile mmake=TMP basename=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= targetdir= compiler=target
310 %(mmake)_NIXFLAG ?= -nix
313 %(mmake)_TARGETBASE := %(basename)
315 %(mmake)_TARGETBASE := %(targetdir)/$(notdir %(basename))
318 # Adjust compiler flags to suit C
319 %(mmake)_C_CPPFLAGS := %(cppflags)
320 %(mmake)_CFLAGS := %(cflags)
321 %(mmake)_CFLAGS := $(subst -fpermissive,, $(%(mmake)_CFLAGS))
323 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
325 %(mmake)_DFLAGS := %(dflags)
328 ifeq ($(findstring %(compiler),host kernel target),)
329 $(error unknown compiler %(compiler))
331 ifeq (%(compiler),target)
332 %(mmake)_LINK ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
333 %(mmake)_STRIP ?= $(TARGET_STRIP)
334 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
335 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
336 $(%(mmake)_TARGETBASE).o : %(mmake)_C_CPPFLAGS:=$(%(mmake)_C_CPPFLAGS)
337 $(%(mmake)_TARGETBASE).d : %(mmake)_C_CPPFLAGS:=$(%(mmake)_C_CPPFLAGS)
338 $(%(mmake)_TARGETBASE).o : %(mmake)_CFLAGS:=$(strip $(%(mmake)_CFLAGS) $(SAFETY_CFLAGS))
339 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(%(mmake)_DFLAGS)
340 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
341 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
342 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
343 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
345 ifeq (%(compiler),host)
346 %(mmake)_LINK ?= $(strip $(HOST_CC) $(HOST_LDFLAGS))
347 %(mmake)_STRIP ?= $(HOST_STRIP)
348 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(HOST_CC)
349 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(HOST_CC)
350 $(%(mmake)_TARGETBASE).o : %(mmake)_C_CPPFLAGS:=$(strip $(HOST_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS))
351 $(%(mmake)_TARGETBASE).d : %(mmake)_C_CPPFLAGS:=$(strip $(HOST_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS))
352 $(%(mmake)_TARGETBASE).o : %(mmake)_CFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_CFLAGS))
353 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_DFLAGS))
354 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
355 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
356 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
357 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
359 ifeq (%(compiler),kernel)
360 %(mmake)_LINK ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
361 %(mmake)_STRIP ?= $(ECHO) >/dev/null
362 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
363 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
364 $(%(mmake)_TARGETBASE).o : %(mmake)_C_CPPFLAGS:=$(strip $(KERNEL_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS))
365 $(%(mmake)_TARGETBASE).d : %(mmake)_C_CPPFLAGS:=$(strip $(KERNEL_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS))
366 $(%(mmake)_TARGETBASE).o : %(mmake)_CFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_CFLAGS))
367 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_DFLAGS))
368 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
369 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
370 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
371 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
374 $(%(mmake)_TARGETBASE).o : CPPFLAGS := $(%(mmake)_C_CPPFLAGS)
375 $(%(mmake)_TARGETBASE).o : CFLAGS := $(%(mmake)_CFLAGS)
376 $(%(mmake)_TARGETBASE).o : %(basename).c
377 %compile_q cmd=$(%(mmake)_CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
380 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(strip $(%(mmake)_NIXFLAG) $(%(mmake)_DFLAGS))
382 $(%(mmake)_TARGETBASE).d : %(basename).c
383 %mkdepend_q cc=$(%(mmake)_CMD) flags="$(strip $(%(mmake)_DFLAGS) $(%(mmake)_C_CPPFLAGS))"
385 #------------------------------------------------------------------------------
388 #------------------------------------------------------------------------------
389 # Generate a rule to compile a C++ source file to an object file and generate
390 # the dependency file. Basename may contain a directory part, then the source
391 # file has to be in that directory. The generated file will be put in the
392 # object directory without the directory.
394 # - basename: the basename of the file to compile. Use % for a wildcard rule
395 # - cflags (default $(CFLAGS)): the C flags to use for compilation
396 # - dflags: the flags used during creation of dependency file. If not specified
397 # the same value as cflags will be used
398 # - targetdir: the directory to put the .o file and the .d file. By default
399 # it is put in the same directory as the .c file
400 %define rule_compile_cxx mmake=TMP basename=/A cppflags=$(CPPFLAGS) cxxflags=$(CXXFLAGS) dxxflags= targetdir= compiler=target
403 %(mmake)_NIXFLAG ?= -nix
405 %(mmake)_TARGETBASE := %(basename)
407 %(mmake)_TARGETBASE := %(targetdir)/$(notdir %(basename))
410 # Adjust compiler flags to suit C++
411 %(mmake)_CXX_CPPFLAGS := %(cppflags)
412 %(mmake)_CXXFLAGS := %(cxxflags)
414 %(mmake)_DXXFLAGS := %(cxxflags)
416 %(mmake)_DXXFLAGS := %(dxxflags)
419 ifeq ($(findstring %(compiler),host kernel target),)
420 $(error unknown compiler %(compiler))
422 ifeq (%(compiler),target)
423 %(mmake)_LINK ?= $(strip $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
424 %(mmake)_STRIP ?= $(TARGET_STRIP)
425 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(AROS_CXX) $(TARGET_SYSROOT))
426 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(AROS_CXX) $(TARGET_SYSROOT))
427 $(%(mmake)_TARGETBASE).o : %(mmake)_CXX_CPPFLAGS:=$(%(mmake)_CXX_CPPFLAGS)
428 $(%(mmake)_TARGETBASE).d : %(mmake)_CXX_CPPFLAGS:=$(%(mmake)_CXX_CPPFLAGS)
429 $(%(mmake)_TARGETBASE).o : %(mmake)_CXXFLAGS:=$(strip $(%(mmake)_CXXFLAGS) $(SAFETY_CFLAGS))
430 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(%(mmake)_DXXFLAGS)
431 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
432 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
433 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
434 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
436 ifeq (%(compiler),host)
437 %(mmake)_LINK ?= $(strip $(HOST_CXX) $(HOST_LDFLAGS))
438 %(mmake)_STRIP ?= $(HOST_STRIP)
439 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(HOST_CXX)
440 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(HOST_CXX)
441 $(%(mmake)_TARGETBASE).o : %(mmake)_CXX_CPPFLAGS:=$(strip $(HOST_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS))
442 $(%(mmake)_TARGETBASE).d : %(mmake)_CXX_CPPFLAGS:=$(strip $(HOST_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS))
443 $(%(mmake)_TARGETBASE).o : %(mmake)_CXXFLAGS:=$(strip $(HOST_CXXFLAGS) $(%(mmake)_CXXFLAGS))
444 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(strip $(HOST_CXXFLAGS) $(%(mmake)_DXXFLAGS))
445 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
446 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
447 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
448 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
450 ifeq (%(compiler),kernel)
451 KERNEL_CXX ?= $(KERNEL_CC)
452 %(mmake)_LINK ?= $(strip $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
453 %(mmake)_STRIP ?= $(ECHO) >/dev/null
454 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))
455 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))
456 $(%(mmake)_TARGETBASE).o : %(mmake)_CXX_CPPFLAGS:=$(strip $(KERNEL_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS))
457 $(%(mmake)_TARGETBASE).d : %(mmake)_CXX_CPPFLAGS:=$(strip $(KERNEL_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS))
458 $(%(mmake)_TARGETBASE).o : %(mmake)_CXXFLAGS:=$(strip $(KERNEL_CXXFLAGS) $(%(mmake)_CXXFLAGS))
459 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(strip $(KERNEL_CXXFLAGS) $(%(mmake)_DXXFLAGS))
460 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
461 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
462 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
463 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
466 $(%(mmake)_TARGETBASE).o : CPPFLAGS := $(%(mmake)_CXX_CPPFLAGS)
467 $(%(mmake)_TARGETBASE).o : CXXFLAGS := $(%(mmake)_CXXFLAGS)
468 $(%(mmake)_TARGETBASE).o : %(basename).cpp
469 %compile_q cmd=$(%(mmake)_CMD) opt="$(strip $(CXXFLAGS) $(CPPFLAGS))" iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
472 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(strip $(%(mmake)_NIXFLAG) $(%(mmake)_DXXFLAGS))
474 $(%(mmake)_TARGETBASE).d : %(basename).cpp
475 %mkdepend_q cc=$(%(mmake)_CMD) flags="$(strip $(%(mmake)_DXXFLAGS) $(%(mmake)_CXX_CPPFLAGS))"
480 #------------------------------------------------------------------------------
483 #------------------------------------------------------------------------------
484 # Generate a rule to compile an ObjC source file to an object file and generate
485 # the dependency file. Basename may contain a directory part, then the source
486 # file has to be in that directory. The generated file will be put in the
487 # object directory without the directory.
489 # - basename: the basename of the file to compile. Use % for a wildcard rule
490 # - cflags (default $(CFLAGS)): the C flags to use for compilation
491 # - dflags: the flags used during creation of dependency file. If not specified
492 # the same value as cflags will be used
493 # - targetdir: the directory to put the .o file and the .d file. By default
494 # it is put in the same directory as the .m file
495 %define rule_compile_objc mmake=TMP basename=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= targetdir= compiler=target
498 %(mmake)_NIXFLAG ?= -nix
500 %(mmake)_TARGETBASE := %(basename)
502 %(mmake)_TARGETBASE := %(targetdir)/$(notdir %(basename))
505 # Adjust compiler flags to suit ObjC
506 %(mmake)_OBJC_CPPFLAGS := %(cppflags)
507 %(mmake)_OBJCFLAGS := %(cflags)
508 %(mmake)_OBJCFLAGS := $(%(mmake)_OBJCFLAGS) -isystem $(AROS_DEVELOPER)/include
509 %(mmake)_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(%(mmake)_OBJCFLAGS)))
511 %(mmake)_OBJCDFLAGS := %(cflags)
513 %(mmake)_OBJCDFLAGS := %(dflags)
516 # Define the use of cross compiler
517 ifeq ($(TARGET_OBJC),)
518 %(mmake)_CC := $(TARGET_CC)
520 %(mmake)_CC := $(TARGET_OBJC)
523 ifeq ($(findstring %(compiler),host kernel target),)
524 $(error unknown compiler %(compiler))
526 ifeq (%(compiler),target)
527 %(mmake)_LINK ?= $(strip $(%(mmake)_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
528 %(mmake)_STRIP ?= $(TARGET_STRIP)
529 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(%(mmake)_CC) $(TARGET_SYSROOT))
530 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(%(mmake)_CC) $(TARGET_SYSROOT))
531 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJC_CPPFLAGS:=$(%(mmake)_OBJC_CPPFLAGS)
532 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJC_CPPFLAGS:=$(%(mmake)_OBJC_CPPFLAGS)
533 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJCFLAGS:=$(strip $(%(mmake)_OBJCFLAGS) $(SAFETY_CFLAGS))
534 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(%(mmake)_OBJCDFLAGS)
535 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
536 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
537 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
538 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
540 ifeq (%(compiler),host)
541 %(mmake)_LINK ?= $(strip $(HOST_CC) $(HOST_LDFLAGS))
542 %(mmake)_STRIP ?= $(HOST_STRIP)
543 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(HOST_CC)
544 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(HOST_CC)
545 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJC_CPPFLAGS:=$(strip $(HOST_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS))
546 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJC_CPPFLAGS:=$(strip $(HOST_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS))
547 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJCFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCFLAGS))
548 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCDFLAGS))
549 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
550 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
551 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
552 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
554 ifeq (%(compiler),kernel)
555 %(mmake)_LINK ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
556 %(mmake)_STRIP ?= $(ECHO) >/dev/null
557 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
558 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
559 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJC_CPPFLAGS:=$(strip $(KERNEL_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS))
560 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJC_CPPFLAGS:=$(strip $(KERNEL_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS))
561 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJCFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCFLAGS))
562 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCDFLAGS))
563 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
564 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
565 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
566 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
569 $(%(mmake)_TARGETBASE).o : CPPFLAGS := $(%(mmake)_OBJC_CPPFLAGS)
570 $(%(mmake)_TARGETBASE).o : CFLAGS := $(%(mmake)_OBJCFLAGS)
571 $(%(mmake)_TARGETBASE).o : %(basename).m
572 %compile_q cmd=$(%(mmake)_CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
575 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(strip $(%(mmake)_NIXFLAG) $(%(mmake)_OBJCDFLAGS))
577 $(%(mmake)_TARGETBASE).d : %(basename).m
578 %mkdepend_q cc=$(%(mmake)_CMD) flags="$(strip $(%(mmake)_OBJCDFLAGS) $(%(mmake)_OBJC_CPPFLAGS))"
583 #------------------------------------------------------------------------------
586 #------------------------------------------------------------------------------
587 # Generate a rule to compile multiple C source files to an object file and
588 # generate the corresponding dependency files. The generated file will be put
589 # in the object directory without the directory part of the source file.
591 # - basenames: the basenames of the files to compile. The names may include
592 # relative or absolute path names. No wildcard is allowed
593 # - cflags (default $(CFLAGS)): the C flags to use for compilation
594 # - dflags: the flags used during creation of dependency file. If not specified
595 # the same value as cflags will be used
596 # - targetdir: the directory to put the .o file and the .d file. By default
597 # it is put in the same directory as the .c file. When targetdir is not
598 # empty, path names will be stripped from the file names so that all files
599 # are in that dir and not in subdirectories.
600 # - compiler (default target): compiler to use, target, kernel or host
601 %define rule_compile_multi mmake=TMP basenames=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= srcdir= targetdir= \
605 %(mmake)_MC_SRCWILDCARD := %
607 %(mmake)_MC_SRCWILDCARD := %(srcdir)/%
611 %(mmake)_MC_TARGETS := $(addsuffix .o,%(basenames))
612 %(mmake)_MC_DTARGETS := $(addsuffix .d,%(basenames))
613 %(mmake)_MC_TGTWILDCARD := %
615 %(mmake)_MC_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
616 %(mmake)_MC_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
617 %(mmake)_MC_TGTWILDCARD := %(targetdir)/%
619 # Be sure that all .c files are generated
620 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : | $(addsuffix .c,%(basenames))
622 # Be sure that all .c files are found
623 %(mmake)_MC_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
624 %(mmake)_MC_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
625 %(mmake)_MC_DIRS := $(foreach dir, $(%(mmake)_MC_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(%(mmake)_MC_SRCDIR)/$(CURDIR)/$(dir)))
626 ifneq ($(%(mmake)_MC_DIRS),)
627 %(mmake)_MC_DIRS := $(shell echo $(%(mmake)_MC_DIRS) | sed 's/\(.\):\//\/\1\//g')
628 vpath %.c $(%(mmake)_MC_DIRS)
633 %(mmake)_MC_CPPFLAGS := %(cppflags)
634 %(mmake)_CFLAGS := %(cflags)
636 %(mmake)_DFLAGS := %(cflags)
638 %(mmake)_DFLAGS := %(dflags)
641 ifeq ($(findstring %(compiler),host kernel target),)
642 $(error unknown compiler %(compiler))
644 ifeq (%(compiler),target)
645 %(mmake)_LINK ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
646 %(mmake)_STRIP ?= $(TARGET_STRIP)
647 %(mmake)_ASSEMBLER ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT))
648 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
649 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_MC_CPPFLAGS:=$(%(mmake)_MC_CPPFLAGS)
650 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_CFLAGS:=$(strip $(%(mmake)_CFLAGS) $(SAFETY_CFLAGS))
651 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_DFLAGS:=$(%(mmake)_DFLAGS)
652 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
653 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
655 ifeq (%(compiler),host)
656 %(mmake)_LINK ?= $(strip $(HOST_CC) $(HOST_LDFLAGS))
657 %(mmake)_STRIP ?= $(HOST_STRIP)
658 %(mmake)_ASSEMBLER ?= $(strip $HOST_CC) $(HOST_SYSROOT))
659 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : CMD:=$(HOST_CC)
660 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_MC_CPPFLAGS:=$(strip $(HOST_MC_CPPFLAGS) $(%(mmake)_MC_CPPFLAGS))
661 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_CFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_CFLAGS))
662 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_DFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_DFLAGS))
663 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
664 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
666 ifeq (%(compiler),kernel)
667 %(mmake)_LINK ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
668 %(mmake)_STRIP ?= $(ECHO) >/dev/null
669 %(mmake)_ASSEMBLER ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
670 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
671 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_MC_CPPFLAGS:=$(strip $(KERNEL_MC_CPPFLAGS) $(%(mmake)_MC_CPPFLAGS))
672 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_CFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_CFLAGS))
673 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_DFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_DFLAGS))
674 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
675 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
678 $(%(mmake)_MC_TARGETS) : CPPFLAGS := $(%(mmake)_MC_CPPFLAGS)
679 $(%(mmake)_MC_TARGETS) : CFLAGS := $(%(mmake)_CFLAGS)
680 $(%(mmake)_MC_TARGETS) : $(%(mmake)_MC_TGTWILDCARD).o : $(%(mmake)_MC_SRCWILDCARD).c
681 %compile_q cmd=$(CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
683 $(%(mmake)_MC_DTARGETS) : $(%(mmake)_MC_TGTWILDCARD).d : $(%(mmake)_MC_SRCWILDCARD).c
684 %mkdepend_q cc=$(CMD) flags="$(strip $(%(mmake)_DFLAGS) $(%(mmake)_MC_CPPFLAGS))"
686 #------------------------------------------------------------------------------
689 #------------------------------------------------------------------------------
690 # Generate a rule to compile multiple C++ source files to an object file and
691 # generate the corresponding dependency files. The generated file will be put
692 # in the object directory without the directory part of the source file.
694 # - basenames: the basenames of the files to compile. The names may include
695 # relative or absolute path names. No wildcard is allowed. basenames will be
696 # matched to supported AROS_CXXEXTS.
697 # - cflags (default $(CFLAGS)): the C flags to use for compilation
698 # - dflags: the flags used during creation of dependency file. If not specified
699 # the same value as cflags will be used
700 # - targetdir: the directory to put the .o file and the .d file. By default
701 # it is put in the same directory as the .c file. When targetdir is not
702 # empty, path names will be stripped from the file names so that all files
703 # are in that dir and not in subdirectories.
704 # - compiler (default target): compiler to use, target, kernel or host
705 %define rule_compile_cxx_multi mmake=TMP basenames=/A cppflags=$(CPPFLAGS) cxxflags=$(CXXFLAGS) dxxflags= \
706 targetdir= compiler=target
708 %(mmake)_CXXABSBASENAMES := $(foreach %(mmake)_CXXBASE,%(basenames),$(if $(filter /%,$(%(mmake)_CXXBASE)),$(%(mmake)_CXXBASE),$(abspath $(SRCDIR)/$(CURDIR)/$(%(mmake)_CXXBASE))))
710 ifneq ($(%(mmake)_CXXABSBASENAMES),)
712 %(mmake)_CXXBASENAMES := $(basename $(%(mmake)_CXXABSBASENAMES))
714 # Identify the "real" c++ files from the passed in basenames
715 %(mmake)_MCXX_FILES := $(strip $(foreach %(mmake)_CXXBASE,$(%(mmake)_CXXABSBASENAMES), $(firstword $(wildcard $(foreach %(mmake)_EXT, $(AROS_CXXEXTS),$(addsuffix .$(%(mmake)_EXT),$(%(mmake)_CXXBASE)))))))
718 %(mmake)_CXXTARGETS := $(notdir $(%(mmake)_CXXBASENAMES:=.o))
719 %(mmake)_CXXDTARGETS := $(notdir $(%(mmake)_CXXBASENAMES:=.d))
720 %(mmake)_MCXX_WILDCARD := %
722 %(mmake)_CXXTARGETS := $(addprefix %(targetdir)/,$(notdir $(%(mmake)_CXXBASENAMES:=.o)))
723 %(mmake)_CXXDTARGETS := $(addprefix %(targetdir)/,$(notdir $(%(mmake)_CXXBASENAMES:=.d)))
724 %(mmake)_MCXX_WILDCARD := %(targetdir)/%
726 # Be sure that all source files are generated
727 $(%(mmake)_CXXTARGETS) $(%(mmake)_CXXDTARGETS) : | $(%(mmake)_MCXX_FILES)
730 # Adjust compiler flags to suit C++
731 %(mmake)_MCXX_CPPFLAGS := %(cppflags)
732 %(mmake)_CXXFLAGS := %(cxxflags)
734 %(mmake)_DXXFLAGS := %(cxxflags)
736 %(mmake)_DXXFLAGS := %(dxxflags)
739 ifeq ($(findstring %(compiler),host kernel target),)
740 $(error unknown compiler %(compiler))
742 ifeq (%(compiler),host)
743 %(mmake)_LINK ?= $(strip $(HOST_CXX) $(HOST_LDFLAGS))
744 %(mmake)_STRIP ?= $(HOST_STRIP)
745 %(mmake)_ASSEMBLER ?= $(strip $(HOST_CC) $(HOST_SYSROOT))
746 %(mmake)_CXXCMD:=$(HOST_CXX)
747 %(mmake)_MCXX_CPPFLAGS := $(strip $(HOST_MCXX_CPPFLAGS) $(%(mmake)_MCXX_CPPFLAGS))
748 %(mmake)_CXXFLAGS := $(strip $(HOST_CXXFLAGS) $(%(mmake)_CXXFLAGS))
749 %(mmake)_DXXFLAGS := $(strip $(HOST_CXXFLAGS) $(%(mmake)_DXXFLAGS))
750 %(mmake)_CXXIQUOTE:=$(HOST_IQUOTE)
751 %(mmake)_CXXIQUOTE_END:=$(HOST_IQUOTE_END)
753 ifeq (%(compiler),target)
754 %(mmake)_LINK ?= $(strip $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
755 %(mmake)_STRIP ?= $(TARGET_STRIP)
756 %(mmake)_ASSEMBLER ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT))
757 %(mmake)_CXXCMD:=$(strip $(AROS_CXX) $(TARGET_SYSROOT))
758 %(mmake)_MCXX_CPPFLAGS := $(%(mmake)_MCXX_CPPFLAGS)
759 %(mmake)_CXXFLAGS := $(strip $(%(mmake)_CXXFLAGS) $(SAFETY_CFLAGS))
760 %(mmake)_DXXFLAGS := $(%(mmake)_DXXFLAGS)
761 %(mmake)_CXXIQUOTE:=$(CFLAGS_IQUOTE)
762 %(mmake)_CXXIQUOTE_END:=$(CFLAGS_IQUOTE_END)
764 ifeq (%(compiler),kernel)
765 KERNEL_CXX ?= $(KERNEL_CC)
766 %(mmake)_LINK ?= $(strip $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
767 %(mmake)_STRIP ?= $(ECHO) >/dev/null
768 %(mmake)_ASSEMBLER ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
769 %(mmake)_CXXCMD:=$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))
770 %(mmake)_CXXFLAGS := $(strip $(KERNEL_MCXX_CPPFLAGS) $(%(mmake)_MCXX_CPPFLAGS))
771 %(mmake)_CXXFLAGS := $(strip $(KERNEL_CXXFLAGS) $(%(mmake)_CXXFLAGS))
772 %(mmake)_DXXFLAGS := $(strip $(KERNEL_CXXFLAGS) $(%(mmake)_DXXFLAGS))
773 %(mmake)_CXXIQUOTE:=$(KERNEL_IQUOTE)
774 %(mmake)_CXXIQUOTE_END:=$(KERNEL_IQUOTE_END)
777 define cxx_multi_recipe_template
779 %compile_q cmd=$(%(mmake)_CXXCMD) opt="$(strip $(%(mmake)_CXXFLAGS) $(%(mmake)_MCXX_CPPFLAGS))" iquote=$(%(mmake)_CXXIQUOTE) iquote_end=$(%(mmake)_CXXIQUOTE_END) from=$(2) to=$(1).o
782 %mkdepend_q cc=$(%(mmake)_CXXCMD) flags="$(strip $(%(mmake)_DXXFLAGS) $(%(mmake)_MCXX_CPPFLAGS))" from=$(2) to=$(1).d
785 $(foreach %(mmake)_CXXFILE,$(%(mmake)_MCXX_FILES),$(eval $(call cxx_multi_recipe_template,$(notdir $(basename $(%(mmake)_CXXFILE))),$(%(mmake)_CXXFILE))))
787 $(foreach %(mmake)_CXXFILE,$(%(mmake)_MCXX_FILES),$(eval $(call cxx_multi_recipe_template,$(addprefix %(targetdir)/,$(notdir $(basename $(%(mmake)_CXXFILE)))),$(%(mmake)_CXXFILE))))
793 #------------------------------------------------------------------------------
796 #------------------------------------------------------------------------------
797 # Generate a rule to compile multiple ObjC source files to an object file and
798 # generate the corresponding dependency files. The generated file will be put
799 # in the object directory without the directory part of the source file.
801 # - basenames: the basenames of the files to compile. The names may include
802 # relative or absolute path names. No wildcard is allowed
803 # - cflags (default $(CFLAGS)): the C flags to use for compilation
804 # - dflags: the flags used during creation of dependency file. If not specified
805 # the same value as cflags will be used
806 # - targetdir: the directory to put the .o file and the .d file. By default
807 # it is put in the same directory as the .m file. When targetdir is not
808 # empty, path names will be stripped from the file names so that all files
809 # are in that dir and not in subdirectories.
810 # - compiler (default target): compiler to use, target, kernel or host
811 %define rule_compile_objc_multi mmake=TMP basenames=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= \
812 targetdir= compiler=target
814 ifneq (%(basenames),)
817 %(mmake)_MOBJC_TARGETS := $(addsuffix .o,%(basenames))
818 %(mmake)_MOBJC_DTARGETS := $(addsuffix .d,%(basenames))
819 %(mmake)_MOBJC_WILDCARD := %
821 %(mmake)_MOBJC_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,%(basenames)))
822 %(mmake)_MOBJC_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,%(basenames)))
823 %(mmake)_MOBJC_WILDCARD := %(targetdir)/%
825 # Be sure that all .m files are generated
826 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : | $(addsuffix .m,%(basenames))
828 # Be sure that all .m files are found
829 %(mmake)_MOBJC_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
830 %(mmake)_MOBJC_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
831 %(mmake)_MOBJC_DIRS := $(foreach dir, $(%(mmake)_MOBJC_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(%(mmake)_MOBJC_SRCDIR)/$(CURDIR)/$(dir)))
832 ifneq ($(%(mmake)_MOBJC_DIRS),)
833 %(mmake)_MOBJC_DIRS := $(shell echo $(%(mmake)_MOBJC_DIRS) | sed 's/\(.\):\//\/\1\//g')
834 vpath %.m $(%(mmake)_MOBJC_DIRS)
838 # Define the use of cross compiler
839 ifeq ($(TARGET_OBJC),)
840 %(mmake)_CC := $(TARGET_CC)
842 %(mmake)_CC := $(TARGET_OBJC)
845 # Adjust compiler flags to suit ObjC
846 %(mmake)_MOBJC_CPPFLAGS := %(cppflags)
847 %(mmake)_OBJCFLAGS := %(cflags)
848 %(mmake)_OBJCFLAGS := $(%(mmake)_OBJCFLAGS) -isystem $(AROS_DEVELOPER)/include
849 %(mmake)_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(%(mmake)_OBJCFLAGS)))
851 %(mmake)_OBJCDFLAGS := %(cflags)
853 %(mmake)_OBJCDFLAGS := %(dflags)
856 ifeq ($(findstring %(compiler),host kernel target),)
857 $(error unknown compiler %(compiler))
859 ifeq (%(compiler),target)
860 %(mmake)_LINK ?= $(strip $(%(mmake)_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
861 %(mmake)_STRIP ?= $(TARGET_STRIP)
862 %(mmake)_ASSEMBLER ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT))
863 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : CMD:=$(strip $(%(mmake)_CC) $(TARGET_SYSROOT))
864 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_MOBJC_CPPFLAGS:=$(%(mmake)_MOBJC_CPPFLAGS)
865 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCFLAGS:=$(strip $(%(mmake)_OBJCFLAGS) $(SAFETY_CFLAGS))
866 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCDFLAGS:=$(%(mmake)_OBJCDFLAGS)
867 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
868 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
870 ifeq (%(compiler),host)
871 %(mmake)_LINK ?= $(strip $(HOST_OBJC) $(HOST_LDFLAGS))
872 %(mmake)_STRIP ?= $(HOST_STRIP)
873 %(mmake)_ASSEMBLER ?= $(strip $(HOST_CC) $(HOST_SYSROOT))
874 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : CMD:=$(HOST_OBJC)
875 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_MOBJC_CPPFLAGS:=$(strip $(HOST_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_CPPFLAGS))
876 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCFLAGS))
877 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCDFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCDFLAGS))
878 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
879 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
881 ifeq (%(compiler),kernel)
882 KERNEL_OBJC ?= $(KERNEL_CC)
883 %(mmake)_LINK ?= $(strip $(KERNEL_OBJC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
884 %(mmake)_STRIP ?= $(ECHO) >/dev/null
885 %(mmake)_ASSEMBLER ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
886 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : CMD:=$(strip $(KERNEL_OBJC) $(KERNEL_SYSROOT))
887 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_MOBJC_CPPFLAGS:=$(strip $(KERNEL_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_CPPFLAGS))
888 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCFLAGS))
889 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCDFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCDFLAGS))
890 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
891 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
894 $(%(mmake)_MOBJC_TARGETS) : CPPFLAGS := $(%(mmake)_MOBJC_CPPFLAGS)
895 $(%(mmake)_MOBJC_TARGETS) : CFLAGS := $(%(mmake)_OBJCFLAGS)
896 $(%(mmake)_MOBJC_TARGETS) : $(%(mmake)_MOBJC_WILDCARD).o : %.m
897 %compile_q cmd=$(CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
899 $(%(mmake)_MOBJC_DTARGETS) : $(%(mmake)_MOBJC_WILDCARD).d : %.m
900 %mkdepend_q cc=$(CMD) flags="$(strip $(%(mmake)_OBJCDFLAGS) $(%(mmake)_MOBJC_CPPFLAGS))"
905 #------------------------------------------------------------------------------
908 #------------------------------------------------------------------------------
909 # Make an alias from one arch specific build to another arch.
911 # - mainmmake: the mmake of the module in the main tree
912 # - arch: the current arch
913 # - alias: the alias to which this should point
914 %define rule_archalias mainmmake=\A arch=\A alias=\A
916 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
918 #------------------------------------------------------------------------------
921 #------------------------------------------------------------------------------
922 # Generate a rule to assemble a source file to an object file. Basename may
923 # contain a directory part, then the source file has to be in that directory.
924 # The generated file will be put in the object directory without the directory.
926 # - basename: the basename of the file to compile. Use % for a wildcard rule
927 # - flags (default $(AFLAGS)): the asm flags to use for assembling
928 # - targetdir: the directory to put the .o file in. By default it is put in the
929 # same directory as the .s file
930 %define rule_assemble basename=/A cppflags=$(CPPFLAGS) aflags=$(AFLAGS) targetdir=
933 %(basename).o : CPPFLAGS := %(cppflags)
934 %(basename).o : AFLAGS := %(aflags)
935 %(basename).o : %(basename).s
937 %(basename).o : %(basename).S
941 %(targetdir)/$(notdir %(basename)).o : CPPFLAGS := %(cppflags)
942 %(targetdir)/$(notdir %(basename)).o : AFLAGS := %(aflags)
943 %(targetdir)/$(notdir %(basename)).o : %(basename).s
945 %(targetdir)/$(notdir %(basename)).o : %(basename).S
950 #------------------------------------------------------------------------------
953 #------------------------------------------------------------------------------
954 # Generate a rule to assemble multiple source files to an object file. The
955 # generated file will be put in the object directory with the directory part
956 # of the source file stripped off.
958 # - basenames: the basenames of the files to compile. The names may include
959 # relative or absolute path names. No wildcard is allowed
960 # - aflags (default $(AFLAGS)): the flags to use for assembly
961 # - targetdir: the directory to put the .o file and the .d file. By default
962 # it is put in the same directory as the .c file. When targetdir is not
963 # empty, path names will be stripped from the file names so that all files
964 # are in that dir and not in subdirectories.
965 %define rule_assemble_multi mmake=TMP cmd="$(strip $(CC) $(TARGET_SYSROOT))" basenames=/A cppflags=$(CPPFLAGS) aflags=$(AFLAGS) targetdir= suffix=.s
968 %(mmake)-MA_TARGETS := $(addsuffix .o,%(basenames))
969 %(mmake)-MA_WILDCARD := %
971 %(mmake)-MA_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
972 %(mmake)-MA_WILDCARD := %(targetdir)/%
974 # Be sure that all .s files are generated
975 $(%(mmake)-MA_TARGETS) : | $(addsuffix %(suffix),%(basenames))
977 # Be sure that all .c files are found
978 %(mmake)-MA_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
979 %(mmake)-MA_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
980 %(mmake)-MA_DIRS := $(foreach dir, $(%(mmake)-MA_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(%(mmake)-MA_SRCDIR)/$(CURDIR)/$(dir)))
981 ifneq ($(%(mmake)-MA_DIRS),)
982 %(mmake)-MA_DIRS := $(shell echo $(%(mmake)-MA_DIRS) | sed 's/\(.\):\//\/\1\//g')
983 vpath %%(suffix) $(%(mmake)-MA_DIRS)
988 %(mmake)-MA_ASSEMBLER ?= %(cmd)
990 $(%(mmake)-MA_TARGETS) : %(mmake)-MA_CMD:= $(%(mmake)-MA_ASSEMBLER)
992 $(%(mmake)-MA_TARGETS) : CPPFLAGS := %(cppflags)
993 $(%(mmake)-MA_TARGETS) : AFLAGS := %(aflags)
994 $(%(mmake)-MA_TARGETS) : $(%(mmake)-MA_WILDCARD).o : %%(suffix)
995 %assemble_q cmd=$(%(mmake)-MA_CMD)
997 #------------------------------------------------------------------------------
1000 #------------------------------------------------------------------------------
1001 # Link %(objs) to %(prog) using the libraries in %(uselibs)
1002 %define rule_link_prog mmake=TMP prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
1003 usehostlibs= usestartup=yes detach=no nix=no cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" strip=$(TARGET_STRIP) objdir=$(GENDIR)/$(CURDIR) coverageinstr=$(TARGET_COVERAGEINSTR)
1005 %(mmake)-link_EXTRA_LDFLAGS :=
1006 %(mmake)-link_EXTRA_LIBS :=
1008 %(mmake)-link_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
1010 ifeq (%(usestartup),no)
1011 %(mmake)-link_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
1013 ifeq (%(detach),yes)
1014 %(mmake)-link_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
1017 # Make a list of the lib files this program depends on.
1018 # In LDFLAGS remove white space between -L and directory
1019 %(mmake)-link_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
1020 # Filter out only the libdirs and remove -L
1021 %(mmake)-link_DIRS := $(patsubst -L%,%,$(filter -L%,$(%(mmake)-link_DIRS)))
1023 %(mmake)-link_DIRS := $(subst //,/,$(addsuffix /,$(%(mmake)-link_DIRS)))
1024 # Add normal linklib path
1025 %(mmake)-link_DIRS += $(AROS_LIB)/
1026 # add lib and .a to static linklib names
1027 %(mmake)-link_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(%(mmake)-link_EXTRA_LIBS)))
1028 ifeq (%(usestartup),yes)
1029 %(mmake)-link_LIBS += startup.o
1031 ifeq (%(detach),yes)
1032 %(mmake)-link_LIBS += detach.o
1034 # search for the linklibs in the given path, ignore ones not found
1035 %(mmake)-link_DEPLIBS := $(foreach lib,$(%(mmake)-link_LIBS), \
1036 $(firstword $(wildcard $(addsuffix $(lib),$(%(mmake)-link_DIRS)))) \
1039 %(prog) : OBJDIR := %(objdir)
1040 %(prog) : OBJS := %(objs)
1041 %(prog) : LDFLAGS := $(strip %(ldflags) $(%(mmake)-link_EXTRA_LDFLAGS))
1042 %(prog) : LIBS := $(addprefix -l,%(uselibs) $(%(mmake)-link_EXTRA_LIBS) %(usehostlibs))
1043 %(prog) : %(objs) $(%(mmake)-link_DEPLIBS)
1044 %link_q cmd="%(cmd)" strip="%(strip)" from=$(OBJS) opt=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR) coverageinstr=%(coverageinstr)
1046 #------------------------------------------------------------------------------
1049 #------------------------------------------------------------------------------
1050 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
1051 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
1052 %define rule_link_progs mmake=TMP progs=/A targetdir=$(AROSDIR)/$(CURDIR) nix=%(nix) \
1053 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
1054 usestartup=yes detach=no cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" strip=$(TARGET_STRIP) coverageinstr=$(TARGET_COVERAGEINSTR)
1056 %(mmake)-link_EXTRA_LDFLAGS :=
1057 %(mmake)-link_EXTRA_LIBS :=
1059 %(mmake)-link_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
1061 ifeq (%(usestartup),no)
1062 %(mmake)-link_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
1064 ifeq (%(detach),yes)
1065 %(mmake)-link_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
1068 # Make a list of the lib files the programs depend on.
1069 # In LDFLAGS remove white space between -L and directory
1070 %(mmake)-link_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
1071 # Filter out only the libdirs and remove -L
1072 %(mmake)-link_DIRS := $(patsubst -L%,%,$(filter -L%,$(%(mmake)-link_DIRS)))
1074 %(mmake)-link_DIRS := $(subst //,/,$(addsuffix /,$(%(mmake)-link_DIRS)))
1075 # Add normal linklib path
1076 %(mmake)-link_DIRS += $(AROS_LIB)/
1077 # add lib and .a to static linklib names
1078 %(mmake)-link_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(%(mmake)-link_EXTRA_LIBS)))
1079 # search for the linklibs in the given path, ignore ones not found
1080 %(mmake)-link_DEPLIBS := $(foreach lib,$(%(mmake)-link_LIBS), \
1081 $(firstword $(wildcard $(addsuffix $(lib),$(%(mmake)-link_DIRS)))) \
1083 %(mmake)-link_PROGS := $(addprefix %(targetdir)/,%(progs))
1085 $(%(mmake)-link_PROGS) : OBJDIR := %(objdir)
1086 $(%(mmake)-link_PROGS) : LDFLAGS := $(strip %(ldflags) $(%(mmake)-link_EXTRA_LDFLAGS))
1087 $(%(mmake)-link_PROGS) : LIBS := $(addprefix -l,%(uselibs) $(%(mmake)-link_EXTRA_LIBS) %(usehostlibs))
1088 $(%(mmake)-link_PROGS) : %(targetdir)/% : %(objdir)/%.o $(%(mmake)-link_DEPLIBS)
1089 %link_q cmd="%(cmd)" strip="%(strip)" from=$< opt=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR) coverageinstr=%(coverageinstr)
1091 #------------------------------------------------------------------------------
1094 #------------------------------------------------------------------------------
1095 # Link the %(objs) to the library %(libdir)/lib%(libname).a
1096 %define rule_link_linklib mmake=TMP libname=/A objs=/A libdir=$(AROS_LIB) linker=target
1098 ifeq (%(linker),target)
1099 %(libdir)/lib%(libname).a : %(mmake)_AR:=$(AR)
1100 %(libdir)/lib%(libname).a : %(mmake)_RANLIB:=$(RANLIB)
1102 ifeq (%(linker),host)
1103 %(libdir)/lib%(libname).a : %(mmake)_AR:=$(HOST_AR)
1104 %(libdir)/lib%(libname).a : %(mmake)_RANLIB:=$(HOST_RANLIB)
1106 ifeq (%(linker),kernel)
1107 %(libdir)/lib%(libname).a : %(mmake)_AR:=$(KERNEL_AR)
1108 %(libdir)/lib%(libname).a : %(mmake)_RANLIB:=$(KERNEL_RANLIB)
1111 %(libdir)/lib%(libname).a : %(objs)
1112 %mklib_q from=$^ ar=$(%(mmake)_AR) ranlib=$(%(mmake)_RANLIB)
1114 #------------------------------------------------------------------------------
1116 #------------------------------------------------------------------------------
1117 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
1118 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
1119 %define rule_linkmodule module=/A objs=/A endobj=/A err=/A objdir=$(OBJDIR) \
1120 cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" ldflags=$(LDFLAGS) uselibs= usehostlibs=
1122 TMP_LDFLAGS := %(ldflags)
1123 # Make a list of the lib files the programs depend on.
1124 # In LDFLAGS remove white space between -L and directory
1125 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
1126 # Filter out only the libdirs and remove -L
1127 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
1129 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
1130 # Add normal linklib path
1131 TMP_DIRS += $(AROS_LIB)/
1132 # add lib and .a to static linklib names
1133 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
1134 # search for the linklibs in the given path, ignore ones not found
1135 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
1136 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
1139 %(module) : LIB_NAMES := %(uselibs)
1140 %(module) : OBJS := %(objs)
1141 %(module) : ENDTAG := %(endobj)
1142 %(module) : ERR := %(err)
1143 %(module) : OBJDIR := %(objdir)
1144 %(module) : LDFLAGS := $(TMP_LDFLAGS)
1145 ifeq (%(usehostlibs),)
1146 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES))
1148 # Warning: the -L/usr/lib here can result in modules
1149 # linking against host libs instead of AROS libs (e.g stdc++) !!
1150 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES)) \
1151 -L/usr/lib $(addprefix -l,%(usehostlibs))
1153 %(module) : %(objs) %(endobj) $(TMP_DEPLIBS) $(USER_DEPLIBS)
1154 %link_module_q cmd="%(cmd)" err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS) objdir=$(OBJDIR) ldflags=$(LDFLAGS)
1157 #------------------------------------------------------------------------------
1160 #------------------------------------------------------------------------------
1161 # Generate the libdefs.h include file for a module.
1162 %define rule_genmodule_genlibdefs modname=/A version= flavour= modtype=/A modsuffix= conffile= targetdir=
1166 TMP_OPTS += -f %(flavour)
1167 TMP_MODNAME := %(modname)_%(flavour)
1169 TMP_MODNAME := %(modname)
1171 TMP_TARGET := $(TMP_MODNAME)_libdefs.h
1172 TMP_DEPS := $(GENMODULE)
1173 ifneq (%(conffile),)
1174 ifeq ($(dir %(conffile)),./)
1175 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1176 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1178 TMP_OPTS += -c %(conffile)
1179 TMP_DEPS += %(conffile)
1182 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1183 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1185 ifneq (%(modsuffix),)
1186 TMP_OPTS += -s %(modsuffix)
1188 ifneq (%(targetdir),)
1189 TMP_OPTS += -d %(targetdir)
1190 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1193 TMP_OPTS += -v %(version)
1196 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1197 $(TMP_TARGET) : MODNAME := %(modname)
1198 $(TMP_TARGET) : MODTYPE := %(modtype)
1199 $(TMP_TARGET) : $(TMP_DEPS)
1200 $(Q)$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1201 $(Q)$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
1203 #------------------------------------------------------------------------------
1205 #------------------------------------------------------------------------------
1206 # Generate the _lib.fd file for a module.
1207 %define rule_genmodule_fd modname=/A modtype=/A modsuffix= conffile= targetdir=
1209 TMP_TARGET := %(modname)_lib.fd
1210 TMP_DEPS := $(GENMODULE)
1212 ifneq (%(conffile),)
1213 ifeq ($(dir %(conffile)),./)
1214 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1215 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1217 TMP_OPTS += -c %(conffile)
1218 TMP_DEPS += %(conffile)
1221 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1222 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1224 ifneq (%(modsuffix),)
1225 TMP_OPTS += -s %(modsuffix)
1227 ifneq (%(targetdir),)
1228 TMP_OPTS += -d %(targetdir)
1229 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1232 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1233 $(TMP_TARGET) : MODNAME := %(modname)
1234 $(TMP_TARGET) : MODTYPE := %(modtype)
1235 $(TMP_TARGET) : $(TMP_DEPS)
1236 $(Q)$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1237 $(Q)$(GENMODULE) $(OPTS) writefd $(MODNAME) $(MODTYPE)
1239 #------------------------------------------------------------------------------
1241 #------------------------------------------------------------------------------
1242 # Generate a Makefile.%(modname)%(modtype) with the genmodule program and include this
1243 # generated file in this Makefile
1244 %define rule_genmodule_makefile modname=/A flavour= modtype=/A modsuffix= conffile= \
1249 TMP_OPTS += -f %(flavour)
1250 TMP_MODNAME := %(modname)_%(flavour)
1252 TMP_MODNAME := %(modname)
1254 TMP_TARGET := Makefile.$(TMP_MODNAME)%(modtype)
1255 TMP_DEPS := $(GENMODULE)
1256 ifneq (%(conffile),)
1257 ifeq ($(dir %(conffile)),./)
1258 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1259 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1261 TMP_OPTS += -c %(conffile)
1262 TMP_DEPS += %(conffile)
1265 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1266 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1268 ifneq (%(modsuffix),)
1269 TMP_OPTS += -s %(modsuffix)
1271 ifneq (%(targetdir),)
1272 TMP_OPTS += -d %(targetdir)
1273 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1276 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1277 $(TMP_TARGET) : MODNAME := %(modname)
1278 $(TMP_TARGET) : MODTYPE := %(modtype)
1279 $(TMP_TARGET) : $(TMP_DEPS)
1280 $(Q)$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
1282 #------------------------------------------------------------------------------
1285 #------------------------------------------------------------------------------
1286 # Generate the support files for compiling a module. This includes include
1287 # files and source files. This rule has to be preceeded by
1288 # %rule_genmodule_makefile
1289 %define rule_genmodule_files modname=/A flavour= modtype=/A modsuffix= targetdir= stubdir= \
1294 TMP_OPTS += -f %(flavour)
1295 TMP_MODNAME := %(modname)_%(flavour)
1297 TMP_MODNAME := %(modname)
1299 TMP_GENTARGETS := $($(TMP_MODNAME)_STARTFILES) $($(TMP_MODNAME)_ENDFILES)
1300 TMP_STUBTARGETS := $($(TMP_MODNAME)_LINKLIBFILES) $($(TMP_MODNAME)_RELLINKLIBFILES)
1301 TMP_GENTARGETS := $(addsuffix .c,$(TMP_GENTARGETS))
1302 TMP_STUBTARGETS := $(addsuffix .c,$(TMP_STUBTARGETS)) \
1303 $(addsuffix .S, $($(TMP_MODNAME)_LINKLIBAFILES) $($(TMP_MODNAME)_RELLINKLIBAFILES))
1305 TMP_DEPS := $(GENMODULE)
1306 ifneq (%(conffile),)
1307 ifeq ($(dir %(conffile)),./)
1308 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1309 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1311 TMP_OPTS += -c %(conffile)
1312 TMP_DEPS += %(conffile)
1315 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1316 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1318 ifneq (%(modsuffix),)
1319 TMP_OPTS += -s %(modsuffix)
1321 ifneq (%(targetdir),)
1322 TMP_OPTS += -d %(targetdir)
1323 TMP_TARGETDIR := $(shell echo %(targetdir) | sed 's/^\(.\):\//\/\1\//')
1324 TMP_GENTARGETS := $(addprefix $(TMP_TARGETDIR)/,$(TMP_GENTARGETS))
1325 TMP_GENFILEFLAG=$(TMP_TARGETDIR)/.%(modname).%(modtype)-genfiles
1327 TMP_GENFILEFLAG=$(GENDIR)/$(CURDIR)/.%(modname).%(modtype)-genfiles
1330 TMP_OPTS += -l %(stubdir)
1331 TMP_STUBTARGETDIR := $(shell echo %(stubdir) | sed 's/^\(.\):\//\/\1\//')
1332 TMP_STUBTARGETS := $(addprefix $(TMP_STUBTARGETDIR)/,$(TMP_STUBTARGETS))
1333 TMP_TARGETDIRS += %(stubdir)
1335 ifneq (%(targetdir),)
1336 TMP_STUBTARGETS := $(addprefix $(TMP_TARGETDIR)/,$(TMP_STUBTARGETS))
1340 TMP_TARGETS := $(TMP_GENTARGETS) $(TMP_STUBTARGETS)
1341 ifneq ($(TMP_TARGETDIRS),)
1342 $(TMP_TARGETS) : | $(TMP_TARGETDIRS)
1345 $(TMP_TARGETS) : $(TMP_DEPS) $(TMP_GENFILEFLAG)
1347 $(TMP_GENFILEFLAG) : OPTS := $(TMP_OPTS)
1348 $(TMP_GENFILEFLAG) : MODNAME := %(modname)
1349 $(TMP_GENFILEFLAG) : MODTYPE := %(modtype)
1350 $(TMP_GENFILEFLAG) : $(TMP_DEPS)
1351 $(Q)$(ECHO) "Generating support files for module $(MODNAME$(BDID))"
1352 ifneq (%(conffile),lib.conf)
1353 $(Q)$(IF) $(TEST) -f lib.conf; then \
1354 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
1357 $(Q)$(IF) $(TEST) -f libdefs.h; then \
1358 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
1360 $(Q)$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
1363 #------------------------------------------------------------------------------
1366 #------------------------------------------------------------------------------
1367 # Generate the support files for compiling a module. This includes include
1368 # files and source files.
1369 %define rule_genmodule_includes modname=/A flavour= modtype=/A modsuffix= \
1370 targetdir= conffile=
1373 TMP_MODNAME := %(modname)_%(flavour)
1375 TMP_MODNAME := %(modname)
1378 ifneq ($($(TMP_MODNAME)_INCLUDES),)
1380 TMP_TARGETS := $($(TMP_MODNAME)_INCLUDES)
1382 TMP_DEPS := $(GENMODULE)
1385 ifneq (%(conffile),)
1386 ifeq ($(dir %(conffile)),./)
1387 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1388 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1390 TMP_OPTS += -c %(conffile)
1391 TMP_DEPS += %(conffile)
1394 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1395 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1397 ifneq (%(modsuffix),)
1398 TMP_OPTS += -s %(modsuffix)
1400 ifneq (%(targetdir),)
1401 TMP_OPTS += -d %(targetdir)
1402 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
1403 TMP_GENINCFLAG=%(targetdir)/.%(modname).%(modtype)-includes
1405 TMP_GENINCFLAG=$(GENDIR)/$(CURDIR)/.%(modname).%(modtype)-includes
1408 $(TMP_TARGETS) : $(TMP_DEPS) $(TMP_GENINCFLAG)
1410 $(TMP_GENINCFLAG) : OPTS := $(TMP_OPTS)
1411 $(TMP_GENINCFLAG) : MODNAME := %(modname)
1412 $(TMP_GENINCFLAG) : MODTYPE := %(modtype)
1413 $(TMP_GENINCFLAG) : $(TMP_DEPS)
1414 $(Q)$(ECHO) "Generating $(MODNAME).$(MODTYPE) includes"
1415 $(Q)$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
1419 #------------------------------------------------------------------------------
1421 #------------------------------------------------------------------------------
1422 # Link %(objs) to binary blob in %(file) using %(name) as name of embedded binary object
1423 # 'start' is an optional starting address
1424 # 'ldflags' is optional additional flags for the linker
1425 %define rule_link_binary mmake=BD file=/A name=/A objs= files= start=0 ldflags=
1427 %(mmake)_OUTDIR := $(dir %(file))
1428 # This trick removes the trailing '/', otherwise findstring below fails, causing a warning
1429 %(mmake)_OUTDIR := $(subst /*,,$(addsuffix *,$(%(mmake)_OUTDIR)))
1430 %(mmake)_TMPDIR := $(GENDIR)/$(CURDIR)
1431 %(mmake)_OBJS := $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir %(files))))
1432 %(mmake)_DEPS := $(addsuffix .d,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir %(files))))
1433 %(mmake)_OBJS += %(objs)
1435 %rule_compile_multi basenames="%(files)" targetdir=$(%(mmake)_OBJDIR)
1437 %(file) : $(%(mmake)_OBJS) $(%(mmake)_DEPS) $(%(mmake)_OUTDIR)
1438 $(Q)$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)..."
1439 $(Q)$(KERNEL_LD) %(ldflags) --entry=%(start) --oformat=binary -Ttext=%(start) -o $(%(mmake)_TMPDIR)/%(name) $(%(mmake)_OBJS)
1440 $(Q)cd $(%(mmake)_TMPDIR) && $(AROS_LD) %(ldflags) -r --format binary %(name) -o $@
1442 ifeq ($(findstring $(%(mmake)_OUTDIR),$(GLOB_MKDIRS)),)
1443 GLOB_MKDIRS += $(%(mmake)_OUTDIR)
1448 #------------------------------------------------------------------------------
1449 # Common rules for all makefiles
1451 # Delete generated makefiles
1454 $(Q)$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
1456 include $(SRCDIR)/config/make.tail
1458 BDID := $(BDTARGETID)
1460 #------------------------------------------------------------------------------
1463 #############################################################################
1464 #############################################################################
1466 ## Here are the mmakefile build macros. These are macros that takes care ##
1467 ## of everything to go from the sources to the generated target. Also all ##
1468 ## intermediate files and directories that are needed are created by these ##
1471 #############################################################################
1472 #############################################################################
1474 #------------------------------------------------------------------------------
1476 %define build_prog mmake=/A progname=/A files= cxxfiles= \
1478 asmfiles= objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1479 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= ldflags=$(LDFLAGS) \
1480 aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
1481 includedir= libdir= \
1482 compiler=target linker= \
1483 coverageinstr=$(TARGET_COVERAGEINSTR) funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO)
1487 %(mmake)_PROGNAME := %(progname)
1488 %(mmake)_OBJDIR := %(objdir)
1489 %(mmake)_TARGETDIR := %(targetdir)
1490 %(mmake)_LINKER := %(linker)
1491 %(mmake)_LIBS := %(uselibs)
1492 # If not supplied, linker is equal to compiler
1493 ifeq ($(%(mmake)_LINKER),)
1494 %(mmake)_LINKER := %(compiler)
1497 ifneq ("$(strip %(files) %(cxxfiles) %(objcfiles) %(asmfiles))","")
1498 %(mmake)_FILES := %(files)
1499 %(mmake)_OBJCFILES := %(objcfiles)
1500 %(mmake)_ASMFILES := %(asmfiles)
1501 %(mmake)_CXXFILES := %(cxxfiles)
1503 %(mmake)_FILES := $(%(mmake)_PROGNAME)
1504 %(mmake)_OBJCFILES :=
1505 %(mmake)_ASMFILES :=
1506 %(mmake)_CXXFILES :=
1509 %(mmake)_ARCHOBJS := $(wildcard $(%(mmake)_OBJDIR)/arch/*.o)
1510 %(mmake)_ARCHFILES := $(basename $(notdir $(%(mmake)_ARCHOBJS)))
1511 %(mmake)_C_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_FILES))
1512 %(mmake)_CXX_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_CXXFILES))
1513 %(mmake)_OBJC_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_OBJCFILES))
1515 TMP_FILES := $(%(mmake)_C_NARCHFILES) $(%(mmake)_CXX_NARCHFILES) $(%(mmake)_ASMFILES) $(%(mmake)_OBJC_NARCHFILES)
1516 %(mmake)_OBJS := $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir $(TMP_FILES))))
1517 %(mmake)_DEPS := $(addsuffix .d,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir $(TMP_FILES))))
1519 %(mmake)_CPPFLAGS := %(cppflags)
1520 ifneq (%(includedir),)
1521 %(mmake)_CPPFLAGS += -I%(includedir)
1523 %(mmake)_CFLAGS := %(cflags)
1524 %(mmake)_CXXFLAGS := %(cxxflags)
1525 %(mmake)_COVERAGE := no
1526 ifeq (%(compiler),target)
1527 ifeq (%(usestartup),yes)
1528 ifeq (%(coverageinstr),yes)
1529 %(mmake)_COVERAGE := yes
1530 %(mmake)_COVERAGEFLAGS ?= $(COVERAGEINSTR_FLAGS)
1531 %(mmake)_COVERAGELIBS ?= $(COVERAGEINSTR_LIBS)
1532 %(mmake)_CFLAGS := $(strip $(%(mmake)_COVERAGEFLAGS) $(%(mmake)_CFLAGS))
1533 %(mmake)_CXXFLAGS := $(strip $(%(mmake)_COVERAGEFLAGS) $(%(mmake)_CXXFLAGS))
1534 %(mmake)_LIBS += $(%(mmake)_COVERAGELIBS)
1536 ifeq (%(funcinstr),yes)
1537 %(mmake)_FUNCINSTR := yes
1538 %(mmake)_INSTRFUNCFLAGS ?= $(FUNCINSTR_FLAGS)
1539 %(mmake)_INSTRFUNCLIBS ?= $(FUNCINSTR_LIBS)
1540 %(mmake)_CFLAGS := $(strip $(%(mmake)_INSTRFUNCFLAGS) $(%(mmake)_CFLAGS))
1541 %(mmake)_CXXFLAGS := $(strip $(%(mmake)_INSTRFUNCFLAGS) $(%(mmake)_CXXFLAGS))
1542 %(mmake)_LIBS += $(%(mmake)_INSTRFUNCLIBS)
1546 %(mmake)_CFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(%(mmake)_CFLAGS))
1547 %(mmake)_CXXFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(%(mmake)_CXXFLAGS))
1550 %(mmake)_AFLAGS := %(aflags)
1552 %(mmake)_DFLAGS := %(dflags)
1554 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
1556 ifneq (%(dxxflags),)
1557 %(mmake)_DXXFLAGS := %(dxxflags)
1559 %(mmake)_DXXFLAGS := $(%(mmake)_CXXFLAGS)
1561 %(mmake)_LDFLAGS := %(ldflags)
1563 %(mmake)_LDFLAGS += -L%(libdir)
1567 %(mmake)-quick : %(mmake)
1569 #MM %(mmake) : includes-generate-deps core-linklibs
1570 %(mmake) : $(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME)
1572 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick %(mmake)-gz-quick),)
1573 %rule_compile_cxx_multi mmake=%(mmake) \
1574 basenames=$(%(mmake)_CXX_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
1575 cppflags=$(%(mmake)_CPPFLAGS) cxxflags=$(%(mmake)_CXXFLAGS) dxxflags=$(%(mmake)_DXXFLAGS) \
1576 compiler="%(compiler)"
1577 %rule_compile_objc_multi mmake=%(mmake) \
1578 basenames=$(%(mmake)_OBJC_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
1579 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
1580 compiler="%(compiler)"
1581 %rule_compile_multi mmake=%(mmake) \
1582 basenames=$(%(mmake)_C_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
1583 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
1584 compiler="%(compiler)"
1585 %rule_assemble_multi mmake=%(mmake) \
1586 cmd=$(%(mmake)_ASSEMBLER) basenames=$(%(mmake)_ASMFILES) targetdir=$(%(mmake)_OBJDIR) \
1587 cppflags=$(%(mmake)_CPPFLAGS) aflags=$(%(mmake)_AFLAGS)
1589 %rule_link_prog mmake=%(mmake) prog=$(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME) \
1590 objs="$(%(mmake)_OBJS) $(%(mmake)_ARCHOBJS) $(USER_OBJS)" ldflags=$(%(mmake)_LDFLAGS) \
1591 uselibs="$(%(mmake)_LIBS)" usehostlibs="%(usehostlibs)" \
1592 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)" \
1593 cmd=$(%(mmake)_LINK) strip=$(%(mmake)_STRIP) objdir=$(%(mmake)_OBJDIR) coverageinstr=$(%(mmake)_COVERAGE)
1597 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(%(mmake)_DEPS)
1599 $(%(mmake)_OBJS) $(%(mmake)_DEPS) : | $(%(mmake)_OBJDIR)
1600 $(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME) : | $(%(mmake)_TARGETDIR)
1601 GLOB_MKDIRS += $(%(mmake)_OBJDIR) $(%(mmake)_TARGETDIR)
1603 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME) $(%(mmake)_DEPS)
1606 $(Q)$(ECHO) "Cleaning up for metatarget %(mmake)"
1610 #------------------------------------------------------------------------------
1613 #------------------------------------------------------------------------------
1614 # Build programs, for every C file an executable will be built with the same
1615 # name as the C file
1616 %define build_progs mmake=/A files=/A nix=no \
1617 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1618 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= ldflags=$(LDFLAGS) \
1619 includedir= libdir= \
1621 uselibs= usehostlibs= usestartup=yes detach=no \
1622 coverageinstr=$(TARGET_COVERAGEINSTR) funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO)
1626 %(mmake)_OBJDIR := %(objdir)
1627 %(mmake)_TARGETDIR := %(targetdir)
1628 %(mmake)_LIBS := %(uselibs)
1630 %(mmake)_FILES := %(files)
1631 %(mmake)_OBJS := $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/,$(%(mmake)_FILES)))
1632 %(mmake)_DEPS := $(addsuffix .d,$(addprefix $(%(mmake)_OBJDIR)/,$(%(mmake)_FILES)))
1633 %(mmake)_EXES := $(addprefix $(%(mmake)_TARGETDIR)/,$(%(mmake)_FILES))
1635 %(mmake)_CPPFLAGS := %(cppflags)
1636 ifneq (%(includedir),)
1637 %(mmake)_CPPFLAGS += -I%(includedir)
1639 %(mmake)_CFLAGS := %(cflags)
1640 %(mmake)_COVERAGE := no
1641 ifeq (%(compiler),target)
1642 ifeq (%(usestartup),yes)
1643 ifeq (%(coverageinstr),yes)
1644 %(mmake)_COVERAGE := yes
1645 %(mmake)_COVERAGEFLAGS ?= $(COVERAGEINSTR_FLAGS)
1646 %(mmake)_COVERAGELIBS ?= $(COVERAGEINSTR_LIBS)
1647 %(mmake)_CFLAGS := $(strip $(%(mmake)_COVERAGEFLAGS) $(%(mmake)_CFLAGS))
1648 %(mmake)_LIBS += $(%(mmake)_COVERAGELIBS)
1650 ifeq (%(funcinstr),yes)
1651 %(mmake)_FUNCINSTR := yes
1652 %(mmake)_INSTRFUNCFLAGS ?= $(FUNCINSTR_FLAGS)
1653 %(mmake)_INSTRFUNCLIBS ?= $(FUNCINSTR_LIBS)
1654 %(mmake)_CFLAGS := $(strip $(%(mmake)_INSTRFUNCFLAGS) $(%(mmake)_CFLAGS))
1655 %(mmake)_LIBS += $(%(mmake)_INSTRFUNCLIBS)
1659 %(mmake)_CFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(%(mmake)_CFLAGS))
1663 %(mmake)_DFLAGS := %(dflags)
1665 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
1667 %(mmake)_LDFLAGS := %(ldflags)
1669 %(mmake)_LDFLAGS += -L%(libdir)
1673 %(mmake)-quick : %(mmake)
1675 #MM %(mmake) : includes-generate-deps core-linklibs
1676 %(mmake) : $(%(mmake)_EXES)
1678 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1679 %rule_compile_multi mmake=%(mmake) basenames=$(%(mmake)_FILES) targetdir=$(%(mmake)_OBJDIR) \
1680 cflags=$(%(mmake)_CFLAGS) cppflags=$(%(mmake)_CPPFLAGS) dflags=$(%(mmake)_DFLAGS) compiler="%(compiler)"
1682 %rule_link_progs mmake=%(mmake) progs=$(%(mmake)_FILES) nix="%(nix)" \
1683 targetdir=$(%(mmake)_TARGETDIR) objdir=$(%(mmake)_OBJDIR) \
1684 ldflags=$(%(mmake)_LDFLAGS) \
1685 uselibs="$(%(mmake)_LIBS)" usehostlibs="%(usehostlibs)" \
1686 usestartup="%(usestartup)" detach="%(detach)" \
1687 cmd=$(%(mmake)_LINK) strip=$(%(mmake)_STRIP) objdir=$(%(mmake)_OBJDIR) coverageinstr=$(%(mmake)_COVERAGE)
1691 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(%(mmake)_DEPS)
1693 $(addprefix $(%(mmake)_TARGETDIR)/,$(%(mmake)_FILES)) : | $(%(mmake)_TARGETDIR)
1694 $(%(mmake)_DEPS) $(%(mmake)_OBJS) : | $(%(mmake)_OBJDIR)
1695 GLOB_MKDIRS += $(%(mmake)_TARGETDIR) $(%(mmake)_OBJDIR)
1697 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_EXES) $(%(mmake)_DEPS)
1700 $(Q)$(ECHO) "Cleaning up for metatarget %(mmake)"
1704 #------------------------------------------------------------------------------
1707 #------------------------------------------------------------------------------
1709 # This is a bare version: It just compiles and links the given files. It is
1710 # assumed that all needed boiler plate code is in the files. This should only
1711 # be used for compiling external code. For AROS code use %build_module
1712 %define build_module_simple mmake=/A modname=/A modtype=/A \
1713 files="$(basename $(call WILDCARD, *.c))" \
1715 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
1716 cppflags=$(CPPFLAGS) \
1717 cflags=$(CFLAGS) dflags= \
1718 cxxflags=$(CXXFLAGS) dxxflags= \
1719 objdir=$(OBJDIR) moduledir= \
1720 uselibs= usehostlibs= compiler=target funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO)
1722 # Define metamake targets and their dependencies
1723 #MM %(mmake) : core-linklibs includes-generate-deps
1724 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1725 #MM %(mmake)-kobj-quick
1729 %(mmake)_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj
1731 .PHONY : $(%(mmake)_ALLTARGETS)
1734 $(error using %build_module_simple: modname may not be empty)
1737 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1740 # Default values for variables and arguments
1741 %(mmake)_DEFLINKLIBNAME := %(modname)
1742 %(mmake)_CFLAGS := %(cflags)
1743 %(mmake)_CXXFLAGS := %(cxxflags)
1744 ifeq (%(compiler),target)
1746 %(mmake)_CFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(%(mmake)_CFLAGS))
1748 ifeq (%(funcinstr),yes)
1749 %(mmake)_FUNCINSTR := yes
1750 %(mmake)_CFLAGS := $(strip $(FUNCINSTR_FLAGS) $(%(mmake)_CFLAGS))
1754 %(mmake)_DFLAGS := %(dflags)
1756 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
1758 %(mmake)_DEFDXXFLAGS := %(dxxflags)
1759 OBJDIR ?= $(GENDIR)/$(CURDIR)
1760 %(mmake)_MODDIR := %(moduledir)
1761 ifeq ($(%(mmake)_MODDIR),)
1762 ifeq (%(modtype),library)
1763 %(mmake)_MODDIR := $(AROS_LIBRARIES)
1765 ifeq (%(modtype),gadget)
1766 %(mmake)_MODDIR := $(AROS_GADGETS)
1768 ifeq (%(modtype),datatype)
1769 %(mmake)_MODDIR := $(AROS_DATATYPES)
1771 ifeq (%(modtype),handler)
1772 %(mmake)_MODDIR := $(AROS_FS)
1774 ifeq (%(modtype),device)
1775 %(mmake)_MODDIR := $(AROS_DEVS)
1777 ifeq (%(modtype),resource)
1778 %(mmake)_MODDIR := $(AROS_RESOURCES)
1780 ifeq (%(modtype),hook)
1781 %(mmake)_MODDIR := $(AROS_RESOURCES)
1783 ifeq (%(modtype),mui)
1784 %(mmake)_MODDIR := $(AROS_CLASSES)/Zune
1786 ifeq (%(modtype),mcc)
1787 %(mmake)_MODDIR := $(AROS_CLASSES)/Zune
1789 ifeq (%(modtype),mcp)
1790 %(mmake)_MODDIR := $(AROS_CLASSES)/Zune
1792 ifeq (%(modtype),usbclass)
1793 %(mmake)_MODDIR := $(AROS_CLASSES)/USB
1795 ifeq (%(modtype),hidd)
1796 %(mmake)_MODDIR := $(AROS_DRIVERS)
1798 ifeq (%(modtype),printer)
1799 %(mmake)_MODDIR := $(AROS_PRINTERS)
1802 ifeq ($(%(mmake)_MODDIR),)
1803 $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1806 %(mmake)_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1807 %(mmake)_ARCHFILES := $(basename $(notdir $(%(mmake)_ARCHOBJS)))
1808 %(mmake)_C_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),%(files))
1809 %(mmake)_CXX_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),%(cxxfiles))
1810 %(mmake)_OBJC_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),%(objcfiles))
1812 %rule_compile_cxx_multi mmake=%(mmake) \
1813 basenames=$(%(mmake)_CXX_NARCHFILES) targetdir="%(objdir)" \
1814 cppflags="%(cppflags)" cxxflags=$(%(mmake)_CXXFLAGS) dxxflags=$(%(mmake)_DXXFLAGS) \
1815 compiler="%(compiler)"
1816 %rule_compile_objc_multi mmake=%(mmake) \
1817 basenames=$(%(mmake)_OBJC_NARCHFILES) targetdir="%(objdir)" \
1818 cppflags="%(cppflags)" cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
1819 compiler="%(compiler)"
1820 %rule_compile_multi mmake=%(mmake) \
1821 basenames=$(%(mmake)_C_NARCHFILES) targetdir="%(objdir)" \
1822 cppflags="%(cppflags)" cflags="$(%(mmake)_CFLAGS)" dflags="$(%(mmake)_DFLAGS)" \
1823 compiler="%(compiler)"
1825 # Handlers use dash instead of dot in their names
1826 ifeq (%(modtype),handler)
1827 %(mmake)_MODULE := $(%(mmake)_MODDIR)/%(modname)-%(modtype)
1829 ifeq (%(modtype),printer)
1830 %(mmake)_MODULE := $(%(mmake)_MODDIR)/%(modname)
1832 %(mmake)_MODULE := $(%(mmake)_MODDIR)/%(modname).%(modtype)
1835 %(mmake)_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1837 %(mmake)-quick : %(mmake)
1838 %(mmake)-kobj-quick : $(%(mmake)_KOBJ)
1839 %(mmake) : $(%(mmake)_MODULE)
1840 %(mmake)-kobj : $(%(mmake)_KOBJ)
1842 # The module is linked from all the compiled .o files
1843 %(mmake)_OBJS := $(%(mmake)_ARCHOBJS) $(addprefix %(objdir)/, $(addsuffix .o,$(notdir $(%(mmake)_C_NARCHFILES))))
1845 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
1846 # This breaks con-handler build. Here we work around this
1847 ifeq (%(modname),con)
1848 %(mmake)_ERR := $(notdir $(%(mmake)_MODULE)).err
1850 %(mmake)_ERR := %(modname).err
1853 %rule_linkmodule module=$(%(mmake)_MODULE) objs=$(%(mmake)_OBJS) \
1854 endobj= err=$(%(mmake)_ERR) objdir="%(objdir)" \
1855 ldflags="$(strip $(LDFLAGS) $(%(modname)_LDFLAGS))" \
1856 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
1858 # Link kernel object file
1859 %(mmake)_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1861 # Make these symbols local
1862 %(mmake)_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1863 UtilityBase ExpansionBase KeymapBase KernelBase
1865 %(mmake)_SYMBOLS := $(%(mmake)_KBASE)
1867 %(mmake)_KLIB := hiddstubs amiga arossupport autoinit libinit
1868 %(mmake)_KOBJ_LIBS := $(filter-out $(%(mmake)_KLIB),%(uselibs)) $(%(mmake)_KAUTOLIB)
1869 $(%(mmake)_KOBJ) : LINKLIBS:=$(%(mmake)_KOBJ_LIBS)
1870 $(%(mmake)_KOBJ) : FILTBASES:=$(addprefix -L ,$(%(mmake)_SYMBOLS))
1871 $(%(mmake)_KOBJ) : USER_LDFLAGS := $(USER_LDFLAGS)
1872 $(%(mmake)_KOBJ) : $(%(mmake)_OBJS) $(%(mmake)_ENDOBJS)
1873 $(Q)$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
1874 $(Q)$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1875 $(Q)$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
1878 ## Dependency fine-tuning
1880 %(mmake)_DEPS := $(addprefix %(objdir)/, $(addsuffix .d,%(files)))
1881 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(%(mmake)_DEPS)
1883 $(%(mmake)_OBJS) $(%(mmake)_DEPS) : | %(objdir)
1884 $(%(mmake)_MODULE) : | $(%(mmake)_MODDIR)
1885 $(%(mmake)_KOBJ) : | $(KOBJSDIR)
1886 GLOB_MKDIRS += %(objdir) $(%(mmake)_MODDIR) $(KOBJSDIR)
1888 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_MODULE) $(%(mmake)_KOBJ) $(%(mmake)_DEPS)
1890 $(Q)$(ECHO) "Cleaning up for module %(modname)"
1893 #------------------------------------------------------------------------------
1896 #------------------------------------------------------------------------------
1897 # Build a module - core routine
1898 # Explanation of this macro is done in the developer's manual
1899 %define build_module_core mmake=/A modname=/A modtype=/A modsuffix= version= flavour= conffile= \
1900 files="$(basename $(call WILDCARD, *.c))" \
1902 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
1903 linklibfiles= linklibobjs= \
1904 cppflags=$(CPPFLAGS) \
1905 cflags=$(CFLAGS) dflags= \
1906 cxxflags=$(CXXFLAGS) dxxflags= \
1907 objdir= moduledir= prefix=$(AROSDIR) \
1908 linklibname= uselibs= usehostlibs= \
1909 compiler=target funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO) nostartup=yes archspecific=no \
1910 include_set=includes-all includedir= libdir= \
1911 build_abi= build_library=
1913 # We will employ a terrifying, but unavoidable, hack here.
1914 # genmf has no concept of conditionals (ie %ifeq), and MetaMake
1915 # ignores GNU Make ifeq() statements, but will process any #MM
1916 # headed lines in the file.
1918 # So, to make the following #MM lines conditional on whether we want
1919 # to build the ABI, Library, or both, we define build_abi= and
1920 # build_library as 'M' to enable, or '' to disable, which allows genmf
1921 # to do the following conversions:
1923 # #%(build_abi)M includes-foo: foo-include
1924 # becomes, when build_abi=M
1925 # #MM includes-foo: foo-include <= Processed by MetaMake
1926 # but, when build_abi= ...
1927 # #M includes-foo: foo-includes <= ignored by MetaMake! Yes!
1929 # Taking full blame for this: Jason S. McMullan <jason.mcmullan@gmail.com>
1931 # Define metamake targets and their dependencies
1934 #MM %(mmake)-makefile
1938 #M%(build_abi)- %(include_set) : %(mmake)-includes
1939 #M%(build_abi)- linklibs-%(modname): %(mmake)-linklib
1940 #M%(build_abi)- linklibs-%(modname)_rel : %(mmake)-linklib
1941 #M%(build_abi)- includes-%(modname): %(mmake)-includes
1942 #M%(build_abi)- includes-%(modname)_rel : %(mmake)-includes
1943 #M%(build_abi)- %(mmake) : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1944 #M%(build_abi) %(mmake)-linklib : %(mmake)-includes includes-%(uselibs)
1945 #M%(build_abi)- %(mmake)-quick : %(mmake)-includes-quick
1946 #M%(build_abi) %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1947 #M%(build_abi) includes-generate-deps %(mmake)-fd
1948 #M%(build_abi) %(mmake)-includes-quick
1949 #M%(build_abi) %(mmake)-includes-dirs
1950 #M%(build_abi) %(mmake)-fd
1953 #%(build_library)M %(mmake)-kobj : core-linklibs linklibs-%(uselibs)
1954 #%(build_library)M %(mmake)-kobj-quick :
1956 # Library with ABI targets:
1957 #%(build_library)%(build_abi) %(mmake)-kobj : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1958 #%(build_library)%(build_abi) %(mmake)-kobj-quick : %(mmake)-includes-quick
1960 # All MetaMake targets defined by this macro
1961 %(mmake)%(flavour)_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-clean
1963 ifeq (%(build_library),M)
1964 %(mmake)%(flavour)_ALLTARGETS += %(mmake)-kobj %(mmake)-kobj-quick
1967 ifeq (%(build_abi),M)
1968 %(mmake)%(flavour)_ALLTARGETS += %(mmake)-includes \
1969 %(mmake)-includes-quick %(mmake)-includes-dirs \
1970 %(mmake)-linklib %(mmake)-fd
1973 .PHONY : $(%(mmake)%(flavour)_ALLTARGETS) %(mmake)-makefile
1976 $(error using %build_module: modname may not be empty)
1979 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1982 # Default values for variables and arguments
1984 %(mmake)%(flavour)_DEFNAME := %(modname)_%(flavour)
1986 %(mmake)%(flavour)_DEFNAME := %(modname)
1988 %(mmake)%(flavour)_DEFLINKLIBNAME := $(%(mmake)%(flavour)_DEFNAME)
1989 ifneq (%(linklibname),)
1990 %(mmake)%(flavour)_LINKLIBNAME := %(linklibname)
1992 %(mmake)%(flavour)_LINKLIBNAME = $(%(mmake)%(flavour)_DEFLINKLIBNAME)
1994 %(mmake)%(flavour)_DEFCPPFLAGS := %(cppflags)
1995 ifneq (%(includedir),)
1996 %(mmake)%(flavour)_DEFCPPFLAGS += -I%(includedir)
1998 %(mmake)%(flavour)_DEFDFLAGS := %(cflags)
2000 %(mmake)%(flavour)_DFLAGS := %(dflags)
2002 %(mmake)%(flavour)_DFLAGS = $(%(mmake)%(flavour)_DEFDFLAGS)
2004 %(mmake)%(flavour)_DEFDXXFLAGS := %(cxxflags)
2005 ifneq (%(dxxflags),)
2006 %(mmake)%(flavour)_DXXFLAGS := %(dxxflags)
2008 %(mmake)%(flavour)_DXXFLAGS = $(%(mmake)%(flavour)_DEFDXXFLAGS)
2010 ifeq (%(compiler),target)
2012 %(mmake)%(flavour)_DEFDFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH) $(%(mmake)%(flavour)_DEFDFLAGS))
2013 %(mmake)%(flavour)_DEFDXXFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH) $(%(mmake)%(flavour)_DEFDXXFLAGS))
2015 ifeq (%(funcinstr),yes)
2016 %(mmake)_FUNCINSTR := yes
2017 %(mmake)%(flavour)_DEFDFLAGS := $(strip $(FUNCINSTR_FLAGS) $(%(mmake)%(flavour)_DEFDFLAGS))
2018 %(mmake)%(flavour)_DEFDXXFLAGS := $(strip $(FUNCINSTR_FLAGS) $(%(mmake)%(flavour)_DEFDXXFLAGS))
2021 OBJDIR ?= $(GENDIR)/$(CURDIR)
2023 %(mmake)_OBJDIR := %(objdir)
2025 %(mmake)%(flavour)_OBJDIR := %(objdir)
2028 %(mmake)_OBJDIR := $(OBJDIR)/%(modname)
2030 %(mmake)%(flavour)_OBJDIR := $(OBJDIR)/$(%(mmake)%(flavour)_DEFNAME)
2034 ## Create genmodule include Makefile for the module
2036 %(mmake)-makefile : $(%(mmake)%(flavour)_OBJDIR)/Makefile.$(%(mmake)%(flavour)_DEFNAME)%(modtype)
2038 %rule_genmodule_makefile \
2039 modname="%(modname)" flavour="%(flavour)" modtype="%(modtype)" \
2040 modsuffix="%(modsuffix)" targetdir="$(%(mmake)%(flavour)_OBJDIR)" \
2041 conffile="%(conffile)"
2043 $(%(mmake)%(flavour)_OBJDIR)/Makefile.$(%(mmake)%(flavour)_DEFNAME)%(modtype) : | $(%(mmake)%(flavour)_OBJDIR)
2045 GLOB_MKDIRS += $(%(mmake)%(flavour)_OBJDIR)
2047 GLOB_MKDIRS += $(%(mmake)%(flavour)_OBJDIR)
2050 # Do not parse these statements if metatarget is not appropriate
2051 ifneq ($(filter $(TARGET),$(%(mmake)%(flavour)_ALLTARGETS)),)
2053 # suppress makes warning that the Makefile doesnt yet exist
2054 # on early passes (it will generate the file as needed though)
2055 # when we include it.
2056 -include $(%(mmake)%(flavour)_OBJDIR)/Makefile.$(%(mmake)%(flavour)_DEFNAME)%(modtype)
2058 %(mmake)%(flavour)_DEFMODDIR := $($(%(mmake)%(flavour)_DEFNAME)_MODDIR)
2059 ifeq (%(archspecific),yes)
2060 %(mmake)%(flavour)_DEFMODDIR := $(AROS_DIR_ARCH)/$(%(mmake)%(flavour)_DEFMODDIR)
2062 ifneq (%(moduledir),)
2063 %(mmake)%(flavour)_MODDIR := %(moduledir)
2065 %(mmake)%(flavour)_MODDIR := $(%(mmake)%(flavour)_DEFMODDIR)
2068 ## include files generation
2070 ifneq (%(includedir),)
2071 %(mmake)%(flavour)_INCDIR := %(includedir)
2073 %(mmake)%(flavour)_INCDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/$(AROS_DIR_INCLUDE)
2075 %(mmake)%(flavour)_LIBDEFSINC := $(%(mmake)%(flavour)_OBJDIR)/include/$(%(mmake)%(flavour)_DEFNAME)_libdefs.h
2076 %(mmake)%(flavour)_DEFLIBDEFSINC := $(%(mmake)%(flavour)_OBJDIR)/include/$(%(mmake)%(flavour)_DEFNAME)_deflibdefs.h
2078 ifeq (%(build_abi),M)
2079 %(mmake)-includes-quick : %(mmake)-includes
2080 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2081 $(addprefix $(%(mmake)%(flavour)_INCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2082 $(%(mmake)%(flavour)_LIBDEFSINC) $(%(mmake)%(flavour)_DEFLIBDEFSINC)
2084 ifneq ($($(%(mmake)%(flavour)_DEFNAME)_INCLUDES),)
2085 %rule_genmodule_includes modname="%(modname)" modtype="%(modtype)" \
2086 modsuffix="%(modsuffix)" targetdir="$(%(mmake)_OBJDIR)/include" \
2087 conffile="%(conffile)" flavour="%(flavour)"
2089 %rule_copy_diff_multi \
2090 files=$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES) srcdir="$(%(mmake)_OBJDIR)/include" targetdir=$(GENINCDIR) \
2091 stampfile="$(%(mmake)_OBJDIR)/%(modname)_geninc"
2093 %rule_copy_diff_multi \
2094 files=$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES) srcdir="$(%(mmake)_OBJDIR)/include" targetdir=$(%(mmake)%(flavour)_INCDIR) \
2095 stampfile="$(%(mmake)_OBJDIR)/%(modname)_incs"
2097 %(mmake)%(flavour)_INCDIRS := $(filter-out ./,$(sort $(dir $($(%(mmake)%(flavour)_DEFNAME)_INCLUDES))))
2099 TMP%(modname)_INCDIRS := \
2100 $(%(mmake)_OBJDIR)/include $(addprefix $(%(mmake)_OBJDIR)/include/,$(%(mmake)%(flavour)_INCDIRS)) \
2101 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(%(mmake)%(flavour)_INCDIRS)) \
2102 $(%(mmake)%(flavour)_INCDIR) $(addprefix $(%(mmake)%(flavour)_INCDIR)/,$(%(mmake)%(flavour)_INCDIRS))
2103 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget="%(mmake)-includes-dirs"
2109 %rule_genmodule_genlibdefs modname="%(modname)" flavour="%(flavour)" modtype="%(modtype)" \
2110 modsuffix="%(modsuffix)" targetdir="$(%(mmake)%(flavour)_OBJDIR)/include" \
2111 conffile="%(conffile)" version="%(version)"
2113 $(%(mmake)%(flavour)_DEFLIBDEFSINC) : FILENAME := $(%(mmake)%(flavour)_LIBDEFSINC)
2114 $(%(mmake)%(flavour)_DEFLIBDEFSINC) :
2115 $(Q)$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
2116 $(Q)$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
2118 $(%(mmake)%(flavour)_LIBDEFSINC) $(%(mmake)%(flavour)_DEFLIBDEFSINC) : | $(%(mmake)%(flavour)_OBJDIR)/include
2119 GLOB_MKDIRS += $(%(mmake)%(flavour)_OBJDIR)/include
2121 ## Extra genmodule src files generation
2123 %rule_genmodule_files modname="%(modname)" modtype="%(modtype)" \
2124 modsuffix="%(modsuffix)" targetdir="$(%(mmake)%(flavour)_OBJDIR)" stubdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" \
2125 conffile="%(conffile)" flavour="%(flavour)"
2127 GLOB_MKDIRS += $(%(mmake)%(flavour)_OBJDIR)/linklib
2129 ifeq (%(build_abi),M)
2131 ifeq (%(includedir),)
2132 %(mmake)%(flavour)_FDDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/$(AROS_DIR_SDK)/$(AROS_DIR_FD)
2134 %(mmake)%(flavour)_FDDIR := %(includedir)/../$(AROS_DIR_FD)
2136 %(mmake)-fd : $(%(mmake)%(flavour)_FDDIR)/%(modname)_lib.fd
2138 %rule_genmodule_fd modname="%(modname)" modtype="%(modtype)" \
2139 modsuffix="%(modsuffix)" targetdir=$(%(mmake)%(flavour)_FDDIR) conffile="%(conffile)"
2141 $(%(mmake)%(flavour)_FDDIR)/%(modname)_lib.fd : | $(%(mmake)%(flavour)_FDDIR)
2143 GLOB_MKDIRS += $(%(mmake)%(flavour)_FDDIR)
2148 %(mmake)%(flavour)_FILES := %(files)
2149 %(mmake)%(flavour)_OBJCFILES := %(objcfiles)
2150 %(mmake)%(flavour)_CXXFILES := %(cxxfiles)
2152 %(mmake)%(flavour)_LIBFILES := %(linklibfiles)
2153 %(mmake)%(flavour)_LIBS := %(uselibs)
2155 %(mmake)%(flavour)_FDIRS := $(sort $(dir $(%(mmake)%(flavour)_FILES)))
2157 %(mmake)%(flavour)_FILEMATCH = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1)))
2158 %(mmake)%(flavour)_MATCHARCH = $(foreach matchfile,$(2),$(foreach archfile,$(1),$(if $(call %(mmake)%(flavour)_FILEMATCH,$(archfile),$(notdir $(matchfile))),$(matchfile),)))
2159 %(mmake)%(flavour)_FILTERARCH = $(filter-out $(call %(mmake)%(flavour)_MATCHARCH,$(1),$(2)),$(2))
2160 %(mmake)%(flavour)_STARTFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_STARTFILES))
2161 %(mmake)%(flavour)_ENDFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_ENDFILES))
2163 %(mmake)%(flavour)_ARCHOBJS := $(wildcard $(%(mmake)%(flavour)_OBJDIR)/arch/*.o)
2164 %(mmake)%(flavour)_LIBARCHOBJS := $(wildcard $(%(mmake)%(flavour)_OBJDIR)/linklib/arch/*.o)
2165 %(mmake)%(flavour)_ARCHFILES := $(basename $(notdir $(%(mmake)%(flavour)_ARCHOBJS)))
2166 %(mmake)%(flavour)_LIBARCHFILES := $(basename $(notdir $(%(mmake)%(flavour)_LIBARCHOBJS)))
2167 %(mmake)%(flavour)_C_NARCHFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_ARCHFILES),$(%(mmake)%(flavour)_FILES))
2168 %(mmake)%(flavour)_CXX_NARCHFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_ARCHFILES),$(%(mmake)%(flavour)_CXXFILES))
2169 %(mmake)%(flavour)_OBJC_NARCHFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_ARCHFILES),$(%(mmake)%(flavour)_OBJCFILES))
2170 %(mmake)%(flavour)_NLIBARCHFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_LIBARCHFILES),$(%(mmake)%(flavour)_LIBFILES))
2171 %(mmake)%(flavour)_ARCHNLIBFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_LIBFILES),$(%(mmake)%(flavour)_LIBARCHFILES))
2173 %(mmake)%(flavour)_CPPFLAGS := $(strip %(cppflags) -I$(%(mmake)%(flavour)_OBJDIR)/include -include $(%(mmake)%(flavour)_DEFLIBDEFSINC))
2174 ifneq (%(includedir),)
2175 %(mmake)%(flavour)_CPPFLAGS += -I%(includedir)
2177 %(mmake)%(flavour)_LINKLIBCPPFLAGS := $(%(mmake)%(flavour)_CPPFLAGS)
2178 %(mmake)%(flavour)_CPPFLAGS += $(strip $($(%(mmake)%(flavour)_DEFNAME)_CPPFLAGS))
2179 %(mmake)%(flavour)_LINKLIBCPPFLAGS += $(strip $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBCPPFLAGS))
2180 %(mmake)%(flavour)_CFLAGS := $(strip %(cflags) $($(%(mmake)%(flavour)_DEFNAME)_CFLAGS))
2181 %(mmake)%(flavour)_LINKLIBCFLAGS := $(strip %(cflags) $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBCFLAGS))
2182 %(mmake)%(flavour)_CXXFLAGS := $(strip %(cxxflags) $($(%(mmake)%(flavour)_DEFNAME)_CXXFLAGS))
2183 ifeq (%(compiler),target)
2185 %(mmake)%(flavour)_LTOFLAGS ?= $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH))
2186 %(mmake)%(flavour)_CFLAGS := $(strip $(%(mmake)%(flavour)_LTOFLAGS) $(%(mmake)%(flavour)_CFLAGS))
2187 %(mmake)%(flavour)_LINKLIBCFLAGS := $(strip $(%(mmake)%(flavour)_LTOFLAGS) $(%(mmake)%(flavour)_LINKLIBCFLAGS))
2188 %(mmake)%(flavour)_CXXFLAGS := $(strip $(%(mmake)%(flavour)_LTOFLAGS) $(%(mmake)%(flavour)_CXXFLAGS))
2190 ifeq (%(funcinstr),yes)
2191 %(mmake)%(flavour)_SUBSTNULL :=
2192 %(mmake)%(flavour)_SUBSTSPACE := $(%(mmake)%(flavour)_SUBSTNULL) #
2193 %(mmake)%(flavour)_SUBSTCOMMA := ,
2194 %(mmake)%(flavour)_INSTRFUNCFLAGS ?= $(strip $(FUNCINSTR_FLAGS) -finstrument-functions-exclude-file-list=$(subst $(%(mmake)%(flavour)_SUBSTSPACE),$(%(mmake)%(flavour)_SUBSTCOMMA),$(strip $($(%(mmake)%(flavour)_DEFNAME)_STARTFILES))))
2195 %(mmake)%(flavour)_INSTRFUNCLIBS ?= $(FUNCINSTR_LIBS)
2196 %(mmake)%(flavour)_CFLAGS := $(strip $(%(mmake)%(flavour)_INSTRFUNCFLAGS) $(%(mmake)%(flavour)_CFLAGS))
2197 %(mmake)%(flavour)_CXXFLAGS := $(strip $(%(mmake)%(flavour)_INSTRFUNCFLAGS) $(%(mmake)%(flavour)_CXXFLAGS))
2198 %(mmake)%(flavour)_LIBS += $(%(mmake)%(flavour)_INSTRFUNCLIBS)
2201 %(mmake)%(flavour)_DFLAGS := $(strip $(%(mmake)%(flavour)_DFLAGS) $($(%(mmake)%(flavour)_DEFNAME)_DFLAGS))
2202 %(mmake)%(flavour)_LINKLIBDFLAGS := $(strip $(%(mmake)%(flavour)_DFLAGS) $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBDFLAGS))
2203 %(mmake)%(flavour)_DXXFLAGS := $(strip $(%(mmake)%(flavour)_DXXFLAGS) $($(%(mmake)%(flavour)_DEFNAME)_DXXFLAGS))
2205 ifeq (%(modtype),library)
2206 %(mmake)%(flavour)_LIBSUFFIX :=
2208 %(mmake)%(flavour)_LIBSUFFIX := .%(modtype)
2212 %(mmake)%(flavour)_LIBDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/$(AROS_DIR_LIB)
2214 %(mmake)%(flavour)_LIBDIR := %(libdir)
2217 ifeq (%(build_abi),M)
2218 %(mmake)%(flavour)_LINKLIBCFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$($(%(mmake)%(flavour)_DEFNAME)_LINKLIBFILES))
2219 %(mmake)%(flavour)_LINKLIBAFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$($(%(mmake)%(flavour)_DEFNAME)_LINKLIBAFILES))
2220 ifeq ($(strip $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBFILES) $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBAFILES) %(linklibfiles) $(%(mmake)%(flavour)_ARCHNLIBFILES)),)
2221 %(mmake)%(flavour)_LINKLIB :=
2223 %(mmake)%(flavour)_LINKLIB := $(%(mmake)%(flavour)_LIBDIR)/lib%(modname)$(%(mmake)%(flavour)_LIBSUFFIX).a
2224 ifneq (%(modname),$(%(mmake)%(flavour)_LINKLIBNAME))
2225 %(mmake)%(flavour)_LINKLIB += $(%(mmake)%(flavour)_LIBDIR)/lib$(%(mmake)%(flavour)_LINKLIBNAME)$(%(mmake)%(flavour)_LIBSUFFIX).a
2228 %(mmake)%(flavour)_LINKLIBFILES := $(%(mmake)%(flavour)_LINKLIBCFILES) $(%(mmake)%(flavour)_LINKLIBAFILES)
2230 %(mmake)%(flavour)_RELLINKLIBCFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$($(%(mmake)%(flavour)_DEFNAME)_RELLINKLIBFILES))
2231 %(mmake)%(flavour)_RELLINKLIBAFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$($(%(mmake)%(flavour)_DEFNAME)_RELLINKLIBAFILES))
2232 ifeq ($(strip $($(%(mmake)%(flavour)_DEFNAME)_RELLINKLIBFILES) $($(%(mmake)%(flavour)_DEFNAME)_RELLINKLIBAFILES) %(linklibfiles) $(%(mmake)%(flavour)_ARCHNLIBFILES)),)
2233 %(mmake)%(flavour)_RELLINKLIB :=
2235 %(mmake)%(flavour)_RELLINKLIB := $(%(mmake)%(flavour)_LIBDIR)/lib$(%(mmake)%(flavour)_DEFNAME)_rel$(%(mmake)%(flavour)_LIBSUFFIX).a
2236 ifneq (%(modname),$(%(mmake)%(flavour)_LINKLIBNAME))
2237 %(mmake)%(flavour)_RELLINKLIB += $(%(mmake)%(flavour)_LIBDIR)/lib$(%(mmake)%(flavour)_LINKLIBNAME)_rel$(%(mmake)%(flavour)_LIBSUFFIX).a
2240 %(mmake)%(flavour)_RELLINKLIBFILES := $(%(mmake)%(flavour)_RELLINKLIBCFILES) $(%(mmake)%(flavour)_RELLINKLIBAFILES)
2243 %(mmake)%(flavour)_ENDOBJS := $(addsuffix .o,$(%(mmake)%(flavour)_ENDFILES))
2244 %(mmake)%(flavour)_LINKLIBOBJS := $(addsuffix .o,$(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$(notdir $(%(mmake)%(flavour)_NLIBARCHFILES))) $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/arch/,$(notdir $(%(mmake)%(flavour)_ARCHNLIBFILES))) $(%(mmake)%(flavour)_LINKLIBFILES)) \
2246 %(mmake)%(flavour)_RELLINKLIBOBJS := $(addsuffix .o,$(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$(notdir $(%(mmake)%(flavour)_NLIBARCHFILES))) $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/arch/,$(notdir $(%(mmake)%(flavour)_ARCHNLIBFILES))) $(%(mmake)%(flavour)_RELLINKLIBFILES)) \
2248 $(%(mmake)%(flavour)_LINKLIBFILES) $(%(mmake)%(flavour)_RELLINKLIBFILES) : | $(%(mmake)%(flavour)_OBJDIR)/linklib
2249 $(%(mmake)%(flavour)_LINKLIBOBJS) $(%(mmake)%(flavour)_RELLINKLIBOBJS) : | $(%(mmake)%(flavour)_OBJDIR)/linklib
2251 %(mmake)%(flavour)_CCFILES := $(%(mmake)%(flavour)_C_NARCHFILES)
2252 %(mmake)%(flavour)_TARGETCCFILES := $(strip $(%(mmake)%(flavour)_STARTFILES) $(%(mmake)%(flavour)_ENDFILES))
2253 %(mmake)%(flavour)_LINKLIBCCFILES := $(strip $(%(mmake)%(flavour)_NLIBARCHFILES) $(%(mmake)%(flavour)_LINKLIBCFILES) $(%(mmake)%(flavour)_RELLINKLIBCFILES))
2254 %(mmake)%(flavour)_LINKLIBCCGENFILES := $(strip $(%(mmake)%(flavour)_LINKLIBCFILES) $(%(mmake)%(flavour)_RELLINKLIBCFILES))
2256 %rule_compile_cxx_multi mmake=%(mmake)%(flavour) \
2257 basenames=$(%(mmake)%(flavour)_CXX_NARCHFILES) targetdir="$(%(mmake)%(flavour)_OBJDIR)" \
2258 cppflags=$(%(mmake)%(flavour)_CPPFLAGS) cxxflags=$(%(mmake)%(flavour)_CXXFLAGS) dxxflags=$(%(mmake)%(flavour)_DXXFLAGS) \
2259 compiler="%(compiler)"
2260 %rule_compile_objc_multi mmake=%(mmake)%(flavour) \
2261 basenames=$(%(mmake)%(flavour)_OBJC_NARCHFILES) targetdir=$(%(mmake)%(flavour)_OBJDIR) \
2262 cppflags=$(%(mmake)%(flavour)_CPPFLAGS) cflags=$(%(mmake)%(flavour)_CFLAGS) dflags=$(%(mmake)%(flavour)_DFLAGS) \
2263 compiler="%(compiler)"
2264 %rule_compile_multi mmake=%(mmake)%(flavour) \
2265 basenames=$(%(mmake)%(flavour)_CCFILES) targetdir="$(%(mmake)%(flavour)_OBJDIR)" \
2266 cppflags=$(%(mmake)%(flavour)_CPPFLAGS) cflags=$(%(mmake)%(flavour)_CFLAGS) dflags=$(%(mmake)%(flavour)_DFLAGS) \
2267 compiler="%(compiler)"
2268 %rule_compile_multi mmake=%(mmake)%(flavour) \
2269 basenames=$(%(mmake)%(flavour)_TARGETCCFILES) targetdir="$(%(mmake)%(flavour)_OBJDIR)" \
2270 cppflags="$(%(mmake)%(flavour)_CPPFLAGS) -D__AROS__" cflags=$(%(mmake)%(flavour)_CFLAGS) dflags=$(%(mmake)%(flavour)_DFLAGS) \
2271 compiler="%(compiler)"
2272 %rule_compile_multi mmake=%(mmake)%(flavour) \
2273 basenames=$(%(mmake)%(flavour)_NLIBARCHFILES) targetdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" \
2274 cppflags="$(%(mmake)%(flavour)_LINKLIBCPPFLAGS) -D__AROS__" cflags=$(%(mmake)%(flavour)_LINKLIBCFLAGS) dflags=$(%(mmake)%(flavour)_LINKLIBDFLAGS) \
2275 compiler="%(compiler)"
2276 %rule_compile_multi mmake=%(mmake)%(flavour) \
2277 basenames=$(%(mmake)%(flavour)_LINKLIBCCGENFILES) srcdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" targetdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" \
2278 cppflags="$(%(mmake)%(flavour)_LINKLIBCPPFLAGS) -D__AROS__" cflags=$(%(mmake)%(flavour)_LINKLIBCFLAGS) dflags=$(%(mmake)%(flavour)_LINKLIBDFLAGS) \
2279 compiler="%(compiler)"
2281 ifneq ($(%(mmake)%(flavour)_LINKLIBAFILES),)
2282 %rule_assemble_multi mmake=%(mmake)%(flavour) \
2283 cmd=$(%(mmake)%(flavour)_ASSEMBLER) basenames="$(%(mmake)%(flavour)_LINKLIBAFILES) $(%(mmake)%(flavour)_RELLINKLIBAFILES)" targetdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" suffix=.S
2288 ifeq (%(modsuffix),)
2289 %(mmake)%(flavour)_SUFFIX := %(modtype)
2291 %(mmake)%(flavour)_SUFFIX := %(modsuffix)
2294 ifeq (%(build_library),M)
2295 # Handlers use dash instead of dot in their names
2296 ifeq ($(%(mmake)%(flavour)_SUFFIX),handler)
2297 %(mmake)%(flavour)_MODULE := %(prefix)/$(%(mmake)%(flavour)_MODDIR)/$(%(mmake)%(flavour)_DEFNAME)-$(%(mmake)%(flavour)_SUFFIX)
2299 %(mmake)%(flavour)_MODULE := %(prefix)/$(%(mmake)%(flavour)_MODDIR)/$(%(mmake)%(flavour)_DEFNAME).$(%(mmake)%(flavour)_SUFFIX)
2301 %(mmake)%(flavour)_KOBJ := $(KOBJSDIR)/$(%(mmake)%(flavour)_DEFNAME)_$(%(mmake)%(flavour)_SUFFIX).o
2303 %(mmake)%(flavour)_MODULE :=
2304 %(mmake)%(flavour)_KOBJ :=
2307 %(mmake)-quick : %(mmake)
2308 %(mmake) : $(%(mmake)%(flavour)_MODULE) $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_RELLINKLIB)
2309 ifeq (%(build_library),M)
2310 %(mmake)-kobj : $(%(mmake)%(flavour)_KOBJ) $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_RELLINKLIB)
2311 %(mmake)-kobj-quick : $(%(mmake)%(flavour)_KOBJ) $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_RELLINKLIB)
2313 ifeq (%(build_abi),M)
2314 %(mmake)-linklib : $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_RELLINKLIB)
2317 %(mmake)%(flavour)_OBJS := $(addsuffix .o,$(%(mmake)%(flavour)_STARTFILES)) $(%(mmake)%(flavour)_ARCHOBJS) \
2318 $(addprefix $(%(mmake)%(flavour)_OBJDIR)/,$(notdir $(%(mmake)%(flavour)_C_NARCHFILES:=.o) $(%(mmake)%(flavour)_CXXFILES:=.o)))
2320 ifeq (%(nostartup),yes)
2321 # Handlers always have entry point
2322 ifneq (%(modtype),handler)
2323 %(mmake)%(flavour)_STARTOBJS := $(addsuffix .o,$(addprefix $(GENDIR)/,$(RESIDENT_BEGIN)))
2327 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
2328 # This breaks con-handler build. Here we work around this
2329 ifeq (%(modname),con)
2330 %(mmake)%(flavour)_ERR := $(notdir $(%(mmake)%(flavour)_MODULE)).err
2332 %(mmake)%(flavour)_ERR := %(modname).err
2335 ifeq (%(build_library),M)
2336 # The module is linked from all the compiled .o files
2337 %rule_linkmodule module=$(%(mmake)%(flavour)_MODULE) objs="$(%(mmake)%(flavour)_STARTOBJS) $(%(mmake)%(flavour)_OBJS) $(USER_OBJS)" \
2338 endobj=$(%(mmake)%(flavour)_ENDOBJS) err=$(%(mmake)%(flavour)_ERR) objdir="$(%(mmake)%(flavour)_OBJDIR)" \
2339 cmd=$(%(mmake)%(flavour)_LINK) ldflags="$(LDFLAGS) $($(%(mmake)%(flavour)_DEFNAME)_LDFLAGS)" \
2340 uselibs="$(%(mmake)%(flavour)_LIBS) $($(%(mmake)%(flavour)_DEFNAME)_LIBS)" usehostlibs="%(usehostlibs)"
2343 ifeq (%(build_abi),M)
2345 %(mmake)%(flavour)_LC_LINKLIBNAME := $(shell echo $(%(mmake)%(flavour)_LINKLIBNAME) | tr A-Z a-z)
2346 %(mmake)%(flavour)_LC_MODNAME := $(shell echo %(modname) | tr A-Z a-z)
2347 ifneq ($(%(mmake)%(flavour)_LINKLIB),)
2348 %rule_link_linklib mmake=%(mmake) libname="$(%(mmake)%(flavour)_LINKLIBNAME)$(%(mmake)%(flavour)_LIBSUFFIX)" objs=$(%(mmake)%(flavour)_LINKLIBOBJS) libdir="$(%(mmake)%(flavour)_LIBDIR)"
2349 ifneq ($(%(mmake)%(flavour)_LC_MODNAME),$(%(mmake)%(flavour)_LC_LINKLIBNAME))
2350 %rule_link_linklib mmake=%(mmake) libname="%(modname)$(%(mmake)%(flavour)_LIBSUFFIX)" objs=$(%(mmake)%(flavour)_LINKLIBOBJS) libdir="$(%(mmake)%(flavour)_LIBDIR)"
2353 $(%(mmake)%(flavour)_LINKLIB) : | $(%(mmake)%(flavour)_LIBDIR)
2354 GLOB_MKDIRS += $(%(mmake)%(flavour)_LIBDIR)
2357 ifneq ($(%(mmake)%(flavour)_RELLINKLIB),)
2358 %rule_link_linklib mmake=%(mmake) libname="$(%(mmake)%(flavour)_LINKLIBNAME)_rel$(%(mmake)%(flavour)_LIBSUFFIX)" objs=$(%(mmake)%(flavour)_RELLINKLIBOBJS) libdir="$(%(mmake)%(flavour)_LIBDIR)"
2359 ifneq ($(%(mmake)%(flavour)_LC_MODNAME),$(%(mmake)%(flavour)_LC_LINKLIBNAME))
2360 %rule_link_linklib mmake=%(mmake) libname="$(%(mmake)%(flavour)_DEFNAME)_rel$(%(mmake)%(flavour)_LIBSUFFIX)" objs=$(%(mmake)%(flavour)_RELLINKLIBOBJS) libdir="$(%(mmake)%(flavour)_LIBDIR)"
2363 $(%(mmake)%(flavour)_RELLINKLIB) : | $(%(mmake)%(flavour)_LIBDIR)
2364 GLOB_MKDIRS += $(%(mmake)%(flavour)_LIBDIR)
2368 ifeq (%(build_library),M)
2369 # Link kernel object file
2370 %(mmake)%(flavour)_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
2372 # Make these symbols local
2373 %(mmake)%(flavour)_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
2374 UtilityBase ExpansionBase KeymapBase KernelBase
2376 %(mmake)%(flavour)_SYMBOLS := $(%(mmake)%(flavour)_KBASE)
2378 %(mmake)%(flavour)_KLIB := hiddstubs amiga arossupport autoinit libinit
2379 %(mmake)%(flavour)_KOBJ_LIBS := $(filter-out $(%(mmake)%(flavour)_KLIB),$(%(mmake)%(flavour)_LIBS)) $(%(mmake)%(flavour)_KAUTOLIB)
2380 $(%(mmake)%(flavour)_KOBJ) : LINKLIBS:=$(%(mmake)%(flavour)_KOBJ_LIBS) $($(%(mmake)%(flavour)_DEFNAME)_LIBS)
2381 $(%(mmake)%(flavour)_KOBJ) : FILTBASES:=$(addprefix -L ,$(%(mmake)%(flavour)_SYMBOLS))
2382 $(%(mmake)%(flavour)_KOBJ) : USER_LDFLAGS:=$(USER_LDFLAGS)
2383 $(%(mmake)%(flavour)_KOBJ) : $(%(mmake)%(flavour)_OBJS) $(USER_OBJS) $(%(mmake)%(flavour)_ENDOBJS)
2384 $(Q)$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
2385 $(Q)$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
2386 $(Q)$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
2389 ## Dependency fine-tuning
2391 %(mmake)%(flavour)_DEPS := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/,$(notdir $(%(mmake)%(flavour)_CCFILES:=.d) $(%(mmake)%(flavour)_TARGETCCFILES:=.d) $(%(mmake)%(flavour)_CXXFILES:=.d))) $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$(notdir $(%(mmake)%(flavour)_LINKLIBCCFILES:=.d)))
2393 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick" deps=$(%(mmake)%(flavour)_DEPS)
2395 $(%(mmake)%(flavour)_OBJS) $(%(mmake)%(flavour)_DEPS) : | $(%(mmake)%(flavour)_OBJDIR) $(%(mmake)%(flavour)_OBJDIR)/linklib
2396 $(%(mmake)%(flavour)_MODULE) : | %(prefix)/$(%(mmake)%(flavour)_MODDIR)
2397 $(%(mmake)%(flavour)_KOBJ) : | $(KOBJSDIR)
2398 GLOB_MKDIRS += $(%(mmake)%(flavour)_OBJDIR) %(prefix)/$(%(mmake)%(flavour)_MODDIR) $(KOBJSDIR)
2400 # Some include files need to be generated before the .c can be parsed.
2401 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick),) # Only for this target these deps are wanted
2403 %(mmake)%(flavour)_DFILE_DEPS := $(%(mmake)%(flavour)_LIBDEFSINC) $(%(mmake)%(flavour)_DEFLIBDEFSINC) \
2404 $(addprefix $(%(mmake)%(flavour)_INCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES))
2405 $(%(mmake)%(flavour)_DEPS) : $(%(mmake)%(flavour)_DFILE_DEPS)
2408 %(mmake)%(flavour)_TOCLEAN := $(%(mmake)%(flavour)_OBJS) $(%(mmake)%(flavour)_DEPS) \
2409 $(%(mmake)%(flavour)_MODULE) $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_KOBJ) \
2410 $(%(mmake)%(flavour)_OBJDIR)/Makefile.%(modname)%(modtype) \
2411 $(addprefix $(%(mmake)%(flavour)_OBJDIR)/include/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2412 $(addprefix $(GENINCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2413 $(addprefix $(%(mmake)%(flavour)_INCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2414 $(%(mmake)%(flavour)_OBJDIR)/%(modname)_geninc $(%(mmake)%(flavour)_OBJDIR)/%(modname)_incs \
2415 $(addsuffix .c,$(%(mmake)%(flavour)_LINKLIBFILES)) $(%(mmake)%(flavour)_LINKLIBOBJS) $(%(mmake)%(flavour)_LIBDEFSINC) \
2416 $(%(mmake)%(flavour)_DEFLIBDEFSINC) $(addsuffix .c,$(%(mmake)%(flavour)_STARTFILES) $(%(mmake)%(flavour)_ENDFILES)) \
2417 $(%(mmake)%(flavour)_ENDOBJS)
2418 %(mmake)-clean : FILES := $(%(mmake)%(flavour)_TOCLEAN)
2420 $(Q)$(ECHO) "Cleaning up for module %(modname)"
2423 endif # $(TARGET) in $(%(mmake)%(flavour)_ALLTARGETS)
2425 #------------------------------------------------------------------------------
2427 #------------------------------------------------------------------------------
2428 # Build a module - ABI and library
2429 # Explanation of this macro is done in the developer's manual
2430 %define build_module mmake=/A modname=/A modtype=/A modsuffix= version= flavour= conffile= \
2431 files="$(basename $(call WILDCARD, *.c))" \
2433 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2434 linklibfiles= linklibobjs= cflags=$(CFLAGS) cppflags=$(CPPFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= \
2435 objdir= moduledir= prefix=$(AROSDIR) \
2436 linklibname= uselibs= usehostlibs= \
2437 compiler=target funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO) nostartup=yes archspecific=no \
2438 include_set=includes-all includedir= libdir=
2440 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2441 modsuffix="%(modsuffix)" version="%(version)" flavour="%(flavour)" conffile="%(conffile)" \
2442 files="%(files)" objcfiles="%(objcfiles)" cxxfiles="%(cxxfiles)" \
2443 linklibname="%(linklibname)" \
2444 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2445 cflags="%(cflags)" cppflags="%(cppflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2446 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2447 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" funcinstr=%(funcinstr) lto=%(lto) \
2448 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2449 include_set=%(include_set) includedir="%(includedir)" libdir="%(libdir)" \
2450 build_abi=M build_library=M
2453 #------------------------------------------------------------------------------
2456 #------------------------------------------------------------------------------
2457 # Build a module skeleton ABI
2458 # This is a stripped-down version of build_module, it only creates include
2459 # files and the linklibs.
2460 # This is used when for plugins or classes with the same API, but no actual
2461 # implementation here.
2462 %define build_module_abi mmake=/A modname=/A modtype=/A modsuffix= version= flavour= conffile= \
2463 linklibfiles= linklibobjs= cflags=$(CFLAGS) cppflags=$(CPPFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= \
2464 objdir= moduledir= prefix=$(AROSDIR) \
2465 linklibname= uselibs= usehostlibs= \
2466 compiler=target nostartup=yes archspecific=no \
2467 include_set=includes-all includedir= libdir=
2469 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2470 modsuffix="%(modsuffix)" version="%(version)" flavour="%(flavour)" conffile="%(conffile)" \
2471 linklibname="%(linklibname)" \
2472 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2473 cflags="%(cflags)" cppflags="%(cppflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2474 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2475 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" lto=%(lto) \
2476 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2477 include_set=%(include_set) includedir="%(includedir)" libdir="%(libdir)" \
2478 build_abi=M build_library=
2481 #------------------------------------------------------------------------------
2483 #------------------------------------------------------------------------------
2484 # Build a module library - no includes nor linklibs
2485 # Explanation of this macro is done in the developer's manual
2486 %define build_module_library mmake=/A modname=/A modtype=/A modsuffix= version= flavour= conffile= \
2487 files="$(basename $(call WILDCARD, *.c))" \
2489 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2490 cflags=$(CFLAGS) cppflags=$(CPPFLAGS) dflags= cxxflags="$(CXXFLAGS)" dxxflags= \
2491 objdir= moduledir= prefix=$(AROSDIR) \
2492 uselibs= usehostlibs= \
2493 compiler=target lto=$(TARGET_LTO) nostartup=yes archspecific=no \
2494 include_set=includes-all includedir= libdir=
2496 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2497 modsuffix="%(modsuffix)" version="%(version)" flavour="%(flavour)" conffile="%(conffile)" \
2498 files="%(files)" objcfiles="%(objcfiles)" cxxfiles="%(cxxfiles)" \
2499 cflags="%(cflags)" cppflags="%(cppflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2500 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2501 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" lto=%(lto) \
2502 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2503 include_set=%(include_set) includedir="%(includedir)" libdir="%(libdir)" \
2504 build_abi= build_library=M
2507 #------------------------------------------------------------------------------
2511 #------------------------------------------------------------------------------
2513 # - mmake is the mmaketarget
2514 # - libname is the baselibname e.g. lib%(libname).a will be created
2515 # - files are the C source files to include in the lib. The list of files
2516 # has to be given without the .c suffix
2517 # - cxxfiles are C++ source files without suffix.
2518 # NB: files will be matched in the order .cpp > .cxx > .cc
2519 # - asmfiles are the asm files to include in the lib. The list of files has to
2520 # be given without the .s suffix
2521 # - objs additional object to link into the linklib. The objects have to be
2522 # given with full absolute path and the .o suffix.
2523 # - objdir is where the .o are generated. Defaults to $(GENDIR)/$(CURDIR)
2524 # - libdir is the directory where the linklib will be placed (default $(AROS_LIB))
2525 # - cflags are the flags to compile the source (default $(CFLAGS))
2526 # - dflags are the flags used during makedepend (default equal to cflags)
2527 # - aflags are the flags used during assembling (default $(AFLAGS))
2528 %define build_linklib mmake=/A libname=/A files= objcfiles= cxxfiles= \
2529 asmfiles= objs= objdir=$(GENDIR)/$(CURDIR) libdir=$(AROS_LIB) \
2531 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= \
2532 aflags=$(AFLAGS) compiler=target lto=$(TARGET_LTO)
2534 # assign and generate the local variables used in this macro
2535 %(mmake)_LIBNAME := %(libname)
2536 %(mmake)_LINKLIB := %(libdir)/lib%(libname).a
2538 %(mmake)_FILES := %(files)
2539 %(mmake)_ASMFILES := %(asmfiles)
2540 %(mmake)_OBJCFILES := %(objcfiles)
2541 %(mmake)_CXXFILES := %(cxxfiles)
2543 %(mmake)_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
2544 %(mmake)_ARCHFILES := $(basename $(notdir $(%(mmake)_ARCHOBJS)))
2545 %(mmake)_C_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_FILES))
2546 %(mmake)_CXX_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_CXXFILES))
2547 %(mmake)_OBJC_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_OBJCFILES))
2549 %(mmake)_OBJS := $(%(mmake)_ARCHOBJS) \
2550 $(addprefix %(objdir)/,$(notdir $(%(mmake)_C_NARCHFILES:=.o) $(%(mmake)_CXX_NARCHFILES:=.o) $(%(mmake)_ASMFILES:=.o) $(%(mmake)_OBJC_NARCHFILES:=.o))) \
2552 %(mmake)_DEPS := $(patsubst %.o,%.d,$(%(mmake)_OBJS))
2554 %(mmake)_CPPFLAGS := %(cppflags)
2555 ifneq (%(includedir),)
2556 %(mmake)_CPPFLAGS += -I%(includedir)
2558 %(mmake)_CFLAGS := %(cflags)
2559 %(mmake)_CXXFLAGS := %(cxxflags)
2561 ifeq (%(compiler),target)
2562 %(mmake)_CFLAGS := $(strip $(LTO_CFLAGS) $(%(mmake)_CFLAGS))
2563 %(mmake)_CXXFLAGS := $(strip $(LTO_CFLAGS) $(%(mmake)_CXXFLAGS))
2566 %(mmake)_AFLAGS := %(aflags)
2567 %(mmake)_DFLAGS := %(dflags)
2569 %(mmake)_DFLAGS := %(dflags)
2571 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
2573 %(mmake)_DXXFLAGS := %(dxxflags)
2574 ifneq (%(dxxflags),)
2575 %(mmake)_DXXFLAGS := %(dxxflags)
2577 %(mmake)_DXXFLAGS := $(%(mmake)_CXXFLAGS)
2580 .PHONY : %(mmake) %(mmake)-clean %(mmake)-quick
2583 %(mmake)-quick : %(mmake)
2585 #MM %(mmake) : includes-generate-deps
2586 %(mmake) : $(%(mmake)_LINKLIB)
2588 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
2590 %rule_compile_cxx_multi mmake=%(mmake) \
2591 basenames=$(%(mmake)_CXX_NARCHFILES) targetdir="%(objdir)" \
2592 cppflags=$(%(mmake)_CPPFLAGS) cxxflags=$(%(mmake)_CXXFLAGS) dxxflags=$(%(mmake)_DXXFLAGS) \
2593 compiler="%(compiler)"
2594 %rule_compile_objc_multi mmake=%(mmake) \
2595 basenames=$(%(mmake)_OBJC_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
2596 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
2597 compiler="%(compiler)"
2598 %rule_compile_multi mmake=%(mmake) \
2599 basenames=$(%(mmake)_C_NARCHFILES) targetdir="%(objdir)" \
2600 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
2601 compiler="%(compiler)"
2602 %rule_assemble basename=% targetdir="%(objdir)" \
2603 aflags=$(%(mmake)_AFLAGS)
2605 %rule_link_linklib mmake=%(mmake) libname="%(libname)" objs=$(%(mmake)_OBJS) libdir="%(libdir)" linker="%(compiler)"
2608 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(%(mmake)_DEPS)
2610 $(%(mmake)_OBJS) $(%(mmake)_DEPS) : | %(objdir)
2611 $(%(mmake)_LINKLIB) : | %(libdir)
2612 GLOB_MKDIRS += %(objdir) %(libdir)
2614 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_LINKLIB) $(%(mmake)_DEPS)
2617 $(Q)$(ECHO) "Cleaning up for metatarget %(mmake)"
2621 #------------------------------------------------------------------------------
2624 #------------------------------------------------------------------------------
2626 # - mmake is the mmaketarget
2627 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
2628 # - description is the catalog description file (.cd), without the .cd suffix (default *.cd)
2629 # - subdir is the destination subdirectory of the catalogs
2630 # - name is the name of the destination catalog, without the .catalog suffix
2631 # - source is the path to the generated source code file
2632 # - dir is the base destination directory (default $(AROS_CATALOGS))
2633 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
2634 # - srcdir is the directory in which the *.cd and *.ct files are searched
2636 %define build_catalogs mmake=/A name=/A subdir=/A \
2637 catalogs= source="../strings.h" description= dir=$(AROS_CATALOGS) \
2638 sourcedescription=$(TOOLDIR)/C_h_aros srcdir=$(SRCDIR)/$(CURDIR)
2640 ifeq (%(description),)
2641 %(mmake)_DESC := $(basename $(wildcard %(srcdir)/*.cd))
2643 %(mmake)_DESC := %(description)
2646 %(mmake)_SRC := $(shell echo %(sourcedescription) | sed 's/^\(.\):\//\/\1\//')
2649 %(mmake)_LNGS := $(basename $(notdir $(call WILDCARD, %(srcdir)/*.ct)))
2651 %(mmake)_LNGS := %(catalogs)
2654 %(mmake)_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, $(%(mmake)_LNGS)))
2655 %(mmake)_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, $(%(mmake)_LNGS))) $(dir %(source))
2658 %(mmake) : $(%(mmake)_OBJS) %(source)
2660 $(%(mmake)_OBJS) : | $(%(mmake)_DIRS)
2661 GLOB_MKDIRS += $(%(mmake)_DIRS)
2663 %(dir)/%/%(subdir)/%(name).catalog : %(srcdir)/%.ct $(%(mmake)_DESC).cd
2664 $(Q)$(ECHO) "Creating %(name) catalog for language $*."
2665 $(Q)$(FLEXCAT) $(%(mmake)_DESC).cd $< CATALOG="%(dir)/$*/%(subdir)/%(name).catalog" || [ $$? -lt 10 ]
2668 %(source) : %(mmake)_DESC := $(%(mmake)_DESC)
2669 %(source) : %(mmake)_SRC := $(%(mmake)_SRC)
2670 %(source) : $(%(mmake)_DESC).cd $(%(mmake)_SRC).sd | $(dir %(source))
2671 $(Q)$(ECHO) "Creating %(name) catalog source file $@"
2672 $(Q)$(FLEXCAT) $(%(mmake)_DESC).cd $@=$(%(mmake)_SRC).sd
2675 %(mmake)-clean : FILES := $(%(mmake)_OBJS) %(source)
2678 $(Q)$(ECHO) "Cleaning up for metatarget %(mmake)"
2681 .PHONY: %(mmake) %(mmake)-clean
2684 #-----------------------------------------------------------------------------
2687 #-----------------------------------------------------------------------------
2689 # - mmake is the mmaketarget
2690 # - icons is a list of icon base names (i.e. without the .info suffix)
2691 # - dir is the destination directory
2692 # - srcdir is where *.png and *.info.src are sought
2693 #-----------------------------------------------------------------------------
2695 %define build_icons mmake=/A icons=/A dir=/A srcdir=$(SRCDIR)/$(CURDIR) image=
2697 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
2700 %(mmake) : $(BD_OBJS)
2704 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%.png
2705 $(Q)$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2706 $(Q)$(ILBMTOICON) $+ $@
2710 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%(image)
2711 $(Q)$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2712 $(Q)$(ILBMTOICON) $+ $@
2716 $(BD_OBJS) : | %(dir)
2717 GLOB_MKDIRS += %(dir)
2719 %(mmake)-clean : FILES := $(BD_OBJS)
2724 .PHONY: %(mmake) %(mmake)-clean
2727 #-----------------------------------------------------------------------------
2730 #------------------------------------------------------------------------------
2731 # Compile files for an arch-specific replacement of code for a module
2732 # - files: the basenames of the C files to compile.
2733 # - asmfiles: the basenames of the asm files to assemble.
2734 # - mainmmake: the mmake of the module in the main directory to compile these
2735 # arch specific files for.
2736 # - maindir: the object directory for the main module
2737 # - arch: the arch for which to compile these files. It can have the form
2738 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
2739 # - cflags (default $(CFLAGS)): the C flags to use for compilation
2740 # - dflags: the flags used during creation of dependency file. If not specified
2741 # the same value as cflags will be used
2742 # - aflags: the flags used during assembling
2743 # - compiler: (host, kernel or target) specifies which compiler to use. By default
2744 # the target compiler is used
2745 # - modname: arch_specific builds of modules (built using build_module) MUST
2746 # specify the name here matching the original module. this insures multiple modules
2747 # built from the same makefile will not pollute each other.
2748 %define build_archspecific files= cxxfiles= asmfiles= linklibfiles= linklibobjs= mainmmake=/A maindir=/A arch=/A \
2749 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target objdir= modname=
2751 ifeq (%(files) %(linklibfiles) %(linklibobjs) %(asmfiles),)
2752 $(error no files or asmfiles given)
2755 ifneq (%(cxxfiles),)
2756 $(error cxx support is TODO)
2759 %buildid targets="%(mainmmake)-%(arch)"
2761 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2762 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2763 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2764 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2765 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2766 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2767 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2768 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2769 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2770 #MM- %(mainmmake)-kobj-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2771 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2772 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2773 #MM- %(mainmmake)-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2774 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2775 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2777 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
2780 BD_OBJROOT$(BDID) := %(objdir)
2783 BD_OBJROOT$(BDID) := $(GENDIR)/%(maindir)/%(modname)
2785 BD_OBJROOT$(BDID) := $(GENDIR)/%(maindir)
2788 BD_OBJDIR$(BDID) := $(BD_OBJROOT$(BDID))/arch
2789 BD_LIBOBJDIR$(BDID) := $(BD_OBJROOT$(BDID))/linklib/arch
2790 BD_FILEOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files)))) $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(cxxfiles))))
2791 BD_LINKLIBOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibfiles))))
2792 BD_LINKLIBARCHOBJS$(BDID) := $(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibobjs)))
2793 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
2794 BD_OBJS$(BDID) := $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) $(BD_ASMOBJS$(BDID))
2795 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files)))) $(addsuffix .d,$(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibfiles))))
2798 BD_DEFLIBDEFSINC$(BDID) := -include $(BD_OBJROOT$(BDID))/include/%(modname)_deflibdefs.h
2801 ifeq ($(TARGET),%(mainmmake)-%(arch)-quick)
2802 BD_TARGET := %(mainmmake)-%(arch)-quick
2804 BD_TARGET := %(mainmmake)-%(arch)
2808 ifeq ($(TARGET),$(BD_TARGET))
2809 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
2810 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(files)))
2811 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(linklibfiles)))
2812 vpath %.s $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2813 vpath %.S $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2816 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID)) $(BD_LIBOBJDIR$(BDID))
2817 GLOB_MKDIRS += $(BD_OBJDIR$(BDID)) $(BD_LIBOBJDIR$(BDID))
2820 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
2823 %(mainmmake)-%(arch)-quick :: $(BD_OBJS$(BDID))
2825 ifeq ($(findstring %(compiler),host kernel target),)
2826 $(error unknown compiler %(compiler))
2829 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=$(strip %(cppflags) -I$(BD_OBJROOT$(BDID)) $(BD_DEFLIBDEFSINC$(BDID)))
2831 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=%(cppflags)
2833 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
2834 ifeq (%(compiler),target)
2835 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
2836 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=$(TMP_CPPFLAGS)
2837 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=$(strip $(TMP_CFLAGS) $(SAFETY_CFLAGS))
2838 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
2839 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
2841 ifeq (%(compiler),host)
2842 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(HOST_CC)
2843 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
2844 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
2846 ifeq (%(compiler),kernel)
2847 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
2848 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=$(strip $(KERNEL_CPPFLAGS) $(TMP_CPPFLAGS))
2849 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(TMP_CFLAGS))
2850 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
2851 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
2854 ifeq ($(TARGET),$(BD_TARGET))
2855 $(BD_LIBOBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2856 %compile_q cmd=$(TMP_CMD) opt="$(strip $(TMP_CFLAGS) $(TMP_CPPFLAGS))" iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2857 $(BD_OBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2858 %compile_q cmd=$(TMP_CMD) opt="$(strip $(TMP_CFLAGS) $(TMP_CPPFLAGS))" iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2862 $(BD_DEPS$(BDID)) : TMP_CPPFLAGS:=$(strip %(cppflags) $(BD_DEFLIBDEFSINC$(BDID)))
2863 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags)
2865 $(BD_DEPS$(BDID)) : TMP_CPPFLAGS:=%(cppflags)
2866 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
2868 ifeq ($(TARGET),$(BD_TARGET))
2869 $(BD_LIBOBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2870 %mkdepend_q cc=$(TMP_CMD) flags="$(strip $(TMP_DFLAGS) $(TMP_CPPFLAGS))"
2872 $(BD_OBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2873 %mkdepend_q cc=$(TMP_CMD) flags="$(strip $(TMP_DFLAGS) $(TMP_CPPFLAGS))"
2876 $(BD_ASMOBJS$(BDID)) : CPPFLAGS:=%(cppflags)
2877 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
2879 ifeq ($(TARGET),$(BD_TARGET))
2880 $(BD_OBJDIR$(BDID))/%.o : %.s
2882 $(BD_OBJDIR$(BDID))/%.o : %.S
2886 %include_deps depstargets=$(BD_TARGET) deps=$(BD_DEPS$(BDID))
2888 #------------------------------------------------------------------------------
2891 #------------------------------------------------------------------------------
2892 # generate asm files from c files (for debugging purposes)
2895 $(Q)$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
2896 $(Q)$(TARGET_CC) $(TARGET_SYSROOT) -S $(CFLAGS) $(CPPFLAGS) $< -c -o $@
2898 #------------------------------------------------------------------------------
2901 #------------------------------------------------------------------------------
2902 # Copy files from one directory to another.
2904 %define copy_files_q mmake=/A files=$(FILES) src=. dst=/A
2906 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
2908 GLOB_MKDIRS += %(dst)
2914 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC))/, $(file)) $(addprefix %(dst)/, $(file))))
2917 #------------------------------------------------------------------------------
2920 #------------------------------------------------------------------------------
2921 # Copy a directory recursively to another place, preserving the original
2922 # hierarchical structure
2924 # src: the source directory whose content will be copied.
2925 # dst: the directories where to copy src's content. If not existing, they will be made.
2926 # excludefiles: files which must not be copied. Path must be relative to src.
2928 %define copy_dir_recursive mmake=/A src=. dst=/A excludefiles=
2934 $(Q)cd $(SRCDIR)/$(CURDIR) && $(CPYDIRREC) -s %(src) -d %(dst) -e %(excludefiles)
2937 #------------------------------------------------------------------------------
2940 #------------------------------------------------------------------------------
2941 # Copy include files into the includes directories. There are currently
2942 # two include directories. One for building AROS $(AROS_INCLUDES) and one
2943 # for building tools that need to run on the host system $(GENINCDIR). The
2944 # $(GENINCDIR) path must not contain any references to the C runtime
2945 # library header files.
2947 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
2948 dir= compiler=target includedir=$(AROS_INCLUDES)
2950 ifeq ($(findstring %(compiler),host kernel target),)
2951 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
2956 $(eval TMP_DIRREMAIN := $$$(TMP_DIR))
2957 TMP_DIRFIRST := $(subst $(TMP_DIRREMAIN),,$(TMP_DIR))
2958 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),$(dir %(includes)))
2959 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,$(notdir %(includes)))
2960 ifeq ($(TMP_DIRFIRST),/)
2961 BD_INC_PATH := %(dir)/
2963 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
2966 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
2967 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
2970 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
2973 ifeq (%(compiler),target)
2976 BD_INCL_FILES2 := $(subst %(dir),%(includedir)/%(path),$(dir %(includes)))
2977 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,$(notdir %(includes)))
2979 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,%(includes))
2982 BD_INCL_FILES += $(BD_INCL_FILES2)
2984 $(BD_INCL_FILES2) : %(includedir)/%(path)/% : $(BD_INC_PATH)%
2989 %(mmake) : $(BD_INCL_FILES)
2993 $(BD_INCL_FILES) : | $(dir $(BD_INCL_FILES))
2994 GLOB_MKDIRS += $(dir $(BD_INCL_FILES))
2996 #------------------------------------------------------------------------------
2999 #------------------------------------------------------------------------------
3000 %define make_hidd_stubs hidd=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
3001 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
3002 STUBS_MEM := $(addsuffix .o,$(STUBS))
3003 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
3004 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
3005 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
3007 #MM- linklibs : hidd-%(hidd)-stubs
3008 #MM- %(parenttarget): hidd-%(hidd)-stubs
3009 #MM hidd-%(hidd)-stubs : includes includes-copy
3010 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
3012 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
3015 $(STUBS_OBJ) : $(STUBS_SRC)
3016 %compile_q cmd="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" opt="$(strip %(cflags) %(cppflags))" iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
3018 $(STUBS_DEP) : $(STUBS_SRC)
3019 %mkdepend_q flags="$(strip %(dflags) %(cppflags))"
3022 %mkdirs_q $(OBJDIR) $(AROS_LIB)
3026 -@$(RM) $(HIDD_LIB) $(OBJDIR)
3028 DEPS := $(DEPS) $(STUBS_DEP)
3031 #------------------------------------------------------------------------------
3034 #------------------------------------------------------------------------------
3035 # Build an imported source tree which uses the configure script from the
3036 # autoconf package. This rule will try to "integrate" the produced files as
3037 # much as possible in the AROS build, for example by putting libraries in the
3038 # standard library directory, includes in the standard include directory, and
3039 # so on. You can however override this behaviour.
3041 # As a special "bonus" for you, the PROGDIR environment variable is defined to
3042 # be %(bindir) (or its deduced value) when running "make install", and
3043 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
3044 # configure script some more parameters whose value depends upon the PROGDIR
3045 # env var, so that the program gets all its stuff installed in the proper place
3046 # when building it, but when running it from inside AROS it can also find that
3047 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
3048 # the configuration parameters set when running ./configure
3050 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
3051 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
3052 # to the name which has to follow it.
3056 # - mmake = the meta make target.
3057 # - package = name of the package to be built.
3058 # - srcdir = the location of the unpacked source code. Defaults
3059 # to $(SRCDIR)/$(CURDIR).
3060 # - prefix = the target directory. Must be an absolute path of the
3061 # host system. Defaults to $(AROS_CONTRIB).
3062 # - aros_prefix = set a path which is valid within the AROS filesystem.
3063 # Defaults to the value of the prefix option.
3064 # - extraoptions = additional options for the configure script.
3065 # - usecppflags = enable the use of cpp flags. some external configure
3066 # scripts will not set their own cppflags if it is already
3067 # set, so this allows them to be disabled (unless you can provide
3068 # all the options they would need)
3069 # - extracppflags = additional preprocessor flags.
3070 # - extracflags = additional flags to use with the C compiler.
3071 # - extracxxflags = additional flags to use with the C++ compiler.
3072 # - nix_dir_layout = if yes the binary will be stored in a bin subdirectory.
3073 # Defaults to the value of the nix argument.
3074 # - nix = enable u*nix path handling, i.e. a path like
3075 # /progdir//./file will be translated to
3076 # progdir:file during run-time. Defaults to no.
3077 # - compiler = target, host or kernel. Defaults to target.
3078 # - install_target = the command used for installing. Defaults to install. Leave
3079 # it empty if you want to suppress installing.
3080 # - preconfigure = a metatarget which is executed before configure is called.
3081 # - postconfigure = a metatarget which is executed after configure is called.
3082 # - postinstall = a metatarget which is executed after installing.
3083 # - install_env = set additional options for installing.
3084 # - use_build_env = if yes the configuration environment is used for
3085 # installing, too. Defaults to no.
3087 # The arguments aros_prefix, nix and nix_dir_layout are related. The logic is
3091 # --prefix = $(aros_prefix)
3092 # progdir = $(aros_prefix)/bin
3095 # --prefix = /PROGDIR
3096 # --bindir = /PROGDIR
3097 # --sbindir = /PROGDIR
3099 # --includedir = /INCLUDE
3100 # --oldincludedir = /INCLUDE
3102 # --prefix = $(aros_prefix)
3105 # progdir = $(aros_prefix)
3108 # bindir = $(prefix)
3109 # sbindir = $(prefix)
3110 # libdir = $(AROS_LIB)
3111 # includedir = $(AROS_INCLUDES)
3112 # oldincludedir = $(AROS_INCLUDES)
3116 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) \
3117 prefix= gendir= basedir=$(CURDIR) extraoptions= \
3118 usecppflags=yes extracppflags= extracflags="$(OPTIMIZATION_CFLAGS)" extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3119 hostisaflags="$(TARGET_ISA_CFLAGS)" targetisaflags="$(TARGET_ISA_CFLAGS)" \
3120 aros_prefix= nix_dir_layout= nix=no compiler=target crossbuild=no \
3121 install_target=install preconfigure= postconfigure= postinstall= \
3122 config_env_extra= install_env= use_build_env=no buildflags=yes gnuflags=yes nlsflag=yes xflag=yes
3125 %(mmake)-prefix := %(prefix)
3127 %(mmake)-prefix := $(AROS_CONTRIB)
3130 ifneq (%(aros_prefix),)
3131 %(mmake)-aros_prefix := %(aros_prefix)
3133 %(mmake)-aros_prefix := $(%(mmake)-prefix)
3139 %(mmake)-nix := $(BD_NIXFLAG)
3140 %(mmake)-volpfx := /
3141 %(mmake)-volsfx := /
3143 ifeq (%(nix_dir_layout),)
3144 %(mmake)-nix_dir_layout := yes
3147 %(mmake)-volsfx := :
3149 ifeq (%(nix_dir_layout),)
3150 %(mmake)-nix_dir_layout := no
3154 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
3156 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
3157 exec_prefix=$(%(mmake)-prefix) %(install_env)
3159 # Check if chosen compiler is valid
3160 ifeq ($(findstring %(compiler),host target kernel),)
3161 $(error unknown compiler %(compiler))
3164 # Set legacy 'host' variable based on chosen compiler
3165 ifeq (%(compiler),host)
3168 %(mmake)-pkgbasedir := $(HOSTGENDIR)
3170 %(mmake)-pkgbasedir := $(HOSTGENDIR)/%(basedir)
3175 %(mmake)-pkgbasedir := $(GENDIR)
3177 %(mmake)-pkgbasedir := $(GENDIR)/%(basedir)
3182 %(mmake)-pkgbasedir := %(gendir)
3184 %(mmake)-pkgbasedir := %(gendir)/%(basedir)
3189 %(mmake)-pkgdir := $(%(mmake)-pkgbasedir)
3191 %(mmake)-pkgdir := $(%(mmake)-pkgbasedir)/%(package)
3194 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
3195 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
3197 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
3198 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
3199 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
3202 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
3203 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
3205 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
3208 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
3210 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
3211 sbindir=$(%(mmake)-prefix) \
3212 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
3213 oldincludedir=$(AROS_INCLUDES) %(install_env)
3216 ifneq ($(DEBUG),yes)
3217 %(mmake)-s_flag = -s
3220 # Set up build environment, and options for configure script
3221 ifeq (%(compiler),host)
3222 # NB: We need to pass in our crosstoolsdir, but cannot set CFLAGS since it
3223 # confused configure scripts. We also cannot pass it via _FOR_BUILD
3224 # since that won't get picked up during configure.
3225 # We also cannot pass in the compiler including std flags so we need to use
3226 # the "plain" host compiler.
3227 %(mmake)-cfg-env := %(config_env_extra) \
3229 CXXCPP="$(HOST_CPP)" \
3230 CC="$(strip $(HOST_DEF_CC) $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include)" \
3231 CXX="$(strip $(HOST_CXX) $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include)" \
3232 LDFLAGS="-L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS)"
3233 ifeq (%(usecppflags),yes)
3234 %(mmake)-cfg-env += TARGET_CPPFLAGS="$(KERNEL_CPPFLAGS)"
3236 %(mmake)-cfg-env += TARGET_CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
3237 TARGET_CFLAGS="$(strip %(targetisaflags) $(KERNEL_CFLAGS) $(%(mmake)-s_flag))" \
3238 TARGET_CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
3239 TARGET_CXXFLAGS="$(strip $(KERNEL_CXXFLAGS) $(%(mmake)-s_flag))" \
3240 TARGET_AS="$(TARGET_AS)" \
3241 OBJCOPY="$(OBJCOPY)" \
3242 TARGET_RANLIB="$(RANLIB)" \
3243 TARGET_STRIP="$(STRIP_PLAIN)" \
3244 TARGET_NM="$(NM_PLAIN)" \
3245 TARGET_OBJCOPY="$(TARGET_OBJCOPY)"
3247 ifeq (%(compiler),target)
3248 %(mmake)-cfg-env := %(config_env_extra) \
3249 PKG_CONFIG_LIBDIR="$(AROS_DEVELOPER)/lib/pkgconfig" \
3250 PKG_CONFIG_SYSROOT_DIR="$(AROSDIR)"
3251 %(mmake)-cfg-env += CPP="$(strip $(TARGET_CPP) $(TARGET_SYSROOT))" \
3252 CXXCPP="$(strip $(TARGET_CPP) $(TARGET_SYSROOT))" \
3253 CC="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
3254 CXX="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
3255 LD="$(strip $(TARGET_LD))"
3256 ifeq (%(crossbuild),yes)
3257 %(mmake)-cfg-env += CFLAGS="$(strip %(targetisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) %(extracflags) $(%(mmake)-s_flag))" \
3258 CXXFLAGS="$(strip %(targetisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) %(extracxxflags) $(%(mmake)-s_flag))"
3259 ifeq (%(usecppflags),yes)
3260 %(mmake)-cfg-env += CPPFLAGS="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3263 %(mmake)-cfg-env += CFLAGS="$(strip %(targetisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) %(extracflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3264 CXXFLAGS="$(strip %(targetisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) %(extracxxflags) $(%(mmake)-nix) $(%(mmake)-s_flag))"
3265 ifeq (%(usecppflags),yes)
3266 %(mmake)-cfg-env += CPPFLAGS="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3269 %(mmake)-cfg-env += LDFLAGS="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))"
3270 ifeq (%(usecppflags),yes)
3271 %(mmake)-cfg-env += CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)"
3273 %(mmake)-cfg-env += CC_FOR_BUILD="$(strip $(HOST_DEF_CC))" \
3274 CFLAGS_FOR_BUILD="$(strip $(HOST_CFLAGS) $(%(mmake)-s_flag))" \
3275 CXX_FOR_BUILD="$(strip $(HOST_CXX))" \
3276 CXXFLAGS_FOR_BUILD="$(strip $(HOST_CXXFLAGS) $(%(mmake)-s_flag))" \
3277 LD_FOR_BUILD="$(strip $(HOST_LD))" \
3278 LDFLAGS_FOR_BUILD="$(strip $(HOST_LDFLAGS) $(%(mmake)-s_flag))"
3279 ifeq (%(usecppflags),yes)
3280 %(mmake)-cfg-env += CPPFLAGS_FOR_HOST="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3282 %(mmake)-cfg-env += CC_FOR_HOST="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
3283 CFLAGS_FOR_HOST="$(strip %(hostisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) -L$(AROS_DEVELOPER)/lib %(extracflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3284 CXX_FOR_HOST="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
3285 CXXFLAGS_FOR_HOST="$(strip %(hostisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) -L$(AROS_DEVELOPER)/lib %(extracxxflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3286 LD_FOR_HOST="$(strip $(TARGET_LD))" \
3287 LDFLAGS_FOR_HOST="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))"
3288 ifeq (%(usecppflags),yes)
3289 %(mmake)-cfg-env += CPPFLAGS_FOR_TARGET="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3291 %(mmake)-cfg-env += CC_FOR_TARGET="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
3292 CFLAGS_FOR_TARGET="$(strip %(targetisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) -L$(AROS_DEVELOPER)/lib %(extracflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3293 CXX_FOR_TARGET="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
3294 CXXFLAGS_FOR_TARGET="$(strip %(targetisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) -L$(AROS_DEVELOPER)/lib %(extracxxflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3295 LD_FOR_TARGET="$(strip $(TARGET_LD))" \
3296 LDFLAGS_FOR_TARGET="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3297 AR="$(strip $(AR_PLAIN))" \
3298 AS="$(strip $(TARGET_AS))" \
3299 OBJCOPY="$(strip $(OBJCOPY))" \
3300 RANLIB="$(strip $(RANLIB))" \
3301 STRIP="$(strip $(STRIP_PLAIN))"
3302 ifeq (%(usecppflags),yes)
3303 %(mmake)-cfg-env += TARGET_CPPFLAGS="$(KERNEL_CPPFLAGS)"
3305 %(mmake)-cfg-env += TARGET_CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
3306 TARGET_CFLAGS="$(strip %(targetisaflags) $(KERNEL_CFLAGS) $(%(mmake)-s_flag))" \
3307 TARGET_CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
3308 TARGET_CXXFLAGS="$(strip $(KERNEL_CXXFLAGS) $(%(mmake)-s_flag))" \
3309 TARGET_AS="$(strip $(TARGET_AS))" \
3310 TARGET_RANLIB="$(strip $(RANLIB))" \
3311 TARGET_STRIP="$(strip $(STRIP_PLAIN))" \
3312 TARGET_NM="$(strip $(NM_PLAIN))"
3313 ifeq (%(buildflags),yes)
3314 %(mmake)-config_opts += --target=$(AROS_TARGET_CPU)-aros
3315 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)
3316 %(mmake)-config_opts += --host=$(AROS_TARGET_CPU)-aros
3318 ifeq (%(gnuflags),yes)
3319 %(mmake)-config_opts += --without-pic --disable-shared
3320 ifeq (%(nlsflag),yes)
3321 # disable native language support
3322 %(mmake)-config_opts += --disable-nls
3325 # disable X window system
3326 %(mmake)-config_opts += --without-x
3330 ifeq (%(compiler),kernel)
3331 %(mmake)-cfg-env := %(config_env_extra) \
3332 CPP="$(KERNEL_CPP)" \
3333 CXXCPP="$(KERNEL_CPP)"
3334 ifeq (%(usecppflags),yes)
3335 %(mmake)-cfg-env += CPPFLAGS="$(strip $(KERNEL_CPPFLAGS) %(extracppflags))"
3337 %(mmake)-cfg-env += CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
3338 CFLAGS="$(strip %(targetisaflags) $(KERNEL_CFLAGS) %(extracflags) $(%(mmake)-s_flag))" \
3339 CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
3340 CXXFLAGS="$(strip $(KERNEL_CXXFLAGS) %(extracxxflags) $(%(mmake)-s_flag))" \
3342 ifeq (%(usecppflags),yes)
3343 %(mmake)-cfg-env += CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)"
3345 %(mmake)-cfg-env += CC_FOR_BUILD="$(HOST_DEF_CC)" \
3346 CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
3347 CXX_FOR_BUILD="$(HOST_CXX)" \
3348 CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
3349 RANLIB="$(RANLIB)" \
3350 TARGET_RANLIB="$(RANLIB)" \
3351 TARGET_STRIP="$(STRIP_PLAIN)" \
3352 TARGET_NM="$(NM_PLAIN)"
3353 ifeq (%(buildflags),yes)
3354 %(mmake)-config_opts += --target=$(AROS_TARGET_CPU)-aros
3355 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)
3356 %(mmake)-config_opts += --host=$(AROS_TARGET_CPU)-aros
3358 ifeq (%(gnuflags),yes)
3359 %(mmake)-config_opts += --without-pic --disable-shared
3360 ifeq (%(nlsflag),yes)
3361 # disable native language support
3362 %(mmake)-config_opts += --disable-nls
3365 # disable X window system
3366 %(mmake)-config_opts += --without-x
3372 ifeq (%(use_build_env),yes)
3373 BUILD_ENV := $(%(mmake)-cfg-env)
3376 ifneq ("$(wildcard %(srcdir)/Makefile)","")
3377 # in an ideal world, we would depend on the files in the source directory,
3378 # so we could copy them when they change. unfortunately filenames with
3379 # spaces causes problems with this
3380 $(%(mmake)-pkgdir)/.local-copy:
3381 %mkdirs_q $(%(mmake)-pkgdir)
3382 $(Q)$(ECHO) "Copying Local-Build Sources to \`$(patsubst $(TOP)/%,%,$(abspath $(%(mmake)-pkgdir)))'"
3383 $(Q)$(CP) -Rf "%(srcdir)/." $(%(mmake)-pkgdir)/ && $(TOUCH) $@
3385 $(%(mmake)-pkgdir)/.files-touched : $(%(mmake)-pkgdir)/.local-copy
3387 %(mmake)-cfg-srcdir=$(%(mmake)-pkgdir)
3389 %(mmake)-cfg-srcdir=%(srcdir)
3391 %(mmake)-make-env := -C $(%(mmake)-pkgdir)
3393 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3395 # When building for the host, we don't need to build the
3396 # linklibs - this is especially true when building the
3397 # crosstool toolchain on 'foreign' architectures (such as
3398 # building PPC on x86)
3400 #MM- %(mmake)-host : setup includes %(mmake)-quick
3401 #MM- %(mmake)-target : setup includes core-linklibs %(mmake)-quick
3402 #MM- %(mmake): %(mmake)-%(compiler)
3404 # Using -j1 in install_command may result in a warning but finally
3405 # it does its job. make install for gcc does not work reliably for -jN
3407 ifneq (%(install_target),)
3408 %(mmake)-install_command = \
3409 $(ECHO) "Installing from build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))" && \
3410 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
3411 $(%(mmake)-make-env) %(install_target) -j1
3413 %(mmake)-uninstall_command = \
3414 $(RM) $(%(mmake)-installflag) && \
3415 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" \
3416 $(%(mmake)-install_opts) $(%(mmake)-make-env) uninstall
3418 %(mmake)-install_command := true
3419 %(mmake)-uninstall_command := true
3422 #MM- %(mmake)-quick : %(preconfigure) %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
3425 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3428 # N.B.: the make test for the targets being up to date generates a benign Error 1.
3430 $(%(mmake)-installflag) : $(%(mmake)-configflag)
3431 $(Q)$(IF) ! $(BUILD_ENV) $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q $(%(mmake)-make-env); then \
3432 $(RM) $(%(mmake)-installflag) && \
3433 $(ECHO) "Performing build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))" && \
3434 $(BUILD_ENV) $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" $(%(mmake)-make-env) && \
3435 $(%(mmake)-install_command) && \
3436 $(TOUCH) $@ -r $^; \
3439 $(%(mmake)-pkgdir)/.files-touched:
3440 %mkdirs_q $(%(mmake)-pkgdir)
3441 $(Q)find %(srcdir) -exec $(TOUCH) -c -r $(%(mmake)-cfg-srcdir)/configure '{}' \; && \
3445 %(mmake)-uninstall :
3446 $(%(mmake)-uninstall_command)
3449 %(mmake)-configure : $(%(mmake)-configflag)
3451 $(%(mmake)-configflag) : TMP_SRCDIR := $(shell echo $(%(mmake)-cfg-srcdir) | sed 's/^\(.\):\//\/\1\//')
3452 $(%(mmake)-configflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
3454 %mkdirs_q $(%(mmake)-pkgdir)
3455 $(Q)$(ECHO) "Configuring build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))"
3456 $(Q)cd $(%(mmake)-pkgdir) && \
3457 find . -name config.cache -exec $(RM) '{}' \; && \
3458 $(%(mmake)-cfg-env) $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) %(extraoptions) && \
3462 %(mmake)-clean : %(mmake)-uninstall
3463 $(Q)$(RM) $(%(mmake)-pkgdir)
3465 #------------------------------------------------------------------------------
3468 #------------------------------------------------------------------------------
3469 # Build an imported source tree which uses cmake
3473 # - mmake = the meta make target.
3474 # - package = name of the package to be built.
3475 # - srcdir = the location of the unpacked source code. Defaults
3476 # to $(SRCDIR)/$(CURDIR).
3477 # - prefix = the target directory. Must be an absolute path of the
3478 # host system. Defaults to $(AROS_CONTRIB).
3479 # - aros_prefix = set a path which is valid within the AROS filesystem.
3480 # Defaults to the value of the prefix option.
3481 # - extraoptions = additional options for the cmake script.
3482 # - usecppflags = enable the use of cpp flags. some external cmake
3483 # scripts will not set their own cppflags if it is already
3484 # set, so this allows them to be disabled (unless you can provide
3485 # all the options they would need)
3486 # - cppflags = preprocessor flags.
3487 # - cflags = flags to use with the C compiler.
3488 # - cxxflags = flags to use with the C++ compiler.
3489 # - installoptions = additional options for the install step.
3492 %define build_with_cmake mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) gendir= prefix= \
3493 aros_prefix= extraoptions= installoptions= maketarget= compiler=target \
3494 usecppflags=yes cppflags=$(CPPFLAGS) cflags=$(CFLAGS) cxxflags=$(CXXFLAGS) ldflags=$(LDFLAGS)
3497 %(mmake)-prefix := %(prefix)
3499 %(mmake)-prefix := $(AROS_CONTRIB)
3502 ifneq (%(aros_prefix),)
3503 %(mmake)-aros_prefix := %(aros_prefix)
3505 %(mmake)-aros_prefix := $(%(mmake)-prefix)
3508 ifeq (%(compiler),host)
3509 BD_LDFLAGS := $(strip -L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS))
3510 BD_CFLAGS := $(strip $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include)
3511 BD_CXXFLAGS := $(strip $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include)
3512 BD_CPPFLAGS := $(HOST_CPPFLAGS)
3513 %(mmake)-cmake_opts := -DCMAKE_INSTALL_PREFIX=$(%(mmake)-prefix) -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(HOST_DEF_CC)" -DCMAKE_C_FLAGS="$(BD_CFLAGS)"
3514 ifeq (%(usecppflags),yes)
3515 %(mmake)-cmake_opts += -DCMAKE_CPP_FLAGS="$(BD_CPPFLAGS)"
3517 %(mmake)-cmake_opts += -DCMAKE_CXX_COMPILER="$(HOST_CXX)" -DCMAKE_CXX_FLAGS="$(BD_CXXFLAGS)"
3519 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
3521 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
3524 BD_LDFLAGS := %(ldflags)
3525 BD_CFLAGS := %(cflags)
3526 BD_CXXFLAGS := %(cxxflags)
3527 BD_CPPFLAGS := %(cppflags)
3528 %(mmake)-cmake_opts := -DCMAKE_TOOLCHAIN_FILE=$(GENDIR)/config/conf.cmake -DCMAKE_INSTALL_PREFIX=$(%(mmake)-prefix) -DCMAKE_C_FLAGS="$(strip $(BD_CFLAGS))"
3529 ifeq (%(usecppflags),yes)
3530 %(mmake)-cmake_opts += -DCMAKE_CPP_FLAGS="$(BD_CPPFLAGS)"
3532 %(mmake)-cmake_opts += -DCMAKE_CXX_FLAGS="$(strip $(BD_CXXFLAGS))" -DCMAKE_EXE_LINKER_FLAGS="$(strip $(BD_LDFLAGS))"
3534 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
3536 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
3541 %(mmake)-pkgdir := %(gendir)/$(CURDIR)
3543 %(mmake)-pkgdir := %(gendir)/$(CURDIR)/%(package)
3547 %(mmake)-cmakeflag := $(%(mmake)-pkgdir)/.cmake
3548 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
3550 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3552 #MM- %(mmake): setup includes core-linklibs %(mmake)-quick
3554 #MM- %(mmake)-quick : %(mmake)-cmake %(mmake)-build_and_install-quick
3557 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3559 $(%(mmake)-installflag) : $(%(mmake)-cmakeflag)
3560 $(IF) ! $(MAKE) -q -C $(%(mmake)-pkgdir); then \
3561 $(RM) $(%(mmake)-installflag) && \
3562 $(MAKE) -C $(%(mmake)-pkgdir) %(maketarget) && \
3563 cd $(%(mmake)-pkgdir) && \
3564 cmake %(installoptions) -P cmake_install.cmake && \
3565 $(TOUCH) $@ -r $^; \
3568 $(%(mmake)-pkgdir)/.files-touched:
3569 %mkdirs_q $(%(mmake)-pkgdir)
3570 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/CMakeLists.txt '{}' \; && \
3574 %(mmake)-cmake : $(%(mmake)-cmakeflag)
3576 $(%(mmake)-cmakeflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
3577 $(%(mmake)-cmakeflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
3579 %mkdirs_q $(%(mmake)-pkgdir)
3580 cd $(%(mmake)-pkgdir) && \
3581 $(RM) -Rf CMakeCache.txt CMakeFiles \; && \
3582 cmake $(%(mmake)-cmake_opts) %(extraoptions) $(TMP_SRCDIR) && \
3586 %(mmake)-clean : %(mmake)-uninstall
3587 $(Q)$(RM) $(%(mmake)-pkgdir)
3589 #------------------------------------------------------------------------------
3592 #------------------------------------------------------------------------------
3593 # Given an archive name, patches names and locations where to find them, fetch
3594 # the archive and the patches from any of those locations, unpack the archive
3595 # and then apply the patches.
3597 # Locations currently supported are http and ftp sites, plus local filesystem
3598 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
3599 # the fetch.sh script needs to be modified, since this macro relies on that script.
3603 # - mmake = mmaketarget
3604 # - archive_origins = list of locations where to find the archive. They are tried
3605 # in sequence, until the archive is found and fetching it
3606 # succeeded. If not specified, the current directory is assumed.
3607 # - archive = the archive name. Mandatory.
3608 # - suffixes = a list of suffixes to append to the package name plus the
3609 # version. Each one of them is tried until a matching archive is
3610 # found. They are appended to patches and these are tried the
3611 # same way as packages are.
3612 # - location = the local directory where to put the fetched archive and patches.
3613 # If not specified, the directory specified by destination is used.
3614 # - destination = the directory to unpack the archive to.
3615 # If not specified, the current directory is assumed.
3616 # - patches_origins = list of locations where to find the patches. They are tried
3617 # in sequence, until a patch is found and fetching it
3618 # succeeded. If not specified, the current directory is assumed.
3619 # - patches_specs = list of "patch specs". A patch spec is of the form
3620 # patch_name[:[patch_subdir][:patch_opt]].
3622 # - patch_name = the name of the patch file
3623 # - patch_subdir = the directory within \destination\ where to
3625 # - patch_opt = any options to pass to the `patch' command
3626 # when applying the patch.
3628 # The patch_subdir and patch_opt fields are optional.
3630 %define fetch mmake=/A archive_origins=. archive=/A suffixes= location= destination=. \
3631 patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
3635 ifneq (%(location),)
3636 %(mmake)-location := %(location)
3638 %(mmake)-location := %(destination)
3643 $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
3644 -d %(destination) -po "%(patches_origins)" -p "%(patches_specs)"
3646 #------------------------------------------------------------------------------
3649 #------------------------------------------------------------------------------
3650 # This macro can aid in patch creation for fetched ports. It temporarily creates another
3651 # unpatched source tree and runs diff against this and a previously fetched and possibly
3652 # patched tree. Depending on what happens after patching during a normal build it might
3653 # give best results if the new patch is created directly after fetch.
3657 # - mmake = mmaketarget
3658 # - archive = archive base name
3659 # - srcdir = the top level directory the package is unpacked to, useful if
3660 # an archive unpacks to a directory other than its name suggests.
3661 # this should not be deeper than a single path element.
3662 # - suffixes = a list of suffixes to append to the the package name plus the
3663 # version. Each one of them is tried until a matching archive is
3665 # - destination = the directory to unpack the archive to.
3666 # - excludes = diff patterns to exclude files or directories from the patch
3668 %define create_patch mmake=/A archive=/A srcdir= suffixes="tar.bz2 tar.gz" destination=/A excludes=
3672 ifneq (%(excludes),)
3673 %(mmake)-exclude := -X ./exclude.patterns
3677 %(mmake)-srcdir := %(srcdir)
3679 %(mmake)-srcdir := %(archive)
3682 #MM- %(mmake) : %(mmake)-diff
3683 #MM- %(mmake)-quick : %(mmake)-diff
3687 $(Q)$(FETCH) -a %(archive) -s "%(suffixes)" -l $(PORTSSOURCEDIR) -d %(destination)/tmp ; \
3688 $(MV) %(destination)/$(%(mmake)-srcdir) %(destination)/tmp/$(%(mmake)-srcdir).aros ; \
3689 cd %(destination)/tmp ; \
3690 $(FOR) f in %(excludes) ; do \
3691 $(ECHO) $$f >> ./exclude.patterns ; \
3693 diff -ruN $(%(mmake)-exclude) \
3694 $(%(mmake)-srcdir) \
3695 $(%(mmake)-srcdir).aros \
3696 >$(SRCDIR)/$(CURDIR)/%(archive)-aros-new.diff ; \
3697 $(MV) %(destination)/tmp/$(%(mmake)-srcdir).aros %(destination)/$(%(mmake)-srcdir) ; \
3698 $(RM) %(destination)/tmp
3700 #------------------------------------------------------------------------------
3703 #------------------------------------------------------------------------------
3704 # Joins the features of %fetch and %build_with_configure.
3706 # If a patch is provided, it *must* be named the following way:
3708 # <package name>-<version number>-aros.diff
3710 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3711 # CD'ing into the archive's extracted directory.
3713 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3714 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3715 # to make that patch fully comprehensive.
3719 # - mmake = the meta make target.
3720 # - package = the GNU package name, sans version and archive format suffixes.
3721 # - subpackage = ???
3722 # - compiler = same meaning as the one for the %build_with_configure macro.
3723 # - install_target = same meaning as the one for the %build_with_configure macro.
3724 # - version = the package's version number, or otherwise any other version string.
3725 # It gets appended to the package name to form the basename of the archive.
3726 # - suffixes = a list of suffixes to apped to the the package name plus the
3727 # version. Each one of them is tried until a matching archive is found.
3728 # Defaults to "tar.bz2 tar.gz".
3729 # - srcdir = the top level directory the package is unpacked to (see create_patch).
3730 # - builddir = override the location we expect to run configure/make in.
3731 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
3732 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
3733 # fetched or not. Default to no.
3734 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
3735 # - prefix = same meaning as the one for the %build_with_configure macro.
3736 # - aros_prefix = same meaning as the one for the %build_with_configure macro.
3737 # - extraoptions = same meaning as the one for the %build_with_configure macro.
3738 # - usecppflags = same meaning as the one for the %build_with_configure macro.
3739 # - extracppflags = same meaning as the one for the %build_with_configure macro.
3740 # - extracflags = same meaning as the one for the %build_with_configure macro.
3741 # - extracxxflags = same meaning as the one for the %build_with_configure macro.
3742 # - preconfigure = same meaning as the one for the %build_with_configure macro.
3743 # - postconfigure = same meaning as the one for the %build_with_configure macro.
3744 # - postinstall = same meaning as the one for the %build_with_configure macro.
3745 # - install_env = same meaning as the one for the %build_with_configure macro.
3746 # - use_build_env = same meaning as the one for the %build_with_configure macro.
3747 # - nix = same meaning as the one for the %build_with_configure macro.
3748 # - nix_dir_layout = same meaning as the one for the %build_with_configure macro.
3749 # - create_pkg = create a distributable package of the compiled sources, defaults to no
3751 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target crossbuild=no install_target=install \
3752 version=/A suffixes="tar.bz2 tar.gz" srcdir= builddir= gendir= basedir=$(CURDIR) package_repo= patch=no patch_repo= \
3753 prefix= aros_prefix= preconfigure= postconfigure= postinstall= \
3754 extraoptions= usecppflags=yes extracppflags= extracflags="$(OPTIMIZATION_CFLAGS)" extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3755 config_env_extra= install_env= use_build_env=no nix=no nix_dir_layout= create_pkg=no buildflags=yes gnuflags=yes nlsflag=yes xflag=yes hostisaflags="$(TARGET_ISA_CFLAGS)" targetisaflags="$(TARGET_ISA_CFLAGS)"
3757 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
3758 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
3759 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
3760 #MM- %(mmake)-create-patch : %(mmake)-%(subpackage)-create-patch
3762 %(mmake)-archbase := %(package)-%(version)
3764 ifeq (%(compiler),host)
3765 %(mmake)-portdir := $(HOSTDIR)/Ports/host/%(package)
3767 %(mmake)-portdir := $(PORTSDIR)/%(package)
3771 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
3773 %(mmake)-prefix := %(prefix)
3776 ifneq (%(subpackage),)
3777 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
3779 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
3783 %(mmake)-%(subpackage)-srcdir := %(srcdir)
3785 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
3788 ifneq (%(builddir),)
3789 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)/%(builddir)
3791 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)
3795 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-f,-p1
3797 %(mmake)-%(subpackage)-patches_specs := ::
3800 %fetch mmake="%(mmake)-%(subpackage)-fetch" archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
3801 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
3802 archive_origins=". %(package_repo)" \
3803 patches_specs=$(%(mmake)-%(subpackage)-patches_specs) patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
3805 %create_patch mmake="%(mmake)-%(subpackage)-create-patch" \
3806 archive=$(%(mmake)-%(subpackage)-archbase) \
3807 srcdir=$(%(mmake)-%(subpackage)-srcdir) \
3808 suffixes="%(suffixes)" \
3809 destination=$(%(mmake)-portdir)
3811 #MM- %(mmake) : %(mmake)-%(subpackage)
3813 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
3815 %(mmake)-%(subpackage)-package-basename := \
3816 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
3818 ifneq (%(create_pkg),no)
3819 %(mmake)-%(subpackage)-package := $(%(mmake)-%(subpackage)-package-basename).tar.bz2
3822 %build_with_configure mmake="%(mmake)-%(subpackage)" package="%(package)" compiler="%(compiler)" crossbuild="%(crossbuild)" install_target="%(install_target)" \
3823 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-builddir) gendir="%(gendir)" basedir="%(basedir)" \
3824 config_env_extra="%(config_env_extra)" install_env="%(install_env)" use_build_env="%(use_build_env)" \
3825 nix="%(nix)" nix_dir_layout="%(nix_dir_layout)" prefix=$(%(mmake)-prefix) aros_prefix="%(aros_prefix)" \
3826 preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall) %(mmake)-%(subpackage)-make-package" \
3827 extraoptions="%(extraoptions)" usecppflags="%(usecppflags)" extracppflags="%(extracppflags)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)" \
3828 buildflags=%(buildflags) gnuflags=%(gnuflags) nlsflag=%(nlsflag) xflag=%(xflag) hostisaflags=%(hostisaflags) targetisaflags=%(targetisaflags)
3830 .PHONY : %(mmake)-%(subpackage)-make-package %(mmake)-%(subpackage)-create-patch
3831 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
3834 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package)
3836 #There seems to be a bug, either with my clock or with make, 'cause it may happen
3837 #that $^ and $@ have exactly the same mtime, and in that case make tries
3838 #to rebuild $@ again, which would fail because the directory where
3839 #the package got installed would not exist anymore.
3840 #We work this around by using an if statement to manually check the mtimes.
3841 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
3842 $(Q)$(IF) $(TEST) $(%(mmake)-installflag) -nt $@ || ! $(TEST) -s $@; then \
3844 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
3845 $(MKDIR) -p "$(DISTDIR)/Packages" ; \
3846 $(MKDIR) -p "$(%(mmake)-prefix)" ; \
3847 cd $(%(mmake)-%(subpackage)-package-dir) ; \
3848 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
3849 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
3852 #------------------------------------------------------------------------------
3855 #------------------------------------------------------------------------------
3856 # Joins the features of %fetch and %build_with_configure, taking advantage of
3857 # the naming scheme of GNU packages. GNU packages names are in the form
3859 # <package name>-<version number>.<archive format suffix>
3861 # If a patch is provided, it *must* be named the following way:
3863 # <package name>-<version number>-aros.diff
3865 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3866 # CD'ing into the archive's extracted directory.
3868 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3869 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3870 # to make that patch fully comprehensive.
3872 # NOTE: GNU packages are always compiled with *nix semantics turned on.
3876 # Arguments have the same meaning as the one for the %fetch_and_build macro, except:
3878 # - prefix = defaults to $(GNUDIR).
3879 # - aros_prefix = defaults to /GNU.
3881 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A crossbuild=no suffixes="tar.bz2 tar.gz" \
3882 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
3883 aros_prefix=/GNU config_env_extra= preconfigure= postconfigure= postinstall= \
3884 extraoptions= usecppflags=yes extracppflags= extracflags="$(OPTIMIZATION_CFLAGS)" extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3885 hostisaflags="$(TARGET_ISA_CFLAGS)" targetisaflags="$(TARGET_ISA_CFLAGS)" \
3886 nix=yes gnuflags=yes nlsflag=yes xflag=yes
3888 GNU_REPOSITORY := gnu://
3890 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
3891 crossbuild="%(crossbuild)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
3892 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
3893 patch="%(patch)" patch_repo="%(patch_repo)" \
3894 prefix="%(prefix)" aros_prefix="%(aros_prefix)" \
3895 extraoptions="%(extraoptions)" usecppflags="%(usecppflags)" extracppflags="%(extracppflags)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)" \
3896 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" \
3897 hostisaflags="%(hostisaflags)" targetisaflags="%(targetisaflags)" \
3898 nix=%(nix) gnuflags=%(gnuflags) nlsflag=%(nlsflag) xflag=%(xflag)
3901 #------------------------------------------------------------------------------
3904 #------------------------------------------------------------------------------
3905 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
3906 # that the package is a "Developer" package, and as such it needs to be placed
3907 # under the $(AROS_DEVELOPER) directory, as a default.
3909 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
3910 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
3911 # "mmake" argument, because the metatarget is implicitely defined as
3913 # #MM- development-%(package)
3915 %define fetch_and_build_gnu_development package=/A subpackage= version=/A crossbuild=no suffixes="tar.bz2 tar.gz" \
3916 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPER) \
3917 aros_prefix=/Developer config_env_extra= preconfigure= postconfigure= postinstall= \
3918 extraoptions= usecppflags=yes extracppflags= extracflags="$(OPTIMIZATION_CFLAGS)" extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3919 hostisaflags="$(TARGET_ISA_CFLAGS)" targetisaflags="$(TARGET_ISA_CFLAGS)" \
3920 nix=yes gnuflags=yes nlsflag=yes xflag=yes
3922 #MM- development : development-%(package)
3925 %fetch_and_build_gnu mmake="development-%(package)" package="%(package)" subpackage="%(subpackage)" \
3926 version="%(version)" crossbuild="%(crossbuild)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
3927 package_repo="%(package_repo)" \
3928 patch="%(patch)" patch_repo="%(patch_repo)" \
3929 prefix="%(prefix)" aros_prefix="%(aros_prefix)" \
3930 extraoptions="%(extraoptions)" usecppflags="%(usecppflags)" extracflags="%(extracflags)" extracppflags="%(extracppflags)" extracxxflags="%(extracxxflags)" \
3931 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="postinstall-%(package)-delete-la-files %(postinstall)" \
3932 hostisaflags="%(hostisaflags)" targetisaflags="%(targetisaflags)" \
3933 nix=%(nix) gnuflags=%(gnuflags) nlsflag=%(nlsflag) xflag=%(xflag)
3936 postinstall-%(package)-delete-la-files:
3937 $(RM) %(prefix)/lib/*.la
3940 #------------------------------------------------------------------------------
3942 # Builds a kickstart package in PKG format
3946 # - mmake = target name
3947 # - file = destination file name with path
3949 # Other arguments are self-explanatory
3951 %define make_package mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
3952 arch_classes= arch_devs= arch_handlers= arch_hidds= arch_libs= arch_res=
3954 PKG_CLASSES := $(addprefix $(AROS_CLASSES)/,$(addsuffix .class, %(classes)))
3955 PKG_DEVICES := $(addprefix $(AROS_DEVS)/,$(addsuffix .device, %(devs)))
3956 PKG_HANDLERS := $(addprefix $(AROS_FS)/,$(addsuffix -handler, %(handlers)))
3957 PKG_HIDD := $(addprefix $(AROS_DEVS)/Drivers/,$(addsuffix .hidd, %(hidds)))
3958 PKG_LIBS := $(addprefix $(AROS_LIBRARIES)/,$(addsuffix .library, %(libs)))
3959 PKG_RESOURCES := $(addprefix $(AROS_DEVS)/,$(addsuffix .resource, %(res)))
3961 PKG_CLASSES_ARCH := $(addprefix $(AROS_CLASSES_ARCH)/,$(addsuffix .class, %(arch_classes)))
3962 PKG_DEVICES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .device, %(arch_devs)))
3963 PKG_HANDLERS_ARCH := $(addprefix $(AROS_FS_ARCH)/,$(addsuffix -handler, %(arch_handlers)))
3964 PKG_HIDD_ARCH := $(addprefix $(AROS_DEVS_ARCH)/Drivers/,$(addsuffix .hidd, %(arch_hidds)))
3965 PKG_LIBRARIES_ARCH := $(addprefix $(AROS_LIBRARIES_ARCH)/,$(addsuffix .library, %(arch_libs)))
3966 PKG_RESOURCES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .resource, %(arch_res)))
3968 PKG_FILES := $(PKG_CLASSES) $(PKG_DEVICES) $(PKG_HANDLERS) $(PKG_HIDD) $(PKG_LIBS) $(PKG_RESOURCES) \
3969 $(PKG_CLASSES_ARCH) $(PKG_DEVICES_ARCH) $(PKG_HANDLERS_ARCH) $(PKG_HIDD_ARCH) $(PKG_LIBRARIES_ARCH) $(PKG_RESOURCES_ARCH)
3970 PKG_DIR := $(dir %(file))
3976 %(mmake)-quick : %(file)
3978 %(file): $(PKG_FILES) | $(PKG_DIR)
3979 $(Q)$(ECHO) Packaging $@...
3980 $(Q)$(SRCDIR)/tools/package/pkg c $@ $^
3982 %compress_file mmake="%(mmake)" file="%(file)"
3984 GLOB_MKDIRS += $(PKG_DIR)
3988 #------------------------------------------------------------------------------
3989 # Compresses %(file) with a gzip.
3990 # Good in conjunction with for example %build_prog
3992 %define compress_file mmake=/A file=/A
3994 #MM- %(mmake)-gz : %(mmake) %(mmake)-gz-quick
3997 %(mmake)-gz-quick : %(file).gz
4000 $(Q)$(ECHO) Compressing $(subst $(TARGETDIR)/,,$^)...
4005 #------------------------------------------------------------------------------
4006 # Links a kickstart module in ELF format
4007 # Arguments are similar to make_package
4009 %define link_kickstart mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
4010 startup= uselibs= ldflags=$(LDFLAGS) map= deps=
4012 KOBJ_CLASSES := $(addprefix $(KOBJSDIR)/, $(addsuffix _class.o, %(classes)))
4013 KOBJ_DEVICES := $(addprefix $(KOBJSDIR)/, $(addsuffix _device.o, %(devs)))
4014 KOBJ_HANDLERS := $(addprefix $(KOBJSDIR)/, $(addsuffix _handler.o, %(handlers)))
4015 KOBJ_HIDD := $(addprefix $(KOBJSDIR)/, $(addsuffix _hidd.o, %(hidds)))
4016 KOBJ_LIBS := $(addprefix $(KOBJSDIR)/, $(addsuffix _library.o, %(libs)))
4017 KOBJ_RES := $(addprefix $(KOBJSDIR)/, $(addsuffix _resource.o, %(res)))
4020 KOBJ_STARTUP := $(GENDIR)/$(RESIDENT_BEGIN).o
4022 KOBJ_STARTUP := %(startup)
4025 KOBJS := $(KOBJ_STARTUP) $(KOBJ_CLASSES) $(KOBJ_HANDLERS) $(KOBJ_LIBS) $(KOBJ_DEVICES) $(KOBJ_HIDD) $(KOBJ_RES)
4027 TMP_LDFLAGS := %(ldflags)
4029 # Make a list of the lib files this program depends on.
4030 # In LDFLAGS remove white space between -L and directory
4031 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
4032 # Filter out only the libdirs and remove -L
4033 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
4035 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
4036 # Add normal linklib path
4037 TMP_DIRS += $(AROS_LIB)/
4038 # add lib and .a to static linklib names
4039 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
4040 # search for the linklibs in the given path, ignore ones not found
4041 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
4042 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
4045 TMP_DIRS += $(dir %(file))
4047 TMP_LDFLAGS += $(GENMAP) %(map)
4048 TMP_DIRS += $(dir %(map))
4051 #MM %(mmake) : %(deps)
4057 %(mmake)-quick : %(file)
4059 %(file): KOBJS := $(KOBJS)
4060 %(file): LDFLAGS := $(TMP_LDFLAGS) $(NOSTARTUP_LDFLAGS) \
4061 -static -nosysbase -Wl,-Ur
4062 %(file): LDLIBS := $(addprefix -l, %(uselibs))
4063 %(file): $(KOBJS) $(DEPLIBS) | $(TMP_DIRS)
4064 $(Q)$(ECHO) "Kickstart $(subst $(TARGETDIR)/,,$@)..."
4065 $(Q)$(TARGET_CC) $(TARGET_SYSROOT) -o $@ $(KOBJS) $(LDFLAGS) $(LDLIBS)
4067 $(Q)$(STRIP) $@ --only-keep-debug -o $@.dbg
4071 $(Q)$(OBJCOPY) --add-gnu-debuglink=$@.dbg $@
4074 %compress_file mmake="%(mmake)" file="%(file)"
4076 GLOB_MKDIRS += $(TMP_DIRS)
4080 #------------------------------------------------------------------------------
4081 # Generate generic rules for a subtarget
4083 %define subtarget parentmmake= mmake=/A mmbase=MM-
4084 #%(mmbase) %(parentmmake) : %(mmake)
4085 #%(mmbase) %(parentmmake)-includes : %(mmake)-includes
4086 #%(mmbase) %(parentmmake)-quick : %(mmake)-quick
4089 #------------------------------------------------------------------------------
4090 # Create a target directory
4092 %define directorytarget mmake=/A directory= icontarget= mmbase=MM-
4095 %mkdirs_q %(directory)
4097 #%(mmbase) %(mmake) : %(mmake)-makedir