1 #############################################################################
2 #############################################################################
4 ## Here are the mmakefile macros that are used as commands in the body ##
6 ## They are used to help the portability of mmakefiles to different ##
7 ## platforms and also will handle the error handling in a standard way. ##
9 #############################################################################
10 #############################################################################
12 #------------------------------------------------------------------------------
13 # Convert the ISO-8859-1 string in %(string) to the host's locale (if necessary)
14 %define localisestr string= var=
15 ifeq (,$(findstring "ISO-8859-1",$(LOCALE)))
16 %(var) := $(shell echo %(string) | iconv -f iso-8859-1 )
22 #------------------------------------------------------------------------------
23 # Compile the file %(from) to %(to) with %(cmd). Write any errors to %(err)
24 # and use the options in %(opt). Use %(iquote) and %(iquote_end) for supplying -iquote or -I- flags
25 %define compile_q cmd="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" opt="$(strip $(CFLAGS) $(CPPFLAGS))" from=$< to=$@ iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
26 $(Q)$(ECHO) "Compiling $(if $(filter /%,%(from)),$(if $(filter $(SRCDIR)/%,$(abspath %(from))),$(patsubst $(SRCDIR)/%,%,$(abspath %(from))),$(patsubst $(TOP)/%,%,$(abspath %(from)))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/%(from))))"
27 $(Q)$(IF) %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -D__SRCFILENAME__="\"$(subst $(TOP)/,,$(subst $(SRCDIR)/,,$(abspath %(from))))"\" -c %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
28 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
29 $(ECHO) "%(from): %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -D__SRCFILENAME__=\"$(subst $(TOP)/,,$(subst $(SRCDIR)/,,$(abspath %(from))))\" -c %(from) -o %(to)" >> $(GENDIR)/errors ; \
30 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors ; \
35 $(ECHO) "Compile failed: %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -D__SRCFILENAME__=\"$(subst $(TOP)/,,$(subst $(SRCDIR)/,,$(abspath %(from))))\" -c %(from) -o %(to)" 1>&2 ; \
36 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
40 #------------------------------------------------------------------------------
43 #------------------------------------------------------------------------------
44 # Assemble the file %(from) to %(to) with %(cmd) with the options in %(opt).
45 %define assemble_q cmd="$(strip $(CC) $(TARGET_SYSROOT))" opt="$(strip $(AFLAGS) $(CPPFLAGS))" from=$< to=$@
46 $(Q)$(ECHO) "Assembling $(notdir %(from))..."
47 $(Q)$(IF) %(cmd) %(opt) %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
48 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
49 $(ECHO) "$(notdir %(from)): %(cmd) %(opt) %(from) -o %(to)" >> $(GENDIR)/errors ; \
50 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
55 $(ECHO) "Assemble failed: %(cmd) %(opt) %(from) -o %(to)" 1>&2 ; \
56 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
60 #-------------------------------------------------------------------------
63 #------------------------------------------------------------------------------
64 # Link a specified number of objects to an executable
65 %define link_q cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" opt=$(LDFLAGS) from=$< to=$@ libs=$(LIBS) strip=$(STRIP) objdir=$(GENDIR)/$(CURDIR) coverageinstr=
66 $(Q)$(eval LINKTARGET=%(to))
67 $(Q)$(ECHO) "Linking $(subst $(TARGETDIR)/,,$(LINKTARGET))..."
68 $(Q)$(eval LINKTMPFILE=%(objdir)/$(notdir $(LINKTARGET)))
69 $(Q)$(IF) %(cmd) %(from) -o $(LINKTMPFILE) %(opt) %(libs) 2>&1 > $(GENDIR)/cerrors 2>&1 ; then \
70 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
71 $(ECHO) "$(LINKTARGET): %(cmd) %(from) -o $(LINKTARGET) %(opt) %(libs)" >> $(GENDIR)/errors ; \
72 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
76 $(CP) $(LINKTMPFILE) $(LINKTARGET) ; \
78 $(ECHO) "Link failed: %(cmd) %(from) -o $(LINKTARGET) %(opt) %(libs)" 1>&2 ; \
79 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
82 $(Q)$(IF) [ "$(DEBUG)" = "yes" ]; then \
83 %(strip) $(LINKTARGET) --only-keep-debug -o $(LINKTARGET).dbg ; \
85 $(Q)%(strip) $(LINKTARGET)
86 $(Q)$(IF) [ "$(DEBUG)" = "yes" ]; then \
87 $(IF) $(TEST) -s $(LINKTARGET).dbg ; then \
88 $(OBJCOPY) --add-gnu-debuglink=$(LINKTARGET).dbg $(LINKTARGET) ; \
91 $(Q)$(IF) [ "%(coverageinstr)" = "yes" ]; then \
92 LINKBASEFILES="$(strip $(notdir $(basename %(from))))" ; \
93 $(FOR) covext in $(TARGET_COVERAGEINSTR_EXTS) ; do \
94 $(FOR) file in $$LINKBASEFILES ; do \
95 COVERAGEFILE=`echo $$file$$covext` ; \
96 $(IF) $(TEST) -s %(objdir)/$$COVERAGEFILE ; then \
97 $(CP) %(objdir)/$$COVERAGEFILE $(dir $(LINKTARGET))$$COVERAGEFILE ; \
103 #------------------------------------------------------------------------------
106 #-------------------------------------------------------------------------
107 # Link a module based upon a number of arguments and the standard $(LIBS)
108 # and $(DEPLIBS) make variables.
110 %define link_module_q cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" err="$(notdir $@).err" objs=/A endtag= module=$(MODULE) ldflags=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
111 $(Q)$(ECHO) "Building $(subst $(TARGETDIR)/,,$@) ..."
112 $(Q)$(IF) %(cmd) $(NOSTARTUP_LDFLAGS) \
113 $(GENMAP) %(objdir)/%(module).map \
114 %(objs) %(libs) %(ldflags) %(endtag) \
115 -o $@ 2>&1 > %(objdir)/%(err); \
117 cat %(objdir)/%(err); \
119 echo "%(cmd) $(NOSTARTUP_LDFLAGS) $(GENMAP) %(objdir)/%(module).map %(objs) %(libs) %(ldflags) %(endtag) -o $@"; \
120 cat %(objdir)/%(err); \
123 $(Q)$(IF) $(TEST) ! -s %(objdir)/%(err) ; then $(RM) %(objdir)/%(err) ; fi
124 $(Q)$(IF) [ "$(DEBUG)" = "yes" ]; then \
125 $(STRIP) $@ --only-keep-debug -o $@.dbg; \
128 $(Q)$(IF) [ "$(DEBUG)" = "yes" ]; then \
129 $(IF) $(TEST) -s $@.dbg ; then \
130 $(OBJCOPY) --add-gnu-debuglink=$@.dbg $@; \
134 #------------------------------------------------------------------------------
137 #------------------------------------------------------------------------------
139 %define mklib_q ar=$(AR) ranlib=$(RANLIB) to=$@ from=$(OBJS)
140 $(Q)$(ECHO) "Creating $(subst $(TARGETDIR)/,,%(to))..."
141 $(Q)%(ar) %(to) %(from)
144 #------------------------------------------------------------------------------
147 #------------------------------------------------------------------------------
148 # Create the dependency file %(to) for %(from)
149 %define mkdepend_q flags="$(strip $(CFLAGS) $(CPPFLAGS))" from=$< to=$@ cc="$(strip $(AROS_CC) $(TARGET_SYSROOT))"
150 %mkdir_q dir="$(dir %(to))"
151 $(Q)$(ECHO) "Makedepend $(if $(filter /%,%(from)),$(if $(filter $(SRCDIR)/%,$(abspath %(from))),$(patsubst $(SRCDIR)/%,%,$(abspath %(from))),$(patsubst $(TOP)/%,%,$(abspath %(from)))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/%(from))))..."
152 $(Q)AROS_CC="%(cc)" $(MKDEPEND) %(flags) -I$(TOP)/$(CURDIR) -I$(SRCDIR)/$(CURDIR) %(from) -o %(to)
154 #------------------------------------------------------------------------------
157 #------------------------------------------------------------------------------
158 # Create one directory without any output
159 %define mkdir_q dir=.
160 $(Q)$(IF) $(TEST) ! -d %(dir) ; then $(MKDIR) %(dir) ; else $(NOP) ; fi
162 #------------------------------------------------------------------------------
165 #------------------------------------------------------------------------------
166 # Create several directories without any output
167 %define mkdirs_q dirs=/M
168 $(Q)$(FOR) dir in %(dirs) ; do \
169 $(IF) $(TEST) ! -d $$dir ; then $(MKDIR) $$dir ; else $(NOP) ; fi ; \
172 #------------------------------------------------------------------------------
175 #############################################################################
176 #############################################################################
178 ## Here are the mmakefile macros that are used to do certain tasks in a ##
179 ## mmakefile. They consist of one or more full makefile rules. ##
180 ## In general the files generated in these macros are also defined as ##
181 ## make targets so that they can be used as a dependency in other rules ##
183 #############################################################################
184 #############################################################################
186 #------------------------------------------------------------------------------
187 # Generate a unique id for each of the %build... rules
188 %define buildid targets=/A
190 ifneq ($(filter $(TARGET),%(targets)),)
191 BDTARGETID := $(BDID)
194 #------------------------------------------------------------------------------
197 #------------------------------------------------------------------------------
198 # Copy file %(from) to %(to) in a makefile rule
199 %define rule_copy from=/A to=/A
203 #------------------------------------------------------------------------------
206 #------------------------------------------------------------------------------
207 # Copy the files %(files) to %(targetdir). For each file in %(files),
208 # %(srcdir)/file is copied to %(targetdir)/file. The targetdir and the
209 # appropriate subdirs are not generated by this rule so they have to be
211 %define rule_copy_multi files=/A targetdir=/A srcdir=.
213 $(addprefix %(targetdir)/,%(files)) : %(targetdir)/% : %(srcdir)/%
216 #------------------------------------------------------------------------------
219 #------------------------------------------------------------------------------
220 # Copy the files %(files) to %(targetdir). For each file in %(files),
221 # %(srcdir)/file is copied to %(targetdir)/file if these files are different.
222 # %(stampfile) is used to keep track of when the last time the comparison has
223 # been done. The targetdir and the appropriate subdirs are not generated by
224 # this rule so they have to be present.
225 %define rule_copy_diff_multi files=/A targetdir=/A srcdir=. \
226 stampfile=$(TMP_SRCDIR)/.copy_stamp
228 TMP_SRCDIR := %(srcdir)
230 $(addprefix %(targetdir)/,%(files)) : | %(stampfile)
232 %(stampfile) : COPYSRCDIR := %(srcdir)
233 %(stampfile) : TGTDIR := %(targetdir)
234 %(stampfile) : FILES := %(files)
235 %(stampfile) : $(addprefix %(srcdir)/,%(files))
236 $(Q)for f in $(FILES); do \
237 $(IF) ! $(CMP) -s $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; then \
238 $(CP) $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; \
243 #------------------------------------------------------------------------------
246 #------------------------------------------------------------------------------
247 # Will join all the files in %(from) to %(to). When text is specified it will
249 # Restriction: at the moment when using a non-empty target dir %(from) may
251 %define rule_join to=/A from=/A text=
254 $(Q)$(IF) $(TEST) "%(text)" != "" ; then \
255 $(Q)$(ECHO) %(text) ; \
259 #------------------------------------------------------------------------------
262 #------------------------------------------------------------------------------
263 # Include the dependency files and add some internal rules
264 # When depstargets is provided the depencies will only be included when one of
265 # these targets is the $(TARGET). Otherwise the dependencies will only be
266 # included when the $(TARGET) is not for setup or clean
267 %define include_deps deps=$(DEPS)/M depstargets=
269 ifneq (%(depstargets),)
270 ifneq ($(findstring $(TARGET),%(depstargets)),)
274 ifeq (,$(filter clean% %clean %clean% setup% includes% %setup,$(TARGET)))
280 #------------------------------------------------------------------------------
283 #------------------------------------------------------------------------------
284 # Create the directories %(dirs). The creation will be done by adding rules to
285 # the %(setuptarget) make target with setup as the default.
286 %define rule_makedirs dirs=/A setuptarget=setup
288 ifneq (%(setuptarget),)
289 %(setuptarget) : | %(dirs)
291 %(setuptarget) :: %(dirs)
294 GLOB_MKDIRS += %(dirs)
297 #------------------------------------------------------------------------------
300 #------------------------------------------------------------------------------
301 # Generate a rule to compile a C source file to an object file and generate
302 # the dependency file. Basename may contain a directory part, then the source
303 # file has to be in that directory. The generated file will be put in the
304 # object directory without the directory.
306 # - basename: the basename of the file to compile. Use % for a wildcard rule
307 # - cflags (default $(CFLAGS)): the C flags to use for compilation
308 # - dflags: the flags used during creation of dependency file. If not specified
309 # the same value as cflags will be used
310 # - targetdir: the directory to put the .o file and the .d file. By default
311 # it is put in the same directory as the .c file
312 %define rule_compile mmake=TMP basename=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= targetdir= compiler=target
314 %(mmake)_NIXFLAG ?= -nix
317 %(mmake)_TARGETBASE := %(basename)
319 %(mmake)_TARGETBASE := %(targetdir)/$(notdir %(basename))
322 # Adjust compiler flags to suit C
323 %(mmake)_C_CPPFLAGS := %(cppflags)
324 %(mmake)_CFLAGS := %(cflags)
325 %(mmake)_CFLAGS := $(subst -fpermissive,, $(%(mmake)_CFLAGS))
327 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
329 %(mmake)_DFLAGS := %(dflags)
332 ifeq ($(findstring %(compiler),host kernel target),)
333 $(error unknown compiler %(compiler))
335 ifeq (%(compiler),target)
336 %(mmake)_LINK ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
337 %(mmake)_STRIP ?= $(TARGET_STRIP)
338 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
339 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
340 $(%(mmake)_TARGETBASE).o : %(mmake)_C_CPPFLAGS:=$(strip $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
341 $(%(mmake)_TARGETBASE).d : %(mmake)_C_CPPFLAGS:=$(strip $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
342 $(%(mmake)_TARGETBASE).o : %(mmake)_CFLAGS:=$(strip $(%(mmake)_CFLAGS) $(SAFETY_CFLAGS))
343 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(%(mmake)_DFLAGS)
344 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
345 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
346 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
347 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
349 ifeq (%(compiler),host)
350 %(mmake)_LINK ?= $(strip $(HOST_CC) $(HOST_LDFLAGS))
351 %(mmake)_STRIP ?= $(HOST_STRIP)
352 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(HOST_CC)
353 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(HOST_CC)
354 $(%(mmake)_TARGETBASE).o : %(mmake)_C_CPPFLAGS:=$(strip $(HOST_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
355 $(%(mmake)_TARGETBASE).d : %(mmake)_C_CPPFLAGS:=$(strip $(HOST_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
356 $(%(mmake)_TARGETBASE).o : %(mmake)_CFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_CFLAGS))
357 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_DFLAGS))
358 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
359 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
360 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
361 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
363 ifeq (%(compiler),kernel)
364 %(mmake)_LINK ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
365 %(mmake)_STRIP ?= $(ECHO) >/dev/null
366 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
367 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
368 $(%(mmake)_TARGETBASE).o : %(mmake)_C_CPPFLAGS:=$(strip $(KERNEL_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
369 $(%(mmake)_TARGETBASE).d : %(mmake)_C_CPPFLAGS:=$(strip $(KERNEL_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
370 $(%(mmake)_TARGETBASE).o : %(mmake)_CFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_CFLAGS))
371 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_DFLAGS))
372 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
373 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
374 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
375 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
378 $(%(mmake)_TARGETBASE).o : CPPFLAGS := $(%(mmake)_C_CPPFLAGS)
379 $(%(mmake)_TARGETBASE).o : CFLAGS := $(%(mmake)_CFLAGS)
380 $(%(mmake)_TARGETBASE).o : %(basename).c
381 %compile_q cmd=$(%(mmake)_CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
384 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(strip $(%(mmake)_NIXFLAG) $(%(mmake)_DFLAGS))
386 $(%(mmake)_TARGETBASE).d : %(basename).c
387 %mkdepend_q cc=$(%(mmake)_CMD) flags="$(strip $(%(mmake)_DFLAGS) $(%(mmake)_C_CPPFLAGS))"
389 #------------------------------------------------------------------------------
392 #------------------------------------------------------------------------------
393 # Generate a rule to compile a C++ source file to an object file and generate
394 # the dependency file. Basename may contain a directory part, then the source
395 # file has to be in that directory. The generated file will be put in the
396 # object directory without the directory.
398 # - basename: the basename of the file to compile. Use % for a wildcard rule
399 # - cflags (default $(CFLAGS)): the C flags to use for compilation
400 # - dflags: the flags used during creation of dependency file. If not specified
401 # the same value as cflags will be used
402 # - targetdir: the directory to put the .o file and the .d file. By default
403 # it is put in the same directory as the .c file
404 %define rule_compile_cxx mmake=TMP basename=/A cppflags=$(CPPFLAGS) cxxflags=$(CXXFLAGS) dxxflags= targetdir= compiler=target
407 %(mmake)_NIXFLAG ?= -nix
409 %(mmake)_TARGETBASE := %(basename)
411 %(mmake)_TARGETBASE := %(targetdir)/$(notdir %(basename))
414 # Adjust compiler flags to suit C++
415 %(mmake)_CXX_CPPFLAGS := %(cppflags)
416 %(mmake)_CXXFLAGS := %(cxxflags)
418 %(mmake)_DXXFLAGS := %(cxxflags)
420 %(mmake)_DXXFLAGS := %(dxxflags)
423 ifeq ($(findstring %(compiler),host kernel target),)
424 $(error unknown compiler %(compiler))
426 ifeq (%(compiler),target)
427 %(mmake)_LINK ?= $(strip $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
428 %(mmake)_STRIP ?= $(TARGET_STRIP)
429 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(AROS_CXX) $(TARGET_SYSROOT))
430 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(AROS_CXX) $(TARGET_SYSROOT))
431 $(%(mmake)_TARGETBASE).o : %(mmake)_CXX_CPPFLAGS:=$(strip $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
432 $(%(mmake)_TARGETBASE).d : %(mmake)_CXX_CPPFLAGS:=$(strip $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
433 $(%(mmake)_TARGETBASE).o : %(mmake)_CXXFLAGS:=$(strip $(%(mmake)_CXXFLAGS) $(SAFETY_CFLAGS))
434 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(%(mmake)_DXXFLAGS)
435 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
436 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
437 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
438 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
440 ifeq (%(compiler),host)
441 %(mmake)_LINK ?= $(strip $(HOST_CXX) $(HOST_LDFLAGS))
442 %(mmake)_STRIP ?= $(HOST_STRIP)
443 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(HOST_CXX)
444 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(HOST_CXX)
445 $(%(mmake)_TARGETBASE).o : %(mmake)_CXX_CPPFLAGS:=$(strip $(HOST_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
446 $(%(mmake)_TARGETBASE).d : %(mmake)_CXX_CPPFLAGS:=$(strip $(HOST_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
447 $(%(mmake)_TARGETBASE).o : %(mmake)_CXXFLAGS:=$(strip $(HOST_CXXFLAGS) $(%(mmake)_CXXFLAGS))
448 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(strip $(HOST_CXXFLAGS) $(%(mmake)_DXXFLAGS))
449 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
450 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
451 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
452 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
454 ifeq (%(compiler),kernel)
455 KERNEL_CXX ?= $(KERNEL_CC)
456 %(mmake)_LINK ?= $(strip $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
457 %(mmake)_STRIP ?= $(ECHO) >/dev/null
458 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))
459 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))
460 $(%(mmake)_TARGETBASE).o : %(mmake)_CXX_CPPFLAGS:=$(strip $(KERNEL_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
461 $(%(mmake)_TARGETBASE).d : %(mmake)_CXX_CPPFLAGS:=$(strip $(KERNEL_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
462 $(%(mmake)_TARGETBASE).o : %(mmake)_CXXFLAGS:=$(strip $(KERNEL_CXXFLAGS) $(%(mmake)_CXXFLAGS))
463 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(strip $(KERNEL_CXXFLAGS) $(%(mmake)_DXXFLAGS))
464 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
465 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
466 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
467 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
470 $(%(mmake)_TARGETBASE).o : CPPFLAGS := $(%(mmake)_CXX_CPPFLAGS)
471 $(%(mmake)_TARGETBASE).o : CXXFLAGS := $(%(mmake)_CXXFLAGS)
472 $(%(mmake)_TARGETBASE).o : %(basename).cpp
473 %compile_q cmd=$(%(mmake)_CMD) opt="$(strip $(CXXFLAGS) $(CPPFLAGS))" iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
476 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(strip $(%(mmake)_NIXFLAG) $(%(mmake)_DXXFLAGS))
478 $(%(mmake)_TARGETBASE).d : %(basename).cpp
479 %mkdepend_q cc=$(%(mmake)_CMD) flags="$(strip $(%(mmake)_DXXFLAGS) $(%(mmake)_CXX_CPPFLAGS))"
484 #------------------------------------------------------------------------------
487 #------------------------------------------------------------------------------
488 # Generate a rule to compile an ObjC source file to an object file and generate
489 # the dependency file. Basename may contain a directory part, then the source
490 # file has to be in that directory. The generated file will be put in the
491 # object directory without the directory.
493 # - basename: the basename of the file to compile. Use % for a wildcard rule
494 # - cflags (default $(CFLAGS)): the C flags to use for compilation
495 # - dflags: the flags used during creation of dependency file. If not specified
496 # the same value as cflags will be used
497 # - targetdir: the directory to put the .o file and the .d file. By default
498 # it is put in the same directory as the .m file
499 %define rule_compile_objc mmake=TMP basename=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= targetdir= compiler=target
502 %(mmake)_NIXFLAG ?= -nix
504 %(mmake)_TARGETBASE := %(basename)
506 %(mmake)_TARGETBASE := %(targetdir)/$(notdir %(basename))
509 # Adjust compiler flags to suit ObjC
510 %(mmake)_OBJC_CPPFLAGS := %(cppflags)
511 %(mmake)_OBJCFLAGS := %(cflags)
512 %(mmake)_OBJCFLAGS := $(%(mmake)_OBJCFLAGS) -isystem $(AROS_DEVELOPER)/include
513 %(mmake)_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(%(mmake)_OBJCFLAGS)))
515 %(mmake)_OBJCDFLAGS := %(cflags)
517 %(mmake)_OBJCDFLAGS := %(dflags)
520 # Define the use of cross compiler
521 ifeq ($(TARGET_OBJC),)
522 %(mmake)_CC := $(TARGET_CC)
524 %(mmake)_CC := $(TARGET_OBJC)
527 ifeq ($(findstring %(compiler),host kernel target),)
528 $(error unknown compiler %(compiler))
530 ifeq (%(compiler),target)
531 %(mmake)_LINK ?= $(strip $(%(mmake)_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
532 %(mmake)_STRIP ?= $(TARGET_STRIP)
533 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(%(mmake)_CC) $(TARGET_SYSROOT))
534 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(%(mmake)_CC) $(TARGET_SYSROOT))
535 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJC_CPPFLAGS:=$(strip $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
536 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJC_CPPFLAGS:=$(strip $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
537 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJCFLAGS:=$(strip $(%(mmake)_OBJCFLAGS) $(SAFETY_CFLAGS))
538 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(%(mmake)_OBJCDFLAGS)
539 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
540 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
541 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
542 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
544 ifeq (%(compiler),host)
545 %(mmake)_LINK ?= $(strip $(HOST_CC) $(HOST_LDFLAGS))
546 %(mmake)_STRIP ?= $(HOST_STRIP)
547 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(HOST_CC)
548 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(HOST_CC)
549 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJC_CPPFLAGS:=$(strip $(HOST_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
550 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJC_CPPFLAGS:=$(strip $(HOST_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
551 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJCFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCFLAGS))
552 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCDFLAGS))
553 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
554 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
555 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
556 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
558 ifeq (%(compiler),kernel)
559 %(mmake)_LINK ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
560 %(mmake)_STRIP ?= $(ECHO) >/dev/null
561 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
562 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
563 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJC_CPPFLAGS:=$(strip $(KERNEL_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
564 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJC_CPPFLAGS:=$(strip $(KERNEL_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
565 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJCFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCFLAGS))
566 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCDFLAGS))
567 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
568 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
569 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
570 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
573 $(%(mmake)_TARGETBASE).o : CPPFLAGS := $(%(mmake)_OBJC_CPPFLAGS)
574 $(%(mmake)_TARGETBASE).o : CFLAGS := $(%(mmake)_OBJCFLAGS)
575 $(%(mmake)_TARGETBASE).o : %(basename).m
576 %compile_q cmd=$(%(mmake)_CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
579 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(strip $(%(mmake)_NIXFLAG) $(%(mmake)_OBJCDFLAGS))
581 $(%(mmake)_TARGETBASE).d : %(basename).m
582 %mkdepend_q cc=$(%(mmake)_CMD) flags="$(strip $(%(mmake)_OBJCDFLAGS) $(%(mmake)_OBJC_CPPFLAGS))"
587 #------------------------------------------------------------------------------
590 #------------------------------------------------------------------------------
591 # Generate a rule to compile multiple C source files to an object file and
592 # generate the corresponding dependency files. The generated file will be put
593 # in the object directory without the directory part of the source file.
595 # - basenames: the basenames of the files to compile. The names may include
596 # relative or absolute path names. No wildcard is allowed
597 # - cflags (default $(CFLAGS)): the C flags to use for compilation
598 # - dflags: the flags used during creation of dependency file. If not specified
599 # the same value as cflags will be used
600 # - targetdir: the directory to put the .o file and the .d file. By default
601 # it is put in the same directory as the .c file. When targetdir is not
602 # empty, path names will be stripped from the file names so that all files
603 # are in that dir and not in subdirectories.
604 # - compiler (default target): compiler to use, target, kernel or host
605 %define rule_compile_multi mmake=TMP basenames=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= srcdir= targetdir= \
606 compiler=target usetree=no
609 %(mmake)_MC_SRCWILDCARD := %
611 %(mmake)_MC_SRCWILDCARD := %(srcdir)/%
615 %(mmake)_MC_TARGETS := $(addsuffix .o,%(basenames))
616 %(mmake)_MC_DTARGETS := $(addsuffix .d,%(basenames))
617 %(mmake)_MC_TGTWILDCARD := %
620 %(mmake)_MC_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
621 %(mmake)_MC_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
624 %(mmake)_MC_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,%(basenames)))
625 %(mmake)_MC_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,%(basenames)))
627 %(mmake)_MC_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(patsubst %(srcdir)/%,%,%(basenames))))
628 %(mmake)_MC_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(patsubst %(srcdir)/%,%,%(basenames))))
631 %(mmake)_MC_TGTWILDCARD := %(targetdir)/%
633 # Be sure that all .c files are generated
634 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : | $(addsuffix .c,%(basenames))
636 # Be sure that all .c files are found
637 %(mmake)_MC_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
638 %(mmake)_MC_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
639 %(mmake)_MC_DIRS := $(foreach dir, $(%(mmake)_MC_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(%(mmake)_MC_SRCDIR)/$(CURDIR)/$(dir)))
640 ifneq ($(%(mmake)_MC_DIRS),)
641 %(mmake)_MC_DIRS := $(shell echo $(%(mmake)_MC_DIRS) | sed 's/\(.\):\//\/\1\//g')
642 vpath %.c $(%(mmake)_MC_DIRS)
647 %(mmake)_MC_CPPFLAGS := %(cppflags)
648 %(mmake)_CFLAGS := %(cflags)
650 %(mmake)_DFLAGS := %(cflags)
652 %(mmake)_DFLAGS := %(dflags)
655 ifeq ($(findstring %(compiler),host kernel target),)
656 $(error unknown compiler %(compiler))
658 ifeq (%(compiler),target)
659 %(mmake)_LINK ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
660 %(mmake)_STRIP ?= $(TARGET_STRIP)
661 %(mmake)_ASSEMBLER ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT))
662 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
663 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_MC_CPPFLAGS:=$(strip $(%(mmake)_MC_CPPFLAGS) $(%(mmake)_MC_EXTRA_CPPFLAGS))
664 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_CFLAGS:=$(strip $(%(mmake)_CFLAGS) $(SAFETY_CFLAGS))
665 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_DFLAGS:=$(%(mmake)_DFLAGS)
666 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
667 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
669 ifeq (%(compiler),host)
670 %(mmake)_LINK ?= $(strip $(HOST_CC) $(HOST_LDFLAGS))
671 %(mmake)_STRIP ?= $(HOST_STRIP)
672 %(mmake)_ASSEMBLER ?= $(strip $HOST_CC) $(HOST_SYSROOT))
673 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : CMD:=$(HOST_CC)
674 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_MC_CPPFLAGS:=$(strip $(HOST_MC_CPPFLAGS) $(%(mmake)_MC_CPPFLAGS) $(%(mmake)_MC_EXTRA_CPPFLAGS))
675 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_CFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_CFLAGS))
676 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_DFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_DFLAGS))
677 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
678 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
680 ifeq (%(compiler),kernel)
681 %(mmake)_LINK ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
682 %(mmake)_STRIP ?= $(ECHO) >/dev/null
683 %(mmake)_ASSEMBLER ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
684 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
685 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_MC_CPPFLAGS:=$(strip $(KERNEL_MC_CPPFLAGS) $(%(mmake)_MC_CPPFLAGS) $(%(mmake)_MC_EXTRA_CPPFLAGS))
686 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_CFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_CFLAGS))
687 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_DFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_DFLAGS))
688 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
689 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
692 $(%(mmake)_MC_TARGETS) : CPPFLAGS := $(%(mmake)_MC_CPPFLAGS)
693 $(%(mmake)_MC_TARGETS) : CFLAGS := $(%(mmake)_CFLAGS)
694 $(%(mmake)_MC_TARGETS) : $(%(mmake)_MC_TGTWILDCARD).o : $(%(mmake)_MC_SRCWILDCARD).c
695 %compile_q cmd=$(CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
697 $(%(mmake)_MC_DTARGETS) : $(%(mmake)_MC_TGTWILDCARD).d : $(%(mmake)_MC_SRCWILDCARD).c
698 %mkdepend_q cc=$(CMD) flags="$(strip $(%(mmake)_DFLAGS) $(%(mmake)_MC_CPPFLAGS))"
700 #------------------------------------------------------------------------------
703 #------------------------------------------------------------------------------
704 # Generate a rule to compile multiple C++ source files to an object file and
705 # generate the corresponding dependency files. The generated file will be put
706 # in the object directory without the directory part of the source file.
708 # - basenames: the basenames of the files to compile. The names may include
709 # relative or absolute path names. No wildcard is allowed. basenames will be
710 # matched to supported AROS_CXXEXTS.
711 # - cflags (default $(CFLAGS)): the C flags to use for compilation
712 # - dflags: the flags used during creation of dependency file. If not specified
713 # the same value as cflags will be used
714 # - targetdir: the directory to put the .o file and the .d file. By default
715 # it is put in the same directory as the .c file. When targetdir is not
716 # empty, path names will be stripped from the file names so that all files
717 # are in that dir and not in subdirectories.
718 # - compiler (default target): compiler to use, target, kernel or host
719 %define rule_compile_cxx_multi mmake=TMP basenames=/A cppflags=$(CPPFLAGS) cxxflags=$(CXXFLAGS) dxxflags= \
720 targetdir= compiler=target srcdir=
722 %(mmake)_CXXABSBASENAMES := $(foreach %(mmake)_CXXBASE,%(basenames),$(if $(filter /%,$(%(mmake)_CXXBASE)),$(%(mmake)_CXXBASE),$(abspath $(SRCDIR)/$(CURDIR)/$(%(mmake)_CXXBASE))))
724 ifneq ($(%(mmake)_CXXABSBASENAMES),)
726 %(mmake)_CXXBASENAMES := $(basename $(%(mmake)_CXXABSBASENAMES))
728 # Identify the "real" c++ files from the passed in basenames
729 %(mmake)_MCXX_FILES := $(strip $(foreach %(mmake)_CXXBASE,$(%(mmake)_CXXABSBASENAMES), $(firstword $(wildcard $(foreach %(mmake)_EXT, $(AROS_CXXEXTS),$(addsuffix .$(%(mmake)_EXT),$(%(mmake)_CXXBASE)))))))
732 %(mmake)_MCXX_SRCWILDCARD := %
734 %(mmake)_MCXX_SRCWILDCARD := %(srcdir)/%
738 %(mmake)_CXXTARGETS := $(notdir $(%(mmake)_CXXBASENAMES:=.o))
739 %(mmake)_CXXDTARGETS := $(notdir $(%(mmake)_CXXBASENAMES:=.d))
740 %(mmake)_MCXX_WILDCARD := %
742 %(mmake)_CXXTARGETS := $(addprefix %(targetdir)/,$(notdir $(%(mmake)_CXXBASENAMES:=.o)))
743 %(mmake)_CXXDTARGETS := $(addprefix %(targetdir)/,$(notdir $(%(mmake)_CXXBASENAMES:=.d)))
744 %(mmake)_MCXX_WILDCARD := %(targetdir)/%
746 # Be sure that all source files are generated
747 $(%(mmake)_CXXTARGETS) $(%(mmake)_CXXDTARGETS) : | $(%(mmake)_MCXX_FILES)
750 # Adjust compiler flags to suit C++
751 %(mmake)_MCXX_CPPFLAGS := %(cppflags)
752 %(mmake)_CXXFLAGS := %(cxxflags)
754 %(mmake)_DXXFLAGS := %(cxxflags)
756 %(mmake)_DXXFLAGS := %(dxxflags)
759 ifeq ($(findstring %(compiler),host kernel target),)
760 $(error unknown compiler %(compiler))
762 ifeq (%(compiler),host)
763 %(mmake)_LINK ?= $(strip $(HOST_CXX) $(HOST_LDFLAGS))
764 %(mmake)_STRIP ?= $(HOST_STRIP)
765 %(mmake)_ASSEMBLER ?= $(strip $(HOST_CC) $(HOST_SYSROOT))
766 %(mmake)_CXXCMD:=$(HOST_CXX)
767 %(mmake)_MCXX_CPPFLAGS := $(strip $(HOST_MCXX_CPPFLAGS) $(%(mmake)_MCXX_CPPFLAGS) $(%(mmake)_MCXX_EXTRA_CPPFLAGS))
768 %(mmake)_CXXFLAGS := $(strip $(HOST_CXXFLAGS) $(%(mmake)_CXXFLAGS))
769 %(mmake)_DXXFLAGS := $(strip $(HOST_CXXFLAGS) $(%(mmake)_DXXFLAGS))
770 %(mmake)_CXXIQUOTE:=$(HOST_IQUOTE)
771 %(mmake)_CXXIQUOTE_END:=$(HOST_IQUOTE_END)
773 ifeq (%(compiler),target)
774 %(mmake)_LINK ?= $(strip $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
775 %(mmake)_STRIP ?= $(TARGET_STRIP)
776 %(mmake)_ASSEMBLER ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT))
777 %(mmake)_CXXCMD:=$(strip $(AROS_CXX) $(TARGET_SYSROOT))
778 %(mmake)_MCXX_CPPFLAGS := $(strip $(%(mmake)_MCXX_CPPFLAGS) $(%(mmake)_MCXX_EXTRA_CPPFLAGS))
779 %(mmake)_CXXFLAGS := $(strip $(%(mmake)_CXXFLAGS) $(SAFETY_CFLAGS))
780 %(mmake)_DXXFLAGS := $(%(mmake)_DXXFLAGS)
781 %(mmake)_CXXIQUOTE:=$(CFLAGS_IQUOTE)
782 %(mmake)_CXXIQUOTE_END:=$(CFLAGS_IQUOTE_END)
784 ifeq (%(compiler),kernel)
785 KERNEL_CXX ?= $(KERNEL_CC)
786 %(mmake)_LINK ?= $(strip $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
787 %(mmake)_STRIP ?= $(ECHO) >/dev/null
788 %(mmake)_ASSEMBLER ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
789 %(mmake)_CXXCMD:=$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))
790 %(mmake)_CXXFLAGS := $(strip $(KERNEL_MCXX_CPPFLAGS) $(%(mmake)_MCXX_CPPFLAGS) $(%(mmake)_MCXX_EXTRA_CPPFLAGS))
791 %(mmake)_CXXFLAGS := $(strip $(KERNEL_CXXFLAGS) $(%(mmake)_CXXFLAGS))
792 %(mmake)_DXXFLAGS := $(strip $(KERNEL_CXXFLAGS) $(%(mmake)_DXXFLAGS))
793 %(mmake)_CXXIQUOTE:=$(KERNEL_IQUOTE)
794 %(mmake)_CXXIQUOTE_END:=$(KERNEL_IQUOTE_END)
797 define cxx_multi_recipe_template
799 %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
802 %mkdepend_q cc=$(%(mmake)_CXXCMD) flags="$(strip $(%(mmake)_DXXFLAGS) $(%(mmake)_MCXX_CPPFLAGS))" from=$(2) to=$(1).d
805 $(foreach %(mmake)_CXXFILE,$(%(mmake)_MCXX_FILES),$(eval $(call cxx_multi_recipe_template,$(notdir $(basename $(%(mmake)_CXXFILE))),$(%(mmake)_CXXFILE))))
807 $(foreach %(mmake)_CXXFILE,$(%(mmake)_MCXX_FILES),$(eval $(call cxx_multi_recipe_template,$(addprefix %(targetdir)/,$(notdir $(basename $(%(mmake)_CXXFILE)))),$(%(mmake)_CXXFILE))))
813 #------------------------------------------------------------------------------
816 #------------------------------------------------------------------------------
817 # Generate a rule to compile multiple ObjC source files to an object file and
818 # generate the corresponding dependency files. The generated file will be put
819 # in the object directory without the directory part of the source file.
821 # - basenames: the basenames of the files to compile. The names may include
822 # relative or absolute path names. No wildcard is allowed
823 # - cflags (default $(CFLAGS)): the C flags to use for compilation
824 # - dflags: the flags used during creation of dependency file. If not specified
825 # the same value as cflags will be used
826 # - targetdir: the directory to put the .o file and the .d file. By default
827 # it is put in the same directory as the .m file. When targetdir is not
828 # empty, path names will be stripped from the file names so that all files
829 # are in that dir and not in subdirectories.
830 # - compiler (default target): compiler to use, target, kernel or host
831 %define rule_compile_objc_multi mmake=TMP basenames=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= \
832 targetdir= compiler=target srcdir=
834 ifneq (%(basenames),)
837 %(mmake)_MOBJC_SRCWILDCARD := %
839 %(mmake)_MOBJC_SRCWILDCARD := %(srcdir)/%
843 %(mmake)_MOBJC_TARGETS := $(addsuffix .o,%(basenames))
844 %(mmake)_MOBJC_DTARGETS := $(addsuffix .d,%(basenames))
845 %(mmake)_MOBJC_WILDCARD := %
847 %(mmake)_MOBJC_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,%(basenames)))
848 %(mmake)_MOBJC_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,%(basenames)))
849 %(mmake)_MOBJC_WILDCARD := %(targetdir)/%
851 # Be sure that all .m files are generated
852 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : | $(addsuffix .m,%(basenames))
854 # Be sure that all .m files are found
855 %(mmake)_MOBJC_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
856 %(mmake)_MOBJC_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
857 %(mmake)_MOBJC_DIRS := $(foreach dir, $(%(mmake)_MOBJC_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(%(mmake)_MOBJC_SRCDIR)/$(CURDIR)/$(dir)))
858 ifneq ($(%(mmake)_MOBJC_DIRS),)
859 %(mmake)_MOBJC_DIRS := $(shell echo $(%(mmake)_MOBJC_DIRS) | sed 's/\(.\):\//\/\1\//g')
860 vpath %.m $(%(mmake)_MOBJC_DIRS)
864 # Define the use of cross compiler
865 ifeq ($(TARGET_OBJC),)
866 %(mmake)_CC := $(TARGET_CC)
868 %(mmake)_CC := $(TARGET_OBJC)
871 # Adjust compiler flags to suit ObjC
872 %(mmake)_MOBJC_CPPFLAGS := %(cppflags)
873 %(mmake)_OBJCFLAGS := %(cflags)
874 %(mmake)_OBJCFLAGS := $(%(mmake)_OBJCFLAGS) -isystem $(AROS_DEVELOPER)/include
875 %(mmake)_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(%(mmake)_OBJCFLAGS)))
877 %(mmake)_OBJCDFLAGS := %(cflags)
879 %(mmake)_OBJCDFLAGS := %(dflags)
882 ifeq ($(findstring %(compiler),host kernel target),)
883 $(error unknown compiler %(compiler))
885 ifeq (%(compiler),target)
886 %(mmake)_LINK ?= $(strip $(%(mmake)_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
887 %(mmake)_STRIP ?= $(TARGET_STRIP)
888 %(mmake)_ASSEMBLER ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT))
889 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : CMD:=$(strip $(%(mmake)_CC) $(TARGET_SYSROOT))
890 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_MOBJC_CPPFLAGS:=$(strip $(%(mmake)_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_EXTRA_CPPFLAGS))
891 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCFLAGS:=$(strip $(%(mmake)_OBJCFLAGS) $(SAFETY_CFLAGS))
892 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCDFLAGS:=$(%(mmake)_OBJCDFLAGS)
893 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
894 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
896 ifeq (%(compiler),host)
897 %(mmake)_LINK ?= $(strip $(HOST_OBJC) $(HOST_LDFLAGS))
898 %(mmake)_STRIP ?= $(HOST_STRIP)
899 %(mmake)_ASSEMBLER ?= $(strip $(HOST_CC) $(HOST_SYSROOT))
900 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : CMD:=$(HOST_OBJC)
901 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_MOBJC_CPPFLAGS:=$(strip $(HOST_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_EXTRA_CPPFLAGS))
902 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCFLAGS))
903 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCDFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCDFLAGS))
904 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
905 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
907 ifeq (%(compiler),kernel)
908 KERNEL_OBJC ?= $(KERNEL_CC)
909 %(mmake)_LINK ?= $(strip $(KERNEL_OBJC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
910 %(mmake)_STRIP ?= $(ECHO) >/dev/null
911 %(mmake)_ASSEMBLER ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
912 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : CMD:=$(strip $(KERNEL_OBJC) $(KERNEL_SYSROOT))
913 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_MOBJC_CPPFLAGS:=$(strip $(KERNEL_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_EXTRA_CPPFLAGS))
914 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCFLAGS))
915 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCDFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCDFLAGS))
916 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
917 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
920 $(%(mmake)_MOBJC_TARGETS) : CPPFLAGS := $(%(mmake)_MOBJC_CPPFLAGS)
921 $(%(mmake)_MOBJC_TARGETS) : CFLAGS := $(%(mmake)_OBJCFLAGS)
922 $(%(mmake)_MOBJC_TARGETS) : $(%(mmake)_MOBJC_WILDCARD).o : $(%(mmake)_MOBJC_SRCWILDCARD).m
923 %compile_q cmd=$(CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
925 $(%(mmake)_MOBJC_DTARGETS) : $(%(mmake)_MOBJC_WILDCARD).d : $(%(mmake)_MOBJC_SRCWILDCARD).m
926 %mkdepend_q cc=$(CMD) flags="$(strip $(%(mmake)_OBJCDFLAGS) $(%(mmake)_MOBJC_CPPFLAGS))"
931 #------------------------------------------------------------------------------
934 #------------------------------------------------------------------------------
935 # Make an alias from one arch specific build to another arch.
937 # - mainmmake: the mmake of the module in the main tree
938 # - arch: the current arch
939 # - alias: the alias to which this should point
940 %define rule_archalias mainmmake=\A arch=\A alias=\A
942 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
944 #------------------------------------------------------------------------------
947 #------------------------------------------------------------------------------
948 # Generate a rule to assemble a source file to an object file. Basename may
949 # contain a directory part, then the source file has to be in that directory.
950 # The generated file will be put in the object directory without the directory.
952 # - basename: the basename of the file to compile. Use % for a wildcard rule
953 # - flags (default $(AFLAGS)): the asm flags to use for assembling
954 # - targetdir: the directory to put the .o file in. By default it is put in the
955 # same directory as the .s file
956 %define rule_assemble basename=/A cppflags=$(CPPFLAGS) aflags=$(AFLAGS) targetdir=
959 %(basename).o : CPPFLAGS := %(cppflags)
960 %(basename).o : AFLAGS := %(aflags)
961 %(basename).o : %(basename).s
963 %(basename).o : %(basename).S
967 %(targetdir)/$(notdir %(basename)).o : CPPFLAGS := %(cppflags)
968 %(targetdir)/$(notdir %(basename)).o : AFLAGS := %(aflags)
969 %(targetdir)/$(notdir %(basename)).o : %(basename).s
971 %(targetdir)/$(notdir %(basename)).o : %(basename).S
976 #------------------------------------------------------------------------------
979 #------------------------------------------------------------------------------
980 # Generate a rule to assemble multiple source files to an object file. The
981 # generated file will be put in the object directory with the directory part
982 # of the source file stripped off.
984 # - basenames: the basenames of the files to compile. The names may include
985 # relative or absolute path names. No wildcard is allowed
986 # - aflags (default $(AFLAGS)): the flags to use for assembly
987 # - targetdir: the directory to put the .o file and the .d file. By default
988 # it is put in the same directory as the .c file. When targetdir is not
989 # empty, path names will be stripped from the file names so that all files
990 # are in that dir and not in subdirectories.
991 %define rule_assemble_multi mmake=TMP cmd="$(strip $(CC) $(TARGET_SYSROOT))" basenames=/A cppflags=$(CPPFLAGS) aflags=$(AFLAGS) targetdir= suffix=.s
994 %(mmake)-MA_TARGETS := $(addsuffix .o,%(basenames))
995 %(mmake)-MA_WILDCARD := %
997 %(mmake)-MA_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
998 %(mmake)-MA_WILDCARD := %(targetdir)/%
1000 # Be sure that all .s files are generated
1001 $(%(mmake)-MA_TARGETS) : | $(addsuffix %(suffix),%(basenames))
1003 # Be sure that all .c files are found
1004 %(mmake)-MA_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
1005 %(mmake)-MA_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
1006 %(mmake)-MA_DIRS := $(foreach dir, $(%(mmake)-MA_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(%(mmake)-MA_SRCDIR)/$(CURDIR)/$(dir)))
1007 ifneq ($(%(mmake)-MA_DIRS),)
1008 %(mmake)-MA_DIRS := $(shell echo $(%(mmake)-MA_DIRS) | sed 's/\(.\):\//\/\1\//g')
1009 vpath %%(suffix) $(%(mmake)-MA_DIRS)
1014 %(mmake)-MA_ASSEMBLER ?= %(cmd)
1016 $(%(mmake)-MA_TARGETS) : %(mmake)-MA_CMD:= $(%(mmake)-MA_ASSEMBLER)
1018 $(%(mmake)-MA_TARGETS) : CPPFLAGS := %(cppflags)
1019 $(%(mmake)-MA_TARGETS) : AFLAGS := %(aflags)
1020 $(%(mmake)-MA_TARGETS) : $(%(mmake)-MA_WILDCARD).o : %%(suffix)
1021 %assemble_q cmd=$(%(mmake)-MA_CMD)
1023 #------------------------------------------------------------------------------
1026 #------------------------------------------------------------------------------
1027 # Link %(objs) to %(prog) using the libraries in %(uselibs)
1028 %define rule_link_prog mmake=TMP prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
1029 usehostlibs= usestartup=yes detach=no nix=no cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" strip=$(TARGET_STRIP) objdir=$(GENDIR)/$(CURDIR) coverageinstr=$(TARGET_COVERAGEINSTR)
1031 %(mmake)-link_EXTRA_LDFLAGS :=
1032 %(mmake)-link_EXTRA_LIBS :=
1034 %(mmake)-link_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
1036 ifeq (%(usestartup),no)
1037 %(mmake)-link_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
1039 ifeq (%(detach),yes)
1040 %(mmake)-link_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
1043 # Make a list of the lib files this program depends on.
1044 # In LDFLAGS remove white space between -L and directory
1045 %(mmake)-link_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
1046 # Filter out only the libdirs and remove -L
1047 %(mmake)-link_DIRS := $(patsubst -L%,%,$(filter -L%,$(%(mmake)-link_DIRS)))
1049 %(mmake)-link_DIRS := $(subst //,/,$(addsuffix /,$(%(mmake)-link_DIRS)))
1050 # Add normal linklib path
1051 %(mmake)-link_DIRS += $(AROS_LIB)/
1052 # add lib and .a to static linklib names
1053 %(mmake)-link_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(%(mmake)-link_EXTRA_LIBS)))
1054 ifeq (%(usestartup),yes)
1055 %(mmake)-link_LIBS += startup.o
1057 ifeq (%(detach),yes)
1058 %(mmake)-link_LIBS += detach.o
1060 # search for the linklibs in the given path, ignore ones not found
1061 %(mmake)-link_DEPLIBS := $(foreach lib,$(%(mmake)-link_LIBS), \
1062 $(firstword $(wildcard $(addsuffix $(lib),$(%(mmake)-link_DIRS)))) \
1065 %(prog) : OBJDIR := %(objdir)
1066 %(prog) : OBJS := %(objs)
1067 %(prog) : LDFLAGS := $(strip %(ldflags) $(%(mmake)-link_EXTRA_LDFLAGS))
1068 %(prog) : LIBS := $(addprefix -l,%(uselibs) $(%(mmake)-link_EXTRA_LIBS) %(usehostlibs))
1069 %(prog) : %(objs) $(%(mmake)-link_DEPLIBS)
1070 %link_q cmd="%(cmd)" strip="%(strip)" from=$(OBJS) opt=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR) coverageinstr=%(coverageinstr)
1072 #------------------------------------------------------------------------------
1075 #------------------------------------------------------------------------------
1076 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
1077 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
1078 %define rule_link_progs mmake=TMP progs=/A targetdir=$(AROSDIR)/$(CURDIR) nix=%(nix) \
1079 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
1080 usestartup=yes detach=no cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" strip=$(TARGET_STRIP) coverageinstr=$(TARGET_COVERAGEINSTR)
1082 %(mmake)-link_EXTRA_LDFLAGS :=
1083 %(mmake)-link_EXTRA_LIBS :=
1085 %(mmake)-link_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
1087 ifeq (%(usestartup),no)
1088 %(mmake)-link_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
1090 ifeq (%(detach),yes)
1091 %(mmake)-link_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
1094 # Make a list of the lib files the programs depend on.
1095 # In LDFLAGS remove white space between -L and directory
1096 %(mmake)-link_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
1097 # Filter out only the libdirs and remove -L
1098 %(mmake)-link_DIRS := $(patsubst -L%,%,$(filter -L%,$(%(mmake)-link_DIRS)))
1100 %(mmake)-link_DIRS := $(subst //,/,$(addsuffix /,$(%(mmake)-link_DIRS)))
1101 # Add normal linklib path
1102 %(mmake)-link_DIRS += $(AROS_LIB)/
1103 # add lib and .a to static linklib names
1104 %(mmake)-link_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(%(mmake)-link_EXTRA_LIBS)))
1105 # search for the linklibs in the given path, ignore ones not found
1106 %(mmake)-link_DEPLIBS := $(foreach lib,$(%(mmake)-link_LIBS), \
1107 $(firstword $(wildcard $(addsuffix $(lib),$(%(mmake)-link_DIRS)))) \
1109 %(mmake)-link_PROGS := $(addprefix %(targetdir)/,%(progs))
1111 $(%(mmake)-link_PROGS) : OBJDIR := %(objdir)
1112 $(%(mmake)-link_PROGS) : LDFLAGS := $(strip %(ldflags) $(%(mmake)-link_EXTRA_LDFLAGS))
1113 $(%(mmake)-link_PROGS) : LIBS := $(addprefix -l,%(uselibs) $(%(mmake)-link_EXTRA_LIBS) %(usehostlibs))
1114 $(%(mmake)-link_PROGS) : %(targetdir)/% : %(objdir)/%.o $(%(mmake)-link_DEPLIBS)
1115 %link_q cmd="%(cmd)" strip="%(strip)" from=$< opt=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR) coverageinstr=%(coverageinstr)
1117 #------------------------------------------------------------------------------
1120 #------------------------------------------------------------------------------
1121 # Link the %(objs) to the library %(libdir)/lib%(libname).a
1122 %define rule_link_linklib mmake=TMP libname=/A objs=/A libdir=$(AROS_LIB) linker=target
1124 ifeq (%(linker),target)
1125 %(libdir)/lib%(libname).a : %(mmake)_AR:=$(AR)
1126 %(libdir)/lib%(libname).a : %(mmake)_RANLIB:=$(RANLIB)
1128 ifeq (%(linker),host)
1129 %(libdir)/lib%(libname).a : %(mmake)_AR:=$(HOST_AR)
1130 %(libdir)/lib%(libname).a : %(mmake)_RANLIB:=$(HOST_RANLIB)
1132 ifeq (%(linker),kernel)
1133 %(libdir)/lib%(libname).a : %(mmake)_AR:=$(KERNEL_AR)
1134 %(libdir)/lib%(libname).a : %(mmake)_RANLIB:=$(KERNEL_RANLIB)
1137 %(libdir)/lib%(libname).a : %(objs)
1138 %mklib_q from=$^ ar=$(%(mmake)_AR) ranlib=$(%(mmake)_RANLIB)
1140 #------------------------------------------------------------------------------
1142 #------------------------------------------------------------------------------
1143 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
1144 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
1145 %define rule_linkmodule mmake=TMP module=/A objs=/A endobj=/A err=/A objdir=$(OBJDIR) \
1146 cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" ldflags=$(LDFLAGS) uselibs= usehostlibs=
1148 %(mmake)_LDFLAGS := %(ldflags)
1149 # Make a list of the lib files the programs depend on.
1150 # In LDFLAGS remove white space between -L and directory
1151 %(mmake)_DIRS := $(subst -L ,-L,$(strip $(%(mmake)_LDFLAGS)))
1152 # Filter out only the libdirs and remove -L
1153 %(mmake)_DIRS := $(patsubst -L%,%,$(filter -L%,$(%(mmake)_DIRS)))
1155 %(mmake)_DIRS := $(subst //,/,$(addsuffix /,$(%(mmake)_DIRS)))
1156 # Add normal linklib path
1157 %(mmake)_DIRS += $(AROS_LIB)/
1158 # add lib and .a to static linklib names
1159 %(mmake)_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
1160 # search for the linklibs in the given path, ignore ones not found
1161 %(mmake)_DEPLIBS := $(foreach lib,$(%(mmake)_LIBS), \
1162 $(firstword $(wildcard $(addsuffix $(lib),$(%(mmake)_DIRS)))) \
1165 %(module) : LIB_NAMES := %(uselibs)
1166 %(module) : OBJS := %(objs)
1167 %(module) : ENDTAG := %(endobj)
1168 %(module) : ERR := %(err)
1169 %(module) : OBJDIR := %(objdir)
1170 %(module) : LDFLAGS := $(%(mmake)_LDFLAGS)
1171 ifeq (%(usehostlibs),)
1172 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES))
1174 # Warning: the -L/usr/lib here can result in modules
1175 # linking against host libs instead of AROS libs (e.g stdc++) !!
1176 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES)) \
1177 -L/usr/lib $(addprefix -l,%(usehostlibs))
1179 %(module) : %(objs) %(endobj) $(%(mmake)_DEPLIBS) $(USER_DEPLIBS)
1180 %link_module_q cmd="%(cmd)" err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS) objdir=$(OBJDIR) ldflags=$(LDFLAGS)
1183 #------------------------------------------------------------------------------
1186 #------------------------------------------------------------------------------
1187 # Generate the libdefs.h include file for a module.
1188 %define rule_genmodule_genlibdefs mmake=TMP modname=/A version= flavour= modtype=/A modsuffix= conffile= targetdir=
1192 %(mmake)_OPTS += -f %(flavour)
1193 %(mmake)_MODNAME := %(modname)_%(flavour)
1195 %(mmake)_MODNAME := %(modname)
1197 %(mmake)_TARGET := $(%(mmake)_MODNAME)_libdefs.h
1198 %(mmake)_DEPS := $(GENMODULE)
1199 ifneq (%(conffile),)
1200 ifeq ($(dir %(conffile)),./)
1201 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1202 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1204 %(mmake)_OPTS += -c %(conffile)
1205 %(mmake)_DEPS += %(conffile)
1208 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1209 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1211 ifneq (%(modsuffix),)
1212 %(mmake)_OPTS += -s %(modsuffix)
1214 ifneq (%(targetdir),)
1215 %(mmake)_OPTS += -d %(targetdir)
1216 %(mmake)_TARGET := %(targetdir)/$(%(mmake)_TARGET)
1219 %(mmake)_OPTS += -v %(version)
1222 $(%(mmake)_TARGET) : OPTS := $(%(mmake)_OPTS)
1223 $(%(mmake)_TARGET) : MODNAME := %(modname)
1224 $(%(mmake)_TARGET) : MODTYPE := %(modtype)
1225 $(%(mmake)_TARGET) : $(%(mmake)_DEPS)
1226 $(Q)$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1227 $(Q)$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
1229 #------------------------------------------------------------------------------
1231 #------------------------------------------------------------------------------
1232 # Generate the _lib.fd file for a module.
1233 %define rule_genmodule_fd mmake=TMP modname=/A modtype=/A modsuffix= conffile= targetdir=
1235 %(mmake)_TARGET := %(modname)_lib.fd
1236 %(mmake)_DEPS := $(GENMODULE)
1238 ifneq (%(conffile),)
1239 ifeq ($(dir %(conffile)),./)
1240 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1241 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1243 %(mmake)_OPTS += -c %(conffile)
1244 %(mmake)_DEPS += %(conffile)
1247 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1248 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1250 ifneq (%(modsuffix),)
1251 %(mmake)_OPTS += -s %(modsuffix)
1253 ifneq (%(targetdir),)
1254 %(mmake)_OPTS += -d %(targetdir)
1255 %(mmake)_TARGET := %(targetdir)/$(%(mmake)_TARGET)
1258 $(%(mmake)_TARGET) : OPTS := $(%(mmake)_OPTS)
1259 $(%(mmake)_TARGET) : MODNAME := %(modname)
1260 $(%(mmake)_TARGET) : MODTYPE := %(modtype)
1261 $(%(mmake)_TARGET) : $(%(mmake)_DEPS)
1262 $(Q)$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1263 $(Q)$(GENMODULE) $(OPTS) writefd $(MODNAME) $(MODTYPE)
1265 #------------------------------------------------------------------------------
1267 #------------------------------------------------------------------------------
1268 # Generate a Makefile.%(modname)%(modtype) with the genmodule program and include this
1269 # generated file in this Makefile
1270 %define rule_genmodule_makefile mmake=TMP modname=/A flavour= modtype=/A modsuffix= conffile= \
1275 %(mmake)_OPTS += -f %(flavour)
1276 %(mmake)_MODNAME := %(modname)_%(flavour)
1278 %(mmake)_MODNAME := %(modname)
1280 %(mmake)_TARGET := Makefile.$(%(mmake)_MODNAME)%(modtype)
1281 %(mmake)_DEPS := $(GENMODULE)
1282 ifneq (%(conffile),)
1283 ifeq ($(dir %(conffile)),./)
1284 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1285 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1287 %(mmake)_OPTS += -c %(conffile)
1288 %(mmake)_DEPS += %(conffile)
1291 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1292 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1294 ifneq (%(modsuffix),)
1295 %(mmake)_OPTS += -s %(modsuffix)
1297 ifneq (%(targetdir),)
1298 %(mmake)_OPTS += -d %(targetdir)
1299 %(mmake)_TARGET := %(targetdir)/$(%(mmake)_TARGET)
1302 $(%(mmake)_TARGET) : OPTS := $(%(mmake)_OPTS)
1303 $(%(mmake)_TARGET) : MODNAME := %(modname)
1304 $(%(mmake)_TARGET) : MODTYPE := %(modtype)
1305 $(%(mmake)_TARGET) : $(%(mmake)_DEPS)
1306 $(Q)$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
1308 #------------------------------------------------------------------------------
1311 #------------------------------------------------------------------------------
1312 # Generate the support files for compiling a module. This includes include
1313 # files and source files. This rule has to be preceeded by
1314 # %rule_genmodule_makefile
1315 %define rule_genmodule_files mmake=TMP modname=/A flavour= modtype=/A modsuffix= targetdir= stubdir= \
1320 %(mmake)_OPTS += -f %(flavour)
1321 %(mmake)_MODNAME := %(modname)_%(flavour)
1323 %(mmake)_MODNAME := %(modname)
1325 %(mmake)_GENTARGETS := $($(%(mmake)_MODNAME)_STARTFILES) $($(%(mmake)_MODNAME)_ENDFILES)
1326 %(mmake)_STUBTARGETS := $($(%(mmake)_MODNAME)_LINKLIBFILES) $($(%(mmake)_MODNAME)_RELLINKLIBFILES)
1327 %(mmake)_GENTARGETS := $(addsuffix .c,$(%(mmake)_GENTARGETS))
1328 %(mmake)_STUBTARGETS := $(addsuffix .c,$(%(mmake)_STUBTARGETS)) \
1329 $(addsuffix .S, $($(%(mmake)_MODNAME)_LINKLIBAFILES) $($(%(mmake)_MODNAME)_RELLINKLIBAFILES))
1331 %(mmake)_DEPS := $(GENMODULE)
1332 ifneq (%(conffile),)
1333 ifeq ($(dir %(conffile)),./)
1334 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1335 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1337 %(mmake)_OPTS += -c %(conffile)
1338 %(mmake)_DEPS += %(conffile)
1341 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1342 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1344 ifneq (%(modsuffix),)
1345 %(mmake)_OPTS += -s %(modsuffix)
1347 ifneq (%(targetdir),)
1348 %(mmake)_OPTS += -d %(targetdir)
1349 %(mmake)_TARGETDIR := $(shell echo %(targetdir) | sed 's/^\(.\):\//\/\1\//')
1350 %(mmake)_GENTARGETS := $(addprefix $(%(mmake)_TARGETDIR)/,$(%(mmake)_GENTARGETS))
1351 %(mmake)_GENFILEFLAG=$(%(mmake)_TARGETDIR)/.%(modname).%(modtype)-genfiles
1353 %(mmake)_GENFILEFLAG=$(GENDIR)/$(CURDIR)/.%(modname).%(modtype)-genfiles
1356 %(mmake)_OPTS += -l %(stubdir)
1357 %(mmake)_STUBTARGETDIR := $(shell echo %(stubdir) | sed 's/^\(.\):\//\/\1\//')
1358 %(mmake)_STUBTARGETS := $(addprefix $(%(mmake)_STUBTARGETDIR)/,$(%(mmake)_STUBTARGETS))
1359 %(mmake)_TARGETDIRS += %(stubdir)
1361 ifneq (%(targetdir),)
1362 %(mmake)_STUBTARGETS := $(addprefix $(%(mmake)_TARGETDIR)/,$(%(mmake)_STUBTARGETS))
1366 %(mmake)_TARGETS := $(%(mmake)_GENTARGETS) $(%(mmake)_STUBTARGETS)
1367 ifneq ($(%(mmake)_TARGETDIRS),)
1368 $(%(mmake)_TARGETS) : | $(%(mmake)_TARGETDIRS)
1371 $(%(mmake)_TARGETS) : $(%(mmake)_DEPS) $(%(mmake)_GENFILEFLAG)
1373 $(%(mmake)_GENFILEFLAG) : OPTS := $(%(mmake)_OPTS)
1374 $(%(mmake)_GENFILEFLAG) : MODNAME := %(modname)
1375 $(%(mmake)_GENFILEFLAG) : MODTYPE := %(modtype)
1376 $(%(mmake)_GENFILEFLAG) : $(%(mmake)_DEPS)
1377 $(Q)$(ECHO) "Generating support files for module $(MODNAME$(BDID))"
1378 $(Q)$(IF) $(TEST) "%(conffile)" = "lib.conf" && $(TEST) -f lib.conf; then \
1379 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
1381 $(Q)$(IF) $(TEST) -f libdefs.h; then \
1382 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
1384 $(Q)$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
1387 #------------------------------------------------------------------------------
1390 #------------------------------------------------------------------------------
1391 # Generate the support files for compiling a module. This includes include
1392 # files and source files.
1393 %define rule_genmodule_includes mmake=TMP modname=/A flavour= modtype=/A modsuffix= \
1394 targetdir= conffile=
1397 %(mmake)_MODNAME := %(modname)_%(flavour)
1399 %(mmake)_MODNAME := %(modname)
1402 ifneq ($($(%(mmake)_MODNAME)_INCLUDES),)
1404 %(mmake)_TARGETS := $($(%(mmake)_MODNAME)_INCLUDES)
1406 %(mmake)_DEPS := $(GENMODULE)
1409 ifneq (%(conffile),)
1410 ifeq ($(dir %(conffile)),./)
1411 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1412 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1414 %(mmake)_OPTS += -c %(conffile)
1415 %(mmake)_DEPS += %(conffile)
1418 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1419 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1421 ifneq (%(modsuffix),)
1422 %(mmake)_OPTS += -s %(modsuffix)
1424 ifneq (%(targetdir),)
1425 %(mmake)_OPTS += -d %(targetdir)
1426 %(mmake)_TARGETS := $(addprefix %(targetdir)/,$(%(mmake)_TARGETS))
1427 %(mmake)_GENINCFLAG=%(targetdir)/.%(modname).%(modtype)-includes
1429 %(mmake)_GENINCFLAG=$(GENDIR)/$(CURDIR)/.%(modname).%(modtype)-includes
1432 $(%(mmake)_TARGETS) : $(%(mmake)_DEPS) $(%(mmake)_GENINCFLAG)
1434 $(%(mmake)_GENINCFLAG) : OPTS := $(%(mmake)_OPTS)
1435 $(%(mmake)_GENINCFLAG) : MODNAME := %(modname)
1436 $(%(mmake)_GENINCFLAG) : MODTYPE := %(modtype)
1437 $(%(mmake)_GENINCFLAG) : $(%(mmake)_DEPS)
1438 $(Q)$(ECHO) "Generating $(MODNAME).$(MODTYPE) includes"
1439 $(Q)$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
1443 #------------------------------------------------------------------------------
1445 #------------------------------------------------------------------------------
1446 # Link %(objs) to binary blob in %(file) using %(name) as name of embedded binary object
1447 # 'start' is an optional starting address
1448 # 'ldflags' is optional additional flags for the linker
1449 %define rule_link_binary mmake=BD file=/A name=/A objs= files= start=0 ldflags=
1451 %(mmake)_OUTDIR := $(dir %(file))
1452 # This trick removes the trailing '/', otherwise findstring below fails, causing a warning
1453 %(mmake)_OUTDIR := $(subst /*,,$(addsuffix *,$(%(mmake)_OUTDIR)))
1454 %(mmake)_TMPDIR := $(GENDIR)/$(CURDIR)
1455 %(mmake)_OBJS := $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir %(files))))
1456 %(mmake)_DEPS := $(addsuffix .d,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir %(files))))
1457 %(mmake)_OBJS += %(objs)
1459 %rule_compile_multi basenames="%(files)" targetdir=$(%(mmake)_OBJDIR)
1461 %(file) : $(%(mmake)_OBJS) $(%(mmake)_DEPS)
1462 $(Q)$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)..."
1463 $(Q)$(KERNEL_LD) %(ldflags) --entry=%(start) --oformat=binary -Ttext=%(start) -o $(%(mmake)_TMPDIR)/%(name) $(%(mmake)_OBJS)
1464 $(Q)cd $(%(mmake)_TMPDIR) && $(AROS_LD) %(ldflags) -r --format binary %(name) -o $@
1466 ifeq ($(findstring $(%(mmake)_OUTDIR),$(GLOB_MKDIRS)),)
1467 %rule_makedirs dirs="$(%(mmake)_OUTDIR)" setuptarget=%(file)
1472 #------------------------------------------------------------------------------
1473 # Common rules for all makefiles
1475 # Delete generated makefiles
1478 $(Q)$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
1480 include $(SRCDIR)/config/make.tail
1482 BDID := $(BDTARGETID)
1484 #------------------------------------------------------------------------------
1487 #############################################################################
1488 #############################################################################
1490 ## Here are the mmakefile build macros. These are macros that takes care ##
1491 ## of everything to go from the sources to the generated target. Also all ##
1492 ## intermediate files and directories that are needed are created by these ##
1495 #############################################################################
1496 #############################################################################
1498 #------------------------------------------------------------------------------
1500 %define build_prog mmake=/A progname=/A files= cxxfiles= \
1502 asmfiles= objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1503 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= ldflags=$(LDFLAGS) \
1504 aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
1505 includedir= libdir= \
1506 compiler=target linker= \
1507 coverageinstr=$(TARGET_COVERAGEINSTR) funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO)
1511 %(mmake)_PROGNAME := %(progname)
1512 %(mmake)_OBJDIR := %(objdir)
1513 %(mmake)_TARGETDIR := %(targetdir)
1514 %(mmake)_LINKER := %(linker)
1515 %(mmake)_LIBS := %(uselibs)
1516 # If not supplied, linker is equal to compiler
1517 ifeq ($(%(mmake)_LINKER),)
1518 %(mmake)_LINKER := %(compiler)
1521 ifneq ("$(strip %(files) %(cxxfiles) %(objcfiles) %(asmfiles))","")
1522 %(mmake)_FILES := %(files)
1523 %(mmake)_OBJCFILES := %(objcfiles)
1524 %(mmake)_ASMFILES := %(asmfiles)
1525 %(mmake)_CXXFILES := %(cxxfiles)
1527 %(mmake)_FILES := $(%(mmake)_PROGNAME)
1528 %(mmake)_OBJCFILES :=
1529 %(mmake)_ASMFILES :=
1530 %(mmake)_CXXFILES :=
1533 %(mmake)_ARCHOBJS := $(wildcard $(%(mmake)_OBJDIR)/arch/*.o)
1534 %(mmake)_ARCHFILES := $(basename $(notdir $(%(mmake)_ARCHOBJS)))
1535 %(mmake)_C_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_FILES))
1536 %(mmake)_CXX_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_CXXFILES))
1537 %(mmake)_OBJC_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_OBJCFILES))
1539 TMP_FILES := $(%(mmake)_C_NARCHFILES) $(%(mmake)_CXX_NARCHFILES) $(%(mmake)_ASMFILES) $(%(mmake)_OBJC_NARCHFILES)
1540 %(mmake)_OBJS := $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir $(TMP_FILES))))
1541 %(mmake)_DEPS := $(addsuffix .d,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir $(TMP_FILES))))
1543 %(mmake)_CPPFLAGS := %(cppflags)
1544 ifneq (%(includedir),)
1545 %(mmake)_CPPFLAGS += -I%(includedir)
1547 %(mmake)_CFLAGS := %(cflags)
1548 %(mmake)_CXXFLAGS := %(cxxflags)
1549 %(mmake)_COVERAGE := no
1550 ifeq (%(compiler),target)
1551 ifeq (%(usestartup),yes)
1552 ifeq (%(coverageinstr),yes)
1553 %(mmake)_COVERAGE := yes
1554 %(mmake)_COVERAGEFLAGS ?= $(COVERAGEINSTR_FLAGS)
1555 %(mmake)_COVERAGELIBS ?= $(COVERAGEINSTR_LIBS)
1556 %(mmake)_CFLAGS := $(strip $(%(mmake)_COVERAGEFLAGS) $(%(mmake)_CFLAGS))
1557 %(mmake)_CXXFLAGS := $(strip $(%(mmake)_COVERAGEFLAGS) $(%(mmake)_CXXFLAGS))
1558 %(mmake)_LIBS += $(%(mmake)_COVERAGELIBS)
1560 ifeq (%(funcinstr),yes)
1561 %(mmake)_FUNCINSTR := yes
1562 %(mmake)_INSTRFUNCFLAGS ?= $(FUNCINSTR_FLAGS)
1563 %(mmake)_INSTRFUNCLIBS ?= $(FUNCINSTR_LIBS)
1564 %(mmake)_CFLAGS := $(strip $(%(mmake)_INSTRFUNCFLAGS) $(%(mmake)_CFLAGS))
1565 %(mmake)_CXXFLAGS := $(strip $(%(mmake)_INSTRFUNCFLAGS) $(%(mmake)_CXXFLAGS))
1566 %(mmake)_LIBS += $(%(mmake)_INSTRFUNCLIBS)
1570 %(mmake)_CFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(%(mmake)_CFLAGS))
1571 %(mmake)_CXXFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(%(mmake)_CXXFLAGS))
1574 %(mmake)_AFLAGS := %(aflags)
1576 %(mmake)_DFLAGS := %(dflags)
1578 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
1580 ifneq (%(dxxflags),)
1581 %(mmake)_DXXFLAGS := %(dxxflags)
1583 %(mmake)_DXXFLAGS := $(%(mmake)_CXXFLAGS)
1585 %(mmake)_LDFLAGS := %(ldflags)
1587 %(mmake)_LDFLAGS += -L%(libdir)
1591 %(mmake)-quick : %(mmake)
1593 #MM %(mmake) : includes-generate-deps core-linklibs
1594 %(mmake) : $(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME)
1596 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick %(mmake)-gz-quick),)
1597 %rule_compile_cxx_multi mmake=%(mmake) \
1598 basenames=$(%(mmake)_CXX_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
1599 cppflags=$(%(mmake)_CPPFLAGS) cxxflags=$(%(mmake)_CXXFLAGS) dxxflags=$(%(mmake)_DXXFLAGS) \
1600 compiler="%(compiler)"
1601 %rule_compile_objc_multi mmake=%(mmake) \
1602 basenames=$(%(mmake)_OBJC_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
1603 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
1604 compiler="%(compiler)"
1605 %rule_compile_multi mmake=%(mmake) \
1606 basenames=$(%(mmake)_C_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
1607 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
1608 compiler="%(compiler)"
1609 %rule_assemble_multi mmake=%(mmake) \
1610 cmd=$(%(mmake)_ASSEMBLER) basenames=$(%(mmake)_ASMFILES) targetdir=$(%(mmake)_OBJDIR) \
1611 cppflags=$(%(mmake)_CPPFLAGS) aflags=$(%(mmake)_AFLAGS)
1613 %rule_link_prog mmake=%(mmake) prog=$(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME) \
1614 objs="$(%(mmake)_OBJS) $(%(mmake)_ARCHOBJS) $(USER_OBJS)" ldflags=$(%(mmake)_LDFLAGS) \
1615 uselibs="$(%(mmake)_LIBS)" usehostlibs="%(usehostlibs)" \
1616 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)" \
1617 cmd=$(%(mmake)_LINK) strip=$(%(mmake)_STRIP) objdir=$(%(mmake)_OBJDIR) coverageinstr=$(%(mmake)_COVERAGE)
1621 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(%(mmake)_DEPS)
1623 %rule_makedirs dirs="$(%(mmake)_OBJDIR) $(%(mmake)_TARGETDIR)" setuptarget="$(%(mmake)_OBJS) $(%(mmake)_DEPS) $(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME)"
1625 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME) $(%(mmake)_DEPS)
1628 $(Q)$(ECHO) "Cleaning up for metatarget %(mmake)"
1632 #------------------------------------------------------------------------------
1635 #------------------------------------------------------------------------------
1636 # Build programs, for every C file an executable will be built with the same
1637 # name as the C file
1638 %define build_progs mmake=/A files=/A nix=no \
1639 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1640 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= ldflags=$(LDFLAGS) \
1641 includedir= libdir= \
1643 uselibs= usehostlibs= usestartup=yes detach=no \
1644 coverageinstr=$(TARGET_COVERAGEINSTR) funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO)
1648 %(mmake)_OBJDIR := %(objdir)
1649 %(mmake)_TARGETDIR := %(targetdir)
1650 %(mmake)_LIBS := %(uselibs)
1652 %(mmake)_FILES := %(files)
1653 %(mmake)_OBJS := $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/,$(%(mmake)_FILES)))
1654 %(mmake)_DEPS := $(addsuffix .d,$(addprefix $(%(mmake)_OBJDIR)/,$(%(mmake)_FILES)))
1655 %(mmake)_EXES := $(addprefix $(%(mmake)_TARGETDIR)/,$(%(mmake)_FILES))
1657 %(mmake)_CPPFLAGS := %(cppflags)
1658 ifneq (%(includedir),)
1659 %(mmake)_CPPFLAGS += -I%(includedir)
1661 %(mmake)_CFLAGS := %(cflags)
1662 %(mmake)_COVERAGE := no
1663 ifeq (%(compiler),target)
1664 ifeq (%(usestartup),yes)
1665 ifeq (%(coverageinstr),yes)
1666 %(mmake)_COVERAGE := yes
1667 %(mmake)_COVERAGEFLAGS ?= $(COVERAGEINSTR_FLAGS)
1668 %(mmake)_COVERAGELIBS ?= $(COVERAGEINSTR_LIBS)
1669 %(mmake)_CFLAGS := $(strip $(%(mmake)_COVERAGEFLAGS) $(%(mmake)_CFLAGS))
1670 %(mmake)_LIBS += $(%(mmake)_COVERAGELIBS)
1672 ifeq (%(funcinstr),yes)
1673 %(mmake)_FUNCINSTR := yes
1674 %(mmake)_INSTRFUNCFLAGS ?= $(FUNCINSTR_FLAGS)
1675 %(mmake)_INSTRFUNCLIBS ?= $(FUNCINSTR_LIBS)
1676 %(mmake)_CFLAGS := $(strip $(%(mmake)_INSTRFUNCFLAGS) $(%(mmake)_CFLAGS))
1677 %(mmake)_LIBS += $(%(mmake)_INSTRFUNCLIBS)
1681 %(mmake)_CFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(%(mmake)_CFLAGS))
1685 %(mmake)_DFLAGS := %(dflags)
1687 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
1689 %(mmake)_LDFLAGS := %(ldflags)
1691 %(mmake)_LDFLAGS += -L%(libdir)
1695 %(mmake)-quick : %(mmake)
1697 #MM %(mmake) : includes-generate-deps core-linklibs
1698 %(mmake) : $(%(mmake)_EXES)
1700 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1701 %rule_compile_multi mmake=%(mmake) basenames=$(%(mmake)_FILES) targetdir=$(%(mmake)_OBJDIR) \
1702 cflags=$(%(mmake)_CFLAGS) cppflags=$(%(mmake)_CPPFLAGS) dflags=$(%(mmake)_DFLAGS) compiler="%(compiler)"
1704 %rule_link_progs mmake=%(mmake) progs=$(%(mmake)_FILES) nix="%(nix)" \
1705 targetdir=$(%(mmake)_TARGETDIR) objdir=$(%(mmake)_OBJDIR) \
1706 ldflags=$(%(mmake)_LDFLAGS) \
1707 uselibs="$(%(mmake)_LIBS)" usehostlibs="%(usehostlibs)" \
1708 usestartup="%(usestartup)" detach="%(detach)" \
1709 cmd=$(%(mmake)_LINK) strip=$(%(mmake)_STRIP) objdir=$(%(mmake)_OBJDIR) coverageinstr=$(%(mmake)_COVERAGE)
1713 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(%(mmake)_DEPS)
1715 %rule_makedirs dirs="$(%(mmake)_TARGETDIR) $(%(mmake)_OBJDIR)" setuptarget="$(%(mmake)_DEPS) $(%(mmake)_OBJS) $(addprefix $(%(mmake)_TARGETDIR)/,$(%(mmake)_FILES))"
1717 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_EXES) $(%(mmake)_DEPS)
1720 $(Q)$(ECHO) "Cleaning up for metatarget %(mmake)"
1724 #------------------------------------------------------------------------------
1727 #------------------------------------------------------------------------------
1729 # This is a bare version: It just compiles and links the given files. It is
1730 # assumed that all needed boiler plate code is in the files. This should only
1731 # be used for compiling external code. For AROS code use %build_module
1732 %define build_module_simple mmake=/A modname=/A modtype=/A \
1733 files="$(basename $(call WILDCARD, *.c))" \
1735 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
1736 cppflags=$(CPPFLAGS) \
1737 cflags=$(CFLAGS) dflags= \
1738 cxxflags=$(CXXFLAGS) dxxflags= \
1739 objdir=$(OBJDIR) moduledir= \
1740 uselibs= usehostlibs= compiler=target funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO)
1742 # Define metamake targets and their dependencies
1743 #MM %(mmake) : core-linklibs includes-generate-deps
1744 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1745 #MM %(mmake)-kobj-quick
1749 %(mmake)_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj
1751 .PHONY : $(%(mmake)_ALLTARGETS)
1754 $(error using %build_module_simple: modname may not be empty)
1757 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1760 # Default values for variables and arguments
1761 %(mmake)_DEFLINKLIBNAME := %(modname)
1762 %(mmake)_CFLAGS := %(cflags)
1763 %(mmake)_CXXFLAGS := %(cxxflags)
1764 ifeq (%(compiler),target)
1766 %(mmake)_CFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(%(mmake)_CFLAGS))
1768 ifeq (%(funcinstr),yes)
1769 %(mmake)_FUNCINSTR := yes
1770 %(mmake)_CFLAGS := $(strip $(FUNCINSTR_FLAGS) $(%(mmake)_CFLAGS))
1774 %(mmake)_DFLAGS := %(dflags)
1776 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
1778 %(mmake)_DEFDXXFLAGS := %(dxxflags)
1779 OBJDIR ?= $(GENDIR)/$(CURDIR)
1780 %(mmake)_MODDIR := %(moduledir)
1781 ifeq ($(%(mmake)_MODDIR),)
1782 ifeq (%(modtype),library)
1783 %(mmake)_MODDIR := $(AROS_LIBRARIES)
1785 ifeq (%(modtype),gadget)
1786 %(mmake)_MODDIR := $(AROS_GADGETS)
1788 ifeq (%(modtype),datatype)
1789 %(mmake)_MODDIR := $(AROS_DATATYPES)
1791 ifeq (%(modtype),handler)
1792 %(mmake)_MODDIR := $(AROS_FS)
1794 ifeq (%(modtype),device)
1795 %(mmake)_MODDIR := $(AROS_DEVS)
1797 ifeq (%(modtype),resource)
1798 %(mmake)_MODDIR := $(AROS_RESOURCES)
1800 ifeq (%(modtype),hook)
1801 %(mmake)_MODDIR := $(AROS_RESOURCES)
1803 ifeq (%(modtype),mui)
1804 %(mmake)_MODDIR := $(AROS_CLASSES)/Zune
1806 ifeq (%(modtype),mcc)
1807 %(mmake)_MODDIR := $(AROS_CLASSES)/Zune
1809 ifeq (%(modtype),mcp)
1810 %(mmake)_MODDIR := $(AROS_CLASSES)/Zune
1812 ifeq (%(modtype),usbclass)
1813 %(mmake)_MODDIR := $(AROS_CLASSES)/USB
1815 ifeq (%(modtype),hidd)
1816 %(mmake)_MODDIR := $(AROS_DRIVERS)
1818 ifeq (%(modtype),printer)
1819 %(mmake)_MODDIR := $(AROS_PRINTERS)
1822 ifeq ($(%(mmake)_MODDIR),)
1823 $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1826 %(mmake)_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1827 %(mmake)_ARCHFILES := $(basename $(notdir $(%(mmake)_ARCHOBJS)))
1828 %(mmake)_C_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),%(files))
1829 %(mmake)_CXX_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),%(cxxfiles))
1830 %(mmake)_OBJC_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),%(objcfiles))
1832 %rule_compile_cxx_multi mmake=%(mmake) \
1833 basenames=$(%(mmake)_CXX_NARCHFILES) targetdir="%(objdir)" \
1834 cppflags="%(cppflags)" cxxflags=$(%(mmake)_CXXFLAGS) dxxflags=$(%(mmake)_DXXFLAGS) \
1835 compiler="%(compiler)"
1836 %rule_compile_objc_multi mmake=%(mmake) \
1837 basenames=$(%(mmake)_OBJC_NARCHFILES) targetdir="%(objdir)" \
1838 cppflags="%(cppflags)" cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
1839 compiler="%(compiler)"
1840 %rule_compile_multi mmake=%(mmake) \
1841 basenames=$(%(mmake)_C_NARCHFILES) targetdir="%(objdir)" \
1842 cppflags="%(cppflags)" cflags="$(%(mmake)_CFLAGS)" dflags="$(%(mmake)_DFLAGS)" \
1843 compiler="%(compiler)"
1845 # Handlers use dash instead of dot in their names
1846 ifeq (%(modtype),handler)
1847 %(mmake)_MODULE := $(%(mmake)_MODDIR)/%(modname)-%(modtype)
1849 ifeq (%(modtype),printer)
1850 %(mmake)_MODULE := $(%(mmake)_MODDIR)/%(modname)
1852 %(mmake)_MODULE := $(%(mmake)_MODDIR)/%(modname).%(modtype)
1855 %(mmake)_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1857 %(mmake)-quick : %(mmake)
1858 %(mmake)-kobj-quick : $(%(mmake)_KOBJ)
1859 %(mmake) : $(%(mmake)_MODULE)
1860 %(mmake)-kobj : $(%(mmake)_KOBJ)
1862 # The module is linked from all the compiled .o files
1863 %(mmake)_OBJS := $(%(mmake)_ARCHOBJS) $(addprefix %(objdir)/, $(addsuffix .o,$(notdir $(%(mmake)_C_NARCHFILES))))
1865 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
1866 # This breaks con-handler build. Here we work around this
1867 ifeq (%(modname),con)
1868 %(mmake)_ERR := $(notdir $(%(mmake)_MODULE)).err
1870 %(mmake)_ERR := %(modname).err
1873 %rule_linkmodule module=$(%(mmake)_MODULE) objs=$(%(mmake)_OBJS) \
1874 endobj= err=$(%(mmake)_ERR) objdir="%(objdir)" \
1875 ldflags="$(strip $(LDFLAGS) $(%(modname)_LDFLAGS))" \
1876 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
1878 # Link kernel object file
1879 %(mmake)_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1881 # Make these symbols local
1882 %(mmake)_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1883 UtilityBase ExpansionBase KeymapBase KernelBase
1885 %(mmake)_SYMBOLS := $(%(mmake)_KBASE)
1887 %(mmake)_KLIB := hiddstubs amiga arossupport autoinit libinit
1888 %(mmake)_KOBJ_LIBS := $(filter-out $(%(mmake)_KLIB),%(uselibs)) $(%(mmake)_KAUTOLIB)
1889 $(%(mmake)_KOBJ) : LINKLIBS:=$(%(mmake)_KOBJ_LIBS)
1890 $(%(mmake)_KOBJ) : FILTBASES:=$(addprefix -L ,$(%(mmake)_SYMBOLS))
1891 $(%(mmake)_KOBJ) : USER_LDFLAGS := $(USER_LDFLAGS)
1892 $(%(mmake)_KOBJ) : $(%(mmake)_OBJS) $(%(mmake)_ENDOBJS)
1893 $(Q)$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
1894 $(Q)$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1895 $(Q)$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
1898 ## Dependency fine-tuning
1900 %(mmake)_DEPS := $(addprefix %(objdir)/, $(addsuffix .d,%(files)))
1901 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(%(mmake)_DEPS)
1903 %rule_makedirs dirs="%(objdir) $(%(mmake)_MODDIR) $(KOBJSDIR)" setuptarget="$(%(mmake)_OBJS) $(%(mmake)_DEPS) $(%(mmake)_MODULE) $(%(mmake)_KOBJ) "
1905 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_MODULE) $(%(mmake)_KOBJ) $(%(mmake)_DEPS)
1907 $(Q)$(ECHO) "Cleaning up for module %(modname)"
1910 #------------------------------------------------------------------------------
1913 #------------------------------------------------------------------------------
1914 # Build a module - core routine
1915 # Explanation of this macro is done in the developer's manual
1916 %define build_module_core mmake=/A modname=/A modtype=/A modsuffix= version= flavour= conffile= \
1917 files="$(basename $(call WILDCARD, *.c))" \
1919 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
1920 linklibfiles= linklibobjs= \
1921 cppflags=$(CPPFLAGS) \
1922 cflags=$(CFLAGS) dflags= \
1923 cxxflags=$(CXXFLAGS) dxxflags= \
1924 objdir= moduledir= prefix=$(AROSDIR) \
1925 linklibname= uselibs= usehostlibs= \
1926 compiler=target funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO) nostartup=yes archspecific=no \
1927 include_set=includes-all includedir= libdir= \
1928 build_abi= build_library=
1930 # We will employ a terrifying, but unavoidable, hack here.
1931 # genmf has no concept of conditionals (ie %ifeq), and MetaMake
1932 # ignores GNU Make ifeq() statements, but will process any #MM
1933 # headed lines in the file.
1935 # So, to make the following #MM lines conditional on whether we want
1936 # to build the ABI, Library, or both, we define build_abi= and
1937 # build_library as 'M' to enable, or '' to disable, which allows genmf
1938 # to do the following conversions:
1940 # #%(build_abi)M includes-foo: foo-include
1941 # becomes, when build_abi=M
1942 # #MM includes-foo: foo-include <= Processed by MetaMake
1943 # but, when build_abi= ...
1944 # #M includes-foo: foo-includes <= ignored by MetaMake! Yes!
1946 # Taking full blame for this: Jason S. McMullan <jason.mcmullan@gmail.com>
1948 # Define metamake targets and their dependencies
1951 #MM %(mmake)-makefile
1955 #M%(build_abi)- %(include_set) : %(mmake)-includes
1956 #M%(build_abi)- linklibs-%(modname): %(mmake)-linklib
1957 #M%(build_abi)- linklibs-%(modname)_rel : %(mmake)-linklib
1958 #M%(build_abi)- includes-%(modname): %(mmake)-includes
1959 #M%(build_abi)- includes-%(modname)_rel : %(mmake)-includes
1960 #M%(build_abi)- %(mmake) : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1961 #M%(build_abi) %(mmake)-linklib : %(mmake)-includes includes-%(uselibs)
1962 #M%(build_abi)- %(mmake)-quick : %(mmake)-includes-quick
1963 #M%(build_abi) %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1964 #M%(build_abi) includes-generate-deps %(mmake)-fd
1965 #M%(build_abi) %(mmake)-includes-quick
1966 #M%(build_abi) %(mmake)-includes-dirs
1967 #M%(build_abi) %(mmake)-fd
1970 #%(build_library)M %(mmake)-kobj : core-linklibs linklibs-%(uselibs)
1971 #%(build_library)M %(mmake)-kobj-quick :
1973 # Library with ABI targets:
1974 #%(build_library)%(build_abi) %(mmake)-kobj : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1975 #%(build_library)%(build_abi) %(mmake)-kobj-quick : %(mmake)-includes-quick
1977 # All MetaMake targets defined by this macro
1978 %(mmake)%(flavour)_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-clean
1980 ifeq (%(build_library),M)
1981 %(mmake)%(flavour)_ALLTARGETS += %(mmake)-kobj %(mmake)-kobj-quick
1984 ifeq (%(build_abi),M)
1985 %(mmake)%(flavour)_ALLTARGETS += %(mmake)-includes \
1986 %(mmake)-includes-quick %(mmake)-includes-dirs \
1987 %(mmake)-linklib %(mmake)-fd
1990 .PHONY : $(%(mmake)%(flavour)_ALLTARGETS) %(mmake)-makefile
1993 $(error using %build_module: modname may not be empty)
1996 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1999 # Default values for variables and arguments
2001 %(mmake)%(flavour)_DEFNAME := %(modname)_%(flavour)
2003 %(mmake)%(flavour)_DEFNAME := %(modname)
2005 %(mmake)%(flavour)_DEFLINKLIBNAME := $(%(mmake)%(flavour)_DEFNAME)
2006 ifneq (%(linklibname),)
2007 %(mmake)%(flavour)_LINKLIBNAME := %(linklibname)
2009 %(mmake)%(flavour)_LINKLIBNAME = $(%(mmake)%(flavour)_DEFLINKLIBNAME)
2011 %(mmake)%(flavour)_DEFCPPFLAGS := %(cppflags)
2012 ifneq (%(includedir),)
2013 %(mmake)%(flavour)_DEFCPPFLAGS += -I%(includedir)
2015 %(mmake)%(flavour)_DEFDFLAGS := %(cflags)
2017 %(mmake)%(flavour)_DFLAGS := %(dflags)
2019 %(mmake)%(flavour)_DFLAGS = $(%(mmake)%(flavour)_DEFDFLAGS)
2021 %(mmake)%(flavour)_DEFDXXFLAGS := %(cxxflags)
2022 ifneq (%(dxxflags),)
2023 %(mmake)%(flavour)_DXXFLAGS := %(dxxflags)
2025 %(mmake)%(flavour)_DXXFLAGS = $(%(mmake)%(flavour)_DEFDXXFLAGS)
2028 ifeq (%(compiler),target)
2030 %(mmake)%(flavour)_DEFDFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH) $(%(mmake)%(flavour)_DEFDFLAGS))
2031 %(mmake)%(flavour)_DEFDXXFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH) $(%(mmake)%(flavour)_DEFDXXFLAGS))
2033 ifeq (%(funcinstr),yes)
2034 %(mmake)_FUNCINSTR := yes
2035 %(mmake)%(flavour)_DEFDFLAGS := $(strip $(FUNCINSTR_FLAGS) $(%(mmake)%(flavour)_DEFDFLAGS))
2036 %(mmake)%(flavour)_DEFDXXFLAGS := $(strip $(FUNCINSTR_FLAGS) $(%(mmake)%(flavour)_DEFDXXFLAGS))
2040 OBJDIR ?= $(GENDIR)/$(CURDIR)
2042 %(mmake)_OBJDIR := %(objdir)
2044 %(mmake)_OBJDIR := $(OBJDIR)/$(%(mmake)%(flavour)_DEFNAME)
2047 %(mmake)%(flavour)_OBJDIR := $(%(mmake)_OBJDIR)
2050 ## Create genmodule include Makefile for the module
2052 %(mmake)%(flavour)-makefile := $(%(mmake)%(flavour)_OBJDIR)/Makefile.$(%(mmake)%(flavour)_DEFNAME)%(modtype)
2053 %(mmake)%(flavour)-genmakefile : $(%(mmake)%(flavour)-makefile)
2055 %rule_genmodule_makefile \
2056 mmake=%(mmake)-genmakefile modname="%(modname)" flavour="%(flavour)" modtype="%(modtype)" \
2057 modsuffix="%(modsuffix)" targetdir="$(%(mmake)%(flavour)_OBJDIR)" \
2058 conffile="%(conffile)"
2060 %rule_makedirs dirs="$(%(mmake)%(flavour)_OBJDIR)" setuptarget=$(%(mmake)%(flavour)-makefile)
2062 # Do not parse these statements if metatarget is not appropriate
2063 ifneq ($(filter $(TARGET),$(%(mmake)%(flavour)_ALLTARGETS)),)
2065 # suppress makes warning that the Makefile doesnt yet exist
2066 # on early passes (it will generate the file as needed though)
2067 # when we include it.
2068 -include $(%(mmake)%(flavour)-makefile)
2070 %(mmake)%(flavour)_DEFMODDIR := $($(%(mmake)%(flavour)_DEFNAME)_MODDIR)
2071 ifeq (%(archspecific),yes)
2072 %(mmake)%(flavour)_DEFMODDIR := $(AROS_DIR_ARCH)/$(%(mmake)%(flavour)_DEFMODDIR)
2074 ifneq (%(moduledir),)
2075 %(mmake)%(flavour)_MODDIR := %(moduledir)
2077 %(mmake)%(flavour)_MODDIR := $(%(mmake)%(flavour)_DEFMODDIR)
2080 ## include files generation
2082 ifneq (%(includedir),)
2083 %(mmake)%(flavour)_INCDIR := %(includedir)
2085 %(mmake)%(flavour)_INCDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/$(AROS_DIR_INCLUDE)
2087 %(mmake)%(flavour)_LIBDEFSINC := $(%(mmake)%(flavour)_OBJDIR)/include/$(%(mmake)%(flavour)_DEFNAME)_libdefs.h
2088 %(mmake)%(flavour)_DEFLIBDEFSINC := $(%(mmake)%(flavour)_OBJDIR)/include/$(%(mmake)%(flavour)_DEFNAME)_deflibdefs.h
2090 ifeq (%(build_abi),M)
2091 %(mmake)-includes-quick : %(mmake)-includes
2092 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2093 $(addprefix $(%(mmake)%(flavour)_INCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2094 $(%(mmake)%(flavour)_LIBDEFSINC) $(%(mmake)%(flavour)_DEFLIBDEFSINC)
2096 ifneq ($($(%(mmake)%(flavour)_DEFNAME)_INCLUDES),)
2097 %rule_genmodule_includes mmake=%(mmake)-includes modname="%(modname)" modtype="%(modtype)" \
2098 modsuffix="%(modsuffix)" targetdir="$(%(mmake)_OBJDIR)/include" \
2099 conffile="%(conffile)" flavour="%(flavour)"
2101 %rule_copy_diff_multi \
2102 files=$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES) srcdir="$(%(mmake)_OBJDIR)/include" targetdir=$(GENINCDIR) \
2103 stampfile="$(%(mmake)_OBJDIR)/%(modname)_geninc"
2105 %rule_copy_diff_multi \
2106 files=$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES) srcdir="$(%(mmake)_OBJDIR)/include" targetdir=$(%(mmake)%(flavour)_INCDIR) \
2107 stampfile="$(%(mmake)_OBJDIR)/%(modname)_incs"
2109 %(mmake)%(flavour)_INCDIRS := $(filter-out ./,$(sort $(dir $($(%(mmake)%(flavour)_DEFNAME)_INCLUDES))))
2111 TMP%(modname)_INCDIRS := \
2112 $(%(mmake)_OBJDIR)/include $(addprefix $(%(mmake)_OBJDIR)/include/,$(%(mmake)%(flavour)_INCDIRS)) \
2113 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(%(mmake)%(flavour)_INCDIRS)) \
2114 $(%(mmake)%(flavour)_INCDIR) $(addprefix $(%(mmake)%(flavour)_INCDIR)/,$(%(mmake)%(flavour)_INCDIRS))
2115 %rule_makedirs dirs="$(TMP%(modname)_INCDIRS)" setuptarget="%(mmake)-includes-dirs"
2121 %rule_genmodule_genlibdefs mmake=%(mmake)-genlibdefs modname="%(modname)" flavour="%(flavour)" modtype="%(modtype)" \
2122 modsuffix="%(modsuffix)" targetdir="$(%(mmake)%(flavour)_OBJDIR)/include" \
2123 conffile="%(conffile)" version="%(version)"
2125 $(%(mmake)%(flavour)_DEFLIBDEFSINC) : FILENAME := $(%(mmake)%(flavour)_LIBDEFSINC)
2126 $(%(mmake)%(flavour)_DEFLIBDEFSINC) : $(%(mmake)%(flavour)_LIBDEFSINC)
2127 $(Q)$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
2128 $(Q)$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
2130 $(%(mmake)%(flavour)_LIBDEFSINC) $(%(mmake)%(flavour)_DEFLIBDEFSINC) : | $(%(mmake)%(flavour)_OBJDIR)/include
2131 %rule_makedirs dirs="$(%(mmake)%(flavour)_OBJDIR)/include" setuptarget=%(mmake)%(flavour)-includes-dirs
2133 ## Extra genmodule src files generation
2135 %rule_genmodule_files mmake=%(mmake)-genmodfiles modname="%(modname)" modtype="%(modtype)" \
2136 modsuffix="%(modsuffix)" targetdir="$(%(mmake)%(flavour)_OBJDIR)" stubdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" \
2137 conffile="%(conffile)" flavour="%(flavour)"
2139 $(%(mmake)-genmodfiles_GENFILEFLAG) : $(%(mmake)%(flavour)_DEFLIBDEFSINC) $(%(mmake)%(flavour)-makefile)
2141 %rule_makedirs dirs="$(%(mmake)%(flavour)_OBJDIR)/linklib" setuptarget=%(mmake)%(flavour)-linklib-setup
2143 ifeq (%(build_abi),M)
2145 ifeq (%(includedir),)
2146 %(mmake)%(flavour)_FDDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/$(AROS_DIR_SDK)/$(AROS_DIR_FD)
2148 %(mmake)%(flavour)_FDDIR := %(includedir)/../$(AROS_DIR_FD)
2150 %(mmake)-fd : $(%(mmake)%(flavour)_FDDIR)/%(modname)_lib.fd
2152 %rule_genmodule_fd modname="%(modname)" modtype="%(modtype)" \
2153 modsuffix="%(modsuffix)" targetdir=$(%(mmake)%(flavour)_FDDIR) conffile="%(conffile)"
2155 $(%(mmake)%(flavour)_FDDIR)/%(modname)_lib.fd : | $(%(mmake)%(flavour)_FDDIR)
2157 %rule_makedirs dirs="$(%(mmake)%(flavour)_FDDIR)" setuptarget=%(mmake)%(flavour)-fd-setup
2162 %(mmake)%(flavour)_FILES := %(files)
2163 %(mmake)%(flavour)_OBJCFILES := %(objcfiles)
2164 %(mmake)%(flavour)_CXXFILES := %(cxxfiles)
2166 %(mmake)%(flavour)_LIBFILES := %(linklibfiles)
2167 %(mmake)%(flavour)_LIBS := %(uselibs)
2169 %(mmake)%(flavour)_FDIRS := $(sort $(dir $(%(mmake)%(flavour)_FILES)))
2171 %(mmake)%(flavour)_FILEMATCH = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1)))
2172 %(mmake)%(flavour)_MATCHARCH = $(foreach matchfile,$(2),$(foreach archfile,$(1),$(if $(call %(mmake)%(flavour)_FILEMATCH,$(archfile),$(notdir $(matchfile))),$(matchfile),)))
2173 %(mmake)%(flavour)_FILTERARCH = $(filter-out $(call %(mmake)%(flavour)_MATCHARCH,$(1),$(2)),$(2))
2174 %(mmake)%(flavour)_STARTFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_STARTFILES))
2175 %(mmake)%(flavour)_ENDFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_ENDFILES))
2177 %(mmake)%(flavour)_ARCHOBJS := $(wildcard $(%(mmake)%(flavour)_OBJDIR)/arch/*.o)
2178 %(mmake)%(flavour)_LIBARCHOBJS := $(wildcard $(%(mmake)%(flavour)_OBJDIR)/linklib/arch/*.o)
2179 %(mmake)%(flavour)_ARCHFILES := $(basename $(notdir $(%(mmake)%(flavour)_ARCHOBJS)))
2180 %(mmake)%(flavour)_LIBARCHFILES := $(basename $(notdir $(%(mmake)%(flavour)_LIBARCHOBJS)))
2181 %(mmake)%(flavour)_C_NARCHFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_ARCHFILES),$(%(mmake)%(flavour)_FILES))
2182 %(mmake)%(flavour)_CXX_NARCHFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_ARCHFILES),$(%(mmake)%(flavour)_CXXFILES))
2183 %(mmake)%(flavour)_OBJC_NARCHFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_ARCHFILES),$(%(mmake)%(flavour)_OBJCFILES))
2184 %(mmake)%(flavour)_NLIBARCHFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_LIBARCHFILES),$(%(mmake)%(flavour)_LIBFILES))
2185 %(mmake)%(flavour)_ARCHNLIBFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_LIBFILES),$(%(mmake)%(flavour)_LIBARCHFILES))
2187 %(mmake)%(flavour)_CPPFLAGS := $(strip %(cppflags) -I$(%(mmake)%(flavour)_OBJDIR)/include -include $(%(mmake)%(flavour)_DEFLIBDEFSINC))
2188 ifneq (%(includedir),)
2189 %(mmake)%(flavour)_CPPFLAGS += -I%(includedir)
2191 %(mmake)%(flavour)_LINKLIBCPPFLAGS := $(%(mmake)%(flavour)_CPPFLAGS)
2192 %(mmake)%(flavour)_CPPFLAGS += $(strip $($(%(mmake)%(flavour)_DEFNAME)_CPPFLAGS))
2193 %(mmake)%(flavour)_LINKLIBCPPFLAGS += $(strip $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBCPPFLAGS))
2194 %(mmake)%(flavour)_CFLAGS := $(strip %(cflags) $($(%(mmake)%(flavour)_DEFNAME)_CFLAGS))
2195 %(mmake)%(flavour)_LINKLIBCFLAGS := $(strip %(cflags) $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBCFLAGS))
2196 %(mmake)%(flavour)_CXXFLAGS := $(strip %(cxxflags) $($(%(mmake)%(flavour)_DEFNAME)_CXXFLAGS))
2197 ifeq (%(compiler),target)
2199 %(mmake)%(flavour)_LTOFLAGS ?= $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH))
2200 %(mmake)%(flavour)_CFLAGS := $(strip $(%(mmake)%(flavour)_LTOFLAGS) $(%(mmake)%(flavour)_CFLAGS))
2201 %(mmake)%(flavour)_LINKLIBCFLAGS := $(strip $(%(mmake)%(flavour)_LTOFLAGS) $(%(mmake)%(flavour)_LINKLIBCFLAGS))
2202 %(mmake)%(flavour)_CXXFLAGS := $(strip $(%(mmake)%(flavour)_LTOFLAGS) $(%(mmake)%(flavour)_CXXFLAGS))
2204 ifeq (%(funcinstr),yes)
2205 %(mmake)%(flavour)_SUBSTNULL :=
2206 %(mmake)%(flavour)_SUBSTSPACE := $(%(mmake)%(flavour)_SUBSTNULL) #
2207 %(mmake)%(flavour)_SUBSTCOMMA := ,
2208 %(mmake)%(flavour)_INSTRFUNCFLAGS ?= $(strip $(FUNCINSTR_FLAGS) -finstrument-functions-exclude-file-list=$(subst $(%(mmake)%(flavour)_SUBSTSPACE),$(%(mmake)%(flavour)_SUBSTCOMMA),$(strip $($(%(mmake)%(flavour)_DEFNAME)_STARTFILES))))
2209 %(mmake)%(flavour)_INSTRFUNCLIBS ?= $(FUNCINSTR_LIBS)
2210 %(mmake)%(flavour)_CFLAGS := $(strip $(%(mmake)%(flavour)_INSTRFUNCFLAGS) $(%(mmake)%(flavour)_CFLAGS))
2211 %(mmake)%(flavour)_CXXFLAGS := $(strip $(%(mmake)%(flavour)_INSTRFUNCFLAGS) $(%(mmake)%(flavour)_CXXFLAGS))
2212 %(mmake)%(flavour)_LIBS += $(%(mmake)%(flavour)_INSTRFUNCLIBS)
2215 %(mmake)%(flavour)_DFLAGS := $(strip $(%(mmake)%(flavour)_DFLAGS) $($(%(mmake)%(flavour)_DEFNAME)_DFLAGS))
2216 %(mmake)%(flavour)_LINKLIBDFLAGS := $(strip $(%(mmake)%(flavour)_DFLAGS) $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBDFLAGS))
2217 %(mmake)%(flavour)_DXXFLAGS := $(strip $(%(mmake)%(flavour)_DXXFLAGS) $($(%(mmake)%(flavour)_DEFNAME)_DXXFLAGS))
2219 ifeq (%(modtype),library)
2220 %(mmake)%(flavour)_LIBSUFFIX :=
2222 %(mmake)%(flavour)_LIBSUFFIX := .%(modtype)
2226 %(mmake)%(flavour)_LIBDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/$(AROS_DIR_LIB)
2228 %(mmake)%(flavour)_LIBDIR := %(libdir)
2231 ifeq (%(build_abi),M)
2232 %(mmake)%(flavour)_LINKLIBCFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$($(%(mmake)%(flavour)_DEFNAME)_LINKLIBFILES))
2233 %(mmake)%(flavour)_LINKLIBAFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$($(%(mmake)%(flavour)_DEFNAME)_LINKLIBAFILES))
2234 ifeq ($(strip $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBFILES) $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBAFILES) %(linklibfiles) $(%(mmake)%(flavour)_ARCHNLIBFILES)),)
2235 %(mmake)%(flavour)_LINKLIB :=
2237 %(mmake)%(flavour)_LINKLIB := $(%(mmake)%(flavour)_LIBDIR)/lib%(modname)$(%(mmake)%(flavour)_LIBSUFFIX).a
2238 ifneq (%(modname),$(%(mmake)%(flavour)_LINKLIBNAME))
2239 %(mmake)%(flavour)_LINKLIB += $(%(mmake)%(flavour)_LIBDIR)/lib$(%(mmake)%(flavour)_LINKLIBNAME)$(%(mmake)%(flavour)_LIBSUFFIX).a
2242 %(mmake)%(flavour)_LINKLIBFILES := $(%(mmake)%(flavour)_LINKLIBCFILES) $(%(mmake)%(flavour)_LINKLIBAFILES)
2244 %(mmake)%(flavour)_RELLINKLIBCFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$($(%(mmake)%(flavour)_DEFNAME)_RELLINKLIBFILES))
2245 %(mmake)%(flavour)_RELLINKLIBAFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$($(%(mmake)%(flavour)_DEFNAME)_RELLINKLIBAFILES))
2246 ifeq ($(strip $($(%(mmake)%(flavour)_DEFNAME)_RELLINKLIBFILES) $($(%(mmake)%(flavour)_DEFNAME)_RELLINKLIBAFILES) %(linklibfiles) $(%(mmake)%(flavour)_ARCHNLIBFILES)),)
2247 %(mmake)%(flavour)_RELLINKLIB :=
2249 %(mmake)%(flavour)_RELLINKLIB := $(%(mmake)%(flavour)_LIBDIR)/lib$(%(mmake)%(flavour)_DEFNAME)_rel$(%(mmake)%(flavour)_LIBSUFFIX).a
2250 ifneq (%(modname),$(%(mmake)%(flavour)_LINKLIBNAME))
2251 %(mmake)%(flavour)_RELLINKLIB += $(%(mmake)%(flavour)_LIBDIR)/lib$(%(mmake)%(flavour)_LINKLIBNAME)_rel$(%(mmake)%(flavour)_LIBSUFFIX).a
2254 %(mmake)%(flavour)_RELLINKLIBFILES := $(%(mmake)%(flavour)_RELLINKLIBCFILES) $(%(mmake)%(flavour)_RELLINKLIBAFILES)
2257 %(mmake)%(flavour)_ENDOBJS := $(addsuffix .o,$(%(mmake)%(flavour)_ENDFILES))
2258 %(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)) \
2260 %(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)) \
2262 $(%(mmake)%(flavour)_LINKLIBFILES) $(%(mmake)%(flavour)_RELLINKLIBFILES) : | $(%(mmake)%(flavour)_OBJDIR)/linklib
2263 $(%(mmake)%(flavour)_LINKLIBOBJS) $(%(mmake)%(flavour)_RELLINKLIBOBJS) : | $(%(mmake)%(flavour)_OBJDIR)/linklib
2265 %(mmake)%(flavour)_CCFILES := $(%(mmake)%(flavour)_C_NARCHFILES)
2266 %(mmake)%(flavour)_TARGETCCFILES := $(strip $(%(mmake)%(flavour)_STARTFILES) $(%(mmake)%(flavour)_ENDFILES))
2267 %(mmake)%(flavour)_LINKLIBCCFILES := $(strip $(%(mmake)%(flavour)_NLIBARCHFILES) $(%(mmake)%(flavour)_LINKLIBCFILES) $(%(mmake)%(flavour)_RELLINKLIBCFILES))
2268 %(mmake)%(flavour)_LINKLIBCCGENFILES := $(strip $(%(mmake)%(flavour)_LINKLIBCFILES) $(%(mmake)%(flavour)_RELLINKLIBCFILES))
2270 %rule_compile_cxx_multi mmake=%(mmake)%(flavour) \
2271 basenames=$(%(mmake)%(flavour)_CXX_NARCHFILES) targetdir="$(%(mmake)%(flavour)_OBJDIR)" \
2272 cppflags=$(%(mmake)%(flavour)_CPPFLAGS) cxxflags=$(%(mmake)%(flavour)_CXXFLAGS) dxxflags=$(%(mmake)%(flavour)_DXXFLAGS) \
2273 compiler="%(compiler)"
2274 %rule_compile_objc_multi mmake=%(mmake)%(flavour) \
2275 basenames=$(%(mmake)%(flavour)_OBJC_NARCHFILES) targetdir=$(%(mmake)%(flavour)_OBJDIR) \
2276 cppflags=$(%(mmake)%(flavour)_CPPFLAGS) cflags=$(%(mmake)%(flavour)_CFLAGS) dflags=$(%(mmake)%(flavour)_DFLAGS) \
2277 compiler="%(compiler)"
2278 %rule_compile_multi mmake=%(mmake)%(flavour) \
2279 basenames=$(%(mmake)%(flavour)_CCFILES) targetdir="$(%(mmake)%(flavour)_OBJDIR)" \
2280 cppflags=$(%(mmake)%(flavour)_CPPFLAGS) cflags=$(%(mmake)%(flavour)_CFLAGS) dflags=$(%(mmake)%(flavour)_DFLAGS) \
2281 compiler="%(compiler)"
2282 %rule_compile_multi mmake=%(mmake)%(flavour) \
2283 basenames=$(%(mmake)%(flavour)_TARGETCCFILES) targetdir="$(%(mmake)%(flavour)_OBJDIR)" \
2284 cppflags="$(%(mmake)%(flavour)_CPPFLAGS) -D__AROS__" cflags=$(%(mmake)%(flavour)_CFLAGS) dflags=$(%(mmake)%(flavour)_DFLAGS) \
2285 compiler="%(compiler)"
2286 %rule_compile_multi mmake=%(mmake)%(flavour) \
2287 basenames=$(%(mmake)%(flavour)_NLIBARCHFILES) targetdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" \
2288 cppflags="$(%(mmake)%(flavour)_LINKLIBCPPFLAGS) -D__AROS__" cflags=$(%(mmake)%(flavour)_LINKLIBCFLAGS) dflags=$(%(mmake)%(flavour)_LINKLIBDFLAGS) \
2289 compiler="%(compiler)"
2290 %rule_compile_multi mmake=%(mmake)%(flavour) \
2291 basenames=$(%(mmake)%(flavour)_LINKLIBCCGENFILES) srcdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" targetdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" \
2292 cppflags="$(%(mmake)%(flavour)_LINKLIBCPPFLAGS) -D__AROS__" cflags=$(%(mmake)%(flavour)_LINKLIBCFLAGS) dflags=$(%(mmake)%(flavour)_LINKLIBDFLAGS) \
2293 compiler="%(compiler)"
2295 ifneq ($(%(mmake)%(flavour)_LINKLIBAFILES),)
2296 %rule_assemble_multi mmake=%(mmake)%(flavour) \
2297 cmd=$(%(mmake)%(flavour)_ASSEMBLER) basenames="$(%(mmake)%(flavour)_LINKLIBAFILES) $(%(mmake)%(flavour)_RELLINKLIBAFILES)" targetdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" suffix=.S
2302 ifeq (%(modsuffix),)
2303 %(mmake)%(flavour)_SUFFIX := %(modtype)
2305 %(mmake)%(flavour)_SUFFIX := %(modsuffix)
2308 ifeq (%(build_library),M)
2309 # Handlers use dash instead of dot in their names
2310 ifeq ($(%(mmake)%(flavour)_SUFFIX),handler)
2311 %(mmake)%(flavour)_MODULE := %(prefix)/$(%(mmake)%(flavour)_MODDIR)/$(%(mmake)%(flavour)_DEFNAME)-$(%(mmake)%(flavour)_SUFFIX)
2313 %(mmake)%(flavour)_MODULE := %(prefix)/$(%(mmake)%(flavour)_MODDIR)/$(%(mmake)%(flavour)_DEFNAME).$(%(mmake)%(flavour)_SUFFIX)
2315 %(mmake)%(flavour)_KOBJ := $(KOBJSDIR)/$(%(mmake)%(flavour)_DEFNAME)_$(%(mmake)%(flavour)_SUFFIX).o
2317 %(mmake)%(flavour)_MODULE :=
2318 %(mmake)%(flavour)_KOBJ :=
2321 %(mmake)-quick : %(mmake)
2322 %(mmake) : $(%(mmake)%(flavour)_MODULE) $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_RELLINKLIB)
2323 ifeq (%(build_library),M)
2324 %(mmake)-kobj : $(%(mmake)%(flavour)_KOBJ) $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_RELLINKLIB)
2325 %(mmake)-kobj-quick : $(%(mmake)%(flavour)_KOBJ) $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_RELLINKLIB)
2327 ifeq (%(build_abi),M)
2328 %(mmake)-linklib : $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_RELLINKLIB)
2331 %(mmake)%(flavour)_OBJS := $(addsuffix .o,$(%(mmake)%(flavour)_STARTFILES)) $(%(mmake)%(flavour)_ARCHOBJS) \
2332 $(addprefix $(%(mmake)%(flavour)_OBJDIR)/,$(notdir $(%(mmake)%(flavour)_C_NARCHFILES:=.o) $(%(mmake)%(flavour)_CXXFILES:=.o)))
2334 ifeq (%(nostartup),yes)
2335 # Handlers always have entry point
2336 ifneq (%(modtype),handler)
2337 %(mmake)%(flavour)_STARTOBJS := $(addsuffix .o,$(addprefix $(GENDIR)/,$(RESIDENT_BEGIN)))
2341 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
2342 # This breaks con-handler build. Here we work around this
2343 ifeq (%(modname),con)
2344 %(mmake)%(flavour)_ERR := $(notdir $(%(mmake)%(flavour)_MODULE)).err
2346 %(mmake)%(flavour)_ERR := %(modname).err
2349 ifeq (%(build_library),M)
2350 # The module is linked from all the compiled .o files
2351 %rule_linkmodule module=$(%(mmake)%(flavour)_MODULE) objs="$(%(mmake)%(flavour)_STARTOBJS) $(%(mmake)%(flavour)_OBJS) $(USER_OBJS)" \
2352 endobj=$(%(mmake)%(flavour)_ENDOBJS) err=$(%(mmake)%(flavour)_ERR) objdir="$(%(mmake)%(flavour)_OBJDIR)" \
2353 cmd=$(%(mmake)%(flavour)_LINK) ldflags="$(LDFLAGS) $($(%(mmake)%(flavour)_DEFNAME)_LDFLAGS)" \
2354 uselibs="$(%(mmake)%(flavour)_LIBS) $($(%(mmake)%(flavour)_DEFNAME)_LIBS)" usehostlibs="%(usehostlibs)"
2357 ifeq (%(build_abi),M)
2359 %(mmake)%(flavour)_LC_LINKLIBNAME := $(shell echo $(%(mmake)%(flavour)_LINKLIBNAME) | tr A-Z a-z)
2360 %(mmake)%(flavour)_LC_MODNAME := $(shell echo %(modname) | tr A-Z a-z)
2361 ifneq ($(%(mmake)%(flavour)_LINKLIB),)
2362 %rule_link_linklib mmake=%(mmake) libname="$(%(mmake)%(flavour)_LINKLIBNAME)$(%(mmake)%(flavour)_LIBSUFFIX)" objs=$(%(mmake)%(flavour)_LINKLIBOBJS) libdir="$(%(mmake)%(flavour)_LIBDIR)"
2363 ifneq ($(%(mmake)%(flavour)_LC_MODNAME),$(%(mmake)%(flavour)_LC_LINKLIBNAME))
2364 %rule_link_linklib mmake=%(mmake) libname="%(modname)$(%(mmake)%(flavour)_LIBSUFFIX)" objs=$(%(mmake)%(flavour)_LINKLIBOBJS) libdir="$(%(mmake)%(flavour)_LIBDIR)"
2367 %rule_makedirs dirs="$(%(mmake)%(flavour)_LIBDIR)" setuptarget=$(%(mmake)%(flavour)_LINKLIB)
2370 ifneq ($(%(mmake)%(flavour)_RELLINKLIB),)
2371 %rule_link_linklib mmake=%(mmake) libname="$(%(mmake)%(flavour)_LINKLIBNAME)_rel$(%(mmake)%(flavour)_LIBSUFFIX)" objs=$(%(mmake)%(flavour)_RELLINKLIBOBJS) libdir="$(%(mmake)%(flavour)_LIBDIR)"
2372 ifneq ($(%(mmake)%(flavour)_LC_MODNAME),$(%(mmake)%(flavour)_LC_LINKLIBNAME))
2373 %rule_link_linklib mmake=%(mmake) libname="$(%(mmake)%(flavour)_DEFNAME)_rel$(%(mmake)%(flavour)_LIBSUFFIX)" objs=$(%(mmake)%(flavour)_RELLINKLIBOBJS) libdir="$(%(mmake)%(flavour)_LIBDIR)"
2376 %rule_makedirs dirs="$(%(mmake)%(flavour)_LIBDIR)" setuptarget=$(%(mmake)%(flavour)_RELLINKLIB)
2380 ifeq (%(build_library),M)
2381 # Link kernel object file
2382 %(mmake)%(flavour)_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
2384 # Make these symbols local
2385 %(mmake)%(flavour)_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
2386 UtilityBase ExpansionBase KeymapBase KernelBase
2388 %(mmake)%(flavour)_SYMBOLS := $(%(mmake)%(flavour)_KBASE)
2390 %(mmake)%(flavour)_KLIB := hiddstubs amiga arossupport autoinit libinit
2391 %(mmake)%(flavour)_KOBJ_LIBS := $(filter-out $(%(mmake)%(flavour)_KLIB),$(%(mmake)%(flavour)_LIBS)) $(%(mmake)%(flavour)_KAUTOLIB)
2392 $(%(mmake)%(flavour)_KOBJ) : LINKLIBS:=$(%(mmake)%(flavour)_KOBJ_LIBS) $($(%(mmake)%(flavour)_DEFNAME)_LIBS)
2393 $(%(mmake)%(flavour)_KOBJ) : FILTBASES:=$(addprefix -L ,$(%(mmake)%(flavour)_SYMBOLS))
2394 $(%(mmake)%(flavour)_KOBJ) : USER_LDFLAGS:=$(USER_LDFLAGS)
2395 $(%(mmake)%(flavour)_KOBJ) : $(%(mmake)%(flavour)_OBJS) $(USER_OBJS) $(%(mmake)%(flavour)_ENDOBJS)
2396 $(Q)$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
2397 $(Q)$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
2398 $(Q)$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
2401 ## Dependency fine-tuning
2403 %(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)))
2405 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick" deps=$(%(mmake)%(flavour)_DEPS)
2407 $(%(mmake)%(flavour)_OBJS) $(%(mmake)%(flavour)_DEPS) : | $(%(mmake)%(flavour)_OBJDIR)/linklib
2408 %rule_makedirs dirs="$(%(mmake)%(flavour)_OBJDIR) %(prefix)/$(%(mmake)%(flavour)_MODDIR) $(KOBJSDIR)" setuptarget="$(%(mmake)%(flavour)_OBJS) $(%(mmake)%(flavour)_DEPS) $(%(mmake)%(flavour)_MODULE) $(%(mmake)%(flavour)_KOBJ)"
2410 # Some include files need to be generated before the .c can be parsed.
2411 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick),) # Only for this target these deps are wanted
2413 %(mmake)%(flavour)_DFILE_DEPS := $(%(mmake)%(flavour)_LIBDEFSINC) $(%(mmake)%(flavour)_DEFLIBDEFSINC) \
2414 $(addprefix $(%(mmake)%(flavour)_INCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES))
2415 $(%(mmake)%(flavour)_DEPS) : $(%(mmake)%(flavour)_DFILE_DEPS)
2418 %(mmake)%(flavour)_TOCLEAN := $(%(mmake)%(flavour)_OBJS) $(%(mmake)%(flavour)_DEPS) \
2419 $(%(mmake)%(flavour)_MODULE) $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_KOBJ) \
2420 $(%(mmake)%(flavour)_OBJDIR)/Makefile.%(modname)%(modtype) \
2421 $(addprefix $(%(mmake)%(flavour)_OBJDIR)/include/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2422 $(addprefix $(GENINCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2423 $(addprefix $(%(mmake)%(flavour)_INCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2424 $(%(mmake)_OBJDIR)/%(modname)_geninc $(%(mmake)_OBJDIR)/%(modname)_incs \
2425 $(addsuffix .c,$(%(mmake)%(flavour)_LINKLIBFILES)) $(%(mmake)%(flavour)_LINKLIBOBJS) $(%(mmake)%(flavour)_LIBDEFSINC) \
2426 $(%(mmake)%(flavour)_DEFLIBDEFSINC) $(addsuffix .c,$(%(mmake)%(flavour)_STARTFILES) $(%(mmake)%(flavour)_ENDFILES)) \
2427 $(%(mmake)%(flavour)_ENDOBJS)
2428 %(mmake)-clean : FILES := $(%(mmake)%(flavour)_TOCLEAN)
2430 $(Q)$(ECHO) "Cleaning up for module %(modname)"
2433 endif # $(TARGET) in $(%(mmake)%(flavour)_ALLTARGETS)
2435 #------------------------------------------------------------------------------
2437 #------------------------------------------------------------------------------
2438 # Build a module - ABI and library
2439 # Explanation of this macro is done in the developer's manual
2440 %define build_module mmake=/A modname=/A modtype=/A modsuffix= version= flavour= conffile= \
2441 files="$(basename $(call WILDCARD, *.c))" \
2443 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2444 linklibfiles= linklibobjs= cflags=$(CFLAGS) cppflags=$(CPPFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= \
2445 objdir= moduledir= prefix=$(AROSDIR) \
2446 linklibname= uselibs= usehostlibs= \
2447 compiler=target funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO) nostartup=yes archspecific=no \
2448 include_set=includes-all includedir= libdir=
2450 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2451 modsuffix="%(modsuffix)" version="%(version)" flavour="%(flavour)" conffile="%(conffile)" \
2452 files="%(files)" objcfiles="%(objcfiles)" cxxfiles="%(cxxfiles)" \
2453 linklibname="%(linklibname)" \
2454 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2455 cflags="%(cflags)" cppflags="%(cppflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2456 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2457 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" funcinstr=%(funcinstr) lto=%(lto) \
2458 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2459 include_set=%(include_set) includedir="%(includedir)" libdir="%(libdir)" \
2460 build_abi=M build_library=M
2463 #------------------------------------------------------------------------------
2466 #------------------------------------------------------------------------------
2467 # Build a module skeleton ABI
2468 # This is a stripped-down version of build_module, it only creates include
2469 # files and the linklibs.
2470 # This is used when for plugins or classes with the same API, but no actual
2471 # implementation here.
2472 %define build_module_abi mmake=/A modname=/A modtype=/A modsuffix= version= flavour= conffile= \
2473 linklibfiles= linklibobjs= cflags=$(CFLAGS) cppflags=$(CPPFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= \
2474 objdir= moduledir= prefix=$(AROSDIR) \
2475 linklibname= uselibs= usehostlibs= \
2476 compiler=target nostartup=yes archspecific=no \
2477 include_set=includes-all includedir= libdir=
2479 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2480 modsuffix="%(modsuffix)" version="%(version)" flavour="%(flavour)" conffile="%(conffile)" \
2481 linklibname="%(linklibname)" \
2482 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2483 cflags="%(cflags)" cppflags="%(cppflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2484 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2485 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" lto=%(lto) \
2486 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2487 include_set=%(include_set) includedir="%(includedir)" libdir="%(libdir)" \
2488 build_abi=M build_library=
2491 #------------------------------------------------------------------------------
2493 #------------------------------------------------------------------------------
2494 # Build a module library - no includes nor linklibs
2495 # Explanation of this macro is done in the developer's manual
2496 %define build_module_library mmake=/A modname=/A modtype=/A modsuffix= version= flavour= conffile= \
2497 files="$(basename $(call WILDCARD, *.c))" \
2499 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2500 cflags=$(CFLAGS) cppflags=$(CPPFLAGS) dflags= cxxflags="$(CXXFLAGS)" dxxflags= \
2501 objdir= moduledir= prefix=$(AROSDIR) \
2502 uselibs= usehostlibs= \
2503 compiler=target lto=$(TARGET_LTO) nostartup=yes archspecific=no \
2504 include_set=includes-all includedir= libdir=
2506 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2507 modsuffix="%(modsuffix)" version="%(version)" flavour="%(flavour)" conffile="%(conffile)" \
2508 files="%(files)" objcfiles="%(objcfiles)" cxxfiles="%(cxxfiles)" \
2509 cflags="%(cflags)" cppflags="%(cppflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2510 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2511 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" lto=%(lto) \
2512 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2513 include_set=%(include_set) includedir="%(includedir)" libdir="%(libdir)" \
2514 build_abi= build_library=M
2517 #------------------------------------------------------------------------------
2521 #------------------------------------------------------------------------------
2523 # - mmake is the mmaketarget
2524 # - libname is the baselibname e.g. lib%(libname).a will be created
2525 # - files are the C source files to include in the lib. The list of files
2526 # has to be given without the .c suffix
2527 # - cxxfiles are C++ source files without suffix.
2528 # NB: files will be matched in the order .cpp > .cxx > .cc
2529 # - asmfiles are the asm files to include in the lib. The list of files has to
2530 # be given without the .s suffix
2531 # - objs additional object to link into the linklib. The objects have to be
2532 # given with full absolute path and the .o suffix.
2533 # - objdir is where the .o are generated. Defaults to $(GENDIR)/$(CURDIR)
2534 # - libdir is the directory where the linklib will be placed (default $(AROS_LIB))
2535 # - cflags are the flags to compile the source (default $(CFLAGS))
2536 # - dflags are the flags used during makedepend (default equal to cflags)
2537 # - aflags are the flags used during assembling (default $(AFLAGS))
2538 %define build_linklib mmake=/A libname=/A files= objcfiles= cxxfiles= \
2539 asmfiles= objs= objdir=$(GENDIR)/$(CURDIR) libdir=$(AROS_LIB) \
2540 includedir= srcdir= \
2541 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= \
2542 aflags=$(AFLAGS) compiler=target lto=$(TARGET_LTO) usetree=no
2544 # assign and generate the local variables used in this macro
2545 %(mmake)_LIBNAME := %(libname)
2546 %(mmake)_LINKLIB := %(libdir)/lib%(libname).a
2548 %(mmake)_FILES ?= %(files)
2549 %(mmake)_ASMFILES := %(asmfiles)
2550 %(mmake)_OBJCFILES := %(objcfiles)
2551 %(mmake)_CXXFILES := %(cxxfiles)
2553 %(mmake)_OBJDIR ?= %(objdir)
2554 %(mmake)_ARCHOBJS := $(wildcard $(%(mmake)_OBJDIR)/arch/*.o)
2555 ifeq (%(usetree),no)
2556 %(mmake)_ARCHFILES := $(basename $(notdir $(%(mmake)_ARCHOBJS)))
2558 %(mmake)_ARCHFILES := $(basename $(patsubst $(%(mmake)_OBJDIR)/%,%,$(%(mmake)_ARCHOBJS)))
2560 %(mmake)_C_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_FILES))
2561 %(mmake)_C_FILES ?= $(%(mmake)_C_NARCHFILES)
2562 %(mmake)_CXX_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_CXXFILES))
2563 %(mmake)_CXX_FILES ?= $(%(mmake)_CXX_NARCHFILES)
2564 %(mmake)_OBJC_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_OBJCFILES))
2565 %(mmake)_OBJC_FILES ?= $(%(mmake)_OBJC_NARCHFILES)
2567 ifeq (%(usetree),no)
2568 %(mmake)_OBJ_FILES ?= $(addprefix $(%(mmake)_OBJDIR)/,$(notdir $(%(mmake)_C_NARCHFILES:=.o) $(%(mmake)_CXX_NARCHFILES:=.o) $(%(mmake)_ASMFILES:=.o) $(%(mmake)_OBJC_NARCHFILES:=.o)))
2570 %(mmake)_OBJ_FILES ?= $(addprefix $(%(mmake)_OBJDIR)/,$(%(mmake)_C_NARCHFILES:=.o) $(%(mmake)_CXX_NARCHFILES:=.o) $(%(mmake)_ASMFILES:=.o) $(%(mmake)_OBJC_NARCHFILES:=.o))
2572 %(mmake)_OBJS ?= $(%(mmake)_ARCHOBJS) $(%(mmake)_OBJ_FILES) %(objs)
2573 %(mmake)_DEPS := $(patsubst %.o,%.d,$(%(mmake)_OBJS))
2575 %(mmake)_CPPFLAGS := %(cppflags)
2576 ifneq (%(includedir),)
2577 %(mmake)_CPPFLAGS += -I%(includedir)
2579 %(mmake)_CFLAGS := %(cflags)
2580 %(mmake)_CXXFLAGS := %(cxxflags)
2582 ifeq (%(compiler),target)
2583 %(mmake)_CFLAGS := $(strip $(LTO_CFLAGS) $(%(mmake)_CFLAGS))
2584 %(mmake)_CXXFLAGS := $(strip $(LTO_CFLAGS) $(%(mmake)_CXXFLAGS))
2587 %(mmake)_AFLAGS := %(aflags)
2588 %(mmake)_DFLAGS := %(dflags)
2590 %(mmake)_DFLAGS := %(dflags)
2592 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
2594 %(mmake)_DXXFLAGS := %(dxxflags)
2595 ifneq (%(dxxflags),)
2596 %(mmake)_DXXFLAGS := %(dxxflags)
2598 %(mmake)_DXXFLAGS := $(%(mmake)_CXXFLAGS)
2601 .PHONY : %(mmake) %(mmake)-clean %(mmake)-quick
2604 %(mmake)-quick : %(mmake)
2606 #MM %(mmake) : includes-generate-deps
2607 %(mmake) : $(%(mmake)_LINKLIB)
2609 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
2611 %rule_compile_cxx_multi mmake=%(mmake) \
2612 basenames=$(%(mmake)_CXX_FILES) targetdir="$(%(mmake)_OBJDIR)" \
2613 cppflags=$(%(mmake)_CPPFLAGS) cxxflags=$(%(mmake)_CXXFLAGS) dxxflags=$(%(mmake)_DXXFLAGS) \
2614 compiler="%(compiler)" srcdir=%(srcdir)
2615 %rule_compile_objc_multi mmake=%(mmake) \
2616 basenames=$(%(mmake)_OBJC_FILES) targetdir=$(%(mmake)_OBJDIR) \
2617 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
2618 compiler="%(compiler)" srcdir=%(srcdir)
2619 %rule_compile_multi mmake=%(mmake) \
2620 basenames=$(%(mmake)_C_FILES) targetdir="$(%(mmake)_OBJDIR)" \
2621 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
2622 compiler="%(compiler)" srcdir=%(srcdir) usetree=%(usetree)
2623 %rule_assemble basename=% targetdir="$(%(mmake)_OBJDIR)" \
2624 aflags=$(%(mmake)_AFLAGS)
2626 %rule_link_linklib mmake=%(mmake) libname="%(libname)" objs=$(%(mmake)_OBJS) libdir="%(libdir)" linker="%(compiler)"
2629 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(%(mmake)_DEPS)
2632 %rule_makedirs dirs="$(%(mmake)_OBJDIR) %(libdir)" setuptarget="$(%(mmake)_OBJS) $(%(mmake)_DEPS) $(%(mmake)_LINKLIB)"
2634 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_LINKLIB) $(%(mmake)_DEPS)
2637 $(Q)$(ECHO) "Cleaning up for metatarget %(mmake)"
2641 #------------------------------------------------------------------------------
2644 #------------------------------------------------------------------------------
2646 # - mmake is the mmaketarget
2647 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
2648 # - description is the catalog description file (.cd), without the .cd suffix (default *.cd)
2649 # - subdir is the destination subdirectory of the catalogs
2650 # - name is the name of the destination catalog, without the .catalog suffix
2651 # - source is the path to the generated source code file
2652 # - dir is the base destination directory (default $(AROS_CATALOGS))
2653 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
2654 # - srcdir is the directory in which the *.cd and *.ct files are searched
2656 %define build_catalogs mmake=/A name=/A subdir=/A \
2657 catalogs= source="../strings.h" description= dir=$(AROS_CATALOGS) \
2658 sourcedescription=$(TOOLDIR)/C_h_aros srcdir=$(SRCDIR)/$(CURDIR)
2660 ifeq (%(description),)
2661 %(mmake)_DESC := $(basename $(wildcard %(srcdir)/*.cd))
2663 %(mmake)_DESC := %(description)
2666 %(mmake)_SRC := $(shell echo %(sourcedescription) | sed 's/^\(.\):\//\/\1\//')
2669 %(mmake)_LNGS := $(basename $(notdir $(call WILDCARD, %(srcdir)/*.ct)))
2671 %(mmake)_LNGS := %(catalogs)
2674 %(mmake)_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, $(%(mmake)_LNGS)))
2675 %(mmake)_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, $(%(mmake)_LNGS))) $(dir %(source))
2678 %(mmake) : $(%(mmake)_OBJS) %(source)
2680 %rule_makedirs dirs="$(%(mmake)_DIRS)" setuptarget=$(%(mmake)_OBJS)
2682 %(dir)/%/%(subdir)/%(name).catalog : %(srcdir)/%.ct $(%(mmake)_DESC).cd
2683 $(Q)$(ECHO) "Creating %(name) catalog for language $*."
2684 $(Q)$(FLEXCAT) $(%(mmake)_DESC).cd $< CATALOG="%(dir)/$*/%(subdir)/%(name).catalog" || [ $$? -lt 10 ]
2687 %(source) : %(mmake)_DESC := $(%(mmake)_DESC)
2688 %(source) : %(mmake)_SRC := $(%(mmake)_SRC)
2689 %(source) : $(%(mmake)_DESC).cd $(%(mmake)_SRC).sd | $(dir %(source))
2690 $(Q)$(ECHO) "Creating %(name) catalog source file $@"
2691 $(Q)$(FLEXCAT) $(%(mmake)_DESC).cd $@=$(%(mmake)_SRC).sd
2694 %(mmake)-clean : FILES := $(%(mmake)_OBJS) %(source)
2697 $(Q)$(ECHO) "Cleaning up for metatarget %(mmake)"
2700 .PHONY: %(mmake) %(mmake)-clean
2703 #-----------------------------------------------------------------------------
2706 #-----------------------------------------------------------------------------
2708 # - mmake is the mmaketarget
2709 # - icons is a list of icon base names (i.e. without the .info suffix)
2710 # - dir is the destination directory
2711 # - srcdir is where *.png and *.info.src are sought
2712 #-----------------------------------------------------------------------------
2714 %define build_icons mmake=/A icons=/A dir=/A srcdir=$(SRCDIR)/$(CURDIR) image=
2716 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
2719 %(mmake) : $(BD_OBJS)
2723 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%.png
2724 $(Q)$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2725 $(Q)$(ILBMTOICON) $+ $@
2729 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%(image)
2730 $(Q)$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2731 $(Q)$(ILBMTOICON) $+ $@
2735 %rule_makedirs dirs="%(dir)" setuptarget=$(BD_OBJS)
2737 %(mmake)-clean : FILES := $(BD_OBJS)
2742 .PHONY: %(mmake) %(mmake)-clean
2745 #-----------------------------------------------------------------------------
2748 #------------------------------------------------------------------------------
2749 # Compile files for an arch-specific replacement of code for a module
2750 # - files: the basenames of the C files to compile.
2751 # - asmfiles: the basenames of the asm files to assemble.
2752 # - mainmmake: the mmake of the module in the main directory to compile these
2753 # arch specific files for.
2754 # - maindir: the object directory for the main module
2755 # - arch: the arch for which to compile these files. It can have the form
2756 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
2757 # - cflags (default $(CFLAGS)): the C flags to use for compilation
2758 # - dflags: the flags used during creation of dependency file. If not specified
2759 # the same value as cflags will be used
2760 # - aflags: the flags used during assembling
2761 # - compiler: (host, kernel or target) specifies which compiler to use. By default
2762 # the target compiler is used
2763 # - modname: arch_specific builds of modules (built using build_module) MUST
2764 # specify the name here matching the original module. this insures multiple modules
2765 # built from the same makefile will not pollute each other.
2766 %define build_archspecific files= cxxfiles= asmfiles= linklibfiles= linklibobjs= mainmmake=/A maindir=/A arch=/A \
2767 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target objdir= modname=
2769 ifeq (%(files) %(linklibfiles) %(linklibobjs) %(asmfiles),)
2770 $(error no files or asmfiles given)
2773 ifneq (%(cxxfiles),)
2774 $(error cxx support is TODO)
2777 %buildid targets="%(mainmmake)-%(arch)"
2779 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2780 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2781 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2782 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2783 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2784 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2785 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2786 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2787 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2788 #MM- %(mainmmake)-kobj-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2789 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2790 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2791 #MM- %(mainmmake)-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2792 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2793 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2795 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
2798 BD_OBJROOT$(BDID) := %(objdir)
2801 BD_OBJROOT$(BDID) := $(GENDIR)/%(maindir)/%(modname)
2803 BD_OBJROOT$(BDID) := $(GENDIR)/%(maindir)
2806 BD_OBJDIR$(BDID) := $(BD_OBJROOT$(BDID))/arch
2807 BD_LIBOBJDIR$(BDID) := $(BD_OBJROOT$(BDID))/linklib/arch
2808 BD_FILEOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files)))) $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(cxxfiles))))
2809 BD_LINKLIBOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibfiles))))
2810 BD_LINKLIBARCHOBJS$(BDID) := $(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibobjs)))
2811 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
2812 BD_OBJS$(BDID) := $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) $(BD_ASMOBJS$(BDID))
2813 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files)))) $(addsuffix .d,$(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibfiles))))
2816 BD_DEFLIBDEFSINC$(BDID) := -include $(BD_OBJROOT$(BDID))/include/%(modname)_deflibdefs.h
2819 ifeq ($(TARGET),%(mainmmake)-%(arch)-quick)
2820 BD_TARGET := %(mainmmake)-%(arch)-quick
2822 BD_TARGET := %(mainmmake)-%(arch)
2826 ifeq ($(TARGET),$(BD_TARGET))
2827 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
2828 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(files)))
2829 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(linklibfiles)))
2830 vpath %.s $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2831 vpath %.S $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2834 %rule_makedirs dirs="$(BD_OBJDIR$(BDID)) $(BD_LIBOBJDIR$(BDID))" setuptarget="$(BD_OBJS$(BDID))"
2837 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
2840 %(mainmmake)-%(arch)-quick :: $(BD_OBJS$(BDID))
2842 ifeq ($(findstring %(compiler),host kernel target),)
2843 $(error unknown compiler %(compiler))
2846 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=$(strip %(cppflags) -I$(BD_OBJROOT$(BDID)) $(BD_DEFLIBDEFSINC$(BDID)))
2848 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=%(cppflags)
2850 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
2851 ifeq (%(compiler),target)
2852 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
2853 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=$(TMP_CPPFLAGS)
2854 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=$(strip $(TMP_CFLAGS) $(SAFETY_CFLAGS))
2855 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
2856 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
2858 ifeq (%(compiler),host)
2859 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(HOST_CC)
2860 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
2861 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
2863 ifeq (%(compiler),kernel)
2864 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
2865 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=$(strip $(KERNEL_CPPFLAGS) $(TMP_CPPFLAGS))
2866 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(TMP_CFLAGS))
2867 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
2868 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
2871 ifeq ($(TARGET),$(BD_TARGET))
2872 $(BD_LIBOBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2873 %compile_q cmd=$(TMP_CMD) opt="$(strip $(TMP_CFLAGS) $(TMP_CPPFLAGS))" iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2874 $(BD_OBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2875 %compile_q cmd=$(TMP_CMD) opt="$(strip $(TMP_CFLAGS) $(TMP_CPPFLAGS))" iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2879 $(BD_DEPS$(BDID)) : TMP_CPPFLAGS:=$(strip %(cppflags) $(BD_DEFLIBDEFSINC$(BDID)))
2880 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags)
2882 $(BD_DEPS$(BDID)) : TMP_CPPFLAGS:=%(cppflags)
2883 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
2885 ifeq ($(TARGET),$(BD_TARGET))
2886 $(BD_LIBOBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2887 %mkdepend_q cc=$(TMP_CMD) flags="$(strip $(TMP_DFLAGS) $(TMP_CPPFLAGS))"
2889 $(BD_OBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2890 %mkdepend_q cc=$(TMP_CMD) flags="$(strip $(TMP_DFLAGS) $(TMP_CPPFLAGS))"
2893 $(BD_ASMOBJS$(BDID)) : CPPFLAGS:=%(cppflags)
2894 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
2896 ifeq ($(TARGET),$(BD_TARGET))
2897 $(BD_OBJDIR$(BDID))/%.o : %.s
2899 $(BD_OBJDIR$(BDID))/%.o : %.S
2903 %include_deps depstargets=$(BD_TARGET) deps=$(BD_DEPS$(BDID))
2905 #------------------------------------------------------------------------------
2908 #------------------------------------------------------------------------------
2909 # generate asm files from c files (for debugging purposes)
2912 $(Q)$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
2913 $(Q)$(TARGET_CC) $(TARGET_SYSROOT) -S $(CFLAGS) $(CPPFLAGS) $< -c -o $@
2915 #------------------------------------------------------------------------------
2918 #------------------------------------------------------------------------------
2919 # Copy files from one directory to another.
2921 %define copy_files_q mmake=/A files=$(FILES) src=. dst=/A
2923 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
2925 %rule_makedirs dirs="%(dst)"
2931 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC))/, $(file)) $(addprefix %(dst)/, $(file))))
2934 #------------------------------------------------------------------------------
2937 #------------------------------------------------------------------------------
2938 # Copy a directory recursively to another place, preserving the original
2939 # hierarchical structure
2941 # src: the source directory whose content will be copied.
2942 # dst: the directories where to copy src's content. If not existing, they will be made.
2943 # excludefiles: files which must not be copied. Path must be relative to src.
2945 %define copy_dir_recursive mmake=/A src=. dst=/A excludefiles=
2951 $(Q)cd $(SRCDIR)/$(CURDIR) && $(CPYDIRREC) -s %(src) -d %(dst) -e %(excludefiles)
2954 #------------------------------------------------------------------------------
2957 #------------------------------------------------------------------------------
2958 # Copy include files into the includes directories. There are currently
2959 # two include directories. One for building AROS $(AROS_INCLUDES) and one
2960 # for building tools that need to run on the host system $(GENINCDIR). The
2961 # $(GENINCDIR) path must not contain any references to the C runtime
2962 # library header files.
2964 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
2965 dir= compiler=target includedir=$(AROS_INCLUDES)
2967 ifeq ($(findstring %(compiler),host kernel target),)
2968 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
2973 $(eval TMP_DIRREMAIN := $$$(TMP_DIR))
2974 TMP_DIRFIRST := $(subst $(TMP_DIRREMAIN),,$(TMP_DIR))
2975 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),$(dir %(includes)))
2976 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,$(notdir %(includes)))
2977 ifeq ($(TMP_DIRFIRST),/)
2978 BD_INC_PATH := %(dir)/
2980 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
2983 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
2984 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
2987 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
2990 ifeq (%(compiler),target)
2993 BD_INCL_FILES2 := $(subst %(dir),%(includedir)/%(path),$(dir %(includes)))
2994 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,$(notdir %(includes)))
2996 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,%(includes))
2999 BD_INCL_FILES += $(BD_INCL_FILES2)
3001 $(BD_INCL_FILES2) : %(includedir)/%(path)/% : $(BD_INC_PATH)%
3006 %(mmake) : $(BD_INCL_FILES)
3010 %rule_makedirs dirs="$(dir $(BD_INCL_FILES))" setuptarget=$(BD_INCL_FILES)
3012 #------------------------------------------------------------------------------
3015 #------------------------------------------------------------------------------
3016 %define make_hidd_stubs hidd=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
3017 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
3018 STUBS_MEM := $(addsuffix .o,$(STUBS))
3019 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
3020 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
3021 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
3023 #MM- linklibs : hidd-%(hidd)-stubs
3024 #MM- %(parenttarget): hidd-%(hidd)-stubs
3025 #MM hidd-%(hidd)-stubs : includes includes-copy
3026 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
3028 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
3031 $(STUBS_OBJ) : $(STUBS_SRC)
3032 %compile_q cmd="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" opt="$(strip %(cflags) %(cppflags))" iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
3034 $(STUBS_DEP) : $(STUBS_SRC)
3035 %mkdepend_q flags="$(strip %(dflags) %(cppflags))"
3038 %mkdirs_q $(OBJDIR) $(AROS_LIB)
3042 -@$(RM) $(HIDD_LIB) $(OBJDIR)
3044 DEPS := $(DEPS) $(STUBS_DEP)
3047 #------------------------------------------------------------------------------
3050 #------------------------------------------------------------------------------
3051 # Build an imported source tree which uses the configure script from the
3052 # autoconf package. This rule will try to "integrate" the produced files as
3053 # much as possible in the AROS build, for example by putting libraries in the
3054 # standard library directory, includes in the standard include directory, and
3055 # so on. You can however override this behaviour.
3057 # As a special "bonus" for you, the PROGDIR environment variable is defined to
3058 # be %(bindir) (or its deduced value) when running "make install", and
3059 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
3060 # configure script some more parameters whose value depends upon the PROGDIR
3061 # env var, so that the program gets all its stuff installed in the proper place
3062 # when building it, but when running it from inside AROS it can also find that
3063 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
3064 # the configuration parameters set when running ./configure
3066 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
3067 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
3068 # to the name which has to follow it.
3072 # - mmake = the meta make target.
3073 # - package = name of the package to be built.
3074 # - srcdir = the location of the unpacked source code. Defaults
3075 # to $(SRCDIR)/$(CURDIR).
3076 # - prefix = the target directory. Must be an absolute path of the
3077 # host system. Defaults to $(AROS_CONTRIB).
3078 # - aros_prefix = set a path which is valid within the AROS filesystem.
3079 # Defaults to the value of the prefix option.
3080 # - extraoptions = additional options for the configure script.
3081 # - usecppflags = enable the use of cpp flags. some external configure
3082 # scripts will not set their own cppflags if it is already
3083 # set, so this allows them to be disabled (unless you can provide
3084 # all the options they would need)
3085 # - extracppflags = additional preprocessor flags.
3086 # - usecflags = same meaning as the one for the %build_with_configure macro.
3087 # - extracflags = additional flags to use with the C compiler.
3088 # - usecxxflags = same meaning as the one for the %build_with_configure macro.
3089 # - extracxxflags = additional flags to use with the C++ compiler.
3090 # - nix_dir_layout = if yes the binary will be stored in a bin subdirectory.
3091 # Defaults to the value of the nix argument.
3092 # - nix = enable u*nix path handling, i.e. a path like
3093 # /progdir//./file will be translated to
3094 # progdir:file during run-time. Defaults to no.
3095 # - compiler = target, host or kernel. Defaults to target.
3096 # - install_target = the command used for installing. Defaults to install. Leave
3097 # it empty if you want to suppress installing.
3098 # - preconfigure = a metatarget which is executed before configure is called.
3099 # - postconfigure = a metatarget which is executed after configure is called.
3100 # - postinstall = a metatarget which is executed after installing.
3101 # - install_env = set additional options for installing.
3102 # - use_build_env = if yes the configuration environment is used for
3103 # installing, too. Defaults to no.
3105 # The arguments aros_prefix, nix and nix_dir_layout are related. The logic is
3109 # --prefix = $(aros_prefix)
3110 # progdir = $(aros_prefix)/bin
3113 # --prefix = /PROGDIR
3114 # --bindir = /PROGDIR
3115 # --sbindir = /PROGDIR
3117 # --includedir = /INCLUDE
3118 # --oldincludedir = /INCLUDE
3120 # --prefix = $(aros_prefix)
3123 # progdir = $(aros_prefix)
3126 # bindir = $(prefix)
3127 # sbindir = $(prefix)
3128 # libdir = $(AROS_LIB)
3129 # includedir = $(AROS_INCLUDES)
3130 # oldincludedir = $(AROS_INCLUDES)
3134 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) \
3135 prefix= gendir= basedir=$(CURDIR) extraoptions= \
3136 usecppflags=yes extracppflags= \
3137 usecflags=yes extracflags="$(OPTIMIZATION_CFLAGS)" \
3138 usecxxflags=yes extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3140 kernelisaflags="$(TARGET_ISA_CFLAGS)" \
3141 targetisaflags="$(TARGET_ISA_CFLAGS)" \
3142 aros_prefix= nix_dir_layout= nix=no compiler=target crossbuild=no \
3143 install_target=install preconfigure= postconfigure= postinstall= \
3144 config_env_extra= install_env= use_build_env=no buildflags=yes gnuflags=yes nlsflag=yes xflag=yes
3147 %(mmake)-prefix := %(prefix)
3149 %(mmake)-prefix := $(AROS_CONTRIB)
3152 ifneq (%(aros_prefix),)
3153 %(mmake)-aros_prefix := %(aros_prefix)
3155 %(mmake)-aros_prefix := $(%(mmake)-prefix)
3161 %(mmake)-nix := $(BD_NIXFLAG)
3162 %(mmake)-volpfx := /
3163 %(mmake)-volsfx := /
3165 ifeq (%(nix_dir_layout),)
3166 %(mmake)-nix_dir_layout := yes
3169 %(mmake)-volsfx := :
3171 ifeq (%(nix_dir_layout),)
3172 %(mmake)-nix_dir_layout := no
3176 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
3178 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
3179 exec_prefix=$(%(mmake)-prefix) %(install_env)
3181 # Check if chosen compiler is valid
3182 ifeq ($(findstring %(compiler),host target kernel),)
3183 $(error unknown compiler %(compiler))
3186 # Set legacy 'host' variable based on chosen compiler
3187 ifeq (%(compiler),host)
3190 %(mmake)-pkgbasedir := $(HOSTGENDIR)
3192 %(mmake)-pkgbasedir := $(HOSTGENDIR)/%(basedir)
3197 %(mmake)-pkgbasedir := $(GENDIR)
3199 %(mmake)-pkgbasedir := $(GENDIR)/%(basedir)
3204 %(mmake)-pkgbasedir := %(gendir)
3206 %(mmake)-pkgbasedir := %(gendir)/%(basedir)
3211 %(mmake)-pkgdir := $(%(mmake)-pkgbasedir)
3213 %(mmake)-pkgdir := $(%(mmake)-pkgbasedir)/%(package)
3216 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
3217 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
3219 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
3220 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
3221 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
3224 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
3225 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
3227 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
3230 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
3232 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
3233 sbindir=$(%(mmake)-prefix) \
3234 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
3235 oldincludedir=$(AROS_INCLUDES) %(install_env)
3238 ifneq ($(DEBUG),yes)
3239 %(mmake)-s_flag = -s
3242 ifeq (%(usecflags),yes)
3243 %(mmake)-HOST_CFLAGS=%(hostisaflags) $(HOST_CFLAGS)
3244 %(mmake)-KERNEL_CFLAGS=%(kernelisaflags) $(KERNEL_CFLAGS) $$(%(mmake)-s_flag)
3245 ifeq (%(crossbuild),yes)
3246 %(mmake)-TARGET_CFLAGS=%(targetisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) $(%(mmake)-s_flag)
3248 %(mmake)-TARGET_CFLAGS=%(targetisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)
3251 ifeq (%(usecxxflags),yes)
3252 %(mmake)-HOST_CXXFLAGS=%(hostisaflags) $(HOST_CXXFLAGS)
3253 %(mmake)-KERNEL_CXXFLAGS=%(kernelisaflags) $(KERNEL_CXXFLAGS) $(%(mmake)-s_flag)
3254 ifeq (%(crossbuild),yes)
3255 %(mmake)-TARGET_CXXFLAGS=%(targetisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) $(%(mmake)-s_flag)
3257 %(mmake)-TARGET_CXXFLAGS=%(targetisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)
3261 # Set up build environment, and options for configure script
3262 ifeq (%(compiler),host)
3263 # NB: We need to pass in our crosstoolsdir, but cannot set CFLAGS since it
3264 # confused configure scripts. We also cannot pass it via _FOR_BUILD
3265 # since that won't get picked up during configure.
3266 # We also cannot pass in the compiler including std flags so we need to use
3267 # the "plain" host compiler.
3268 %(mmake)-cfg-env := %(config_env_extra) \
3270 CXXCPP="$(HOST_CPP)" \
3271 CC="$(strip $(HOST_DEF_CC) $(%(mmake)-HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include)" \
3272 CXX="$(strip $(HOST_CXX) $(%(mmake)-HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include)" \
3273 LDFLAGS="-L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS)"
3274 ifeq (%(usecppflags),yes)
3275 %(mmake)-cfg-env += TARGET_CPPFLAGS="$(KERNEL_CPPFLAGS)"
3277 %(mmake)-cfg-env += TARGET_CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
3278 TARGET_CFLAGS="$(strip $(%(mmake)-KERNEL_CFLAGS))" \
3279 TARGET_CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
3280 TARGET_CXXFLAGS="$(strip $(%(mmake)-KERNEL_CXXFLAGS))" \
3281 TARGET_AS="$(TARGET_AS)" \
3282 OBJCOPY="$(OBJCOPY)" \
3283 TARGET_RANLIB="$(RANLIB)" \
3284 TARGET_STRIP="$(STRIP_PLAIN)" \
3285 TARGET_NM="$(NM_PLAIN)" \
3286 TARGET_OBJCOPY="$(TARGET_OBJCOPY)"
3288 ifeq (%(compiler),target)
3289 %(mmake)-cfg-env := %(config_env_extra) \
3290 PKG_CONFIG_LIBDIR="$(AROS_DEVELOPER)/lib/pkgconfig" \
3291 PKG_CONFIG_SYSROOT_DIR="$(AROSDIR)"
3292 %(mmake)-cfg-env += CPP="$(strip $(TARGET_CPP) $(TARGET_SYSROOT))" \
3293 CXXCPP="$(strip $(TARGET_CPP) $(TARGET_SYSROOT))" \
3294 CC="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
3295 CXX="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
3296 LD="$(strip $(TARGET_LD))"
3297 %(mmake)-cfg-env += CFLAGS="$(%(mmake)-TARGET_CFLAGS) %(extracflags)" \
3298 CXXFLAGS="$(%(mmake)-TARGET_CXXFLAGS) %(extracxxflags)"
3299 ifeq (%(usecppflags),yes)
3300 %(mmake)-cfg-env += CPPFLAGS="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3302 %(mmake)-cfg-env += LDFLAGS="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))"
3303 ifeq (%(usecppflags),yes)
3304 %(mmake)-cfg-env += CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)"
3306 %(mmake)-cfg-env += CC_FOR_BUILD="$(strip $(HOST_DEF_CC))" \
3307 CFLAGS_FOR_BUILD="$(strip $(%(mmake)-HOST_CFLAGS))" \
3308 CXX_FOR_BUILD="$(strip $(HOST_CXX))" \
3309 CXXFLAGS_FOR_BUILD="$(strip $(%(mmake)-HOST_CXXFLAGS))" \
3310 LD_FOR_BUILD="$(strip $(HOST_LD))" \
3311 LDFLAGS_FOR_BUILD="$(strip $(HOST_LDFLAGS) $(%(mmake)-s_flag))"
3312 ifeq (%(usecppflags),yes)
3313 %(mmake)-cfg-env += CPPFLAGS_FOR_HOST="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3315 %(mmake)-cfg-env += CC_FOR_HOST="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
3316 CFLAGS_FOR_HOST="$(strip %(hostisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) -L$(AROS_DEVELOPER)/lib %(extracflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3317 CXX_FOR_HOST="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
3318 CXXFLAGS_FOR_HOST="$(strip %(hostisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) -L$(AROS_DEVELOPER)/lib %(extracxxflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3319 LD_FOR_HOST="$(strip $(TARGET_LD))" \
3320 LDFLAGS_FOR_HOST="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))"
3321 ifeq (%(usecppflags),yes)
3322 %(mmake)-cfg-env += CPPFLAGS_FOR_TARGET="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3324 %(mmake)-cfg-env += CC_FOR_TARGET="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
3325 CFLAGS_FOR_TARGET="$(strip $(%(mmake)-TARGET_CFLAGS) -L$(AROS_DEVELOPER)/lib %(extracflags))" \
3326 CXX_FOR_TARGET="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
3327 CXXFLAGS_FOR_TARGET="$(strip $(%(mmake)-TARGET_CXXFLAGS) -L$(AROS_DEVELOPER)/lib %(extracxxflags))" \
3328 LD_FOR_TARGET="$(strip $(TARGET_LD))" \
3329 LDFLAGS_FOR_TARGET="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3330 AR="$(strip $(AR_PLAIN))" \
3331 AS="$(strip $(TARGET_AS))" \
3332 OBJCOPY="$(strip $(OBJCOPY))" \
3333 RANLIB="$(strip $(RANLIB))" \
3334 STRIP="$(strip $(STRIP_PLAIN))"
3335 ifeq (%(usecppflags),yes)
3336 %(mmake)-cfg-env += TARGET_CPPFLAGS="$(KERNEL_CPPFLAGS)"
3338 %(mmake)-cfg-env += TARGET_CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
3339 TARGET_CFLAGS="$(strip $(%(mmake)-KERNEL_CFLAGS))" \
3340 TARGET_CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
3341 TARGET_CXXFLAGS="$(strip $(%(mmake)-KERNEL_CXXFLAGS))" \
3342 TARGET_AS="$(strip $(TARGET_AS))" \
3343 TARGET_RANLIB="$(strip $(RANLIB))" \
3344 TARGET_STRIP="$(strip $(STRIP_PLAIN))" \
3345 TARGET_NM="$(strip $(NM_PLAIN))"
3346 ifeq (%(buildflags),yes)
3347 %(mmake)-config_opts += --target=$(AROS_TARGET_CPU)-aros
3348 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)
3349 %(mmake)-config_opts += --host=$(AROS_TARGET_CPU)-aros
3351 ifeq (%(gnuflags),yes)
3352 %(mmake)-config_opts += --without-pic --disable-shared
3353 ifeq (%(nlsflag),yes)
3354 # disable native language support
3355 %(mmake)-config_opts += --disable-nls
3358 # disable X window system
3359 %(mmake)-config_opts += --without-x
3363 ifeq (%(compiler),kernel)
3364 %(mmake)-cfg-env := %(config_env_extra) \
3365 CPP="$(KERNEL_CPP)" \
3366 CXXCPP="$(KERNEL_CPP)"
3367 ifeq (%(usecppflags),yes)
3368 %(mmake)-cfg-env += CPPFLAGS="$(strip $(KERNEL_CPPFLAGS) %(extracppflags))"
3370 %(mmake)-cfg-env += CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
3371 CFLAGS="$(strip $(%(mmake)-KERNEL_CFLAGS) %(extracflags))" \
3372 CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
3373 CXXFLAGS="$(strip $(%(mmake)-KERNEL_CXXFLAGS) %(extracxxflags))" \
3375 ifeq (%(usecppflags),yes)
3376 %(mmake)-cfg-env += CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)"
3378 %(mmake)-cfg-env += CC_FOR_BUILD="$(HOST_DEF_CC)" \
3379 CFLAGS_FOR_BUILD="$(%(mmake)-HOST_CFLAGS)" \
3380 CXX_FOR_BUILD="$(HOST_CXX)" \
3381 CXXFLAGS_FOR_BUILD="$(%(mmake)-HOST_CXXFLAGS)" \
3382 RANLIB="$(RANLIB)" \
3383 TARGET_RANLIB="$(RANLIB)" \
3384 TARGET_STRIP="$(STRIP_PLAIN)" \
3385 TARGET_NM="$(NM_PLAIN)"
3386 ifeq (%(buildflags),yes)
3387 %(mmake)-config_opts += --target=$(AROS_TARGET_CPU)-aros
3388 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)
3389 %(mmake)-config_opts += --host=$(AROS_TARGET_CPU)-aros
3391 ifeq (%(gnuflags),yes)
3392 %(mmake)-config_opts += --without-pic --disable-shared
3393 ifeq (%(nlsflag),yes)
3394 # disable native language support
3395 %(mmake)-config_opts += --disable-nls
3398 # disable X window system
3399 %(mmake)-config_opts += --without-x
3405 ifeq (%(use_build_env),yes)
3406 BUILD_ENV := $(%(mmake)-cfg-env)
3409 %(mmake)-touchfileflag ?= $(%(mmake)-pkgdir)/.files-touched
3411 ifneq ("$(wildcard %(srcdir)/Makefile)","")
3412 # in an ideal world, we would depend on the files in the source directory,
3413 # so we could copy them when they change. unfortunately filenames with
3414 # spaces cause problems with this
3415 $(%(mmake)-pkgdir)/.local-copy:
3416 %mkdirs_q $(%(mmake)-pkgdir)
3417 $(Q)$(ECHO) "Copying Local-Build Sources to \`$(patsubst $(TOP)/%,%,$(abspath $(%(mmake)-pkgdir)))'"
3418 $(Q)$(CP) -Rf "%(srcdir)/." $(%(mmake)-pkgdir)/ && $(TOUCH) $@
3420 $(%(mmake)-touchfileflag) : $(%(mmake)-pkgdir)/.local-copy
3422 %(mmake)-cfg-srcdir=$(%(mmake)-pkgdir)
3424 %(mmake)-cfg-srcdir=%(srcdir)
3426 %(mmake)-make-env := -C $(%(mmake)-pkgdir)
3428 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3430 # When building for the host, we don't need to build the
3431 # linklibs - this is especially true when building the
3432 # crosstool toolchain on 'foreign' architectures (such as
3433 # building PPC on x86)
3435 #MM- %(mmake)-host : setup includes %(mmake)-quick
3436 #MM- %(mmake)-target : setup includes core-linklibs %(mmake)-quick
3437 #MM- %(mmake): %(mmake)-%(compiler)
3439 # Using -j1 in install_command may result in a warning but finally
3440 # it does its job. make install for gcc does not work reliably for -jN
3442 ifneq (%(install_target),)
3443 %(mmake)-install_command = \
3444 $(ECHO) "Installing from build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))" && \
3445 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
3446 $(%(mmake)-make-env) %(install_target) -j1
3448 %(mmake)-uninstall_command = \
3449 $(RM) $(%(mmake)-installflag) && \
3450 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" \
3451 $(%(mmake)-install_opts) $(%(mmake)-make-env) uninstall
3453 %(mmake)-install_command := true
3454 %(mmake)-uninstall_command := true
3457 #MM- %(mmake)-quick : %(preconfigure) %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
3460 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3463 # N.B.: the make test for the targets being up to date generates a benign Error 1.
3465 $(%(mmake)-installflag) : $(%(mmake)-configflag)
3466 $(Q)$(IF) ! $(BUILD_ENV) $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q $(%(mmake)-make-env); then \
3467 $(RM) $(%(mmake)-installflag) && \
3468 $(ECHO) "Performing build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))" && \
3469 $(BUILD_ENV) $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" $(%(mmake)-make-env) && \
3470 $(%(mmake)-install_command) && \
3471 $(TOUCH) $@ -r $^; \
3474 ifneq ($(%(mmake)-touchfileflag),)
3475 $(%(mmake)-touchfileflag):
3476 %mkdirs_q $(%(mmake)-pkgdir)
3477 $(Q)find %(srcdir) -exec $(TOUCH) -c -r $(%(mmake)-cfg-srcdir)/configure '{}' \; && \
3482 %(mmake)-uninstall :
3483 $(%(mmake)-uninstall_command)
3486 %(mmake)-configure : $(%(mmake)-configflag)
3488 $(%(mmake)-configflag) : TMP_SRCDIR := $(shell echo $(%(mmake)-cfg-srcdir) | sed 's/^\(.\):\//\/\1\//')
3489 $(%(mmake)-configflag) : $(%(mmake)-touchfileflag) $(TOP)/$(CURDIR)/mmakefile
3491 %mkdirs_q $(%(mmake)-pkgdir)
3492 $(Q)$(ECHO) "Configuring build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))"
3493 $(Q)cd $(%(mmake)-pkgdir) && \
3494 find . -name config.cache -exec $(RM) '{}' \; && \
3495 $(%(mmake)-cfg-env) $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) %(extraoptions) && \
3499 %(mmake)-clean : %(mmake)-uninstall
3500 $(Q)$(RM) $(%(mmake)-pkgdir)
3502 #------------------------------------------------------------------------------
3505 #------------------------------------------------------------------------------
3506 # Build an imported source tree which uses cmake
3510 # - mmake = the meta make target.
3511 # - package = name of the package to be built.
3512 # - srcdir = the location of the unpacked source code. Defaults
3513 # to $(SRCDIR)/$(CURDIR).
3514 # - prefix = the target directory. Must be an absolute path of the
3515 # host system. Defaults to $(AROS_CONTRIB).
3516 # - aros_prefix = set a path which is valid within the AROS filesystem.
3517 # Defaults to the value of the prefix option.
3518 # - extraoptions = additional options for the cmake script.
3519 # - usecppflags = enable the use of cpp flags. some external cmake
3520 # scripts will not set their own cppflags if it is already
3521 # set, so this allows them to be disabled (unless you can provide
3522 # all the options they would need)
3523 # - cppflags = preprocessor flags.
3524 # - extracppflags = additional preprocessor flags.
3525 # - usecflags = enable the use of the build systems C flags
3526 # - cflags = additional flags to use with the C compiler.
3527 # - usecxxflags = enable the use of the build systems C flags
3528 # - cxxflags = additional flags to use with the C++ compiler.
3529 # - cflags = flags to use with the C compiler.
3530 # - cxxflags = flags to use with the C++ compiler.
3531 # - installoptions = additional options for the install step.
3534 %define build_with_cmake mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) gendir= prefix= \
3535 aros_prefix= extraoptions= installoptions= maketarget= compiler=target \
3536 usecppflags=yes extracppflags=$(CPPFLAGS) \
3537 usecflags=yes extracflags=$(CFLAGS) \
3538 usecxxflags=yes extracxxflags=$(CXXFLAGS) \
3542 %(mmake)-prefix := %(prefix)
3544 %(mmake)-prefix := $(AROS_CONTRIB)
3547 ifneq (%(aros_prefix),)
3548 %(mmake)-aros_prefix := %(aros_prefix)
3550 %(mmake)-aros_prefix := $(%(mmake)-prefix)
3553 ifeq (%(compiler),host)
3554 BD_LDFLAGS := -L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS) %(extraldflags)
3555 BD_CFLAGS := $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include %(extracflags)
3556 BD_CXXFLAGS := $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include %(extracxxflags)
3557 BD_CPPFLAGS := $(HOST_CPPFLAGS) %(extracppflags)
3558 %(mmake)-cmake_opts := -DCMAKE_INSTALL_PREFIX=$(%(mmake)-prefix) -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(strip $(HOST_DEF_CC))"
3559 ifeq (%(usecflags),yes)
3560 %(mmake)-cmake_opts += -DCMAKE_C_FLAGS="$(strip $(BD_CFLAGS))"
3562 ifeq (%(usecppflags),yes)
3563 %(mmake)-cmake_opts += -DCMAKE_CPP_FLAGS="$(strip $(BD_CPPFLAGS))"
3565 %(mmake)-cmake_opts += -DCMAKE_CXX_COMPILER="$(strip $(HOST_CXX))"
3566 ifeq (%(usecxxflags),yes)
3567 %(mmake)-cmake_opts += -DCMAKE_CXX_FLAGS="$(strip $(BD_CXXFLAGS))"
3570 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
3572 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
3575 BD_LDFLAGS := $(strip $(LDFLAGS) %(extraldflags))
3576 BD_CFLAGS := $(strip $(CFLAGS) %(extracflags))
3577 BD_CXXFLAGS := $(strip $(CXXFLAGS) %(extracxxflags))
3578 BD_CPPFLAGS := $(strip $(CPPFLAGS) %(extracppflags))
3579 %(mmake)-cmake_opts := -DCMAKE_TOOLCHAIN_FILE=$(GENDIR)/config/conf.cmake -DCMAKE_INSTALL_PREFIX=$(%(mmake)-prefix)
3580 ifeq (%(usecflags),yes)
3581 %(mmake)-cmake_opts += -DCMAKE_C_FLAGS="$(strip $(BD_CFLAGS))"
3583 ifeq (%(usecppflags),yes)
3584 %(mmake)-cmake_opts += -DCMAKE_CPP_FLAGS="$(strip $(BD_CPPFLAGS))"
3586 ifeq (%(usecxxflags),yes)
3587 %(mmake)-cmake_opts += -DCMAKE_CXX_FLAGS="$(strip $(BD_CXXFLAGS))"
3589 %(mmake)-cmake_opts += -DCMAKE_EXE_LINKER_FLAGS="$(strip $(BD_LDFLAGS))"
3591 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
3593 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
3598 %(mmake)-pkgdir := %(gendir)/$(CURDIR)
3600 %(mmake)-pkgdir := %(gendir)/$(CURDIR)/%(package)
3604 %(mmake)-cmakeflag := $(%(mmake)-pkgdir)/.cmake
3605 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
3607 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3609 #MM- %(mmake): setup includes core-linklibs %(mmake)-quick
3611 #MM- %(mmake)-quick : %(mmake)-cmake %(mmake)-build_and_install-quick
3614 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3616 $(%(mmake)-installflag) : $(%(mmake)-cmakeflag)
3617 $(IF) ! $(MAKE) -q -C $(%(mmake)-pkgdir); then \
3618 $(RM) $(%(mmake)-installflag) && \
3619 $(MAKE) -C $(%(mmake)-pkgdir) %(maketarget) && \
3620 cd $(%(mmake)-pkgdir) && \
3621 cmake %(installoptions) -P cmake_install.cmake && \
3622 $(TOUCH) $@ -r $^; \
3625 %(mmake)-touchfileflag ?= $(%(mmake)-pkgdir)/.files-touched
3626 ifneq ($(%(mmake)-touchfileflag),)
3627 $(%(mmake)-touchfileflag):
3628 %mkdirs_q $(%(mmake)-pkgdir)
3629 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/CMakeLists.txt '{}' \; && \
3634 %(mmake)-cmake : $(%(mmake)-cmakeflag)
3636 $(%(mmake)-cmakeflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
3637 $(%(mmake)-cmakeflag) : $(%(mmake)-touchfileflag) $(TOP)/$(CURDIR)/mmakefile
3639 %mkdirs_q $(%(mmake)-pkgdir)
3640 cd $(%(mmake)-pkgdir) && \
3641 $(RM) -Rf CMakeCache.txt CMakeFiles \; && \
3642 cmake $(%(mmake)-cmake_opts) %(extraoptions) $(TMP_SRCDIR) && \
3646 %(mmake)-clean : %(mmake)-uninstall
3647 $(Q)$(RM) $(%(mmake)-pkgdir)
3649 #------------------------------------------------------------------------------
3652 #------------------------------------------------------------------------------
3653 # Given an archive name, patches names and locations where to find them, fetch
3654 # the archive and the patches from any of those locations, unpack the archive
3655 # and then apply the patches.
3657 # Locations currently supported are http and ftp sites, plus local filesystem
3658 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
3659 # the fetch.sh script needs to be modified, since this macro relies on that script.
3663 # - mmake = mmaketarget
3664 # - archive_origins = list of locations where to find the archive. They are tried
3665 # in sequence, until the archive is found and fetching it
3666 # succeeded. If not specified, the current directory is assumed.
3667 # - archive = the archive name. Mandatory.
3668 # - suffixes = a list of suffixes to append to the package name plus the
3669 # version. Each one of them is tried until a matching archive is
3670 # found. They are appended to patches and these are tried the
3671 # same way as packages are.
3672 # - location = the local directory where to put the fetched archive and patches.
3673 # If not specified, the directory specified by destination is used.
3674 # - destination = the directory to unpack the archive to.
3675 # If not specified, the current directory is assumed.
3676 # - patches_origins = list of locations where to find the patches. They are tried
3677 # in sequence, until a patch is found and fetching it
3678 # succeeded. If not specified, the current directory is assumed.
3679 # - patches_specs = list of "patch specs". A patch spec is of the form
3680 # patch_name[:[patch_subdir][:patch_opt]].
3682 # - patch_name = the name of the patch file
3683 # - patch_subdir = the directory within \destination\ where to
3685 # - patch_opt = any options to pass to the `patch' command
3686 # when applying the patch.
3688 # The patch_subdir and patch_opt fields are optional.
3690 %define fetch mmake=/A archive_origins=. archive=/A suffixes= location= destination=. \
3691 patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
3695 ifneq (%(location),)
3696 %(mmake)-location := %(location)
3698 %(mmake)-location := %(destination)
3701 %(mmake)-fetchedflag := $(%(mmake)-location)/.%(archive)-fetched
3705 $(Q)$(ECHO) "Fetching %(archive) ..."
3706 $(Q)$(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
3707 -d %(destination) -po "%(patches_origins)" -p "%(patches_specs)"
3708 $(Q)$(IF) ! $(TEST) -f $(%(mmake)-fetchedflag) ; then \
3709 $(TOUCH) $(%(mmake)-fetchedflag) ; \
3712 # $(Q)$(IF) ! $(TEST) -f $(%(mmake)-fetchedflag) ; then \
3713 # $(ECHO) "Fetching %(archive) ..." \
3714 # && $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
3715 # -d %(destination) -po "%(patches_origins)" -p "%(patches_specs)" \
3716 # && $(TOUCH) $(%(mmake)-fetchedflag) ; \
3719 #------------------------------------------------------------------------------
3722 #------------------------------------------------------------------------------
3723 # This macro can aid in patch creation for fetched ports. It temporarily creates another
3724 # unpatched source tree and runs diff against this and a previously fetched and possibly
3725 # patched tree. Depending on what happens after patching during a normal build it might
3726 # give best results if the new patch is created directly after fetch.
3730 # - mmake = mmaketarget
3731 # - archive = archive base name
3732 # - srcdir = the top level directory the package is unpacked to, useful if
3733 # an archive unpacks to a directory other than its name suggests.
3734 # this should not be deeper than a single path element.
3735 # - suffixes = a list of suffixes to append to the the package name plus the
3736 # version. Each one of them is tried until a matching archive is
3738 # - destination = the directory to unpack the archive to.
3739 # - excludes = diff patterns to exclude files or directories from the patch
3741 %define create_patch mmake=/A archive=/A srcdir= suffixes="tar.bz2 tar.gz" destination=/A excludes=
3745 ifneq (%(excludes),)
3746 %(mmake)-exclude := -X ./exclude.patterns
3750 %(mmake)-srcdir := %(srcdir)
3752 %(mmake)-srcdir := %(archive)
3755 #MM- %(mmake) : %(mmake)-diff
3756 #MM- %(mmake)-quick : %(mmake)-diff
3760 $(Q)$(FETCH) -a %(archive) -s "%(suffixes)" -l $(PORTSSOURCEDIR) -d %(destination)/tmp ; \
3761 $(MV) %(destination)/$(%(mmake)-srcdir) %(destination)/tmp/$(%(mmake)-srcdir).aros ; \
3762 cd %(destination)/tmp ; \
3763 $(FOR) f in %(excludes) ; do \
3764 $(ECHO) $$f >> ./exclude.patterns ; \
3766 $(ECHO) "Creating \`%(archive)-aros-new.diff'" ; \
3767 diff -ruN $(%(mmake)-exclude) \
3768 $(%(mmake)-srcdir) \
3769 $(%(mmake)-srcdir).aros \
3770 >$(SRCDIR)/$(CURDIR)/%(archive)-aros-new.diff ; \
3771 $(MV) %(destination)/tmp/$(%(mmake)-srcdir).aros %(destination)/$(%(mmake)-srcdir) ; \
3772 $(RM) %(destination)/tmp
3774 #------------------------------------------------------------------------------
3777 #------------------------------------------------------------------------------
3778 # Joins the features of %fetch and %build_with_configure.
3780 # If a patch is provided, it *must* be named the following way:
3782 # <package name>-<version number>-aros.diff
3784 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3785 # CD'ing into the archive's extracted directory.
3787 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3788 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3789 # to make that patch fully comprehensive.
3793 # - mmake = the meta make target.
3794 # - package = the GNU package name, sans version and archive format suffixes.
3795 # - subpackage = ???
3796 # - compiler = same meaning as the one for the %build_with_configure macro.
3797 # - install_target = same meaning as the one for the %build_with_configure macro.
3798 # - version = the package's version number, or otherwise any other version string.
3799 # It gets appended to the package name to form the basename of the archive.
3800 # - suffixes = a list of suffixes to apped to the the package name plus the
3801 # version. Each one of them is tried until a matching archive is found.
3802 # Defaults to "tar.bz2 tar.gz".
3803 # - srcdir = the top level directory the package is unpacked to (see create_patch).
3804 # - builddir = override the location we expect to run configure/make in.
3805 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
3806 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
3807 # fetched or not. Default to no.
3808 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
3809 # - prefix = same meaning as the one for the %build_with_configure macro.
3810 # - aros_prefix = same meaning as the one for the %build_with_configure macro.
3811 # - extraoptions = same meaning as the one for the %build_with_configure macro.
3812 # - usecppflags = same meaning as the one for the %build_with_configure macro.
3813 # - extracppflags = same meaning as the one for the %build_with_configure macro.
3814 # - usecflags = same meaning as the one for the %build_with_configure macro.
3815 # - extracflags = same meaning as the one for the %build_with_configure macro.
3816 # - usecxxflags = same meaning as the one for the %build_with_configure macro.
3817 # - extracxxflags = same meaning as the one for the %build_with_configure macro.
3818 # - preconfigure = same meaning as the one for the %build_with_configure macro.
3819 # - postconfigure = same meaning as the one for the %build_with_configure macro.
3820 # - postinstall = same meaning as the one for the %build_with_configure macro.
3821 # - install_env = same meaning as the one for the %build_with_configure macro.
3822 # - use_build_env = same meaning as the one for the %build_with_configure macro.
3823 # - nix = same meaning as the one for the %build_with_configure macro.
3824 # - nix_dir_layout = same meaning as the one for the %build_with_configure macro.
3825 # - create_pkg = create a distributable package of the compiled sources, defaults to no
3827 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target crossbuild=no install_target=install \
3828 version=/A suffixes="tar.bz2 tar.gz" srcdir= builddir= gendir= basedir=$(CURDIR) package_repo= patch=no patch_repo= \
3829 prefix= aros_prefix= preconfigure= postconfigure= postinstall= \
3831 usecppflags=yes extracppflags= \
3832 usecflags=yes extracflags="$(OPTIMIZATION_CFLAGS)" \
3833 usecxxflags=yes extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3834 config_env_extra= install_env= use_build_env=no nix=no nix_dir_layout= create_pkg=no \
3835 buildflags=yes gnuflags=yes nlsflag=yes xflag=yes \
3836 hostisaflags= kernelisaflags="$(TARGET_ISA_CFLAGS)" targetisaflags="$(TARGET_ISA_CFLAGS)"
3838 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
3839 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
3840 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
3841 #MM- %(mmake)-create-patch : %(mmake)-%(subpackage)-create-patch
3842 #MM- %(mmake)-create-patch-quick : %(mmake)-%(subpackage)-create-patch
3844 %(mmake)-archbase := %(package)-%(version)
3846 ifeq (%(compiler),host)
3847 %(mmake)-portdir := $(HOSTDIR)/Ports/host/%(package)
3849 %(mmake)-portdir := $(PORTSDIR)/%(package)
3853 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
3855 %(mmake)-prefix := %(prefix)
3858 ifneq (%(subpackage),)
3859 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
3861 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
3865 %(mmake)-%(subpackage)-srcdir := %(srcdir)
3867 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
3870 ifneq (%(builddir),)
3871 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)/%(builddir)
3873 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)
3877 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-f,-p1
3879 %(mmake)-%(subpackage)-patches_specs := ::
3882 %fetch mmake="%(mmake)-%(subpackage)-fetch" archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
3883 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
3884 archive_origins=". %(package_repo)" \
3885 patches_specs=$(%(mmake)-%(subpackage)-patches_specs) patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
3887 %create_patch mmake="%(mmake)-%(subpackage)-create-patch" \
3888 archive=$(%(mmake)-%(subpackage)-archbase) \
3889 srcdir=$(%(mmake)-%(subpackage)-srcdir) \
3890 suffixes="%(suffixes)" \
3891 destination=$(%(mmake)-portdir)
3893 #MM %(mmake) : %(mmake)-%(subpackage)
3898 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
3900 %(mmake)-%(subpackage)-package-basename := \
3901 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
3903 ifneq (%(create_pkg),no)
3904 %(mmake)-%(subpackage)-package := $(%(mmake)-%(subpackage)-package-basename).tar.bz2
3907 %build_with_configure mmake="%(mmake)-%(subpackage)" package="%(package)" compiler="%(compiler)" crossbuild="%(crossbuild)" install_target="%(install_target)" \
3908 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-builddir) gendir="%(gendir)" basedir="%(basedir)" \
3909 config_env_extra="%(config_env_extra)" install_env="%(install_env)" use_build_env="%(use_build_env)" \
3910 nix="%(nix)" nix_dir_layout="%(nix_dir_layout)" prefix=$(%(mmake)-prefix) aros_prefix="%(aros_prefix)" \
3911 preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall) %(mmake)-%(subpackage)-make-package" \
3912 extraoptions="%(extraoptions)" \
3913 usecppflags="%(usecppflags)" extracppflags="%(extracppflags)" \
3914 usecflags="%(usecflags)" extracflags="%(extracflags)" \
3915 usecxxflags="%(usecxxflags)" extracxxflags="%(extracxxflags)" \
3916 buildflags=%(buildflags) gnuflags=%(gnuflags) nlsflag=%(nlsflag) xflag=%(xflag) \
3917 hostisaflags=%(hostisaflags) kernelisaflags="%(kernelisaflags)" targetisaflags=%(targetisaflags)
3919 .PHONY : %(mmake)-%(subpackage)-make-package %(mmake)-%(subpackage)-create-patch
3920 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
3923 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package)
3925 #There seems to be a bug, either with my clock or with make, 'cause it may happen
3926 #that $^ and $@ have exactly the same mtime, and in that case make tries
3927 #to rebuild $@ again, which would fail because the directory where
3928 #the package got installed would not exist anymore.
3929 #We work this around by using an if statement to manually check the mtimes.
3930 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
3931 $(Q)$(IF) $(TEST) $(%(mmake)-installflag) -nt $@ || ! $(TEST) -s $@; then \
3933 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
3934 $(MKDIR) -p "$(DISTDIR)/Packages" ; \
3935 $(MKDIR) -p "$(%(mmake)-prefix)" ; \
3936 cd $(%(mmake)-%(subpackage)-package-dir) ; \
3937 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
3938 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
3941 #------------------------------------------------------------------------------
3944 #------------------------------------------------------------------------------
3945 # Joins the features of %fetch and %build_with_configure, taking advantage of
3946 # the naming scheme of GNU packages. GNU packages names are in the form
3948 # <package name>-<version number>.<archive format suffix>
3950 # If a patch is provided, it *must* be named the following way:
3952 # <package name>-<version number>-aros.diff
3954 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3955 # CD'ing into the archive's extracted directory.
3957 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3958 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3959 # to make that patch fully comprehensive.
3961 # NOTE: GNU packages are always compiled with *nix semantics turned on.
3965 # Arguments have the same meaning as the one for the %fetch_and_build macro, except:
3967 # - prefix = defaults to $(GNUDIR).
3968 # - aros_prefix = defaults to /GNU.
3970 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A crossbuild=no suffixes="tar.bz2 tar.gz" \
3971 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
3972 aros_prefix=/GNU config_env_extra= preconfigure= postconfigure= postinstall= \
3974 usecppflags=yes extracppflags= \
3975 usecflags=yes extracflags="$(OPTIMIZATION_CFLAGS)" \
3976 usecxxflags=yes extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3978 kernelisaflags="$(TARGET_ISA_CFLAGS)" \
3979 targetisaflags="$(TARGET_ISA_CFLAGS)" \
3980 use_build_env=no nix=yes gnuflags=yes nlsflag=yes xflag=yes
3982 GNU_REPOSITORY := gnu://
3984 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
3985 crossbuild="%(crossbuild)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
3986 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
3987 patch="%(patch)" patch_repo="%(patch_repo)" \
3988 prefix="%(prefix)" aros_prefix="%(aros_prefix)" \
3989 extraoptions="%(extraoptions)" \
3990 usecppflags="%(usecppflags)" extracppflags="%(extracppflags)" \
3991 usecflags="%(usecflags)" extracflags="%(extracflags)" \
3992 usecxxflags="%(usecxxflags)" extracxxflags="%(extracxxflags)" \
3993 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" \
3994 hostisaflags="%(hostisaflags)" kernelisaflags="%(kernelisaflags)" targetisaflags="%(targetisaflags)" \
3995 use_build_env=%(use_build_env) nix=%(nix) gnuflags=%(gnuflags) nlsflag=%(nlsflag) xflag=%(xflag)
3998 #------------------------------------------------------------------------------
4001 #------------------------------------------------------------------------------
4002 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
4003 # that the package is a "Developer" package, and as such it needs to be placed
4004 # under the $(AROS_DEVELOPER) directory, as a default.
4006 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
4007 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
4008 # "mmake" argument, because the metatarget is implicitely defined as
4010 # #MM- development-%(package)
4012 %define fetch_and_build_gnu_development package=/A subpackage= version=/A crossbuild=no suffixes="tar.bz2 tar.gz" \
4013 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPER) \
4014 aros_prefix=/Developer config_env_extra= preconfigure= postconfigure= postinstall= \
4016 usecppflags=yes extracppflags= \
4017 usecflags=yes extracflags="$(OPTIMIZATION_CFLAGS)" \
4018 usecxxflags=yes extracxxflags="$(OPTIMIZATION_CFLAGS)" \
4020 kernelisaflags="$(TARGET_ISA_CFLAGS)" \
4021 targetisaflags="$(TARGET_ISA_CFLAGS)" \
4022 use_build_env=no nix=yes gnuflags=yes nlsflag=yes xflag=yes
4024 #MM- development : development-%(package)
4027 %fetch_and_build_gnu mmake="development-%(package)" package="%(package)" subpackage="%(subpackage)" \
4028 version="%(version)" crossbuild="%(crossbuild)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
4029 package_repo="%(package_repo)" \
4030 patch="%(patch)" patch_repo="%(patch_repo)" \
4031 prefix="%(prefix)" aros_prefix="%(aros_prefix)" \
4032 extraoptions="%(extraoptions)" \
4033 usecppflags="%(usecppflags)" extracppflags="%(extracppflags)" \
4034 usecflags="%(usecflags)" extracflags="%(extracflags)" \
4035 usecxxflags="%(usecxxflags)" extracxxflags="%(extracxxflags)" \
4036 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="postinstall-%(package)-delete-la-files %(postinstall)" \
4037 hostisaflags="%(hostisaflags)" kernelisaflags="%(kernelisaflags)" targetisaflags="%(targetisaflags)" \
4038 use_build_env=%(use_build_env) nix=%(nix) gnuflags=%(gnuflags) nlsflag=%(nlsflag) xflag=%(xflag)
4041 postinstall-%(package)-delete-la-files:
4042 $(RM) %(prefix)/lib/*.la
4045 #------------------------------------------------------------------------------
4047 # Builds a kickstart package in PKG format
4051 # - mmake = target name
4052 # - file = destination file name with path
4054 # Other arguments are self-explanatory
4056 %define make_package mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
4057 arch_classes= arch_devs= arch_handlers= arch_hidds= arch_libs= arch_res=
4059 PKG_CLASSES := $(addprefix $(AROS_CLASSES)/,$(addsuffix .class, %(classes)))
4060 PKG_DEVICES := $(addprefix $(AROS_DEVS)/,$(addsuffix .device, %(devs)))
4061 PKG_HANDLERS := $(addprefix $(AROS_FS)/,$(addsuffix -handler, %(handlers)))
4062 PKG_HIDD := $(addprefix $(AROS_DEVS)/Drivers/,$(addsuffix .hidd, %(hidds)))
4063 PKG_LIBS := $(addprefix $(AROS_LIBRARIES)/,$(addsuffix .library, %(libs)))
4064 PKG_RESOURCES := $(addprefix $(AROS_DEVS)/,$(addsuffix .resource, %(res)))
4066 PKG_CLASSES_ARCH := $(addprefix $(AROS_CLASSES_ARCH)/,$(addsuffix .class, %(arch_classes)))
4067 PKG_DEVICES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .device, %(arch_devs)))
4068 PKG_HANDLERS_ARCH := $(addprefix $(AROS_FS_ARCH)/,$(addsuffix -handler, %(arch_handlers)))
4069 PKG_HIDD_ARCH := $(addprefix $(AROS_DEVS_ARCH)/Drivers/,$(addsuffix .hidd, %(arch_hidds)))
4070 PKG_LIBRARIES_ARCH := $(addprefix $(AROS_LIBRARIES_ARCH)/,$(addsuffix .library, %(arch_libs)))
4071 PKG_RESOURCES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .resource, %(arch_res)))
4073 PKG_FILES := $(PKG_CLASSES) $(PKG_DEVICES) $(PKG_HANDLERS) $(PKG_HIDD) $(PKG_LIBS) $(PKG_RESOURCES) \
4074 $(PKG_CLASSES_ARCH) $(PKG_DEVICES_ARCH) $(PKG_HANDLERS_ARCH) $(PKG_HIDD_ARCH) $(PKG_LIBRARIES_ARCH) $(PKG_RESOURCES_ARCH)
4075 PKG_DIR := $(dir %(file))
4081 %(mmake)-quick : %(file)
4083 %(file): $(PKG_FILES) | $(PKG_DIR)
4084 $(Q)$(ECHO) Packaging $@...
4085 $(Q)$(SRCDIR)/tools/package/pkg c $@ $^
4087 %compress_file mmake="%(mmake)" file="%(file)"
4089 %rule_makedirs dirs="$(PKG_DIR)"
4093 #------------------------------------------------------------------------------
4094 # Compresses %(file) with a gzip.
4095 # Good in conjunction with for example %build_prog
4097 %define compress_file mmake=/A file=/A
4099 #MM- %(mmake)-gz : %(mmake) %(mmake)-gz-quick
4102 %(mmake)-gz-quick : %(file).gz
4105 $(Q)$(ECHO) Compressing $(subst $(TARGETDIR)/,,$^)...
4110 #------------------------------------------------------------------------------
4111 # Links a kickstart module in ELF format
4112 # Arguments are similar to make_package
4114 %define link_kickstart mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
4115 startup= uselibs= ldflags=$(LDFLAGS) map= deps=
4117 KOBJ_CLASSES := $(addprefix $(KOBJSDIR)/, $(addsuffix _class.o, %(classes)))
4118 KOBJ_DEVICES := $(addprefix $(KOBJSDIR)/, $(addsuffix _device.o, %(devs)))
4119 KOBJ_HANDLERS := $(addprefix $(KOBJSDIR)/, $(addsuffix _handler.o, %(handlers)))
4120 KOBJ_HIDD := $(addprefix $(KOBJSDIR)/, $(addsuffix _hidd.o, %(hidds)))
4121 KOBJ_LIBS := $(addprefix $(KOBJSDIR)/, $(addsuffix _library.o, %(libs)))
4122 KOBJ_RES := $(addprefix $(KOBJSDIR)/, $(addsuffix _resource.o, %(res)))
4125 KOBJ_STARTUP := $(GENDIR)/$(RESIDENT_BEGIN).o
4127 KOBJ_STARTUP := %(startup)
4130 KOBJS := $(KOBJ_STARTUP) $(KOBJ_CLASSES) $(KOBJ_HANDLERS) $(KOBJ_LIBS) $(KOBJ_DEVICES) $(KOBJ_HIDD) $(KOBJ_RES)
4132 TMP_LDFLAGS := %(ldflags)
4134 # Make a list of the lib files this program depends on.
4135 # In LDFLAGS remove white space between -L and directory
4136 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
4137 # Filter out only the libdirs and remove -L
4138 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
4140 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
4141 # Add normal linklib path
4142 TMP_DIRS += $(AROS_LIB)/
4143 # add lib and .a to static linklib names
4144 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
4145 # search for the linklibs in the given path, ignore ones not found
4146 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS),$(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))))
4148 TMP_DIRS += $(dir %(file))
4150 TMP_LDFLAGS += $(GENMAP) %(map)
4151 TMP_DIRS += $(dir %(map))
4154 #MM %(mmake) : %(deps)
4160 %(mmake)-quick : %(file)
4162 %(file): KOBJS := $(KOBJS)
4163 %(file): LDFLAGS := $(TMP_LDFLAGS) $(NOSTARTUP_LDFLAGS) \
4164 -static -nosysbase -Wl,-Ur
4165 %(file): LDLIBS := $(addprefix -l, %(uselibs))
4166 %(file): $(KOBJS) $(DEPLIBS) | $(TMP_DIRS)
4167 $(Q)$(ECHO) "Kickstart $(subst $(TARGETDIR)/,,$@)..."
4168 $(Q)$(TARGET_CC) $(TARGET_SYSROOT) -o $@ $(KOBJS) $(LDFLAGS) $(LDLIBS)
4170 $(Q)$(STRIP) $@ --only-keep-debug -o $@.dbg
4174 $(Q)$(OBJCOPY) --add-gnu-debuglink=$@.dbg $@
4177 %compress_file mmake="%(mmake)" file="%(file)"
4179 %rule_makedirs dirs="$(TMP_DIRS)"
4183 #------------------------------------------------------------------------------
4184 # Generate generic rules for a subtarget
4186 %define subtarget parentmmake= mmake=/A mmbase=MM-
4187 #%(mmbase) %(parentmmake) : %(mmake)
4188 #%(mmbase) %(parentmmake)-includes : %(mmake)-includes
4189 #%(mmbase) %(parentmmake)-quick : %(mmake)-quick
4192 #------------------------------------------------------------------------------
4193 # Create a target directory
4195 %define directorytarget mmake=/A directory= icontarget= mmbase=MM-
4198 %mkdirs_q %(directory)
4200 #%(mmbase) %(mmake) : %(mmake)-makedir