1 #############################################################################
2 #############################################################################
4 ## Here are the mmakefile macros that are used as commands in the body ##
6 ## They are used to help the portability of mmakefiles to different ##
7 ## platforms and also will handle the error handling in a standard way. ##
9 #############################################################################
10 #############################################################################
12 #------------------------------------------------------------------------------
13 # Convert the ISO-8859-1 string in %(string) to the host's locale (if necessary)
14 %define localisestr string= var=
15 ifeq (,$(findstring "ISO-8859-1",$(LOCALE)))
16 %(var) := $(shell echo %(string) | iconv -f iso-8859-1 )
22 #------------------------------------------------------------------------------
23 # Compile the file %(from) to %(to) with %(cmd). Write any errors to %(err)
24 # and use the options in %(opt). Use %(iquote) and %(iquote_end) for supplying -iquote or -I- flags
25 %define compile_q cmd="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" opt="$(strip $(CFLAGS) $(CPPFLAGS))" from=$< to=$@ iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
26 $(Q)$(ECHO) "Compiling $(if $(filter /%,%(from)),$(if $(filter $(SRCDIR)/%,$(abspath %(from))),$(patsubst $(SRCDIR)/%,%,$(abspath %(from))),$(patsubst $(TOP)/%,%,$(abspath %(from)))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/%(from))))"
27 $(Q)$(IF) %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -D__SRCFILENAME__="\"$(subst $(TOP)/,,$(subst $(SRCDIR)/,,$(abspath %(from))))"\" -c %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
28 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
29 $(ECHO) "%(from): %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -D__SRCFILENAME__=\"$(subst $(TOP)/,,$(subst $(SRCDIR)/,,$(abspath %(from))))\" -c %(from) -o %(to)" >> $(GENDIR)/errors ; \
30 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors ; \
35 $(ECHO) "Compile failed: %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -D__SRCFILENAME__=\"$(subst $(TOP)/,,$(subst $(SRCDIR)/,,$(abspath %(from))))\" -c %(from) -o %(to)" 1>&2 ; \
36 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
40 #------------------------------------------------------------------------------
43 #------------------------------------------------------------------------------
44 # Assemble the file %(from) to %(to) with %(cmd) with the options in %(opt).
45 %define assemble_q cmd="$(strip $(CC) $(TARGET_SYSROOT))" opt="$(strip $(AFLAGS) $(CPPFLAGS))" from=$< to=$@
46 $(Q)$(ECHO) "Assembling $(notdir %(from))..."
47 $(Q)$(IF) %(cmd) %(opt) %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
48 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
49 $(ECHO) "$(notdir %(from)): %(cmd) %(opt) %(from) -o %(to)" >> $(GENDIR)/errors ; \
50 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
55 $(ECHO) "Assemble failed: %(cmd) %(opt) %(from) -o %(to)" 1>&2 ; \
56 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
60 #-------------------------------------------------------------------------
63 #------------------------------------------------------------------------------
64 # Strip symbols from the specified file
65 %define strip_q strip=$(STRIP) file=
66 $(Q)$(IF) $(TEST) "%(strip)" != ""; then \
67 $(IF) $(TEST) "$(DEBUG)" = "yes"; then \
68 %(strip) %(file) --only-keep-debug -o %(file).dbg ; \
71 $(IF) $(TEST) "$(DEBUG)" = "yes"; then \
72 $(IF) $(TEST) -s %(file).dbg ; then \
73 $(OBJCOPY) --add-gnu-debuglink=%(file).dbg %(file) ; \
78 #------------------------------------------------------------------------------
80 #------------------------------------------------------------------------------
81 # Link a specified number of objects to an executable
82 %define link_q cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" opt=$(LDFLAGS) from=$< to=$@ libs=$(LIBS) strip=$(STRIP) objdir=$(GENDIR)/$(CURDIR) coverageinstr=
83 $(Q)$(eval LINKTARGET=%(to))
84 $(Q)$(ECHO) "Linking $(subst $(TARGETDIR)/,,$(LINKTARGET))..."
85 $(Q)$(eval LINKTMPFILE=%(objdir)/$(notdir $(LINKTARGET)))
86 $(Q)$(IF) %(cmd) %(from) -o $(LINKTMPFILE) %(opt) %(libs) 2>&1 > $(GENDIR)/cerrors 2>&1 ; then \
87 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
88 $(ECHO) "$(LINKTARGET): %(cmd) %(from) -o $(LINKTARGET) %(opt) %(libs)" >> $(GENDIR)/errors ; \
89 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
93 $(CP) $(LINKTMPFILE) $(LINKTARGET) ; \
95 $(ECHO) "Link failed: %(cmd) %(from) -o $(LINKTARGET) %(opt) %(libs)" 1>&2 ; \
96 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
99 %strip_q strip=%(strip) file=$(LINKTARGET)
100 $(Q)$(IF) $(TEST) "%(coverageinstr)" = "yes"; then \
101 LINKBASEFILES="$(strip $(notdir $(basename %(from))))" ; \
102 $(FOR) covext in $(TARGET_COVERAGEINSTR_EXTS) ; do \
103 $(FOR) file in $$LINKBASEFILES ; do \
104 COVERAGEFILE=`echo $$file$$covext` ; \
105 $(IF) $(TEST) -s %(objdir)/$$COVERAGEFILE ; then \
106 $(CP) %(objdir)/$$COVERAGEFILE $(dir $(LINKTARGET))$$COVERAGEFILE ; \
112 #------------------------------------------------------------------------------
115 #-------------------------------------------------------------------------
116 # Link a module based upon a number of arguments and the standard $(LIBS)
117 # and $(DEPLIBS) make variables.
119 %define link_module_q cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" err="$(notdir $@).err" strip=$(STRIP) objs=/A endtag= module=$(MODULE) ldflags=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
120 $(Q)$(ECHO) "Building $(subst $(TARGETDIR)/,,$@) ..."
121 $(Q)$(IF) %(cmd) $(NOSTARTUP_LDFLAGS) \
122 $(GENMAP) %(objdir)/%(module).map \
123 %(objs) %(libs) %(ldflags) %(endtag) \
124 -o $@ 2>&1 > %(objdir)/%(err); \
126 cat %(objdir)/%(err); \
128 echo "%(cmd) $(NOSTARTUP_LDFLAGS) $(GENMAP) %(objdir)/%(module).map %(objs) %(libs) %(ldflags) %(endtag) -o $@"; \
129 cat %(objdir)/%(err); \
132 $(Q)$(IF) $(TEST) ! -s %(objdir)/%(err) ; then $(RM) %(objdir)/%(err) ; fi
133 %strip_q strip=%(strip) file=$@
135 #------------------------------------------------------------------------------
138 #------------------------------------------------------------------------------
140 %define mklib_q ar=$(AR) ranlib=$(RANLIB) to=$@ from=$(OBJS)
141 $(Q)$(ECHO) "Creating $(subst $(TARGETDIR)/,,%(to))..."
142 $(Q)%(ar) %(to) %(from)
145 #------------------------------------------------------------------------------
148 #------------------------------------------------------------------------------
149 # Create the dependency file %(to) for %(from)
150 %define mkdepend_q flags="$(strip $(CFLAGS) $(CPPFLAGS))" from=$< to=$@ cc="$(strip $(AROS_CC) $(TARGET_SYSROOT))"
151 %mkdir_q dir="$(dir %(to))"
152 $(Q)$(ECHO) "Makedepend $(if $(filter /%,%(from)),$(if $(filter $(SRCDIR)/%,$(abspath %(from))),$(patsubst $(SRCDIR)/%,%,$(abspath %(from))),$(patsubst $(TOP)/%,%,$(abspath %(from)))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/%(from))))..."
153 $(Q)AROS_CC="%(cc)" $(MKDEPEND) %(flags) -I$(TOP)/$(CURDIR) -I$(SRCDIR)/$(CURDIR) %(from) -o %(to)
155 #------------------------------------------------------------------------------
158 #------------------------------------------------------------------------------
159 # Create one directory without any output
160 %define mkdir_q dir=.
161 $(Q)$(IF) $(TEST) ! -d %(dir) ; then $(MKDIR) %(dir) ; else $(NOP) ; fi
163 #------------------------------------------------------------------------------
166 #------------------------------------------------------------------------------
167 # Create several directories without any output
168 %define mkdirs_q dirs=/M
169 $(Q)$(FOR) dir in %(dirs) ; do \
170 $(IF) $(TEST) ! -d $$dir ; then $(MKDIR) $$dir ; else $(NOP) ; fi ; \
173 #------------------------------------------------------------------------------
176 #############################################################################
177 #############################################################################
179 ## Here are the mmakefile macros that are used to do certain tasks in a ##
180 ## mmakefile. They consist of one or more full makefile rules. ##
181 ## In general the files generated in these macros are also defined as ##
182 ## make targets so that they can be used as a dependency in other rules ##
184 #############################################################################
185 #############################################################################
187 #------------------------------------------------------------------------------
188 # Generate a unique id for each of the %build... rules
189 %define buildid targets=/A
191 ifneq ($(filter $(TARGET),%(targets)),)
192 BDTARGETID := $(BDID)
195 #------------------------------------------------------------------------------
198 #------------------------------------------------------------------------------
199 # Copy file %(from) to %(to) in a makefile rule
200 %define rule_copy from=/A to=/A
204 #------------------------------------------------------------------------------
207 #------------------------------------------------------------------------------
208 # Copy the files %(files) to %(targetdir). For each file in %(files),
209 # %(srcdir)/file is copied to %(targetdir)/file. The targetdir and the
210 # appropriate subdirs are not generated by this rule so they have to be
212 %define rule_copy_multi files=/A targetdir=/A srcdir=.
214 $(addprefix %(targetdir)/,%(files)) : %(targetdir)/% : %(srcdir)/%
217 #------------------------------------------------------------------------------
220 #------------------------------------------------------------------------------
221 # Copy the files %(files) to %(targetdir). For each file in %(files),
222 # %(srcdir)/file is copied to %(targetdir)/file if these files are different.
223 # %(stampfile) is used to keep track of when the last time the comparison has
224 # been done. The targetdir and the appropriate subdirs are not generated by
225 # this rule so they have to be present.
226 %define rule_copy_diff_multi files=/A targetdir=/A srcdir=. \
227 stampfile=$(TMP_SRCDIR)/.copy_stamp
229 TMP_SRCDIR := %(srcdir)
231 $(addprefix %(targetdir)/,%(files)) : | %(stampfile)
233 %(stampfile) : COPYSRCDIR := %(srcdir)
234 %(stampfile) : TGTDIR := %(targetdir)
235 %(stampfile) : FILES := %(files)
236 %(stampfile) : $(addprefix %(srcdir)/,%(files))
237 $(Q)for f in $(FILES); do \
238 $(IF) ! $(CMP) -s $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; then \
239 $(CP) $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; \
244 #------------------------------------------------------------------------------
247 #------------------------------------------------------------------------------
248 # Will join all the files in %(from) to %(to). When text is specified it will
250 # Restriction: at the moment when using a non-empty target dir %(from) may
252 %define rule_join to=/A from=/A text=
255 $(Q)$(IF) $(TEST) "%(text)" != "" ; then \
256 $(Q)$(ECHO) %(text) ; \
260 #------------------------------------------------------------------------------
263 #------------------------------------------------------------------------------
264 # Include the dependency files and add some internal rules
265 # When depstargets is provided the depencies will only be included when one of
266 # these targets is the $(TARGET). Otherwise the dependencies will only be
267 # included when the $(TARGET) is not for setup or clean
268 %define include_deps deps=$(DEPS)/M depstargets=
270 ifneq (%(depstargets),)
271 ifneq ($(findstring $(TARGET),%(depstargets)),)
275 ifeq (,$(filter clean% %clean %clean% setup% includes% %setup,$(TARGET)))
281 #------------------------------------------------------------------------------
284 #------------------------------------------------------------------------------
285 # Create the directories %(dirs). The creation will be done by adding rules to
286 # the %(setuptarget) make target with setup as the default.
287 %define rule_makedirs dirs=/A setuptarget=setup
289 ifneq (%(setuptarget),)
290 %(setuptarget) : | %(dirs)
292 %(setuptarget) :: %(dirs)
295 GLOB_MKDIRS += %(dirs)
298 #------------------------------------------------------------------------------
301 #------------------------------------------------------------------------------
302 # Generate a rule to compile a C source file to an object file and generate
303 # the dependency file. Basename may contain a directory part, then the source
304 # file has to be in that directory. The generated file will be put in the
305 # object directory without the directory.
307 # - basename: the basename of the file to compile. Use % for a wildcard rule
308 # - cflags (default $(CFLAGS)): the C flags to use for compilation
309 # - dflags: the flags used during creation of dependency file. If not specified
310 # the same value as cflags will be used
311 # - targetdir: the directory to put the .o file and the .d file. By default
312 # it is put in the same directory as the .c file
313 %define rule_compile mmake=TMP basename=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= targetdir= compiler=target
315 %(mmake)_NIXFLAG ?= -nix
318 %(mmake)_TARGETBASE := %(basename)
320 %(mmake)_TARGETBASE := %(targetdir)/$(notdir %(basename))
323 # Adjust compiler flags to suit C
324 %(mmake)_C_CPPFLAGS := %(cppflags)
325 %(mmake)_CFLAGS := %(cflags)
326 %(mmake)_CFLAGS := $(subst -fpermissive,, $(%(mmake)_CFLAGS))
328 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
330 %(mmake)_DFLAGS := %(dflags)
333 ifeq ($(findstring %(compiler),host kernel target),)
334 $(error unknown compiler %(compiler))
336 ifeq (%(compiler),target)
337 %(mmake)_LINK ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
338 %(mmake)_STRIP ?= $(TARGET_STRIP)
339 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
340 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
341 $(%(mmake)_TARGETBASE).o : %(mmake)_C_CPPFLAGS:=$(strip $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
342 $(%(mmake)_TARGETBASE).d : %(mmake)_C_CPPFLAGS:=$(strip $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
343 $(%(mmake)_TARGETBASE).o : %(mmake)_CFLAGS:=$(strip $(%(mmake)_CFLAGS) $(SAFETY_CFLAGS))
344 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(%(mmake)_DFLAGS)
345 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
346 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
347 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
348 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
350 ifeq (%(compiler),host)
351 %(mmake)_LINK ?= $(strip $(HOST_CC) $(HOST_LDFLAGS))
352 %(mmake)_STRIP ?= $(HOST_STRIP)
353 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(HOST_CC)
354 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(HOST_CC)
355 $(%(mmake)_TARGETBASE).o : %(mmake)_C_CPPFLAGS:=$(strip $(HOST_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
356 $(%(mmake)_TARGETBASE).d : %(mmake)_C_CPPFLAGS:=$(strip $(HOST_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
357 $(%(mmake)_TARGETBASE).o : %(mmake)_CFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_CFLAGS))
358 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_DFLAGS))
359 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
360 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
361 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
362 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
364 ifeq (%(compiler),kernel)
365 %(mmake)_LINK ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
366 %(mmake)_STRIP ?= $(ECHO) >/dev/null
367 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
368 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
369 $(%(mmake)_TARGETBASE).o : %(mmake)_C_CPPFLAGS:=$(strip $(KERNEL_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
370 $(%(mmake)_TARGETBASE).d : %(mmake)_C_CPPFLAGS:=$(strip $(KERNEL_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS) $(%(mmake)_C_EXTRA_CPPFLAGS))
371 $(%(mmake)_TARGETBASE).o : %(mmake)_CFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_CFLAGS))
372 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_DFLAGS))
373 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
374 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
375 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
376 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
379 $(%(mmake)_TARGETBASE).o : CPPFLAGS := $(%(mmake)_C_CPPFLAGS)
380 $(%(mmake)_TARGETBASE).o : CFLAGS := $(%(mmake)_CFLAGS)
381 $(%(mmake)_TARGETBASE).o : %(basename).c
382 %compile_q cmd=$(%(mmake)_CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
385 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(strip $(%(mmake)_NIXFLAG) $(%(mmake)_DFLAGS))
387 $(%(mmake)_TARGETBASE).d : %(basename).c
388 %mkdepend_q cc=$(%(mmake)_CMD) flags="$(strip $(%(mmake)_DFLAGS) $(%(mmake)_C_CPPFLAGS))"
390 #------------------------------------------------------------------------------
393 #------------------------------------------------------------------------------
394 # Generate a rule to compile a C++ source file to an object file and generate
395 # the dependency file. Basename may contain a directory part, then the source
396 # file has to be in that directory. The generated file will be put in the
397 # object directory without the directory.
399 # - basename: the basename of the file to compile. Use % for a wildcard rule
400 # - cflags (default $(CFLAGS)): the C flags to use for compilation
401 # - dflags: the flags used during creation of dependency file. If not specified
402 # the same value as cflags will be used
403 # - targetdir: the directory to put the .o file and the .d file. By default
404 # it is put in the same directory as the .c file
405 %define rule_compile_cxx mmake=TMP basename=/A cppflags=$(CPPFLAGS) cxxflags=$(CXXFLAGS) dxxflags= targetdir= compiler=target
408 %(mmake)_NIXFLAG ?= -nix
410 %(mmake)_TARGETBASE := %(basename)
412 %(mmake)_TARGETBASE := %(targetdir)/$(notdir %(basename))
415 # Adjust compiler flags to suit C++
416 %(mmake)_CXX_CPPFLAGS := %(cppflags)
417 %(mmake)_CXXFLAGS := %(cxxflags)
419 %(mmake)_DXXFLAGS := %(cxxflags)
421 %(mmake)_DXXFLAGS := %(dxxflags)
424 ifeq ($(findstring %(compiler),host kernel target),)
425 $(error unknown compiler %(compiler))
427 ifeq (%(compiler),target)
428 %(mmake)_LINK ?= $(strip $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
429 %(mmake)_STRIP ?= $(TARGET_STRIP)
430 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(AROS_CXX) $(TARGET_SYSROOT))
431 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(AROS_CXX) $(TARGET_SYSROOT))
432 $(%(mmake)_TARGETBASE).o : %(mmake)_CXX_CPPFLAGS:=$(strip $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
433 $(%(mmake)_TARGETBASE).d : %(mmake)_CXX_CPPFLAGS:=$(strip $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
434 $(%(mmake)_TARGETBASE).o : %(mmake)_CXXFLAGS:=$(strip $(%(mmake)_CXXFLAGS) $(SAFETY_CFLAGS))
435 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(%(mmake)_DXXFLAGS)
436 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
437 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
438 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
439 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
441 ifeq (%(compiler),host)
442 %(mmake)_LINK ?= $(strip $(HOST_CXX) $(HOST_LDFLAGS))
443 %(mmake)_STRIP ?= $(HOST_STRIP)
444 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(HOST_CXX)
445 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(HOST_CXX)
446 $(%(mmake)_TARGETBASE).o : %(mmake)_CXX_CPPFLAGS:=$(strip $(HOST_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
447 $(%(mmake)_TARGETBASE).d : %(mmake)_CXX_CPPFLAGS:=$(strip $(HOST_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
448 $(%(mmake)_TARGETBASE).o : %(mmake)_CXXFLAGS:=$(strip $(HOST_CXXFLAGS) $(%(mmake)_CXXFLAGS))
449 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(strip $(HOST_CXXFLAGS) $(%(mmake)_DXXFLAGS))
450 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
451 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
452 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
453 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
455 ifeq (%(compiler),kernel)
456 KERNEL_CXX ?= $(KERNEL_CC)
457 %(mmake)_LINK ?= $(strip $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
458 %(mmake)_STRIP ?= $(ECHO) >/dev/null
459 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))
460 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))
461 $(%(mmake)_TARGETBASE).o : %(mmake)_CXX_CPPFLAGS:=$(strip $(KERNEL_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
462 $(%(mmake)_TARGETBASE).d : %(mmake)_CXX_CPPFLAGS:=$(strip $(KERNEL_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS) $(%(mmake)_CXX_EXTRA_CPPFLAGS))
463 $(%(mmake)_TARGETBASE).o : %(mmake)_CXXFLAGS:=$(strip $(KERNEL_CXXFLAGS) $(%(mmake)_CXXFLAGS))
464 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(strip $(KERNEL_CXXFLAGS) $(%(mmake)_DXXFLAGS))
465 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
466 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
467 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
468 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
471 $(%(mmake)_TARGETBASE).o : CPPFLAGS := $(%(mmake)_CXX_CPPFLAGS)
472 $(%(mmake)_TARGETBASE).o : CXXFLAGS := $(%(mmake)_CXXFLAGS)
473 $(%(mmake)_TARGETBASE).o : %(basename).cpp
474 %compile_q cmd=$(%(mmake)_CMD) opt="$(strip $(CXXFLAGS) $(CPPFLAGS))" iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
477 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(strip $(%(mmake)_NIXFLAG) $(%(mmake)_DXXFLAGS))
479 $(%(mmake)_TARGETBASE).d : %(basename).cpp
480 %mkdepend_q cc=$(%(mmake)_CMD) flags="$(strip $(%(mmake)_DXXFLAGS) $(%(mmake)_CXX_CPPFLAGS))"
485 #------------------------------------------------------------------------------
488 #------------------------------------------------------------------------------
489 # Generate a rule to compile an ObjC source file to an object file and generate
490 # the dependency file. Basename may contain a directory part, then the source
491 # file has to be in that directory. The generated file will be put in the
492 # object directory without the directory.
494 # - basename: the basename of the file to compile. Use % for a wildcard rule
495 # - cflags (default $(CFLAGS)): the C flags to use for compilation
496 # - dflags: the flags used during creation of dependency file. If not specified
497 # the same value as cflags will be used
498 # - targetdir: the directory to put the .o file and the .d file. By default
499 # it is put in the same directory as the .m file
500 %define rule_compile_objc mmake=TMP basename=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= targetdir= compiler=target
503 %(mmake)_NIXFLAG ?= -nix
505 %(mmake)_TARGETBASE := %(basename)
507 %(mmake)_TARGETBASE := %(targetdir)/$(notdir %(basename))
510 # Adjust compiler flags to suit ObjC
511 %(mmake)_OBJC_CPPFLAGS := %(cppflags)
512 %(mmake)_OBJCFLAGS := %(cflags)
513 %(mmake)_OBJCFLAGS := $(%(mmake)_OBJCFLAGS) -isystem $(AROS_DEVELOPER)/include
514 %(mmake)_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(%(mmake)_OBJCFLAGS)))
516 %(mmake)_OBJCDFLAGS := %(cflags)
518 %(mmake)_OBJCDFLAGS := %(dflags)
521 # Define the use of cross compiler
522 ifeq ($(TARGET_OBJC),)
523 %(mmake)_CC := $(TARGET_CC)
525 %(mmake)_CC := $(TARGET_OBJC)
528 ifeq ($(findstring %(compiler),host kernel target),)
529 $(error unknown compiler %(compiler))
531 ifeq (%(compiler),target)
532 %(mmake)_LINK ?= $(strip $(%(mmake)_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
533 %(mmake)_STRIP ?= $(TARGET_STRIP)
534 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(%(mmake)_CC) $(TARGET_SYSROOT))
535 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(%(mmake)_CC) $(TARGET_SYSROOT))
536 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJC_CPPFLAGS:=$(strip $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
537 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJC_CPPFLAGS:=$(strip $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
538 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJCFLAGS:=$(strip $(%(mmake)_OBJCFLAGS) $(SAFETY_CFLAGS))
539 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(%(mmake)_OBJCDFLAGS)
540 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
541 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
542 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
543 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
545 ifeq (%(compiler),host)
546 %(mmake)_LINK ?= $(strip $(HOST_CC) $(HOST_LDFLAGS))
547 %(mmake)_STRIP ?= $(HOST_STRIP)
548 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(HOST_CC)
549 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(HOST_CC)
550 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJC_CPPFLAGS:=$(strip $(HOST_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
551 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJC_CPPFLAGS:=$(strip $(HOST_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
552 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJCFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCFLAGS))
553 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCDFLAGS))
554 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
555 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
556 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
557 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
559 ifeq (%(compiler),kernel)
560 %(mmake)_LINK ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
561 %(mmake)_STRIP ?= $(ECHO) >/dev/null
562 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
563 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
564 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJC_CPPFLAGS:=$(strip $(KERNEL_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
565 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJC_CPPFLAGS:=$(strip $(KERNEL_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS) $(%(mmake)_OBJC_EXTRA_CPPFLAGS))
566 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJCFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCFLAGS))
567 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCDFLAGS))
568 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
569 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
570 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
571 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
574 $(%(mmake)_TARGETBASE).o : CPPFLAGS := $(%(mmake)_OBJC_CPPFLAGS)
575 $(%(mmake)_TARGETBASE).o : CFLAGS := $(%(mmake)_OBJCFLAGS)
576 $(%(mmake)_TARGETBASE).o : %(basename).m
577 %compile_q cmd=$(%(mmake)_CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
580 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(strip $(%(mmake)_NIXFLAG) $(%(mmake)_OBJCDFLAGS))
582 $(%(mmake)_TARGETBASE).d : %(basename).m
583 %mkdepend_q cc=$(%(mmake)_CMD) flags="$(strip $(%(mmake)_OBJCDFLAGS) $(%(mmake)_OBJC_CPPFLAGS))"
588 #------------------------------------------------------------------------------
591 #------------------------------------------------------------------------------
592 # Generate a rule to compile multiple C source files to an object file and
593 # generate the corresponding dependency files. The generated file will be put
594 # in the object directory without the directory part of the source file.
596 # - basenames: the basenames of the files to compile. The names may include
597 # relative or absolute path names. No wildcard is allowed
598 # - cflags (default $(CFLAGS)): the C flags to use for compilation
599 # - dflags: the flags used during creation of dependency file. If not specified
600 # the same value as cflags will be used
601 # - targetdir: the directory to put the .o file and the .d file. By default
602 # it is put in the same directory as the .c file. When targetdir is not
603 # empty, path names will be stripped from the file names so that all files
604 # are in that dir and not in subdirectories.
605 # - compiler (default target): compiler to use, target, kernel or host
606 %define rule_compile_multi mmake=TMP basenames=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= srcdir= targetdir= \
607 compiler=target usetree=no
610 %(mmake)_MC_SRCWILDCARD := %
612 %(mmake)_MC_SRCWILDCARD := %(srcdir)/%
616 %(mmake)_MC_TARGETS := $(addsuffix .o,%(basenames))
617 %(mmake)_MC_DTARGETS := $(addsuffix .d,%(basenames))
618 %(mmake)_MC_TGTWILDCARD := %
621 %(mmake)_MC_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
622 %(mmake)_MC_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
625 %(mmake)_MC_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,%(basenames)))
626 %(mmake)_MC_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,%(basenames)))
628 %(mmake)_MC_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(patsubst %(srcdir)/%,%,%(basenames))))
629 %(mmake)_MC_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(patsubst %(srcdir)/%,%,%(basenames))))
632 %(mmake)_MC_TGTWILDCARD := %(targetdir)/%
634 # Be sure that all .c files are generated
635 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : | $(addsuffix .c,%(basenames))
637 # Be sure that all .c files are found
638 %(mmake)_MC_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
639 %(mmake)_MC_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
640 %(mmake)_MC_DIRS := $(foreach dir, $(%(mmake)_MC_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(%(mmake)_MC_SRCDIR)/$(CURDIR)/$(dir)))
641 ifneq ($(%(mmake)_MC_DIRS),)
642 %(mmake)_MC_DIRS := $(shell echo $(%(mmake)_MC_DIRS) | sed 's/\(.\):\//\/\1\//g')
643 vpath %.c $(%(mmake)_MC_DIRS)
648 %(mmake)_MC_CPPFLAGS := %(cppflags)
649 %(mmake)_CFLAGS := %(cflags)
651 %(mmake)_DFLAGS := %(cflags)
653 %(mmake)_DFLAGS := %(dflags)
656 ifeq ($(findstring %(compiler),host kernel target),)
657 $(error unknown compiler %(compiler))
659 ifeq (%(compiler),target)
660 %(mmake)_LINK ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
661 %(mmake)_STRIP ?= $(TARGET_STRIP)
662 %(mmake)_ASSEMBLER ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT))
663 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
664 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_MC_CPPFLAGS:=$(strip $(%(mmake)_MC_CPPFLAGS) $(%(mmake)_MC_EXTRA_CPPFLAGS))
665 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_CFLAGS:=$(strip $(%(mmake)_CFLAGS) $(SAFETY_CFLAGS))
666 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_DFLAGS:=$(%(mmake)_DFLAGS)
667 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
668 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
670 ifeq (%(compiler),host)
671 %(mmake)_LINK ?= $(strip $(HOST_CC) $(HOST_LDFLAGS))
672 %(mmake)_STRIP ?= $(HOST_STRIP)
673 %(mmake)_ASSEMBLER ?= $(strip $HOST_CC) $(HOST_SYSROOT))
674 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : CMD:=$(HOST_CC)
675 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_MC_CPPFLAGS:=$(strip $(HOST_MC_CPPFLAGS) $(%(mmake)_MC_CPPFLAGS) $(%(mmake)_MC_EXTRA_CPPFLAGS))
676 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_CFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_CFLAGS))
677 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_DFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_DFLAGS))
678 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
679 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
681 ifeq (%(compiler),kernel)
682 %(mmake)_LINK ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
683 %(mmake)_STRIP ?= $(ECHO) >/dev/null
684 %(mmake)_ASSEMBLER ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
685 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
686 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_MC_CPPFLAGS:=$(strip $(KERNEL_MC_CPPFLAGS) $(%(mmake)_MC_CPPFLAGS) $(%(mmake)_MC_EXTRA_CPPFLAGS))
687 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_CFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_CFLAGS))
688 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_DFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_DFLAGS))
689 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
690 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
693 $(%(mmake)_MC_TARGETS) : CPPFLAGS := $(%(mmake)_MC_CPPFLAGS)
694 $(%(mmake)_MC_TARGETS) : CFLAGS := $(%(mmake)_CFLAGS)
695 $(%(mmake)_MC_TARGETS) : $(%(mmake)_MC_TGTWILDCARD).o : $(%(mmake)_MC_SRCWILDCARD).c
696 %compile_q cmd=$(CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
698 $(%(mmake)_MC_DTARGETS) : $(%(mmake)_MC_TGTWILDCARD).d : $(%(mmake)_MC_SRCWILDCARD).c
699 %mkdepend_q cc=$(CMD) flags="$(strip $(%(mmake)_DFLAGS) $(%(mmake)_MC_CPPFLAGS))"
701 #------------------------------------------------------------------------------
704 #------------------------------------------------------------------------------
705 # Generate a rule to compile multiple C++ source files to an object file and
706 # generate the corresponding dependency files. The generated file will be put
707 # in the object directory without the directory part of the source file.
709 # - basenames: the basenames of the files to compile. The names may include
710 # relative or absolute path names. No wildcard is allowed. basenames will be
711 # matched to supported AROS_CXXEXTS.
712 # - cflags (default $(CFLAGS)): the C flags to use for compilation
713 # - dflags: the flags used during creation of dependency file. If not specified
714 # the same value as cflags will be used
715 # - targetdir: the directory to put the .o file and the .d file. By default
716 # it is put in the same directory as the .c file. When targetdir is not
717 # empty, path names will be stripped from the file names so that all files
718 # are in that dir and not in subdirectories.
719 # - compiler (default target): compiler to use, target, kernel or host
720 %define rule_compile_cxx_multi mmake=TMP basenames=/A cppflags=$(CPPFLAGS) cxxflags=$(CXXFLAGS) dxxflags= \
721 targetdir= compiler=target srcdir=
723 %(mmake)_CXXABSBASENAMES := $(foreach %(mmake)_CXXBASE,%(basenames),$(if $(filter /%,$(%(mmake)_CXXBASE)),$(%(mmake)_CXXBASE),$(abspath $(SRCDIR)/$(CURDIR)/$(%(mmake)_CXXBASE))))
725 ifneq ($(%(mmake)_CXXABSBASENAMES),)
727 %(mmake)_CXXBASENAMES := $(basename $(%(mmake)_CXXABSBASENAMES))
729 # Identify the "real" c++ files from the passed in basenames
730 %(mmake)_MCXX_FILES := $(strip $(foreach %(mmake)_CXXBASE,$(%(mmake)_CXXABSBASENAMES), $(firstword $(wildcard $(foreach %(mmake)_EXT, $(AROS_CXXEXTS),$(addsuffix .$(%(mmake)_EXT),$(%(mmake)_CXXBASE)))))))
733 %(mmake)_MCXX_SRCWILDCARD := %
735 %(mmake)_MCXX_SRCWILDCARD := %(srcdir)/%
739 %(mmake)_CXXTARGETS := $(notdir $(%(mmake)_CXXBASENAMES:=.o))
740 %(mmake)_CXXDTARGETS := $(notdir $(%(mmake)_CXXBASENAMES:=.d))
741 %(mmake)_MCXX_WILDCARD := %
743 %(mmake)_CXXTARGETS := $(addprefix %(targetdir)/,$(notdir $(%(mmake)_CXXBASENAMES:=.o)))
744 %(mmake)_CXXDTARGETS := $(addprefix %(targetdir)/,$(notdir $(%(mmake)_CXXBASENAMES:=.d)))
745 %(mmake)_MCXX_WILDCARD := %(targetdir)/%
747 # Be sure that all source files are generated
748 $(%(mmake)_CXXTARGETS) $(%(mmake)_CXXDTARGETS) : | $(%(mmake)_MCXX_FILES)
751 # Adjust compiler flags to suit C++
752 %(mmake)_MCXX_CPPFLAGS := %(cppflags)
753 %(mmake)_CXXFLAGS := %(cxxflags)
755 %(mmake)_DXXFLAGS := %(cxxflags)
757 %(mmake)_DXXFLAGS := %(dxxflags)
760 ifeq ($(findstring %(compiler),host kernel target),)
761 $(error unknown compiler %(compiler))
763 ifeq (%(compiler),host)
764 %(mmake)_LINK ?= $(strip $(HOST_CXX) $(HOST_LDFLAGS))
765 %(mmake)_STRIP ?= $(HOST_STRIP)
766 %(mmake)_ASSEMBLER ?= $(strip $(HOST_CC) $(HOST_SYSROOT))
767 %(mmake)_CXXCMD:=$(HOST_CXX)
768 %(mmake)_MCXX_CPPFLAGS := $(strip $(HOST_MCXX_CPPFLAGS) $(%(mmake)_MCXX_CPPFLAGS) $(%(mmake)_MCXX_EXTRA_CPPFLAGS))
769 %(mmake)_CXXFLAGS := $(strip $(HOST_CXXFLAGS) $(%(mmake)_CXXFLAGS))
770 %(mmake)_DXXFLAGS := $(strip $(HOST_CXXFLAGS) $(%(mmake)_DXXFLAGS))
771 %(mmake)_CXXIQUOTE:=$(HOST_IQUOTE)
772 %(mmake)_CXXIQUOTE_END:=$(HOST_IQUOTE_END)
774 ifeq (%(compiler),target)
775 %(mmake)_LINK ?= $(strip $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
776 %(mmake)_STRIP ?= $(TARGET_STRIP)
777 %(mmake)_ASSEMBLER ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT))
778 %(mmake)_CXXCMD:=$(strip $(AROS_CXX) $(TARGET_SYSROOT))
779 %(mmake)_MCXX_CPPFLAGS := $(strip $(%(mmake)_MCXX_CPPFLAGS) $(%(mmake)_MCXX_EXTRA_CPPFLAGS))
780 %(mmake)_CXXFLAGS := $(strip $(%(mmake)_CXXFLAGS) $(SAFETY_CFLAGS))
781 %(mmake)_DXXFLAGS := $(%(mmake)_DXXFLAGS)
782 %(mmake)_CXXIQUOTE:=$(CFLAGS_IQUOTE)
783 %(mmake)_CXXIQUOTE_END:=$(CFLAGS_IQUOTE_END)
785 ifeq (%(compiler),kernel)
786 KERNEL_CXX ?= $(KERNEL_CC)
787 %(mmake)_LINK ?= $(strip $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
788 %(mmake)_STRIP ?= $(ECHO) >/dev/null
789 %(mmake)_ASSEMBLER ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
790 %(mmake)_CXXCMD:=$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))
791 %(mmake)_CXXFLAGS := $(strip $(KERNEL_MCXX_CPPFLAGS) $(%(mmake)_MCXX_CPPFLAGS) $(%(mmake)_MCXX_EXTRA_CPPFLAGS))
792 %(mmake)_CXXFLAGS := $(strip $(KERNEL_CXXFLAGS) $(%(mmake)_CXXFLAGS))
793 %(mmake)_DXXFLAGS := $(strip $(KERNEL_CXXFLAGS) $(%(mmake)_DXXFLAGS))
794 %(mmake)_CXXIQUOTE:=$(KERNEL_IQUOTE)
795 %(mmake)_CXXIQUOTE_END:=$(KERNEL_IQUOTE_END)
798 define cxx_multi_recipe_template
800 %compile_q cmd=$(%(mmake)_CXXCMD) opt="$(strip $(%(mmake)_CXXFLAGS) $(%(mmake)_MCXX_CPPFLAGS))" iquote=$(%(mmake)_CXXIQUOTE) iquote_end=$(%(mmake)_CXXIQUOTE_END) from=$(2) to=$(1).o
803 %mkdepend_q cc=$(%(mmake)_CXXCMD) flags="$(strip $(%(mmake)_DXXFLAGS) $(%(mmake)_MCXX_CPPFLAGS))" from=$(2) to=$(1).d
806 $(foreach %(mmake)_CXXFILE,$(%(mmake)_MCXX_FILES),$(eval $(call cxx_multi_recipe_template,$(notdir $(basename $(%(mmake)_CXXFILE))),$(%(mmake)_CXXFILE))))
808 $(foreach %(mmake)_CXXFILE,$(%(mmake)_MCXX_FILES),$(eval $(call cxx_multi_recipe_template,$(addprefix %(targetdir)/,$(notdir $(basename $(%(mmake)_CXXFILE)))),$(%(mmake)_CXXFILE))))
814 #------------------------------------------------------------------------------
817 #------------------------------------------------------------------------------
818 # Generate a rule to compile multiple ObjC source files to an object file and
819 # generate the corresponding dependency files. The generated file will be put
820 # in the object directory without the directory part of the source file.
822 # - basenames: the basenames of the files to compile. The names may include
823 # relative or absolute path names. No wildcard is allowed
824 # - cflags (default $(CFLAGS)): the C flags to use for compilation
825 # - dflags: the flags used during creation of dependency file. If not specified
826 # the same value as cflags will be used
827 # - targetdir: the directory to put the .o file and the .d file. By default
828 # it is put in the same directory as the .m file. When targetdir is not
829 # empty, path names will be stripped from the file names so that all files
830 # are in that dir and not in subdirectories.
831 # - compiler (default target): compiler to use, target, kernel or host
832 %define rule_compile_objc_multi mmake=TMP basenames=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= \
833 targetdir= compiler=target srcdir=
835 ifneq (%(basenames),)
838 %(mmake)_MOBJC_SRCWILDCARD := %
840 %(mmake)_MOBJC_SRCWILDCARD := %(srcdir)/%
844 %(mmake)_MOBJC_TARGETS := $(addsuffix .o,%(basenames))
845 %(mmake)_MOBJC_DTARGETS := $(addsuffix .d,%(basenames))
846 %(mmake)_MOBJC_WILDCARD := %
848 %(mmake)_MOBJC_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,%(basenames)))
849 %(mmake)_MOBJC_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,%(basenames)))
850 %(mmake)_MOBJC_WILDCARD := %(targetdir)/%
852 # Be sure that all .m files are generated
853 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : | $(addsuffix .m,%(basenames))
855 # Be sure that all .m files are found
856 %(mmake)_MOBJC_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
857 %(mmake)_MOBJC_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
858 %(mmake)_MOBJC_DIRS := $(foreach dir, $(%(mmake)_MOBJC_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(%(mmake)_MOBJC_SRCDIR)/$(CURDIR)/$(dir)))
859 ifneq ($(%(mmake)_MOBJC_DIRS),)
860 %(mmake)_MOBJC_DIRS := $(shell echo $(%(mmake)_MOBJC_DIRS) | sed 's/\(.\):\//\/\1\//g')
861 vpath %.m $(%(mmake)_MOBJC_DIRS)
865 # Define the use of cross compiler
866 ifeq ($(TARGET_OBJC),)
867 %(mmake)_CC := $(TARGET_CC)
869 %(mmake)_CC := $(TARGET_OBJC)
872 # Adjust compiler flags to suit ObjC
873 %(mmake)_MOBJC_CPPFLAGS := %(cppflags)
874 %(mmake)_OBJCFLAGS := %(cflags)
875 %(mmake)_OBJCFLAGS := $(%(mmake)_OBJCFLAGS) -isystem $(AROS_DEVELOPER)/include
876 %(mmake)_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(%(mmake)_OBJCFLAGS)))
878 %(mmake)_OBJCDFLAGS := %(cflags)
880 %(mmake)_OBJCDFLAGS := %(dflags)
883 ifeq ($(findstring %(compiler),host kernel target),)
884 $(error unknown compiler %(compiler))
886 ifeq (%(compiler),target)
887 %(mmake)_LINK ?= $(strip $(%(mmake)_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
888 %(mmake)_STRIP ?= $(TARGET_STRIP)
889 %(mmake)_ASSEMBLER ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT))
890 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : CMD:=$(strip $(%(mmake)_CC) $(TARGET_SYSROOT))
891 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_MOBJC_CPPFLAGS:=$(strip $(%(mmake)_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_EXTRA_CPPFLAGS))
892 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCFLAGS:=$(strip $(%(mmake)_OBJCFLAGS) $(SAFETY_CFLAGS))
893 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCDFLAGS:=$(%(mmake)_OBJCDFLAGS)
894 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
895 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
897 ifeq (%(compiler),host)
898 %(mmake)_LINK ?= $(strip $(HOST_OBJC) $(HOST_LDFLAGS))
899 %(mmake)_STRIP ?= $(HOST_STRIP)
900 %(mmake)_ASSEMBLER ?= $(strip $(HOST_CC) $(HOST_SYSROOT))
901 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : CMD:=$(HOST_OBJC)
902 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_MOBJC_CPPFLAGS:=$(strip $(HOST_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_EXTRA_CPPFLAGS))
903 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCFLAGS))
904 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCDFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCDFLAGS))
905 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
906 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
908 ifeq (%(compiler),kernel)
909 KERNEL_OBJC ?= $(KERNEL_CC)
910 %(mmake)_LINK ?= $(strip $(KERNEL_OBJC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
911 %(mmake)_STRIP ?= $(ECHO) >/dev/null
912 %(mmake)_ASSEMBLER ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
913 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : CMD:=$(strip $(KERNEL_OBJC) $(KERNEL_SYSROOT))
914 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_MOBJC_CPPFLAGS:=$(strip $(KERNEL_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_EXTRA_CPPFLAGS))
915 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCFLAGS))
916 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCDFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCDFLAGS))
917 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
918 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
921 $(%(mmake)_MOBJC_TARGETS) : CPPFLAGS := $(%(mmake)_MOBJC_CPPFLAGS)
922 $(%(mmake)_MOBJC_TARGETS) : CFLAGS := $(%(mmake)_OBJCFLAGS)
923 $(%(mmake)_MOBJC_TARGETS) : $(%(mmake)_MOBJC_WILDCARD).o : $(%(mmake)_MOBJC_SRCWILDCARD).m
924 %compile_q cmd=$(CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
926 $(%(mmake)_MOBJC_DTARGETS) : $(%(mmake)_MOBJC_WILDCARD).d : $(%(mmake)_MOBJC_SRCWILDCARD).m
927 %mkdepend_q cc=$(CMD) flags="$(strip $(%(mmake)_OBJCDFLAGS) $(%(mmake)_MOBJC_CPPFLAGS))"
932 #------------------------------------------------------------------------------
935 #------------------------------------------------------------------------------
936 # Make an alias from one arch specific build to another arch.
938 # - mainmmake: the mmake of the module in the main tree
939 # - arch: the current arch
940 # - alias: the alias to which this should point
941 %define rule_archalias mainmmake=\A arch=\A alias=\A
943 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
945 #------------------------------------------------------------------------------
948 #------------------------------------------------------------------------------
949 # Generate a rule to assemble a source file to an object file. Basename may
950 # contain a directory part, then the source file has to be in that directory.
951 # The generated file will be put in the object directory without the directory.
953 # - basename: the basename of the file to compile. Use % for a wildcard rule
954 # - flags (default $(AFLAGS)): the asm flags to use for assembling
955 # - targetdir: the directory to put the .o file in. By default it is put in the
956 # same directory as the .s file
957 %define rule_assemble basename=/A cppflags=$(CPPFLAGS) aflags=$(AFLAGS) targetdir=
960 %(basename).o : CPPFLAGS := %(cppflags)
961 %(basename).o : AFLAGS := %(aflags)
962 %(basename).o : %(basename).s
964 %(basename).o : %(basename).S
968 %(targetdir)/$(notdir %(basename)).o : CPPFLAGS := %(cppflags)
969 %(targetdir)/$(notdir %(basename)).o : AFLAGS := %(aflags)
970 %(targetdir)/$(notdir %(basename)).o : %(basename).s
972 %(targetdir)/$(notdir %(basename)).o : %(basename).S
977 #------------------------------------------------------------------------------
980 #------------------------------------------------------------------------------
981 # Generate a rule to assemble multiple source files to an object file. The
982 # generated file will be put in the object directory with the directory part
983 # of the source file stripped off.
985 # - basenames: the basenames of the files to compile. The names may include
986 # relative or absolute path names. No wildcard is allowed
987 # - aflags (default $(AFLAGS)): the flags to use for assembly
988 # - targetdir: the directory to put the .o file and the .d file. By default
989 # it is put in the same directory as the .c file. When targetdir is not
990 # empty, path names will be stripped from the file names so that all files
991 # are in that dir and not in subdirectories.
992 %define rule_assemble_multi mmake=TMP cmd="$(strip $(CC) $(TARGET_SYSROOT))" basenames=/A cppflags=$(CPPFLAGS) aflags=$(AFLAGS) targetdir= suffix=.s
995 %(mmake)-MA_TARGETS := $(addsuffix .o,%(basenames))
996 %(mmake)-MA_WILDCARD := %
998 %(mmake)-MA_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
999 %(mmake)-MA_WILDCARD := %(targetdir)/%
1001 # Be sure that all .s files are generated
1002 $(%(mmake)-MA_TARGETS) : | $(addsuffix %(suffix),%(basenames))
1004 # Be sure that all .c files are found
1005 %(mmake)-MA_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
1006 %(mmake)-MA_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
1007 %(mmake)-MA_DIRS := $(foreach dir, $(%(mmake)-MA_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(%(mmake)-MA_SRCDIR)/$(CURDIR)/$(dir)))
1008 ifneq ($(%(mmake)-MA_DIRS),)
1009 %(mmake)-MA_DIRS := $(shell echo $(%(mmake)-MA_DIRS) | sed 's/\(.\):\//\/\1\//g')
1010 vpath %%(suffix) $(%(mmake)-MA_DIRS)
1015 %(mmake)-MA_ASSEMBLER ?= %(cmd)
1017 $(%(mmake)-MA_TARGETS) : %(mmake)-MA_CMD:= $(%(mmake)-MA_ASSEMBLER)
1019 $(%(mmake)-MA_TARGETS) : CPPFLAGS := %(cppflags)
1020 $(%(mmake)-MA_TARGETS) : AFLAGS := %(aflags)
1021 $(%(mmake)-MA_TARGETS) : $(%(mmake)-MA_WILDCARD).o : %%(suffix)
1022 %assemble_q cmd=$(%(mmake)-MA_CMD)
1024 #------------------------------------------------------------------------------
1027 #------------------------------------------------------------------------------
1028 # Link %(objs) to %(prog) using the libraries in %(uselibs)
1029 %define rule_link_prog mmake=TMP prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
1030 usehostlibs= usestartup=yes detach=no nix=no cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" strip=$(TARGET_STRIP) objdir=$(GENDIR)/$(CURDIR) coverageinstr=$(TARGET_COVERAGEINSTR)
1032 %(mmake)-link_EXTRA_LDFLAGS :=
1033 %(mmake)-link_EXTRA_LIBS :=
1035 %(mmake)-link_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
1037 ifeq (%(usestartup),no)
1038 %(mmake)-link_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
1040 ifeq (%(detach),yes)
1041 %(mmake)-link_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
1044 # Make a list of the lib files this program depends on.
1045 # In LDFLAGS remove white space between -L and directory
1046 %(mmake)-link_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
1047 # Filter out only the libdirs and remove -L
1048 %(mmake)-link_DIRS := $(patsubst -L%,%,$(filter -L%,$(%(mmake)-link_DIRS)))
1050 %(mmake)-link_DIRS := $(subst //,/,$(addsuffix /,$(%(mmake)-link_DIRS)))
1051 # Add normal linklib path
1052 %(mmake)-link_DIRS += $(AROS_LIB)/
1053 # add lib and .a to static linklib names
1054 %(mmake)-link_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(%(mmake)-link_EXTRA_LIBS)))
1055 ifeq (%(usestartup),yes)
1056 %(mmake)-link_LIBS += startup.o
1058 ifeq (%(detach),yes)
1059 %(mmake)-link_LIBS += detach.o
1061 # search for the linklibs in the given path, ignore ones not found
1062 %(mmake)-link_DEPLIBS := $(foreach lib,$(%(mmake)-link_LIBS), \
1063 $(firstword $(wildcard $(addsuffix $(lib),$(%(mmake)-link_DIRS)))) \
1066 %(prog) : OBJDIR := %(objdir)
1067 %(prog) : OBJS := %(objs)
1068 %(prog) : LDFLAGS := $(strip %(ldflags) $(%(mmake)-link_EXTRA_LDFLAGS))
1069 %(prog) : LIBS := $(addprefix -l,%(uselibs) $(%(mmake)-link_EXTRA_LIBS) %(usehostlibs))
1070 %(prog) : %(objs) $(%(mmake)-link_DEPLIBS)
1071 %link_q cmd="%(cmd)" strip="%(strip)" from=$(OBJS) opt=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR) coverageinstr=%(coverageinstr)
1073 #------------------------------------------------------------------------------
1076 #------------------------------------------------------------------------------
1077 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
1078 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
1079 %define rule_link_progs mmake=TMP progs=/A targetdir=$(AROSDIR)/$(CURDIR) nix=%(nix) \
1080 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
1081 usestartup=yes detach=no cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" strip=$(TARGET_STRIP) coverageinstr=$(TARGET_COVERAGEINSTR)
1083 %(mmake)-link_EXTRA_LDFLAGS :=
1084 %(mmake)-link_EXTRA_LIBS :=
1086 %(mmake)-link_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
1088 ifeq (%(usestartup),no)
1089 %(mmake)-link_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
1091 ifeq (%(detach),yes)
1092 %(mmake)-link_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
1095 # Make a list of the lib files the programs depend on.
1096 # In LDFLAGS remove white space between -L and directory
1097 %(mmake)-link_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
1098 # Filter out only the libdirs and remove -L
1099 %(mmake)-link_DIRS := $(patsubst -L%,%,$(filter -L%,$(%(mmake)-link_DIRS)))
1101 %(mmake)-link_DIRS := $(subst //,/,$(addsuffix /,$(%(mmake)-link_DIRS)))
1102 # Add normal linklib path
1103 %(mmake)-link_DIRS += $(AROS_LIB)/
1104 # add lib and .a to static linklib names
1105 %(mmake)-link_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(%(mmake)-link_EXTRA_LIBS)))
1106 # search for the linklibs in the given path, ignore ones not found
1107 %(mmake)-link_DEPLIBS := $(foreach lib,$(%(mmake)-link_LIBS), \
1108 $(firstword $(wildcard $(addsuffix $(lib),$(%(mmake)-link_DIRS)))) \
1110 %(mmake)-link_PROGS := $(addprefix %(targetdir)/,%(progs))
1112 $(%(mmake)-link_PROGS) : OBJDIR := %(objdir)
1113 $(%(mmake)-link_PROGS) : LDFLAGS := $(strip %(ldflags) $(%(mmake)-link_EXTRA_LDFLAGS))
1114 $(%(mmake)-link_PROGS) : LIBS := $(addprefix -l,%(uselibs) $(%(mmake)-link_EXTRA_LIBS) %(usehostlibs))
1115 $(%(mmake)-link_PROGS) : %(targetdir)/% : %(objdir)/%.o $(%(mmake)-link_DEPLIBS)
1116 %link_q cmd="%(cmd)" strip="%(strip)" from=$< opt=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR) coverageinstr=%(coverageinstr)
1118 #------------------------------------------------------------------------------
1121 #------------------------------------------------------------------------------
1122 # Link the %(objs) to the library %(libdir)/lib%(libname).a
1123 %define rule_link_linklib mmake=TMP libname=/A objs=/A libdir=$(AROS_LIB) linker=target
1125 ifeq (%(linker),target)
1126 %(libdir)/lib%(libname).a : %(mmake)_AR:=$(AR)
1127 %(libdir)/lib%(libname).a : %(mmake)_RANLIB:=$(RANLIB)
1129 ifeq (%(linker),host)
1130 %(libdir)/lib%(libname).a : %(mmake)_AR:=$(HOST_AR)
1131 %(libdir)/lib%(libname).a : %(mmake)_RANLIB:=$(HOST_RANLIB)
1133 ifeq (%(linker),kernel)
1134 %(libdir)/lib%(libname).a : %(mmake)_AR:=$(KERNEL_AR)
1135 %(libdir)/lib%(libname).a : %(mmake)_RANLIB:=$(KERNEL_RANLIB)
1138 %(libdir)/lib%(libname).a : %(objs)
1139 %mklib_q from=$^ ar=$(%(mmake)_AR) ranlib=$(%(mmake)_RANLIB)
1141 #------------------------------------------------------------------------------
1143 #------------------------------------------------------------------------------
1144 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
1145 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
1146 %define rule_linkmodule mmake=TMP module=/A objs=/A endobj=/A err=/A objdir=$(OBJDIR) \
1147 cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" ldflags=$(LDFLAGS) uselibs= usehostlibs=
1149 %(mmake)_LDFLAGS := %(ldflags)
1150 # Make a list of the lib files the programs depend on.
1151 # In LDFLAGS remove white space between -L and directory
1152 %(mmake)_DIRS := $(subst -L ,-L,$(strip $(%(mmake)_LDFLAGS)))
1153 # Filter out only the libdirs and remove -L
1154 %(mmake)_DIRS := $(patsubst -L%,%,$(filter -L%,$(%(mmake)_DIRS)))
1156 %(mmake)_DIRS := $(subst //,/,$(addsuffix /,$(%(mmake)_DIRS)))
1157 # Add normal linklib path
1158 %(mmake)_DIRS += $(AROS_LIB)/
1159 # add lib and .a to static linklib names
1160 %(mmake)_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
1161 # search for the linklibs in the given path, ignore ones not found
1162 %(mmake)_DEPLIBS := $(foreach lib,$(%(mmake)_LIBS), \
1163 $(firstword $(wildcard $(addsuffix $(lib),$(%(mmake)_DIRS)))) \
1166 %(module) : LIB_NAMES := %(uselibs)
1167 %(module) : OBJS := %(objs)
1168 %(module) : ENDTAG := %(endobj)
1169 %(module) : ERR := %(err)
1170 %(module) : OBJDIR := %(objdir)
1171 %(module) : LDFLAGS := $(%(mmake)_LDFLAGS)
1172 ifeq (%(usehostlibs),)
1173 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES))
1175 # Warning: the -L/usr/lib here can result in modules
1176 # linking against host libs instead of AROS libs (e.g stdc++) !!
1177 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES)) \
1178 -L/usr/lib $(addprefix -l,%(usehostlibs))
1180 %(module) : %(objs) %(endobj) $(%(mmake)_DEPLIBS) $(USER_DEPLIBS)
1181 %link_module_q cmd="%(cmd)" err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS) objdir=$(OBJDIR) ldflags=$(LDFLAGS)
1184 #------------------------------------------------------------------------------
1187 #------------------------------------------------------------------------------
1188 # Generate the libdefs.h include file for a module.
1189 %define rule_genmodule_genlibdefs mmake=TMP modname=/A version= flavour= modtype=/A modsuffix= conffile= confoverride= targetdir=
1193 %(mmake)_OPTS += -f %(flavour)
1194 %(mmake)_MODNAME := %(modname)_%(flavour)
1196 %(mmake)_MODNAME := %(modname)
1198 %(mmake)_TARGET := $(%(mmake)_MODNAME)_libdefs.h
1199 %(mmake)_DEPS := $(GENMODULE)
1200 ifneq (%(conffile),)
1201 ifeq ($(dir %(conffile)),./)
1202 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1203 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1205 %(mmake)_OPTS += -c %(conffile)
1206 %(mmake)_DEPS += %(conffile)
1209 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1210 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1212 ifneq (%(confoverride),)
1213 ifeq ($(dir %(confoverride)),./)
1214 %(mmake)_OPTS += -o $(SRCDIR)/$(CURDIR)/%(confoverride)
1215 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(confoverride)
1217 %(mmake)_OPTS += -o %(confoverride)
1218 %(mmake)_DEPS += %(confoverride)
1221 ifneq (%(modsuffix),)
1222 %(mmake)_OPTS += -s %(modsuffix)
1224 ifneq (%(targetdir),)
1225 %(mmake)_OPTS += -d %(targetdir)
1226 %(mmake)_TARGET := %(targetdir)/$(%(mmake)_TARGET)
1229 %(mmake)_OPTS += -v %(version)
1232 $(%(mmake)_TARGET) : OPTS := $(%(mmake)_OPTS)
1233 $(%(mmake)_TARGET) : MODNAME := %(modname)
1234 $(%(mmake)_TARGET) : MODTYPE := %(modtype)
1235 $(%(mmake)_TARGET) : $(%(mmake)_DEPS)
1236 $(Q)$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1237 $(Q)$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
1239 #------------------------------------------------------------------------------
1241 #------------------------------------------------------------------------------
1242 # Generate the _lib.fd file for a module.
1243 %define rule_genmodule_fd mmake=TMP modname=/A modtype=/A modsuffix= conffile= confoverride= targetdir=
1245 %(mmake)_TARGET := %(modname)_lib.fd
1246 %(mmake)_DEPS := $(GENMODULE)
1248 ifneq (%(conffile),)
1249 ifeq ($(dir %(conffile)),./)
1250 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1251 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1253 %(mmake)_OPTS += -c %(conffile)
1254 %(mmake)_DEPS += %(conffile)
1257 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1258 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1260 ifneq (%(confoverride),)
1261 ifeq ($(dir %(confoverride)),./)
1262 %(mmake)_OPTS += -o $(SRCDIR)/$(CURDIR)/%(confoverride)
1263 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(confoverride)
1265 %(mmake)_OPTS += -o %(confoverride)
1266 %(mmake)_DEPS += %(confoverride)
1269 ifneq (%(modsuffix),)
1270 %(mmake)_OPTS += -s %(modsuffix)
1272 ifneq (%(targetdir),)
1273 %(mmake)_OPTS += -d %(targetdir)
1274 %(mmake)_TARGET := %(targetdir)/$(%(mmake)_TARGET)
1277 $(%(mmake)_TARGET) : OPTS := $(%(mmake)_OPTS)
1278 $(%(mmake)_TARGET) : MODNAME := %(modname)
1279 $(%(mmake)_TARGET) : MODTYPE := %(modtype)
1280 $(%(mmake)_TARGET) : $(%(mmake)_DEPS)
1281 $(Q)$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1282 $(Q)$(GENMODULE) $(OPTS) writefd $(MODNAME) $(MODTYPE)
1284 #------------------------------------------------------------------------------
1286 #------------------------------------------------------------------------------
1287 # Generate a Makefile.%(modname)%(modtype) with the genmodule program and include this
1288 # generated file in this Makefile
1289 %define rule_genmodule_makefile mmake=TMP modname=/A flavour= modtype=/A modsuffix= conffile= confoverride= \
1294 %(mmake)_OPTS += -f %(flavour)
1295 %(mmake)_MODNAME := %(modname)_%(flavour)
1297 %(mmake)_MODNAME := %(modname)
1299 %(mmake)_TARGET := Makefile.$(%(mmake)_MODNAME)%(modtype)
1300 %(mmake)_DEPS := $(GENMODULE)
1301 ifneq (%(conffile),)
1302 ifeq ($(dir %(conffile)),./)
1303 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1304 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1306 %(mmake)_OPTS += -c %(conffile)
1307 %(mmake)_DEPS += %(conffile)
1310 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1311 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1313 ifneq (%(confoverride),)
1314 ifeq ($(dir %(confoverride)),./)
1315 %(mmake)_OPTS += -o $(SRCDIR)/$(CURDIR)/%(confoverride)
1316 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(confoverride)
1318 %(mmake)_OPTS += -o %(confoverride)
1319 %(mmake)_DEPS += %(confoverride)
1322 ifneq (%(modsuffix),)
1323 %(mmake)_OPTS += -s %(modsuffix)
1325 ifneq (%(targetdir),)
1326 %(mmake)_OPTS += -d %(targetdir)
1327 %(mmake)_TARGET := %(targetdir)/$(%(mmake)_TARGET)
1330 $(%(mmake)_TARGET) : OPTS := $(%(mmake)_OPTS)
1331 $(%(mmake)_TARGET) : MODNAME := %(modname)
1332 $(%(mmake)_TARGET) : MODTYPE := %(modtype)
1333 $(%(mmake)_TARGET) : $(%(mmake)_DEPS)
1334 $(Q)$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
1336 #------------------------------------------------------------------------------
1339 #------------------------------------------------------------------------------
1340 # Generate the support files for compiling a module. This includes include
1341 # files and source files. This rule has to be preceeded by
1342 # %rule_genmodule_makefile
1343 %define rule_genmodule_files mmake=TMP modname=/A flavour= modtype=/A modsuffix= targetdir= stubdir= \
1344 conffile= confoverride=
1348 %(mmake)_OPTS += -f %(flavour)
1349 %(mmake)_MODNAME := %(modname)_%(flavour)
1351 %(mmake)_MODNAME := %(modname)
1353 %(mmake)_GENTARGETS := $($(%(mmake)_MODNAME)_STARTFILES) $($(%(mmake)_MODNAME)_ENDFILES)
1354 %(mmake)_STUBTARGETS := $($(%(mmake)_MODNAME)_LINKLIBFILES) $($(%(mmake)_MODNAME)_RELLINKLIBFILES)
1355 %(mmake)_GENTARGETS := $(addsuffix .c,$(%(mmake)_GENTARGETS))
1356 %(mmake)_STUBTARGETS := $(addsuffix .c,$(%(mmake)_STUBTARGETS)) \
1357 $(addsuffix .S, $($(%(mmake)_MODNAME)_LINKLIBAFILES) $($(%(mmake)_MODNAME)_RELLINKLIBAFILES))
1359 %(mmake)_DEPS := $(GENMODULE)
1360 ifneq (%(conffile),)
1361 ifeq ($(dir %(conffile)),./)
1362 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1363 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1365 %(mmake)_OPTS += -c %(conffile)
1366 %(mmake)_DEPS += %(conffile)
1369 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1370 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1372 ifneq (%(confoverride),)
1373 ifeq ($(dir %(confoverride)),./)
1374 %(mmake)_OPTS += -o $(SRCDIR)/$(CURDIR)/%(confoverride)
1375 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(confoverride)
1377 %(mmake)_OPTS += -o %(confoverride)
1378 %(mmake)_DEPS += %(confoverride)
1381 ifneq (%(modsuffix),)
1382 %(mmake)_OPTS += -s %(modsuffix)
1384 ifneq (%(targetdir),)
1385 %(mmake)_OPTS += -d %(targetdir)
1386 %(mmake)_TARGETDIR := $(shell echo %(targetdir) | sed 's/^\(.\):\//\/\1\//')
1387 %(mmake)_GENTARGETS := $(addprefix $(%(mmake)_TARGETDIR)/,$(%(mmake)_GENTARGETS))
1388 %(mmake)_GENFILEFLAG=$(%(mmake)_TARGETDIR)/.%(modname).%(modtype)-genfiles
1390 %(mmake)_GENFILEFLAG=$(GENDIR)/$(CURDIR)/.%(modname).%(modtype)-genfiles
1393 %(mmake)_OPTS += -l %(stubdir)
1394 %(mmake)_STUBTARGETDIR := $(shell echo %(stubdir) | sed 's/^\(.\):\//\/\1\//')
1395 %(mmake)_STUBTARGETS := $(addprefix $(%(mmake)_STUBTARGETDIR)/,$(%(mmake)_STUBTARGETS))
1396 %(mmake)_TARGETDIRS += %(stubdir)
1398 ifneq (%(targetdir),)
1399 %(mmake)_STUBTARGETS := $(addprefix $(%(mmake)_TARGETDIR)/,$(%(mmake)_STUBTARGETS))
1403 %(mmake)_TARGETS := $(%(mmake)_GENTARGETS) $(%(mmake)_STUBTARGETS)
1404 ifneq ($(%(mmake)_TARGETDIRS),)
1405 $(%(mmake)_TARGETS) : | $(%(mmake)_TARGETDIRS)
1408 $(%(mmake)_TARGETS) : $(%(mmake)_DEPS) $(%(mmake)_GENFILEFLAG)
1410 $(%(mmake)_GENFILEFLAG) : OPTS := $(%(mmake)_OPTS)
1411 $(%(mmake)_GENFILEFLAG) : MODNAME := %(modname)
1412 $(%(mmake)_GENFILEFLAG) : MODTYPE := %(modtype)
1413 $(%(mmake)_GENFILEFLAG) : $(%(mmake)_DEPS)
1414 $(Q)$(ECHO) "Generating support files for module $(MODNAME$(BDID))"
1415 $(Q)$(IF) $(TEST) "%(conffile)" = "lib.conf" && $(TEST) -f lib.conf; then \
1416 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
1418 $(Q)$(IF) $(TEST) -f libdefs.h; then \
1419 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
1421 $(Q)$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
1424 #------------------------------------------------------------------------------
1427 #------------------------------------------------------------------------------
1428 # Generate the support files for compiling a module. This includes include
1429 # files and source files.
1430 %define rule_genmodule_includes mmake=TMP modname=/A flavour= modtype=/A modsuffix= \
1431 targetdir= conffile= confoverride=
1434 %(mmake)_MODNAME := %(modname)_%(flavour)
1436 %(mmake)_MODNAME := %(modname)
1439 ifneq ($($(%(mmake)_MODNAME)_INCLUDES),)
1441 %(mmake)_TARGETS := $($(%(mmake)_MODNAME)_INCLUDES)
1443 %(mmake)_DEPS := $(GENMODULE)
1446 ifneq (%(conffile),)
1447 ifeq ($(dir %(conffile)),./)
1448 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1449 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1451 %(mmake)_OPTS += -c %(conffile)
1452 %(mmake)_DEPS += %(conffile)
1455 %(mmake)_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1456 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1458 ifneq (%(confoverride),)
1459 ifeq ($(dir %(confoverride)),./)
1460 %(mmake)_OPTS += -o $(SRCDIR)/$(CURDIR)/%(confoverride)
1461 %(mmake)_DEPS += $(SRCDIR)/$(CURDIR)/%(confoverride)
1463 %(mmake)_OPTS += -o %(confoverride)
1464 %(mmake)_DEPS += %(confoverride)
1467 ifneq (%(modsuffix),)
1468 %(mmake)_OPTS += -s %(modsuffix)
1470 ifneq (%(targetdir),)
1471 %(mmake)_OPTS += -d %(targetdir)
1472 %(mmake)_TARGETS := $(addprefix %(targetdir)/,$(%(mmake)_TARGETS))
1473 %(mmake)_GENINCFLAG=%(targetdir)/.%(modname).%(modtype)-includes
1475 %(mmake)_GENINCFLAG=$(GENDIR)/$(CURDIR)/.%(modname).%(modtype)-includes
1478 $(%(mmake)_TARGETS) : $(%(mmake)_DEPS) $(%(mmake)_GENINCFLAG)
1480 $(%(mmake)_GENINCFLAG) : OPTS := $(%(mmake)_OPTS)
1481 $(%(mmake)_GENINCFLAG) : MODNAME := %(modname)
1482 $(%(mmake)_GENINCFLAG) : MODTYPE := %(modtype)
1483 $(%(mmake)_GENINCFLAG) : $(%(mmake)_DEPS)
1484 $(Q)$(ECHO) "Generating $(MODNAME).$(MODTYPE) includes"
1485 $(Q)$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
1489 #------------------------------------------------------------------------------
1491 #------------------------------------------------------------------------------
1492 # Link %(objs) to binary blob in %(file) using %(name) as name of embedded binary object
1493 # 'start' is an optional starting address
1494 # 'ldflags' is optional additional flags for the linker
1495 %define rule_link_binary mmake=BD file=/A name=/A objs= files= start=0 ldflags=
1497 %(mmake)_OUTDIR := $(dir %(file))
1498 # This trick removes the trailing '/', otherwise findstring below fails, causing a warning
1499 %(mmake)_OUTDIR := $(subst /*,,$(addsuffix *,$(%(mmake)_OUTDIR)))
1500 %(mmake)_TMPDIR := $(GENDIR)/$(CURDIR)
1501 %(mmake)_OBJS := $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir %(files))))
1502 %(mmake)_DEPS := $(addsuffix .d,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir %(files))))
1503 %(mmake)_OBJS += %(objs)
1505 %rule_compile_multi basenames="%(files)" targetdir=$(%(mmake)_OBJDIR)
1507 %(file) : $(%(mmake)_OBJS) $(%(mmake)_DEPS)
1508 $(Q)$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)..."
1509 $(Q)$(KERNEL_LD) %(ldflags) --entry=%(start) --oformat=binary -Ttext=%(start) -o $(%(mmake)_TMPDIR)/%(name) $(%(mmake)_OBJS)
1510 $(Q)cd $(%(mmake)_TMPDIR) && $(AROS_LD) %(ldflags) -r --format binary %(name) -o $@
1512 ifeq ($(findstring $(%(mmake)_OUTDIR),$(GLOB_MKDIRS)),)
1513 %rule_makedirs dirs="$(%(mmake)_OUTDIR)" setuptarget=%(file)
1518 #------------------------------------------------------------------------------
1519 # Common rules for all makefiles
1521 # Delete generated makefiles
1524 $(Q)$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
1526 include $(SRCDIR)/config/make.tail
1528 BDID := $(BDTARGETID)
1530 #------------------------------------------------------------------------------
1533 #############################################################################
1534 #############################################################################
1536 ## Here are the mmakefile build macros. These are macros that takes care ##
1537 ## of everything to go from the sources to the generated target. Also all ##
1538 ## intermediate files and directories that are needed are created by these ##
1541 #############################################################################
1542 #############################################################################
1544 #------------------------------------------------------------------------------
1546 %define build_prog mmake=/A progname=/A files= cxxfiles= \
1548 asmfiles= objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1549 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= ldflags=$(LDFLAGS) \
1550 aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
1551 includedir= libdir= \
1552 compiler=target linker= \
1553 coverageinstr=$(TARGET_COVERAGEINSTR) funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO)
1557 %(mmake)_PROGNAME := %(progname)
1558 %(mmake)_OBJDIR := %(objdir)
1559 %(mmake)_TARGETDIR := %(targetdir)
1560 %(mmake)_LINKER := %(linker)
1561 %(mmake)_LIBS := %(uselibs)
1562 # If not supplied, linker is equal to compiler
1563 ifeq ($(%(mmake)_LINKER),)
1564 %(mmake)_LINKER := %(compiler)
1567 ifneq ("$(strip %(files) %(cxxfiles) %(objcfiles) %(asmfiles))","")
1568 %(mmake)_FILES := %(files)
1569 %(mmake)_OBJCFILES := %(objcfiles)
1570 %(mmake)_ASMFILES := %(asmfiles)
1571 %(mmake)_CXXFILES := %(cxxfiles)
1573 %(mmake)_FILES := $(%(mmake)_PROGNAME)
1574 %(mmake)_OBJCFILES :=
1575 %(mmake)_ASMFILES :=
1576 %(mmake)_CXXFILES :=
1579 %(mmake)_ARCHOBJS := $(wildcard $(%(mmake)_OBJDIR)/arch/*.o)
1580 %(mmake)_ARCHFILES := $(basename $(notdir $(%(mmake)_ARCHOBJS)))
1581 %(mmake)_C_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_FILES))
1582 %(mmake)_CXX_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_CXXFILES))
1583 %(mmake)_OBJC_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_OBJCFILES))
1585 TMP_FILES := $(%(mmake)_C_NARCHFILES) $(%(mmake)_CXX_NARCHFILES) $(%(mmake)_ASMFILES) $(%(mmake)_OBJC_NARCHFILES)
1586 %(mmake)_OBJS := $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir $(TMP_FILES))))
1587 %(mmake)_DEPS := $(addsuffix .d,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir $(TMP_FILES))))
1589 %(mmake)_CPPFLAGS := %(cppflags)
1590 ifneq (%(includedir),)
1591 %(mmake)_CPPFLAGS += -I%(includedir)
1593 %(mmake)_CFLAGS := %(cflags)
1594 %(mmake)_CXXFLAGS := %(cxxflags)
1595 %(mmake)_COVERAGE := no
1596 ifeq (%(compiler),target)
1597 ifeq (%(usestartup),yes)
1598 ifeq (%(coverageinstr),yes)
1599 %(mmake)_COVERAGE := yes
1600 %(mmake)_COVERAGEFLAGS ?= $(COVERAGEINSTR_FLAGS)
1601 %(mmake)_COVERAGELIBS ?= $(COVERAGEINSTR_LIBS)
1602 %(mmake)_CFLAGS := $(strip $(%(mmake)_COVERAGEFLAGS) $(%(mmake)_CFLAGS))
1603 %(mmake)_CXXFLAGS := $(strip $(%(mmake)_COVERAGEFLAGS) $(%(mmake)_CXXFLAGS))
1604 %(mmake)_LIBS += $(%(mmake)_COVERAGELIBS)
1606 ifeq (%(funcinstr),yes)
1607 %(mmake)_FUNCINSTR := yes
1608 %(mmake)_INSTRFUNCFLAGS ?= $(FUNCINSTR_FLAGS)
1609 %(mmake)_INSTRFUNCLIBS ?= $(FUNCINSTR_LIBS)
1610 %(mmake)_CFLAGS := $(strip $(%(mmake)_INSTRFUNCFLAGS) $(%(mmake)_CFLAGS))
1611 %(mmake)_CXXFLAGS := $(strip $(%(mmake)_INSTRFUNCFLAGS) $(%(mmake)_CXXFLAGS))
1612 %(mmake)_LIBS += $(%(mmake)_INSTRFUNCLIBS)
1616 %(mmake)_CFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(%(mmake)_CFLAGS))
1617 %(mmake)_CXXFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(%(mmake)_CXXFLAGS))
1620 %(mmake)_AFLAGS := %(aflags)
1622 %(mmake)_DFLAGS := %(dflags)
1624 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
1626 ifneq (%(dxxflags),)
1627 %(mmake)_DXXFLAGS := %(dxxflags)
1629 %(mmake)_DXXFLAGS := $(%(mmake)_CXXFLAGS)
1631 %(mmake)_LDFLAGS := %(ldflags)
1633 %(mmake)_LDFLAGS += -L%(libdir)
1637 %(mmake)-quick : %(mmake)
1639 #MM %(mmake) : includes-generate-deps core-linklibs
1640 %(mmake) : $(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME)
1642 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick %(mmake)-gz-quick),)
1643 %rule_compile_cxx_multi mmake=%(mmake) \
1644 basenames=$(%(mmake)_CXX_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
1645 cppflags=$(%(mmake)_CPPFLAGS) cxxflags=$(%(mmake)_CXXFLAGS) dxxflags=$(%(mmake)_DXXFLAGS) \
1646 compiler="%(compiler)"
1647 %rule_compile_objc_multi mmake=%(mmake) \
1648 basenames=$(%(mmake)_OBJC_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
1649 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
1650 compiler="%(compiler)"
1651 %rule_compile_multi mmake=%(mmake) \
1652 basenames=$(%(mmake)_C_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
1653 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
1654 compiler="%(compiler)"
1655 %rule_assemble_multi mmake=%(mmake) \
1656 cmd=$(%(mmake)_ASSEMBLER) basenames=$(%(mmake)_ASMFILES) targetdir=$(%(mmake)_OBJDIR) \
1657 cppflags=$(%(mmake)_CPPFLAGS) aflags=$(%(mmake)_AFLAGS)
1659 %rule_link_prog mmake=%(mmake) prog=$(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME) \
1660 objs="$(%(mmake)_OBJS) $(%(mmake)_ARCHOBJS) $(USER_OBJS)" ldflags=$(%(mmake)_LDFLAGS) \
1661 uselibs="$(%(mmake)_LIBS)" usehostlibs="%(usehostlibs)" \
1662 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)" \
1663 cmd=$(%(mmake)_LINK) strip=$(%(mmake)_STRIP) objdir=$(%(mmake)_OBJDIR) coverageinstr=$(%(mmake)_COVERAGE)
1667 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(%(mmake)_DEPS)
1669 %rule_makedirs dirs="$(%(mmake)_OBJDIR) $(%(mmake)_TARGETDIR)" setuptarget="$(%(mmake)_OBJS) $(%(mmake)_DEPS) $(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME)"
1671 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME) $(%(mmake)_DEPS)
1674 $(Q)$(ECHO) "Cleaning up for metatarget %(mmake)"
1678 #------------------------------------------------------------------------------
1681 #------------------------------------------------------------------------------
1682 # Build programs, for every C file an executable will be built with the same
1683 # name as the C file
1684 %define build_progs mmake=/A files=/A nix=no \
1685 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1686 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= ldflags=$(LDFLAGS) \
1687 includedir= libdir= \
1689 uselibs= usehostlibs= usestartup=yes detach=no \
1690 coverageinstr=$(TARGET_COVERAGEINSTR) funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO)
1694 %(mmake)_OBJDIR := %(objdir)
1695 %(mmake)_TARGETDIR := %(targetdir)
1696 %(mmake)_LIBS := %(uselibs)
1698 %(mmake)_FILES := %(files)
1699 %(mmake)_OBJS := $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/,$(%(mmake)_FILES)))
1700 %(mmake)_DEPS := $(addsuffix .d,$(addprefix $(%(mmake)_OBJDIR)/,$(%(mmake)_FILES)))
1701 %(mmake)_EXES := $(addprefix $(%(mmake)_TARGETDIR)/,$(%(mmake)_FILES))
1703 %(mmake)_CPPFLAGS := %(cppflags)
1704 ifneq (%(includedir),)
1705 %(mmake)_CPPFLAGS += -I%(includedir)
1707 %(mmake)_CFLAGS := %(cflags)
1708 %(mmake)_COVERAGE := no
1709 ifeq (%(compiler),target)
1710 ifeq (%(usestartup),yes)
1711 ifeq (%(coverageinstr),yes)
1712 %(mmake)_COVERAGE := yes
1713 %(mmake)_COVERAGEFLAGS ?= $(COVERAGEINSTR_FLAGS)
1714 %(mmake)_COVERAGELIBS ?= $(COVERAGEINSTR_LIBS)
1715 %(mmake)_CFLAGS := $(strip $(%(mmake)_COVERAGEFLAGS) $(%(mmake)_CFLAGS))
1716 %(mmake)_LIBS += $(%(mmake)_COVERAGELIBS)
1718 ifeq (%(funcinstr),yes)
1719 %(mmake)_FUNCINSTR := yes
1720 %(mmake)_INSTRFUNCFLAGS ?= $(FUNCINSTR_FLAGS)
1721 %(mmake)_INSTRFUNCLIBS ?= $(FUNCINSTR_LIBS)
1722 %(mmake)_CFLAGS := $(strip $(%(mmake)_INSTRFUNCFLAGS) $(%(mmake)_CFLAGS))
1723 %(mmake)_LIBS += $(%(mmake)_INSTRFUNCLIBS)
1727 %(mmake)_CFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(%(mmake)_CFLAGS))
1731 %(mmake)_DFLAGS := %(dflags)
1733 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
1735 %(mmake)_LDFLAGS := %(ldflags)
1737 %(mmake)_LDFLAGS += -L%(libdir)
1741 %(mmake)-quick : %(mmake)
1743 #MM %(mmake) : includes-generate-deps core-linklibs
1744 %(mmake) : $(%(mmake)_EXES)
1746 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1747 %rule_compile_multi mmake=%(mmake) basenames=$(%(mmake)_FILES) targetdir=$(%(mmake)_OBJDIR) \
1748 cflags=$(%(mmake)_CFLAGS) cppflags=$(%(mmake)_CPPFLAGS) dflags=$(%(mmake)_DFLAGS) compiler="%(compiler)"
1750 %rule_link_progs mmake=%(mmake) progs=$(%(mmake)_FILES) nix="%(nix)" \
1751 targetdir=$(%(mmake)_TARGETDIR) objdir=$(%(mmake)_OBJDIR) \
1752 ldflags=$(%(mmake)_LDFLAGS) \
1753 uselibs="$(%(mmake)_LIBS)" usehostlibs="%(usehostlibs)" \
1754 usestartup="%(usestartup)" detach="%(detach)" \
1755 cmd=$(%(mmake)_LINK) strip=$(%(mmake)_STRIP) objdir=$(%(mmake)_OBJDIR) coverageinstr=$(%(mmake)_COVERAGE)
1759 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(%(mmake)_DEPS)
1761 %rule_makedirs dirs="$(%(mmake)_TARGETDIR) $(%(mmake)_OBJDIR)" setuptarget="$(%(mmake)_DEPS) $(%(mmake)_OBJS) $(addprefix $(%(mmake)_TARGETDIR)/,$(%(mmake)_FILES))"
1763 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_EXES) $(%(mmake)_DEPS)
1766 $(Q)$(ECHO) "Cleaning up for metatarget %(mmake)"
1770 #------------------------------------------------------------------------------
1773 #------------------------------------------------------------------------------
1775 # This is a bare version: It just compiles and links the given files. It is
1776 # assumed that all needed boiler plate code is in the files. This should only
1777 # be used for compiling external code. For AROS code use %build_module
1778 %define build_module_simple mmake=/A modname=/A modtype=/A \
1779 files="$(basename $(call WILDCARD, *.c))" \
1781 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
1782 cppflags=$(CPPFLAGS) \
1783 cflags=$(CFLAGS) dflags= \
1784 cxxflags=$(CXXFLAGS) dxxflags= \
1785 objdir=$(OBJDIR) moduledir= \
1786 uselibs= usehostlibs= compiler=target funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO)
1788 # Define metamake targets and their dependencies
1789 #MM %(mmake) : core-linklibs includes-generate-deps
1790 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1791 #MM %(mmake)-kobj-quick
1795 %(mmake)_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj
1797 .PHONY : $(%(mmake)_ALLTARGETS)
1800 $(error using %build_module_simple: modname may not be empty)
1803 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1806 # Default values for variables and arguments
1807 %(mmake)_DEFLINKLIBNAME := %(modname)
1808 %(mmake)_CFLAGS := %(cflags)
1809 %(mmake)_CXXFLAGS := %(cxxflags)
1810 ifeq (%(compiler),target)
1812 %(mmake)_CFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(%(mmake)_CFLAGS))
1814 ifeq (%(funcinstr),yes)
1815 %(mmake)_FUNCINSTR := yes
1816 %(mmake)_CFLAGS := $(strip $(FUNCINSTR_FLAGS) $(%(mmake)_CFLAGS))
1820 %(mmake)_DFLAGS := %(dflags)
1822 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
1824 %(mmake)_DEFDXXFLAGS := %(dxxflags)
1825 OBJDIR ?= $(GENDIR)/$(CURDIR)
1826 %(mmake)_MODDIR := %(moduledir)
1827 ifeq ($(%(mmake)_MODDIR),)
1828 ifeq (%(modtype),library)
1829 %(mmake)_MODDIR := $(AROS_LIBRARIES)
1831 ifeq (%(modtype),gadget)
1832 %(mmake)_MODDIR := $(AROS_GADGETS)
1834 ifeq (%(modtype),datatype)
1835 %(mmake)_MODDIR := $(AROS_DATATYPES)
1837 ifeq (%(modtype),handler)
1838 %(mmake)_MODDIR := $(AROS_FS)
1840 ifeq (%(modtype),device)
1841 %(mmake)_MODDIR := $(AROS_DEVS)
1843 ifeq (%(modtype),resource)
1844 %(mmake)_MODDIR := $(AROS_RESOURCES)
1846 ifeq (%(modtype),hook)
1847 %(mmake)_MODDIR := $(AROS_RESOURCES)
1849 ifeq (%(modtype),mui)
1850 %(mmake)_MODDIR := $(AROS_CLASSES)/Zune
1852 ifeq (%(modtype),mcc)
1853 %(mmake)_MODDIR := $(AROS_CLASSES)/Zune
1855 ifeq (%(modtype),mcp)
1856 %(mmake)_MODDIR := $(AROS_CLASSES)/Zune
1858 ifeq (%(modtype),usbclass)
1859 %(mmake)_MODDIR := $(AROS_CLASSES)/USB
1861 ifeq (%(modtype),hidd)
1862 %(mmake)_MODDIR := $(AROS_DRIVERS)
1864 ifeq (%(modtype),printer)
1865 %(mmake)_MODDIR := $(AROS_PRINTERS)
1868 ifeq ($(%(mmake)_MODDIR),)
1869 $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1872 %(mmake)_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1873 %(mmake)_ARCHFILES := $(basename $(notdir $(%(mmake)_ARCHOBJS)))
1874 %(mmake)_C_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),%(files))
1875 %(mmake)_CXX_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),%(cxxfiles))
1876 %(mmake)_OBJC_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),%(objcfiles))
1878 %rule_compile_cxx_multi mmake=%(mmake) \
1879 basenames=$(%(mmake)_CXX_NARCHFILES) targetdir="%(objdir)" \
1880 cppflags="%(cppflags)" cxxflags=$(%(mmake)_CXXFLAGS) dxxflags=$(%(mmake)_DXXFLAGS) \
1881 compiler="%(compiler)"
1882 %rule_compile_objc_multi mmake=%(mmake) \
1883 basenames=$(%(mmake)_OBJC_NARCHFILES) targetdir="%(objdir)" \
1884 cppflags="%(cppflags)" cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
1885 compiler="%(compiler)"
1886 %rule_compile_multi mmake=%(mmake) \
1887 basenames=$(%(mmake)_C_NARCHFILES) targetdir="%(objdir)" \
1888 cppflags="%(cppflags)" cflags="$(%(mmake)_CFLAGS)" dflags="$(%(mmake)_DFLAGS)" \
1889 compiler="%(compiler)"
1891 # Handlers use dash instead of dot in their names
1892 ifeq (%(modtype),handler)
1893 %(mmake)_MODULE := $(%(mmake)_MODDIR)/%(modname)-%(modtype)
1895 ifeq (%(modtype),printer)
1896 %(mmake)_MODULE := $(%(mmake)_MODDIR)/%(modname)
1898 %(mmake)_MODULE := $(%(mmake)_MODDIR)/%(modname).%(modtype)
1901 %(mmake)_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1903 %(mmake)-quick : %(mmake)
1904 %(mmake)-kobj-quick : $(%(mmake)_KOBJ)
1905 %(mmake) : $(%(mmake)_MODULE)
1906 %(mmake)-kobj : $(%(mmake)_KOBJ)
1908 # The module is linked from all the compiled .o files
1909 %(mmake)_OBJS := $(%(mmake)_ARCHOBJS) $(addprefix %(objdir)/, $(addsuffix .o,$(notdir $(%(mmake)_C_NARCHFILES))))
1911 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
1912 # This breaks con-handler build. Here we work around this
1913 ifeq (%(modname),con)
1914 %(mmake)_ERR := $(notdir $(%(mmake)_MODULE)).err
1916 %(mmake)_ERR := %(modname).err
1919 %rule_linkmodule module=$(%(mmake)_MODULE) objs=$(%(mmake)_OBJS) \
1920 endobj= err=$(%(mmake)_ERR) objdir="%(objdir)" \
1921 ldflags="$(strip $(LDFLAGS) $(%(modname)_LDFLAGS))" \
1922 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
1924 # Link kernel object file
1925 %(mmake)_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1927 # Make these symbols local
1928 %(mmake)_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1929 UtilityBase ExpansionBase KeymapBase KernelBase
1931 %(mmake)_SYMBOLS := $(%(mmake)_KBASE)
1933 %(mmake)_KLIB := hiddstubs amiga arossupport autoinit libinit
1934 %(mmake)_KOBJ_LIBS := $(filter-out $(%(mmake)_KLIB),%(uselibs)) $(%(mmake)_KAUTOLIB)
1935 $(%(mmake)_KOBJ) : LINKLIBS:=$(%(mmake)_KOBJ_LIBS)
1936 $(%(mmake)_KOBJ) : FILTBASES:=$(addprefix -L ,$(%(mmake)_SYMBOLS))
1937 $(%(mmake)_KOBJ) : USER_LDFLAGS := $(USER_LDFLAGS)
1938 $(%(mmake)_KOBJ) : $(%(mmake)_OBJS) $(%(mmake)_ENDOBJS)
1939 $(Q)$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
1940 $(Q)$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1941 $(Q)$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
1944 ## Dependency fine-tuning
1946 %(mmake)_DEPS := $(addprefix %(objdir)/, $(addsuffix .d,%(files)))
1947 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(%(mmake)_DEPS)
1949 %rule_makedirs dirs="%(objdir) $(%(mmake)_MODDIR) $(KOBJSDIR)" setuptarget="$(%(mmake)_OBJS) $(%(mmake)_DEPS) $(%(mmake)_MODULE) $(%(mmake)_KOBJ) "
1951 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_MODULE) $(%(mmake)_KOBJ) $(%(mmake)_DEPS)
1953 $(Q)$(ECHO) "Cleaning up for module %(modname)"
1956 #------------------------------------------------------------------------------
1959 #------------------------------------------------------------------------------
1960 # Build a module - core routine
1961 # Explanation of this macro is done in the developer's manual
1962 %define build_module_core mmake=/A modname=/A modtype=/A modsuffix= version= flavour= \
1963 conffile= confoverride= \
1964 files="$(basename $(call WILDCARD, *.c))" \
1966 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
1967 linklibfiles= linklibobjs= \
1968 cppflags=$(CPPFLAGS) \
1969 cflags=$(CFLAGS) dflags= \
1970 cxxflags=$(CXXFLAGS) dxxflags= \
1971 objdir= moduledir= prefix=$(AROSDIR) \
1972 linklibname= uselibs= usehostlibs= \
1973 compiler=target funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO) nostartup=yes archspecific=no \
1974 include_set=includes-all includedir= libdir= \
1975 build_abi= build_library=
1977 # We will employ a terrifying, but unavoidable, hack here.
1978 # genmf has no concept of conditionals (ie %ifeq), and MetaMake
1979 # ignores GNU Make ifeq() statements, but will process any #MM
1980 # headed lines in the file.
1982 # So, to make the following #MM lines conditional on whether we want
1983 # to build the ABI, Library, or both, we define build_abi= and
1984 # build_library as 'M' to enable, or '' to disable, which allows genmf
1985 # to do the following conversions:
1987 # #%(build_abi)M includes-foo: foo-include
1988 # becomes, when build_abi=M
1989 # #MM includes-foo: foo-include <= Processed by MetaMake
1990 # but, when build_abi= ...
1991 # #M includes-foo: foo-includes <= ignored by MetaMake! Yes!
1993 # Taking full blame for this: Jason S. McMullan <jason.mcmullan@gmail.com>
1995 # Define metamake targets and their dependencies
1998 #MM %(mmake)-makefile
2002 #M%(build_abi)- %(include_set) : %(mmake)-includes
2003 #M%(build_abi)- linklibs-%(modname): %(mmake)-linklib
2004 #M%(build_abi)- linklibs-%(modname)_rel : %(mmake)-linklib
2005 #M%(build_abi)- includes-%(modname): %(mmake)-includes
2006 #M%(build_abi)- includes-%(modname)_rel : %(mmake)-includes
2007 #M%(build_abi)- %(mmake) : %(mmake)-includes core-linklibs linklibs-%(uselibs)
2008 #M%(build_abi) %(mmake)-linklib : %(mmake)-includes includes-%(uselibs)
2009 #M%(build_abi)- %(mmake)-quick : %(mmake)-includes-quick
2010 #M%(build_abi) %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
2011 #M%(build_abi) includes-generate-deps %(mmake)-fd
2012 #M%(build_abi) %(mmake)-includes-quick
2013 #M%(build_abi) %(mmake)-includes-dirs
2014 #M%(build_abi) %(mmake)-fd
2017 #%(build_library)M %(mmake)-kobj : core-linklibs linklibs-%(uselibs)
2018 #%(build_library)M %(mmake)-kobj-quick :
2020 # Library with ABI targets:
2021 #%(build_library)%(build_abi) %(mmake)-kobj : %(mmake)-includes core-linklibs linklibs-%(uselibs)
2022 #%(build_library)%(build_abi) %(mmake)-kobj-quick : %(mmake)-includes-quick
2024 # All MetaMake targets defined by this macro
2025 %(mmake)%(flavour)_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-clean
2027 ifeq (%(build_library),M)
2028 %(mmake)%(flavour)_ALLTARGETS += %(mmake)-kobj %(mmake)-kobj-quick
2031 ifeq (%(build_abi),M)
2032 %(mmake)%(flavour)_ALLTARGETS += %(mmake)-includes \
2033 %(mmake)-includes-quick %(mmake)-includes-dirs \
2034 %(mmake)-linklib %(mmake)-fd
2037 .PHONY : $(%(mmake)%(flavour)_ALLTARGETS) %(mmake)-makefile
2040 $(error using %build_module: modname may not be empty)
2043 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
2046 # Default values for variables and arguments
2048 %(mmake)%(flavour)_DEFNAME := %(modname)_%(flavour)
2050 %(mmake)%(flavour)_DEFNAME := %(modname)
2052 %(mmake)%(flavour)_DEFLINKLIBNAME := $(%(mmake)%(flavour)_DEFNAME)
2053 ifneq (%(linklibname),)
2054 %(mmake)%(flavour)_LINKLIBNAME := %(linklibname)
2056 %(mmake)%(flavour)_LINKLIBNAME = $(%(mmake)%(flavour)_DEFLINKLIBNAME)
2058 %(mmake)%(flavour)_DEFCPPFLAGS := %(cppflags)
2059 ifneq (%(includedir),)
2060 %(mmake)%(flavour)_DEFCPPFLAGS += -I%(includedir)
2062 %(mmake)%(flavour)_DEFDFLAGS := %(cflags)
2064 %(mmake)%(flavour)_DFLAGS := %(dflags)
2066 %(mmake)%(flavour)_DFLAGS = $(%(mmake)%(flavour)_DEFDFLAGS)
2068 %(mmake)%(flavour)_DEFDXXFLAGS := %(cxxflags)
2069 ifneq (%(dxxflags),)
2070 %(mmake)%(flavour)_DXXFLAGS := %(dxxflags)
2072 %(mmake)%(flavour)_DXXFLAGS = $(%(mmake)%(flavour)_DEFDXXFLAGS)
2075 ifeq (%(compiler),target)
2077 %(mmake)%(flavour)_DEFDFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH) $(%(mmake)%(flavour)_DEFDFLAGS))
2078 %(mmake)%(flavour)_DEFDXXFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH) $(%(mmake)%(flavour)_DEFDXXFLAGS))
2080 ifeq (%(funcinstr),yes)
2081 %(mmake)_FUNCINSTR := yes
2082 %(mmake)%(flavour)_DEFDFLAGS := $(strip $(FUNCINSTR_FLAGS) $(%(mmake)%(flavour)_DEFDFLAGS))
2083 %(mmake)%(flavour)_DEFDXXFLAGS := $(strip $(FUNCINSTR_FLAGS) $(%(mmake)%(flavour)_DEFDXXFLAGS))
2087 OBJDIR ?= $(GENDIR)/$(CURDIR)
2089 %(mmake)_OBJDIR := %(objdir)
2091 %(mmake)_OBJDIR := $(OBJDIR)/$(%(mmake)%(flavour)_DEFNAME)
2094 %(mmake)%(flavour)_OBJDIR := $(%(mmake)_OBJDIR)
2097 ## Create genmodule include Makefile for the module
2099 %(mmake)%(flavour)-makefile := $(%(mmake)%(flavour)_OBJDIR)/Makefile.$(%(mmake)%(flavour)_DEFNAME)%(modtype)
2100 %(mmake)%(flavour)-genmakefile : $(%(mmake)%(flavour)-makefile)
2102 %rule_genmodule_makefile \
2103 mmake=%(mmake)-genmakefile modname="%(modname)" flavour="%(flavour)" modtype="%(modtype)" \
2104 modsuffix="%(modsuffix)" targetdir="$(%(mmake)%(flavour)_OBJDIR)" \
2105 conffile="%(conffile)" confoverride="%(confoverride)"
2107 %rule_makedirs dirs="$(%(mmake)%(flavour)_OBJDIR)" setuptarget=$(%(mmake)%(flavour)-makefile)
2109 # Do not parse these statements if metatarget is not appropriate
2110 ifneq ($(filter $(TARGET),$(%(mmake)%(flavour)_ALLTARGETS)),)
2112 # suppress makes warning that the Makefile doesnt yet exist
2113 # on early passes (it will generate the file as needed though)
2114 # when we include it.
2115 -include $(%(mmake)%(flavour)-makefile)
2117 %(mmake)%(flavour)_DEFMODDIR := $($(%(mmake)%(flavour)_DEFNAME)_MODDIR)
2118 ifeq (%(archspecific),yes)
2119 %(mmake)%(flavour)_DEFMODDIR := $(AROS_DIR_ARCH)/$(%(mmake)%(flavour)_DEFMODDIR)
2121 ifneq (%(moduledir),)
2122 %(mmake)%(flavour)_MODDIR := %(moduledir)
2124 %(mmake)%(flavour)_MODDIR := $(%(mmake)%(flavour)_DEFMODDIR)
2127 ## include files generation
2129 ifneq (%(includedir),)
2130 %(mmake)%(flavour)_INCDIR := %(includedir)
2132 %(mmake)%(flavour)_INCDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/$(AROS_DIR_INCLUDE)
2134 %(mmake)%(flavour)_LIBDEFSINC := $(%(mmake)%(flavour)_OBJDIR)/include/$(%(mmake)%(flavour)_DEFNAME)_libdefs.h
2135 %(mmake)%(flavour)_DEFLIBDEFSINC := $(%(mmake)%(flavour)_OBJDIR)/include/$(%(mmake)%(flavour)_DEFNAME)_deflibdefs.h
2137 ifeq (%(build_abi),M)
2138 %(mmake)-includes-quick : %(mmake)-includes
2139 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2140 $(addprefix $(%(mmake)%(flavour)_INCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2141 $(%(mmake)%(flavour)_LIBDEFSINC) $(%(mmake)%(flavour)_DEFLIBDEFSINC)
2143 ifneq ($($(%(mmake)%(flavour)_DEFNAME)_INCLUDES),)
2144 %rule_genmodule_includes mmake=%(mmake)-includes modname="%(modname)" modtype="%(modtype)" \
2145 modsuffix="%(modsuffix)" targetdir="$(%(mmake)_OBJDIR)/include" \
2146 conffile="%(conffile)" confoverride="%(confoverride)" flavour="%(flavour)"
2148 %rule_copy_diff_multi \
2149 files=$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES) srcdir="$(%(mmake)_OBJDIR)/include" targetdir=$(GENINCDIR) \
2150 stampfile="$(%(mmake)_OBJDIR)/%(modname)_geninc"
2152 %rule_copy_diff_multi \
2153 files=$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES) srcdir="$(%(mmake)_OBJDIR)/include" targetdir=$(%(mmake)%(flavour)_INCDIR) \
2154 stampfile="$(%(mmake)_OBJDIR)/%(modname)_incs"
2156 %(mmake)%(flavour)_INCDIRS := $(filter-out ./,$(sort $(dir $($(%(mmake)%(flavour)_DEFNAME)_INCLUDES))))
2158 TMP%(modname)_INCDIRS := \
2159 $(%(mmake)_OBJDIR)/include $(addprefix $(%(mmake)_OBJDIR)/include/,$(%(mmake)%(flavour)_INCDIRS)) \
2160 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(%(mmake)%(flavour)_INCDIRS)) \
2161 $(%(mmake)%(flavour)_INCDIR) $(addprefix $(%(mmake)%(flavour)_INCDIR)/,$(%(mmake)%(flavour)_INCDIRS))
2162 %rule_makedirs dirs="$(TMP%(modname)_INCDIRS)" setuptarget="%(mmake)-includes-dirs"
2168 %rule_genmodule_genlibdefs mmake=%(mmake)-genlibdefs modname="%(modname)" flavour="%(flavour)" modtype="%(modtype)" \
2169 modsuffix="%(modsuffix)" targetdir="$(%(mmake)%(flavour)_OBJDIR)/include" \
2170 conffile="%(conffile)" confoverride="%(confoverride)" version="%(version)"
2172 $(%(mmake)%(flavour)_DEFLIBDEFSINC) : FILENAME := $(%(mmake)%(flavour)_LIBDEFSINC)
2173 $(%(mmake)%(flavour)_DEFLIBDEFSINC) : $(%(mmake)%(flavour)_LIBDEFSINC)
2174 $(Q)$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
2175 $(Q)$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
2177 $(%(mmake)%(flavour)_LIBDEFSINC) $(%(mmake)%(flavour)_DEFLIBDEFSINC) : | $(%(mmake)%(flavour)_OBJDIR)/include
2178 %rule_makedirs dirs="$(%(mmake)%(flavour)_OBJDIR)/include" setuptarget=%(mmake)%(flavour)-includes-dirs
2180 ## Extra genmodule src files generation
2182 %rule_genmodule_files mmake=%(mmake)-genmodfiles modname="%(modname)" modtype="%(modtype)" \
2183 modsuffix="%(modsuffix)" targetdir="$(%(mmake)%(flavour)_OBJDIR)" stubdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" \
2184 conffile="%(conffile)" confoverride="%(confoverride)" flavour="%(flavour)"
2186 $(%(mmake)-genmodfiles_GENFILEFLAG) : $(%(mmake)%(flavour)_DEFLIBDEFSINC) $(%(mmake)%(flavour)-makefile)
2188 %rule_makedirs dirs="$(%(mmake)%(flavour)_OBJDIR)/linklib" setuptarget=$(%(mmake)-genmodfiles_GENFILEFLAG)
2190 ifeq (%(build_abi),M)
2192 ifeq (%(includedir),)
2193 %(mmake)%(flavour)_FDDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/$(AROS_DIR_SDK)/$(AROS_DIR_FD)
2195 %(mmake)%(flavour)_FDDIR := %(includedir)/../$(AROS_DIR_FD)
2197 %(mmake)-fd : $(%(mmake)%(flavour)_FDDIR)/%(modname)_lib.fd
2199 %rule_genmodule_fd modname="%(modname)" modtype="%(modtype)" \
2200 modsuffix="%(modsuffix)" targetdir=$(%(mmake)%(flavour)_FDDIR) conffile="%(conffile)" confoverride="%(confoverride)"
2202 $(%(mmake)%(flavour)_FDDIR)/%(modname)_lib.fd : | $(%(mmake)%(flavour)_FDDIR)
2204 %rule_makedirs dirs="$(%(mmake)%(flavour)_FDDIR)" setuptarget=%(mmake)%(flavour)-fd-setup
2209 %(mmake)%(flavour)_FILES := %(files)
2210 %(mmake)%(flavour)_OBJCFILES := %(objcfiles)
2211 %(mmake)%(flavour)_CXXFILES := %(cxxfiles)
2213 %(mmake)%(flavour)_LIBFILES := %(linklibfiles)
2214 %(mmake)%(flavour)_LIBS := %(uselibs)
2216 %(mmake)%(flavour)_FDIRS := $(sort $(dir $(%(mmake)%(flavour)_FILES)))
2218 %(mmake)%(flavour)_FILEMATCH = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1)))
2219 %(mmake)%(flavour)_MATCHARCH = $(foreach matchfile,$(2),$(foreach archfile,$(1),$(if $(call %(mmake)%(flavour)_FILEMATCH,$(archfile),$(notdir $(matchfile))),$(matchfile),)))
2220 %(mmake)%(flavour)_FILTERARCH = $(filter-out $(call %(mmake)%(flavour)_MATCHARCH,$(1),$(2)),$(2))
2221 %(mmake)%(flavour)_STARTFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_STARTFILES))
2222 %(mmake)%(flavour)_ENDFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_ENDFILES))
2224 %(mmake)%(flavour)_ARCHOBJS := $(wildcard $(%(mmake)%(flavour)_OBJDIR)/arch/*.o)
2225 %(mmake)%(flavour)_LIBARCHOBJS := $(wildcard $(%(mmake)%(flavour)_OBJDIR)/linklib/arch/*.o)
2226 %(mmake)%(flavour)_ARCHFILES := $(basename $(notdir $(%(mmake)%(flavour)_ARCHOBJS)))
2227 %(mmake)%(flavour)_LIBARCHFILES := $(basename $(notdir $(%(mmake)%(flavour)_LIBARCHOBJS)))
2228 %(mmake)%(flavour)_C_NARCHFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_ARCHFILES),$(%(mmake)%(flavour)_FILES))
2229 %(mmake)%(flavour)_CXX_NARCHFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_ARCHFILES),$(%(mmake)%(flavour)_CXXFILES))
2230 %(mmake)%(flavour)_OBJC_NARCHFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_ARCHFILES),$(%(mmake)%(flavour)_OBJCFILES))
2231 %(mmake)%(flavour)_NLIBARCHFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_LIBARCHFILES),$(%(mmake)%(flavour)_LIBFILES))
2232 %(mmake)%(flavour)_ARCHNLIBFILES := $(call %(mmake)%(flavour)_FILTERARCH,$(%(mmake)%(flavour)_LIBFILES),$(%(mmake)%(flavour)_LIBARCHFILES))
2234 %(mmake)%(flavour)_CPPFLAGS := $(strip %(cppflags) -I$(%(mmake)%(flavour)_OBJDIR)/include -include $(%(mmake)%(flavour)_DEFLIBDEFSINC))
2235 ifneq (%(includedir),)
2236 %(mmake)%(flavour)_CPPFLAGS += -I%(includedir)
2238 %(mmake)%(flavour)_LINKLIBCPPFLAGS := $(%(mmake)%(flavour)_CPPFLAGS)
2239 %(mmake)%(flavour)_CPPFLAGS += $(strip $($(%(mmake)%(flavour)_DEFNAME)_CPPFLAGS))
2240 %(mmake)%(flavour)_LINKLIBCPPFLAGS += $(strip $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBCPPFLAGS))
2241 %(mmake)%(flavour)_CFLAGS := $(strip %(cflags) $($(%(mmake)%(flavour)_DEFNAME)_CFLAGS))
2242 %(mmake)%(flavour)_LINKLIBCFLAGS := $(strip %(cflags) $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBCFLAGS))
2243 %(mmake)%(flavour)_CXXFLAGS := $(strip %(cxxflags) $($(%(mmake)%(flavour)_DEFNAME)_CXXFLAGS))
2244 ifeq (%(compiler),target)
2246 %(mmake)%(flavour)_LTOFLAGS ?= $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH))
2247 %(mmake)%(flavour)_CFLAGS := $(strip $(%(mmake)%(flavour)_LTOFLAGS) $(%(mmake)%(flavour)_CFLAGS))
2248 %(mmake)%(flavour)_LINKLIBCFLAGS := $(strip $(%(mmake)%(flavour)_LTOFLAGS) $(%(mmake)%(flavour)_LINKLIBCFLAGS))
2249 %(mmake)%(flavour)_CXXFLAGS := $(strip $(%(mmake)%(flavour)_LTOFLAGS) $(%(mmake)%(flavour)_CXXFLAGS))
2251 ifeq (%(funcinstr),yes)
2252 %(mmake)%(flavour)_SUBSTNULL :=
2253 %(mmake)%(flavour)_SUBSTSPACE := $(%(mmake)%(flavour)_SUBSTNULL) #
2254 %(mmake)%(flavour)_SUBSTCOMMA := ,
2255 %(mmake)%(flavour)_INSTRFUNCFLAGS ?= $(strip $(FUNCINSTR_FLAGS) -finstrument-functions-exclude-file-list=$(subst $(%(mmake)%(flavour)_SUBSTSPACE),$(%(mmake)%(flavour)_SUBSTCOMMA),$(strip $($(%(mmake)%(flavour)_DEFNAME)_STARTFILES))))
2256 %(mmake)%(flavour)_INSTRFUNCLIBS ?= $(FUNCINSTR_LIBS)
2257 %(mmake)%(flavour)_CFLAGS := $(strip $(%(mmake)%(flavour)_INSTRFUNCFLAGS) $(%(mmake)%(flavour)_CFLAGS))
2258 %(mmake)%(flavour)_CXXFLAGS := $(strip $(%(mmake)%(flavour)_INSTRFUNCFLAGS) $(%(mmake)%(flavour)_CXXFLAGS))
2259 %(mmake)%(flavour)_LIBS += $(%(mmake)%(flavour)_INSTRFUNCLIBS)
2262 %(mmake)%(flavour)_DFLAGS := $(strip $(%(mmake)%(flavour)_DFLAGS) $($(%(mmake)%(flavour)_DEFNAME)_DFLAGS))
2263 %(mmake)%(flavour)_LINKLIBDFLAGS := $(strip $(%(mmake)%(flavour)_DFLAGS) $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBDFLAGS))
2264 %(mmake)%(flavour)_DXXFLAGS := $(strip $(%(mmake)%(flavour)_DXXFLAGS) $($(%(mmake)%(flavour)_DEFNAME)_DXXFLAGS))
2266 ifeq (%(modtype),library)
2267 %(mmake)%(flavour)_LIBSUFFIX :=
2269 %(mmake)%(flavour)_LIBSUFFIX := .%(modtype)
2273 %(mmake)%(flavour)_LIBDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/$(AROS_DIR_LIB)
2275 %(mmake)%(flavour)_LIBDIR := %(libdir)
2278 ifeq (%(build_abi),M)
2279 %(mmake)%(flavour)_LINKLIBCFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$($(%(mmake)%(flavour)_DEFNAME)_LINKLIBFILES))
2280 %(mmake)%(flavour)_LINKLIBAFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$($(%(mmake)%(flavour)_DEFNAME)_LINKLIBAFILES))
2281 ifeq ($(strip $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBFILES) $($(%(mmake)%(flavour)_DEFNAME)_LINKLIBAFILES) %(linklibfiles) $(%(mmake)%(flavour)_ARCHNLIBFILES)),)
2282 %(mmake)%(flavour)_LINKLIB :=
2284 %(mmake)%(flavour)_LINKLIB := $(%(mmake)%(flavour)_LIBDIR)/lib%(modname)$(%(mmake)%(flavour)_LIBSUFFIX).a
2285 ifneq (%(modname),$(%(mmake)%(flavour)_LINKLIBNAME))
2286 %(mmake)%(flavour)_LINKLIB += $(%(mmake)%(flavour)_LIBDIR)/lib$(%(mmake)%(flavour)_LINKLIBNAME)$(%(mmake)%(flavour)_LIBSUFFIX).a
2289 %(mmake)%(flavour)_LINKLIBFILES := $(%(mmake)%(flavour)_LINKLIBCFILES) $(%(mmake)%(flavour)_LINKLIBAFILES)
2291 %(mmake)%(flavour)_RELLINKLIBCFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$($(%(mmake)%(flavour)_DEFNAME)_RELLINKLIBFILES))
2292 %(mmake)%(flavour)_RELLINKLIBAFILES := $(addprefix $(%(mmake)%(flavour)_OBJDIR)/linklib/,$($(%(mmake)%(flavour)_DEFNAME)_RELLINKLIBAFILES))
2293 ifeq ($(strip $($(%(mmake)%(flavour)_DEFNAME)_RELLINKLIBFILES) $($(%(mmake)%(flavour)_DEFNAME)_RELLINKLIBAFILES) %(linklibfiles) $(%(mmake)%(flavour)_ARCHNLIBFILES)),)
2294 %(mmake)%(flavour)_RELLINKLIB :=
2296 %(mmake)%(flavour)_RELLINKLIB := $(%(mmake)%(flavour)_LIBDIR)/lib$(%(mmake)%(flavour)_DEFNAME)_rel$(%(mmake)%(flavour)_LIBSUFFIX).a
2297 ifneq (%(modname),$(%(mmake)%(flavour)_LINKLIBNAME))
2298 %(mmake)%(flavour)_RELLINKLIB += $(%(mmake)%(flavour)_LIBDIR)/lib$(%(mmake)%(flavour)_LINKLIBNAME)_rel$(%(mmake)%(flavour)_LIBSUFFIX).a
2301 %(mmake)%(flavour)_RELLINKLIBFILES := $(%(mmake)%(flavour)_RELLINKLIBCFILES) $(%(mmake)%(flavour)_RELLINKLIBAFILES)
2304 %(mmake)%(flavour)_ENDOBJS := $(addsuffix .o,$(%(mmake)%(flavour)_ENDFILES))
2305 %(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)) \
2307 %(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)) \
2309 $(%(mmake)%(flavour)_LINKLIBFILES) $(%(mmake)%(flavour)_RELLINKLIBFILES) : | $(%(mmake)%(flavour)_OBJDIR)/linklib
2310 $(%(mmake)%(flavour)_LINKLIBOBJS) $(%(mmake)%(flavour)_RELLINKLIBOBJS) : | $(%(mmake)%(flavour)_OBJDIR)/linklib
2312 %(mmake)%(flavour)_CCFILES := $(%(mmake)%(flavour)_C_NARCHFILES)
2313 %(mmake)%(flavour)_TARGETCCFILES := $(strip $(%(mmake)%(flavour)_STARTFILES) $(%(mmake)%(flavour)_ENDFILES))
2314 %(mmake)%(flavour)_LINKLIBCCFILES := $(strip $(%(mmake)%(flavour)_NLIBARCHFILES) $(%(mmake)%(flavour)_LINKLIBCFILES) $(%(mmake)%(flavour)_RELLINKLIBCFILES))
2315 %(mmake)%(flavour)_LINKLIBCCGENFILES := $(strip $(%(mmake)%(flavour)_LINKLIBCFILES) $(%(mmake)%(flavour)_RELLINKLIBCFILES))
2317 %rule_compile_cxx_multi mmake=%(mmake)%(flavour) \
2318 basenames=$(%(mmake)%(flavour)_CXX_NARCHFILES) targetdir="$(%(mmake)%(flavour)_OBJDIR)" \
2319 cppflags=$(%(mmake)%(flavour)_CPPFLAGS) cxxflags=$(%(mmake)%(flavour)_CXXFLAGS) dxxflags=$(%(mmake)%(flavour)_DXXFLAGS) \
2320 compiler="%(compiler)"
2321 %rule_compile_objc_multi mmake=%(mmake)%(flavour) \
2322 basenames=$(%(mmake)%(flavour)_OBJC_NARCHFILES) targetdir=$(%(mmake)%(flavour)_OBJDIR) \
2323 cppflags=$(%(mmake)%(flavour)_CPPFLAGS) cflags=$(%(mmake)%(flavour)_CFLAGS) dflags=$(%(mmake)%(flavour)_DFLAGS) \
2324 compiler="%(compiler)"
2325 %rule_compile_multi mmake=%(mmake)%(flavour) \
2326 basenames=$(%(mmake)%(flavour)_CCFILES) targetdir="$(%(mmake)%(flavour)_OBJDIR)" \
2327 cppflags=$(%(mmake)%(flavour)_CPPFLAGS) cflags=$(%(mmake)%(flavour)_CFLAGS) dflags=$(%(mmake)%(flavour)_DFLAGS) \
2328 compiler="%(compiler)"
2329 %rule_compile_multi mmake=%(mmake)%(flavour) \
2330 basenames=$(%(mmake)%(flavour)_TARGETCCFILES) targetdir="$(%(mmake)%(flavour)_OBJDIR)" \
2331 cppflags="$(%(mmake)%(flavour)_CPPFLAGS) -D__AROS__" cflags=$(%(mmake)%(flavour)_CFLAGS) dflags=$(%(mmake)%(flavour)_DFLAGS) \
2332 compiler="%(compiler)"
2333 %rule_compile_multi mmake=%(mmake)%(flavour) \
2334 basenames=$(%(mmake)%(flavour)_NLIBARCHFILES) targetdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" \
2335 cppflags="$(%(mmake)%(flavour)_LINKLIBCPPFLAGS) -D__AROS__" cflags=$(%(mmake)%(flavour)_LINKLIBCFLAGS) dflags=$(%(mmake)%(flavour)_LINKLIBDFLAGS) \
2336 compiler="%(compiler)"
2337 %rule_compile_multi mmake=%(mmake)%(flavour) \
2338 basenames=$(%(mmake)%(flavour)_LINKLIBCCGENFILES) srcdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" targetdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" \
2339 cppflags="$(%(mmake)%(flavour)_LINKLIBCPPFLAGS) -D__AROS__" cflags=$(%(mmake)%(flavour)_LINKLIBCFLAGS) dflags=$(%(mmake)%(flavour)_LINKLIBDFLAGS) \
2340 compiler="%(compiler)"
2342 ifneq ($(%(mmake)%(flavour)_LINKLIBAFILES),)
2343 %rule_assemble_multi mmake=%(mmake)%(flavour) \
2344 cmd=$(%(mmake)%(flavour)_ASSEMBLER) basenames="$(%(mmake)%(flavour)_LINKLIBAFILES) $(%(mmake)%(flavour)_RELLINKLIBAFILES)" targetdir="$(%(mmake)%(flavour)_OBJDIR)/linklib" suffix=.S
2349 ifeq (%(modsuffix),)
2350 %(mmake)%(flavour)_SUFFIX := %(modtype)
2352 %(mmake)%(flavour)_SUFFIX := %(modsuffix)
2355 ifeq (%(build_library),M)
2356 # Handlers use dash instead of dot in their names
2357 ifeq ($(%(mmake)%(flavour)_SUFFIX),handler)
2358 %(mmake)%(flavour)_MODULE := %(prefix)/$(%(mmake)%(flavour)_MODDIR)/$(%(mmake)%(flavour)_DEFNAME)-$(%(mmake)%(flavour)_SUFFIX)
2360 %(mmake)%(flavour)_MODULE := %(prefix)/$(%(mmake)%(flavour)_MODDIR)/$(%(mmake)%(flavour)_DEFNAME).$(%(mmake)%(flavour)_SUFFIX)
2362 %(mmake)%(flavour)_KOBJ := $(KOBJSDIR)/$(%(mmake)%(flavour)_DEFNAME)_$(%(mmake)%(flavour)_SUFFIX).o
2364 %(mmake)%(flavour)_MODULE :=
2365 %(mmake)%(flavour)_KOBJ :=
2368 %(mmake)-quick : %(mmake)
2369 %(mmake) : $(%(mmake)%(flavour)_MODULE) $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_RELLINKLIB)
2370 ifeq (%(build_library),M)
2371 %(mmake)-kobj : $(%(mmake)%(flavour)_KOBJ) $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_RELLINKLIB)
2372 %(mmake)-kobj-quick : $(%(mmake)%(flavour)_KOBJ) $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_RELLINKLIB)
2374 ifeq (%(build_abi),M)
2375 %(mmake)-linklib : $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_RELLINKLIB)
2378 %(mmake)%(flavour)_OBJS := $(addsuffix .o,$(%(mmake)%(flavour)_STARTFILES)) $(%(mmake)%(flavour)_ARCHOBJS) \
2379 $(addprefix $(%(mmake)%(flavour)_OBJDIR)/,$(notdir $(%(mmake)%(flavour)_C_NARCHFILES:=.o) $(%(mmake)%(flavour)_CXXFILES:=.o)))
2381 ifeq (%(nostartup),yes)
2382 # Handlers always have entry point
2383 ifneq (%(modtype),handler)
2384 %(mmake)%(flavour)_STARTOBJS := $(addsuffix .o,$(addprefix $(GENDIR)/,$(RESIDENT_BEGIN)))
2388 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
2389 # This breaks con-handler build. Here we work around this
2390 ifeq (%(modname),con)
2391 %(mmake)%(flavour)_ERR := $(notdir $(%(mmake)%(flavour)_MODULE)).err
2393 %(mmake)%(flavour)_ERR := %(modname).err
2396 ifeq (%(build_library),M)
2397 # The module is linked from all the compiled .o files
2398 %rule_linkmodule module=$(%(mmake)%(flavour)_MODULE) objs="$(%(mmake)%(flavour)_STARTOBJS) $(%(mmake)%(flavour)_OBJS) $(USER_OBJS)" \
2399 endobj=$(%(mmake)%(flavour)_ENDOBJS) err=$(%(mmake)%(flavour)_ERR) objdir="$(%(mmake)%(flavour)_OBJDIR)" \
2400 cmd=$(%(mmake)%(flavour)_LINK) ldflags="$(LDFLAGS) $($(%(mmake)%(flavour)_DEFNAME)_LDFLAGS)" \
2401 uselibs="$(%(mmake)%(flavour)_LIBS) $($(%(mmake)%(flavour)_DEFNAME)_LIBS)" usehostlibs="%(usehostlibs)"
2404 ifeq (%(build_abi),M)
2406 %(mmake)%(flavour)_LC_LINKLIBNAME := $(shell echo $(%(mmake)%(flavour)_LINKLIBNAME) | tr A-Z a-z)
2407 %(mmake)%(flavour)_LC_MODNAME := $(shell echo %(modname) | tr A-Z a-z)
2408 ifneq ($(%(mmake)%(flavour)_LINKLIB),)
2409 %rule_link_linklib mmake=%(mmake) libname="$(%(mmake)%(flavour)_LINKLIBNAME)$(%(mmake)%(flavour)_LIBSUFFIX)" objs=$(%(mmake)%(flavour)_LINKLIBOBJS) libdir="$(%(mmake)%(flavour)_LIBDIR)"
2410 ifneq ($(%(mmake)%(flavour)_LC_MODNAME),$(%(mmake)%(flavour)_LC_LINKLIBNAME))
2411 %rule_link_linklib mmake=%(mmake) libname="%(modname)$(%(mmake)%(flavour)_LIBSUFFIX)" objs=$(%(mmake)%(flavour)_LINKLIBOBJS) libdir="$(%(mmake)%(flavour)_LIBDIR)"
2414 %rule_makedirs dirs="$(%(mmake)%(flavour)_LIBDIR)" setuptarget=$(%(mmake)%(flavour)_LINKLIB)
2417 ifneq ($(%(mmake)%(flavour)_RELLINKLIB),)
2418 %rule_link_linklib mmake=%(mmake) libname="$(%(mmake)%(flavour)_LINKLIBNAME)_rel$(%(mmake)%(flavour)_LIBSUFFIX)" objs=$(%(mmake)%(flavour)_RELLINKLIBOBJS) libdir="$(%(mmake)%(flavour)_LIBDIR)"
2419 ifneq ($(%(mmake)%(flavour)_LC_MODNAME),$(%(mmake)%(flavour)_LC_LINKLIBNAME))
2420 %rule_link_linklib mmake=%(mmake) libname="$(%(mmake)%(flavour)_DEFNAME)_rel$(%(mmake)%(flavour)_LIBSUFFIX)" objs=$(%(mmake)%(flavour)_RELLINKLIBOBJS) libdir="$(%(mmake)%(flavour)_LIBDIR)"
2423 %rule_makedirs dirs="$(%(mmake)%(flavour)_LIBDIR)" setuptarget=$(%(mmake)%(flavour)_RELLINKLIB)
2427 ifeq (%(build_library),M)
2428 # Link kernel object file
2429 %(mmake)%(flavour)_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
2431 # Make these symbols local
2432 %(mmake)%(flavour)_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
2433 UtilityBase ExpansionBase KeymapBase KernelBase
2435 %(mmake)%(flavour)_SYMBOLS := $(%(mmake)%(flavour)_KBASE)
2437 %(mmake)%(flavour)_KLIB := hiddstubs amiga arossupport autoinit libinit
2438 %(mmake)%(flavour)_KOBJ_LIBS := $(filter-out $(%(mmake)%(flavour)_KLIB),$(%(mmake)%(flavour)_LIBS)) $(%(mmake)%(flavour)_KAUTOLIB)
2439 $(%(mmake)%(flavour)_KOBJ) : LINKLIBS:=$(%(mmake)%(flavour)_KOBJ_LIBS) $($(%(mmake)%(flavour)_DEFNAME)_LIBS)
2440 $(%(mmake)%(flavour)_KOBJ) : FILTBASES:=$(addprefix -L ,$(%(mmake)%(flavour)_SYMBOLS))
2441 $(%(mmake)%(flavour)_KOBJ) : USER_LDFLAGS:=$(USER_LDFLAGS)
2442 $(%(mmake)%(flavour)_KOBJ) : $(%(mmake)%(flavour)_OBJS) $(USER_OBJS) $(%(mmake)%(flavour)_ENDOBJS)
2443 $(Q)$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
2444 $(Q)$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
2445 $(Q)$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
2448 ## Dependency fine-tuning
2450 %(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)))
2452 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick" deps=$(%(mmake)%(flavour)_DEPS)
2454 $(%(mmake)%(flavour)_OBJS) $(%(mmake)%(flavour)_DEPS) : | $(%(mmake)%(flavour)_OBJDIR)/linklib
2455 %rule_makedirs dirs="$(%(mmake)%(flavour)_OBJDIR) %(prefix)/$(%(mmake)%(flavour)_MODDIR) $(KOBJSDIR)" setuptarget="$(%(mmake)%(flavour)_OBJS) $(%(mmake)%(flavour)_DEPS) $(%(mmake)%(flavour)_MODULE) $(%(mmake)%(flavour)_KOBJ)"
2457 # Some include files need to be generated before the .c can be parsed.
2458 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick),) # Only for this target these deps are wanted
2460 %(mmake)%(flavour)_DFILE_DEPS := $(%(mmake)%(flavour)_LIBDEFSINC) $(%(mmake)%(flavour)_DEFLIBDEFSINC) \
2461 $(addprefix $(%(mmake)%(flavour)_INCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES))
2462 $(%(mmake)%(flavour)_DEPS) : $(%(mmake)%(flavour)_DFILE_DEPS)
2465 %(mmake)%(flavour)_TOCLEAN := $(%(mmake)%(flavour)_OBJS) $(%(mmake)%(flavour)_DEPS) \
2466 $(%(mmake)%(flavour)_MODULE) $(%(mmake)%(flavour)_LINKLIB) $(%(mmake)%(flavour)_KOBJ) \
2467 $(%(mmake)%(flavour)_OBJDIR)/Makefile.%(modname)%(modtype) \
2468 $(addprefix $(%(mmake)%(flavour)_OBJDIR)/include/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2469 $(addprefix $(GENINCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2470 $(addprefix $(%(mmake)%(flavour)_INCDIR)/,$($(%(mmake)%(flavour)_DEFNAME)_INCLUDES)) \
2471 $(%(mmake)_OBJDIR)/%(modname)_geninc $(%(mmake)_OBJDIR)/%(modname)_incs \
2472 $(addsuffix .c,$(%(mmake)%(flavour)_LINKLIBFILES)) $(%(mmake)%(flavour)_LINKLIBOBJS) $(%(mmake)%(flavour)_LIBDEFSINC) \
2473 $(%(mmake)%(flavour)_DEFLIBDEFSINC) $(addsuffix .c,$(%(mmake)%(flavour)_STARTFILES) $(%(mmake)%(flavour)_ENDFILES)) \
2474 $(%(mmake)%(flavour)_ENDOBJS)
2475 %(mmake)-clean : FILES := $(%(mmake)%(flavour)_TOCLEAN)
2477 $(Q)$(ECHO) "Cleaning up for module %(modname)"
2480 endif # $(TARGET) in $(%(mmake)%(flavour)_ALLTARGETS)
2482 #------------------------------------------------------------------------------
2484 #------------------------------------------------------------------------------
2485 # Build a module - ABI and library
2486 # Explanation of this macro is done in the developer's manual
2487 %define build_module mmake=/A modname=/A modtype=/A modsuffix= version= flavour= conffile= confoverride= \
2488 files="$(basename $(call WILDCARD, *.c))" \
2490 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2491 linklibfiles= linklibobjs= cflags=$(CFLAGS) cppflags=$(CPPFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= \
2492 objdir= moduledir= prefix=$(AROSDIR) \
2493 linklibname= uselibs= usehostlibs= \
2494 compiler=target funcinstr=$(TARGET_FUNCINSTR) lto=$(TARGET_LTO) nostartup=yes archspecific=no \
2495 include_set=includes-all includedir= libdir=
2497 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2498 modsuffix="%(modsuffix)" version="%(version)" flavour="%(flavour)" conffile="%(conffile)" confoverride="%(confoverride)" \
2499 files="%(files)" objcfiles="%(objcfiles)" cxxfiles="%(cxxfiles)" \
2500 linklibname="%(linklibname)" \
2501 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2502 cflags="%(cflags)" cppflags="%(cppflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2503 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2504 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" funcinstr=%(funcinstr) lto=%(lto) \
2505 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2506 include_set=%(include_set) includedir="%(includedir)" libdir="%(libdir)" \
2507 build_abi=M build_library=M
2510 #------------------------------------------------------------------------------
2513 #------------------------------------------------------------------------------
2514 # Build a module skeleton ABI
2515 # This is a stripped-down version of build_module, it only creates include
2516 # files and the linklibs.
2517 # This is used when for plugins or classes with the same API, but no actual
2518 # implementation here.
2519 %define build_module_abi mmake=/A modname=/A modtype=/A modsuffix= version= flavour= conffile= confoverride= \
2520 linklibfiles= linklibobjs= cflags=$(CFLAGS) cppflags=$(CPPFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= \
2521 objdir= moduledir= prefix=$(AROSDIR) \
2522 linklibname= uselibs= usehostlibs= \
2523 compiler=target nostartup=yes archspecific=no \
2524 include_set=includes-all includedir= libdir=
2526 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2527 modsuffix="%(modsuffix)" version="%(version)" flavour="%(flavour)" conffile="%(conffile)" confoverride="%(confoverride)" \
2528 linklibname="%(linklibname)" \
2529 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2530 cflags="%(cflags)" cppflags="%(cppflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2531 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2532 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" lto=%(lto) \
2533 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2534 include_set=%(include_set) includedir="%(includedir)" libdir="%(libdir)" \
2535 build_abi=M build_library=
2538 #------------------------------------------------------------------------------
2540 #------------------------------------------------------------------------------
2541 # Build a module library - no includes nor linklibs
2542 # Explanation of this macro is done in the developer's manual
2543 %define build_module_library mmake=/A modname=/A modtype=/A modsuffix= version= flavour= \
2544 conffile= confoverride= \
2545 files="$(basename $(call WILDCARD, *.c))" \
2547 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2548 cflags=$(CFLAGS) cppflags=$(CPPFLAGS) dflags= cxxflags="$(CXXFLAGS)" dxxflags= \
2549 objdir= moduledir= prefix=$(AROSDIR) \
2550 uselibs= usehostlibs= \
2551 compiler=target lto=$(TARGET_LTO) nostartup=yes archspecific=no \
2552 include_set=includes-all includedir= libdir=
2554 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2555 modsuffix="%(modsuffix)" version="%(version)" flavour="%(flavour)" \
2556 conffile="%(conffile)" confoverride="%(confoverride)" \
2557 files="%(files)" objcfiles="%(objcfiles)" cxxfiles="%(cxxfiles)" \
2558 cflags="%(cflags)" cppflags="%(cppflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2559 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2560 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" lto=%(lto) \
2561 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2562 include_set=%(include_set) includedir="%(includedir)" libdir="%(libdir)" \
2563 build_abi= build_library=M
2566 #------------------------------------------------------------------------------
2570 #------------------------------------------------------------------------------
2572 # - mmake is the mmaketarget
2573 # - libname is the baselibname e.g. lib%(libname).a will be created
2574 # - files are the C source files to include in the lib. The list of files
2575 # has to be given without the .c suffix
2576 # - cxxfiles are C++ source files without suffix.
2577 # NB: files will be matched in the order .cpp > .cxx > .cc
2578 # - asmfiles are the asm files to include in the lib. The list of files has to
2579 # be given without the .s suffix
2580 # - objs additional object to link into the linklib. The objects have to be
2581 # given with full absolute path and the .o suffix.
2582 # - objdir is where the .o are generated. Defaults to $(GENDIR)/$(CURDIR)
2583 # - libdir is the directory where the linklib will be placed (default $(AROS_LIB))
2584 # - cflags are the flags to compile the source (default $(CFLAGS))
2585 # - dflags are the flags used during makedepend (default equal to cflags)
2586 # - aflags are the flags used during assembling (default $(AFLAGS))
2587 %define build_linklib mmake=/A libname=/A files= objcfiles= cxxfiles= \
2588 asmfiles= objs= objdir=$(GENDIR)/$(CURDIR) libdir=$(AROS_LIB) \
2589 includedir= srcdir= \
2590 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= \
2591 aflags=$(AFLAGS) compiler=target lto=$(TARGET_LTO) usetree=no
2593 # assign and generate the local variables used in this macro
2594 %(mmake)_LIBNAME := %(libname)
2595 %(mmake)_LINKLIB := %(libdir)/lib%(libname).a
2597 %(mmake)_FILES ?= %(files)
2598 %(mmake)_ASMFILES := %(asmfiles)
2599 %(mmake)_OBJCFILES := %(objcfiles)
2600 %(mmake)_CXXFILES := %(cxxfiles)
2602 %(mmake)_OBJDIR ?= %(objdir)
2603 %(mmake)_ARCHOBJS := $(wildcard $(%(mmake)_OBJDIR)/arch/*.o)
2604 ifeq (%(usetree),no)
2605 %(mmake)_ARCHFILES := $(basename $(notdir $(%(mmake)_ARCHOBJS)))
2607 %(mmake)_ARCHFILES := $(basename $(patsubst $(%(mmake)_OBJDIR)/%,%,$(%(mmake)_ARCHOBJS)))
2609 %(mmake)_C_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_FILES))
2610 %(mmake)_C_FILES ?= $(%(mmake)_C_NARCHFILES)
2611 %(mmake)_CXX_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_CXXFILES))
2612 %(mmake)_CXX_FILES ?= $(%(mmake)_CXX_NARCHFILES)
2613 %(mmake)_OBJC_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_OBJCFILES))
2614 %(mmake)_OBJC_FILES ?= $(%(mmake)_OBJC_NARCHFILES)
2616 ifeq (%(usetree),no)
2617 %(mmake)_OBJ_FILES ?= $(addprefix $(%(mmake)_OBJDIR)/,$(notdir $(%(mmake)_C_NARCHFILES:=.o) $(%(mmake)_CXX_NARCHFILES:=.o) $(%(mmake)_ASMFILES:=.o) $(%(mmake)_OBJC_NARCHFILES:=.o)))
2619 %(mmake)_OBJ_FILES ?= $(addprefix $(%(mmake)_OBJDIR)/,$(%(mmake)_C_NARCHFILES:=.o) $(%(mmake)_CXX_NARCHFILES:=.o) $(%(mmake)_ASMFILES:=.o) $(%(mmake)_OBJC_NARCHFILES:=.o))
2621 %(mmake)_OBJS ?= $(%(mmake)_ARCHOBJS) $(%(mmake)_OBJ_FILES) %(objs)
2622 %(mmake)_DEPS := $(patsubst %.o,%.d,$(%(mmake)_OBJS))
2624 %(mmake)_CPPFLAGS := %(cppflags)
2625 ifneq (%(includedir),)
2626 %(mmake)_CPPFLAGS += -I%(includedir)
2628 %(mmake)_CFLAGS := %(cflags)
2629 %(mmake)_CXXFLAGS := %(cxxflags)
2631 ifeq (%(compiler),target)
2632 %(mmake)_CFLAGS := $(strip $(LTO_CFLAGS) $(%(mmake)_CFLAGS))
2633 %(mmake)_CXXFLAGS := $(strip $(LTO_CFLAGS) $(%(mmake)_CXXFLAGS))
2636 %(mmake)_AFLAGS := %(aflags)
2637 %(mmake)_DFLAGS := %(dflags)
2639 %(mmake)_DFLAGS := %(dflags)
2641 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
2643 %(mmake)_DXXFLAGS := %(dxxflags)
2644 ifneq (%(dxxflags),)
2645 %(mmake)_DXXFLAGS := %(dxxflags)
2647 %(mmake)_DXXFLAGS := $(%(mmake)_CXXFLAGS)
2650 .PHONY : %(mmake) %(mmake)-clean %(mmake)-quick
2653 %(mmake)-quick : %(mmake)
2655 #MM %(mmake) : includes-generate-deps
2656 %(mmake) : $(%(mmake)_LINKLIB)
2658 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
2660 %rule_compile_cxx_multi mmake=%(mmake) \
2661 basenames=$(%(mmake)_CXX_FILES) targetdir="$(%(mmake)_OBJDIR)" \
2662 cppflags=$(%(mmake)_CPPFLAGS) cxxflags=$(%(mmake)_CXXFLAGS) dxxflags=$(%(mmake)_DXXFLAGS) \
2663 compiler="%(compiler)" srcdir=%(srcdir)
2664 %rule_compile_objc_multi mmake=%(mmake) \
2665 basenames=$(%(mmake)_OBJC_FILES) targetdir=$(%(mmake)_OBJDIR) \
2666 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
2667 compiler="%(compiler)" srcdir=%(srcdir)
2668 %rule_compile_multi mmake=%(mmake) \
2669 basenames=$(%(mmake)_C_FILES) targetdir="$(%(mmake)_OBJDIR)" \
2670 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
2671 compiler="%(compiler)" srcdir=%(srcdir) usetree=%(usetree)
2672 %rule_assemble basename=% targetdir="$(%(mmake)_OBJDIR)" \
2673 aflags=$(%(mmake)_AFLAGS)
2675 %rule_link_linklib mmake=%(mmake) libname="%(libname)" objs=$(%(mmake)_OBJS) libdir="%(libdir)" linker="%(compiler)"
2678 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(%(mmake)_DEPS)
2681 %rule_makedirs dirs="$(%(mmake)_OBJDIR) %(libdir)" setuptarget="$(%(mmake)_OBJS) $(%(mmake)_DEPS) $(%(mmake)_LINKLIB)"
2683 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_LINKLIB) $(%(mmake)_DEPS)
2686 $(Q)$(ECHO) "Cleaning up for metatarget %(mmake)"
2690 #------------------------------------------------------------------------------
2693 #------------------------------------------------------------------------------
2695 # - mmake is the mmaketarget
2696 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
2697 # - description is the catalog description file (.cd), without the .cd suffix (default *.cd)
2698 # - subdir is the destination subdirectory of the catalogs
2699 # - name is the name of the destination catalog, without the .catalog suffix
2700 # - source is the path to the generated source code file
2701 # - dir is the base destination directory (default $(AROS_CATALOGS))
2702 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
2703 # - srcdir is the directory in which the *.cd and *.ct files are searched
2705 %define build_catalogs mmake=/A name=/A subdir=/A \
2706 catalogs= source="../strings.h" description= dir=$(AROS_CATALOGS) \
2707 sourcedescription=$(TOOLDIR)/C_h_aros srcdir=$(SRCDIR)/$(CURDIR)
2709 ifeq (%(description),)
2710 %(mmake)_DESC := $(basename $(wildcard %(srcdir)/*.cd))
2712 %(mmake)_DESC := %(description)
2715 %(mmake)_SRC := $(shell echo %(sourcedescription) | sed 's/^\(.\):\//\/\1\//')
2718 %(mmake)_LNGS := $(basename $(notdir $(call WILDCARD, %(srcdir)/*.ct)))
2720 %(mmake)_LNGS := %(catalogs)
2723 %(mmake)_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, $(%(mmake)_LNGS)))
2724 %(mmake)_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, $(%(mmake)_LNGS))) $(dir %(source))
2727 %(mmake) : $(%(mmake)_OBJS) %(source)
2729 %rule_makedirs dirs="$(%(mmake)_DIRS)" setuptarget=$(%(mmake)_OBJS)
2731 %(dir)/%/%(subdir)/%(name).catalog : %(srcdir)/%.ct $(%(mmake)_DESC).cd
2732 $(Q)$(ECHO) "Creating %(name) catalog for language $*."
2733 $(Q)$(FLEXCAT) $(%(mmake)_DESC).cd $< CATALOG="%(dir)/$*/%(subdir)/%(name).catalog" || [ $$? -lt 10 ]
2736 %(source) : %(mmake)_DESC := $(%(mmake)_DESC)
2737 %(source) : %(mmake)_SRC := $(%(mmake)_SRC)
2738 %(source) : $(%(mmake)_DESC).cd $(%(mmake)_SRC).sd | $(dir %(source))
2739 $(Q)$(ECHO) "Creating %(name) catalog source file $@"
2740 $(Q)$(FLEXCAT) $(%(mmake)_DESC).cd $@=$(%(mmake)_SRC).sd
2743 %(mmake)-clean : FILES := $(%(mmake)_OBJS) %(source)
2746 $(Q)$(ECHO) "Cleaning up for metatarget %(mmake)"
2749 .PHONY: %(mmake) %(mmake)-clean
2752 #-----------------------------------------------------------------------------
2755 #-----------------------------------------------------------------------------
2757 # - mmake is the mmaketarget
2758 # - icons is a list of icon base names (i.e. without the .info suffix)
2759 # - dir is the destination directory
2760 # - srcdir is where *.png and *.info.src are sought
2761 #-----------------------------------------------------------------------------
2763 %define build_icons mmake=/A icons=/A dir=/A srcdir=$(SRCDIR)/$(CURDIR) image=
2765 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
2768 %(mmake) : $(BD_OBJS)
2772 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%.png
2773 $(Q)$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2774 $(Q)$(ILBMTOICON) $+ $@
2778 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%(image)
2779 $(Q)$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2780 $(Q)$(ILBMTOICON) $+ $@
2784 %rule_makedirs dirs="%(dir)" setuptarget=$(BD_OBJS)
2786 %(mmake)-clean : FILES := $(BD_OBJS)
2791 .PHONY: %(mmake) %(mmake)-clean
2794 #-----------------------------------------------------------------------------
2797 #------------------------------------------------------------------------------
2798 # Compile files for an arch-specific replacement of code for a module
2799 # - files: the basenames of the C files to compile.
2800 # - asmfiles: the basenames of the asm files to assemble.
2801 # - mainmmake: the mmake of the module in the main directory to compile these
2802 # arch specific files for.
2803 # - maindir: the object directory for the main module
2804 # - arch: the arch for which to compile these files. It can have the form
2805 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
2806 # - cflags (default $(CFLAGS)): the C flags to use for compilation
2807 # - dflags: the flags used during creation of dependency file. If not specified
2808 # the same value as cflags will be used
2809 # - aflags: the flags used during assembling
2810 # - compiler: (host, kernel or target) specifies which compiler to use. By default
2811 # the target compiler is used
2812 # - modname: arch_specific builds of modules (built using build_module) MUST
2813 # specify the name here matching the original module. this insures multiple modules
2814 # built from the same makefile will not pollute each other.
2815 %define build_archspecific files= cxxfiles= asmfiles= linklibfiles= linklibobjs= mainmmake=/A maindir=/A arch=/A \
2816 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target objdir= modname=
2818 ifeq (%(files) %(linklibfiles) %(linklibobjs) %(asmfiles),)
2819 $(error no files or asmfiles given)
2822 ifneq (%(cxxfiles),)
2823 $(error cxx support is TODO)
2826 %buildid targets="%(mainmmake)-%(arch)"
2828 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2829 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2830 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2831 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2832 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2833 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2834 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2835 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2836 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2837 #MM- %(mainmmake)-kobj-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2838 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2839 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2840 #MM- %(mainmmake)-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2841 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2842 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2844 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
2847 BD_OBJROOT$(BDID) := %(objdir)
2850 BD_OBJROOT$(BDID) := $(GENDIR)/%(maindir)/%(modname)
2852 BD_OBJROOT$(BDID) := $(GENDIR)/%(maindir)
2855 BD_OBJDIR$(BDID) := $(BD_OBJROOT$(BDID))/arch
2856 BD_LIBOBJDIR$(BDID) := $(BD_OBJROOT$(BDID))/linklib/arch
2857 BD_FILEOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files)))) $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(cxxfiles))))
2858 BD_LINKLIBOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibfiles))))
2859 BD_LINKLIBARCHOBJS$(BDID) := $(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibobjs)))
2860 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
2861 BD_OBJS$(BDID) := $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) $(BD_ASMOBJS$(BDID))
2862 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files)))) $(addsuffix .d,$(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibfiles))))
2865 BD_DEFLIBDEFSINC$(BDID) := -include $(BD_OBJROOT$(BDID))/include/%(modname)_deflibdefs.h
2868 ifeq ($(TARGET),%(mainmmake)-%(arch)-quick)
2869 BD_TARGET := %(mainmmake)-%(arch)-quick
2871 BD_TARGET := %(mainmmake)-%(arch)
2875 ifeq ($(TARGET),$(BD_TARGET))
2876 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
2877 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(files)))
2878 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(linklibfiles)))
2879 vpath %.s $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2880 vpath %.S $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2883 %rule_makedirs dirs="$(BD_OBJDIR$(BDID)) $(BD_LIBOBJDIR$(BDID))" setuptarget="$(BD_OBJS$(BDID))"
2886 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
2889 %(mainmmake)-%(arch)-quick :: $(BD_OBJS$(BDID))
2891 ifeq ($(findstring %(compiler),host kernel target),)
2892 $(error unknown compiler %(compiler))
2895 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=$(strip %(cppflags) -I$(BD_OBJROOT$(BDID)) $(BD_DEFLIBDEFSINC$(BDID)))
2897 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=%(cppflags)
2899 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
2900 ifeq (%(compiler),target)
2901 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
2902 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=$(TMP_CPPFLAGS)
2903 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=$(strip $(TMP_CFLAGS) $(SAFETY_CFLAGS))
2904 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
2905 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
2907 ifeq (%(compiler),host)
2908 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(HOST_CC)
2909 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
2910 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
2912 ifeq (%(compiler),kernel)
2913 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
2914 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=$(strip $(KERNEL_CPPFLAGS) $(TMP_CPPFLAGS))
2915 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=$(strip $(TARGET_ISA_CFLAGS) $(KERNEL_CFLAGS) $(TMP_CFLAGS))
2916 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
2917 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
2920 ifeq ($(TARGET),$(BD_TARGET))
2921 $(BD_LIBOBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2922 %compile_q cmd=$(TMP_CMD) opt="$(strip $(TMP_CFLAGS) $(TMP_CPPFLAGS))" iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2923 $(BD_OBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2924 %compile_q cmd=$(TMP_CMD) opt="$(strip $(TMP_CFLAGS) $(TMP_CPPFLAGS))" iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2928 $(BD_DEPS$(BDID)) : TMP_CPPFLAGS:=$(strip %(cppflags) $(BD_DEFLIBDEFSINC$(BDID)))
2929 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags)
2931 $(BD_DEPS$(BDID)) : TMP_CPPFLAGS:=%(cppflags)
2932 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
2934 ifeq ($(TARGET),$(BD_TARGET))
2935 $(BD_LIBOBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2936 %mkdepend_q cc=$(TMP_CMD) flags="$(strip $(TMP_DFLAGS) $(TMP_CPPFLAGS))"
2938 $(BD_OBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2939 %mkdepend_q cc=$(TMP_CMD) flags="$(strip $(TMP_DFLAGS) $(TMP_CPPFLAGS))"
2942 $(BD_ASMOBJS$(BDID)) : CPPFLAGS:=%(cppflags)
2943 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
2945 ifeq ($(TARGET),$(BD_TARGET))
2946 $(BD_OBJDIR$(BDID))/%.o : %.s
2948 $(BD_OBJDIR$(BDID))/%.o : %.S
2952 %include_deps depstargets=$(BD_TARGET) deps=$(BD_DEPS$(BDID))
2954 #------------------------------------------------------------------------------
2957 #------------------------------------------------------------------------------
2958 # generate asm files from c files (for debugging purposes)
2961 $(Q)$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
2962 $(Q)$(TARGET_CC) $(TARGET_SYSROOT) -S $(CFLAGS) $(CPPFLAGS) $< -c -o $@
2964 #------------------------------------------------------------------------------
2967 #------------------------------------------------------------------------------
2968 # Copy files from one directory to another.
2970 %define copy_files_q mmake=/A files=$(FILES) src=. dst=/A
2972 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
2974 %rule_makedirs dirs="%(dst)"
2980 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC))/, $(file)) $(addprefix %(dst)/, $(file))))
2983 #------------------------------------------------------------------------------
2986 #------------------------------------------------------------------------------
2987 # Copy a directory recursively to another place, preserving the original
2988 # hierarchical structure
2990 # src: the source directory whose content will be copied.
2991 # dst: the directories where to copy src's content. If not existing, they will be made.
2992 # excludefiles: files which must not be copied. Path must be relative to src.
2994 %define copy_dir_recursive mmake=/A src=. dst=/A excludefiles=
3000 $(Q)cd $(SRCDIR)/$(CURDIR) && $(CPYDIRREC) -s %(src) -d %(dst) -e %(excludefiles)
3003 #------------------------------------------------------------------------------
3006 #------------------------------------------------------------------------------
3007 # Copy include files into the includes directories. There are currently
3008 # two include directories. One for building AROS $(AROS_INCLUDES) and one
3009 # for building tools that need to run on the host system $(GENINCDIR). The
3010 # $(GENINCDIR) path must not contain any references to the C runtime
3011 # library header files.
3013 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
3014 dir= compiler=target includedir=$(AROS_INCLUDES)
3016 ifeq ($(findstring %(compiler),host kernel target),)
3017 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
3022 $(eval TMP_DIRREMAIN := $$$(TMP_DIR))
3023 TMP_DIRFIRST := $(subst $(TMP_DIRREMAIN),,$(TMP_DIR))
3024 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),$(dir %(includes)))
3025 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,$(notdir %(includes)))
3026 ifeq ($(TMP_DIRFIRST),/)
3027 BD_INC_PATH := %(dir)/
3029 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
3032 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
3033 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
3036 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
3039 ifeq (%(compiler),target)
3042 BD_INCL_FILES2 := $(subst %(dir),%(includedir)/%(path),$(dir %(includes)))
3043 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,$(notdir %(includes)))
3045 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,%(includes))
3048 BD_INCL_FILES += $(BD_INCL_FILES2)
3050 $(BD_INCL_FILES2) : %(includedir)/%(path)/% : $(BD_INC_PATH)%
3055 %(mmake) : $(BD_INCL_FILES)
3059 %rule_makedirs dirs="$(dir $(BD_INCL_FILES))" setuptarget=$(BD_INCL_FILES)
3061 #------------------------------------------------------------------------------
3064 #------------------------------------------------------------------------------
3065 %define make_hidd_stubs hidd=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
3066 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
3067 STUBS_MEM := $(addsuffix .o,$(STUBS))
3068 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
3069 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
3070 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
3072 #MM- linklibs : hidd-%(hidd)-stubs
3073 #MM- %(parenttarget): hidd-%(hidd)-stubs
3074 #MM hidd-%(hidd)-stubs : includes includes-copy
3075 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
3077 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
3080 $(STUBS_OBJ) : $(STUBS_SRC)
3081 %compile_q cmd="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" opt="$(strip %(cflags) %(cppflags))" iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
3083 $(STUBS_DEP) : $(STUBS_SRC)
3084 %mkdepend_q flags="$(strip %(dflags) %(cppflags))"
3087 %mkdirs_q $(OBJDIR) $(AROS_LIB)
3091 -@$(RM) $(HIDD_LIB) $(OBJDIR)
3093 DEPS := $(DEPS) $(STUBS_DEP)
3096 #------------------------------------------------------------------------------
3099 #------------------------------------------------------------------------------
3100 # Build an imported source tree which uses the configure script from the
3101 # autoconf package. This rule will try to "integrate" the produced files as
3102 # much as possible in the AROS build, for example by putting libraries in the
3103 # standard library directory, includes in the standard include directory, and
3104 # so on. You can however override this behaviour.
3106 # As a special "bonus" for you, the PROGDIR environment variable is defined to
3107 # be %(bindir) (or its deduced value) when running "make install", and
3108 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
3109 # configure script some more parameters whose value depends upon the PROGDIR
3110 # env var, so that the program gets all its stuff installed in the proper place
3111 # when building it, but when running it from inside AROS it can also find that
3112 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
3113 # the configuration parameters set when running ./configure
3115 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
3116 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
3117 # to the name which has to follow it.
3121 # - mmake = the meta make target.
3122 # - package = name of the package to be built.
3123 # - srcdir = the location of the unpacked source code. Defaults
3124 # to $(SRCDIR)/$(CURDIR).
3125 # - prefix = the target directory. Must be an absolute path of the
3126 # host system. Defaults to $(AROS_CONTRIB).
3127 # - aros_prefix = set a path which is valid within the AROS filesystem.
3128 # Defaults to the value of the prefix option.
3129 # - extraoptions = additional options for the configure script.
3130 # - usecppflags = enable the use of cpp flags. some external configure
3131 # scripts will not set their own cppflags if it is already
3132 # set, so this allows them to be disabled (unless you can provide
3133 # all the options they would need)
3134 # - extracppflags = additional preprocessor flags.
3135 # - usecflags = same meaning as the one for the %build_with_configure macro.
3136 # - extracflags = additional flags to use with the C compiler.
3137 # - usecxxflags = same meaning as the one for the %build_with_configure macro.
3138 # - extracxxflags = additional flags to use with the C++ compiler.
3139 # - nix_dir_layout = if yes the binary will be stored in a bin subdirectory.
3140 # Defaults to the value of the nix argument.
3141 # - nix = enable u*nix path handling, i.e. a path like
3142 # /progdir//./file will be translated to
3143 # progdir:file during run-time. Defaults to no.
3144 # - compiler = target, host or kernel. Defaults to target.
3145 # - install_target = the command used for installing. Defaults to install. Leave
3146 # it empty if you want to suppress installing.
3147 # - preconfigure = a metatarget which is executed before configure is called.
3148 # - postconfigure = a metatarget which is executed after configure is called.
3149 # - postinstall = a metatarget which is executed after installing.
3150 # - install_env = set additional options for installing.
3151 # - use_build_env = if yes the configuration environment is used for
3152 # installing, too. Defaults to no.
3154 # The arguments aros_prefix, nix and nix_dir_layout are related. The logic is
3158 # --prefix = $(aros_prefix)
3159 # progdir = $(aros_prefix)/bin
3162 # --prefix = /PROGDIR
3163 # --bindir = /PROGDIR
3164 # --sbindir = /PROGDIR
3166 # --includedir = /INCLUDE
3167 # --oldincludedir = /INCLUDE
3169 # --prefix = $(aros_prefix)
3172 # progdir = $(aros_prefix)
3175 # bindir = $(prefix)
3176 # sbindir = $(prefix)
3177 # libdir = $(AROS_LIB)
3178 # includedir = $(AROS_INCLUDES)
3179 # oldincludedir = $(AROS_INCLUDES)
3183 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) \
3184 prefix= gendir= basedir=$(CURDIR) extraoptions= \
3185 usecppflags=yes extracppflags= \
3186 usecflags=yes extracflags="$(OPTIMIZATION_CFLAGS)" \
3187 usecxxflags=yes extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3188 hostisaflags="$(HOST_ISA_CFLAGS)" \
3189 kernelisaflags="$(TARGET_ISA_CFLAGS)" \
3190 targetisaflags="$(TARGET_ISA_CFLAGS)" \
3191 aros_prefix= nix_dir_layout= nix=no compiler=target crossbuild=no \
3192 install_target=install preconfigure= postconfigure= postinstall= \
3193 config_env_extra= install_env= use_build_env=no buildflags=yes gnuflags=yes nlsflag=yes xflag=yes
3196 %(mmake)-prefix := %(prefix)
3198 %(mmake)-prefix := $(AROS_CONTRIB)
3201 ifneq (%(aros_prefix),)
3202 %(mmake)-aros_prefix := %(aros_prefix)
3204 %(mmake)-aros_prefix := $(%(mmake)-prefix)
3210 %(mmake)-nix := $(BD_NIXFLAG)
3211 %(mmake)-volpfx := /
3212 %(mmake)-volsfx := /
3214 ifeq (%(nix_dir_layout),)
3215 %(mmake)-nix_dir_layout := yes
3218 %(mmake)-volsfx := :
3220 ifeq (%(nix_dir_layout),)
3221 %(mmake)-nix_dir_layout := no
3225 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
3227 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
3228 exec_prefix=$(%(mmake)-prefix) %(install_env)
3230 # Check if chosen compiler is valid
3231 ifeq ($(findstring %(compiler),host target kernel),)
3232 $(error unknown compiler %(compiler))
3235 # Set legacy 'host' variable based on chosen compiler
3236 ifeq (%(compiler),host)
3239 %(mmake)-pkgbasedir := $(HOSTGENDIR)
3241 %(mmake)-pkgbasedir := $(HOSTGENDIR)/%(basedir)
3246 %(mmake)-pkgbasedir := $(GENDIR)
3248 %(mmake)-pkgbasedir := $(GENDIR)/%(basedir)
3253 %(mmake)-pkgbasedir := %(gendir)
3255 %(mmake)-pkgbasedir := %(gendir)/%(basedir)
3260 %(mmake)-pkgdir := $(%(mmake)-pkgbasedir)
3262 %(mmake)-pkgdir := $(%(mmake)-pkgbasedir)/%(package)
3265 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
3266 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
3268 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
3269 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
3270 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
3273 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
3274 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
3276 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
3279 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
3281 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
3282 sbindir=$(%(mmake)-prefix) \
3283 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
3284 oldincludedir=$(AROS_INCLUDES) %(install_env)
3287 ifneq ($(DEBUG),yes)
3288 %(mmake)-s_flag = -s
3291 ifeq (%(usecflags),yes)
3292 %(mmake)-HOST_CFLAGS=%(hostisaflags) $(HOST_CFLAGS)
3293 %(mmake)-KERNEL_CFLAGS=%(kernelisaflags) $(KERNEL_CFLAGS) $$(%(mmake)-s_flag)
3294 ifeq (%(crossbuild),yes)
3295 %(mmake)-TARGET_CFLAGS=%(targetisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) $(%(mmake)-s_flag)
3297 %(mmake)-TARGET_CFLAGS=%(targetisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)
3300 ifeq (%(usecxxflags),yes)
3301 %(mmake)-HOST_CXXFLAGS=%(hostisaflags) $(HOST_CXXFLAGS)
3302 %(mmake)-KERNEL_CXXFLAGS=%(kernelisaflags) $(KERNEL_CXXFLAGS) $(%(mmake)-s_flag)
3303 ifeq (%(crossbuild),yes)
3304 %(mmake)-TARGET_CXXFLAGS=%(targetisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) $(%(mmake)-s_flag)
3306 %(mmake)-TARGET_CXXFLAGS=%(targetisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)
3310 # Set up build environment, and options for configure script
3311 ifeq (%(compiler),host)
3312 # NB: We need to pass in our crosstoolsdir, but cannot set CFLAGS since it
3313 # confused configure scripts. We also cannot pass it via _FOR_BUILD
3314 # since that won't get picked up during configure.
3315 # We also cannot pass in the compiler including std flags so we need to use
3316 # the "plain" host compiler.
3317 %(mmake)-cfg-env := %(config_env_extra) \
3319 CXXCPP="$(HOST_CPP)" \
3320 CC="$(strip $(HOST_DEF_CC) $(%(mmake)-HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include)" \
3321 CXX="$(strip $(HOST_CXX) $(%(mmake)-HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include)" \
3322 LDFLAGS="-L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS)"
3323 ifeq (%(usecppflags),yes)
3324 %(mmake)-cfg-env += TARGET_CPPFLAGS="$(KERNEL_CPPFLAGS)"
3326 %(mmake)-cfg-env += TARGET_CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
3327 TARGET_CFLAGS="$(strip $(%(mmake)-KERNEL_CFLAGS))" \
3328 TARGET_CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
3329 TARGET_CXXFLAGS="$(strip $(%(mmake)-KERNEL_CXXFLAGS))" \
3330 TARGET_AS="$(TARGET_AS)" \
3331 OBJCOPY="$(OBJCOPY)" \
3332 TARGET_RANLIB="$(RANLIB)" \
3333 TARGET_STRIP="$(STRIP_PLAIN)" \
3334 TARGET_NM="$(NM_PLAIN)" \
3335 TARGET_OBJCOPY="$(TARGET_OBJCOPY)"
3337 ifeq (%(compiler),target)
3338 %(mmake)-cfg-env := %(config_env_extra) \
3339 PKG_CONFIG_LIBDIR="$(AROS_DEVELOPER)/lib/pkgconfig" \
3340 PKG_CONFIG_SYSROOT_DIR="$(AROSDIR)"
3341 %(mmake)-cfg-env += CPP="$(strip $(TARGET_CPP) $(TARGET_SYSROOT))" \
3342 CXXCPP="$(strip $(TARGET_CPP) $(TARGET_SYSROOT))" \
3343 CC="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
3344 CXX="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
3345 LD="$(strip $(TARGET_LD))"
3346 %(mmake)-cfg-env += CFLAGS="$(%(mmake)-TARGET_CFLAGS) %(extracflags)" \
3347 CXXFLAGS="$(%(mmake)-TARGET_CXXFLAGS) %(extracxxflags)"
3348 ifeq (%(usecppflags),yes)
3349 %(mmake)-cfg-env += CPPFLAGS="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3351 %(mmake)-cfg-env += LDFLAGS="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))"
3352 ifeq (%(usecppflags),yes)
3353 %(mmake)-cfg-env += CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)"
3355 %(mmake)-cfg-env += CC_FOR_BUILD="$(strip $(HOST_DEF_CC))" \
3356 CFLAGS_FOR_BUILD="$(strip $(%(mmake)-HOST_CFLAGS))" \
3357 CXX_FOR_BUILD="$(strip $(HOST_CXX))" \
3358 CXXFLAGS_FOR_BUILD="$(strip $(%(mmake)-HOST_CXXFLAGS))" \
3359 LD_FOR_BUILD="$(strip $(HOST_LD))" \
3360 LDFLAGS_FOR_BUILD="$(strip $(HOST_LDFLAGS) $(%(mmake)-s_flag))"
3361 ifeq (%(usecppflags),yes)
3362 %(mmake)-cfg-env += CPPFLAGS_FOR_HOST="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3364 %(mmake)-cfg-env += CC_FOR_HOST="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
3365 CFLAGS_FOR_HOST="$(strip %(hostisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) -L$(AROS_DEVELOPER)/lib %(extracflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3366 CXX_FOR_HOST="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
3367 CXXFLAGS_FOR_HOST="$(strip %(hostisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) -L$(AROS_DEVELOPER)/lib %(extracxxflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3368 LD_FOR_HOST="$(strip $(TARGET_LD))" \
3369 LDFLAGS_FOR_HOST="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))"
3370 ifeq (%(usecppflags),yes)
3371 %(mmake)-cfg-env += CPPFLAGS_FOR_TARGET="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3373 %(mmake)-cfg-env += CC_FOR_TARGET="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
3374 CFLAGS_FOR_TARGET="$(strip $(%(mmake)-TARGET_CFLAGS) -L$(AROS_DEVELOPER)/lib %(extracflags))" \
3375 CXX_FOR_TARGET="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
3376 CXXFLAGS_FOR_TARGET="$(strip $(%(mmake)-TARGET_CXXFLAGS) -L$(AROS_DEVELOPER)/lib %(extracxxflags))" \
3377 LD_FOR_TARGET="$(strip $(TARGET_LD))" \
3378 LDFLAGS_FOR_TARGET="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3379 AR="$(strip $(AR_PLAIN))" \
3380 AS="$(strip $(TARGET_AS))" \
3381 OBJCOPY="$(strip $(OBJCOPY))" \
3382 RANLIB="$(strip $(RANLIB))" \
3383 STRIP="$(strip $(STRIP_PLAIN))"
3384 ifeq (%(usecppflags),yes)
3385 %(mmake)-cfg-env += TARGET_CPPFLAGS="$(KERNEL_CPPFLAGS)"
3387 %(mmake)-cfg-env += TARGET_CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
3388 TARGET_CFLAGS="$(strip $(%(mmake)-KERNEL_CFLAGS))" \
3389 TARGET_CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
3390 TARGET_CXXFLAGS="$(strip $(%(mmake)-KERNEL_CXXFLAGS))" \
3391 TARGET_AS="$(strip $(TARGET_AS))" \
3392 TARGET_RANLIB="$(strip $(RANLIB))" \
3393 TARGET_STRIP="$(strip $(STRIP_PLAIN))" \
3394 TARGET_NM="$(strip $(NM_PLAIN))"
3395 ifeq (%(buildflags),yes)
3396 %(mmake)-config_opts += --target=$(AROS_TARGET_CPU)-aros
3397 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)
3398 %(mmake)-config_opts += --host=$(AROS_TARGET_CPU)-aros
3400 ifeq (%(gnuflags),yes)
3401 %(mmake)-config_opts += --without-pic --disable-shared
3402 ifeq (%(nlsflag),yes)
3403 # disable native language support
3404 %(mmake)-config_opts += --disable-nls
3407 # disable X window system
3408 %(mmake)-config_opts += --without-x
3412 ifeq (%(compiler),kernel)
3413 %(mmake)-cfg-env := %(config_env_extra) \
3414 CPP="$(KERNEL_CPP)" \
3415 CXXCPP="$(KERNEL_CPP)"
3416 ifeq (%(usecppflags),yes)
3417 %(mmake)-cfg-env += CPPFLAGS="$(strip $(KERNEL_CPPFLAGS) %(extracppflags))"
3419 %(mmake)-cfg-env += CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
3420 CFLAGS="$(strip $(%(mmake)-KERNEL_CFLAGS) %(extracflags))" \
3421 CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
3422 CXXFLAGS="$(strip $(%(mmake)-KERNEL_CXXFLAGS) %(extracxxflags))" \
3424 ifeq (%(usecppflags),yes)
3425 %(mmake)-cfg-env += CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)"
3427 %(mmake)-cfg-env += CC_FOR_BUILD="$(HOST_DEF_CC)" \
3428 CFLAGS_FOR_BUILD="$(%(mmake)-HOST_CFLAGS)" \
3429 CXX_FOR_BUILD="$(HOST_CXX)" \
3430 CXXFLAGS_FOR_BUILD="$(%(mmake)-HOST_CXXFLAGS)" \
3431 RANLIB="$(RANLIB)" \
3432 TARGET_RANLIB="$(RANLIB)" \
3433 TARGET_STRIP="$(STRIP_PLAIN)" \
3434 TARGET_NM="$(NM_PLAIN)"
3435 ifeq (%(buildflags),yes)
3436 %(mmake)-config_opts += --target=$(AROS_TARGET_CPU)-aros
3437 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)
3438 %(mmake)-config_opts += --host=$(AROS_TARGET_CPU)-aros
3440 ifeq (%(gnuflags),yes)
3441 %(mmake)-config_opts += --without-pic --disable-shared
3442 ifeq (%(nlsflag),yes)
3443 # disable native language support
3444 %(mmake)-config_opts += --disable-nls
3447 # disable X window system
3448 %(mmake)-config_opts += --without-x
3454 ifeq (%(use_build_env),yes)
3455 BUILD_ENV := $(%(mmake)-cfg-env)
3458 %(mmake)-touchfileflag ?= $(%(mmake)-pkgdir)/.files-touched
3460 ifneq ("$(wildcard %(srcdir)/Makefile)","")
3461 # in an ideal world, we would depend on the files in the source directory,
3462 # so we could copy them when they change. unfortunately filenames with
3463 # spaces cause problems with this
3464 $(%(mmake)-pkgdir)/.local-copy:
3465 %mkdirs_q $(%(mmake)-pkgdir)
3466 $(Q)$(ECHO) "Copying Local-Build Sources to \`$(patsubst $(TOP)/%,%,$(abspath $(%(mmake)-pkgdir)))'"
3467 $(Q)$(CP) -Rf "%(srcdir)/." $(%(mmake)-pkgdir)/ && $(TOUCH) $@
3469 $(%(mmake)-touchfileflag) : $(%(mmake)-pkgdir)/.local-copy
3471 %(mmake)-cfg-srcdir=$(%(mmake)-pkgdir)
3473 %(mmake)-cfg-srcdir=%(srcdir)
3475 %(mmake)-make-env := -C $(%(mmake)-pkgdir)
3477 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3479 # When building for the host, we don't need to build the
3480 # linklibs - this is especially true when building the
3481 # crosstool toolchain on 'foreign' architectures (such as
3482 # building PPC on x86)
3484 #MM- %(mmake)-host : setup includes %(mmake)-quick
3485 #MM- %(mmake)-target : setup includes core-linklibs %(mmake)-quick
3486 #MM- %(mmake): %(mmake)-%(compiler)
3488 # Using -j1 in install_command may result in a warning but finally
3489 # it does its job. make install for gcc does not work reliably for -jN
3491 ifneq (%(install_target),)
3492 %(mmake)-install_command = \
3493 $(ECHO) "Installing from build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))" && \
3494 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
3495 $(%(mmake)-make-env) %(install_target) -j1
3497 %(mmake)-uninstall_command = \
3498 $(RM) $(%(mmake)-installflag) && \
3499 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" \
3500 $(%(mmake)-install_opts) $(%(mmake)-make-env) uninstall
3502 %(mmake)-install_command := true
3503 %(mmake)-uninstall_command := true
3506 #MM- %(mmake)-quick : %(preconfigure) %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
3509 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3512 # N.B.: the make test for the targets being up to date generates a benign Error 1.
3514 $(%(mmake)-installflag) : $(%(mmake)-configflag)
3515 $(Q)$(IF) ! $(BUILD_ENV) $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q $(%(mmake)-make-env); then \
3516 $(RM) $(%(mmake)-installflag) && \
3517 $(ECHO) "Performing build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))" && \
3518 $(BUILD_ENV) $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" $(%(mmake)-make-env) && \
3519 $(%(mmake)-install_command) && \
3520 $(TOUCH) $@ -r $^; \
3523 ifneq ($(%(mmake)-touchfileflag),)
3524 $(%(mmake)-touchfileflag):
3525 %mkdirs_q $(%(mmake)-pkgdir)
3526 $(Q)find %(srcdir) -exec $(TOUCH) -c -r $(%(mmake)-cfg-srcdir)/configure '{}' \; && \
3531 %(mmake)-uninstall :
3532 $(%(mmake)-uninstall_command)
3535 %(mmake)-configure : $(%(mmake)-configflag)
3537 $(%(mmake)-configflag) : TMP_SRCDIR := $(shell echo $(%(mmake)-cfg-srcdir) | sed 's/^\(.\):\//\/\1\//')
3538 $(%(mmake)-configflag) : $(%(mmake)-touchfileflag) $(TOP)/$(CURDIR)/mmakefile
3540 %mkdirs_q $(%(mmake)-pkgdir)
3541 $(Q)$(ECHO) "Configuring build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))"
3542 $(Q)cd $(%(mmake)-pkgdir) && \
3543 find . -name config.cache -exec $(RM) '{}' \; && \
3544 $(%(mmake)-cfg-env) $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) %(extraoptions) && \
3548 %(mmake)-clean : %(mmake)-uninstall
3549 $(Q)$(RM) $(%(mmake)-pkgdir)
3551 #------------------------------------------------------------------------------
3554 #------------------------------------------------------------------------------
3555 # Build an imported source tree which uses cmake
3559 # - mmake = the meta make target.
3560 # - package = name of the package to be built.
3561 # - srcdir = the location of the unpacked source code. Defaults
3562 # to $(SRCDIR)/$(CURDIR).
3563 # - prefix = the target directory. Must be an absolute path of the
3564 # host system. Defaults to $(AROS_CONTRIB).
3565 # - aros_prefix = set a path which is valid within the AROS filesystem.
3566 # Defaults to the value of the prefix option.
3567 # - extraoptions = additional options for the cmake script.
3568 # - usecppflags = enable the use of cpp flags. some external cmake
3569 # scripts will not set their own cppflags if it is already
3570 # set, so this allows them to be disabled (unless you can provide
3571 # all the options they would need)
3572 # - cppflags = preprocessor flags.
3573 # - extracppflags = additional preprocessor flags.
3574 # - usecflags = enable the use of the build systems C flags
3575 # - cflags = additional flags to use with the C compiler.
3576 # - usecxxflags = enable the use of the build systems C flags
3577 # - cxxflags = additional flags to use with the C++ compiler.
3578 # - cflags = flags to use with the C compiler.
3579 # - cxxflags = flags to use with the C++ compiler.
3580 # - installoptions = additional options for the install step.
3583 %define build_with_cmake mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) gendir= prefix= \
3584 aros_prefix= extraoptions= installoptions= maketarget= compiler=target \
3585 usecppflags=yes extracppflags= \
3586 usecflags=yes extracflags= \
3587 usecxxflags=yes extracxxflags= \
3588 extraldflags= useldlinker=no
3591 %(mmake)-prefix := %(prefix)
3593 %(mmake)-prefix := $(AROS_CONTRIB)
3596 ifneq (%(aros_prefix),)
3597 %(mmake)-aros_prefix := %(aros_prefix)
3599 %(mmake)-aros_prefix := $(%(mmake)-prefix)
3602 ifeq (%(compiler),host)
3603 BD_LDFLAGS := $(HOST_LDFLAGS) -L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS) %(extraldflags)
3604 BD_CFLAGS := $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include %(extracflags)
3605 BD_CXXFLAGS := $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include %(extracxxflags)
3606 BD_CPPFLAGS := $(HOST_CPPFLAGS) %(extracppflags)
3607 %(mmake)-cmake_opts := -DCMAKE_INSTALL_PREFIX=$(%(mmake)-prefix) \
3608 -DCMAKE_BUILD_TYPE=Release \
3609 -DCMAKE_LINKER="$(strip $(HOST_LD))" \
3610 -DCMAKE_EXE_LINKER_FLAGS="$(strip $(BD_LDFLAGS))"
3611 ifeq (%(useldlinker),yes)
3612 %(mmake)-cmake_opts += -DCMAKE_CXX_LINK_EXECUTABLE="<CMAKE_LINKER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"
3614 %(mmake)-cmake_opts += -DCMAKE_C_COMPILER="$(strip $(HOST_DEF_CC))"
3615 ifeq (%(usecflags),yes)
3616 %(mmake)-cmake_opts += -DCMAKE_C_FLAGS="$(strip $(BD_CFLAGS))"
3618 ifeq (%(usecppflags),yes)
3619 %(mmake)-cmake_opts += -DCMAKE_CPP_FLAGS="$(strip $(BD_CPPFLAGS))"
3621 %(mmake)-cmake_opts += -DCMAKE_CXX_COMPILER="$(strip $(HOST_CXX))"
3622 ifeq (%(usecxxflags),yes)
3623 %(mmake)-cmake_opts += -DCMAKE_CXX_FLAGS="$(strip $(BD_CXXFLAGS))"
3626 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
3628 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
3631 BD_LDFLAGS := $(strip $(LDFLAGS) %(extraldflags))
3632 BD_CFLAGS := $(strip $(CFLAGS) %(extracflags))
3633 BD_CXXFLAGS := $(strip $(CXXFLAGS) %(extracxxflags))
3634 BD_CPPFLAGS := $(strip $(CPPFLAGS) %(extracppflags))
3635 %(mmake)-cmake_opts := -DCMAKE_TOOLCHAIN_FILE=$(GENDIR)/config/conf.cmake -DCMAKE_INSTALL_PREFIX=$(%(mmake)-prefix)
3636 ifeq (%(usecflags),yes)
3637 %(mmake)-cmake_opts += -DCMAKE_C_FLAGS="$(strip $(BD_CFLAGS))"
3639 ifeq (%(usecppflags),yes)
3640 %(mmake)-cmake_opts += -DCMAKE_CPP_FLAGS="$(strip $(BD_CPPFLAGS))"
3642 ifeq (%(usecxxflags),yes)
3643 %(mmake)-cmake_opts += -DCMAKE_CXX_FLAGS="$(strip $(BD_CXXFLAGS))"
3645 %(mmake)-cmake_opts += -DCMAKE_EXE_LINKER_FLAGS="$(strip $(BD_LDFLAGS))"
3647 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
3649 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
3654 %(mmake)-pkgdir := %(gendir)/$(CURDIR)
3656 %(mmake)-pkgdir := %(gendir)/$(CURDIR)/%(package)
3660 %(mmake)-cmakeflag := $(%(mmake)-pkgdir)/.cmake
3661 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
3663 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3665 #MM- %(mmake): setup includes core-linklibs %(mmake)-quick
3667 #MM- %(mmake)-quick : %(mmake)-cmake %(mmake)-build_and_install-quick
3670 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3672 $(%(mmake)-installflag) : $(%(mmake)-cmakeflag)
3673 $(IF) ! $(MAKE) -q -C $(%(mmake)-pkgdir); then \
3674 $(RM) $(%(mmake)-installflag) && \
3675 $(MAKE) -C $(%(mmake)-pkgdir) %(maketarget) && \
3676 cd $(%(mmake)-pkgdir) && \
3677 cmake %(installoptions) -P cmake_install.cmake && \
3678 $(TOUCH) $@ -r $^; \
3681 %(mmake)-touchfileflag ?= $(%(mmake)-pkgdir)/.files-touched
3682 ifneq ($(%(mmake)-touchfileflag),)
3683 $(%(mmake)-touchfileflag):
3684 %mkdirs_q $(%(mmake)-pkgdir)
3685 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/CMakeLists.txt '{}' \; && \
3690 %(mmake)-cmake : $(%(mmake)-cmakeflag)
3692 $(%(mmake)-cmakeflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
3693 $(%(mmake)-cmakeflag) : $(%(mmake)-touchfileflag) $(TOP)/$(CURDIR)/mmakefile
3695 %mkdirs_q $(%(mmake)-pkgdir)
3696 cd $(%(mmake)-pkgdir) && \
3697 $(RM) -Rf CMakeCache.txt CMakeFiles \; && \
3698 cmake $(%(mmake)-cmake_opts) %(extraoptions) $(TMP_SRCDIR) && \
3702 %(mmake)-clean : %(mmake)-uninstall
3703 $(Q)$(RM) $(%(mmake)-pkgdir)
3705 #------------------------------------------------------------------------------
3708 #------------------------------------------------------------------------------
3709 # Given an archive name, patches names and locations where to find them, fetch
3710 # the archive and the patches from any of those locations, unpack the archive
3711 # and then apply the patches.
3713 # Locations currently supported are http and ftp sites, plus local filesystem
3714 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
3715 # the fetch.sh script needs to be modified, since this macro relies on that script.
3719 # - mmake = mmaketarget
3720 # - archive_origins = list of locations where to find the archive. They are tried
3721 # in sequence, until the archive is found and fetching it
3722 # succeeded. If not specified, the current directory is assumed.
3723 # - archive = the archive name. Mandatory.
3724 # - suffixes = a list of suffixes to append to the package name plus the
3725 # version. Each one of them is tried until a matching archive is
3726 # found. They are appended to patches and these are tried the
3727 # same way as packages are.
3728 # - location = the local directory where to put the fetched archive and patches.
3729 # If not specified, the directory specified by destination is used.
3730 # - destination = the directory to unpack the archive to.
3731 # If not specified, the current directory is assumed.
3732 # - patches_origins = list of locations where to find the patches. They are tried
3733 # in sequence, until a patch is found and fetching it
3734 # succeeded. If not specified, the current directory is assumed.
3735 # - patches_specs = list of "patch specs". A patch spec is of the form
3736 # patch_name[:[patch_subdir][:patch_opt]].
3738 # - patch_name = the name of the patch file
3739 # - patch_subdir = the directory within \destination\ where to
3741 # - patch_opt = any options to pass to the `patch' command
3742 # when applying the patch.
3744 # The patch_subdir and patch_opt fields are optional.
3746 %define fetch mmake=/A archive_origins=. archive=/A suffixes= location= destination=. \
3747 patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
3751 ifneq (%(location),)
3752 %(mmake)-location := %(location)
3754 %(mmake)-location := %(destination)
3757 %(mmake)-fetchedflag := $(%(mmake)-location)/.%(archive)-fetched
3761 $(Q)$(ECHO) "Fetching %(archive) ..."
3762 $(Q)$(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
3763 -d %(destination) -po "%(patches_origins)" -p "%(patches_specs)"
3764 $(Q)$(IF) ! $(TEST) -f $(%(mmake)-fetchedflag) ; then \
3765 $(TOUCH) $(%(mmake)-fetchedflag) ; \
3768 # $(Q)$(IF) ! $(TEST) -f $(%(mmake)-fetchedflag) ; then \
3769 # $(ECHO) "Fetching %(archive) ..." \
3770 # && $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
3771 # -d %(destination) -po "%(patches_origins)" -p "%(patches_specs)" \
3772 # && $(TOUCH) $(%(mmake)-fetchedflag) ; \
3775 #------------------------------------------------------------------------------
3778 #------------------------------------------------------------------------------
3779 # This macro can aid in patch creation for fetched ports. It temporarily creates another
3780 # unpatched source tree and runs diff against this and a previously fetched and possibly
3781 # patched tree. Depending on what happens after patching during a normal build it might
3782 # give best results if the new patch is created directly after fetch.
3786 # - mmake = mmaketarget
3787 # - archive = archive base name
3788 # - srcdir = the top level directory the package is unpacked to, useful if
3789 # an archive unpacks to a directory other than its name suggests.
3790 # this should not be deeper than a single path element.
3791 # - suffixes = a list of suffixes to append to the the package name plus the
3792 # version. Each one of them is tried until a matching archive is
3794 # - destination = the directory to unpack the archive to.
3795 # - excludes = diff patterns to exclude files or directories from the patch
3797 %define create_patch mmake=/A archive=/A srcdir= suffixes="tar.bz2 tar.gz" destination=/A excludes=
3801 ifneq (%(excludes),)
3802 %(mmake)-exclude := -X ./exclude.patterns
3806 %(mmake)-srcdir := %(srcdir)
3808 %(mmake)-srcdir := %(archive)
3811 #MM- %(mmake) : %(mmake)-diff
3812 #MM- %(mmake)-quick : %(mmake)-diff
3816 $(Q)$(FETCH) -a %(archive) -s "%(suffixes)" -l $(PORTSSOURCEDIR) -d %(destination)/tmp ; \
3817 $(MV) %(destination)/$(%(mmake)-srcdir) %(destination)/tmp/$(%(mmake)-srcdir).aros ; \
3818 cd %(destination)/tmp ; \
3819 $(FOR) f in %(excludes) ; do \
3820 $(ECHO) $$f >> ./exclude.patterns ; \
3822 $(ECHO) "Creating \`%(archive)-aros-new.diff'" ; \
3823 diff -ruN $(%(mmake)-exclude) \
3824 $(%(mmake)-srcdir) \
3825 $(%(mmake)-srcdir).aros \
3826 >$(SRCDIR)/$(CURDIR)/%(archive)-aros-new.diff ; \
3827 $(MV) %(destination)/tmp/$(%(mmake)-srcdir).aros %(destination)/$(%(mmake)-srcdir) ; \
3828 $(RM) %(destination)/tmp
3830 #------------------------------------------------------------------------------
3833 #------------------------------------------------------------------------------
3834 # Joins the features of %fetch and %build_with_configure.
3836 # If a patch is provided, it *must* be named the following way:
3838 # <package name>-<version number>-aros.diff
3840 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3841 # CD'ing into the archive's extracted directory.
3843 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3844 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3845 # to make that patch fully comprehensive.
3849 # - mmake = the meta make target.
3850 # - package = the GNU package name, sans version and archive format suffixes.
3851 # - subpackage = ???
3852 # - compiler = same meaning as the one for the %build_with_configure macro.
3853 # - install_target = same meaning as the one for the %build_with_configure macro.
3854 # - version = the package's version number, or otherwise any other version string.
3855 # It gets appended to the package name to form the basename of the archive.
3856 # - suffixes = a list of suffixes to apped to the the package name plus the
3857 # version. Each one of them is tried until a matching archive is found.
3858 # Defaults to "tar.bz2 tar.gz".
3859 # - srcdir = the top level directory the package is unpacked to (see create_patch).
3860 # - builddir = override the location we expect to run configure/make in.
3861 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
3862 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
3863 # fetched or not. Default to no.
3864 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
3865 # - prefix = same meaning as the one for the %build_with_configure macro.
3866 # - aros_prefix = same meaning as the one for the %build_with_configure macro.
3867 # - extraoptions = same meaning as the one for the %build_with_configure macro.
3868 # - usecppflags = same meaning as the one for the %build_with_configure macro.
3869 # - extracppflags = same meaning as the one for the %build_with_configure macro.
3870 # - usecflags = same meaning as the one for the %build_with_configure macro.
3871 # - extracflags = same meaning as the one for the %build_with_configure macro.
3872 # - usecxxflags = same meaning as the one for the %build_with_configure macro.
3873 # - extracxxflags = same meaning as the one for the %build_with_configure macro.
3874 # - preconfigure = same meaning as the one for the %build_with_configure macro.
3875 # - postconfigure = same meaning as the one for the %build_with_configure macro.
3876 # - postinstall = same meaning as the one for the %build_with_configure macro.
3877 # - install_env = same meaning as the one for the %build_with_configure macro.
3878 # - use_build_env = same meaning as the one for the %build_with_configure macro.
3879 # - nix = same meaning as the one for the %build_with_configure macro.
3880 # - nix_dir_layout = same meaning as the one for the %build_with_configure macro.
3881 # - create_pkg = create a distributable package of the compiled sources, defaults to no
3883 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target crossbuild=no install_target=install \
3884 version=/A suffixes="tar.bz2 tar.gz" srcdir= builddir= gendir= basedir=$(CURDIR) package_repo= patch=no patch_repo= \
3885 prefix= aros_prefix= preconfigure= postconfigure= postinstall= \
3887 usecppflags=yes extracppflags= \
3888 usecflags=yes extracflags="$(OPTIMIZATION_CFLAGS)" \
3889 usecxxflags=yes extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3890 config_env_extra= install_env= use_build_env=no nix=no nix_dir_layout= create_pkg=no \
3891 buildflags=yes gnuflags=yes nlsflag=yes xflag=yes \
3892 hostisaflags= kernelisaflags="$(TARGET_ISA_CFLAGS)" targetisaflags="$(TARGET_ISA_CFLAGS)"
3894 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
3895 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
3896 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
3897 #MM- %(mmake)-create-patch : %(mmake)-%(subpackage)-create-patch
3898 #MM- %(mmake)-create-patch-quick : %(mmake)-%(subpackage)-create-patch
3900 %(mmake)-archbase := %(package)-%(version)
3902 ifeq (%(compiler),host)
3903 %(mmake)-portdir := $(HOSTDIR)/Ports/host/%(package)
3905 %(mmake)-portdir := $(PORTSDIR)/%(package)
3909 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
3911 %(mmake)-prefix := %(prefix)
3914 ifneq (%(subpackage),)
3915 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
3917 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
3921 %(mmake)-%(subpackage)-srcdir := %(srcdir)
3923 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
3926 ifneq (%(builddir),)
3927 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)/%(builddir)
3929 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)
3933 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-f,-p1
3935 %(mmake)-%(subpackage)-patches_specs := ::
3938 %fetch mmake="%(mmake)-%(subpackage)-fetch" archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
3939 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
3940 archive_origins=". %(package_repo)" \
3941 patches_specs=$(%(mmake)-%(subpackage)-patches_specs) patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
3943 %create_patch mmake="%(mmake)-%(subpackage)-create-patch" \
3944 archive=$(%(mmake)-%(subpackage)-archbase) \
3945 srcdir=$(%(mmake)-%(subpackage)-srcdir) \
3946 suffixes="%(suffixes)" \
3947 destination=$(%(mmake)-portdir)
3949 #MM %(mmake) : %(mmake)-%(subpackage)
3954 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
3956 %(mmake)-%(subpackage)-package-basename := \
3957 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
3959 ifneq (%(create_pkg),no)
3960 %(mmake)-%(subpackage)-package := $(%(mmake)-%(subpackage)-package-basename).tar.bz2
3963 %build_with_configure mmake="%(mmake)-%(subpackage)" package="%(package)" compiler="%(compiler)" crossbuild="%(crossbuild)" install_target="%(install_target)" \
3964 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-builddir) gendir="%(gendir)" basedir="%(basedir)" \
3965 config_env_extra="%(config_env_extra)" install_env="%(install_env)" use_build_env="%(use_build_env)" \
3966 nix="%(nix)" nix_dir_layout="%(nix_dir_layout)" prefix=$(%(mmake)-prefix) aros_prefix="%(aros_prefix)" \
3967 preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall) %(mmake)-%(subpackage)-make-package" \
3968 extraoptions="%(extraoptions)" \
3969 usecppflags="%(usecppflags)" extracppflags="%(extracppflags)" \
3970 usecflags="%(usecflags)" extracflags="%(extracflags)" \
3971 usecxxflags="%(usecxxflags)" extracxxflags="%(extracxxflags)" \
3972 buildflags=%(buildflags) gnuflags=%(gnuflags) nlsflag=%(nlsflag) xflag=%(xflag) \
3973 hostisaflags=%(hostisaflags) kernelisaflags="%(kernelisaflags)" targetisaflags=%(targetisaflags)
3975 .PHONY : %(mmake)-%(subpackage)-make-package %(mmake)-%(subpackage)-create-patch
3976 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
3979 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package)
3981 #There seems to be a bug, either with my clock or with make, 'cause it may happen
3982 #that $^ and $@ have exactly the same mtime, and in that case make tries
3983 #to rebuild $@ again, which would fail because the directory where
3984 #the package got installed would not exist anymore.
3985 #We work this around by using an if statement to manually check the mtimes.
3986 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
3987 $(Q)$(IF) $(TEST) $(%(mmake)-installflag) -nt $@ || ! $(TEST) -s $@; then \
3989 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
3990 $(MKDIR) -p "$(DISTDIR)/Packages" ; \
3991 $(MKDIR) -p "$(%(mmake)-prefix)" ; \
3992 cd $(%(mmake)-%(subpackage)-package-dir) ; \
3993 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
3994 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
3997 #------------------------------------------------------------------------------
4000 #------------------------------------------------------------------------------
4001 # Joins the features of %fetch and %build_with_configure, taking advantage of
4002 # the naming scheme of GNU packages. GNU packages names are in the form
4004 # <package name>-<version number>.<archive format suffix>
4006 # If a patch is provided, it *must* be named the following way:
4008 # <package name>-<version number>-aros.diff
4010 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
4011 # CD'ing into the archive's extracted directory.
4013 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
4014 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
4015 # to make that patch fully comprehensive.
4017 # NOTE: GNU packages are always compiled with *nix semantics turned on.
4021 # Arguments have the same meaning as the one for the %fetch_and_build macro, except:
4023 # - prefix = defaults to $(GNUDIR).
4024 # - aros_prefix = defaults to /GNU.
4026 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A crossbuild=no suffixes="tar.bz2 tar.gz" \
4027 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
4028 aros_prefix=/GNU config_env_extra= preconfigure= postconfigure= postinstall= \
4030 usecppflags=yes extracppflags= \
4031 usecflags=yes extracflags="$(OPTIMIZATION_CFLAGS)" \
4032 usecxxflags=yes extracxxflags="$(OPTIMIZATION_CFLAGS)" \
4033 hostisaflags="$(HOST_ISA_CFLAGS)" \
4034 kernelisaflags="$(TARGET_ISA_CFLAGS)" \
4035 targetisaflags="$(TARGET_ISA_CFLAGS)" \
4036 use_build_env=no nix=yes gnuflags=yes nlsflag=yes xflag=yes
4038 GNU_REPOSITORY := gnu://
4040 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
4041 crossbuild="%(crossbuild)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
4042 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
4043 patch="%(patch)" patch_repo="%(patch_repo)" \
4044 prefix="%(prefix)" aros_prefix="%(aros_prefix)" \
4045 extraoptions="%(extraoptions)" \
4046 usecppflags="%(usecppflags)" extracppflags="%(extracppflags)" \
4047 usecflags="%(usecflags)" extracflags="%(extracflags)" \
4048 usecxxflags="%(usecxxflags)" extracxxflags="%(extracxxflags)" \
4049 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" \
4050 hostisaflags="%(hostisaflags)" kernelisaflags="%(kernelisaflags)" targetisaflags="%(targetisaflags)" \
4051 use_build_env=%(use_build_env) nix=%(nix) gnuflags=%(gnuflags) nlsflag=%(nlsflag) xflag=%(xflag)
4054 #------------------------------------------------------------------------------
4057 #------------------------------------------------------------------------------
4058 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
4059 # that the package is a "Developer" package, and as such it needs to be placed
4060 # under the $(AROS_DEVELOPER) directory, as a default.
4062 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
4063 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
4064 # "mmake" argument, because the metatarget is implicitely defined as
4066 # #MM- development-%(package)
4068 %define fetch_and_build_gnu_development package=/A subpackage= version=/A crossbuild=no suffixes="tar.bz2 tar.gz" \
4069 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPER) \
4070 aros_prefix=/Developer config_env_extra= preconfigure= postconfigure= postinstall= \
4072 usecppflags=yes extracppflags= \
4073 usecflags=yes extracflags="$(OPTIMIZATION_CFLAGS)" \
4074 usecxxflags=yes extracxxflags="$(OPTIMIZATION_CFLAGS)" \
4075 hostisaflags="$(HOST_ISA_CFLAGS)" \
4076 kernelisaflags="$(TARGET_ISA_CFLAGS)" \
4077 targetisaflags="$(TARGET_ISA_CFLAGS)" \
4078 use_build_env=no nix=yes gnuflags=yes nlsflag=yes xflag=yes
4080 #MM- development : development-%(package)
4083 %fetch_and_build_gnu mmake="development-%(package)" package="%(package)" subpackage="%(subpackage)" \
4084 version="%(version)" crossbuild="%(crossbuild)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
4085 package_repo="%(package_repo)" \
4086 patch="%(patch)" patch_repo="%(patch_repo)" \
4087 prefix="%(prefix)" aros_prefix="%(aros_prefix)" \
4088 extraoptions="%(extraoptions)" \
4089 usecppflags="%(usecppflags)" extracppflags="%(extracppflags)" \
4090 usecflags="%(usecflags)" extracflags="%(extracflags)" \
4091 usecxxflags="%(usecxxflags)" extracxxflags="%(extracxxflags)" \
4092 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="postinstall-%(package)-delete-la-files %(postinstall)" \
4093 hostisaflags="%(hostisaflags)" kernelisaflags="%(kernelisaflags)" targetisaflags="%(targetisaflags)" \
4094 use_build_env=%(use_build_env) nix=%(nix) gnuflags=%(gnuflags) nlsflag=%(nlsflag) xflag=%(xflag)
4097 postinstall-%(package)-delete-la-files:
4098 $(RM) %(prefix)/lib/*.la
4101 #------------------------------------------------------------------------------
4103 # Builds a kickstart package in PKG format
4107 # - mmake = target name
4108 # - file = destination file name with path
4110 # Other arguments are self-explanatory
4112 %define make_package mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
4113 arch_classes= arch_devs= arch_handlers= arch_hidds= arch_libs= arch_res=
4115 PKG_CLASSES := $(addprefix $(AROS_CLASSES)/,$(addsuffix .class, %(classes)))
4116 PKG_DEVICES := $(addprefix $(AROS_DEVS)/,$(addsuffix .device, %(devs)))
4117 PKG_HANDLERS := $(addprefix $(AROS_FS)/,$(addsuffix -handler, %(handlers)))
4118 PKG_HIDD := $(addprefix $(AROS_DEVS)/Drivers/,$(addsuffix .hidd, %(hidds)))
4119 PKG_LIBS := $(addprefix $(AROS_LIBRARIES)/,$(addsuffix .library, %(libs)))
4120 PKG_RESOURCES := $(addprefix $(AROS_DEVS)/,$(addsuffix .resource, %(res)))
4122 PKG_CLASSES_ARCH := $(addprefix $(AROS_CLASSES_ARCH)/,$(addsuffix .class, %(arch_classes)))
4123 PKG_DEVICES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .device, %(arch_devs)))
4124 PKG_HANDLERS_ARCH := $(addprefix $(AROS_FS_ARCH)/,$(addsuffix -handler, %(arch_handlers)))
4125 PKG_HIDD_ARCH := $(addprefix $(AROS_DEVS_ARCH)/Drivers/,$(addsuffix .hidd, %(arch_hidds)))
4126 PKG_LIBRARIES_ARCH := $(addprefix $(AROS_LIBRARIES_ARCH)/,$(addsuffix .library, %(arch_libs)))
4127 PKG_RESOURCES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .resource, %(arch_res)))
4129 PKG_FILES := $(PKG_CLASSES) $(PKG_DEVICES) $(PKG_HANDLERS) $(PKG_HIDD) $(PKG_LIBS) $(PKG_RESOURCES) \
4130 $(PKG_CLASSES_ARCH) $(PKG_DEVICES_ARCH) $(PKG_HANDLERS_ARCH) $(PKG_HIDD_ARCH) $(PKG_LIBRARIES_ARCH) $(PKG_RESOURCES_ARCH)
4131 PKG_DIR := $(dir %(file))
4137 %(mmake)-quick : %(file)
4139 %(file): $(PKG_FILES) | $(PKG_DIR)
4140 $(Q)$(ECHO) Packaging $@...
4141 $(Q)$(SRCDIR)/tools/package/pkg c $@ $^
4143 %compress_file mmake="%(mmake)" file="%(file)"
4145 %rule_makedirs dirs="$(PKG_DIR)"
4149 #------------------------------------------------------------------------------
4150 # Compresses %(file) with a gzip.
4151 # Good in conjunction with for example %build_prog
4153 %define compress_file mmake=/A file=/A
4155 #MM- %(mmake)-gz : %(mmake) %(mmake)-gz-quick
4158 %(mmake)-gz-quick : %(file).gz
4161 $(Q)$(ECHO) Compressing $(subst $(TARGETDIR)/,,$^)...
4166 #------------------------------------------------------------------------------
4167 # Links a kickstart module in ELF format
4168 # Arguments are similar to make_package
4170 %define link_kickstart mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
4171 startup= uselibs= ldflags=$(LDFLAGS) map= deps= strip=$(STRIP)
4173 KOBJ_CLASSES := $(addprefix $(KOBJSDIR)/, $(addsuffix _class.o, %(classes)))
4174 KOBJ_DEVICES := $(addprefix $(KOBJSDIR)/, $(addsuffix _device.o, %(devs)))
4175 KOBJ_HANDLERS := $(addprefix $(KOBJSDIR)/, $(addsuffix _handler.o, %(handlers)))
4176 KOBJ_HIDD := $(addprefix $(KOBJSDIR)/, $(addsuffix _hidd.o, %(hidds)))
4177 KOBJ_LIBS := $(addprefix $(KOBJSDIR)/, $(addsuffix _library.o, %(libs)))
4178 KOBJ_RES := $(addprefix $(KOBJSDIR)/, $(addsuffix _resource.o, %(res)))
4181 KOBJ_STARTUP := $(GENDIR)/$(RESIDENT_BEGIN).o
4183 KOBJ_STARTUP := %(startup)
4186 KOBJS := $(KOBJ_STARTUP) $(KOBJ_CLASSES) $(KOBJ_HANDLERS) $(KOBJ_LIBS) $(KOBJ_DEVICES) $(KOBJ_HIDD) $(KOBJ_RES)
4188 TMP_LDFLAGS := %(ldflags)
4190 # Make a list of the lib files this program depends on.
4191 # In LDFLAGS remove white space between -L and directory
4192 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
4193 # Filter out only the libdirs and remove -L
4194 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
4196 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
4197 # Add normal linklib path
4198 TMP_DIRS += $(AROS_LIB)/
4199 # add lib and .a to static linklib names
4200 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
4201 # search for the linklibs in the given path, ignore ones not found
4202 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS),$(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))))
4204 TMP_DIRS += $(dir %(file))
4206 TMP_LDFLAGS += $(GENMAP) %(map)
4207 TMP_DIRS += $(dir %(map))
4210 #MM %(mmake) : %(deps)
4216 %(mmake)-quick : %(file)
4218 %(file): KOBJS := $(KOBJS)
4219 %(file): LDFLAGS := $(TMP_LDFLAGS) $(NOSTARTUP_LDFLAGS) \
4220 -static -nosysbase -Wl,-Ur
4221 %(file): LDLIBS := $(addprefix -l, %(uselibs))
4222 %(file): $(KOBJS) $(DEPLIBS) | $(TMP_DIRS)
4223 $(Q)$(ECHO) "Kickstart $(subst $(TARGETDIR)/,,$@)..."
4224 $(Q)$(TARGET_CC) $(TARGET_SYSROOT) -o $@ $(KOBJS) $(LDFLAGS) $(LDLIBS)
4225 %strip_q strip=%(strip) file=$@
4227 %compress_file mmake="%(mmake)" file="%(file)"
4229 %rule_makedirs dirs="$(TMP_DIRS)"
4233 #------------------------------------------------------------------------------
4234 # Generate generic rules for a subtarget
4236 %define subtarget parentmmake= mmake=/A mmbase=MM-
4237 #%(mmbase) %(parentmmake) : %(mmake)
4238 #%(mmbase) %(parentmmake)-includes : %(mmake)-includes
4239 #%(mmbase) %(parentmmake)-quick : %(mmake)-quick
4242 #------------------------------------------------------------------------------
4243 # Create a target directory
4245 %define directorytarget mmake=/A directory= icontarget= mmbase=MM-
4248 %mkdirs_q %(directory)
4250 #%(mmbase) %(mmake) : %(mmake)-makedir