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 # Strip symbols from the specified file
65 %define strip_q strip=$(STRIP) file=
66 $(Q)$(IF) $(TEST) "%(strip)" != ""; then \
67 $(IF) $(TEST) "$(DEBUG)" = "yes"; then \
68 %(strip) %(file) --only-keep-debug -o %(file).dbg ; \
71 $(IF) $(TEST) "$(DEBUG)" = "yes"; then \
72 $(IF) $(TEST) -s %(file).dbg ; then \
73 $(OBJCOPY) --add-gnu-debuglink=%(file).dbg %(file) ; \
78 #------------------------------------------------------------------------------
80 #------------------------------------------------------------------------------
81 # Link a specified number of objects to an executable
82 %define link_q cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" opt=$(LDFLAGS) from=$< to=$@ libs=$(LIBS) strip=$(STRIP) objdir=$(GENDIR)/$(CURDIR) coverageinstr=
83 $(Q)$(eval LINKTARGET=%(to))
84 $(Q)$(ECHO) "Linking $(subst $(TARGETDIR)/,,$(LINKTARGET))..."
85 $(Q)$(eval LINKTMPFILE=%(objdir)/$(notdir $(LINKTARGET)))
86 $(Q)$(IF) %(cmd) %(from) -o $(LINKTMPFILE) %(opt) %(libs) 2>&1 > $(GENDIR)/cerrors 2>&1 ; then \
87 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
88 $(ECHO) "$(LINKTARGET): %(cmd) %(from) -o $(LINKTARGET) %(opt) %(libs)" >> $(GENDIR)/errors ; \
89 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
93 $(CP) $(LINKTMPFILE) $(LINKTARGET) ; \
95 $(ECHO) "Link failed: %(cmd) %(from) -o $(LINKTARGET) %(opt) %(libs)" 1>&2 ; \
96 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
99 %strip_q strip=%(strip) file=$(LINKTARGET)
100 $(Q)$(IF) $(TEST) "%(coverageinstr)" = "yes"; then \
101 LINKBASEFILES="$(strip $(notdir $(basename %(from))))" ; \
102 $(FOR) covext in $(TARGET_COVERAGEINSTR_EXTS) ; do \
103 $(FOR) file in $$LINKBASEFILES ; do \
104 COVERAGEFILE=`echo $$file$$covext` ; \
105 $(IF) $(TEST) -s %(objdir)/$$COVERAGEFILE ; then \
106 $(CP) %(objdir)/$$COVERAGEFILE $(dir $(LINKTARGET))$$COVERAGEFILE ; \
112 #------------------------------------------------------------------------------
115 #-------------------------------------------------------------------------
116 # Link a module based upon a number of arguments and the standard $(LIBS)
117 # and $(DEPLIBS) make variables.
119 %define link_module_q cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" err="$(notdir $@).err" strip=$(STRIP) objs=/A endtag= module=$(MODULE) ldflags=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
120 $(Q)$(ECHO) "Building $(subst $(TARGETDIR)/,,$@) ..."
121 $(Q)$(IF) %(cmd) $(NOSTARTUP_LDFLAGS) \
122 $(GENMAP) %(objdir)/%(module).map \
123 %(objs) %(libs) %(ldflags) %(endtag) \
124 -o $@ 2>&1 > %(objdir)/%(err); \
126 cat %(objdir)/%(err); \
128 echo "%(cmd) $(NOSTARTUP_LDFLAGS) $(GENMAP) %(objdir)/%(module).map %(objs) %(libs) %(ldflags) %(endtag) -o $@"; \
129 cat %(objdir)/%(err); \
132 $(Q)$(IF) $(TEST) ! -s %(objdir)/%(err) ; then $(RM) %(objdir)/%(err) ; fi
133 %strip_q strip=%(strip) file=$@
135 #------------------------------------------------------------------------------
138 #------------------------------------------------------------------------------
140 %define mklib_q ar=$(AR) ranlib=$(RANLIB) to=$@ from=$(OBJS)
141 $(Q)$(ECHO) "Creating $(subst $(TARGETDIR)/,,%(to))..."
142 $(Q)%(ar) %(to) %(from)
145 #------------------------------------------------------------------------------
148 #------------------------------------------------------------------------------
149 # Create the dependency file %(to) for %(from)
150 %define mkdepend_q flags="$(strip $(CFLAGS) $(CPPFLAGS))" from=$< to=$@ cc="$(strip $(AROS_CC) $(TARGET_SYSROOT))"
151 %mkdir_q dir="$(dir %(to))"
152 $(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))))..."
153 $(Q)AROS_CC="%(cc)" $(MKDEPEND) %(flags) -I$(TOP)/$(CURDIR) -I$(SRCDIR)/$(CURDIR) %(from) -o %(to)
155 #------------------------------------------------------------------------------
158 #------------------------------------------------------------------------------
159 # Create one directory without any output
160 %define mkdir_q dir=.
161 $(Q)$(IF) $(TEST) ! -d %(dir) ; then $(MKDIR) %(dir) ; else $(NOP) ; fi
163 #------------------------------------------------------------------------------
166 #------------------------------------------------------------------------------
167 # Create several directories without any output
168 %define mkdirs_q dirs=/M
169 $(Q)$(FOR) dir in %(dirs) ; do \
170 $(IF) $(TEST) ! -d $$dir ; then $(MKDIR) $$dir ; else $(NOP) ; fi ; \
173 #------------------------------------------------------------------------------
176 #############################################################################
177 #############################################################################
179 ## Here are the mmakefile macros that are used to do certain tasks in a ##
180 ## mmakefile. They consist of one or more full makefile rules. ##
181 ## In general the files generated in these macros are also defined as ##
182 ## make targets so that they can be used as a dependency in other rules ##
184 #############################################################################
185 #############################################################################
187 #------------------------------------------------------------------------------
188 # Generate a unique id for each of the %build... rules
189 %define buildid targets=/A
191 ifneq ($(filter $(TARGET),%(targets)),)
192 BDTARGETID := $(BDID)
195 #------------------------------------------------------------------------------
198 #------------------------------------------------------------------------------
199 # Copy file %(from) to %(to) in a makefile rule
200 %define rule_copy from=/A to=/A
204 #------------------------------------------------------------------------------
207 #------------------------------------------------------------------------------
208 # Copy the files %(files) to %(targetdir). For each file in %(files),
209 # %(srcdir)/file is copied to %(targetdir)/file. The targetdir and the
210 # appropriate subdirs are not generated by this rule so they have to be
212 %define rule_copy_multi files=/A targetdir=/A srcdir=.
214 $(addprefix %(targetdir)/,%(files)) : %(targetdir)/% : %(srcdir)/%
217 #------------------------------------------------------------------------------
220 #------------------------------------------------------------------------------
221 # Copy the files %(files) to %(targetdir). For each file in %(files),
222 # %(srcdir)/file is copied to %(targetdir)/file if these files are different.
223 # %(stampfile) is used to keep track of when the last time the comparison has
224 # been done. The targetdir and the appropriate subdirs are not generated by
225 # this rule so they have to be present.
226 %define rule_copy_diff_multi files=/A targetdir=/A srcdir=. \
227 stampfile=$(TMP_SRCDIR)/.copy_stamp
229 TMP_SRCDIR := %(srcdir)
231 $(addprefix %(targetdir)/,%(files)) : | %(stampfile)
233 %(stampfile) : COPYSRCDIR := %(srcdir)
234 %(stampfile) : TGTDIR := %(targetdir)
235 %(stampfile) : FILES := %(files)
236 %(stampfile) : $(addprefix %(srcdir)/,%(files))
237 $(Q)for f in $(FILES); do \
238 $(IF) ! $(CMP) -s $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; then \
239 $(CP) $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; \
244 #------------------------------------------------------------------------------
247 #------------------------------------------------------------------------------
248 # Will join all the files in %(from) to %(to). When text is specified it will
250 # Restriction: at the moment when using a non-empty target dir %(from) may
252 %define rule_join to=/A from=/A text=
255 $(Q)$(IF) $(TEST) "%(text)" != "" ; then \
256 $(Q)$(ECHO) %(text) ; \
260 #------------------------------------------------------------------------------
263 #------------------------------------------------------------------------------
264 # Include the dependency files and add some internal rules
265 # When depstargets is provided the depencies will only be included when one of
266 # these targets is the $(TARGET). Otherwise the dependencies will only be
267 # included when the $(TARGET) is not for setup or clean
268 %define include_deps deps=$(DEPS)/M depstargets=
270 ifneq (%(depstargets),)
271 ifneq ($(findstring $(TARGET),%(depstargets)),)
275 ifeq (,$(filter clean% %clean %clean% setup% includes% %setup,$(TARGET)))
281 #------------------------------------------------------------------------------
284 #------------------------------------------------------------------------------
285 # Create the directories %(dirs). The creation will be done by adding rules to
286 # the %(setuptarget) make target with setup as the default.
287 %define rule_makedirs dirs=/A setuptarget=setup
289 ifneq (%(setuptarget),)
290 %(setuptarget) : | %(dirs)
292 %(setuptarget) :: %(dirs)
295 GLOB_MKDIRS += %(dirs)
298 #------------------------------------------------------------------------------
301 #------------------------------------------------------------------------------
302 # Generate a rule to compile a C source file to an object file and generate
303 # the dependency file. Basename may contain a directory part, then the source
304 # file has to be in that directory. The generated file will be put in the
305 # object directory without the directory.
307 # - basename: the basename of the file to compile. Use % for a wildcard rule
308 # - cflags (default $(CFLAGS)): the C flags to use for compilation
309 # - dflags: the flags used during creation of dependency file. If not specified
310 # the same value as cflags will be used
311 # - targetdir: the directory to put the .o file and the .d file. By default
312 # it is put in the same directory as the .c file
313 %define rule_compile mmake=TMP basename=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= targetdir= compiler=target
315 %(mmake)_NIXFLAG ?= -nix
318 %(mmake)_TARGETBASE := %(basename)
320 %(mmake)_TARGETBASE := %(targetdir)/$(notdir %(basename))
323 # Adjust compiler flags to suit C
324 %(mmake)_C_CPPFLAGS := %(cppflags)
325 %(mmake)_CFLAGS := %(cflags)
326 %(mmake)_CFLAGS := $(subst -fpermissive,, $(%(mmake)_CFLAGS))
328 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
330 %(mmake)_DFLAGS := %(dflags)
333 ifeq ($(findstring %(compiler),host kernel target),)
334 $(error unknown compiler %(compiler))
336 ifeq (%(compiler),target)
337 %(mmake)_LINK ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
338 %(mmake)_STRIP ?= $(TARGET_STRIP)
339 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
340 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
341 $(%(mmake)_TARGETBASE).o : %(mmake)_C_CPPFLAGS:=$(strip $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
342 $(%(mmake)_TARGETBASE).d : %(mmake)_C_CPPFLAGS:=$(strip $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
343 $(%(mmake)_TARGETBASE).o : %(mmake)_CFLAGS:=$(strip $(%(mmake)_CFLAGS) $(SAFETY_CFLAGS))
344 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(%(mmake)_DFLAGS)
345 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
346 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
347 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
348 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
350 ifeq (%(compiler),host)
351 %(mmake)_LINK ?= $(strip $(HOST_CC) $(HOST_LDFLAGS))
352 %(mmake)_STRIP ?= $(HOST_STRIP)
353 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(HOST_CC)
354 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(HOST_CC)
355 $(%(mmake)_TARGETBASE).o : %(mmake)_C_CPPFLAGS:=$(strip $(HOST_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
356 $(%(mmake)_TARGETBASE).d : %(mmake)_C_CPPFLAGS:=$(strip $(HOST_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
357 $(%(mmake)_TARGETBASE).o : %(mmake)_CFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_CFLAGS))
358 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_DFLAGS))
359 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
360 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
361 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
362 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
364 ifeq (%(compiler),kernel)
365 %(mmake)_LINK ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
366 %(mmake)_STRIP ?= $(ECHO) >/dev/null
367 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
368 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
369 $(%(mmake)_TARGETBASE).o : %(mmake)_C_CPPFLAGS:=$(strip $(KERNEL_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
370 $(%(mmake)_TARGETBASE).d : %(mmake)_C_CPPFLAGS:=$(strip $(KERNEL_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
371 $(%(mmake)_TARGETBASE).o : %(mmake)_CFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_CFLAGS))
372 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_DFLAGS))
373 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
374 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
375 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
376 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
379 $(%(mmake)_TARGETBASE).o : CPPFLAGS := $(%(mmake)_C_CPPFLAGS)
380 $(%(mmake)_TARGETBASE).o : CFLAGS := $(%(mmake)_CFLAGS)
381 $(%(mmake)_TARGETBASE).o : %(basename).c
382 %compile_q cmd=$(%(mmake)_CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
385 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(strip $(%(mmake)_NIXFLAG) $(%(mmake)_DFLAGS))
387 $(%(mmake)_TARGETBASE).d : %(basename).c
388 %mkdepend_q cc=$(%(mmake)_CMD) flags="$(strip $(%(mmake)_DFLAGS) $(%(mmake)_C_CPPFLAGS))"
390 #------------------------------------------------------------------------------
393 #------------------------------------------------------------------------------
394 # Generate a rule to compile a C++ source file to an object file and generate
395 # the dependency file. Basename may contain a directory part, then the source
396 # file has to be in that directory. The generated file will be put in the
397 # object directory without the directory.
399 # - basename: the basename of the file to compile. Use % for a wildcard rule
400 # - cflags (default $(CFLAGS)): the C flags to use for compilation
401 # - dflags: the flags used during creation of dependency file. If not specified
402 # the same value as cflags will be used
403 # - targetdir: the directory to put the .o file and the .d file. By default
404 # it is put in the same directory as the .c file
405 %define rule_compile_cxx mmake=TMP basename=/A cppflags=$(CPPFLAGS) cxxflags=$(CXXFLAGS) dxxflags= targetdir= compiler=target
408 %(mmake)_NIXFLAG ?= -nix
410 %(mmake)_TARGETBASE := %(basename)
412 %(mmake)_TARGETBASE := %(targetdir)/$(notdir %(basename))
415 # Adjust compiler flags to suit C++
416 %(mmake)_CXX_CPPFLAGS := %(cppflags)
417 %(mmake)_CXXFLAGS := %(cxxflags)
419 %(mmake)_DXXFLAGS := %(cxxflags)
421 %(mmake)_DXXFLAGS := %(dxxflags)
424 ifeq ($(findstring %(compiler),host kernel target),)
425 $(error unknown compiler %(compiler))
427 ifeq (%(compiler),target)
428 %(mmake)_LINK ?= $(strip $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
429 %(mmake)_STRIP ?= $(TARGET_STRIP)
430 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(AROS_CXX) $(TARGET_SYSROOT))
431 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(AROS_CXX) $(TARGET_SYSROOT))
432 $(%(mmake)_TARGETBASE).o : %(mmake)_CXX_CPPFLAGS:=$(strip $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
433 $(%(mmake)_TARGETBASE).d : %(mmake)_CXX_CPPFLAGS:=$(strip $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
434 $(%(mmake)_TARGETBASE).o : %(mmake)_CXXFLAGS:=$(strip $(%(mmake)_CXXFLAGS) $(SAFETY_CFLAGS))
435 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(%(mmake)_DXXFLAGS)
436 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
437 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
438 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
439 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
441 ifeq (%(compiler),host)
442 %(mmake)_LINK ?= $(strip $(HOST_CXX) $(HOST_LDFLAGS))
443 %(mmake)_STRIP ?= $(HOST_STRIP)
444 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(HOST_CXX)
445 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(HOST_CXX)
446 $(%(mmake)_TARGETBASE).o : %(mmake)_CXX_CPPFLAGS:=$(strip $(HOST_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
447 $(%(mmake)_TARGETBASE).d : %(mmake)_CXX_CPPFLAGS:=$(strip $(HOST_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
448 $(%(mmake)_TARGETBASE).o : %(mmake)_CXXFLAGS:=$(strip $(HOST_CXXFLAGS) $(%(mmake)_CXXFLAGS))
449 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(strip $(HOST_CXXFLAGS) $(%(mmake)_DXXFLAGS))
450 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
451 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
452 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
453 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
455 ifeq (%(compiler),kernel)
456 KERNEL_CXX ?= $(KERNEL_CC)
457 %(mmake)_LINK ?= $(strip $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
458 %(mmake)_STRIP ?= $(ECHO) >/dev/null
459 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))
460 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))
461 $(%(mmake)_TARGETBASE).o : %(mmake)_CXX_CPPFLAGS:=$(strip $(KERNEL_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
462 $(%(mmake)_TARGETBASE).d : %(mmake)_CXX_CPPFLAGS:=$(strip $(KERNEL_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
463 $(%(mmake)_TARGETBASE).o : %(mmake)_CXXFLAGS:=$(strip $(KERNEL_CXXFLAGS) $(%(mmake)_CXXFLAGS))
464 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(strip $(KERNEL_CXXFLAGS) $(%(mmake)_DXXFLAGS))
465 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
466 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
467 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
468 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
471 $(%(mmake)_TARGETBASE).o : CPPFLAGS := $(%(mmake)_CXX_CPPFLAGS)
472 $(%(mmake)_TARGETBASE).o : CXXFLAGS := $(%(mmake)_CXXFLAGS)
473 $(%(mmake)_TARGETBASE).o : %(basename).cpp
474 %compile_q cmd=$(%(mmake)_CMD) opt="$(strip $(CXXFLAGS) $(CPPFLAGS))" iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
477 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(strip $(%(mmake)_NIXFLAG) $(%(mmake)_DXXFLAGS))
479 $(%(mmake)_TARGETBASE).d : %(basename).cpp
480 %mkdepend_q cc=$(%(mmake)_CMD) flags="$(strip $(%(mmake)_DXXFLAGS) $(%(mmake)_CXX_CPPFLAGS))"
485 #------------------------------------------------------------------------------
488 #------------------------------------------------------------------------------
489 # Generate a rule to compile an ObjC source file to an object file and generate
490 # the dependency file. Basename may contain a directory part, then the source
491 # file has to be in that directory. The generated file will be put in the
492 # object directory without the directory.
494 # - basename: the basename of the file to compile. Use % for a wildcard rule
495 # - cflags (default $(CFLAGS)): the C flags to use for compilation
496 # - dflags: the flags used during creation of dependency file. If not specified
497 # the same value as cflags will be used
498 # - targetdir: the directory to put the .o file and the .d file. By default
499 # it is put in the same directory as the .m file
500 %define rule_compile_objc mmake=TMP basename=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= targetdir= compiler=target
503 %(mmake)_NIXFLAG ?= -nix
505 %(mmake)_TARGETBASE := %(basename)
507 %(mmake)_TARGETBASE := %(targetdir)/$(notdir %(basename))
510 # Adjust compiler flags to suit ObjC
511 %(mmake)_OBJC_CPPFLAGS := %(cppflags)
512 %(mmake)_OBJCFLAGS := %(cflags)
513 %(mmake)_OBJCFLAGS := $(%(mmake)_OBJCFLAGS) -isystem $(AROS_DEVELOPER)/include
514 %(mmake)_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(%(mmake)_OBJCFLAGS)))
516 %(mmake)_OBJCDFLAGS := %(cflags)
518 %(mmake)_OBJCDFLAGS := %(dflags)
521 # Define the use of cross compiler
522 ifeq ($(TARGET_OBJC),)
523 %(mmake)_CC := $(TARGET_CC)
525 %(mmake)_CC := $(TARGET_OBJC)
528 ifeq ($(findstring %(compiler),host kernel target),)
529 $(error unknown compiler %(compiler))
531 ifeq (%(compiler),target)
532 %(mmake)_LINK ?= $(strip $(%(mmake)_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
533 %(mmake)_STRIP ?= $(TARGET_STRIP)
534 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(%(mmake)_CC) $(TARGET_SYSROOT))
535 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(%(mmake)_CC) $(TARGET_SYSROOT))
536 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJC_CPPFLAGS:=$(strip $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
537 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJC_CPPFLAGS:=$(strip $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
538 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJCFLAGS:=$(strip $(%(mmake)_OBJCFLAGS) $(SAFETY_CFLAGS))
539 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(%(mmake)_OBJCDFLAGS)
540 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
541 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
542 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
543 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
545 ifeq (%(compiler),host)
546 %(mmake)_LINK ?= $(strip $(HOST_CC) $(HOST_LDFLAGS))
547 %(mmake)_STRIP ?= $(HOST_STRIP)
548 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(HOST_CC)
549 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(HOST_CC)
550 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJC_CPPFLAGS:=$(strip $(HOST_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
551 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJC_CPPFLAGS:=$(strip $(HOST_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
552 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJCFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCFLAGS))
553 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCDFLAGS))
554 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
555 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
556 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
557 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
559 ifeq (%(compiler),kernel)
560 %(mmake)_LINK ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
561 %(mmake)_STRIP ?= $(ECHO) >/dev/null
562 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
563 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
564 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJC_CPPFLAGS:=$(strip $(KERNEL_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
565 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJC_CPPFLAGS:=$(strip $(KERNEL_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
566 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJCFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCFLAGS))
567 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCDFLAGS))
568 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
569 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
570 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
571 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
574 $(%(mmake)_TARGETBASE).o : CPPFLAGS := $(%(mmake)_OBJC_CPPFLAGS)
575 $(%(mmake)_TARGETBASE).o : CFLAGS := $(%(mmake)_OBJCFLAGS)
576 $(%(mmake)_TARGETBASE).o : %(basename).m
577 %compile_q cmd=$(%(mmake)_CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
580 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(strip $(%(mmake)_NIXFLAG) $(%(mmake)_OBJCDFLAGS))
582 $(%(mmake)_TARGETBASE).d : %(basename).m
583 %mkdepend_q cc=$(%(mmake)_CMD) flags="$(strip $(%(mmake)_OBJCDFLAGS) $(%(mmake)_OBJC_CPPFLAGS))"
588 #------------------------------------------------------------------------------
591 #------------------------------------------------------------------------------
592 # Generate a rule to compile multiple C source files to an object file and
593 # generate the corresponding dependency files. The generated file will be put
594 # in the object directory without the directory part of the source file.
596 # - basenames: the basenames of the files to compile. The names may include
597 # relative or absolute path names. No wildcard is allowed
598 # - cflags (default $(CFLAGS)): the C flags to use for compilation
599 # - dflags: the flags used during creation of dependency file. If not specified
600 # the same value as cflags will be used
601 # - targetdir: the directory to put the .o file and the .d file. By default
602 # it is put in the same directory as the .c file. When targetdir is not
603 # empty, path names will be stripped from the file names so that all files
604 # are in that dir and not in subdirectories.
605 # - compiler (default target): compiler to use, target, kernel or host
606 %define rule_compile_multi mmake=TMP basenames=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= srcdir= targetdir= \
607 compiler=target usetree=no
610 %(mmake)_MC_SRCWILDCARD := %
612 %(mmake)_MC_SRCWILDCARD := %(srcdir)/%
616 %(mmake)_MC_TARGETS := $(addsuffix .o,%(basenames))
617 %(mmake)_MC_DTARGETS := $(addsuffix .d,%(basenames))
618 %(mmake)_MC_TGTWILDCARD := %
621 %(mmake)_MC_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
622 %(mmake)_MC_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
625 %(mmake)_MC_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,%(basenames)))
626 %(mmake)_MC_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,%(basenames)))
628 %(mmake)_MC_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(patsubst %(srcdir)/%,%,%(basenames))))
629 %(mmake)_MC_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(patsubst %(srcdir)/%,%,%(basenames))))
632 %(mmake)_MC_TGTWILDCARD := %(targetdir)/%
634 # Be sure that all .c files are generated
635 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : | $(addsuffix .c,%(basenames))
637 # Be sure that all .c files are found
638 %(mmake)_MC_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
639 %(mmake)_MC_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
640 %(mmake)_MC_DIRS := $(foreach dir, $(%(mmake)_MC_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(%(mmake)_MC_SRCDIR)/$(CURDIR)/$(dir)))
641 ifneq ($(%(mmake)_MC_DIRS),)
642 %(mmake)_MC_DIRS := $(shell echo $(%(mmake)_MC_DIRS) | sed 's/\(.\):\//\/\1\//g')
643 vpath %.c $(%(mmake)_MC_DIRS)
648 %(mmake)_MC_CPPFLAGS := %(cppflags)
649 %(mmake)_CFLAGS := %(cflags)
651 %(mmake)_DFLAGS := %(cflags)
653 %(mmake)_DFLAGS := %(dflags)
656 ifeq ($(findstring %(compiler),host kernel target),)
657 $(error unknown compiler %(compiler))
659 ifeq (%(compiler),target)
660 %(mmake)_LINK ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
661 %(mmake)_STRIP ?= $(TARGET_STRIP)
662 %(mmake)_ASSEMBLER ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT))
663 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
664 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_MC_CPPFLAGS:=$(strip $(%(mmake)_MC_CPPFLAGS) $(%(mmake)_MC_EXTRA_CPPFLAGS))
665 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_CFLAGS:=$(strip $(%(mmake)_CFLAGS) $(SAFETY_CFLAGS))
666 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_DFLAGS:=$(%(mmake)_DFLAGS)
667 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
668 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
670 ifeq (%(compiler),host)
671 %(mmake)_LINK ?= $(strip $(HOST_CC) $(HOST_LDFLAGS))
672 %(mmake)_STRIP ?= $(HOST_STRIP)
673 %(mmake)_ASSEMBLER ?= $(strip $HOST_CC) $(HOST_SYSROOT))
674 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : CMD:=$(HOST_CC)
675 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_MC_CPPFLAGS:=$(strip $(HOST_MC_CPPFLAGS) $(%(mmake)_MC_CPPFLAGS) $(%(mmake)_MC_EXTRA_CPPFLAGS))
676 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_CFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_CFLAGS))
677 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_DFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_DFLAGS))
678 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
679 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
681 ifeq (%(compiler),kernel)
682 %(mmake)_LINK ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
683 %(mmake)_STRIP ?= $(ECHO) >/dev/null
684 %(mmake)_ASSEMBLER ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
685 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
686 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_MC_CPPFLAGS:=$(strip $(KERNEL_MC_CPPFLAGS) $(%(mmake)_MC_CPPFLAGS) $(%(mmake)_MC_EXTRA_CPPFLAGS))
687 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_CFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_CFLAGS))
688 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_DFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_DFLAGS))
689 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
690 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
693 $(%(mmake)_MC_TARGETS) : CPPFLAGS := $(%(mmake)_MC_CPPFLAGS)
694 $(%(mmake)_MC_TARGETS) : CFLAGS := $(%(mmake)_CFLAGS)
695 $(%(mmake)_MC_TARGETS) : $(%(mmake)_MC_TGTWILDCARD).o : $(%(mmake)_MC_SRCWILDCARD).c
696 %compile_q cmd=$(CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
698 $(%(mmake)_MC_DTARGETS) : $(%(mmake)_MC_TGTWILDCARD).d : $(%(mmake)_MC_SRCWILDCARD).c
699 %mkdepend_q cc=$(CMD) flags="$(strip $(%(mmake)_DFLAGS) $(%(mmake)_MC_CPPFLAGS))"
701 #------------------------------------------------------------------------------
704 #------------------------------------------------------------------------------
705 # Generate a rule to compile multiple C++ source files to an object file and
706 # generate the corresponding dependency files. The generated file will be put
707 # in the object directory without the directory part of the source file.
709 # - basenames: the basenames of the files to compile. The names may include
710 # relative or absolute path names. No wildcard is allowed. basenames will be
711 # matched to supported AROS_CXXEXTS.
712 # - cflags (default $(CFLAGS)): the C flags to use for compilation
713 # - dflags: the flags used during creation of dependency file. If not specified
714 # the same value as cflags will be used
715 # - targetdir: the directory to put the .o file and the .d file. By default
716 # it is put in the same directory as the .c file. When targetdir is not
717 # empty, path names will be stripped from the file names so that all files
718 # are in that dir and not in subdirectories.
719 # - compiler (default target): compiler to use, target, kernel or host
720 %define rule_compile_cxx_multi mmake=TMP basenames=/A cppflags=$(CPPFLAGS) cxxflags=$(CXXFLAGS) dxxflags= \
721 targetdir= compiler=target srcdir=
723 %(mmake)_CXXABSBASENAMES := $(foreach %(mmake)_CXXBASE,%(basenames),$(if $(filter /%,$(%(mmake)_CXXBASE)),$(%(mmake)_CXXBASE),$(abspath $(SRCDIR)/$(CURDIR)/$(%(mmake)_CXXBASE))))
725 ifneq ($(%(mmake)_CXXABSBASENAMES),)
727 %(mmake)_CXXBASENAMES := $(basename $(%(mmake)_CXXABSBASENAMES))
729 # Identify the "real" c++ files from the passed in basenames
730 %(mmake)_MCXX_FILES := $(strip $(foreach %(mmake)_CXXBASE,$(%(mmake)_CXXABSBASENAMES), $(firstword $(wildcard $(foreach %(mmake)_EXT, $(AROS_CXXEXTS),$(addsuffix .$(%(mmake)_EXT),$(%(mmake)_CXXBASE)))))))
733 %(mmake)_MCXX_SRCWILDCARD := %
735 %(mmake)_MCXX_SRCWILDCARD := %(srcdir)/%
739 %(mmake)_CXXTARGETS := $(notdir $(%(mmake)_CXXBASENAMES:=.o))
740 %(mmake)_CXXDTARGETS := $(notdir $(%(mmake)_CXXBASENAMES:=.d))
741 %(mmake)_MCXX_WILDCARD := %
743 %(mmake)_CXXTARGETS := $(addprefix %(targetdir)/,$(notdir $(%(mmake)_CXXBASENAMES:=.o)))
744 %(mmake)_CXXDTARGETS := $(addprefix %(targetdir)/,$(notdir $(%(mmake)_CXXBASENAMES:=.d)))
745 %(mmake)_MCXX_WILDCARD := %(targetdir)/%
747 # Be sure that all source files are generated
748 $(%(mmake)_CXXTARGETS) $(%(mmake)_CXXDTARGETS) : | $(%(mmake)_MCXX_FILES)
751 # Adjust compiler flags to suit C++
752 %(mmake)_MCXX_CPPFLAGS := %(cppflags)
753 %(mmake)_CXXFLAGS := %(cxxflags)
755 %(mmake)_DXXFLAGS := %(cxxflags)
757 %(mmake)_DXXFLAGS := %(dxxflags)
760 ifeq ($(findstring %(compiler),host kernel target),)
761 $(error unknown compiler %(compiler))
763 ifeq (%(compiler),host)
764 %(mmake)_LINK ?= $(strip $(HOST_CXX) $(HOST_LDFLAGS))
765 %(mmake)_STRIP ?= $(HOST_STRIP)
766 %(mmake)_ASSEMBLER ?= $(strip $(HOST_CC) $(HOST_SYSROOT))
767 %(mmake)_CXXCMD:=$(HOST_CXX)
768 %(mmake)_MCXX_CPPFLAGS := $(strip $(HOST_MCXX_CPPFLAGS) $(%(mmake)_MCXX_CPPFLAGS) $(%(mmake)_MCXX_EXTRA_CPPFLAGS))
769 %(mmake)_CXXFLAGS := $(strip $(HOST_CXXFLAGS) $(%(mmake)_CXXFLAGS))
770 %(mmake)_DXXFLAGS := $(strip $(HOST_CXXFLAGS) $(%(mmake)_DXXFLAGS))
771 %(mmake)_CXXIQUOTE:=$(HOST_IQUOTE)
772 %(mmake)_CXXIQUOTE_END:=$(HOST_IQUOTE_END)
774 ifeq (%(compiler),target)
775 %(mmake)_LINK ?= $(strip $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
776 %(mmake)_STRIP ?= $(TARGET_STRIP)
777 %(mmake)_ASSEMBLER ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT))
778 %(mmake)_CXXCMD:=$(strip $(AROS_CXX) $(TARGET_SYSROOT))
779 %(mmake)_MCXX_CPPFLAGS := $(strip $(%(mmake)_MCXX_CPPFLAGS) $(%(mmake)_MCXX_EXTRA_CPPFLAGS))
780 %(mmake)_CXXFLAGS := $(strip $(%(mmake)_CXXFLAGS) $(SAFETY_CFLAGS))
781 %(mmake)_DXXFLAGS := $(%(mmake)_DXXFLAGS)
782 %(mmake)_CXXIQUOTE:=$(CFLAGS_IQUOTE)
783 %(mmake)_CXXIQUOTE_END:=$(CFLAGS_IQUOTE_END)
785 ifeq (%(compiler),kernel)
786 KERNEL_CXX ?= $(KERNEL_CC)
787 %(mmake)_LINK ?= $(strip $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
788 %(mmake)_STRIP ?= $(ECHO) >/dev/null
789 %(mmake)_ASSEMBLER ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
790 %(mmake)_CXXCMD:=$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))
791 %(mmake)_CXXFLAGS := $(strip $(KERNEL_MCXX_CPPFLAGS) $(%(mmake)_MCXX_CPPFLAGS) $(%(mmake)_MCXX_EXTRA_CPPFLAGS))
792 %(mmake)_CXXFLAGS := $(strip $(KERNEL_CXXFLAGS) $(%(mmake)_CXXFLAGS))
793 %(mmake)_DXXFLAGS := $(strip $(KERNEL_CXXFLAGS) $(%(mmake)_DXXFLAGS))
794 %(mmake)_CXXIQUOTE:=$(KERNEL_IQUOTE)
795 %(mmake)_CXXIQUOTE_END:=$(KERNEL_IQUOTE_END)
798 define cxx_multi_recipe_template
800 %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
803 %mkdepend_q cc=$(%(mmake)_CXXCMD) flags="$(strip $(%(mmake)_DXXFLAGS) $(%(mmake)_MCXX_CPPFLAGS))" from=$(2) to=$(1).d
806 $(foreach %(mmake)_CXXFILE,$(%(mmake)_MCXX_FILES),$(eval $(call cxx_multi_recipe_template,$(notdir $(basename $(%(mmake)_CXXFILE))),$(%(mmake)_CXXFILE))))
808 $(foreach %(mmake)_CXXFILE,$(%(mmake)_MCXX_FILES),$(eval $(call cxx_multi_recipe_template,$(addprefix %(targetdir)/,$(notdir $(basename $(%(mmake)_CXXFILE)))),$(%(mmake)_CXXFILE))))
814 #------------------------------------------------------------------------------
817 #------------------------------------------------------------------------------
818 # Generate a rule to compile multiple ObjC source files to an object file and
819 # generate the corresponding dependency files. The generated file will be put
820 # in the object directory without the directory part of the source file.
822 # - basenames: the basenames of the files to compile. The names may include
823 # relative or absolute path names. No wildcard is allowed
824 # - cflags (default $(CFLAGS)): the C flags to use for compilation
825 # - dflags: the flags used during creation of dependency file. If not specified
826 # the same value as cflags will be used
827 # - targetdir: the directory to put the .o file and the .d file. By default
828 # it is put in the same directory as the .m file. When targetdir is not
829 # empty, path names will be stripped from the file names so that all files
830 # are in that dir and not in subdirectories.
831 # - compiler (default target): compiler to use, target, kernel or host
832 %define rule_compile_objc_multi mmake=TMP basenames=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= \
833 targetdir= compiler=target srcdir=
835 ifneq (%(basenames),)
838 %(mmake)_MOBJC_SRCWILDCARD := %
840 %(mmake)_MOBJC_SRCWILDCARD := %(srcdir)/%
844 %(mmake)_MOBJC_TARGETS := $(addsuffix .o,%(basenames))
845 %(mmake)_MOBJC_DTARGETS := $(addsuffix .d,%(basenames))
846 %(mmake)_MOBJC_WILDCARD := %
848 %(mmake)_MOBJC_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,%(basenames)))
849 %(mmake)_MOBJC_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,%(basenames)))
850 %(mmake)_MOBJC_WILDCARD := %(targetdir)/%
852 # Be sure that all .m files are generated
853 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : | $(addsuffix .m,%(basenames))
855 # Be sure that all .m files are found
856 %(mmake)_MOBJC_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
857 %(mmake)_MOBJC_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
858 %(mmake)_MOBJC_DIRS := $(foreach dir, $(%(mmake)_MOBJC_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(%(mmake)_MOBJC_SRCDIR)/$(CURDIR)/$(dir)))
859 ifneq ($(%(mmake)_MOBJC_DIRS),)
860 %(mmake)_MOBJC_DIRS := $(shell echo $(%(mmake)_MOBJC_DIRS) | sed 's/\(.\):\//\/\1\//g')
861 vpath %.m $(%(mmake)_MOBJC_DIRS)
865 # Define the use of cross compiler
866 ifeq ($(TARGET_OBJC),)
867 %(mmake)_CC := $(TARGET_CC)
869 %(mmake)_CC := $(TARGET_OBJC)
872 # Adjust compiler flags to suit ObjC
873 %(mmake)_MOBJC_CPPFLAGS := %(cppflags)
874 %(mmake)_OBJCFLAGS := %(cflags)
875 %(mmake)_OBJCFLAGS := $(%(mmake)_OBJCFLAGS) -isystem $(AROS_DEVELOPER)/include
876 %(mmake)_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(%(mmake)_OBJCFLAGS)))
878 %(mmake)_OBJCDFLAGS := %(cflags)
880 %(mmake)_OBJCDFLAGS := %(dflags)
883 ifeq ($(findstring %(compiler),host kernel target),)
884 $(error unknown compiler %(compiler))
886 ifeq (%(compiler),target)
887 %(mmake)_LINK ?= $(strip $(%(mmake)_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
888 %(mmake)_STRIP ?= $(TARGET_STRIP)
889 %(mmake)_ASSEMBLER ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT))
890 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : CMD:=$(strip $(%(mmake)_CC) $(TARGET_SYSROOT))
891 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_MOBJC_CPPFLAGS:=$(strip $(%(mmake)_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_EXTRA_CPPFLAGS))
892 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCFLAGS:=$(strip $(%(mmake)_OBJCFLAGS) $(SAFETY_CFLAGS))
893 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCDFLAGS:=$(%(mmake)_OBJCDFLAGS)
894 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
895 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
897 ifeq (%(compiler),host)
898 %(mmake)_LINK ?= $(strip $(HOST_OBJC) $(HOST_LDFLAGS))
899 %(mmake)_STRIP ?= $(HOST_STRIP)
900 %(mmake)_ASSEMBLER ?= $(strip $(HOST_CC) $(HOST_SYSROOT))
901 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : CMD:=$(HOST_OBJC)
902 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_MOBJC_CPPFLAGS:=$(strip $(HOST_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_EXTRA_CPPFLAGS))
903 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCFLAGS))
904 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCDFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCDFLAGS))
905 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
906 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
908 ifeq (%(compiler),kernel)
909 KERNEL_OBJC ?= $(KERNEL_CC)
910 %(mmake)_LINK ?= $(strip $(KERNEL_OBJC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
911 %(mmake)_STRIP ?= $(ECHO) >/dev/null
912 %(mmake)_ASSEMBLER ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
913 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : CMD:=$(strip $(KERNEL_OBJC) $(KERNEL_SYSROOT))
914 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_MOBJC_CPPFLAGS:=$(strip $(KERNEL_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_EXTRA_CPPFLAGS))
915 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCFLAGS))
916 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCDFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCDFLAGS))
917 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
918 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
921 $(%(mmake)_MOBJC_TARGETS) : CPPFLAGS := $(%(mmake)_MOBJC_CPPFLAGS)
922 $(%(mmake)_MOBJC_TARGETS) : CFLAGS := $(%(mmake)_OBJCFLAGS)
923 $(%(mmake)_MOBJC_TARGETS) : $(%(mmake)_MOBJC_WILDCARD).o : $(%(mmake)_MOBJC_SRCWILDCARD).m
924 %compile_q cmd=$(CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
926 $(%(mmake)_MOBJC_DTARGETS) : $(%(mmake)_MOBJC_WILDCARD).d : $(%(mmake)_MOBJC_SRCWILDCARD).m
927 %mkdepend_q cc=$(CMD) flags="$(strip $(%(mmake)_OBJCDFLAGS) $(%(mmake)_MOBJC_CPPFLAGS))"
932 #------------------------------------------------------------------------------
935 #------------------------------------------------------------------------------
936 # Make an alias from one arch specific build to another arch.
938 # - mainmmake: the mmake of the module in the main tree
939 # - arch: the current arch
940 # - alias: the alias to which this should point
941 %define rule_archalias mainmmake=\A arch=\A alias=\A
943 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
945 #------------------------------------------------------------------------------
948 #------------------------------------------------------------------------------
949 # Generate a rule to assemble a source file to an object file. Basename may
950 # contain a directory part, then the source file has to be in that directory.
951 # The generated file will be put in the object directory without the directory.
953 # - basename: the basename of the file to compile. Use % for a wildcard rule
954 # - flags (default $(AFLAGS)): the asm flags to use for assembling
955 # - targetdir: the directory to put the .o file in. By default it is put in the
956 # same directory as the .s file
957 %define rule_assemble basename=/A cppflags=$(CPPFLAGS) aflags=$(AFLAGS) targetdir=
960 %(basename).o : CPPFLAGS := %(cppflags)
961 %(basename).o : AFLAGS := %(aflags)
962 %(basename).o : %(basename).s
964 %(basename).o : %(basename).S
968 %(targetdir)/$(notdir %(basename)).o : CPPFLAGS := %(cppflags)
969 %(targetdir)/$(notdir %(basename)).o : AFLAGS := %(aflags)
970 %(targetdir)/$(notdir %(basename)).o : %(basename).s
972 %(targetdir)/$(notdir %(basename)).o : %(basename).S
977 #------------------------------------------------------------------------------
980 #------------------------------------------------------------------------------
981 # Generate a rule to assemble multiple source files to an object file. The
982 # generated file will be put in the object directory with the directory part
983 # of the source file stripped off.
985 # - basenames: the basenames of the files to compile. The names may include
986 # relative or absolute path names. No wildcard is allowed
987 # - aflags (default $(AFLAGS)): the flags to use for assembly
988 # - targetdir: the directory to put the .o file and the .d file. By default
989 # it is put in the same directory as the .c file. When targetdir is not
990 # empty, path names will be stripped from the file names so that all files
991 # are in that dir and not in subdirectories.
992 %define rule_assemble_multi mmake=TMP cmd="$(strip $(CC) $(TARGET_SYSROOT))" basenames=/A cppflags=$(CPPFLAGS) aflags=$(AFLAGS) targetdir= suffix=.s
995 %(mmake)-MA_TARGETS := $(addsuffix .o,%(basenames))
996 %(mmake)-MA_WILDCARD := %
998 %(mmake)-MA_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
999 %(mmake)-MA_WILDCARD := %(targetdir)/%
1001 # Be sure that all .s files are generated
1002 $(%(mmake)-MA_TARGETS) : | $(addsuffix %(suffix),%(basenames))
1004 # Be sure that all .c files are found
1005 %(mmake)-MA_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
1006 %(mmake)-MA_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
1007 %(mmake)-MA_DIRS := $(foreach dir, $(%(mmake)-MA_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(%(mmake)-MA_SRCDIR)/$(CURDIR)/$(dir)))
1008 ifneq ($(%(mmake)-MA_DIRS),)
1009 %(mmake)-MA_DIRS := $(shell echo $(%(mmake)-MA_DIRS) | sed 's/\(.\):\//\/\1\//g')
1010 vpath %%(suffix) $(%(mmake)-MA_DIRS)
1015 %(mmake)-MA_ASSEMBLER ?= %(cmd)
1017 $(%(mmake)-MA_TARGETS) : %(mmake)-MA_CMD:= $(%(mmake)-MA_ASSEMBLER)
1019 $(%(mmake)-MA_TARGETS) : CPPFLAGS := %(cppflags)
1020 $(%(mmake)-MA_TARGETS) : AFLAGS := %(aflags)
1021 $(%(mmake)-MA_TARGETS) : $(%(mmake)-MA_WILDCARD).o : %%(suffix)
1022 %assemble_q cmd=$(%(mmake)-MA_CMD)
1024 #------------------------------------------------------------------------------
1027 #------------------------------------------------------------------------------
1028 # Link %(objs) to %(prog) using the libraries in %(uselibs)
1029 %define rule_link_prog mmake=TMP prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
1030 usehostlibs= usestartup=yes detach=no nix=no cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" strip=$(TARGET_STRIP) objdir=$(GENDIR)/$(CURDIR) coverageinstr=$(TARGET_COVERAGEINSTR)
1032 %(mmake)-link_EXTRA_LDFLAGS :=
1033 %(mmake)-link_EXTRA_LIBS :=
1035 %(mmake)-link_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
1037 ifeq (%(usestartup),no)
1038 %(mmake)-link_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
1040 ifeq (%(detach),yes)
1041 %(mmake)-link_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
1044 # Make a list of the lib files this program depends on.
1045 # In LDFLAGS remove white space between -L and directory
1046 %(mmake)-link_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
1047 # Filter out only the libdirs and remove -L
1048 %(mmake)-link_DIRS := $(patsubst -L%,%,$(filter -L%,$(%(mmake)-link_DIRS)))
1050 %(mmake)-link_DIRS := $(subst //,/,$(addsuffix /,$(%(mmake)-link_DIRS)))
1051 # Add normal linklib path
1052 %(mmake)-link_DIRS += $(AROS_LIB)/
1053 # add lib and .a to static linklib names
1054 %(mmake)-link_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(%(mmake)-link_EXTRA_LIBS)))
1055 ifeq (%(usestartup),yes)
1056 %(mmake)-link_LIBS += startup.o
1058 ifeq (%(detach),yes)
1059 %(mmake)-link_LIBS += detach.o
1061 # search for the linklibs in the given path, ignore ones not found
1062 %(mmake)-link_DEPLIBS := $(foreach lib,$(%(mmake)-link_LIBS), \
1063 $(firstword $(wildcard $(addsuffix $(lib),$(%(mmake)-link_DIRS)))) \
1066 %(prog) : OBJDIR := %(objdir)
1067 %(prog) : OBJS := %(objs)
1068 %(prog) : LDFLAGS := $(strip %(ldflags) $(%(mmake)-link_EXTRA_LDFLAGS))
1069 %(prog) : LIBS := $(addprefix -l,%(uselibs) $(%(mmake)-link_EXTRA_LIBS) %(usehostlibs))
1070 %(prog) : %(objs) $(%(mmake)-link_DEPLIBS)
1071 %link_q cmd="%(cmd)" strip="%(strip)" from=$(OBJS) opt=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR) coverageinstr=%(coverageinstr)
1073 #------------------------------------------------------------------------------
1076 #------------------------------------------------------------------------------
1077 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
1078 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
1079 %define rule_link_progs mmake=TMP progs=/A targetdir=$(AROSDIR)/$(CURDIR) nix=%(nix) \
1080 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
1081 usestartup=yes detach=no cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" strip=$(TARGET_STRIP) coverageinstr=$(TARGET_COVERAGEINSTR)
1083 %(mmake)-link_EXTRA_LDFLAGS :=
1084 %(mmake)-link_EXTRA_LIBS :=
1086 %(mmake)-link_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
1088 ifeq (%(usestartup),no)
1089 %(mmake)-link_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
1091 ifeq (%(detach),yes)
1092 %(mmake)-link_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
1095 # Make a list of the lib files the programs depend on.
1096 # In LDFLAGS remove white space between -L and directory
1097 %(mmake)-link_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
1098 # Filter out only the libdirs and remove -L
1099 %(mmake)-link_DIRS := $(patsubst -L%,%,$(filter -L%,$(%(mmake)-link_DIRS)))
1101 %(mmake)-link_DIRS := $(subst //,/,$(addsuffix /,$(%(mmake)-link_DIRS)))
1102 # Add normal linklib path
1103 %(mmake)-link_DIRS += $(AROS_LIB)/
1104 # add lib and .a to static linklib names
1105 %(mmake)-link_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(%(mmake)-link_EXTRA_LIBS)))
1106 # search for the linklibs in the given path, ignore ones not found
1107 %(mmake)-link_DEPLIBS := $(foreach lib,$(%(mmake)-link_LIBS), \
1108 $(firstword $(wildcard $(addsuffix $(lib),$(%(mmake)-link_DIRS)))) \
1110 %(mmake)-link_PROGS := $(addprefix %(targetdir)/,%(progs))
1112 $(%(mmake)-link_PROGS) : OBJDIR := %(objdir)
1113 $(%(mmake)-link_PROGS) : LDFLAGS := $(strip %(ldflags) $(%(mmake)-link_EXTRA_LDFLAGS))
1114 $(%(mmake)-link_PROGS) : LIBS := $(addprefix -l,%(uselibs) $(%(mmake)-link_EXTRA_LIBS) %(usehostlibs))
1115 $(%(mmake)-link_PROGS) : %(targetdir)/% : %(objdir)/%.o $(%(mmake)-link_DEPLIBS)
1116 %link_q cmd="%(cmd)" strip="%(strip)" from=$< opt=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR) coverageinstr=%(coverageinstr)
1118 #------------------------------------------------------------------------------
1121 #------------------------------------------------------------------------------
1122 # Link the %(objs) to the library %(libdir)/lib%(libname).a
1123 %define rule_link_linklib mmake=TMP libname=/A objs=/A libdir=$(AROS_LIB) linker=target
1125 ifeq (%(linker),target)
1126 %(libdir)/lib%(libname).a : %(mmake)_AR:=$(AR)
1127 %(libdir)/lib%(libname).a : %(mmake)_RANLIB:=$(RANLIB)
1129 ifeq (%(linker),host)
1130 %(libdir)/lib%(libname).a : %(mmake)_AR:=$(HOST_AR)
1131 %(libdir)/lib%(libname).a : %(mmake)_RANLIB:=$(HOST_RANLIB)
1133 ifeq (%(linker),kernel)
1134 %(libdir)/lib%(libname).a : %(mmake)_AR:=$(KERNEL_AR)
1135 %(libdir)/lib%(libname).a : %(mmake)_RANLIB:=$(KERNEL_RANLIB)
1138 %(libdir)/lib%(libname).a : %(objs)
1139 %mklib_q from=$^ ar=$(%(mmake)_AR) ranlib=$(%(mmake)_RANLIB)
1141 #------------------------------------------------------------------------------
1143 #------------------------------------------------------------------------------
1144 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
1145 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
1146 %define rule_linkmodule mmake=TMP module=/A objs=/A endobj=/A err=/A objdir=$(OBJDIR) \
1147 cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" ldflags=$(LDFLAGS) uselibs= usehostlibs=
1149 %(mmake)_LDFLAGS := %(ldflags)
1150 # Make a list of the lib files the programs depend on.
1151 # In LDFLAGS remove white space between -L and directory
1152 %(mmake)_DIRS := $(subst -L ,-L,$(strip $(%(mmake)_LDFLAGS)))
1153 # Filter out only the libdirs and remove -L
1154 %(mmake)_DIRS := $(patsubst -L%,%,$(filter -L%,$(%(mmake)_DIRS)))
1156 %(mmake)_DIRS := $(subst //,/,$(addsuffix /,$(%(mmake)_DIRS)))
1157 # Add normal linklib path
1158 %(mmake)_DIRS += $(AROS_LIB)/
1159 # add lib and .a to static linklib names
1160 %(mmake)_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
1161 # search for the linklibs in the given path, ignore ones not found
1162 %(mmake)_DEPLIBS := $(foreach lib,$(%(mmake)_LIBS), \
1163 $(firstword $(wildcard $(addsuffix $(lib),$(%(mmake)_DIRS)))) \
1166 %(module) : LIB_NAMES := %(uselibs)
1167 %(module) : OBJS := %(objs)
1168 %(module) : ENDTAG := %(endobj)
1169 %(module) : ERR := %(err)
1170 %(module) : OBJDIR := %(objdir)
1171 %(module) : LDFLAGS := $(%(mmake)_LDFLAGS)
1172 ifeq (%(usehostlibs),)
1173 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES))
1175 # Warning: the -L/usr/lib here can result in modules
1176 # linking against host libs instead of AROS libs (e.g stdc++) !!
1177 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES)) \
1178 -L/usr/lib $(addprefix -l,%(usehostlibs))
1180 %(module) : %(objs) %(endobj) $(%(mmake)_DEPLIBS) $(USER_DEPLIBS)
1181 %link_module_q cmd="%(cmd)" err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS) objdir=$(OBJDIR) ldflags=$(LDFLAGS)
1184 #------------------------------------------------------------------------------
1187 #------------------------------------------------------------------------------
1188 # Generate the libdefs.h include file for a module.
1189 %define rule_genmodule_genlibdefs mmake=TMP modname=/A version= flavour= modtype=/A modsuffix= conffile= targetdir=
1193 %(mmake)_OPTS += -f %(flavour)
1194 %(mmake)_MODNAME := %(modname)_%(flavour)
1196 %(mmake)_MODNAME := %(modname)
1198 %(mmake)_TARGET := $(%(mmake)_MODNAME)_libdefs.h
1199 %(mmake)_DEPS := $(GENMODULE)
1200 ifneq (%(conffile),)
1201 ifeq ($(dir %(conffile)),./)
1202 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1203 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1205 %(mmake)_OPTS += -c %(conffile)
1206 %(mmake)_DEPS += %(conffile)
1209 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1210 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1212 ifneq (%(modsuffix),)
1213 %(mmake)_OPTS += -s %(modsuffix)
1215 ifneq (%(targetdir),)
1216 %(mmake)_OPTS += -d %(targetdir)
1217 %(mmake)_TARGET := %(targetdir)/$(%(mmake)_TARGET)
1220 %(mmake)_OPTS += -v %(version)
1223 $(%(mmake)_TARGET) : OPTS := $(%(mmake)_OPTS)
1224 $(%(mmake)_TARGET) : MODNAME := %(modname)
1225 $(%(mmake)_TARGET) : MODTYPE := %(modtype)
1226 $(%(mmake)_TARGET) : $(%(mmake)_DEPS)
1227 $(Q)$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1228 $(Q)$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
1230 #------------------------------------------------------------------------------
1232 #------------------------------------------------------------------------------
1233 # Generate the _lib.fd file for a module.
1234 %define rule_genmodule_fd mmake=TMP modname=/A modtype=/A modsuffix= conffile= targetdir=
1236 %(mmake)_TARGET := %(modname)_lib.fd
1237 %(mmake)_DEPS := $(GENMODULE)
1239 ifneq (%(conffile),)
1240 ifeq ($(dir %(conffile)),./)
1241 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1242 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1244 %(mmake)_OPTS += -c %(conffile)
1245 %(mmake)_DEPS += %(conffile)
1248 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1249 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1251 ifneq (%(modsuffix),)
1252 %(mmake)_OPTS += -s %(modsuffix)
1254 ifneq (%(targetdir),)
1255 %(mmake)_OPTS += -d %(targetdir)
1256 %(mmake)_TARGET := %(targetdir)/$(%(mmake)_TARGET)
1259 $(%(mmake)_TARGET) : OPTS := $(%(mmake)_OPTS)
1260 $(%(mmake)_TARGET) : MODNAME := %(modname)
1261 $(%(mmake)_TARGET) : MODTYPE := %(modtype)
1262 $(%(mmake)_TARGET) : $(%(mmake)_DEPS)
1263 $(Q)$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1264 $(Q)$(GENMODULE) $(OPTS) writefd $(MODNAME) $(MODTYPE)
1266 #------------------------------------------------------------------------------
1268 #------------------------------------------------------------------------------
1269 # Generate a Makefile.%(modname)%(modtype) with the genmodule program and include this
1270 # generated file in this Makefile
1271 %define rule_genmodule_makefile mmake=TMP modname=/A flavour= modtype=/A modsuffix= conffile= \
1276 %(mmake)_OPTS += -f %(flavour)
1277 %(mmake)_MODNAME := %(modname)_%(flavour)
1279 %(mmake)_MODNAME := %(modname)
1281 %(mmake)_TARGET := Makefile.$(%(mmake)_MODNAME)%(modtype)
1282 %(mmake)_DEPS := $(GENMODULE)
1283 ifneq (%(conffile),)
1284 ifeq ($(dir %(conffile)),./)
1285 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1286 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1288 %(mmake)_OPTS += -c %(conffile)
1289 %(mmake)_DEPS += %(conffile)
1292 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1293 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1295 ifneq (%(modsuffix),)
1296 %(mmake)_OPTS += -s %(modsuffix)
1298 ifneq (%(targetdir),)
1299 %(mmake)_OPTS += -d %(targetdir)
1300 %(mmake)_TARGET := %(targetdir)/$(%(mmake)_TARGET)
1303 $(%(mmake)_TARGET) : OPTS := $(%(mmake)_OPTS)
1304 $(%(mmake)_TARGET) : MODNAME := %(modname)
1305 $(%(mmake)_TARGET) : MODTYPE := %(modtype)
1306 $(%(mmake)_TARGET) : $(%(mmake)_DEPS)
1307 $(Q)$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
1309 #------------------------------------------------------------------------------
1312 #------------------------------------------------------------------------------
1313 # Generate the support files for compiling a module. This includes include
1314 # files and source files. This rule has to be preceeded by
1315 # %rule_genmodule_makefile
1316 %define rule_genmodule_files mmake=TMP modname=/A flavour= modtype=/A modsuffix= targetdir= stubdir= \
1321 %(mmake)_OPTS += -f %(flavour)
1322 %(mmake)_MODNAME := %(modname)_%(flavour)
1324 %(mmake)_MODNAME := %(modname)
1326 %(mmake)_GENTARGETS := $($(%(mmake)_MODNAME)_STARTFILES) $($(%(mmake)_MODNAME)_ENDFILES)
1327 %(mmake)_STUBTARGETS := $($(%(mmake)_MODNAME)_LINKLIBFILES) $($(%(mmake)_MODNAME)_RELLINKLIBFILES)
1328 %(mmake)_GENTARGETS := $(addsuffix .c,$(%(mmake)_GENTARGETS))
1329 %(mmake)_STUBTARGETS := $(addsuffix .c,$(%(mmake)_STUBTARGETS)) \
1330 $(addsuffix .S, $($(%(mmake)_MODNAME)_LINKLIBAFILES) $($(%(mmake)_MODNAME)_RELLINKLIBAFILES))
1332 %(mmake)_DEPS := $(GENMODULE)
1333 ifneq (%(conffile),)
1334 ifeq ($(dir %(conffile)),./)
1335 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1336 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1338 %(mmake)_OPTS += -c %(conffile)
1339 %(mmake)_DEPS += %(conffile)
1342 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1343 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1345 ifneq (%(modsuffix),)
1346 %(mmake)_OPTS += -s %(modsuffix)
1348 ifneq (%(targetdir),)
1349 %(mmake)_OPTS += -d %(targetdir)
1350 %(mmake)_TARGETDIR := $(shell echo %(targetdir) | sed 's/^\(.\):\//\/\1\//')
1351 %(mmake)_GENTARGETS := $(addprefix $(%(mmake)_TARGETDIR)/,$(%(mmake)_GENTARGETS))
1352 %(mmake)_GENFILEFLAG=$(%(mmake)_TARGETDIR)/.%(modname).%(modtype)-genfiles
1354 %(mmake)_GENFILEFLAG=$(GENDIR)/$(CURDIR)/.%(modname).%(modtype)-genfiles
1357 %(mmake)_OPTS += -l %(stubdir)
1358 %(mmake)_STUBTARGETDIR := $(shell echo %(stubdir) | sed 's/^\(.\):\//\/\1\//')
1359 %(mmake)_STUBTARGETS := $(addprefix $(%(mmake)_STUBTARGETDIR)/,$(%(mmake)_STUBTARGETS))
1360 %(mmake)_TARGETDIRS += %(stubdir)
1362 ifneq (%(targetdir),)
1363 %(mmake)_STUBTARGETS := $(addprefix $(%(mmake)_TARGETDIR)/,$(%(mmake)_STUBTARGETS))
1367 %(mmake)_TARGETS := $(%(mmake)_GENTARGETS) $(%(mmake)_STUBTARGETS)
1368 ifneq ($(%(mmake)_TARGETDIRS),)
1369 $(%(mmake)_TARGETS) : | $(%(mmake)_TARGETDIRS)
1372 $(%(mmake)_TARGETS) : $(%(mmake)_DEPS) $(%(mmake)_GENFILEFLAG)
1374 $(%(mmake)_GENFILEFLAG) : OPTS := $(%(mmake)_OPTS)
1375 $(%(mmake)_GENFILEFLAG) : MODNAME := %(modname)
1376 $(%(mmake)_GENFILEFLAG) : MODTYPE := %(modtype)
1377 $(%(mmake)_GENFILEFLAG) : $(%(mmake)_DEPS)
1378 $(Q)$(ECHO) "Generating support files for module $(MODNAME$(BDID))"
1379 $(Q)$(IF) $(TEST) "%(conffile)" = "lib.conf" && $(TEST) -f lib.conf; then \
1380 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
1382 $(Q)$(IF) $(TEST) -f libdefs.h; then \
1383 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
1385 $(Q)$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
1388 #------------------------------------------------------------------------------
1391 #------------------------------------------------------------------------------
1392 # Generate the support files for compiling a module. This includes include
1393 # files and source files.
1394 %define rule_genmodule_includes mmake=TMP modname=/A flavour= modtype=/A modsuffix= \
1395 targetdir= conffile=
1398 %(mmake)_MODNAME := %(modname)_%(flavour)
1400 %(mmake)_MODNAME := %(modname)
1403 ifneq ($($(%(mmake)_MODNAME)_INCLUDES),)
1405 %(mmake)_TARGETS := $($(%(mmake)_MODNAME)_INCLUDES)
1407 %(mmake)_DEPS := $(GENMODULE)
1410 ifneq (%(conffile),)
1411 ifeq ($(dir %(conffile)),./)
1412 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1413 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1415 %(mmake)_OPTS += -c %(conffile)
1416 %(mmake)_DEPS += %(conffile)
1419 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1420 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1422 ifneq (%(modsuffix),)
1423 %(mmake)_OPTS += -s %(modsuffix)
1425 ifneq (%(targetdir),)
1426 %(mmake)_OPTS += -d %(targetdir)
1427 %(mmake)_TARGETS := $(addprefix %(targetdir)/,$(%(mmake)_TARGETS))
1428 %(mmake)_GENINCFLAG=%(targetdir)/.%(modname).%(modtype)-includes
1430 %(mmake)_GENINCFLAG=$(GENDIR)/$(CURDIR)/.%(modname).%(modtype)-includes
1433 $(%(mmake)_TARGETS) : $(%(mmake)_DEPS) $(%(mmake)_GENINCFLAG)
1435 $(%(mmake)_GENINCFLAG) : OPTS := $(%(mmake)_OPTS)
1436 $(%(mmake)_GENINCFLAG) : MODNAME := %(modname)
1437 $(%(mmake)_GENINCFLAG) : MODTYPE := %(modtype)
1438 $(%(mmake)_GENINCFLAG) : $(%(mmake)_DEPS)
1439 $(Q)$(ECHO) "Generating $(MODNAME).$(MODTYPE) includes"
1440 $(Q)$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
1444 #------------------------------------------------------------------------------
1446 #------------------------------------------------------------------------------
1447 # Link %(objs) to binary blob in %(file) using %(name) as name of embedded binary object
1448 # 'start' is an optional starting address
1449 # 'ldflags' is optional additional flags for the linker
1450 %define rule_link_binary mmake=BD file=/A name=/A objs= files= start=0 ldflags=
1452 %(mmake)_OUTDIR := $(dir %(file))
1453 # This trick removes the trailing '/', otherwise findstring below fails, causing a warning
1454 %(mmake)_OUTDIR := $(subst /*,,$(addsuffix *,$(%(mmake)_OUTDIR)))
1455 %(mmake)_TMPDIR := $(GENDIR)/$(CURDIR)
1456 %(mmake)_OBJS := $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir %(files))))
1457 %(mmake)_DEPS := $(addsuffix .d,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir %(files))))
1458 %(mmake)_OBJS += %(objs)
1460 %rule_compile_multi basenames="%(files)" targetdir=$(%(mmake)_OBJDIR)
1462 %(file) : $(%(mmake)_OBJS) $(%(mmake)_DEPS)
1463 $(Q)$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)..."
1464 $(Q)$(KERNEL_LD) %(ldflags) --entry=%(start) --oformat=binary -Ttext=%(start) -o $(%(mmake)_TMPDIR)/%(name) $(%(mmake)_OBJS)
1465 $(Q)cd $(%(mmake)_TMPDIR) && $(AROS_LD) %(ldflags) -r --format binary %(name) -o $@
1467 ifeq ($(findstring $(%(mmake)_OUTDIR),$(GLOB_MKDIRS)),)
1468 %rule_makedirs dirs="$(%(mmake)_OUTDIR)" setuptarget=%(file)
1473 #------------------------------------------------------------------------------
1474 # Common rules for all makefiles
1476 # Delete generated makefiles
1479 $(Q)$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
1481 include $(SRCDIR)/config/make.tail
1483 BDID := $(BDTARGETID)
1485 #------------------------------------------------------------------------------
1488 #############################################################################
1489 #############################################################################
1491 ## Here are the mmakefile build macros. These are macros that takes care ##
1492 ## of everything to go from the sources to the generated target. Also all ##
1493 ## intermediate files and directories that are needed are created by these ##
1496 #############################################################################
1497 #############################################################################
1499 #------------------------------------------------------------------------------
1501 %define build_prog mmake=/A progname=/A files= cxxfiles= \
1503 asmfiles= objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1504 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= ldflags=$(LDFLAGS) \
1505 aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
1506 includedir= libdir= \
1507 compiler=target linker= \
1508 coverageinstr=$(TARGET_COVERAGEINSTR) funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO)
1512 %(mmake)_PROGNAME := %(progname)
1513 %(mmake)_OBJDIR := %(objdir)
1514 %(mmake)_TARGETDIR := %(targetdir)
1515 %(mmake)_LINKER := %(linker)
1516 %(mmake)_LIBS := %(uselibs)
1517 # If not supplied, linker is equal to compiler
1518 ifeq ($(%(mmake)_LINKER),)
1519 %(mmake)_LINKER := %(compiler)
1522 ifneq ("$(strip %(files) %(cxxfiles) %(objcfiles) %(asmfiles))","")
1523 %(mmake)_FILES := %(files)
1524 %(mmake)_OBJCFILES := %(objcfiles)
1525 %(mmake)_ASMFILES := %(asmfiles)
1526 %(mmake)_CXXFILES := %(cxxfiles)
1528 %(mmake)_FILES := $(%(mmake)_PROGNAME)
1529 %(mmake)_OBJCFILES :=
1530 %(mmake)_ASMFILES :=
1531 %(mmake)_CXXFILES :=
1534 %(mmake)_ARCHOBJS := $(wildcard $(%(mmake)_OBJDIR)/arch/*.o)
1535 %(mmake)_ARCHFILES := $(basename $(notdir $(%(mmake)_ARCHOBJS)))
1536 %(mmake)_C_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_FILES))
1537 %(mmake)_CXX_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_CXXFILES))
1538 %(mmake)_OBJC_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_OBJCFILES))
1540 TMP_FILES := $(%(mmake)_C_NARCHFILES) $(%(mmake)_CXX_NARCHFILES) $(%(mmake)_ASMFILES) $(%(mmake)_OBJC_NARCHFILES)
1541 %(mmake)_OBJS := $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir $(TMP_FILES))))
1542 %(mmake)_DEPS := $(addsuffix .d,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir $(TMP_FILES))))
1544 %(mmake)_CPPFLAGS := %(cppflags)
1545 ifneq (%(includedir),)
1546 %(mmake)_CPPFLAGS += -I%(includedir)
1548 %(mmake)_CFLAGS := %(cflags)
1549 %(mmake)_CXXFLAGS := %(cxxflags)
1550 %(mmake)_COVERAGE := no
1551 ifeq (%(compiler),target)
1552 ifeq (%(usestartup),yes)
1553 ifeq (%(coverageinstr),yes)
1554 %(mmake)_COVERAGE := yes
1555 %(mmake)_COVERAGEFLAGS ?= $(COVERAGEINSTR_FLAGS)
1556 %(mmake)_COVERAGELIBS ?= $(COVERAGEINSTR_LIBS)
1557 %(mmake)_CFLAGS := $(strip $(%(mmake)_COVERAGEFLAGS) $(%(mmake)_CFLAGS))
1558 %(mmake)_CXXFLAGS := $(strip $(%(mmake)_COVERAGEFLAGS) $(%(mmake)_CXXFLAGS))
1559 %(mmake)_LIBS += $(%(mmake)_COVERAGELIBS)
1561 ifeq (%(funcinstr),yes)
1562 %(mmake)_FUNCINSTR := yes
1563 %(mmake)_INSTRFUNCFLAGS ?= $(FUNCINSTR_FLAGS)
1564 %(mmake)_INSTRFUNCLIBS ?= $(FUNCINSTR_LIBS)
1565 %(mmake)_CFLAGS := $(strip $(%(mmake)_INSTRFUNCFLAGS) $(%(mmake)_CFLAGS))
1566 %(mmake)_CXXFLAGS := $(strip $(%(mmake)_INSTRFUNCFLAGS) $(%(mmake)_CXXFLAGS))
1567 %(mmake)_LIBS += $(%(mmake)_INSTRFUNCLIBS)
1571 %(mmake)_CFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(%(mmake)_CFLAGS))
1572 %(mmake)_CXXFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(%(mmake)_CXXFLAGS))
1575 %(mmake)_AFLAGS := %(aflags)
1577 %(mmake)_DFLAGS := %(dflags)
1579 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
1581 ifneq (%(dxxflags),)
1582 %(mmake)_DXXFLAGS := %(dxxflags)
1584 %(mmake)_DXXFLAGS := $(%(mmake)_CXXFLAGS)
1586 %(mmake)_LDFLAGS := %(ldflags)
1588 %(mmake)_LDFLAGS += -L%(libdir)
1592 %(mmake)-quick : %(mmake)
1594 #MM %(mmake) : includes-generate-deps core-linklibs
1595 %(mmake) : $(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME)
1597 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick %(mmake)-gz-quick),)
1598 %rule_compile_cxx_multi mmake=%(mmake) \
1599 basenames=$(%(mmake)_CXX_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
1600 cppflags=$(%(mmake)_CPPFLAGS) cxxflags=$(%(mmake)_CXXFLAGS) dxxflags=$(%(mmake)_DXXFLAGS) \
1601 compiler="%(compiler)"
1602 %rule_compile_objc_multi mmake=%(mmake) \
1603 basenames=$(%(mmake)_OBJC_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
1604 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
1605 compiler="%(compiler)"
1606 %rule_compile_multi mmake=%(mmake) \
1607 basenames=$(%(mmake)_C_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
1608 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
1609 compiler="%(compiler)"
1610 %rule_assemble_multi mmake=%(mmake) \
1611 cmd=$(%(mmake)_ASSEMBLER) basenames=$(%(mmake)_ASMFILES) targetdir=$(%(mmake)_OBJDIR) \
1612 cppflags=$(%(mmake)_CPPFLAGS) aflags=$(%(mmake)_AFLAGS)
1614 %rule_link_prog mmake=%(mmake) prog=$(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME) \
1615 objs="$(%(mmake)_OBJS) $(%(mmake)_ARCHOBJS) $(USER_OBJS)" ldflags=$(%(mmake)_LDFLAGS) \
1616 uselibs="$(%(mmake)_LIBS)" usehostlibs="%(usehostlibs)" \
1617 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)" \
1618 cmd=$(%(mmake)_LINK) strip=$(%(mmake)_STRIP) objdir=$(%(mmake)_OBJDIR) coverageinstr=$(%(mmake)_COVERAGE)
1622 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(%(mmake)_DEPS)
1624 %rule_makedirs dirs="$(%(mmake)_OBJDIR) $(%(mmake)_TARGETDIR)" setuptarget="$(%(mmake)_OBJS) $(%(mmake)_DEPS) $(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME)"
1626 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME) $(%(mmake)_DEPS)
1629 $(Q)$(ECHO) "Cleaning up for metatarget %(mmake)"
1633 #------------------------------------------------------------------------------
1636 #------------------------------------------------------------------------------
1637 # Build programs, for every C file an executable will be built with the same
1638 # name as the C file
1639 %define build_progs mmake=/A files=/A nix=no \
1640 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1641 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= ldflags=$(LDFLAGS) \
1642 includedir= libdir= \
1644 uselibs= usehostlibs= usestartup=yes detach=no \
1645 coverageinstr=$(TARGET_COVERAGEINSTR) funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO)
1649 %(mmake)_OBJDIR := %(objdir)
1650 %(mmake)_TARGETDIR := %(targetdir)
1651 %(mmake)_LIBS := %(uselibs)
1653 %(mmake)_FILES := %(files)
1654 %(mmake)_OBJS := $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/,$(%(mmake)_FILES)))
1655 %(mmake)_DEPS := $(addsuffix .d,$(addprefix $(%(mmake)_OBJDIR)/,$(%(mmake)_FILES)))
1656 %(mmake)_EXES := $(addprefix $(%(mmake)_TARGETDIR)/,$(%(mmake)_FILES))
1658 %(mmake)_CPPFLAGS := %(cppflags)
1659 ifneq (%(includedir),)
1660 %(mmake)_CPPFLAGS += -I%(includedir)
1662 %(mmake)_CFLAGS := %(cflags)
1663 %(mmake)_COVERAGE := no
1664 ifeq (%(compiler),target)
1665 ifeq (%(usestartup),yes)
1666 ifeq (%(coverageinstr),yes)
1667 %(mmake)_COVERAGE := yes
1668 %(mmake)_COVERAGEFLAGS ?= $(COVERAGEINSTR_FLAGS)
1669 %(mmake)_COVERAGELIBS ?= $(COVERAGEINSTR_LIBS)
1670 %(mmake)_CFLAGS := $(strip $(%(mmake)_COVERAGEFLAGS) $(%(mmake)_CFLAGS))
1671 %(mmake)_LIBS += $(%(mmake)_COVERAGELIBS)
1673 ifeq (%(funcinstr),yes)
1674 %(mmake)_FUNCINSTR := yes
1675 %(mmake)_INSTRFUNCFLAGS ?= $(FUNCINSTR_FLAGS)
1676 %(mmake)_INSTRFUNCLIBS ?= $(FUNCINSTR_LIBS)
1677 %(mmake)_CFLAGS := $(strip $(%(mmake)_INSTRFUNCFLAGS) $(%(mmake)_CFLAGS))
1678 %(mmake)_LIBS += $(%(mmake)_INSTRFUNCLIBS)
1682 %(mmake)_CFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(%(mmake)_CFLAGS))
1686 %(mmake)_DFLAGS := %(dflags)
1688 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
1690 %(mmake)_LDFLAGS := %(ldflags)
1692 %(mmake)_LDFLAGS += -L%(libdir)
1696 %(mmake)-quick : %(mmake)
1698 #MM %(mmake) : includes-generate-deps core-linklibs
1699 %(mmake) : $(%(mmake)_EXES)
1701 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1702 %rule_compile_multi mmake=%(mmake) basenames=$(%(mmake)_FILES) targetdir=$(%(mmake)_OBJDIR) \
1703 cflags=$(%(mmake)_CFLAGS) cppflags=$(%(mmake)_CPPFLAGS) dflags=$(%(mmake)_DFLAGS) compiler="%(compiler)"
1705 %rule_link_progs mmake=%(mmake) progs=$(%(mmake)_FILES) nix="%(nix)" \
1706 targetdir=$(%(mmake)_TARGETDIR) objdir=$(%(mmake)_OBJDIR) \
1707 ldflags=$(%(mmake)_LDFLAGS) \
1708 uselibs="$(%(mmake)_LIBS)" usehostlibs="%(usehostlibs)" \
1709 usestartup="%(usestartup)" detach="%(detach)" \
1710 cmd=$(%(mmake)_LINK) strip=$(%(mmake)_STRIP) objdir=$(%(mmake)_OBJDIR) coverageinstr=$(%(mmake)_COVERAGE)
1714 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(%(mmake)_DEPS)
1716 %rule_makedirs dirs="$(%(mmake)_TARGETDIR) $(%(mmake)_OBJDIR)" setuptarget="$(%(mmake)_DEPS) $(%(mmake)_OBJS) $(addprefix $(%(mmake)_TARGETDIR)/,$(%(mmake)_FILES))"
1718 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_EXES) $(%(mmake)_DEPS)
1721 $(Q)$(ECHO) "Cleaning up for metatarget %(mmake)"
1725 #------------------------------------------------------------------------------
1728 #------------------------------------------------------------------------------
1730 # This is a bare version: It just compiles and links the given files. It is
1731 # assumed that all needed boiler plate code is in the files. This should only
1732 # be used for compiling external code. For AROS code use %build_module
1733 %define build_module_simple mmake=/A modname=/A modtype=/A \
1734 files="$(basename $(call WILDCARD, *.c))" \
1736 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
1737 cppflags=$(CPPFLAGS) \
1738 cflags=$(CFLAGS) dflags= \
1739 cxxflags=$(CXXFLAGS) dxxflags= \
1740 objdir=$(OBJDIR) moduledir= \
1741 uselibs= usehostlibs= compiler=target funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO)
1743 # Define metamake targets and their dependencies
1744 #MM %(mmake) : core-linklibs includes-generate-deps
1745 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1746 #MM %(mmake)-kobj-quick
1750 %(mmake)_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj
1752 .PHONY : $(%(mmake)_ALLTARGETS)
1755 $(error using %build_module_simple: modname may not be empty)
1758 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1761 # Default values for variables and arguments
1762 %(mmake)_DEFLINKLIBNAME := %(modname)
1763 %(mmake)_CFLAGS := %(cflags)
1764 %(mmake)_CXXFLAGS := %(cxxflags)
1765 ifeq (%(compiler),target)
1767 %(mmake)_CFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(%(mmake)_CFLAGS))
1769 ifeq (%(funcinstr),yes)
1770 %(mmake)_FUNCINSTR := yes
1771 %(mmake)_CFLAGS := $(strip $(FUNCINSTR_FLAGS) $(%(mmake)_CFLAGS))
1775 %(mmake)_DFLAGS := %(dflags)
1777 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
1779 %(mmake)_DEFDXXFLAGS := %(dxxflags)
1780 OBJDIR ?= $(GENDIR)/$(CURDIR)
1781 %(mmake)_MODDIR := %(moduledir)
1782 ifeq ($(%(mmake)_MODDIR),)
1783 ifeq (%(modtype),library)
1784 %(mmake)_MODDIR := $(AROS_LIBRARIES)
1786 ifeq (%(modtype),gadget)
1787 %(mmake)_MODDIR := $(AROS_GADGETS)
1789 ifeq (%(modtype),datatype)
1790 %(mmake)_MODDIR := $(AROS_DATATYPES)
1792 ifeq (%(modtype),handler)
1793 %(mmake)_MODDIR := $(AROS_FS)
1795 ifeq (%(modtype),device)
1796 %(mmake)_MODDIR := $(AROS_DEVS)
1798 ifeq (%(modtype),resource)
1799 %(mmake)_MODDIR := $(AROS_RESOURCES)
1801 ifeq (%(modtype),hook)
1802 %(mmake)_MODDIR := $(AROS_RESOURCES)
1804 ifeq (%(modtype),mui)
1805 %(mmake)_MODDIR := $(AROS_CLASSES)/Zune
1807 ifeq (%(modtype),mcc)
1808 %(mmake)_MODDIR := $(AROS_CLASSES)/Zune
1810 ifeq (%(modtype),mcp)
1811 %(mmake)_MODDIR := $(AROS_CLASSES)/Zune
1813 ifeq (%(modtype),usbclass)
1814 %(mmake)_MODDIR := $(AROS_CLASSES)/USB
1816 ifeq (%(modtype),hidd)
1817 %(mmake)_MODDIR := $(AROS_DRIVERS)
1819 ifeq (%(modtype),printer)
1820 %(mmake)_MODDIR := $(AROS_PRINTERS)
1823 ifeq ($(%(mmake)_MODDIR),)
1824 $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1827 %(mmake)_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1828 %(mmake)_ARCHFILES := $(basename $(notdir $(%(mmake)_ARCHOBJS)))
1829 %(mmake)_C_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),%(files))
1830 %(mmake)_CXX_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),%(cxxfiles))
1831 %(mmake)_OBJC_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),%(objcfiles))
1833 %rule_compile_cxx_multi mmake=%(mmake) \
1834 basenames=$(%(mmake)_CXX_NARCHFILES) targetdir="%(objdir)" \
1835 cppflags="%(cppflags)" cxxflags=$(%(mmake)_CXXFLAGS) dxxflags=$(%(mmake)_DXXFLAGS) \
1836 compiler="%(compiler)"
1837 %rule_compile_objc_multi mmake=%(mmake) \
1838 basenames=$(%(mmake)_OBJC_NARCHFILES) targetdir="%(objdir)" \
1839 cppflags="%(cppflags)" cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
1840 compiler="%(compiler)"
1841 %rule_compile_multi mmake=%(mmake) \
1842 basenames=$(%(mmake)_C_NARCHFILES) targetdir="%(objdir)" \
1843 cppflags="%(cppflags)" cflags="$(%(mmake)_CFLAGS)" dflags="$(%(mmake)_DFLAGS)" \
1844 compiler="%(compiler)"
1846 # Handlers use dash instead of dot in their names
1847 ifeq (%(modtype),handler)
1848 %(mmake)_MODULE := $(%(mmake)_MODDIR)/%(modname)-%(modtype)
1850 ifeq (%(modtype),printer)
1851 %(mmake)_MODULE := $(%(mmake)_MODDIR)/%(modname)
1853 %(mmake)_MODULE := $(%(mmake)_MODDIR)/%(modname).%(modtype)
1856 %(mmake)_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1858 %(mmake)-quick : %(mmake)
1859 %(mmake)-kobj-quick : $(%(mmake)_KOBJ)
1860 %(mmake) : $(%(mmake)_MODULE)
1861 %(mmake)-kobj : $(%(mmake)_KOBJ)
1863 # The module is linked from all the compiled .o files
1864 %(mmake)_OBJS := $(%(mmake)_ARCHOBJS) $(addprefix %(objdir)/, $(addsuffix .o,$(notdir $(%(mmake)_C_NARCHFILES))))
1866 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
1867 # This breaks con-handler build. Here we work around this
1868 ifeq (%(modname),con)
1869 %(mmake)_ERR := $(notdir $(%(mmake)_MODULE)).err
1871 %(mmake)_ERR := %(modname).err
1874 %rule_linkmodule module=$(%(mmake)_MODULE) objs=$(%(mmake)_OBJS) \
1875 endobj= err=$(%(mmake)_ERR) objdir="%(objdir)" \
1876 ldflags="$(strip $(LDFLAGS) $(%(modname)_LDFLAGS))" \
1877 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
1879 # Link kernel object file
1880 %(mmake)_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1882 # Make these symbols local
1883 %(mmake)_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1884 UtilityBase ExpansionBase KeymapBase KernelBase
1886 %(mmake)_SYMBOLS := $(%(mmake)_KBASE)
1888 %(mmake)_KLIB := hiddstubs amiga arossupport autoinit libinit
1889 %(mmake)_KOBJ_LIBS := $(filter-out $(%(mmake)_KLIB),%(uselibs)) $(%(mmake)_KAUTOLIB)
1890 $(%(mmake)_KOBJ) : LINKLIBS:=$(%(mmake)_KOBJ_LIBS)
1891 $(%(mmake)_KOBJ) : FILTBASES:=$(addprefix -L ,$(%(mmake)_SYMBOLS))
1892 $(%(mmake)_KOBJ) : USER_LDFLAGS := $(USER_LDFLAGS)
1893 $(%(mmake)_KOBJ) : $(%(mmake)_OBJS) $(%(mmake)_ENDOBJS)
1894 $(Q)$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
1895 $(Q)$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1896 $(Q)$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
1899 ## Dependency fine-tuning
1901 %(mmake)_DEPS := $(addprefix %(objdir)/, $(addsuffix .d,%(files)))
1902 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(%(mmake)_DEPS)
1904 %rule_makedirs dirs="%(objdir) $(%(mmake)_MODDIR) $(KOBJSDIR)" setuptarget="$(%(mmake)_OBJS) $(%(mmake)_DEPS) $(%(mmake)_MODULE) $(%(mmake)_KOBJ) "
1906 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_MODULE) $(%(mmake)_KOBJ) $(%(mmake)_DEPS)
1908 $(Q)$(ECHO) "Cleaning up for module %(modname)"
1911 #------------------------------------------------------------------------------
1914 #------------------------------------------------------------------------------
1915 # Build a module - core routine
1916 # Explanation of this macro is done in the developer's manual
1917 %define build_module_core mmake=/A modname=/A modtype=/A modsuffix= version= flavour= conffile= \
1918 files="$(basename $(call WILDCARD, *.c))" \
1920 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
1921 linklibfiles= linklibobjs= \
1922 cppflags=$(CPPFLAGS) \
1923 cflags=$(CFLAGS) dflags= \
1924 cxxflags=$(CXXFLAGS) dxxflags= \
1925 objdir= moduledir= prefix=$(AROSDIR) \
1926 linklibname= uselibs= usehostlibs= \
1927 compiler=target funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO) nostartup=yes archspecific=no \
1928 include_set=includes-all includedir= libdir= \
1929 build_abi= build_library=
1931 # We will employ a terrifying, but unavoidable, hack here.
1932 # genmf has no concept of conditionals (ie %ifeq), and MetaMake
1933 # ignores GNU Make ifeq() statements, but will process any #MM
1934 # headed lines in the file.
1936 # So, to make the following #MM lines conditional on whether we want
1937 # to build the ABI, Library, or both, we define build_abi= and
1938 # build_library as 'M' to enable, or '' to disable, which allows genmf
1939 # to do the following conversions:
1941 # #%(build_abi)M includes-foo: foo-include
1942 # becomes, when build_abi=M
1943 # #MM includes-foo: foo-include <= Processed by MetaMake
1944 # but, when build_abi= ...
1945 # #M includes-foo: foo-includes <= ignored by MetaMake! Yes!
1947 # Taking full blame for this: Jason S. McMullan <jason.mcmullan@gmail.com>
1949 # Define metamake targets and their dependencies
1952 #MM %(mmake)-makefile
1956 #M%(build_abi)- %(include_set) : %(mmake)-includes
1957 #M%(build_abi)- linklibs-%(modname): %(mmake)-linklib
1958 #M%(build_abi)- linklibs-%(modname)_rel : %(mmake)-linklib
1959 #M%(build_abi)- includes-%(modname): %(mmake)-includes
1960 #M%(build_abi)- includes-%(modname)_rel : %(mmake)-includes
1961 #M%(build_abi)- %(mmake) : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1962 #M%(build_abi) %(mmake)-linklib : %(mmake)-includes includes-%(uselibs)
1963 #M%(build_abi)- %(mmake)-quick : %(mmake)-includes-quick
1964 #M%(build_abi) %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1965 #M%(build_abi) includes-generate-deps %(mmake)-fd
1966 #M%(build_abi) %(mmake)-includes-quick
1967 #M%(build_abi) %(mmake)-includes-dirs
1968 #M%(build_abi) %(mmake)-fd
1971 #%(build_library)M %(mmake)-kobj : core-linklibs linklibs-%(uselibs)
1972 #%(build_library)M %(mmake)-kobj-quick :
1974 # Library with ABI targets:
1975 #%(build_library)%(build_abi) %(mmake)-kobj : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1976 #%(build_library)%(build_abi) %(mmake)-kobj-quick : %(mmake)-includes-quick
1978 # All MetaMake targets defined by this macro
1979 %(mmake)%(flavour)_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-clean
1981 ifeq (%(build_library),M)
1982 %(mmake)%(flavour)_ALLTARGETS += %(mmake)-kobj %(mmake)-kobj-quick
1985 ifeq (%(build_abi),M)
1986 %(mmake)%(flavour)_ALLTARGETS += %(mmake)-includes \
1987 %(mmake)-includes-quick %(mmake)-includes-dirs \
1988 %(mmake)-linklib %(mmake)-fd
1991 .PHONY : $(%(mmake)%(flavour)_ALLTARGETS) %(mmake)-makefile
1994 $(error using %build_module: modname may not be empty)
1997 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
2000 # Default values for variables and arguments
2002 %(mmake)%(flavour)_DEFNAME := %(modname)_%(flavour)
2004 %(mmake)%(flavour)_DEFNAME := %(modname)
2006 %(mmake)%(flavour)_DEFLINKLIBNAME := $(%(mmake)%(flavour)_DEFNAME)
2007 ifneq (%(linklibname),)
2008 %(mmake)%(flavour)_LINKLIBNAME := %(linklibname)
2010 %(mmake)%(flavour)_LINKLIBNAME = $(%(mmake)%(flavour)_DEFLINKLIBNAME)
2012 %(mmake)%(flavour)_DEFCPPFLAGS := %(cppflags)
2013 ifneq (%(includedir),)
2014 %(mmake)%(flavour)_DEFCPPFLAGS += -I%(includedir)
2016 %(mmake)%(flavour)_DEFDFLAGS := %(cflags)
2018 %(mmake)%(flavour)_DFLAGS := %(dflags)
2020 %(mmake)%(flavour)_DFLAGS = $(%(mmake)%(flavour)_DEFDFLAGS)
2022 %(mmake)%(flavour)_DEFDXXFLAGS := %(cxxflags)
2023 ifneq (%(dxxflags),)
2024 %(mmake)%(flavour)_DXXFLAGS := %(dxxflags)
2026 %(mmake)%(flavour)_DXXFLAGS = $(%(mmake)%(flavour)_DEFDXXFLAGS)
2029 ifeq (%(compiler),target)
2031 %(mmake)%(flavour)_DEFDFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH) $(%(mmake)%(flavour)_DEFDFLAGS))
2032 %(mmake)%(flavour)_DEFDXXFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH) $(%(mmake)%(flavour)_DEFDXXFLAGS))
2034 ifeq (%(funcinstr),yes)
2035 %(mmake)_FUNCINSTR := yes
2036 %(mmake)%(flavour)_DEFDFLAGS := $(strip $(FUNCINSTR_FLAGS) $(%(mmake)%(flavour)_DEFDFLAGS))
2037 %(mmake)%(flavour)_DEFDXXFLAGS := $(strip $(FUNCINSTR_FLAGS) $(%(mmake)%(flavour)_DEFDXXFLAGS))
2041 OBJDIR ?= $(GENDIR)/$(CURDIR)
2043 %(mmake)_OBJDIR := %(objdir)
2045 %(mmake)_OBJDIR := $(OBJDIR)/$(%(mmake)%(flavour)_DEFNAME)
2048 %(mmake)%(flavour)_OBJDIR := $(%(mmake)_OBJDIR)
2051 ## Create genmodule include Makefile for the module
2053 %(mmake)%(flavour)-makefile := $(%(mmake)%(flavour)_OBJDIR)/Makefile.$(%(mmake)%(flavour)_DEFNAME)%(modtype)
2054 %(mmake)%(flavour)-genmakefile : $(%(mmake)%(flavour)-makefile)
2056 %rule_genmodule_makefile \
2057 mmake=%(mmake)-genmakefile modname="%(modname)" flavour="%(flavour)" modtype="%(modtype)" \
2058 modsuffix="%(modsuffix)" targetdir="$(%(mmake)%(flavour)_OBJDIR)" \
2059 conffile="%(conffile)"
2061 %rule_makedirs dirs="$(%(mmake)%(flavour)_OBJDIR)" setuptarget=$(%(mmake)%(flavour)-makefile)
2063 # Do not parse these statements if metatarget is not appropriate
2064 ifneq ($(filter $(TARGET),$(%(mmake)%(flavour)_ALLTARGETS)),)
2066 # suppress makes warning that the Makefile doesnt yet exist
2067 # on early passes (it will generate the file as needed though)
2068 # when we include it.
2069 -include $(%(mmake)%(flavour)-makefile)
2071 %(mmake)%(flavour)_DEFMODDIR := $($(%(mmake)%(flavour)_DEFNAME)_MODDIR)
2072 ifeq (%(archspecific),yes)
2073 %(mmake)%(flavour)_DEFMODDIR := $(AROS_DIR_ARCH)/$(%(mmake)%(flavour)_DEFMODDIR)
2075 ifneq (%(moduledir),)
2076 %(mmake)%(flavour)_MODDIR := %(moduledir)
2078 %(mmake)%(flavour)_MODDIR := $(%(mmake)%(flavour)_DEFMODDIR)
2081 ## include files generation
2083 ifneq (%(includedir),)
2084 %(mmake)%(flavour)_INCDIR := %(includedir)
2086 %(mmake)%(flavour)_INCDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/$(AROS_DIR_INCLUDE)
2088 %(mmake)%(flavour)_LIBDEFSINC := $(%(mmake)%(flavour)_OBJDIR)/include/$(%(mmake)%(flavour)_DEFNAME)_libdefs.h
2089 %(mmake)%(flavour)_DEFLIBDEFSINC := $(%(mmake)%(flavour)_OBJDIR)/include/$(%(mmake)%(flavour)_DEFNAME)_deflibdefs.h
2091 ifeq (%(build_abi),M)
2092 %(mmake)-includes-quick : %(mmake)-includes
2093 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2094 $(addprefix $(%(mmake)%(flavour)_INCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2095 $(%(mmake)%(flavour)_LIBDEFSINC) $(%(mmake)%(flavour)_DEFLIBDEFSINC)
2097 ifneq ($($(%(mmake)%(flavour)_DEFNAME)_INCLUDES),)
2098 %rule_genmodule_includes mmake=%(mmake)-includes modname="%(modname)" modtype="%(modtype)" \
2099 modsuffix="%(modsuffix)" targetdir="$(%(mmake)_OBJDIR)/include" \
2100 conffile="%(conffile)" flavour="%(flavour)"
2102 %rule_copy_diff_multi \
2103 files=$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES) srcdir="$(%(mmake)_OBJDIR)/include" targetdir=$(GENINCDIR) \
2104 stampfile="$(%(mmake)_OBJDIR)/%(modname)_geninc"
2106 %rule_copy_diff_multi \
2107 files=$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES) srcdir="$(%(mmake)_OBJDIR)/include" targetdir=$(%(mmake)%(flavour)_INCDIR) \
2108 stampfile="$(%(mmake)_OBJDIR)/%(modname)_incs"
2110 %(mmake)%(flavour)_INCDIRS := $(filter-out ./,$(sort $(dir $($(%(mmake)%(flavour)_DEFNAME)_INCLUDES))))
2112 TMP%(modname)_INCDIRS := \
2113 $(%(mmake)_OBJDIR)/include $(addprefix $(%(mmake)_OBJDIR)/include/,$(%(mmake)%(flavour)_INCDIRS)) \
2114 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(%(mmake)%(flavour)_INCDIRS)) \
2115 $(%(mmake)%(flavour)_INCDIR) $(addprefix $(%(mmake)%(flavour)_INCDIR)/,$(%(mmake)%(flavour)_INCDIRS))
2116 %rule_makedirs dirs="$(TMP%(modname)_INCDIRS)" setuptarget="%(mmake)-includes-dirs"
2122 %rule_genmodule_genlibdefs mmake=%(mmake)-genlibdefs modname="%(modname)" flavour="%(flavour)" modtype="%(modtype)" \
2123 modsuffix="%(modsuffix)" targetdir="$(%(mmake)%(flavour)_OBJDIR)/include" \
2124 conffile="%(conffile)" version="%(version)"
2126 $(%(mmake)%(flavour)_DEFLIBDEFSINC) : FILENAME := $(%(mmake)%(flavour)_LIBDEFSINC)
2127 $(%(mmake)%(flavour)_DEFLIBDEFSINC) : $(%(mmake)%(flavour)_LIBDEFSINC)
2128 $(Q)$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
2129 $(Q)$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
2131 $(%(mmake)%(flavour)_LIBDEFSINC) $(%(mmake)%(flavour)_DEFLIBDEFSINC) : | $(%(mmake)%(flavour)_OBJDIR)/include
2132 %rule_makedirs dirs="$(%(mmake)%(flavour)_OBJDIR)/include" setuptarget=%(mmake)%(flavour)-includes-dirs
2134 ## Extra genmodule src files generation
2136 %rule_genmodule_files mmake=%(mmake)-genmodfiles modname="%(modname)" modtype="%(modtype)" \
2137 modsuffix="%(modsuffix)" targetdir="$(%(mmake)%(flavour)_OBJDIR)" stubdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" \
2138 conffile="%(conffile)" flavour="%(flavour)"
2140 $(%(mmake)-genmodfiles_GENFILEFLAG) : $(%(mmake)%(flavour)_DEFLIBDEFSINC) $(%(mmake)%(flavour)-makefile)
2142 %rule_makedirs dirs="$(%(mmake)%(flavour)_OBJDIR)/linklib" setuptarget=%(mmake)%(flavour)-linklib-setup
2144 ifeq (%(build_abi),M)
2146 ifeq (%(includedir),)
2147 %(mmake)%(flavour)_FDDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/$(AROS_DIR_SDK)/$(AROS_DIR_FD)
2149 %(mmake)%(flavour)_FDDIR := %(includedir)/../$(AROS_DIR_FD)
2151 %(mmake)-fd : $(%(mmake)%(flavour)_FDDIR)/%(modname)_lib.fd
2153 %rule_genmodule_fd modname="%(modname)" modtype="%(modtype)" \
2154 modsuffix="%(modsuffix)" targetdir=$(%(mmake)%(flavour)_FDDIR) conffile="%(conffile)"
2156 $(%(mmake)%(flavour)_FDDIR)/%(modname)_lib.fd : | $(%(mmake)%(flavour)_FDDIR)
2158 %rule_makedirs dirs="$(%(mmake)%(flavour)_FDDIR)" setuptarget=%(mmake)%(flavour)-fd-setup
2163 %(mmake)%(flavour)_FILES := %(files)
2164 %(mmake)%(flavour)_OBJCFILES := %(objcfiles)
2165 %(mmake)%(flavour)_CXXFILES := %(cxxfiles)
2167 %(mmake)%(flavour)_LIBFILES := %(linklibfiles)
2168 %(mmake)%(flavour)_LIBS := %(uselibs)
2170 %(mmake)%(flavour)_FDIRS := $(sort $(dir $(%(mmake)%(flavour)_FILES)))
2172 %(mmake)%(flavour)_FILEMATCH = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1)))
2173 %(mmake)%(flavour)_MATCHARCH = $(foreach matchfile,$(2),$(foreach archfile,$(1),$(if $(call %(mmake)%(flavour)_FILEMATCH,$(archfile),$(notdir $(matchfile))),$(matchfile),)))
2174 %(mmake)%(flavour)_FILTERARCH = $(filter-out $(call %(mmake)%(flavour)_MATCHARCH,$(1),$(2)),$(2))
2175 %(mmake)%(flavour)_STARTFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_STARTFILES))
2176 %(mmake)%(flavour)_ENDFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_ENDFILES))
2178 %(mmake)%(flavour)_ARCHOBJS := $(wildcard $(%(mmake)%(flavour)_OBJDIR)/arch/*.o)
2179 %(mmake)%(flavour)_LIBARCHOBJS := $(wildcard $(%(mmake)%(flavour)_OBJDIR)/linklib/arch/*.o)
2180 %(mmake)%(flavour)_ARCHFILES := $(basename $(notdir $(%(mmake)%(flavour)_ARCHOBJS)))
2181 %(mmake)%(flavour)_LIBARCHFILES := $(basename $(notdir $(%(mmake)%(flavour)_LIBARCHOBJS)))
2182 %(mmake)%(flavour)_C_NARCHFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_ARCHFILES),$(%(mmake)%(flavour)_FILES))
2183 %(mmake)%(flavour)_CXX_NARCHFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_ARCHFILES),$(%(mmake)%(flavour)_CXXFILES))
2184 %(mmake)%(flavour)_OBJC_NARCHFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_ARCHFILES),$(%(mmake)%(flavour)_OBJCFILES))
2185 %(mmake)%(flavour)_NLIBARCHFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_LIBARCHFILES),$(%(mmake)%(flavour)_LIBFILES))
2186 %(mmake)%(flavour)_ARCHNLIBFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_LIBFILES),$(%(mmake)%(flavour)_LIBARCHFILES))
2188 %(mmake)%(flavour)_CPPFLAGS := $(strip %(cppflags) -I$(%(mmake)%(flavour)_OBJDIR)/include -include $(%(mmake)%(flavour)_DEFLIBDEFSINC))
2189 ifneq (%(includedir),)
2190 %(mmake)%(flavour)_CPPFLAGS += -I%(includedir)
2192 %(mmake)%(flavour)_LINKLIBCPPFLAGS := $(%(mmake)%(flavour)_CPPFLAGS)
2193 %(mmake)%(flavour)_CPPFLAGS += $(strip $($(%(mmake)%(flavour)_DEFNAME)_CPPFLAGS))
2194 %(mmake)%(flavour)_LINKLIBCPPFLAGS += $(strip $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBCPPFLAGS))
2195 %(mmake)%(flavour)_CFLAGS := $(strip %(cflags) $($(%(mmake)%(flavour)_DEFNAME)_CFLAGS))
2196 %(mmake)%(flavour)_LINKLIBCFLAGS := $(strip %(cflags) $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBCFLAGS))
2197 %(mmake)%(flavour)_CXXFLAGS := $(strip %(cxxflags) $($(%(mmake)%(flavour)_DEFNAME)_CXXFLAGS))
2198 ifeq (%(compiler),target)
2200 %(mmake)%(flavour)_LTOFLAGS ?= $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH))
2201 %(mmake)%(flavour)_CFLAGS := $(strip $(%(mmake)%(flavour)_LTOFLAGS) $(%(mmake)%(flavour)_CFLAGS))
2202 %(mmake)%(flavour)_LINKLIBCFLAGS := $(strip $(%(mmake)%(flavour)_LTOFLAGS) $(%(mmake)%(flavour)_LINKLIBCFLAGS))
2203 %(mmake)%(flavour)_CXXFLAGS := $(strip $(%(mmake)%(flavour)_LTOFLAGS) $(%(mmake)%(flavour)_CXXFLAGS))
2205 ifeq (%(funcinstr),yes)
2206 %(mmake)%(flavour)_SUBSTNULL :=
2207 %(mmake)%(flavour)_SUBSTSPACE := $(%(mmake)%(flavour)_SUBSTNULL) #
2208 %(mmake)%(flavour)_SUBSTCOMMA := ,
2209 %(mmake)%(flavour)_INSTRFUNCFLAGS ?= $(strip $(FUNCINSTR_FLAGS) -finstrument-functions-exclude-file-list=$(subst $(%(mmake)%(flavour)_SUBSTSPACE),$(%(mmake)%(flavour)_SUBSTCOMMA),$(strip $($(%(mmake)%(flavour)_DEFNAME)_STARTFILES))))
2210 %(mmake)%(flavour)_INSTRFUNCLIBS ?= $(FUNCINSTR_LIBS)
2211 %(mmake)%(flavour)_CFLAGS := $(strip $(%(mmake)%(flavour)_INSTRFUNCFLAGS) $(%(mmake)%(flavour)_CFLAGS))
2212 %(mmake)%(flavour)_CXXFLAGS := $(strip $(%(mmake)%(flavour)_INSTRFUNCFLAGS) $(%(mmake)%(flavour)_CXXFLAGS))
2213 %(mmake)%(flavour)_LIBS += $(%(mmake)%(flavour)_INSTRFUNCLIBS)
2216 %(mmake)%(flavour)_DFLAGS := $(strip $(%(mmake)%(flavour)_DFLAGS) $($(%(mmake)%(flavour)_DEFNAME)_DFLAGS))
2217 %(mmake)%(flavour)_LINKLIBDFLAGS := $(strip $(%(mmake)%(flavour)_DFLAGS) $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBDFLAGS))
2218 %(mmake)%(flavour)_DXXFLAGS := $(strip $(%(mmake)%(flavour)_DXXFLAGS) $($(%(mmake)%(flavour)_DEFNAME)_DXXFLAGS))
2220 ifeq (%(modtype),library)
2221 %(mmake)%(flavour)_LIBSUFFIX :=
2223 %(mmake)%(flavour)_LIBSUFFIX := .%(modtype)
2227 %(mmake)%(flavour)_LIBDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/$(AROS_DIR_LIB)
2229 %(mmake)%(flavour)_LIBDIR := %(libdir)
2232 ifeq (%(build_abi),M)
2233 %(mmake)%(flavour)_LINKLIBCFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$($(%(mmake)%(flavour)_DEFNAME)_LINKLIBFILES))
2234 %(mmake)%(flavour)_LINKLIBAFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$($(%(mmake)%(flavour)_DEFNAME)_LINKLIBAFILES))
2235 ifeq ($(strip $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBFILES) $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBAFILES) %(linklibfiles) $(%(mmake)%(flavour)_ARCHNLIBFILES)),)
2236 %(mmake)%(flavour)_LINKLIB :=
2238 %(mmake)%(flavour)_LINKLIB := $(%(mmake)%(flavour)_LIBDIR)/lib%(modname)$(%(mmake)%(flavour)_LIBSUFFIX).a
2239 ifneq (%(modname),$(%(mmake)%(flavour)_LINKLIBNAME))
2240 %(mmake)%(flavour)_LINKLIB += $(%(mmake)%(flavour)_LIBDIR)/lib$(%(mmake)%(flavour)_LINKLIBNAME)$(%(mmake)%(flavour)_LIBSUFFIX).a
2243 %(mmake)%(flavour)_LINKLIBFILES := $(%(mmake)%(flavour)_LINKLIBCFILES) $(%(mmake)%(flavour)_LINKLIBAFILES)
2245 %(mmake)%(flavour)_RELLINKLIBCFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$($(%(mmake)%(flavour)_DEFNAME)_RELLINKLIBFILES))
2246 %(mmake)%(flavour)_RELLINKLIBAFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$($(%(mmake)%(flavour)_DEFNAME)_RELLINKLIBAFILES))
2247 ifeq ($(strip $($(%(mmake)%(flavour)_DEFNAME)_RELLINKLIBFILES) $($(%(mmake)%(flavour)_DEFNAME)_RELLINKLIBAFILES) %(linklibfiles) $(%(mmake)%(flavour)_ARCHNLIBFILES)),)
2248 %(mmake)%(flavour)_RELLINKLIB :=
2250 %(mmake)%(flavour)_RELLINKLIB := $(%(mmake)%(flavour)_LIBDIR)/lib$(%(mmake)%(flavour)_DEFNAME)_rel$(%(mmake)%(flavour)_LIBSUFFIX).a
2251 ifneq (%(modname),$(%(mmake)%(flavour)_LINKLIBNAME))
2252 %(mmake)%(flavour)_RELLINKLIB += $(%(mmake)%(flavour)_LIBDIR)/lib$(%(mmake)%(flavour)_LINKLIBNAME)_rel$(%(mmake)%(flavour)_LIBSUFFIX).a
2255 %(mmake)%(flavour)_RELLINKLIBFILES := $(%(mmake)%(flavour)_RELLINKLIBCFILES) $(%(mmake)%(flavour)_RELLINKLIBAFILES)
2258 %(mmake)%(flavour)_ENDOBJS := $(addsuffix .o,$(%(mmake)%(flavour)_ENDFILES))
2259 %(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)) \
2261 %(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)) \
2263 $(%(mmake)%(flavour)_LINKLIBFILES) $(%(mmake)%(flavour)_RELLINKLIBFILES) : | $(%(mmake)%(flavour)_OBJDIR)/linklib
2264 $(%(mmake)%(flavour)_LINKLIBOBJS) $(%(mmake)%(flavour)_RELLINKLIBOBJS) : | $(%(mmake)%(flavour)_OBJDIR)/linklib
2266 %(mmake)%(flavour)_CCFILES := $(%(mmake)%(flavour)_C_NARCHFILES)
2267 %(mmake)%(flavour)_TARGETCCFILES := $(strip $(%(mmake)%(flavour)_STARTFILES) $(%(mmake)%(flavour)_ENDFILES))
2268 %(mmake)%(flavour)_LINKLIBCCFILES := $(strip $(%(mmake)%(flavour)_NLIBARCHFILES) $(%(mmake)%(flavour)_LINKLIBCFILES) $(%(mmake)%(flavour)_RELLINKLIBCFILES))
2269 %(mmake)%(flavour)_LINKLIBCCGENFILES := $(strip $(%(mmake)%(flavour)_LINKLIBCFILES) $(%(mmake)%(flavour)_RELLINKLIBCFILES))
2271 %rule_compile_cxx_multi mmake=%(mmake)%(flavour) \
2272 basenames=$(%(mmake)%(flavour)_CXX_NARCHFILES) targetdir="$(%(mmake)%(flavour)_OBJDIR)" \
2273 cppflags=$(%(mmake)%(flavour)_CPPFLAGS) cxxflags=$(%(mmake)%(flavour)_CXXFLAGS) dxxflags=$(%(mmake)%(flavour)_DXXFLAGS) \
2274 compiler="%(compiler)"
2275 %rule_compile_objc_multi mmake=%(mmake)%(flavour) \
2276 basenames=$(%(mmake)%(flavour)_OBJC_NARCHFILES) targetdir=$(%(mmake)%(flavour)_OBJDIR) \
2277 cppflags=$(%(mmake)%(flavour)_CPPFLAGS) cflags=$(%(mmake)%(flavour)_CFLAGS) dflags=$(%(mmake)%(flavour)_DFLAGS) \
2278 compiler="%(compiler)"
2279 %rule_compile_multi mmake=%(mmake)%(flavour) \
2280 basenames=$(%(mmake)%(flavour)_CCFILES) targetdir="$(%(mmake)%(flavour)_OBJDIR)" \
2281 cppflags=$(%(mmake)%(flavour)_CPPFLAGS) cflags=$(%(mmake)%(flavour)_CFLAGS) dflags=$(%(mmake)%(flavour)_DFLAGS) \
2282 compiler="%(compiler)"
2283 %rule_compile_multi mmake=%(mmake)%(flavour) \
2284 basenames=$(%(mmake)%(flavour)_TARGETCCFILES) targetdir="$(%(mmake)%(flavour)_OBJDIR)" \
2285 cppflags="$(%(mmake)%(flavour)_CPPFLAGS) -D__AROS__" cflags=$(%(mmake)%(flavour)_CFLAGS) dflags=$(%(mmake)%(flavour)_DFLAGS) \
2286 compiler="%(compiler)"
2287 %rule_compile_multi mmake=%(mmake)%(flavour) \
2288 basenames=$(%(mmake)%(flavour)_NLIBARCHFILES) targetdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" \
2289 cppflags="$(%(mmake)%(flavour)_LINKLIBCPPFLAGS) -D__AROS__" cflags=$(%(mmake)%(flavour)_LINKLIBCFLAGS) dflags=$(%(mmake)%(flavour)_LINKLIBDFLAGS) \
2290 compiler="%(compiler)"
2291 %rule_compile_multi mmake=%(mmake)%(flavour) \
2292 basenames=$(%(mmake)%(flavour)_LINKLIBCCGENFILES) srcdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" targetdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" \
2293 cppflags="$(%(mmake)%(flavour)_LINKLIBCPPFLAGS) -D__AROS__" cflags=$(%(mmake)%(flavour)_LINKLIBCFLAGS) dflags=$(%(mmake)%(flavour)_LINKLIBDFLAGS) \
2294 compiler="%(compiler)"
2296 ifneq ($(%(mmake)%(flavour)_LINKLIBAFILES),)
2297 %rule_assemble_multi mmake=%(mmake)%(flavour) \
2298 cmd=$(%(mmake)%(flavour)_ASSEMBLER) basenames="$(%(mmake)%(flavour)_LINKLIBAFILES) $(%(mmake)%(flavour)_RELLINKLIBAFILES)" targetdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" suffix=.S
2303 ifeq (%(modsuffix),)
2304 %(mmake)%(flavour)_SUFFIX := %(modtype)
2306 %(mmake)%(flavour)_SUFFIX := %(modsuffix)
2309 ifeq (%(build_library),M)
2310 # Handlers use dash instead of dot in their names
2311 ifeq ($(%(mmake)%(flavour)_SUFFIX),handler)
2312 %(mmake)%(flavour)_MODULE := %(prefix)/$(%(mmake)%(flavour)_MODDIR)/$(%(mmake)%(flavour)_DEFNAME)-$(%(mmake)%(flavour)_SUFFIX)
2314 %(mmake)%(flavour)_MODULE := %(prefix)/$(%(mmake)%(flavour)_MODDIR)/$(%(mmake)%(flavour)_DEFNAME).$(%(mmake)%(flavour)_SUFFIX)
2316 %(mmake)%(flavour)_KOBJ := $(KOBJSDIR)/$(%(mmake)%(flavour)_DEFNAME)_$(%(mmake)%(flavour)_SUFFIX).o
2318 %(mmake)%(flavour)_MODULE :=
2319 %(mmake)%(flavour)_KOBJ :=
2322 %(mmake)-quick : %(mmake)
2323 %(mmake) : $(%(mmake)%(flavour)_MODULE) $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_RELLINKLIB)
2324 ifeq (%(build_library),M)
2325 %(mmake)-kobj : $(%(mmake)%(flavour)_KOBJ) $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_RELLINKLIB)
2326 %(mmake)-kobj-quick : $(%(mmake)%(flavour)_KOBJ) $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_RELLINKLIB)
2328 ifeq (%(build_abi),M)
2329 %(mmake)-linklib : $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_RELLINKLIB)
2332 %(mmake)%(flavour)_OBJS := $(addsuffix .o,$(%(mmake)%(flavour)_STARTFILES)) $(%(mmake)%(flavour)_ARCHOBJS) \
2333 $(addprefix $(%(mmake)%(flavour)_OBJDIR)/,$(notdir $(%(mmake)%(flavour)_C_NARCHFILES:=.o) $(%(mmake)%(flavour)_CXXFILES:=.o)))
2335 ifeq (%(nostartup),yes)
2336 # Handlers always have entry point
2337 ifneq (%(modtype),handler)
2338 %(mmake)%(flavour)_STARTOBJS := $(addsuffix .o,$(addprefix $(GENDIR)/,$(RESIDENT_BEGIN)))
2342 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
2343 # This breaks con-handler build. Here we work around this
2344 ifeq (%(modname),con)
2345 %(mmake)%(flavour)_ERR := $(notdir $(%(mmake)%(flavour)_MODULE)).err
2347 %(mmake)%(flavour)_ERR := %(modname).err
2350 ifeq (%(build_library),M)
2351 # The module is linked from all the compiled .o files
2352 %rule_linkmodule module=$(%(mmake)%(flavour)_MODULE) objs="$(%(mmake)%(flavour)_STARTOBJS) $(%(mmake)%(flavour)_OBJS) $(USER_OBJS)" \
2353 endobj=$(%(mmake)%(flavour)_ENDOBJS) err=$(%(mmake)%(flavour)_ERR) objdir="$(%(mmake)%(flavour)_OBJDIR)" \
2354 cmd=$(%(mmake)%(flavour)_LINK) ldflags="$(LDFLAGS) $($(%(mmake)%(flavour)_DEFNAME)_LDFLAGS)" \
2355 uselibs="$(%(mmake)%(flavour)_LIBS) $($(%(mmake)%(flavour)_DEFNAME)_LIBS)" usehostlibs="%(usehostlibs)"
2358 ifeq (%(build_abi),M)
2360 %(mmake)%(flavour)_LC_LINKLIBNAME := $(shell echo $(%(mmake)%(flavour)_LINKLIBNAME) | tr A-Z a-z)
2361 %(mmake)%(flavour)_LC_MODNAME := $(shell echo %(modname) | tr A-Z a-z)
2362 ifneq ($(%(mmake)%(flavour)_LINKLIB),)
2363 %rule_link_linklib mmake=%(mmake) libname="$(%(mmake)%(flavour)_LINKLIBNAME)$(%(mmake)%(flavour)_LIBSUFFIX)" objs=$(%(mmake)%(flavour)_LINKLIBOBJS) libdir="$(%(mmake)%(flavour)_LIBDIR)"
2364 ifneq ($(%(mmake)%(flavour)_LC_MODNAME),$(%(mmake)%(flavour)_LC_LINKLIBNAME))
2365 %rule_link_linklib mmake=%(mmake) libname="%(modname)$(%(mmake)%(flavour)_LIBSUFFIX)" objs=$(%(mmake)%(flavour)_LINKLIBOBJS) libdir="$(%(mmake)%(flavour)_LIBDIR)"
2368 %rule_makedirs dirs="$(%(mmake)%(flavour)_LIBDIR)" setuptarget=$(%(mmake)%(flavour)_LINKLIB)
2371 ifneq ($(%(mmake)%(flavour)_RELLINKLIB),)
2372 %rule_link_linklib mmake=%(mmake) libname="$(%(mmake)%(flavour)_LINKLIBNAME)_rel$(%(mmake)%(flavour)_LIBSUFFIX)" objs=$(%(mmake)%(flavour)_RELLINKLIBOBJS) libdir="$(%(mmake)%(flavour)_LIBDIR)"
2373 ifneq ($(%(mmake)%(flavour)_LC_MODNAME),$(%(mmake)%(flavour)_LC_LINKLIBNAME))
2374 %rule_link_linklib mmake=%(mmake) libname="$(%(mmake)%(flavour)_DEFNAME)_rel$(%(mmake)%(flavour)_LIBSUFFIX)" objs=$(%(mmake)%(flavour)_RELLINKLIBOBJS) libdir="$(%(mmake)%(flavour)_LIBDIR)"
2377 %rule_makedirs dirs="$(%(mmake)%(flavour)_LIBDIR)" setuptarget=$(%(mmake)%(flavour)_RELLINKLIB)
2381 ifeq (%(build_library),M)
2382 # Link kernel object file
2383 %(mmake)%(flavour)_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
2385 # Make these symbols local
2386 %(mmake)%(flavour)_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
2387 UtilityBase ExpansionBase KeymapBase KernelBase
2389 %(mmake)%(flavour)_SYMBOLS := $(%(mmake)%(flavour)_KBASE)
2391 %(mmake)%(flavour)_KLIB := hiddstubs amiga arossupport autoinit libinit
2392 %(mmake)%(flavour)_KOBJ_LIBS := $(filter-out $(%(mmake)%(flavour)_KLIB),$(%(mmake)%(flavour)_LIBS)) $(%(mmake)%(flavour)_KAUTOLIB)
2393 $(%(mmake)%(flavour)_KOBJ) : LINKLIBS:=$(%(mmake)%(flavour)_KOBJ_LIBS) $($(%(mmake)%(flavour)_DEFNAME)_LIBS)
2394 $(%(mmake)%(flavour)_KOBJ) : FILTBASES:=$(addprefix -L ,$(%(mmake)%(flavour)_SYMBOLS))
2395 $(%(mmake)%(flavour)_KOBJ) : USER_LDFLAGS:=$(USER_LDFLAGS)
2396 $(%(mmake)%(flavour)_KOBJ) : $(%(mmake)%(flavour)_OBJS) $(USER_OBJS) $(%(mmake)%(flavour)_ENDOBJS)
2397 $(Q)$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
2398 $(Q)$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
2399 $(Q)$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
2402 ## Dependency fine-tuning
2404 %(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)))
2406 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick" deps=$(%(mmake)%(flavour)_DEPS)
2408 $(%(mmake)%(flavour)_OBJS) $(%(mmake)%(flavour)_DEPS) : | $(%(mmake)%(flavour)_OBJDIR)/linklib
2409 %rule_makedirs dirs="$(%(mmake)%(flavour)_OBJDIR) %(prefix)/$(%(mmake)%(flavour)_MODDIR) $(KOBJSDIR)" setuptarget="$(%(mmake)%(flavour)_OBJS) $(%(mmake)%(flavour)_DEPS) $(%(mmake)%(flavour)_MODULE) $(%(mmake)%(flavour)_KOBJ)"
2411 # Some include files need to be generated before the .c can be parsed.
2412 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick),) # Only for this target these deps are wanted
2414 %(mmake)%(flavour)_DFILE_DEPS := $(%(mmake)%(flavour)_LIBDEFSINC) $(%(mmake)%(flavour)_DEFLIBDEFSINC) \
2415 $(addprefix $(%(mmake)%(flavour)_INCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES))
2416 $(%(mmake)%(flavour)_DEPS) : $(%(mmake)%(flavour)_DFILE_DEPS)
2419 %(mmake)%(flavour)_TOCLEAN := $(%(mmake)%(flavour)_OBJS) $(%(mmake)%(flavour)_DEPS) \
2420 $(%(mmake)%(flavour)_MODULE) $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_KOBJ) \
2421 $(%(mmake)%(flavour)_OBJDIR)/Makefile.%(modname)%(modtype) \
2422 $(addprefix $(%(mmake)%(flavour)_OBJDIR)/include/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2423 $(addprefix $(GENINCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2424 $(addprefix $(%(mmake)%(flavour)_INCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2425 $(%(mmake)_OBJDIR)/%(modname)_geninc $(%(mmake)_OBJDIR)/%(modname)_incs \
2426 $(addsuffix .c,$(%(mmake)%(flavour)_LINKLIBFILES)) $(%(mmake)%(flavour)_LINKLIBOBJS) $(%(mmake)%(flavour)_LIBDEFSINC) \
2427 $(%(mmake)%(flavour)_DEFLIBDEFSINC) $(addsuffix .c,$(%(mmake)%(flavour)_STARTFILES) $(%(mmake)%(flavour)_ENDFILES)) \
2428 $(%(mmake)%(flavour)_ENDOBJS)
2429 %(mmake)-clean : FILES := $(%(mmake)%(flavour)_TOCLEAN)
2431 $(Q)$(ECHO) "Cleaning up for module %(modname)"
2434 endif # $(TARGET) in $(%(mmake)%(flavour)_ALLTARGETS)
2436 #------------------------------------------------------------------------------
2438 #------------------------------------------------------------------------------
2439 # Build a module - ABI and library
2440 # Explanation of this macro is done in the developer's manual
2441 %define build_module mmake=/A modname=/A modtype=/A modsuffix= version= flavour= conffile= \
2442 files="$(basename $(call WILDCARD, *.c))" \
2444 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2445 linklibfiles= linklibobjs= cflags=$(CFLAGS) cppflags=$(CPPFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= \
2446 objdir= moduledir= prefix=$(AROSDIR) \
2447 linklibname= uselibs= usehostlibs= \
2448 compiler=target funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO) nostartup=yes archspecific=no \
2449 include_set=includes-all includedir= libdir=
2451 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2452 modsuffix="%(modsuffix)" version="%(version)" flavour="%(flavour)" conffile="%(conffile)" \
2453 files="%(files)" objcfiles="%(objcfiles)" cxxfiles="%(cxxfiles)" \
2454 linklibname="%(linklibname)" \
2455 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2456 cflags="%(cflags)" cppflags="%(cppflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2457 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2458 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" funcinstr=%(funcinstr) lto=%(lto) \
2459 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2460 include_set=%(include_set) includedir="%(includedir)" libdir="%(libdir)" \
2461 build_abi=M build_library=M
2464 #------------------------------------------------------------------------------
2467 #------------------------------------------------------------------------------
2468 # Build a module skeleton ABI
2469 # This is a stripped-down version of build_module, it only creates include
2470 # files and the linklibs.
2471 # This is used when for plugins or classes with the same API, but no actual
2472 # implementation here.
2473 %define build_module_abi mmake=/A modname=/A modtype=/A modsuffix= version= flavour= conffile= \
2474 linklibfiles= linklibobjs= cflags=$(CFLAGS) cppflags=$(CPPFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= \
2475 objdir= moduledir= prefix=$(AROSDIR) \
2476 linklibname= uselibs= usehostlibs= \
2477 compiler=target nostartup=yes archspecific=no \
2478 include_set=includes-all includedir= libdir=
2480 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2481 modsuffix="%(modsuffix)" version="%(version)" flavour="%(flavour)" conffile="%(conffile)" \
2482 linklibname="%(linklibname)" \
2483 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2484 cflags="%(cflags)" cppflags="%(cppflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2485 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2486 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" lto=%(lto) \
2487 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2488 include_set=%(include_set) includedir="%(includedir)" libdir="%(libdir)" \
2489 build_abi=M build_library=
2492 #------------------------------------------------------------------------------
2494 #------------------------------------------------------------------------------
2495 # Build a module library - no includes nor linklibs
2496 # Explanation of this macro is done in the developer's manual
2497 %define build_module_library mmake=/A modname=/A modtype=/A modsuffix= version= flavour= conffile= \
2498 files="$(basename $(call WILDCARD, *.c))" \
2500 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2501 cflags=$(CFLAGS) cppflags=$(CPPFLAGS) dflags= cxxflags="$(CXXFLAGS)" dxxflags= \
2502 objdir= moduledir= prefix=$(AROSDIR) \
2503 uselibs= usehostlibs= \
2504 compiler=target lto=$(TARGET_LTO) nostartup=yes archspecific=no \
2505 include_set=includes-all includedir= libdir=
2507 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2508 modsuffix="%(modsuffix)" version="%(version)" flavour="%(flavour)" conffile="%(conffile)" \
2509 files="%(files)" objcfiles="%(objcfiles)" cxxfiles="%(cxxfiles)" \
2510 cflags="%(cflags)" cppflags="%(cppflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2511 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2512 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" lto=%(lto) \
2513 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2514 include_set=%(include_set) includedir="%(includedir)" libdir="%(libdir)" \
2515 build_abi= build_library=M
2518 #------------------------------------------------------------------------------
2522 #------------------------------------------------------------------------------
2524 # - mmake is the mmaketarget
2525 # - libname is the baselibname e.g. lib%(libname).a will be created
2526 # - files are the C source files to include in the lib. The list of files
2527 # has to be given without the .c suffix
2528 # - cxxfiles are C++ source files without suffix.
2529 # NB: files will be matched in the order .cpp > .cxx > .cc
2530 # - asmfiles are the asm files to include in the lib. The list of files has to
2531 # be given without the .s suffix
2532 # - objs additional object to link into the linklib. The objects have to be
2533 # given with full absolute path and the .o suffix.
2534 # - objdir is where the .o are generated. Defaults to $(GENDIR)/$(CURDIR)
2535 # - libdir is the directory where the linklib will be placed (default $(AROS_LIB))
2536 # - cflags are the flags to compile the source (default $(CFLAGS))
2537 # - dflags are the flags used during makedepend (default equal to cflags)
2538 # - aflags are the flags used during assembling (default $(AFLAGS))
2539 %define build_linklib mmake=/A libname=/A files= objcfiles= cxxfiles= \
2540 asmfiles= objs= objdir=$(GENDIR)/$(CURDIR) libdir=$(AROS_LIB) \
2541 includedir= srcdir= \
2542 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= \
2543 aflags=$(AFLAGS) compiler=target lto=$(TARGET_LTO) usetree=no
2545 # assign and generate the local variables used in this macro
2546 %(mmake)_LIBNAME := %(libname)
2547 %(mmake)_LINKLIB := %(libdir)/lib%(libname).a
2549 %(mmake)_FILES ?= %(files)
2550 %(mmake)_ASMFILES := %(asmfiles)
2551 %(mmake)_OBJCFILES := %(objcfiles)
2552 %(mmake)_CXXFILES := %(cxxfiles)
2554 %(mmake)_OBJDIR ?= %(objdir)
2555 %(mmake)_ARCHOBJS := $(wildcard $(%(mmake)_OBJDIR)/arch/*.o)
2556 ifeq (%(usetree),no)
2557 %(mmake)_ARCHFILES := $(basename $(notdir $(%(mmake)_ARCHOBJS)))
2559 %(mmake)_ARCHFILES := $(basename $(patsubst $(%(mmake)_OBJDIR)/%,%,$(%(mmake)_ARCHOBJS)))
2561 %(mmake)_C_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_FILES))
2562 %(mmake)_C_FILES ?= $(%(mmake)_C_NARCHFILES)
2563 %(mmake)_CXX_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_CXXFILES))
2564 %(mmake)_CXX_FILES ?= $(%(mmake)_CXX_NARCHFILES)
2565 %(mmake)_OBJC_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_OBJCFILES))
2566 %(mmake)_OBJC_FILES ?= $(%(mmake)_OBJC_NARCHFILES)
2568 ifeq (%(usetree),no)
2569 %(mmake)_OBJ_FILES ?= $(addprefix $(%(mmake)_OBJDIR)/,$(notdir $(%(mmake)_C_NARCHFILES:=.o) $(%(mmake)_CXX_NARCHFILES:=.o) $(%(mmake)_ASMFILES:=.o) $(%(mmake)_OBJC_NARCHFILES:=.o)))
2571 %(mmake)_OBJ_FILES ?= $(addprefix $(%(mmake)_OBJDIR)/,$(%(mmake)_C_NARCHFILES:=.o) $(%(mmake)_CXX_NARCHFILES:=.o) $(%(mmake)_ASMFILES:=.o) $(%(mmake)_OBJC_NARCHFILES:=.o))
2573 %(mmake)_OBJS ?= $(%(mmake)_ARCHOBJS) $(%(mmake)_OBJ_FILES) %(objs)
2574 %(mmake)_DEPS := $(patsubst %.o,%.d,$(%(mmake)_OBJS))
2576 %(mmake)_CPPFLAGS := %(cppflags)
2577 ifneq (%(includedir),)
2578 %(mmake)_CPPFLAGS += -I%(includedir)
2580 %(mmake)_CFLAGS := %(cflags)
2581 %(mmake)_CXXFLAGS := %(cxxflags)
2583 ifeq (%(compiler),target)
2584 %(mmake)_CFLAGS := $(strip $(LTO_CFLAGS) $(%(mmake)_CFLAGS))
2585 %(mmake)_CXXFLAGS := $(strip $(LTO_CFLAGS) $(%(mmake)_CXXFLAGS))
2588 %(mmake)_AFLAGS := %(aflags)
2589 %(mmake)_DFLAGS := %(dflags)
2591 %(mmake)_DFLAGS := %(dflags)
2593 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
2595 %(mmake)_DXXFLAGS := %(dxxflags)
2596 ifneq (%(dxxflags),)
2597 %(mmake)_DXXFLAGS := %(dxxflags)
2599 %(mmake)_DXXFLAGS := $(%(mmake)_CXXFLAGS)
2602 .PHONY : %(mmake) %(mmake)-clean %(mmake)-quick
2605 %(mmake)-quick : %(mmake)
2607 #MM %(mmake) : includes-generate-deps
2608 %(mmake) : $(%(mmake)_LINKLIB)
2610 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
2612 %rule_compile_cxx_multi mmake=%(mmake) \
2613 basenames=$(%(mmake)_CXX_FILES) targetdir="$(%(mmake)_OBJDIR)" \
2614 cppflags=$(%(mmake)_CPPFLAGS) cxxflags=$(%(mmake)_CXXFLAGS) dxxflags=$(%(mmake)_DXXFLAGS) \
2615 compiler="%(compiler)" srcdir=%(srcdir)
2616 %rule_compile_objc_multi mmake=%(mmake) \
2617 basenames=$(%(mmake)_OBJC_FILES) targetdir=$(%(mmake)_OBJDIR) \
2618 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
2619 compiler="%(compiler)" srcdir=%(srcdir)
2620 %rule_compile_multi mmake=%(mmake) \
2621 basenames=$(%(mmake)_C_FILES) targetdir="$(%(mmake)_OBJDIR)" \
2622 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
2623 compiler="%(compiler)" srcdir=%(srcdir) usetree=%(usetree)
2624 %rule_assemble basename=% targetdir="$(%(mmake)_OBJDIR)" \
2625 aflags=$(%(mmake)_AFLAGS)
2627 %rule_link_linklib mmake=%(mmake) libname="%(libname)" objs=$(%(mmake)_OBJS) libdir="%(libdir)" linker="%(compiler)"
2630 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(%(mmake)_DEPS)
2633 %rule_makedirs dirs="$(%(mmake)_OBJDIR) %(libdir)" setuptarget="$(%(mmake)_OBJS) $(%(mmake)_DEPS) $(%(mmake)_LINKLIB)"
2635 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_LINKLIB) $(%(mmake)_DEPS)
2638 $(Q)$(ECHO) "Cleaning up for metatarget %(mmake)"
2642 #------------------------------------------------------------------------------
2645 #------------------------------------------------------------------------------
2647 # - mmake is the mmaketarget
2648 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
2649 # - description is the catalog description file (.cd), without the .cd suffix (default *.cd)
2650 # - subdir is the destination subdirectory of the catalogs
2651 # - name is the name of the destination catalog, without the .catalog suffix
2652 # - source is the path to the generated source code file
2653 # - dir is the base destination directory (default $(AROS_CATALOGS))
2654 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
2655 # - srcdir is the directory in which the *.cd and *.ct files are searched
2657 %define build_catalogs mmake=/A name=/A subdir=/A \
2658 catalogs= source="../strings.h" description= dir=$(AROS_CATALOGS) \
2659 sourcedescription=$(TOOLDIR)/C_h_aros srcdir=$(SRCDIR)/$(CURDIR)
2661 ifeq (%(description),)
2662 %(mmake)_DESC := $(basename $(wildcard %(srcdir)/*.cd))
2664 %(mmake)_DESC := %(description)
2667 %(mmake)_SRC := $(shell echo %(sourcedescription) | sed 's/^\(.\):\//\/\1\//')
2670 %(mmake)_LNGS := $(basename $(notdir $(call WILDCARD, %(srcdir)/*.ct)))
2672 %(mmake)_LNGS := %(catalogs)
2675 %(mmake)_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, $(%(mmake)_LNGS)))
2676 %(mmake)_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, $(%(mmake)_LNGS))) $(dir %(source))
2679 %(mmake) : $(%(mmake)_OBJS) %(source)
2681 %rule_makedirs dirs="$(%(mmake)_DIRS)" setuptarget=$(%(mmake)_OBJS)
2683 %(dir)/%/%(subdir)/%(name).catalog : %(srcdir)/%.ct $(%(mmake)_DESC).cd
2684 $(Q)$(ECHO) "Creating %(name) catalog for language $*."
2685 $(Q)$(FLEXCAT) $(%(mmake)_DESC).cd $< CATALOG="%(dir)/$*/%(subdir)/%(name).catalog" || [ $$? -lt 10 ]
2688 %(source) : %(mmake)_DESC := $(%(mmake)_DESC)
2689 %(source) : %(mmake)_SRC := $(%(mmake)_SRC)
2690 %(source) : $(%(mmake)_DESC).cd $(%(mmake)_SRC).sd | $(dir %(source))
2691 $(Q)$(ECHO) "Creating %(name) catalog source file $@"
2692 $(Q)$(FLEXCAT) $(%(mmake)_DESC).cd $@=$(%(mmake)_SRC).sd
2695 %(mmake)-clean : FILES := $(%(mmake)_OBJS) %(source)
2698 $(Q)$(ECHO) "Cleaning up for metatarget %(mmake)"
2701 .PHONY: %(mmake) %(mmake)-clean
2704 #-----------------------------------------------------------------------------
2707 #-----------------------------------------------------------------------------
2709 # - mmake is the mmaketarget
2710 # - icons is a list of icon base names (i.e. without the .info suffix)
2711 # - dir is the destination directory
2712 # - srcdir is where *.png and *.info.src are sought
2713 #-----------------------------------------------------------------------------
2715 %define build_icons mmake=/A icons=/A dir=/A srcdir=$(SRCDIR)/$(CURDIR) image=
2717 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
2720 %(mmake) : $(BD_OBJS)
2724 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%.png
2725 $(Q)$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2726 $(Q)$(ILBMTOICON) $+ $@
2730 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%(image)
2731 $(Q)$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2732 $(Q)$(ILBMTOICON) $+ $@
2736 %rule_makedirs dirs="%(dir)" setuptarget=$(BD_OBJS)
2738 %(mmake)-clean : FILES := $(BD_OBJS)
2743 .PHONY: %(mmake) %(mmake)-clean
2746 #-----------------------------------------------------------------------------
2749 #------------------------------------------------------------------------------
2750 # Compile files for an arch-specific replacement of code for a module
2751 # - files: the basenames of the C files to compile.
2752 # - asmfiles: the basenames of the asm files to assemble.
2753 # - mainmmake: the mmake of the module in the main directory to compile these
2754 # arch specific files for.
2755 # - maindir: the object directory for the main module
2756 # - arch: the arch for which to compile these files. It can have the form
2757 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
2758 # - cflags (default $(CFLAGS)): the C flags to use for compilation
2759 # - dflags: the flags used during creation of dependency file. If not specified
2760 # the same value as cflags will be used
2761 # - aflags: the flags used during assembling
2762 # - compiler: (host, kernel or target) specifies which compiler to use. By default
2763 # the target compiler is used
2764 # - modname: arch_specific builds of modules (built using build_module) MUST
2765 # specify the name here matching the original module. this insures multiple modules
2766 # built from the same makefile will not pollute each other.
2767 %define build_archspecific files= cxxfiles= asmfiles= linklibfiles= linklibobjs= mainmmake=/A maindir=/A arch=/A \
2768 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target objdir= modname=
2770 ifeq (%(files) %(linklibfiles) %(linklibobjs) %(asmfiles),)
2771 $(error no files or asmfiles given)
2774 ifneq (%(cxxfiles),)
2775 $(error cxx support is TODO)
2778 %buildid targets="%(mainmmake)-%(arch)"
2780 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2781 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2782 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2783 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2784 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2785 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2786 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2787 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2788 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2789 #MM- %(mainmmake)-kobj-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2790 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2791 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2792 #MM- %(mainmmake)-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2793 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2794 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2796 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
2799 BD_OBJROOT$(BDID) := %(objdir)
2802 BD_OBJROOT$(BDID) := $(GENDIR)/%(maindir)/%(modname)
2804 BD_OBJROOT$(BDID) := $(GENDIR)/%(maindir)
2807 BD_OBJDIR$(BDID) := $(BD_OBJROOT$(BDID))/arch
2808 BD_LIBOBJDIR$(BDID) := $(BD_OBJROOT$(BDID))/linklib/arch
2809 BD_FILEOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files)))) $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(cxxfiles))))
2810 BD_LINKLIBOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibfiles))))
2811 BD_LINKLIBARCHOBJS$(BDID) := $(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibobjs)))
2812 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
2813 BD_OBJS$(BDID) := $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) $(BD_ASMOBJS$(BDID))
2814 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files)))) $(addsuffix .d,$(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibfiles))))
2817 BD_DEFLIBDEFSINC$(BDID) := -include $(BD_OBJROOT$(BDID))/include/%(modname)_deflibdefs.h
2820 ifeq ($(TARGET),%(mainmmake)-%(arch)-quick)
2821 BD_TARGET := %(mainmmake)-%(arch)-quick
2823 BD_TARGET := %(mainmmake)-%(arch)
2827 ifeq ($(TARGET),$(BD_TARGET))
2828 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
2829 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(files)))
2830 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(linklibfiles)))
2831 vpath %.s $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2832 vpath %.S $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2835 %rule_makedirs dirs="$(BD_OBJDIR$(BDID)) $(BD_LIBOBJDIR$(BDID))" setuptarget="$(BD_OBJS$(BDID))"
2838 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
2841 %(mainmmake)-%(arch)-quick :: $(BD_OBJS$(BDID))
2843 ifeq ($(findstring %(compiler),host kernel target),)
2844 $(error unknown compiler %(compiler))
2847 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=$(strip %(cppflags) -I$(BD_OBJROOT$(BDID)) $(BD_DEFLIBDEFSINC$(BDID)))
2849 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=%(cppflags)
2851 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
2852 ifeq (%(compiler),target)
2853 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
2854 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=$(TMP_CPPFLAGS)
2855 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=$(strip $(TMP_CFLAGS) $(SAFETY_CFLAGS))
2856 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
2857 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
2859 ifeq (%(compiler),host)
2860 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(HOST_CC)
2861 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
2862 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
2864 ifeq (%(compiler),kernel)
2865 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
2866 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=$(strip $(KERNEL_CPPFLAGS) $(TMP_CPPFLAGS))
2867 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(TMP_CFLAGS))
2868 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
2869 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
2872 ifeq ($(TARGET),$(BD_TARGET))
2873 $(BD_LIBOBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2874 %compile_q cmd=$(TMP_CMD) opt="$(strip $(TMP_CFLAGS) $(TMP_CPPFLAGS))" iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2875 $(BD_OBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2876 %compile_q cmd=$(TMP_CMD) opt="$(strip $(TMP_CFLAGS) $(TMP_CPPFLAGS))" iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2880 $(BD_DEPS$(BDID)) : TMP_CPPFLAGS:=$(strip %(cppflags) $(BD_DEFLIBDEFSINC$(BDID)))
2881 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags)
2883 $(BD_DEPS$(BDID)) : TMP_CPPFLAGS:=%(cppflags)
2884 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
2886 ifeq ($(TARGET),$(BD_TARGET))
2887 $(BD_LIBOBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2888 %mkdepend_q cc=$(TMP_CMD) flags="$(strip $(TMP_DFLAGS) $(TMP_CPPFLAGS))"
2890 $(BD_OBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2891 %mkdepend_q cc=$(TMP_CMD) flags="$(strip $(TMP_DFLAGS) $(TMP_CPPFLAGS))"
2894 $(BD_ASMOBJS$(BDID)) : CPPFLAGS:=%(cppflags)
2895 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
2897 ifeq ($(TARGET),$(BD_TARGET))
2898 $(BD_OBJDIR$(BDID))/%.o : %.s
2900 $(BD_OBJDIR$(BDID))/%.o : %.S
2904 %include_deps depstargets=$(BD_TARGET) deps=$(BD_DEPS$(BDID))
2906 #------------------------------------------------------------------------------
2909 #------------------------------------------------------------------------------
2910 # generate asm files from c files (for debugging purposes)
2913 $(Q)$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
2914 $(Q)$(TARGET_CC) $(TARGET_SYSROOT) -S $(CFLAGS) $(CPPFLAGS) $< -c -o $@
2916 #------------------------------------------------------------------------------
2919 #------------------------------------------------------------------------------
2920 # Copy files from one directory to another.
2922 %define copy_files_q mmake=/A files=$(FILES) src=. dst=/A
2924 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
2926 %rule_makedirs dirs="%(dst)"
2932 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC))/, $(file)) $(addprefix %(dst)/, $(file))))
2935 #------------------------------------------------------------------------------
2938 #------------------------------------------------------------------------------
2939 # Copy a directory recursively to another place, preserving the original
2940 # hierarchical structure
2942 # src: the source directory whose content will be copied.
2943 # dst: the directories where to copy src's content. If not existing, they will be made.
2944 # excludefiles: files which must not be copied. Path must be relative to src.
2946 %define copy_dir_recursive mmake=/A src=. dst=/A excludefiles=
2952 $(Q)cd $(SRCDIR)/$(CURDIR) && $(CPYDIRREC) -s %(src) -d %(dst) -e %(excludefiles)
2955 #------------------------------------------------------------------------------
2958 #------------------------------------------------------------------------------
2959 # Copy include files into the includes directories. There are currently
2960 # two include directories. One for building AROS $(AROS_INCLUDES) and one
2961 # for building tools that need to run on the host system $(GENINCDIR). The
2962 # $(GENINCDIR) path must not contain any references to the C runtime
2963 # library header files.
2965 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
2966 dir= compiler=target includedir=$(AROS_INCLUDES)
2968 ifeq ($(findstring %(compiler),host kernel target),)
2969 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
2974 $(eval TMP_DIRREMAIN := $$$(TMP_DIR))
2975 TMP_DIRFIRST := $(subst $(TMP_DIRREMAIN),,$(TMP_DIR))
2976 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),$(dir %(includes)))
2977 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,$(notdir %(includes)))
2978 ifeq ($(TMP_DIRFIRST),/)
2979 BD_INC_PATH := %(dir)/
2981 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
2984 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
2985 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
2988 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
2991 ifeq (%(compiler),target)
2994 BD_INCL_FILES2 := $(subst %(dir),%(includedir)/%(path),$(dir %(includes)))
2995 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,$(notdir %(includes)))
2997 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,%(includes))
3000 BD_INCL_FILES += $(BD_INCL_FILES2)
3002 $(BD_INCL_FILES2) : %(includedir)/%(path)/% : $(BD_INC_PATH)%
3007 %(mmake) : $(BD_INCL_FILES)
3011 %rule_makedirs dirs="$(dir $(BD_INCL_FILES))" setuptarget=$(BD_INCL_FILES)
3013 #------------------------------------------------------------------------------
3016 #------------------------------------------------------------------------------
3017 %define make_hidd_stubs hidd=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
3018 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
3019 STUBS_MEM := $(addsuffix .o,$(STUBS))
3020 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
3021 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
3022 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
3024 #MM- linklibs : hidd-%(hidd)-stubs
3025 #MM- %(parenttarget): hidd-%(hidd)-stubs
3026 #MM hidd-%(hidd)-stubs : includes includes-copy
3027 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
3029 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
3032 $(STUBS_OBJ) : $(STUBS_SRC)
3033 %compile_q cmd="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" opt="$(strip %(cflags) %(cppflags))" iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
3035 $(STUBS_DEP) : $(STUBS_SRC)
3036 %mkdepend_q flags="$(strip %(dflags) %(cppflags))"
3039 %mkdirs_q $(OBJDIR) $(AROS_LIB)
3043 -@$(RM) $(HIDD_LIB) $(OBJDIR)
3045 DEPS := $(DEPS) $(STUBS_DEP)
3048 #------------------------------------------------------------------------------
3051 #------------------------------------------------------------------------------
3052 # Build an imported source tree which uses the configure script from the
3053 # autoconf package. This rule will try to "integrate" the produced files as
3054 # much as possible in the AROS build, for example by putting libraries in the
3055 # standard library directory, includes in the standard include directory, and
3056 # so on. You can however override this behaviour.
3058 # As a special "bonus" for you, the PROGDIR environment variable is defined to
3059 # be %(bindir) (or its deduced value) when running "make install", and
3060 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
3061 # configure script some more parameters whose value depends upon the PROGDIR
3062 # env var, so that the program gets all its stuff installed in the proper place
3063 # when building it, but when running it from inside AROS it can also find that
3064 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
3065 # the configuration parameters set when running ./configure
3067 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
3068 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
3069 # to the name which has to follow it.
3073 # - mmake = the meta make target.
3074 # - package = name of the package to be built.
3075 # - srcdir = the location of the unpacked source code. Defaults
3076 # to $(SRCDIR)/$(CURDIR).
3077 # - prefix = the target directory. Must be an absolute path of the
3078 # host system. Defaults to $(AROS_CONTRIB).
3079 # - aros_prefix = set a path which is valid within the AROS filesystem.
3080 # Defaults to the value of the prefix option.
3081 # - extraoptions = additional options for the configure script.
3082 # - usecppflags = enable the use of cpp flags. some external configure
3083 # scripts will not set their own cppflags if it is already
3084 # set, so this allows them to be disabled (unless you can provide
3085 # all the options they would need)
3086 # - extracppflags = additional preprocessor flags.
3087 # - usecflags = same meaning as the one for the %build_with_configure macro.
3088 # - extracflags = additional flags to use with the C compiler.
3089 # - usecxxflags = same meaning as the one for the %build_with_configure macro.
3090 # - extracxxflags = additional flags to use with the C++ compiler.
3091 # - nix_dir_layout = if yes the binary will be stored in a bin subdirectory.
3092 # Defaults to the value of the nix argument.
3093 # - nix = enable u*nix path handling, i.e. a path like
3094 # /progdir//./file will be translated to
3095 # progdir:file during run-time. Defaults to no.
3096 # - compiler = target, host or kernel. Defaults to target.
3097 # - install_target = the command used for installing. Defaults to install. Leave
3098 # it empty if you want to suppress installing.
3099 # - preconfigure = a metatarget which is executed before configure is called.
3100 # - postconfigure = a metatarget which is executed after configure is called.
3101 # - postinstall = a metatarget which is executed after installing.
3102 # - install_env = set additional options for installing.
3103 # - use_build_env = if yes the configuration environment is used for
3104 # installing, too. Defaults to no.
3106 # The arguments aros_prefix, nix and nix_dir_layout are related. The logic is
3110 # --prefix = $(aros_prefix)
3111 # progdir = $(aros_prefix)/bin
3114 # --prefix = /PROGDIR
3115 # --bindir = /PROGDIR
3116 # --sbindir = /PROGDIR
3118 # --includedir = /INCLUDE
3119 # --oldincludedir = /INCLUDE
3121 # --prefix = $(aros_prefix)
3124 # progdir = $(aros_prefix)
3127 # bindir = $(prefix)
3128 # sbindir = $(prefix)
3129 # libdir = $(AROS_LIB)
3130 # includedir = $(AROS_INCLUDES)
3131 # oldincludedir = $(AROS_INCLUDES)
3135 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) \
3136 prefix= gendir= basedir=$(CURDIR) extraoptions= \
3137 usecppflags=yes extracppflags= \
3138 usecflags=yes extracflags="$(OPTIMIZATION_CFLAGS)" \
3139 usecxxflags=yes extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3140 hostisaflags="$(HOST_ISA_CFLAGS)" \
3141 kernelisaflags="$(TARGET_ISA_CFLAGS)" \
3142 targetisaflags="$(TARGET_ISA_CFLAGS)" \
3143 aros_prefix= nix_dir_layout= nix=no compiler=target crossbuild=no \
3144 install_target=install preconfigure= postconfigure= postinstall= \
3145 config_env_extra= install_env= use_build_env=no buildflags=yes gnuflags=yes nlsflag=yes xflag=yes
3148 %(mmake)-prefix := %(prefix)
3150 %(mmake)-prefix := $(AROS_CONTRIB)
3153 ifneq (%(aros_prefix),)
3154 %(mmake)-aros_prefix := %(aros_prefix)
3156 %(mmake)-aros_prefix := $(%(mmake)-prefix)
3162 %(mmake)-nix := $(BD_NIXFLAG)
3163 %(mmake)-volpfx := /
3164 %(mmake)-volsfx := /
3166 ifeq (%(nix_dir_layout),)
3167 %(mmake)-nix_dir_layout := yes
3170 %(mmake)-volsfx := :
3172 ifeq (%(nix_dir_layout),)
3173 %(mmake)-nix_dir_layout := no
3177 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
3179 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
3180 exec_prefix=$(%(mmake)-prefix) %(install_env)
3182 # Check if chosen compiler is valid
3183 ifeq ($(findstring %(compiler),host target kernel),)
3184 $(error unknown compiler %(compiler))
3187 # Set legacy 'host' variable based on chosen compiler
3188 ifeq (%(compiler),host)
3191 %(mmake)-pkgbasedir := $(HOSTGENDIR)
3193 %(mmake)-pkgbasedir := $(HOSTGENDIR)/%(basedir)
3198 %(mmake)-pkgbasedir := $(GENDIR)
3200 %(mmake)-pkgbasedir := $(GENDIR)/%(basedir)
3205 %(mmake)-pkgbasedir := %(gendir)
3207 %(mmake)-pkgbasedir := %(gendir)/%(basedir)
3212 %(mmake)-pkgdir := $(%(mmake)-pkgbasedir)
3214 %(mmake)-pkgdir := $(%(mmake)-pkgbasedir)/%(package)
3217 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
3218 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
3220 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
3221 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
3222 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
3225 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
3226 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
3228 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
3231 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
3233 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
3234 sbindir=$(%(mmake)-prefix) \
3235 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
3236 oldincludedir=$(AROS_INCLUDES) %(install_env)
3239 ifneq ($(DEBUG),yes)
3240 %(mmake)-s_flag = -s
3243 ifeq (%(usecflags),yes)
3244 %(mmake)-HOST_CFLAGS=%(hostisaflags) $(HOST_CFLAGS)
3245 %(mmake)-KERNEL_CFLAGS=%(kernelisaflags) $(KERNEL_CFLAGS) $$(%(mmake)-s_flag)
3246 ifeq (%(crossbuild),yes)
3247 %(mmake)-TARGET_CFLAGS=%(targetisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) $(%(mmake)-s_flag)
3249 %(mmake)-TARGET_CFLAGS=%(targetisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)
3252 ifeq (%(usecxxflags),yes)
3253 %(mmake)-HOST_CXXFLAGS=%(hostisaflags) $(HOST_CXXFLAGS)
3254 %(mmake)-KERNEL_CXXFLAGS=%(kernelisaflags) $(KERNEL_CXXFLAGS) $(%(mmake)-s_flag)
3255 ifeq (%(crossbuild),yes)
3256 %(mmake)-TARGET_CXXFLAGS=%(targetisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) $(%(mmake)-s_flag)
3258 %(mmake)-TARGET_CXXFLAGS=%(targetisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)
3262 # Set up build environment, and options for configure script
3263 ifeq (%(compiler),host)
3264 # NB: We need to pass in our crosstoolsdir, but cannot set CFLAGS since it
3265 # confused configure scripts. We also cannot pass it via _FOR_BUILD
3266 # since that won't get picked up during configure.
3267 # We also cannot pass in the compiler including std flags so we need to use
3268 # the "plain" host compiler.
3269 %(mmake)-cfg-env := %(config_env_extra) \
3271 CXXCPP="$(HOST_CPP)" \
3272 CC="$(strip $(HOST_DEF_CC) $(%(mmake)-HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include)" \
3273 CXX="$(strip $(HOST_CXX) $(%(mmake)-HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include)" \
3274 LDFLAGS="-L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS)"
3275 ifeq (%(usecppflags),yes)
3276 %(mmake)-cfg-env += TARGET_CPPFLAGS="$(KERNEL_CPPFLAGS)"
3278 %(mmake)-cfg-env += TARGET_CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
3279 TARGET_CFLAGS="$(strip $(%(mmake)-KERNEL_CFLAGS))" \
3280 TARGET_CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
3281 TARGET_CXXFLAGS="$(strip $(%(mmake)-KERNEL_CXXFLAGS))" \
3282 TARGET_AS="$(TARGET_AS)" \
3283 OBJCOPY="$(OBJCOPY)" \
3284 TARGET_RANLIB="$(RANLIB)" \
3285 TARGET_STRIP="$(STRIP_PLAIN)" \
3286 TARGET_NM="$(NM_PLAIN)" \
3287 TARGET_OBJCOPY="$(TARGET_OBJCOPY)"
3289 ifeq (%(compiler),target)
3290 %(mmake)-cfg-env := %(config_env_extra) \
3291 PKG_CONFIG_LIBDIR="$(AROS_DEVELOPER)/lib/pkgconfig" \
3292 PKG_CONFIG_SYSROOT_DIR="$(AROSDIR)"
3293 %(mmake)-cfg-env += CPP="$(strip $(TARGET_CPP) $(TARGET_SYSROOT))" \
3294 CXXCPP="$(strip $(TARGET_CPP) $(TARGET_SYSROOT))" \
3295 CC="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
3296 CXX="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
3297 LD="$(strip $(TARGET_LD))"
3298 %(mmake)-cfg-env += CFLAGS="$(%(mmake)-TARGET_CFLAGS) %(extracflags)" \
3299 CXXFLAGS="$(%(mmake)-TARGET_CXXFLAGS) %(extracxxflags)"
3300 ifeq (%(usecppflags),yes)
3301 %(mmake)-cfg-env += CPPFLAGS="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3303 %(mmake)-cfg-env += LDFLAGS="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))"
3304 ifeq (%(usecppflags),yes)
3305 %(mmake)-cfg-env += CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)"
3307 %(mmake)-cfg-env += CC_FOR_BUILD="$(strip $(HOST_DEF_CC))" \
3308 CFLAGS_FOR_BUILD="$(strip $(%(mmake)-HOST_CFLAGS))" \
3309 CXX_FOR_BUILD="$(strip $(HOST_CXX))" \
3310 CXXFLAGS_FOR_BUILD="$(strip $(%(mmake)-HOST_CXXFLAGS))" \
3311 LD_FOR_BUILD="$(strip $(HOST_LD))" \
3312 LDFLAGS_FOR_BUILD="$(strip $(HOST_LDFLAGS) $(%(mmake)-s_flag))"
3313 ifeq (%(usecppflags),yes)
3314 %(mmake)-cfg-env += CPPFLAGS_FOR_HOST="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3316 %(mmake)-cfg-env += CC_FOR_HOST="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
3317 CFLAGS_FOR_HOST="$(strip %(hostisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) -L$(AROS_DEVELOPER)/lib %(extracflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3318 CXX_FOR_HOST="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
3319 CXXFLAGS_FOR_HOST="$(strip %(hostisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) -L$(AROS_DEVELOPER)/lib %(extracxxflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3320 LD_FOR_HOST="$(strip $(TARGET_LD))" \
3321 LDFLAGS_FOR_HOST="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))"
3322 ifeq (%(usecppflags),yes)
3323 %(mmake)-cfg-env += CPPFLAGS_FOR_TARGET="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3325 %(mmake)-cfg-env += CC_FOR_TARGET="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
3326 CFLAGS_FOR_TARGET="$(strip $(%(mmake)-TARGET_CFLAGS) -L$(AROS_DEVELOPER)/lib %(extracflags))" \
3327 CXX_FOR_TARGET="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
3328 CXXFLAGS_FOR_TARGET="$(strip $(%(mmake)-TARGET_CXXFLAGS) -L$(AROS_DEVELOPER)/lib %(extracxxflags))" \
3329 LD_FOR_TARGET="$(strip $(TARGET_LD))" \
3330 LDFLAGS_FOR_TARGET="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3331 AR="$(strip $(AR_PLAIN))" \
3332 AS="$(strip $(TARGET_AS))" \
3333 OBJCOPY="$(strip $(OBJCOPY))" \
3334 RANLIB="$(strip $(RANLIB))" \
3335 STRIP="$(strip $(STRIP_PLAIN))"
3336 ifeq (%(usecppflags),yes)
3337 %(mmake)-cfg-env += TARGET_CPPFLAGS="$(KERNEL_CPPFLAGS)"
3339 %(mmake)-cfg-env += TARGET_CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
3340 TARGET_CFLAGS="$(strip $(%(mmake)-KERNEL_CFLAGS))" \
3341 TARGET_CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
3342 TARGET_CXXFLAGS="$(strip $(%(mmake)-KERNEL_CXXFLAGS))" \
3343 TARGET_AS="$(strip $(TARGET_AS))" \
3344 TARGET_RANLIB="$(strip $(RANLIB))" \
3345 TARGET_STRIP="$(strip $(STRIP_PLAIN))" \
3346 TARGET_NM="$(strip $(NM_PLAIN))"
3347 ifeq (%(buildflags),yes)
3348 %(mmake)-config_opts += --target=$(AROS_TARGET_CPU)-aros
3349 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)
3350 %(mmake)-config_opts += --host=$(AROS_TARGET_CPU)-aros
3352 ifeq (%(gnuflags),yes)
3353 %(mmake)-config_opts += --without-pic --disable-shared
3354 ifeq (%(nlsflag),yes)
3355 # disable native language support
3356 %(mmake)-config_opts += --disable-nls
3359 # disable X window system
3360 %(mmake)-config_opts += --without-x
3364 ifeq (%(compiler),kernel)
3365 %(mmake)-cfg-env := %(config_env_extra) \
3366 CPP="$(KERNEL_CPP)" \
3367 CXXCPP="$(KERNEL_CPP)"
3368 ifeq (%(usecppflags),yes)
3369 %(mmake)-cfg-env += CPPFLAGS="$(strip $(KERNEL_CPPFLAGS) %(extracppflags))"
3371 %(mmake)-cfg-env += CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
3372 CFLAGS="$(strip $(%(mmake)-KERNEL_CFLAGS) %(extracflags))" \
3373 CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
3374 CXXFLAGS="$(strip $(%(mmake)-KERNEL_CXXFLAGS) %(extracxxflags))" \
3376 ifeq (%(usecppflags),yes)
3377 %(mmake)-cfg-env += CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)"
3379 %(mmake)-cfg-env += CC_FOR_BUILD="$(HOST_DEF_CC)" \
3380 CFLAGS_FOR_BUILD="$(%(mmake)-HOST_CFLAGS)" \
3381 CXX_FOR_BUILD="$(HOST_CXX)" \
3382 CXXFLAGS_FOR_BUILD="$(%(mmake)-HOST_CXXFLAGS)" \
3383 RANLIB="$(RANLIB)" \
3384 TARGET_RANLIB="$(RANLIB)" \
3385 TARGET_STRIP="$(STRIP_PLAIN)" \
3386 TARGET_NM="$(NM_PLAIN)"
3387 ifeq (%(buildflags),yes)
3388 %(mmake)-config_opts += --target=$(AROS_TARGET_CPU)-aros
3389 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)
3390 %(mmake)-config_opts += --host=$(AROS_TARGET_CPU)-aros
3392 ifeq (%(gnuflags),yes)
3393 %(mmake)-config_opts += --without-pic --disable-shared
3394 ifeq (%(nlsflag),yes)
3395 # disable native language support
3396 %(mmake)-config_opts += --disable-nls
3399 # disable X window system
3400 %(mmake)-config_opts += --without-x
3406 ifeq (%(use_build_env),yes)
3407 BUILD_ENV := $(%(mmake)-cfg-env)
3410 %(mmake)-touchfileflag ?= $(%(mmake)-pkgdir)/.files-touched
3412 ifneq ("$(wildcard %(srcdir)/Makefile)","")
3413 # in an ideal world, we would depend on the files in the source directory,
3414 # so we could copy them when they change. unfortunately filenames with
3415 # spaces cause problems with this
3416 $(%(mmake)-pkgdir)/.local-copy:
3417 %mkdirs_q $(%(mmake)-pkgdir)
3418 $(Q)$(ECHO) "Copying Local-Build Sources to \`$(patsubst $(TOP)/%,%,$(abspath $(%(mmake)-pkgdir)))'"
3419 $(Q)$(CP) -Rf "%(srcdir)/." $(%(mmake)-pkgdir)/ && $(TOUCH) $@
3421 $(%(mmake)-touchfileflag) : $(%(mmake)-pkgdir)/.local-copy
3423 %(mmake)-cfg-srcdir=$(%(mmake)-pkgdir)
3425 %(mmake)-cfg-srcdir=%(srcdir)
3427 %(mmake)-make-env := -C $(%(mmake)-pkgdir)
3429 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3431 # When building for the host, we don't need to build the
3432 # linklibs - this is especially true when building the
3433 # crosstool toolchain on 'foreign' architectures (such as
3434 # building PPC on x86)
3436 #MM- %(mmake)-host : setup includes %(mmake)-quick
3437 #MM- %(mmake)-target : setup includes core-linklibs %(mmake)-quick
3438 #MM- %(mmake): %(mmake)-%(compiler)
3440 # Using -j1 in install_command may result in a warning but finally
3441 # it does its job. make install for gcc does not work reliably for -jN
3443 ifneq (%(install_target),)
3444 %(mmake)-install_command = \
3445 $(ECHO) "Installing from build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))" && \
3446 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
3447 $(%(mmake)-make-env) %(install_target) -j1
3449 %(mmake)-uninstall_command = \
3450 $(RM) $(%(mmake)-installflag) && \
3451 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" \
3452 $(%(mmake)-install_opts) $(%(mmake)-make-env) uninstall
3454 %(mmake)-install_command := true
3455 %(mmake)-uninstall_command := true
3458 #MM- %(mmake)-quick : %(preconfigure) %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
3461 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3464 # N.B.: the make test for the targets being up to date generates a benign Error 1.
3466 $(%(mmake)-installflag) : $(%(mmake)-configflag)
3467 $(Q)$(IF) ! $(BUILD_ENV) $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q $(%(mmake)-make-env); then \
3468 $(RM) $(%(mmake)-installflag) && \
3469 $(ECHO) "Performing build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))" && \
3470 $(BUILD_ENV) $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" $(%(mmake)-make-env) && \
3471 $(%(mmake)-install_command) && \
3472 $(TOUCH) $@ -r $^; \
3475 ifneq ($(%(mmake)-touchfileflag),)
3476 $(%(mmake)-touchfileflag):
3477 %mkdirs_q $(%(mmake)-pkgdir)
3478 $(Q)find %(srcdir) -exec $(TOUCH) -c -r $(%(mmake)-cfg-srcdir)/configure '{}' \; && \
3483 %(mmake)-uninstall :
3484 $(%(mmake)-uninstall_command)
3487 %(mmake)-configure : $(%(mmake)-configflag)
3489 $(%(mmake)-configflag) : TMP_SRCDIR := $(shell echo $(%(mmake)-cfg-srcdir) | sed 's/^\(.\):\//\/\1\//')
3490 $(%(mmake)-configflag) : $(%(mmake)-touchfileflag) $(TOP)/$(CURDIR)/mmakefile
3492 %mkdirs_q $(%(mmake)-pkgdir)
3493 $(Q)$(ECHO) "Configuring build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))"
3494 $(Q)cd $(%(mmake)-pkgdir) && \
3495 find . -name config.cache -exec $(RM) '{}' \; && \
3496 $(%(mmake)-cfg-env) $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) %(extraoptions) && \
3500 %(mmake)-clean : %(mmake)-uninstall
3501 $(Q)$(RM) $(%(mmake)-pkgdir)
3503 #------------------------------------------------------------------------------
3506 #------------------------------------------------------------------------------
3507 # Build an imported source tree which uses cmake
3511 # - mmake = the meta make target.
3512 # - package = name of the package to be built.
3513 # - srcdir = the location of the unpacked source code. Defaults
3514 # to $(SRCDIR)/$(CURDIR).
3515 # - prefix = the target directory. Must be an absolute path of the
3516 # host system. Defaults to $(AROS_CONTRIB).
3517 # - aros_prefix = set a path which is valid within the AROS filesystem.
3518 # Defaults to the value of the prefix option.
3519 # - extraoptions = additional options for the cmake script.
3520 # - usecppflags = enable the use of cpp flags. some external cmake
3521 # scripts will not set their own cppflags if it is already
3522 # set, so this allows them to be disabled (unless you can provide
3523 # all the options they would need)
3524 # - cppflags = preprocessor flags.
3525 # - extracppflags = additional preprocessor flags.
3526 # - usecflags = enable the use of the build systems C flags
3527 # - cflags = additional flags to use with the C compiler.
3528 # - usecxxflags = enable the use of the build systems C flags
3529 # - cxxflags = additional flags to use with the C++ compiler.
3530 # - cflags = flags to use with the C compiler.
3531 # - cxxflags = flags to use with the C++ compiler.
3532 # - installoptions = additional options for the install step.
3535 %define build_with_cmake mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) gendir= prefix= \
3536 aros_prefix= extraoptions= installoptions= maketarget= compiler=target \
3537 usecppflags=yes extracppflags=$(CPPFLAGS) \
3538 usecflags=yes extracflags=$(CFLAGS) \
3539 usecxxflags=yes extracxxflags=$(CXXFLAGS) \
3543 %(mmake)-prefix := %(prefix)
3545 %(mmake)-prefix := $(AROS_CONTRIB)
3548 ifneq (%(aros_prefix),)
3549 %(mmake)-aros_prefix := %(aros_prefix)
3551 %(mmake)-aros_prefix := $(%(mmake)-prefix)
3554 ifeq (%(compiler),host)
3555 BD_LDFLAGS := -L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS) %(extraldflags)
3556 BD_CFLAGS := $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include %(extracflags)
3557 BD_CXXFLAGS := $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include %(extracxxflags)
3558 BD_CPPFLAGS := $(HOST_CPPFLAGS) %(extracppflags)
3559 %(mmake)-cmake_opts := -DCMAKE_INSTALL_PREFIX=$(%(mmake)-prefix) -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(strip $(HOST_DEF_CC))"
3560 ifeq (%(usecflags),yes)
3561 %(mmake)-cmake_opts += -DCMAKE_C_FLAGS="$(strip $(BD_CFLAGS))"
3563 ifeq (%(usecppflags),yes)
3564 %(mmake)-cmake_opts += -DCMAKE_CPP_FLAGS="$(strip $(BD_CPPFLAGS))"
3566 %(mmake)-cmake_opts += -DCMAKE_CXX_COMPILER="$(strip $(HOST_CXX))"
3567 ifeq (%(usecxxflags),yes)
3568 %(mmake)-cmake_opts += -DCMAKE_CXX_FLAGS="$(strip $(BD_CXXFLAGS))"
3571 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
3573 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
3576 BD_LDFLAGS := $(strip $(LDFLAGS) %(extraldflags))
3577 BD_CFLAGS := $(strip $(CFLAGS) %(extracflags))
3578 BD_CXXFLAGS := $(strip $(CXXFLAGS) %(extracxxflags))
3579 BD_CPPFLAGS := $(strip $(CPPFLAGS) %(extracppflags))
3580 %(mmake)-cmake_opts := -DCMAKE_TOOLCHAIN_FILE=$(GENDIR)/config/conf.cmake -DCMAKE_INSTALL_PREFIX=$(%(mmake)-prefix)
3581 ifeq (%(usecflags),yes)
3582 %(mmake)-cmake_opts += -DCMAKE_C_FLAGS="$(strip $(BD_CFLAGS))"
3584 ifeq (%(usecppflags),yes)
3585 %(mmake)-cmake_opts += -DCMAKE_CPP_FLAGS="$(strip $(BD_CPPFLAGS))"
3587 ifeq (%(usecxxflags),yes)
3588 %(mmake)-cmake_opts += -DCMAKE_CXX_FLAGS="$(strip $(BD_CXXFLAGS))"
3590 %(mmake)-cmake_opts += -DCMAKE_EXE_LINKER_FLAGS="$(strip $(BD_LDFLAGS))"
3592 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
3594 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
3599 %(mmake)-pkgdir := %(gendir)/$(CURDIR)
3601 %(mmake)-pkgdir := %(gendir)/$(CURDIR)/%(package)
3605 %(mmake)-cmakeflag := $(%(mmake)-pkgdir)/.cmake
3606 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
3608 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3610 #MM- %(mmake): setup includes core-linklibs %(mmake)-quick
3612 #MM- %(mmake)-quick : %(mmake)-cmake %(mmake)-build_and_install-quick
3615 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3617 $(%(mmake)-installflag) : $(%(mmake)-cmakeflag)
3618 $(IF) ! $(MAKE) -q -C $(%(mmake)-pkgdir); then \
3619 $(RM) $(%(mmake)-installflag) && \
3620 $(MAKE) -C $(%(mmake)-pkgdir) %(maketarget) && \
3621 cd $(%(mmake)-pkgdir) && \
3622 cmake %(installoptions) -P cmake_install.cmake && \
3623 $(TOUCH) $@ -r $^; \
3626 %(mmake)-touchfileflag ?= $(%(mmake)-pkgdir)/.files-touched
3627 ifneq ($(%(mmake)-touchfileflag),)
3628 $(%(mmake)-touchfileflag):
3629 %mkdirs_q $(%(mmake)-pkgdir)
3630 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/CMakeLists.txt '{}' \; && \
3635 %(mmake)-cmake : $(%(mmake)-cmakeflag)
3637 $(%(mmake)-cmakeflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
3638 $(%(mmake)-cmakeflag) : $(%(mmake)-touchfileflag) $(TOP)/$(CURDIR)/mmakefile
3640 %mkdirs_q $(%(mmake)-pkgdir)
3641 cd $(%(mmake)-pkgdir) && \
3642 $(RM) -Rf CMakeCache.txt CMakeFiles \; && \
3643 cmake $(%(mmake)-cmake_opts) %(extraoptions) $(TMP_SRCDIR) && \
3647 %(mmake)-clean : %(mmake)-uninstall
3648 $(Q)$(RM) $(%(mmake)-pkgdir)
3650 #------------------------------------------------------------------------------
3653 #------------------------------------------------------------------------------
3654 # Given an archive name, patches names and locations where to find them, fetch
3655 # the archive and the patches from any of those locations, unpack the archive
3656 # and then apply the patches.
3658 # Locations currently supported are http and ftp sites, plus local filesystem
3659 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
3660 # the fetch.sh script needs to be modified, since this macro relies on that script.
3664 # - mmake = mmaketarget
3665 # - archive_origins = list of locations where to find the archive. They are tried
3666 # in sequence, until the archive is found and fetching it
3667 # succeeded. If not specified, the current directory is assumed.
3668 # - archive = the archive name. Mandatory.
3669 # - suffixes = a list of suffixes to append to the package name plus the
3670 # version. Each one of them is tried until a matching archive is
3671 # found. They are appended to patches and these are tried the
3672 # same way as packages are.
3673 # - location = the local directory where to put the fetched archive and patches.
3674 # If not specified, the directory specified by destination is used.
3675 # - destination = the directory to unpack the archive to.
3676 # If not specified, the current directory is assumed.
3677 # - patches_origins = list of locations where to find the patches. They are tried
3678 # in sequence, until a patch is found and fetching it
3679 # succeeded. If not specified, the current directory is assumed.
3680 # - patches_specs = list of "patch specs". A patch spec is of the form
3681 # patch_name[:[patch_subdir][:patch_opt]].
3683 # - patch_name = the name of the patch file
3684 # - patch_subdir = the directory within \destination\ where to
3686 # - patch_opt = any options to pass to the `patch' command
3687 # when applying the patch.
3689 # The patch_subdir and patch_opt fields are optional.
3691 %define fetch mmake=/A archive_origins=. archive=/A suffixes= location= destination=. \
3692 patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
3696 ifneq (%(location),)
3697 %(mmake)-location := %(location)
3699 %(mmake)-location := %(destination)
3702 %(mmake)-fetchedflag := $(%(mmake)-location)/.%(archive)-fetched
3706 $(Q)$(ECHO) "Fetching %(archive) ..."
3707 $(Q)$(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
3708 -d %(destination) -po "%(patches_origins)" -p "%(patches_specs)"
3709 $(Q)$(IF) ! $(TEST) -f $(%(mmake)-fetchedflag) ; then \
3710 $(TOUCH) $(%(mmake)-fetchedflag) ; \
3713 # $(Q)$(IF) ! $(TEST) -f $(%(mmake)-fetchedflag) ; then \
3714 # $(ECHO) "Fetching %(archive) ..." \
3715 # && $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
3716 # -d %(destination) -po "%(patches_origins)" -p "%(patches_specs)" \
3717 # && $(TOUCH) $(%(mmake)-fetchedflag) ; \
3720 #------------------------------------------------------------------------------
3723 #------------------------------------------------------------------------------
3724 # This macro can aid in patch creation for fetched ports. It temporarily creates another
3725 # unpatched source tree and runs diff against this and a previously fetched and possibly
3726 # patched tree. Depending on what happens after patching during a normal build it might
3727 # give best results if the new patch is created directly after fetch.
3731 # - mmake = mmaketarget
3732 # - archive = archive base name
3733 # - srcdir = the top level directory the package is unpacked to, useful if
3734 # an archive unpacks to a directory other than its name suggests.
3735 # this should not be deeper than a single path element.
3736 # - suffixes = a list of suffixes to append to the the package name plus the
3737 # version. Each one of them is tried until a matching archive is
3739 # - destination = the directory to unpack the archive to.
3740 # - excludes = diff patterns to exclude files or directories from the patch
3742 %define create_patch mmake=/A archive=/A srcdir= suffixes="tar.bz2 tar.gz" destination=/A excludes=
3746 ifneq (%(excludes),)
3747 %(mmake)-exclude := -X ./exclude.patterns
3751 %(mmake)-srcdir := %(srcdir)
3753 %(mmake)-srcdir := %(archive)
3756 #MM- %(mmake) : %(mmake)-diff
3757 #MM- %(mmake)-quick : %(mmake)-diff
3761 $(Q)$(FETCH) -a %(archive) -s "%(suffixes)" -l $(PORTSSOURCEDIR) -d %(destination)/tmp ; \
3762 $(MV) %(destination)/$(%(mmake)-srcdir) %(destination)/tmp/$(%(mmake)-srcdir).aros ; \
3763 cd %(destination)/tmp ; \
3764 $(FOR) f in %(excludes) ; do \
3765 $(ECHO) $$f >> ./exclude.patterns ; \
3767 $(ECHO) "Creating \`%(archive)-aros-new.diff'" ; \
3768 diff -ruN $(%(mmake)-exclude) \
3769 $(%(mmake)-srcdir) \
3770 $(%(mmake)-srcdir).aros \
3771 >$(SRCDIR)/$(CURDIR)/%(archive)-aros-new.diff ; \
3772 $(MV) %(destination)/tmp/$(%(mmake)-srcdir).aros %(destination)/$(%(mmake)-srcdir) ; \
3773 $(RM) %(destination)/tmp
3775 #------------------------------------------------------------------------------
3778 #------------------------------------------------------------------------------
3779 # Joins the features of %fetch and %build_with_configure.
3781 # If a patch is provided, it *must* be named the following way:
3783 # <package name>-<version number>-aros.diff
3785 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3786 # CD'ing into the archive's extracted directory.
3788 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3789 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3790 # to make that patch fully comprehensive.
3794 # - mmake = the meta make target.
3795 # - package = the GNU package name, sans version and archive format suffixes.
3796 # - subpackage = ???
3797 # - compiler = same meaning as the one for the %build_with_configure macro.
3798 # - install_target = same meaning as the one for the %build_with_configure macro.
3799 # - version = the package's version number, or otherwise any other version string.
3800 # It gets appended to the package name to form the basename of the archive.
3801 # - suffixes = a list of suffixes to apped to the the package name plus the
3802 # version. Each one of them is tried until a matching archive is found.
3803 # Defaults to "tar.bz2 tar.gz".
3804 # - srcdir = the top level directory the package is unpacked to (see create_patch).
3805 # - builddir = override the location we expect to run configure/make in.
3806 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
3807 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
3808 # fetched or not. Default to no.
3809 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
3810 # - prefix = same meaning as the one for the %build_with_configure macro.
3811 # - aros_prefix = same meaning as the one for the %build_with_configure macro.
3812 # - extraoptions = same meaning as the one for the %build_with_configure macro.
3813 # - usecppflags = same meaning as the one for the %build_with_configure macro.
3814 # - extracppflags = same meaning as the one for the %build_with_configure macro.
3815 # - usecflags = same meaning as the one for the %build_with_configure macro.
3816 # - extracflags = same meaning as the one for the %build_with_configure macro.
3817 # - usecxxflags = same meaning as the one for the %build_with_configure macro.
3818 # - extracxxflags = same meaning as the one for the %build_with_configure macro.
3819 # - preconfigure = same meaning as the one for the %build_with_configure macro.
3820 # - postconfigure = same meaning as the one for the %build_with_configure macro.
3821 # - postinstall = same meaning as the one for the %build_with_configure macro.
3822 # - install_env = same meaning as the one for the %build_with_configure macro.
3823 # - use_build_env = same meaning as the one for the %build_with_configure macro.
3824 # - nix = same meaning as the one for the %build_with_configure macro.
3825 # - nix_dir_layout = same meaning as the one for the %build_with_configure macro.
3826 # - create_pkg = create a distributable package of the compiled sources, defaults to no
3828 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target crossbuild=no install_target=install \
3829 version=/A suffixes="tar.bz2 tar.gz" srcdir= builddir= gendir= basedir=$(CURDIR) package_repo= patch=no patch_repo= \
3830 prefix= aros_prefix= preconfigure= postconfigure= postinstall= \
3832 usecppflags=yes extracppflags= \
3833 usecflags=yes extracflags="$(OPTIMIZATION_CFLAGS)" \
3834 usecxxflags=yes extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3835 config_env_extra= install_env= use_build_env=no nix=no nix_dir_layout= create_pkg=no \
3836 buildflags=yes gnuflags=yes nlsflag=yes xflag=yes \
3837 hostisaflags= kernelisaflags="$(TARGET_ISA_CFLAGS)" targetisaflags="$(TARGET_ISA_CFLAGS)"
3839 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
3840 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
3841 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
3842 #MM- %(mmake)-create-patch : %(mmake)-%(subpackage)-create-patch
3843 #MM- %(mmake)-create-patch-quick : %(mmake)-%(subpackage)-create-patch
3845 %(mmake)-archbase := %(package)-%(version)
3847 ifeq (%(compiler),host)
3848 %(mmake)-portdir := $(HOSTDIR)/Ports/host/%(package)
3850 %(mmake)-portdir := $(PORTSDIR)/%(package)
3854 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
3856 %(mmake)-prefix := %(prefix)
3859 ifneq (%(subpackage),)
3860 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
3862 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
3866 %(mmake)-%(subpackage)-srcdir := %(srcdir)
3868 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
3871 ifneq (%(builddir),)
3872 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)/%(builddir)
3874 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)
3878 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-f,-p1
3880 %(mmake)-%(subpackage)-patches_specs := ::
3883 %fetch mmake="%(mmake)-%(subpackage)-fetch" archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
3884 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
3885 archive_origins=". %(package_repo)" \
3886 patches_specs=$(%(mmake)-%(subpackage)-patches_specs) patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
3888 %create_patch mmake="%(mmake)-%(subpackage)-create-patch" \
3889 archive=$(%(mmake)-%(subpackage)-archbase) \
3890 srcdir=$(%(mmake)-%(subpackage)-srcdir) \
3891 suffixes="%(suffixes)" \
3892 destination=$(%(mmake)-portdir)
3894 #MM %(mmake) : %(mmake)-%(subpackage)
3899 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
3901 %(mmake)-%(subpackage)-package-basename := \
3902 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
3904 ifneq (%(create_pkg),no)
3905 %(mmake)-%(subpackage)-package := $(%(mmake)-%(subpackage)-package-basename).tar.bz2
3908 %build_with_configure mmake="%(mmake)-%(subpackage)" package="%(package)" compiler="%(compiler)" crossbuild="%(crossbuild)" install_target="%(install_target)" \
3909 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-builddir) gendir="%(gendir)" basedir="%(basedir)" \
3910 config_env_extra="%(config_env_extra)" install_env="%(install_env)" use_build_env="%(use_build_env)" \
3911 nix="%(nix)" nix_dir_layout="%(nix_dir_layout)" prefix=$(%(mmake)-prefix) aros_prefix="%(aros_prefix)" \
3912 preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall) %(mmake)-%(subpackage)-make-package" \
3913 extraoptions="%(extraoptions)" \
3914 usecppflags="%(usecppflags)" extracppflags="%(extracppflags)" \
3915 usecflags="%(usecflags)" extracflags="%(extracflags)" \
3916 usecxxflags="%(usecxxflags)" extracxxflags="%(extracxxflags)" \
3917 buildflags=%(buildflags) gnuflags=%(gnuflags) nlsflag=%(nlsflag) xflag=%(xflag) \
3918 hostisaflags=%(hostisaflags) kernelisaflags="%(kernelisaflags)" targetisaflags=%(targetisaflags)
3920 .PHONY : %(mmake)-%(subpackage)-make-package %(mmake)-%(subpackage)-create-patch
3921 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
3924 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package)
3926 #There seems to be a bug, either with my clock or with make, 'cause it may happen
3927 #that $^ and $@ have exactly the same mtime, and in that case make tries
3928 #to rebuild $@ again, which would fail because the directory where
3929 #the package got installed would not exist anymore.
3930 #We work this around by using an if statement to manually check the mtimes.
3931 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
3932 $(Q)$(IF) $(TEST) $(%(mmake)-installflag) -nt $@ || ! $(TEST) -s $@; then \
3934 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
3935 $(MKDIR) -p "$(DISTDIR)/Packages" ; \
3936 $(MKDIR) -p "$(%(mmake)-prefix)" ; \
3937 cd $(%(mmake)-%(subpackage)-package-dir) ; \
3938 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
3939 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
3942 #------------------------------------------------------------------------------
3945 #------------------------------------------------------------------------------
3946 # Joins the features of %fetch and %build_with_configure, taking advantage of
3947 # the naming scheme of GNU packages. GNU packages names are in the form
3949 # <package name>-<version number>.<archive format suffix>
3951 # If a patch is provided, it *must* be named the following way:
3953 # <package name>-<version number>-aros.diff
3955 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3956 # CD'ing into the archive's extracted directory.
3958 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3959 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3960 # to make that patch fully comprehensive.
3962 # NOTE: GNU packages are always compiled with *nix semantics turned on.
3966 # Arguments have the same meaning as the one for the %fetch_and_build macro, except:
3968 # - prefix = defaults to $(GNUDIR).
3969 # - aros_prefix = defaults to /GNU.
3971 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A crossbuild=no suffixes="tar.bz2 tar.gz" \
3972 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
3973 aros_prefix=/GNU config_env_extra= preconfigure= postconfigure= postinstall= \
3975 usecppflags=yes extracppflags= \
3976 usecflags=yes extracflags="$(OPTIMIZATION_CFLAGS)" \
3977 usecxxflags=yes extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3978 hostisaflags="$(HOST_ISA_CFLAGS)" \
3979 kernelisaflags="$(TARGET_ISA_CFLAGS)" \
3980 targetisaflags="$(TARGET_ISA_CFLAGS)" \
3981 use_build_env=no nix=yes gnuflags=yes nlsflag=yes xflag=yes
3983 GNU_REPOSITORY := gnu://
3985 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
3986 crossbuild="%(crossbuild)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
3987 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
3988 patch="%(patch)" patch_repo="%(patch_repo)" \
3989 prefix="%(prefix)" aros_prefix="%(aros_prefix)" \
3990 extraoptions="%(extraoptions)" \
3991 usecppflags="%(usecppflags)" extracppflags="%(extracppflags)" \
3992 usecflags="%(usecflags)" extracflags="%(extracflags)" \
3993 usecxxflags="%(usecxxflags)" extracxxflags="%(extracxxflags)" \
3994 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" \
3995 hostisaflags="%(hostisaflags)" kernelisaflags="%(kernelisaflags)" targetisaflags="%(targetisaflags)" \
3996 use_build_env=%(use_build_env) nix=%(nix) gnuflags=%(gnuflags) nlsflag=%(nlsflag) xflag=%(xflag)
3999 #------------------------------------------------------------------------------
4002 #------------------------------------------------------------------------------
4003 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
4004 # that the package is a "Developer" package, and as such it needs to be placed
4005 # under the $(AROS_DEVELOPER) directory, as a default.
4007 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
4008 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
4009 # "mmake" argument, because the metatarget is implicitely defined as
4011 # #MM- development-%(package)
4013 %define fetch_and_build_gnu_development package=/A subpackage= version=/A crossbuild=no suffixes="tar.bz2 tar.gz" \
4014 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPER) \
4015 aros_prefix=/Developer config_env_extra= preconfigure= postconfigure= postinstall= \
4017 usecppflags=yes extracppflags= \
4018 usecflags=yes extracflags="$(OPTIMIZATION_CFLAGS)" \
4019 usecxxflags=yes extracxxflags="$(OPTIMIZATION_CFLAGS)" \
4020 hostisaflags="$(HOST_ISA_CFLAGS)" \
4021 kernelisaflags="$(TARGET_ISA_CFLAGS)" \
4022 targetisaflags="$(TARGET_ISA_CFLAGS)" \
4023 use_build_env=no nix=yes gnuflags=yes nlsflag=yes xflag=yes
4025 #MM- development : development-%(package)
4028 %fetch_and_build_gnu mmake="development-%(package)" package="%(package)" subpackage="%(subpackage)" \
4029 version="%(version)" crossbuild="%(crossbuild)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
4030 package_repo="%(package_repo)" \
4031 patch="%(patch)" patch_repo="%(patch_repo)" \
4032 prefix="%(prefix)" aros_prefix="%(aros_prefix)" \
4033 extraoptions="%(extraoptions)" \
4034 usecppflags="%(usecppflags)" extracppflags="%(extracppflags)" \
4035 usecflags="%(usecflags)" extracflags="%(extracflags)" \
4036 usecxxflags="%(usecxxflags)" extracxxflags="%(extracxxflags)" \
4037 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="postinstall-%(package)-delete-la-files %(postinstall)" \
4038 hostisaflags="%(hostisaflags)" kernelisaflags="%(kernelisaflags)" targetisaflags="%(targetisaflags)" \
4039 use_build_env=%(use_build_env) nix=%(nix) gnuflags=%(gnuflags) nlsflag=%(nlsflag) xflag=%(xflag)
4042 postinstall-%(package)-delete-la-files:
4043 $(RM) %(prefix)/lib/*.la
4046 #------------------------------------------------------------------------------
4048 # Builds a kickstart package in PKG format
4052 # - mmake = target name
4053 # - file = destination file name with path
4055 # Other arguments are self-explanatory
4057 %define make_package mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
4058 arch_classes= arch_devs= arch_handlers= arch_hidds= arch_libs= arch_res=
4060 PKG_CLASSES := $(addprefix $(AROS_CLASSES)/,$(addsuffix .class, %(classes)))
4061 PKG_DEVICES := $(addprefix $(AROS_DEVS)/,$(addsuffix .device, %(devs)))
4062 PKG_HANDLERS := $(addprefix $(AROS_FS)/,$(addsuffix -handler, %(handlers)))
4063 PKG_HIDD := $(addprefix $(AROS_DEVS)/Drivers/,$(addsuffix .hidd, %(hidds)))
4064 PKG_LIBS := $(addprefix $(AROS_LIBRARIES)/,$(addsuffix .library, %(libs)))
4065 PKG_RESOURCES := $(addprefix $(AROS_DEVS)/,$(addsuffix .resource, %(res)))
4067 PKG_CLASSES_ARCH := $(addprefix $(AROS_CLASSES_ARCH)/,$(addsuffix .class, %(arch_classes)))
4068 PKG_DEVICES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .device, %(arch_devs)))
4069 PKG_HANDLERS_ARCH := $(addprefix $(AROS_FS_ARCH)/,$(addsuffix -handler, %(arch_handlers)))
4070 PKG_HIDD_ARCH := $(addprefix $(AROS_DEVS_ARCH)/Drivers/,$(addsuffix .hidd, %(arch_hidds)))
4071 PKG_LIBRARIES_ARCH := $(addprefix $(AROS_LIBRARIES_ARCH)/,$(addsuffix .library, %(arch_libs)))
4072 PKG_RESOURCES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .resource, %(arch_res)))
4074 PKG_FILES := $(PKG_CLASSES) $(PKG_DEVICES) $(PKG_HANDLERS) $(PKG_HIDD) $(PKG_LIBS) $(PKG_RESOURCES) \
4075 $(PKG_CLASSES_ARCH) $(PKG_DEVICES_ARCH) $(PKG_HANDLERS_ARCH) $(PKG_HIDD_ARCH) $(PKG_LIBRARIES_ARCH) $(PKG_RESOURCES_ARCH)
4076 PKG_DIR := $(dir %(file))
4082 %(mmake)-quick : %(file)
4084 %(file): $(PKG_FILES) | $(PKG_DIR)
4085 $(Q)$(ECHO) Packaging $@...
4086 $(Q)$(SRCDIR)/tools/package/pkg c $@ $^
4088 %compress_file mmake="%(mmake)" file="%(file)"
4090 %rule_makedirs dirs="$(PKG_DIR)"
4094 #------------------------------------------------------------------------------
4095 # Compresses %(file) with a gzip.
4096 # Good in conjunction with for example %build_prog
4098 %define compress_file mmake=/A file=/A
4100 #MM- %(mmake)-gz : %(mmake) %(mmake)-gz-quick
4103 %(mmake)-gz-quick : %(file).gz
4106 $(Q)$(ECHO) Compressing $(subst $(TARGETDIR)/,,$^)...
4111 #------------------------------------------------------------------------------
4112 # Links a kickstart module in ELF format
4113 # Arguments are similar to make_package
4115 %define link_kickstart mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
4116 startup= uselibs= ldflags=$(LDFLAGS) map= deps= strip=$(STRIP)
4118 KOBJ_CLASSES := $(addprefix $(KOBJSDIR)/, $(addsuffix _class.o, %(classes)))
4119 KOBJ_DEVICES := $(addprefix $(KOBJSDIR)/, $(addsuffix _device.o, %(devs)))
4120 KOBJ_HANDLERS := $(addprefix $(KOBJSDIR)/, $(addsuffix _handler.o, %(handlers)))
4121 KOBJ_HIDD := $(addprefix $(KOBJSDIR)/, $(addsuffix _hidd.o, %(hidds)))
4122 KOBJ_LIBS := $(addprefix $(KOBJSDIR)/, $(addsuffix _library.o, %(libs)))
4123 KOBJ_RES := $(addprefix $(KOBJSDIR)/, $(addsuffix _resource.o, %(res)))
4126 KOBJ_STARTUP := $(GENDIR)/$(RESIDENT_BEGIN).o
4128 KOBJ_STARTUP := %(startup)
4131 KOBJS := $(KOBJ_STARTUP) $(KOBJ_CLASSES) $(KOBJ_HANDLERS) $(KOBJ_LIBS) $(KOBJ_DEVICES) $(KOBJ_HIDD) $(KOBJ_RES)
4133 TMP_LDFLAGS := %(ldflags)
4135 # Make a list of the lib files this program depends on.
4136 # In LDFLAGS remove white space between -L and directory
4137 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
4138 # Filter out only the libdirs and remove -L
4139 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
4141 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
4142 # Add normal linklib path
4143 TMP_DIRS += $(AROS_LIB)/
4144 # add lib and .a to static linklib names
4145 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
4146 # search for the linklibs in the given path, ignore ones not found
4147 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS),$(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))))
4149 TMP_DIRS += $(dir %(file))
4151 TMP_LDFLAGS += $(GENMAP) %(map)
4152 TMP_DIRS += $(dir %(map))
4155 #MM %(mmake) : %(deps)
4161 %(mmake)-quick : %(file)
4163 %(file): KOBJS := $(KOBJS)
4164 %(file): LDFLAGS := $(TMP_LDFLAGS) $(NOSTARTUP_LDFLAGS) \
4165 -static -nosysbase -Wl,-Ur
4166 %(file): LDLIBS := $(addprefix -l, %(uselibs))
4167 %(file): $(KOBJS) $(DEPLIBS) | $(TMP_DIRS)
4168 $(Q)$(ECHO) "Kickstart $(subst $(TARGETDIR)/,,$@)..."
4169 $(Q)$(TARGET_CC) $(TARGET_SYSROOT) -o $@ $(KOBJS) $(LDFLAGS) $(LDLIBS)
4170 %strip_q strip=%(strip) file=$@
4172 %compress_file mmake="%(mmake)" file="%(file)"
4174 %rule_makedirs dirs="$(TMP_DIRS)"
4178 #------------------------------------------------------------------------------
4179 # Generate generic rules for a subtarget
4181 %define subtarget parentmmake= mmake=/A mmbase=MM-
4182 #%(mmbase) %(parentmmake) : %(mmake)
4183 #%(mmbase) %(parentmmake)-includes : %(mmake)-includes
4184 #%(mmbase) %(parentmmake)-quick : %(mmake)-quick
4187 #------------------------------------------------------------------------------
4188 # Create a target directory
4190 %define directorytarget mmake=/A directory= icontarget= mmbase=MM-
4193 %mkdirs_q %(directory)
4195 #%(mmbase) %(mmake) : %(mmake)-makedir