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 @$(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 @$(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 @$(ECHO) "Assembling $(notdir %(from))..."
47 @$(IF) %(cmd) %(opt) %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
48 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
49 $(ECHO) "$(notdir %(from)): %(cmd) %(opt) %(from) -o %(to)" >> $(GENDIR)/errors ; \
50 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
55 $(ECHO) "Assemble failed: %(cmd) %(opt) %(from) -o %(to)" 1>&2 ; \
56 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
60 #-------------------------------------------------------------------------
63 #------------------------------------------------------------------------------
64 # Link a specified number of objects to an executable
65 %define link_q cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" opt=$(LDFLAGS) from=$< to=$@ libs=$(LIBS) strip=$(STRIP) objdir=$(GENDIR)/$(CURDIR) coverageinstr=
66 @$(eval LINKTARGET=%(to))
67 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$(LINKTARGET))..."
68 @$(eval LINKTMPFILE=%(objdir)/$(notdir $(LINKTARGET)))
69 @$(IF) %(cmd) %(from) -o $(LINKTMPFILE) %(opt) %(libs) 2>&1 > $(GENDIR)/cerrors 2>&1 ; then \
70 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
71 $(ECHO) "$(LINKTARGET): %(cmd) %(from) -o $(LINKTARGET) %(opt) %(libs)" >> $(GENDIR)/errors ; \
72 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
76 $(CP) $(LINKTMPFILE) $(LINKTARGET) ; \
78 $(ECHO) "Link failed: %(cmd) %(from) -o $(LINKTARGET) %(opt) %(libs)" 1>&2 ; \
79 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
82 @$(IF) [ "$(DEBUG)" = "yes" ]; then \
83 %(strip) $(LINKTARGET) --only-keep-debug -o $(LINKTARGET).dbg ; \
85 @%(strip) $(LINKTARGET)
86 @$(IF) [ "$(DEBUG)" = "yes" ]; then \
87 $(IF) $(TEST) -s $(LINKTARGET).dbg ; then \
88 $(OBJCOPY) --add-gnu-debuglink=$(LINKTARGET).dbg $(LINKTARGET) ; \
91 @$(IF) [ "%(coverageinstr)" = "yes" ]; then \
92 LINKBASEFILES="$(strip $(notdir $(basename %(from))))" ; \
93 $(FOR) covext in $(TARGET_COVERAGEINSTR_EXTS) ; do \
94 $(FOR) file in $$LINKBASEFILES ; do \
95 COVERAGEFILE=`echo $$file$$covext` ; \
96 $(IF) $(TEST) -s %(objdir)/$$COVERAGEFILE ; then \
97 $(CP) %(objdir)/$$COVERAGEFILE $(dir $(LINKTARGET))$$COVERAGEFILE ; \
103 #------------------------------------------------------------------------------
106 #-------------------------------------------------------------------------
107 # Link a module based upon a number of arguments and the standard $(LIBS)
108 # and $(DEPLIBS) make variables.
110 %define link_module_q cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" err="$(notdir $@).err" objs=/A endtag= module=$(MODULE) ldflags=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
111 @$(ECHO) "Building $(subst $(TARGETDIR)/,,$@) ..."
112 @$(IF) %(cmd) $(NOSTARTUP_LDFLAGS) \
113 $(GENMAP) %(objdir)/%(module).map \
114 %(objs) %(libs) %(ldflags) %(endtag) \
115 -o $@ 2>&1 > %(objdir)/%(err); \
117 cat %(objdir)/%(err); \
119 echo "%(cmd) $(NOSTARTUP_LDFLAGS) $(GENMAP) %(objdir)/%(module).map %(objs) %(libs) %(ldflags) %(endtag) -o $@"; \
120 cat %(objdir)/%(err); \
123 @$(IF) $(TEST) ! -s %(objdir)/%(err) ; then $(RM) %(objdir)/%(err) ; fi
124 @$(IF) [ "$(DEBUG)" = "yes" ]; then \
125 $(STRIP) $@ --only-keep-debug -o $@.dbg; \
128 @$(IF) [ "$(DEBUG)" = "yes" ]; then \
129 $(IF) $(TEST) -s $@.dbg ; then \
130 $(OBJCOPY) --add-gnu-debuglink=$@.dbg $@; \
134 #------------------------------------------------------------------------------
137 #------------------------------------------------------------------------------
139 %define mklib_q ar=$(AR) ranlib=$(RANLIB) to=$@ from=$(OBJS)
140 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,%(to))..."
144 #------------------------------------------------------------------------------
147 #------------------------------------------------------------------------------
148 # Create the dependency file %(to) for %(from)
149 %define mkdepend_q flags="$(strip $(CFLAGS) $(CPPFLAGS))" from=$< to=$@ cc="$(strip $(AROS_CC) $(TARGET_SYSROOT))"
150 %mkdir_q dir="$(dir %(to))"
151 @$(ECHO) "Makedepend $(if $(filter /%,%(from)),$(if $(filter $(SRCDIR)/%,$(abspath %(from))),$(patsubst $(SRCDIR)/%,%,$(abspath %(from))),$(patsubst $(TOP)/%,%,$(abspath %(from)))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/%(from))))..."
152 @AROS_CC="%(cc)" $(MKDEPEND) %(flags) -I$(TOP)/$(CURDIR) -I$(SRCDIR)/$(CURDIR) %(from) -o %(to)
154 #------------------------------------------------------------------------------
157 #------------------------------------------------------------------------------
158 # Create one directory without any output
159 %define mkdir_q dir=.
160 @$(IF) $(TEST) ! -d %(dir) ; then $(MKDIR) %(dir) ; else $(NOP) ; fi
162 #------------------------------------------------------------------------------
165 #------------------------------------------------------------------------------
166 # Create several directories without any output
167 %define mkdirs_q dirs=/M
168 @$(FOR) dir in %(dirs) ; do \
169 $(IF) $(TEST) ! -d $$dir ; then $(MKDIR) $$dir ; else $(NOP) ; fi ; \
172 #------------------------------------------------------------------------------
175 #############################################################################
176 #############################################################################
178 ## Here are the mmakefile macros that are used to do certain tasks in a ##
179 ## mmakefile. They consist of one or more full makefile rules. ##
180 ## In general the files generated in these macros are also defined as ##
181 ## make targets so that they can be used as a dependency in other rules ##
183 #############################################################################
184 #############################################################################
186 #------------------------------------------------------------------------------
187 # Generate a unique id for each of the %build... rules
188 %define buildid targets=/A
190 ifneq ($(filter $(TARGET),%(targets)),)
191 BDTARGETID := $(BDID)
194 #------------------------------------------------------------------------------
197 #------------------------------------------------------------------------------
198 # Copy file %(from) to %(to) in a makefile rule
199 %define rule_copy from=/A to=/A
203 #------------------------------------------------------------------------------
206 #------------------------------------------------------------------------------
207 # Copy the files %(files) to %(targetdir). For each file in %(files),
208 # %(srcdir)/file is copied to %(targetdir)/file. The targetdir and the
209 # appropriate subdirs are not generated by this rule so they have to be
211 %define rule_copy_multi files=/A targetdir=/A srcdir=.
213 $(addprefix %(targetdir)/,%(files)) : %(targetdir)/% : %(srcdir)/%
216 #------------------------------------------------------------------------------
219 #------------------------------------------------------------------------------
220 # Copy the files %(files) to %(targetdir). For each file in %(files),
221 # %(srcdir)/file is copied to %(targetdir)/file if these files are different.
222 # %(stampfile) is used to keep track of when the last time the comparison has
223 # been done. The targetdir and the appropriate subdirs are not generated by
224 # this rule so they have to be present.
225 %define rule_copy_diff_multi files=/A targetdir=/A srcdir=. \
226 stampfile=$(TMP_SRCDIR)/.copy_stamp
228 TMP_SRCDIR := %(srcdir)
230 $(addprefix %(targetdir)/,%(files)) : | %(stampfile)
232 %(stampfile) : COPYSRCDIR := %(srcdir)
233 %(stampfile) : TGTDIR := %(targetdir)
234 %(stampfile) : FILES := %(files)
235 %(stampfile) : $(addprefix %(srcdir)/,%(files))
236 @for f in $(FILES); do \
237 $(IF) ! $(CMP) -s $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; then \
238 $(CP) $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; \
243 #------------------------------------------------------------------------------
246 #------------------------------------------------------------------------------
247 # Will join all the files in %(from) to %(to). When text is specified it will
249 # Restriction: at the moment when using a non-empty target dir %(from) may
251 %define rule_join to=/A from=/A text=
259 #------------------------------------------------------------------------------
262 #------------------------------------------------------------------------------
263 # Include the dependency files and add some internal rules
264 # When depstargets is provided the depencies will only be included when one of
265 # these targets is the $(TARGET). Otherwise the dependencies will only be
266 # included when the $(TARGET) is not for setup or clean
267 %define include_deps deps=$(DEPS)/M depstargets=
269 ifneq (%(depstargets),)
270 ifneq ($(findstring $(TARGET),%(depstargets)),)
274 ifeq (,$(filter clean% %clean %clean% setup% includes% %setup,$(TARGET)))
280 #------------------------------------------------------------------------------
283 #------------------------------------------------------------------------------
284 # Create the directories %(dirs). The creation will be done by adding rules to
285 # the %(setuptarget) make target with setup as the default.
286 %define rule_makedirs dirs=/A setuptarget=setup
288 %(setuptarget) :: %(dirs)
290 GLOB_MKDIRS += %(dirs)
293 #------------------------------------------------------------------------------
296 #------------------------------------------------------------------------------
297 # Generate a rule to compile a C source file to an object file and generate
298 # the dependency file. Basename may contain a directory part, then the source
299 # file has to be in that directory. The generated file will be put in the
300 # object directory without the directory.
302 # - basename: the basename of the file to compile. Use % for a wildcard rule
303 # - cflags (default $(CFLAGS)): the C flags to use for compilation
304 # - dflags: the flags used during creation of dependency file. If not specified
305 # the same value as cflags will be used
306 # - targetdir: the directory to put the .o file and the .d file. By default
307 # it is put in the same directory as the .c file
308 %define rule_compile mmake=TMP basename=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= targetdir= compiler=target
310 %(mmake)_NIXFLAG ?= -nix
313 %(mmake)_TARGETBASE := %(basename)
315 %(mmake)_TARGETBASE := %(targetdir)/$(notdir %(basename))
318 # Adjust compiler flags to suit C
319 %(mmake)_C_CPPFLAGS := %(cppflags)
320 %(mmake)_CFLAGS := %(cflags)
321 %(mmake)_CFLAGS := $(subst -fpermissive,, $(%(mmake)_CFLAGS))
323 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
325 %(mmake)_DFLAGS := %(dflags)
328 ifeq ($(findstring %(compiler),host kernel target),)
329 $(error unknown compiler %(compiler))
331 ifeq (%(compiler),target)
332 %(mmake)_LINK ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
333 %(mmake)_STRIP ?= $(TARGET_STRIP)
334 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
335 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
336 $(%(mmake)_TARGETBASE).o : %(mmake)_C_CPPFLAGS:=$(%(mmake)_C_CPPFLAGS)
337 $(%(mmake)_TARGETBASE).d : %(mmake)_C_CPPFLAGS:=$(%(mmake)_C_CPPFLAGS)
338 $(%(mmake)_TARGETBASE).o : %(mmake)_CFLAGS:=$(strip $(%(mmake)_CFLAGS) $(SAFETY_CFLAGS))
339 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(%(mmake)_DFLAGS)
340 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
341 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
342 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
343 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
345 ifeq (%(compiler),host)
346 %(mmake)_LINK ?= $(strip $(HOST_CC) $(HOST_LDFLAGS))
347 %(mmake)_STRIP ?= $(HOST_STRIP)
348 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(HOST_CC)
349 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(HOST_CC)
350 $(%(mmake)_TARGETBASE).o : %(mmake)_C_CPPFLAGS:=$(strip $(HOST_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS))
351 $(%(mmake)_TARGETBASE).d : %(mmake)_C_CPPFLAGS:=$(strip $(HOST_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS))
352 $(%(mmake)_TARGETBASE).o : %(mmake)_CFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_CFLAGS))
353 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_DFLAGS))
354 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
355 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
356 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
357 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
359 ifeq (%(compiler),kernel)
360 %(mmake)_LINK ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
361 %(mmake)_STRIP ?= $(ECHO) >/dev/null
362 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
363 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
364 $(%(mmake)_TARGETBASE).o : %(mmake)_C_CPPFLAGS:=$(strip $(KERNEL_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS))
365 $(%(mmake)_TARGETBASE).d : %(mmake)_C_CPPFLAGS:=$(strip $(KERNEL_C_CPPFLAGS) $(%(mmake)_C_CPPFLAGS))
366 $(%(mmake)_TARGETBASE).o : %(mmake)_CFLAGS:=$(strip $(ISA_FLAGS) $(KERNEL_CFLAGS) $(%(mmake)_CFLAGS))
367 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(strip $(ISA_FLAGS) $(KERNEL_CFLAGS) $(%(mmake)_DFLAGS))
368 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
369 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
370 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
371 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
374 $(%(mmake)_TARGETBASE).o : CPPFLAGS := $(%(mmake)_C_CPPFLAGS)
375 $(%(mmake)_TARGETBASE).o : CFLAGS := $(%(mmake)_CFLAGS)
376 $(%(mmake)_TARGETBASE).o : %(basename).c
377 %compile_q cmd=$(%(mmake)_CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
380 $(%(mmake)_TARGETBASE).d : %(mmake)_DFLAGS:=$(strip $(%(mmake)_NIXFLAG) $(%(mmake)_DFLAGS))
382 $(%(mmake)_TARGETBASE).d : %(basename).c
383 %mkdepend_q cc=$(%(mmake)_CMD) flags="$(strip $(%(mmake)_DFLAGS) $(%(mmake)_C_CPPFLAGS))"
385 #------------------------------------------------------------------------------
388 #------------------------------------------------------------------------------
389 # Generate a rule to compile a C++ source file to an object file and generate
390 # the dependency file. Basename may contain a directory part, then the source
391 # file has to be in that directory. The generated file will be put in the
392 # object directory without the directory.
394 # - basename: the basename of the file to compile. Use % for a wildcard rule
395 # - cflags (default $(CFLAGS)): the C flags to use for compilation
396 # - dflags: the flags used during creation of dependency file. If not specified
397 # the same value as cflags will be used
398 # - targetdir: the directory to put the .o file and the .d file. By default
399 # it is put in the same directory as the .c file
400 %define rule_compile_cxx mmake=TMP basename=/A cppflags=$(CPPFLAGS) cxxflags=$(CXXFLAGS) dxxflags= targetdir= compiler=target
403 %(mmake)_NIXFLAG ?= -nix
405 %(mmake)_TARGETBASE := %(basename)
407 %(mmake)_TARGETBASE := %(targetdir)/$(notdir %(basename))
410 # Adjust compiler flags to suit C++
411 %(mmake)_CXX_CPPFLAGS := %(cppflags)
412 %(mmake)_CXXFLAGS := %(cxxflags)
414 %(mmake)_DXXFLAGS := %(cxxflags)
416 %(mmake)_DXXFLAGS := %(dxxflags)
419 ifeq ($(findstring %(compiler),host kernel target),)
420 $(error unknown compiler %(compiler))
422 ifeq (%(compiler),target)
423 %(mmake)_LINK ?= $(strip $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
424 %(mmake)_STRIP ?= $(TARGET_STRIP)
425 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(AROS_CXX) $(TARGET_SYSROOT))
426 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(AROS_CXX) $(TARGET_SYSROOT))
427 $(%(mmake)_TARGETBASE).o : %(mmake)_CXX_CPPFLAGS:=$(%(mmake)_CXX_CPPFLAGS)
428 $(%(mmake)_TARGETBASE).d : %(mmake)_CXX_CPPFLAGS:=$(%(mmake)_CXX_CPPFLAGS)
429 $(%(mmake)_TARGETBASE).o : %(mmake)_CXXFLAGS:=$(strip $(%(mmake)_CXXFLAGS) $(SAFETY_CFLAGS))
430 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(%(mmake)_DXXFLAGS)
431 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
432 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
433 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
434 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
436 ifeq (%(compiler),host)
437 %(mmake)_LINK ?= $(strip $(HOST_CXX) $(HOST_LDFLAGS))
438 %(mmake)_STRIP ?= $(HOST_STRIP)
439 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(HOST_CXX)
440 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(HOST_CXX)
441 $(%(mmake)_TARGETBASE).o : %(mmake)_CXX_CPPFLAGS:=$(strip $(HOST_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS))
442 $(%(mmake)_TARGETBASE).d : %(mmake)_CXX_CPPFLAGS:=$(strip $(HOST_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS))
443 $(%(mmake)_TARGETBASE).o : %(mmake)_CXXFLAGS:=$(strip $(HOST_CXXFLAGS) $(%(mmake)_CXXFLAGS))
444 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(strip $(HOST_CXXFLAGS) $(%(mmake)_DXXFLAGS))
445 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
446 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
447 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
448 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
450 ifeq (%(compiler),kernel)
451 KERNEL_CXX ?= $(KERNEL_CC)
452 %(mmake)_LINK ?= $(strip $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
453 %(mmake)_STRIP ?= $(ECHO) >/dev/null
454 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))
455 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))
456 $(%(mmake)_TARGETBASE).o : %(mmake)_CXX_CPPFLAGS:=$(strip $(KERNEL_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS))
457 $(%(mmake)_TARGETBASE).d : %(mmake)_CXX_CPPFLAGS:=$(strip $(KERNEL_CXX_CPPFLAGS) $(%(mmake)_CXX_CPPFLAGS))
458 $(%(mmake)_TARGETBASE).o : %(mmake)_CXXFLAGS:=$(strip $(KERNEL_CXXFLAGS) $(%(mmake)_CXXFLAGS))
459 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(strip $(KERNEL_CXXFLAGS) $(%(mmake)_DXXFLAGS))
460 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
461 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
462 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
463 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
466 $(%(mmake)_TARGETBASE).o : CPPFLAGS := $(%(mmake)_CXX_CPPFLAGS)
467 $(%(mmake)_TARGETBASE).o : CXXFLAGS := $(%(mmake)_CXXFLAGS)
468 $(%(mmake)_TARGETBASE).o : %(basename).cpp
469 %compile_q cmd=$(%(mmake)_CMD) opt="$(strip $(CXXFLAGS) $(CPPFLAGS))" iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
472 $(%(mmake)_TARGETBASE).d : %(mmake)_DXXFLAGS:=$(strip $(%(mmake)_NIXFLAG) $(%(mmake)_DXXFLAGS))
474 $(%(mmake)_TARGETBASE).d : %(basename).cpp
475 %mkdepend_q cc=$(%(mmake)_CMD) flags="$(strip $(%(mmake)_DXXFLAGS) $(%(mmake)_CXX_CPPFLAGS))"
480 #------------------------------------------------------------------------------
483 #------------------------------------------------------------------------------
484 # Generate a rule to compile an ObjC source file to an object file and generate
485 # the dependency file. Basename may contain a directory part, then the source
486 # file has to be in that directory. The generated file will be put in the
487 # object directory without the directory.
489 # - basename: the basename of the file to compile. Use % for a wildcard rule
490 # - cflags (default $(CFLAGS)): the C flags to use for compilation
491 # - dflags: the flags used during creation of dependency file. If not specified
492 # the same value as cflags will be used
493 # - targetdir: the directory to put the .o file and the .d file. By default
494 # it is put in the same directory as the .m file
495 %define rule_compile_objc mmake=TMP basename=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= targetdir= compiler=target
498 %(mmake)_NIXFLAG ?= -nix
500 %(mmake)_TARGETBASE := %(basename)
502 %(mmake)_TARGETBASE := %(targetdir)/$(notdir %(basename))
505 # Adjust compiler flags to suit ObjC
506 %(mmake)_OBJC_CPPFLAGS := %(cppflags)
507 %(mmake)_OBJCFLAGS := %(cflags)
508 %(mmake)_OBJCFLAGS := $(%(mmake)_OBJCFLAGS) -isystem $(AROS_DEVELOPER)/include
509 %(mmake)_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(%(mmake)_OBJCFLAGS)))
511 %(mmake)_OBJCDFLAGS := %(cflags)
513 %(mmake)_OBJCDFLAGS := %(dflags)
516 # Define the use of cross compiler
517 ifeq ($(TARGET_OBJC),)
518 %(mmake)_CC := $(TARGET_CC)
520 %(mmake)_CC := $(TARGET_OBJC)
523 ifeq ($(findstring %(compiler),host kernel target),)
524 $(error unknown compiler %(compiler))
526 ifeq (%(compiler),target)
527 %(mmake)_LINK ?= $(strip $(%(mmake)_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
528 %(mmake)_STRIP ?= $(TARGET_STRIP)
529 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(%(mmake)_CC) $(TARGET_SYSROOT))
530 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(%(mmake)_CC) $(TARGET_SYSROOT))
531 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJC_CPPFLAGS:=$(%(mmake)_OBJC_CPPFLAGS)
532 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJC_CPPFLAGS:=$(%(mmake)_OBJC_CPPFLAGS)
533 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJCFLAGS:=$(strip $(%(mmake)_OBJCFLAGS) $(SAFETY_CFLAGS))
534 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(%(mmake)_OBJCDFLAGS)
535 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
536 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
537 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
538 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
540 ifeq (%(compiler),host)
541 %(mmake)_LINK ?= $(strip $(HOST_CC) $(HOST_LDFLAGS))
542 %(mmake)_STRIP ?= $(HOST_STRIP)
543 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(HOST_CC)
544 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(HOST_CC)
545 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJC_CPPFLAGS:=$(strip $(HOST_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS))
546 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJC_CPPFLAGS:=$(strip $(HOST_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS))
547 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJCFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCFLAGS))
548 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCDFLAGS))
549 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
550 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
551 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
552 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
554 ifeq (%(compiler),kernel)
555 %(mmake)_LINK ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
556 %(mmake)_STRIP ?= $(ECHO) >/dev/null
557 $(%(mmake)_TARGETBASE).o : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
558 $(%(mmake)_TARGETBASE).d : %(mmake)_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
559 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJC_CPPFLAGS:=$(strip $(KERNEL_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS))
560 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJC_CPPFLAGS:=$(strip $(KERNEL_OBJC_CPPFLAGS) $(%(mmake)_OBJC_CPPFLAGS))
561 $(%(mmake)_TARGETBASE).o : %(mmake)_OBJCFLAGS:=$(strip $(ISA_FLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCFLAGS))
562 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(strip $(ISA_FLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCDFLAGS))
563 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
564 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
565 $(%(mmake)_TARGETBASE).o : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
566 $(%(mmake)_TARGETBASE).d : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
569 $(%(mmake)_TARGETBASE).o : CPPFLAGS := $(%(mmake)_OBJC_CPPFLAGS)
570 $(%(mmake)_TARGETBASE).o : CFLAGS := $(%(mmake)_OBJCFLAGS)
571 $(%(mmake)_TARGETBASE).o : %(basename).m
572 %compile_q cmd=$(%(mmake)_CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
575 $(%(mmake)_TARGETBASE).d : %(mmake)_OBJCDFLAGS:=$(strip $(%(mmake)_NIXFLAG) $(%(mmake)_OBJCDFLAGS))
577 $(%(mmake)_TARGETBASE).d : %(basename).m
578 %mkdepend_q cc=$(%(mmake)_CMD) flags="$(strip $(%(mmake)_OBJCDFLAGS) $(%(mmake)_OBJC_CPPFLAGS))"
583 #------------------------------------------------------------------------------
586 #------------------------------------------------------------------------------
587 # Generate a rule to compile multiple C source files to an object file and
588 # generate the corresponding dependency files. The generated file will be put
589 # in the object directory without the directory part of the source file.
591 # - basenames: the basenames of the files to compile. The names may include
592 # relative or absolute path names. No wildcard is allowed
593 # - cflags (default $(CFLAGS)): the C flags to use for compilation
594 # - dflags: the flags used during creation of dependency file. If not specified
595 # the same value as cflags will be used
596 # - targetdir: the directory to put the .o file and the .d file. By default
597 # it is put in the same directory as the .c file. When targetdir is not
598 # empty, path names will be stripped from the file names so that all files
599 # are in that dir and not in subdirectories.
600 # - compiler (default target): compiler to use, target, kernel or host
601 %define rule_compile_multi mmake=TMP basenames=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= srcdir= targetdir= \
605 %(mmake)_MC_SRCWILDCARD := %
607 %(mmake)_MC_SRCWILDCARD := %(srcdir)/%
611 %(mmake)_MC_TARGETS := $(addsuffix .o,%(basenames))
612 %(mmake)_MC_DTARGETS := $(addsuffix .d,%(basenames))
613 %(mmake)_MC_TGTWILDCARD := %
615 %(mmake)_MC_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
616 %(mmake)_MC_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
617 %(mmake)_MC_TGTWILDCARD := %(targetdir)/%
619 # Be sure that all .c files are generated
620 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : | $(addsuffix .c,%(basenames))
622 # Be sure that all .c files are found
623 %(mmake)_MC_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
624 %(mmake)_MC_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
625 %(mmake)_MC_DIRS := $(foreach dir, $(%(mmake)_MC_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(%(mmake)_MC_SRCDIR)/$(CURDIR)/$(dir)))
626 ifneq ($(%(mmake)_MC_DIRS),)
627 %(mmake)_MC_DIRS := $(shell echo $(%(mmake)_MC_DIRS) | sed 's/\(.\):\//\/\1\//g')
628 vpath %.c $(%(mmake)_MC_DIRS)
633 %(mmake)_MC_CPPFLAGS := %(cppflags)
634 %(mmake)_CFLAGS := %(cflags)
636 %(mmake)_DFLAGS := %(cflags)
638 %(mmake)_DFLAGS := %(dflags)
641 ifeq ($(findstring %(compiler),host kernel target),)
642 $(error unknown compiler %(compiler))
644 ifeq (%(compiler),target)
645 %(mmake)_LINK ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
646 %(mmake)_STRIP ?= $(TARGET_STRIP)
647 %(mmake)_ASSEMBLER ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT))
648 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
649 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_MC_CPPFLAGS:=$(%(mmake)_MC_CPPFLAGS)
650 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_CFLAGS:=$(strip $(%(mmake)_CFLAGS) $(SAFETY_CFLAGS))
651 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_DFLAGS:=$(%(mmake)_DFLAGS)
652 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
653 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
655 ifeq (%(compiler),host)
656 %(mmake)_LINK ?= $(strip $(HOST_CC) $(HOST_LDFLAGS))
657 %(mmake)_STRIP ?= $(HOST_STRIP)
658 %(mmake)_ASSEMBLER ?= $(strip $HOST_CC) $(HOST_SYSROOT))
659 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : CMD:=$(HOST_CC)
660 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_MC_CPPFLAGS:=$(strip $(HOST_MC_CPPFLAGS) $(%(mmake)_MC_CPPFLAGS))
661 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_CFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_CFLAGS))
662 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_DFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_DFLAGS))
663 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
664 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
666 ifeq (%(compiler),kernel)
667 %(mmake)_LINK ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
668 %(mmake)_STRIP ?= $(ECHO) >/dev/null
669 %(mmake)_ASSEMBLER ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
670 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
671 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_MC_CPPFLAGS:=$(strip $(KERNEL_MC_CPPFLAGS) $(%(mmake)_MC_CPPFLAGS))
672 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_CFLAGS:=$(strip $(ISA_FLAGS) $(KERNEL_CFLAGS) $(%(mmake)_CFLAGS))
673 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_DFLAGS:=$(strip $(ISA_FLAGS) $(KERNEL_CFLAGS) $(%(mmake)_DFLAGS))
674 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
675 $(%(mmake)_MC_TARGETS) $(%(mmake)_MC_DTARGETS) : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
678 $(%(mmake)_MC_TARGETS) : CPPFLAGS := $(%(mmake)_MC_CPPFLAGS)
679 $(%(mmake)_MC_TARGETS) : CFLAGS := $(%(mmake)_CFLAGS)
680 $(%(mmake)_MC_TARGETS) : $(%(mmake)_MC_TGTWILDCARD).o : $(%(mmake)_MC_SRCWILDCARD).c
681 %compile_q cmd=$(CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
683 $(%(mmake)_MC_DTARGETS) : $(%(mmake)_MC_TGTWILDCARD).d : $(%(mmake)_MC_SRCWILDCARD).c
684 %mkdepend_q cc=$(CMD) flags="$(strip $(%(mmake)_DFLAGS) $(%(mmake)_MC_CPPFLAGS))"
686 #------------------------------------------------------------------------------
689 #------------------------------------------------------------------------------
690 # Generate a rule to compile multiple C++ source files to an object file and
691 # generate the corresponding dependency files. The generated file will be put
692 # in the object directory without the directory part of the source file.
694 # - basenames: the basenames of the files to compile. The names may include
695 # relative or absolute path names. No wildcard is allowed. basenames will be
696 # matched to supported AROS_CXXEXTS.
697 # - cflags (default $(CFLAGS)): the C flags to use for compilation
698 # - dflags: the flags used during creation of dependency file. If not specified
699 # the same value as cflags will be used
700 # - targetdir: the directory to put the .o file and the .d file. By default
701 # it is put in the same directory as the .c file. When targetdir is not
702 # empty, path names will be stripped from the file names so that all files
703 # are in that dir and not in subdirectories.
704 # - compiler (default target): compiler to use, target, kernel or host
705 %define rule_compile_cxx_multi mmake=TMP basenames=/A cppflags=$(CPPFLAGS) cxxflags=$(CXXFLAGS) dxxflags= \
706 targetdir= compiler=target
708 %(mmake)_CXXABSBASENAMES := $(foreach %(mmake)_CXXBASE,%(basenames),$(if $(filter /%,$(%(mmake)_CXXBASE)),$(%(mmake)_CXXBASE),$(abspath $(SRCDIR)/$(CURDIR)/$(%(mmake)_CXXBASE))))
710 ifneq ($(%(mmake)_CXXABSBASENAMES),)
712 %(mmake)_CXXBASENAMES := $(basename $(%(mmake)_CXXABSBASENAMES))
714 # Identify the "real" c++ files from the passed in basenames
715 %(mmake)_MCXX_FILES := $(strip $(foreach %(mmake)_CXXBASE,$(%(mmake)_CXXABSBASENAMES), $(firstword $(wildcard $(foreach %(mmake)_EXT, $(AROS_CXXEXTS),$(addsuffix .$(%(mmake)_EXT),$(%(mmake)_CXXBASE)))))))
718 %(mmake)_CXXTARGETS := $(notdir $(%(mmake)_CXXBASENAMES:=.o))
719 %(mmake)_CXXDTARGETS := $(notdir $(%(mmake)_CXXBASENAMES:=.d))
720 %(mmake)_MCXX_WILDCARD := %
722 %(mmake)_CXXTARGETS := $(addprefix %(targetdir)/,$(notdir $(%(mmake)_CXXBASENAMES:=.o)))
723 %(mmake)_CXXDTARGETS := $(addprefix %(targetdir)/,$(notdir $(%(mmake)_CXXBASENAMES:=.d)))
724 %(mmake)_MCXX_WILDCARD := %(targetdir)/%
726 # Be sure that all source files are generated
727 $(%(mmake)_CXXTARGETS) $(%(mmake)_CXXDTARGETS) : | $(%(mmake)_MCXX_FILES)
730 # Adjust compiler flags to suit C++
731 %(mmake)_MCXX_CPPFLAGS := %(cppflags)
732 %(mmake)_CXXFLAGS := %(cxxflags)
734 %(mmake)_DXXFLAGS := %(cxxflags)
736 %(mmake)_DXXFLAGS := %(dxxflags)
739 ifeq ($(findstring %(compiler),host kernel target),)
740 $(error unknown compiler %(compiler))
742 ifeq (%(compiler),host)
743 %(mmake)_LINK ?= $(strip $(HOST_CXX) $(HOST_LDFLAGS))
744 %(mmake)_STRIP ?= $(HOST_STRIP)
745 %(mmake)_ASSEMBLER ?= $(strip $(HOST_CC) $(HOST_SYSROOT))
746 %(mmake)_CXXCMD:=$(HOST_CXX)
747 %(mmake)_MCXX_CPPFLAGS := $(strip $(HOST_MCXX_CPPFLAGS) $(%(mmake)_MCXX_CPPFLAGS))
748 %(mmake)_CXXFLAGS := $(strip $(HOST_CXXFLAGS) $(%(mmake)_CXXFLAGS))
749 %(mmake)_DXXFLAGS := $(strip $(HOST_CXXFLAGS) $(%(mmake)_DXXFLAGS))
750 %(mmake)_CXXIQUOTE:=$(HOST_IQUOTE)
751 %(mmake)_CXXIQUOTE_END:=$(HOST_IQUOTE_END)
753 ifeq (%(compiler),target)
754 %(mmake)_LINK ?= $(strip $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
755 %(mmake)_STRIP ?= $(TARGET_STRIP)
756 %(mmake)_ASSEMBLER ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT))
757 %(mmake)_CXXCMD:=$(strip $(AROS_CXX) $(TARGET_SYSROOT))
758 %(mmake)_MCXX_CPPFLAGS := $(%(mmake)_MCXX_CPPFLAGS)
759 %(mmake)_CXXFLAGS := $(strip $(%(mmake)_CXXFLAGS) $(SAFETY_CFLAGS))
760 %(mmake)_DXXFLAGS := $(%(mmake)_DXXFLAGS)
761 %(mmake)_CXXIQUOTE:=$(CFLAGS_IQUOTE)
762 %(mmake)_CXXIQUOTE_END:=$(CFLAGS_IQUOTE_END)
764 ifeq (%(compiler),kernel)
765 KERNEL_CXX ?= $(KERNEL_CC)
766 %(mmake)_LINK ?= $(strip $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
767 %(mmake)_STRIP ?= $(ECHO) >/dev/null
768 %(mmake)_ASSEMBLER ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
769 %(mmake)_CXXCMD:=$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))
770 %(mmake)_CXXFLAGS := $(strip $(KERNEL_MCXX_CPPFLAGS) $(%(mmake)_MCXX_CPPFLAGS))
771 %(mmake)_CXXFLAGS := $(strip $(KERNEL_CXXFLAGS) $(%(mmake)_CXXFLAGS))
772 %(mmake)_DXXFLAGS := $(strip $(KERNEL_CXXFLAGS) $(%(mmake)_DXXFLAGS))
773 %(mmake)_CXXIQUOTE:=$(KERNEL_IQUOTE)
774 %(mmake)_CXXIQUOTE_END:=$(KERNEL_IQUOTE_END)
777 define cxx_multi_recipe_template
779 %compile_q cmd=$(%(mmake)_CXXCMD) opt="$(strip $(%(mmake)_CXXFLAGS) $(%(mmake)_MCXX_CPPFLAGS))" iquote=$(%(mmake)_CXXIQUOTE) iquote_end=$(%(mmake)_CXXIQUOTE_END) from=$(2) to=$(1).o
782 %mkdepend_q cc=$(%(mmake)_CXXCMD) flags="$(strip $(%(mmake)_DXXFLAGS) $(%(mmake)_MCXX_CPPFLAGS))" from=$(2) to=$(1).d
785 $(foreach %(mmake)_CXXFILE,$(%(mmake)_MCXX_FILES),$(eval $(call cxx_multi_recipe_template,$(notdir $(basename $(%(mmake)_CXXFILE))),$(%(mmake)_CXXFILE))))
787 $(foreach %(mmake)_CXXFILE,$(%(mmake)_MCXX_FILES),$(eval $(call cxx_multi_recipe_template,$(addprefix %(targetdir)/,$(notdir $(basename $(%(mmake)_CXXFILE)))),$(%(mmake)_CXXFILE))))
793 #------------------------------------------------------------------------------
796 #------------------------------------------------------------------------------
797 # Generate a rule to compile multiple ObjC source files to an object file and
798 # generate the corresponding dependency files. The generated file will be put
799 # in the object directory without the directory part of the source file.
801 # - basenames: the basenames of the files to compile. The names may include
802 # relative or absolute path names. No wildcard is allowed
803 # - cflags (default $(CFLAGS)): the C flags to use for compilation
804 # - dflags: the flags used during creation of dependency file. If not specified
805 # the same value as cflags will be used
806 # - targetdir: the directory to put the .o file and the .d file. By default
807 # it is put in the same directory as the .m file. When targetdir is not
808 # empty, path names will be stripped from the file names so that all files
809 # are in that dir and not in subdirectories.
810 # - compiler (default target): compiler to use, target, kernel or host
811 %define rule_compile_objc_multi mmake=TMP basenames=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= \
812 targetdir= compiler=target
814 ifneq (%(basenames),)
817 %(mmake)_MOBJC_TARGETS := $(addsuffix .o,%(basenames))
818 %(mmake)_MOBJC_DTARGETS := $(addsuffix .d,%(basenames))
819 %(mmake)_MOBJC_WILDCARD := %
821 %(mmake)_MOBJC_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,%(basenames)))
822 %(mmake)_MOBJC_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,%(basenames)))
823 %(mmake)_MOBJC_WILDCARD := %(targetdir)/%
825 # Be sure that all .m files are generated
826 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : | $(addsuffix .m,%(basenames))
828 # Be sure that all .m files are found
829 %(mmake)_MOBJC_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
830 %(mmake)_MOBJC_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
831 %(mmake)_MOBJC_DIRS := $(foreach dir, $(%(mmake)_MOBJC_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(%(mmake)_MOBJC_SRCDIR)/$(CURDIR)/$(dir)))
832 ifneq ($(%(mmake)_MOBJC_DIRS),)
833 %(mmake)_MOBJC_DIRS := $(shell echo $(%(mmake)_MOBJC_DIRS) | sed 's/\(.\):\//\/\1\//g')
834 vpath %.m $(%(mmake)_MOBJC_DIRS)
838 # Define the use of cross compiler
839 ifeq ($(TARGET_OBJC),)
840 %(mmake)_CC := $(TARGET_CC)
842 %(mmake)_CC := $(TARGET_OBJC)
845 # Adjust compiler flags to suit ObjC
846 %(mmake)_MOBJC_CPPFLAGS := %(cppflags)
847 %(mmake)_OBJCFLAGS := %(cflags)
848 %(mmake)_OBJCFLAGS := $(%(mmake)_OBJCFLAGS) -isystem $(AROS_DEVELOPER)/include
849 %(mmake)_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(%(mmake)_OBJCFLAGS)))
851 %(mmake)_OBJCDFLAGS := %(cflags)
853 %(mmake)_OBJCDFLAGS := %(dflags)
856 ifeq ($(findstring %(compiler),host kernel target),)
857 $(error unknown compiler %(compiler))
859 ifeq (%(compiler),target)
860 %(mmake)_LINK ?= $(strip $(%(mmake)_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS))
861 %(mmake)_STRIP ?= $(TARGET_STRIP)
862 %(mmake)_ASSEMBLER ?= $(strip $(TARGET_CC) $(TARGET_SYSROOT))
863 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : CMD:=$(strip $(%(mmake)_CC) $(TARGET_SYSROOT))
864 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_MOBJC_CPPFLAGS:=$(%(mmake)_MOBJC_CPPFLAGS)
865 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCFLAGS:=$(strip $(%(mmake)_OBJCFLAGS) $(SAFETY_CFLAGS))
866 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCDFLAGS:=$(%(mmake)_OBJCDFLAGS)
867 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE:=$(CFLAGS_IQUOTE)
868 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
870 ifeq (%(compiler),host)
871 %(mmake)_LINK ?= $(strip $(HOST_OBJC) $(HOST_LDFLAGS))
872 %(mmake)_STRIP ?= $(HOST_STRIP)
873 %(mmake)_ASSEMBLER ?= $(strip $(HOST_CC) $(HOST_SYSROOT))
874 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : CMD:=$(HOST_OBJC)
875 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_MOBJC_CPPFLAGS:=$(strip $(HOST_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_CPPFLAGS))
876 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCFLAGS))
877 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCDFLAGS:=$(strip $(HOST_CFLAGS) $(%(mmake)_OBJCDFLAGS))
878 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE:=$(HOST_IQUOTE)
879 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE_END:=$(HOST_IQUOTE_END)
881 ifeq (%(compiler),kernel)
882 KERNEL_OBJC ?= $(KERNEL_CC)
883 %(mmake)_LINK ?= $(strip $(KERNEL_OBJC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS))
884 %(mmake)_STRIP ?= $(ECHO) >/dev/null
885 %(mmake)_ASSEMBLER ?= $(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
886 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : CMD:=$(strip $(KERNEL_OBJC) $(KERNEL_SYSROOT))
887 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_MOBJC_CPPFLAGS:=$(strip $(KERNEL_MOBJC_CPPFLAGS) $(%(mmake)_MOBJC_CPPFLAGS))
888 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCFLAGS:=$(strip $(ISA_FLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCFLAGS))
889 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_OBJCDFLAGS:=$(strip $(ISA_FLAGS) $(KERNEL_CFLAGS) $(%(mmake)_OBJCDFLAGS))
890 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE:=$(KERNEL_IQUOTE)
891 $(%(mmake)_MOBJC_TARGETS) $(%(mmake)_MOBJC_DTARGETS) : %(mmake)_IQUOTE_END:=$(KERNEL_IQUOTE_END)
894 $(%(mmake)_MOBJC_TARGETS) : CPPFLAGS := $(%(mmake)_MOBJC_CPPFLAGS)
895 $(%(mmake)_MOBJC_TARGETS) : CFLAGS := $(%(mmake)_OBJCFLAGS)
896 $(%(mmake)_MOBJC_TARGETS) : $(%(mmake)_MOBJC_WILDCARD).o : %.m
897 %compile_q cmd=$(CMD) iquote=$(%(mmake)_IQUOTE) iquote_end=$(%(mmake)_IQUOTE_END)
899 $(%(mmake)_MOBJC_DTARGETS) : $(%(mmake)_MOBJC_WILDCARD).d : %.m
900 %mkdepend_q cc=$(CMD) flags="$(strip $(%(mmake)_OBJCDFLAGS) $(%(mmake)_MOBJC_CPPFLAGS))"
905 #------------------------------------------------------------------------------
908 #------------------------------------------------------------------------------
909 # Make an alias from one arch specific build to another arch.
911 # - mainmmake: the mmake of the module in the main tree
912 # - arch: the current arch
913 # - alias: the alias to which this should point
914 %define rule_archalias mainmmake=\A arch=\A alias=\A
916 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
918 #------------------------------------------------------------------------------
921 #------------------------------------------------------------------------------
922 # Generate a rule to assemble a source file to an object file. Basename may
923 # contain a directory part, then the source file has to be in that directory.
924 # The generated file will be put in the object directory without the directory.
926 # - basename: the basename of the file to compile. Use % for a wildcard rule
927 # - flags (default $(AFLAGS)): the asm flags to use for assembling
928 # - targetdir: the directory to put the .o file in. By default it is put in the
929 # same directory as the .s file
930 %define rule_assemble basename=/A cppflags=$(CPPFLAGS) aflags=$(AFLAGS) targetdir=
933 %(basename).o : CPPFLAGS := %(cppflags)
934 %(basename).o : AFLAGS := %(aflags)
935 %(basename).o : %(basename).s
937 %(basename).o : %(basename).S
941 %(targetdir)/$(notdir %(basename)).o : CPPFLAGS := %(cppflags)
942 %(targetdir)/$(notdir %(basename)).o : AFLAGS := %(aflags)
943 %(targetdir)/$(notdir %(basename)).o : %(basename).s
945 %(targetdir)/$(notdir %(basename)).o : %(basename).S
950 #------------------------------------------------------------------------------
953 #------------------------------------------------------------------------------
954 # Generate a rule to assemble multiple source files to an object file. The
955 # generated file will be put in the object directory with the directory part
956 # of the source file stripped off.
958 # - basenames: the basenames of the files to compile. The names may include
959 # relative or absolute path names. No wildcard is allowed
960 # - aflags (default $(AFLAGS)): the flags to use for assembly
961 # - targetdir: the directory to put the .o file and the .d file. By default
962 # it is put in the same directory as the .c file. When targetdir is not
963 # empty, path names will be stripped from the file names so that all files
964 # are in that dir and not in subdirectories.
965 %define rule_assemble_multi mmake=TMP cmd="$(strip $(CC) $(TARGET_SYSROOT))" basenames=/A cppflags=$(CPPFLAGS) aflags=$(AFLAGS) targetdir= suffix=.s
968 %(mmake)-MA_TARGETS := $(addsuffix .o,%(basenames))
969 %(mmake)-MA_WILDCARD := %
971 %(mmake)-MA_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
972 %(mmake)-MA_WILDCARD := %(targetdir)/%
974 # Be sure that all .s files are generated
975 $(%(mmake)-MA_TARGETS) : | $(addsuffix %(suffix),%(basenames))
977 # Be sure that all .c files are found
978 %(mmake)-MA_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
979 %(mmake)-MA_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
980 %(mmake)-MA_DIRS := $(foreach dir, $(%(mmake)-MA_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(%(mmake)-MA_SRCDIR)/$(CURDIR)/$(dir)))
981 ifneq ($(%(mmake)-MA_DIRS),)
982 %(mmake)-MA_DIRS := $(shell echo $(%(mmake)-MA_DIRS) | sed 's/\(.\):\//\/\1\//g')
983 vpath %%(suffix) $(%(mmake)-MA_DIRS)
988 %(mmake)-MA_ASSEMBLER ?= %(cmd)
990 $(%(mmake)-MA_TARGETS) : %(mmake)-MA_CMD:= $(%(mmake)-MA_ASSEMBLER)
992 $(%(mmake)-MA_TARGETS) : CPPFLAGS := %(cppflags)
993 $(%(mmake)-MA_TARGETS) : AFLAGS := %(aflags)
994 $(%(mmake)-MA_TARGETS) : $(%(mmake)-MA_WILDCARD).o : %%(suffix)
995 %assemble_q cmd=$(%(mmake)-MA_CMD)
997 #------------------------------------------------------------------------------
1000 #------------------------------------------------------------------------------
1001 # Link %(objs) to %(prog) using the libraries in %(uselibs)
1002 %define rule_link_prog mmake=TMP prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
1003 usehostlibs= usestartup=yes detach=no nix=no cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" strip=$(TARGET_STRIP) objdir=$(GENDIR)/$(CURDIR) coverageinstr=$(TARGET_COVERAGEINSTR)
1005 %(mmake)-link_EXTRA_LDFLAGS :=
1006 %(mmake)-link_EXTRA_LIBS :=
1008 %(mmake)-link_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
1010 ifeq (%(usestartup),no)
1011 %(mmake)-link_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
1013 ifeq (%(detach),yes)
1014 %(mmake)-link_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
1017 # Make a list of the lib files this program depends on.
1018 # In LDFLAGS remove white space between -L and directory
1019 %(mmake)-link_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
1020 # Filter out only the libdirs and remove -L
1021 %(mmake)-link_DIRS := $(patsubst -L%,%,$(filter -L%,$(%(mmake)-link_DIRS)))
1023 %(mmake)-link_DIRS := $(subst //,/,$(addsuffix /,$(%(mmake)-link_DIRS)))
1024 # Add normal linklib path
1025 %(mmake)-link_DIRS += $(AROS_LIB)/
1026 # add lib and .a to static linklib names
1027 %(mmake)-link_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(%(mmake)-link_EXTRA_LIBS)))
1028 ifeq (%(usestartup),yes)
1029 %(mmake)-link_LIBS += startup.o
1031 ifeq (%(detach),yes)
1032 %(mmake)-link_LIBS += detach.o
1034 # search for the linklibs in the given path, ignore ones not found
1035 %(mmake)-link_DEPLIBS := $(foreach lib,$(%(mmake)-link_LIBS), \
1036 $(firstword $(wildcard $(addsuffix $(lib),$(%(mmake)-link_DIRS)))) \
1039 %(prog) : OBJDIR := %(objdir)
1040 %(prog) : OBJS := %(objs)
1041 %(prog) : LDFLAGS := $(strip %(ldflags) $(%(mmake)-link_EXTRA_LDFLAGS))
1042 %(prog) : LIBS := $(addprefix -l,%(uselibs) $(%(mmake)-link_EXTRA_LIBS) %(usehostlibs))
1043 %(prog) : %(objs) $(%(mmake)-link_DEPLIBS)
1044 %link_q cmd="%(cmd)" strip="%(strip)" from=$(OBJS) opt=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR) coverageinstr=%(coverageinstr)
1046 #------------------------------------------------------------------------------
1049 #------------------------------------------------------------------------------
1050 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
1051 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
1052 %define rule_link_progs mmake=TMP progs=/A targetdir=$(AROSDIR)/$(CURDIR) nix=%(nix) \
1053 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
1054 usestartup=yes detach=no cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" strip=$(TARGET_STRIP) coverageinstr=$(TARGET_COVERAGEINSTR)
1056 %(mmake)-link_EXTRA_LDFLAGS :=
1057 %(mmake)-link_EXTRA_LIBS :=
1059 %(mmake)-link_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
1061 ifeq (%(usestartup),no)
1062 %(mmake)-link_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
1064 ifeq (%(detach),yes)
1065 %(mmake)-link_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
1068 # Make a list of the lib files the programs depend on.
1069 # In LDFLAGS remove white space between -L and directory
1070 %(mmake)-link_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
1071 # Filter out only the libdirs and remove -L
1072 %(mmake)-link_DIRS := $(patsubst -L%,%,$(filter -L%,$(%(mmake)-link_DIRS)))
1074 %(mmake)-link_DIRS := $(subst //,/,$(addsuffix /,$(%(mmake)-link_DIRS)))
1075 # Add normal linklib path
1076 %(mmake)-link_DIRS += $(AROS_LIB)/
1077 # add lib and .a to static linklib names
1078 %(mmake)-link_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(%(mmake)-link_EXTRA_LIBS)))
1079 # search for the linklibs in the given path, ignore ones not found
1080 %(mmake)-link_DEPLIBS := $(foreach lib,$(%(mmake)-link_LIBS), \
1081 $(firstword $(wildcard $(addsuffix $(lib),$(%(mmake)-link_DIRS)))) \
1083 %(mmake)-link_PROGS := $(addprefix %(targetdir)/,%(progs))
1085 $(%(mmake)-link_PROGS) : OBJDIR := %(objdir)
1086 $(%(mmake)-link_PROGS) : LDFLAGS := $(strip %(ldflags) $(%(mmake)-link_EXTRA_LDFLAGS))
1087 $(%(mmake)-link_PROGS) : LIBS := $(addprefix -l,%(uselibs) $(%(mmake)-link_EXTRA_LIBS) %(usehostlibs))
1088 $(%(mmake)-link_PROGS) : %(targetdir)/% : %(objdir)/%.o $(%(mmake)-link_DEPLIBS)
1089 %link_q cmd="%(cmd)" strip="%(strip)" from=$< opt=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR) coverageinstr=%(coverageinstr)
1091 #------------------------------------------------------------------------------
1094 #------------------------------------------------------------------------------
1095 # Link the %(objs) to the library %(libdir)/lib%(libname).a
1096 %define rule_link_linklib mmake=TMP libname=/A objs=/A libdir=$(AROS_LIB) linker=target
1098 ifeq (%(linker),target)
1099 %(libdir)/lib%(libname).a : %(mmake)_AR:=$(AR)
1100 %(libdir)/lib%(libname).a : %(mmake)_RANLIB:=$(RANLIB)
1102 ifeq (%(linker),host)
1103 %(libdir)/lib%(libname).a : %(mmake)_AR:=$(HOST_AR)
1104 %(libdir)/lib%(libname).a : %(mmake)_RANLIB:=$(HOST_RANLIB)
1106 ifeq (%(linker),kernel)
1107 %(libdir)/lib%(libname).a : %(mmake)_AR:=$(KERNEL_AR)
1108 %(libdir)/lib%(libname).a : %(mmake)_RANLIB:=$(KERNEL_RANLIB)
1111 %(libdir)/lib%(libname).a : %(objs)
1112 %mklib_q from=$^ ar=$(%(mmake)_AR) ranlib=$(%(mmake)_RANLIB)
1114 #------------------------------------------------------------------------------
1116 #------------------------------------------------------------------------------
1117 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
1118 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
1119 %define rule_linkmodule module=/A objs=/A endobj=/A err=/A objdir=$(OBJDIR) \
1120 cmd="$(strip $(AROS_CC) $(TARGET_SYSROOT))" ldflags=$(LDFLAGS) uselibs= usehostlibs=
1122 TMP_LDFLAGS := %(ldflags)
1123 # Make a list of the lib files the programs depend on.
1124 # In LDFLAGS remove white space between -L and directory
1125 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
1126 # Filter out only the libdirs and remove -L
1127 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
1129 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
1130 # Add normal linklib path
1131 TMP_DIRS += $(AROS_LIB)/
1132 # add lib and .a to static linklib names
1133 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
1134 # search for the linklibs in the given path, ignore ones not found
1135 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
1136 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
1139 %(module) : LIB_NAMES := %(uselibs)
1140 %(module) : OBJS := %(objs)
1141 %(module) : ENDTAG := %(endobj)
1142 %(module) : ERR := %(err)
1143 %(module) : OBJDIR := %(objdir)
1144 %(module) : LDFLAGS := $(TMP_LDFLAGS)
1145 ifeq (%(usehostlibs),)
1146 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES))
1148 # Warning: the -L/usr/lib here can result in modules
1149 # linking against host libs instead of AROS libs (e.g stdc++) !!
1150 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES)) \
1151 -L/usr/lib $(addprefix -l,%(usehostlibs))
1153 %(module) : %(objs) %(endobj) $(TMP_DEPLIBS) $(USER_DEPLIBS)
1154 %link_module_q cmd="%(cmd)" err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS) objdir=$(OBJDIR) ldflags=$(LDFLAGS)
1157 #------------------------------------------------------------------------------
1160 #------------------------------------------------------------------------------
1161 # Generate the libdefs.h include file for a module.
1162 %define rule_genmodule_genlibdefs modname=/A modtype=/A modsuffix= conffile= targetdir= version=
1164 TMP_TARGET := %(modname)_libdefs.h
1165 TMP_DEPS := $(GENMODULE)
1167 ifneq (%(conffile),)
1168 ifeq ($(dir %(conffile)),./)
1169 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1170 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1172 TMP_OPTS += -c %(conffile)
1173 TMP_DEPS += %(conffile)
1176 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1177 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1179 ifneq (%(modsuffix),)
1180 TMP_OPTS += -s %(modsuffix)
1182 ifneq (%(targetdir),)
1183 TMP_OPTS += -d %(targetdir)
1184 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1187 TMP_OPTS += -v %(version)
1190 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1191 $(TMP_TARGET) : MODNAME := %(modname)
1192 $(TMP_TARGET) : MODTYPE := %(modtype)
1193 $(TMP_TARGET) : $(TMP_DEPS)
1194 @$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1195 @$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
1197 #------------------------------------------------------------------------------
1199 #------------------------------------------------------------------------------
1200 # Generate the _lib.fd file for a module.
1201 %define rule_genmodule_fd modname=/A modtype=/A modsuffix= conffile= targetdir=
1203 TMP_TARGET := %(modname)_lib.fd
1204 TMP_DEPS := $(GENMODULE)
1206 ifneq (%(conffile),)
1207 ifeq ($(dir %(conffile)),./)
1208 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1209 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1211 TMP_OPTS += -c %(conffile)
1212 TMP_DEPS += %(conffile)
1215 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1216 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1218 ifneq (%(modsuffix),)
1219 TMP_OPTS += -s %(modsuffix)
1221 ifneq (%(targetdir),)
1222 TMP_OPTS += -d %(targetdir)
1223 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1226 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1227 $(TMP_TARGET) : MODNAME := %(modname)
1228 $(TMP_TARGET) : MODTYPE := %(modtype)
1229 $(TMP_TARGET) : $(TMP_DEPS)
1230 @$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1231 @$(GENMODULE) $(OPTS) writefd $(MODNAME) $(MODTYPE)
1233 #------------------------------------------------------------------------------
1235 #------------------------------------------------------------------------------
1236 # Generate a Makefile.%(modname)%(modtype) with the genmodule program and include this
1237 # generated file in this Makefile
1238 %define rule_genmodule_makefile modname=/A modtype=/A modsuffix= conffile= \
1241 TMP_TARGET := Makefile.%(modname)%(modtype)
1242 TMP_DEPS := $(GENMODULE)
1244 ifneq (%(conffile),)
1245 ifeq ($(dir %(conffile)),./)
1246 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1247 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1249 TMP_OPTS += -c %(conffile)
1250 TMP_DEPS += %(conffile)
1253 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1254 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1256 ifneq (%(modsuffix),)
1257 TMP_OPTS += -s %(modsuffix)
1259 ifneq (%(targetdir),)
1260 TMP_OPTS += -d %(targetdir)
1261 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1264 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1265 $(TMP_TARGET) : MODNAME := %(modname)
1266 $(TMP_TARGET) : MODTYPE := %(modtype)
1267 $(TMP_TARGET) : $(TMP_DEPS)
1268 @$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
1270 #------------------------------------------------------------------------------
1273 #------------------------------------------------------------------------------
1274 # Generate the support files for compiling a module. This includes include
1275 # files and source files. This rule has to be preceeded by
1276 # %rule_genmodule_makefile
1277 %define rule_genmodule_files modname=/A modtype=/A modsuffix= targetdir= stubdir= \
1280 TMP_GENTARGETS := $(%(modname)_STARTFILES) $(%(modname)_ENDFILES)
1281 TMP_STUBTARGETS := $(%(modname)_LINKLIBFILES) $(%(modname)_RELLINKLIBFILES)
1282 TMP_GENTARGETS := $(addsuffix .c,$(TMP_GENTARGETS))
1283 TMP_STUBTARGETS := $(addsuffix .c,$(TMP_STUBTARGETS)) \
1284 $(addsuffix .S, $(%(modname)_LINKLIBAFILES) $(%(modname)_RELLINKLIBAFILES))
1286 TMP_DEPS := $(GENMODULE)
1289 ifneq (%(conffile),)
1290 ifeq ($(dir %(conffile)),./)
1291 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1292 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1294 TMP_OPTS += -c %(conffile)
1295 TMP_DEPS += %(conffile)
1298 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1299 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1301 ifneq (%(modsuffix),)
1302 TMP_OPTS += -s %(modsuffix)
1304 ifneq (%(targetdir),)
1305 TMP_OPTS += -d %(targetdir)
1306 TMP_TARGETDIR := $(shell echo %(targetdir) | sed 's/^\(.\):\//\/\1\//')
1307 TMP_GENTARGETS := $(addprefix $(TMP_TARGETDIR)/,$(TMP_GENTARGETS))
1308 TMP_GENFILEFLAG=$(TMP_TARGETDIR)/.%(modname).%(modtype)-genfiles
1310 TMP_GENFILEFLAG=$(GENDIR)/$(CURDIR)/.%(modname).%(modtype)-genfiles
1313 TMP_OPTS += -l %(stubdir)
1314 TMP_STUBTARGETDIR := $(shell echo %(stubdir) | sed 's/^\(.\):\//\/\1\//')
1315 TMP_STUBTARGETS := $(addprefix $(TMP_STUBTARGETDIR)/,$(TMP_STUBTARGETS))
1316 TMP_TARGETDIRS += %(stubdir)
1318 ifneq (%(targetdir),)
1319 TMP_STUBTARGETS := $(addprefix $(TMP_TARGETDIR)/,$(TMP_STUBTARGETS))
1323 TMP_TARGETS := $(TMP_GENTARGETS) $(TMP_STUBTARGETS)
1324 ifneq ($(TMP_TARGETDIRS),)
1325 $(TMP_TARGETS) : | $(TMP_TARGETDIRS)
1328 $(TMP_TARGETS) : $(TMP_DEPS) $(TMP_GENFILEFLAG)
1330 $(TMP_GENFILEFLAG) : OPTS := $(TMP_OPTS)
1331 $(TMP_GENFILEFLAG) : MODNAME := %(modname)
1332 $(TMP_GENFILEFLAG) : MODTYPE := %(modtype)
1333 $(TMP_GENFILEFLAG) : $(TMP_DEPS)
1334 @$(ECHO) "Generating support files for module $(MODNAME$(BDID))"
1335 ifneq (%(conffile),lib.conf)
1336 @$(IF) $(TEST) -f lib.conf; then \
1337 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
1340 @$(IF) $(TEST) -f libdefs.h; then \
1341 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
1343 @$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
1346 #------------------------------------------------------------------------------
1349 #------------------------------------------------------------------------------
1350 # Generate the support files for compiling a module. This includes include
1351 # files and source files.
1352 %define rule_genmodule_includes modname=/A modtype=/A modsuffix= \
1353 targetdir= conffile=
1355 ifneq ($(%(modname)_INCLUDES),)
1357 TMP_TARGETS := $(%(modname)_INCLUDES)
1359 TMP_DEPS := $(GENMODULE)
1362 ifneq (%(conffile),)
1363 ifeq ($(dir %(conffile)),./)
1364 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1365 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1367 TMP_OPTS += -c %(conffile)
1368 TMP_DEPS += %(conffile)
1371 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1372 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1374 ifneq (%(modsuffix),)
1375 TMP_OPTS += -s %(modsuffix)
1377 ifneq (%(targetdir),)
1378 TMP_OPTS += -d %(targetdir)
1379 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
1380 TMP_GENINCFLAG=%(targetdir)/.%(modname).%(modtype)-includes
1382 TMP_GENINCFLAG=$(GENDIR)/$(CURDIR)/.%(modname).%(modtype)-includes
1385 $(TMP_TARGETS) : $(TMP_DEPS) $(TMP_GENINCFLAG)
1387 $(TMP_GENINCFLAG) : OPTS := $(TMP_OPTS)
1388 $(TMP_GENINCFLAG) : MODNAME := %(modname)
1389 $(TMP_GENINCFLAG) : MODTYPE := %(modtype)
1390 $(TMP_GENINCFLAG) : $(TMP_DEPS)
1391 @$(ECHO) "Generating $(MODNAME).$(MODTYPE) includes"
1392 @$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
1396 #------------------------------------------------------------------------------
1398 #------------------------------------------------------------------------------
1399 # Link %(objs) to binary blob in %(file) using %(name) as name of embedded binary object
1400 # 'start' is an optional starting address
1401 # 'ldflags' is optional additional flags for the linker
1402 %define rule_link_binary mmake=BD file=/A name=/A objs= files= start=0 ldflags=
1404 %(mmake)_OUTDIR := $(dir %(file))
1405 # This trick removes the trailing '/', otherwise findstring below fails, causing a warning
1406 %(mmake)_OUTDIR := $(subst /*,,$(addsuffix *,$(%(mmake)_OUTDIR)))
1407 %(mmake)_TMPDIR := $(GENDIR)/$(CURDIR)
1408 %(mmake)_OBJS := $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir %(files))))
1409 %(mmake)_DEPS := $(addsuffix .d,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir %(files))))
1410 %(mmake)_OBJS += %(objs)
1412 %rule_compile_multi basenames="%(files)" targetdir=$(%(mmake)_OBJDIR)
1414 %(file) : $(%(mmake)_OBJS) $(%(mmake)_DEPS) $(%(mmake)_OUTDIR)
1415 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)..."
1416 @$(KERNEL_LD) %(ldflags) --entry=%(start) --oformat=binary -Ttext=%(start) -o $(%(mmake)_TMPDIR)/%(name) $(%(mmake)_OBJS)
1417 @cd $(%(mmake)_TMPDIR) && $(AROS_LD) %(ldflags) -r --format binary %(name) -o $@
1419 ifeq ($(findstring $(%(mmake)_OUTDIR),$(GLOB_MKDIRS)),)
1420 GLOB_MKDIRS += $(%(mmake)_OUTDIR)
1425 #------------------------------------------------------------------------------
1426 # Common rules for all makefiles
1428 # Delete generated makefiles
1431 @$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
1433 include $(SRCDIR)/config/make.tail
1435 BDID := $(BDTARGETID)
1437 #------------------------------------------------------------------------------
1440 #############################################################################
1441 #############################################################################
1443 ## Here are the mmakefile build macros. These are macros that takes care ##
1444 ## of everything to go from the sources to the generated target. Also all ##
1445 ## intermediate files and directories that are needed are created by these ##
1448 #############################################################################
1449 #############################################################################
1451 #------------------------------------------------------------------------------
1453 %define build_prog mmake=/A progname=/A files= cxxfiles= \
1455 asmfiles= objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1456 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= ldflags=$(LDFLAGS) \
1457 aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
1458 includedir= libdir= \
1459 compiler=target linker= \
1460 coverageinstr=$(TARGET_COVERAGEINSTR) lto=$(TARGET_LTO)
1464 %(mmake)_PROGNAME := %(progname)
1465 %(mmake)_OBJDIR := %(objdir)
1466 %(mmake)_TARGETDIR := %(targetdir)
1467 %(mmake)_LINKER := %(linker)
1468 %(mmake)_LIBS := %(uselibs)
1469 # If not supplied, linker is equal to compiler
1470 ifeq ($(%(mmake)_LINKER),)
1471 %(mmake)_LINKER := %(compiler)
1474 ifneq ("$(strip %(files) %(cxxfiles) %(objcfiles) %(asmfiles))","")
1475 %(mmake)_FILES := %(files)
1476 %(mmake)_OBJCFILES := %(objcfiles)
1477 %(mmake)_ASMFILES := %(asmfiles)
1478 %(mmake)_CXXFILES := %(cxxfiles)
1480 %(mmake)_FILES := $(%(mmake)_PROGNAME)
1481 %(mmake)_OBJCFILES :=
1482 %(mmake)_ASMFILES :=
1483 %(mmake)_CXXFILES :=
1486 %(mmake)_ARCHOBJS := $(wildcard $(%(mmake)_OBJDIR)/arch/*.o)
1487 %(mmake)_ARCHFILES := $(basename $(notdir $(%(mmake)_ARCHOBJS)))
1488 %(mmake)_C_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_FILES))
1489 %(mmake)_CXX_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_CXXFILES))
1490 %(mmake)_OBJC_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_OBJCFILES))
1492 TMP_FILES := $(%(mmake)_C_NARCHFILES) $(%(mmake)_CXX_NARCHFILES) $(%(mmake)_ASMFILES) $(%(mmake)_OBJC_NARCHFILES)
1493 %(mmake)_OBJS := $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir $(TMP_FILES))))
1494 %(mmake)_DEPS := $(addsuffix .d,$(addprefix $(%(mmake)_OBJDIR)/,$(notdir $(TMP_FILES))))
1496 %(mmake)_CPPFLAGS := %(cppflags)
1497 ifneq (%(includedir),)
1498 %(mmake)_CPPFLAGS += -I%(includedir)
1500 %(mmake)_CFLAGS := %(cflags)
1501 %(mmake)_CXXFLAGS := %(cxxflags)
1502 %(mmake)_COVERAGE := no
1503 ifeq (%(compiler),target)
1504 ifeq (%(usestartup),yes)
1505 ifeq (%(coverageinstr),yes)
1506 %(mmake)_COVERAGE := yes
1507 %(mmake)_CFLAGS := $(strip $(COVERAGEINSTR_FLAGS) $(%(mmake)_CFLAGS))
1508 %(mmake)_CXXFLAGS := $(strip $(COVERAGEINSTR_FLAGS) $(%(mmake)_CXXFLAGS))
1509 %(mmake)_LIBS += gcov
1513 %(mmake)_CFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(%(mmake)_CFLAGS))
1514 %(mmake)_CXXFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(%(mmake)_CXXFLAGS))
1517 %(mmake)_AFLAGS := %(aflags)
1519 %(mmake)_DFLAGS := %(dflags)
1521 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
1523 ifneq (%(dxxflags),)
1524 %(mmake)_DXXFLAGS := %(dxxflags)
1526 %(mmake)_DXXFLAGS := $(%(mmake)_CXXFLAGS)
1528 %(mmake)_LDFLAGS := %(ldflags)
1530 %(mmake)_LDFLAGS += -L%(libdir)
1534 %(mmake)-quick : %(mmake)
1536 #MM %(mmake) : includes-generate-deps core-linklibs
1537 %(mmake) : $(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME)
1539 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick %(mmake)-gz-quick),)
1540 %rule_compile_cxx_multi mmake=%(mmake) \
1541 basenames=$(%(mmake)_CXX_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
1542 cppflags=$(%(mmake)_CPPFLAGS) cxxflags=$(%(mmake)_CXXFLAGS) dxxflags=$(%(mmake)_DXXFLAGS) \
1543 compiler="%(compiler)"
1544 %rule_compile_objc_multi mmake=%(mmake) \
1545 basenames=$(%(mmake)_OBJC_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
1546 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
1547 compiler="%(compiler)"
1548 %rule_compile_multi mmake=%(mmake) \
1549 basenames=$(%(mmake)_C_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
1550 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
1551 compiler="%(compiler)"
1552 %rule_assemble_multi mmake=%(mmake) \
1553 cmd=$(%(mmake)_ASSEMBLER) basenames=$(%(mmake)_ASMFILES) targetdir=$(%(mmake)_OBJDIR) \
1554 cppflags=$(%(mmake)_CPPFLAGS) aflags=$(%(mmake)_AFLAGS)
1556 %rule_link_prog mmake=%(mmake) prog=$(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME) \
1557 objs="$(%(mmake)_OBJS) $(%(mmake)_ARCHOBJS) $(USER_OBJS)" ldflags=$(%(mmake)_LDFLAGS) \
1558 uselibs="$(%(mmake)_LIBS)" usehostlibs="%(usehostlibs)" \
1559 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)" \
1560 cmd=$(%(mmake)_LINK) strip=$(%(mmake)_STRIP) objdir=$(%(mmake)_OBJDIR) coverageinstr=$(%(mmake)_COVERAGE)
1564 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(%(mmake)_DEPS)
1566 $(%(mmake)_OBJS) $(%(mmake)_DEPS) : | $(%(mmake)_OBJDIR)
1567 $(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME) : | $(%(mmake)_TARGETDIR)
1568 GLOB_MKDIRS += $(%(mmake)_OBJDIR) $(%(mmake)_TARGETDIR)
1570 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_TARGETDIR)/$(%(mmake)_PROGNAME) $(%(mmake)_DEPS)
1573 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1577 #------------------------------------------------------------------------------
1580 #------------------------------------------------------------------------------
1581 # Build programs, for every C file an executable will be built with the same
1582 # name as the C file
1583 %define build_progs mmake=/A files=/A nix=no \
1584 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1585 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= ldflags=$(LDFLAGS) \
1586 includedir= libdir= \
1588 uselibs= usehostlibs= usestartup=yes detach=no \
1589 coverageinstr=$(TARGET_COVERAGEINSTR) lto=$(TARGET_LTO)
1593 %(mmake)_OBJDIR := %(objdir)
1594 %(mmake)_TARGETDIR := %(targetdir)
1595 %(mmake)_LIBS := %(uselibs)
1597 %(mmake)_FILES := %(files)
1598 %(mmake)_OBJS := $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/,$(%(mmake)_FILES)))
1599 %(mmake)_DEPS := $(addsuffix .d,$(addprefix $(%(mmake)_OBJDIR)/,$(%(mmake)_FILES)))
1600 %(mmake)_EXES := $(addprefix $(%(mmake)_TARGETDIR)/,$(%(mmake)_FILES))
1602 %(mmake)_CPPFLAGS := %(cppflags)
1603 ifneq (%(includedir),)
1604 %(mmake)_CPPFLAGS += -I%(includedir)
1606 %(mmake)_CFLAGS := %(cflags)
1607 %(mmake)_COVERAGE := no
1608 ifeq (%(compiler),target)
1609 ifeq (%(usestartup),yes)
1610 ifeq (%(coverageinstr),yes)
1611 %(mmake)_COVERAGE := yes
1612 %(mmake)_CFLAGS := $(strip $(COVERAGEINSTR_FLAGS) $(%(mmake)_CFLAGS))
1613 %(mmake)_LIBS += gcov
1617 %(mmake)_CFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(%(mmake)_CFLAGS))
1621 %(mmake)_DFLAGS := %(dflags)
1623 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
1625 %(mmake)_LDFLAGS := %(ldflags)
1627 %(mmake)_LDFLAGS += -L%(libdir)
1631 %(mmake)-quick : %(mmake)
1633 #MM %(mmake) : includes-generate-deps core-linklibs
1634 %(mmake) : $(%(mmake)_EXES)
1636 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1637 %rule_compile_multi mmake=%(mmake) basenames=$(%(mmake)_FILES) targetdir=$(%(mmake)_OBJDIR) \
1638 cflags=$(%(mmake)_CFLAGS) cppflags=$(%(mmake)_CPPFLAGS) dflags=$(%(mmake)_DFLAGS) compiler="%(compiler)"
1640 %rule_link_progs mmake=%(mmake) progs=$(%(mmake)_FILES) nix="%(nix)" \
1641 targetdir=$(%(mmake)_TARGETDIR) objdir=$(%(mmake)_OBJDIR) \
1642 ldflags=$(%(mmake)_LDFLAGS) \
1643 uselibs="$(%(mmake)_LIBS)" usehostlibs="%(usehostlibs)" \
1644 usestartup="%(usestartup)" detach="%(detach)" \
1645 cmd=$(%(mmake)_LINK) strip=$(%(mmake)_STRIP) objdir=$(%(mmake)_OBJDIR) coverageinstr=$(%(mmake)_COVERAGE)
1649 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(%(mmake)_DEPS)
1651 $(addprefix $(%(mmake)_TARGETDIR)/,$(%(mmake)_FILES)) : | $(%(mmake)_TARGETDIR)
1652 $(%(mmake)_DEPS) $(%(mmake)_OBJS) : | $(%(mmake)_OBJDIR)
1653 GLOB_MKDIRS += $(%(mmake)_TARGETDIR) $(%(mmake)_OBJDIR)
1655 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_EXES) $(%(mmake)_DEPS)
1658 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1662 #------------------------------------------------------------------------------
1665 #------------------------------------------------------------------------------
1667 # This is a bare version: It just compiles and links the given files. It is
1668 # assumed that all needed boiler plate code is in the files. This should only
1669 # be used for compiling external code. For AROS code use %build_module
1670 %define build_module_simple mmake=/A modname=/A modtype=/A \
1671 files="$(basename $(call WILDCARD, *.c))" \
1673 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
1674 cppflags=$(CPPFLAGS) \
1675 cflags=$(CFLAGS) dflags= \
1676 cxxflags=$(CXXFLAGS) dxxflags= \
1677 objdir=$(OBJDIR) moduledir= \
1678 uselibs= usehostlibs= compiler=target lto=$(TARGET_LTO)
1680 # Define metamake targets and their dependencies
1681 #MM %(mmake) : core-linklibs includes-generate-deps
1682 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1683 #MM %(mmake)-kobj-quick
1687 %(mmake)_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj
1689 .PHONY : $(%(mmake)_ALLTARGETS)
1692 $(error using %build_module_simple: modname may not be empty)
1695 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1698 # Default values for variables and arguments
1699 %(mmake)_DEFLINKLIBNAME := %(modname)
1700 %(mmake)_CFLAGS := %(cflags)
1701 %(mmake)_CXXFLAGS := %(cxxflags)
1702 ifeq (%(compiler),target)
1704 %(mmake)_CFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(%(mmake)_CFLAGS))
1708 %(mmake)_DFLAGS := %(dflags)
1710 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
1712 %(mmake)_DEFDXXFLAGS := %(dxxflags)
1713 OBJDIR ?= $(GENDIR)/$(CURDIR)
1714 %(mmake)_MODDIR := %(moduledir)
1715 ifeq ($(%(mmake)_MODDIR),)
1716 ifeq (%(modtype),library)
1717 %(mmake)_MODDIR := $(AROS_LIBRARIES)
1719 ifeq (%(modtype),gadget)
1720 %(mmake)_MODDIR := $(AROS_GADGETS)
1722 ifeq (%(modtype),datatype)
1723 %(mmake)_MODDIR := $(AROS_DATATYPES)
1725 ifeq (%(modtype),handler)
1726 %(mmake)_MODDIR := $(AROS_FS)
1728 ifeq (%(modtype),device)
1729 %(mmake)_MODDIR := $(AROS_DEVS)
1731 ifeq (%(modtype),resource)
1732 %(mmake)_MODDIR := $(AROS_RESOURCES)
1734 ifeq (%(modtype),hook)
1735 %(mmake)_MODDIR := $(AROS_RESOURCES)
1737 ifeq (%(modtype),mui)
1738 %(mmake)_MODDIR := $(AROS_CLASSES)/Zune
1740 ifeq (%(modtype),mcc)
1741 %(mmake)_MODDIR := $(AROS_CLASSES)/Zune
1743 ifeq (%(modtype),mcp)
1744 %(mmake)_MODDIR := $(AROS_CLASSES)/Zune
1746 ifeq (%(modtype),usbclass)
1747 %(mmake)_MODDIR := $(AROS_CLASSES)/USB
1749 ifeq (%(modtype),hidd)
1750 %(mmake)_MODDIR := $(AROS_DRIVERS)
1752 ifeq (%(modtype),printer)
1753 %(mmake)_MODDIR := $(AROS_PRINTERS)
1756 ifeq ($(%(mmake)_MODDIR),)
1757 $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1760 %(mmake)_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1761 %(mmake)_ARCHFILES := $(basename $(notdir $(%(mmake)_ARCHOBJS)))
1762 %(mmake)_C_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),%(files))
1763 %(mmake)_CXX_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),%(cxxfiles))
1764 %(mmake)_OBJC_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),%(objcfiles))
1766 %rule_compile_cxx_multi mmake=%(mmake) \
1767 basenames=$(%(mmake)_CXX_NARCHFILES) targetdir="%(objdir)" \
1768 cppflags="%(cppflags)" cxxflags=$(%(mmake)_CXXFLAGS) dxxflags=$(%(mmake)_DXXFLAGS) \
1769 compiler="%(compiler)"
1770 %rule_compile_objc_multi mmake=%(mmake) \
1771 basenames=$(%(mmake)_OBJC_NARCHFILES) targetdir="%(objdir)" \
1772 cppflags="%(cppflags)" cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
1773 compiler="%(compiler)"
1774 %rule_compile_multi mmake=%(mmake) \
1775 basenames=$(%(mmake)_C_NARCHFILES) targetdir="%(objdir)" \
1776 cppflags="%(cppflags)" cflags="$(%(mmake)_CFLAGS)" dflags="$(%(mmake)_DFLAGS)" \
1777 compiler="%(compiler)"
1779 # Handlers use dash instead of dot in their names
1780 ifeq (%(modtype),handler)
1781 %(mmake)_MODULE := $(%(mmake)_MODDIR)/%(modname)-%(modtype)
1783 ifeq (%(modtype),printer)
1784 %(mmake)_MODULE := $(%(mmake)_MODDIR)/%(modname)
1786 %(mmake)_MODULE := $(%(mmake)_MODDIR)/%(modname).%(modtype)
1789 %(mmake)_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1791 %(mmake)-quick : %(mmake)
1792 %(mmake)-kobj-quick : $(%(mmake)_KOBJ)
1793 %(mmake) : $(%(mmake)_MODULE)
1794 %(mmake)-kobj : $(%(mmake)_KOBJ)
1796 # The module is linked from all the compiled .o files
1797 %(mmake)_OBJS := $(%(mmake)_ARCHOBJS) $(addprefix %(objdir)/, $(addsuffix .o,$(notdir $(%(mmake)_C_NARCHFILES))))
1799 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
1800 # This breaks con-handler build. Here we work around this
1801 ifeq (%(modname),con)
1802 %(mmake)_ERR := $(notdir $(%(mmake)_MODULE)).err
1804 %(mmake)_ERR := %(modname).err
1807 %rule_linkmodule module=$(%(mmake)_MODULE) objs=$(%(mmake)_OBJS) \
1808 endobj= err=$(%(mmake)_ERR) objdir="%(objdir)" \
1809 ldflags="$(strip $(LDFLAGS) $(%(modname)_LDFLAGS))" \
1810 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
1812 # Link kernel object file
1813 %(mmake)_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1815 # Make these symbols local
1816 %(mmake)_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1817 UtilityBase ExpansionBase KeymapBase KernelBase
1819 %(mmake)_SYMBOLS := $(%(mmake)_KBASE)
1821 %(mmake)_KLIB := hiddstubs amiga arossupport autoinit libinit
1822 %(mmake)_KOBJ_LIBS := $(filter-out $(%(mmake)_KLIB),%(uselibs)) $(%(mmake)_KAUTOLIB)
1823 $(%(mmake)_KOBJ) : LINKLIBS:=$(%(mmake)_KOBJ_LIBS)
1824 $(%(mmake)_KOBJ) : FILTBASES:=$(addprefix -L ,$(%(mmake)_SYMBOLS))
1825 $(%(mmake)_KOBJ) : USER_LDFLAGS := $(USER_LDFLAGS)
1826 $(%(mmake)_KOBJ) : $(%(mmake)_OBJS) $(%(mmake)_ENDOBJS)
1827 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
1828 @$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1829 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
1832 ## Dependency fine-tuning
1834 %(mmake)_DEPS := $(addprefix %(objdir)/, $(addsuffix .d,%(files)))
1835 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(%(mmake)_DEPS)
1837 $(%(mmake)_OBJS) $(%(mmake)_DEPS) : | %(objdir)
1838 $(%(mmake)_MODULE) : | $(%(mmake)_MODDIR)
1839 $(%(mmake)_KOBJ) : | $(KOBJSDIR)
1840 GLOB_MKDIRS += %(objdir) $(%(mmake)_MODDIR) $(KOBJSDIR)
1842 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_MODULE) $(%(mmake)_KOBJ) $(%(mmake)_DEPS)
1844 @$(ECHO) "Cleaning up for module %(modname)"
1847 #------------------------------------------------------------------------------
1850 #------------------------------------------------------------------------------
1851 # Build a module - core routine
1852 # Explanation of this macro is done in the developer's manual
1853 %define build_module_core mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
1854 files="$(basename $(call WILDCARD, *.c))" \
1856 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
1857 linklibfiles= linklibobjs= \
1858 cppflags=$(CPPFLAGS) \
1859 cflags=$(CFLAGS) dflags= \
1860 cxxflags=$(CXXFLAGS) dxxflags= \
1861 objdir= moduledir= prefix=$(AROSDIR) \
1862 linklibname= uselibs= usehostlibs= \
1863 compiler=target lto=$(TARGET_LTO) nostartup=yes archspecific=no \
1864 includedir= libdir= \
1865 build_abi= build_library=
1867 # We will employ a terrifying, but unavoidable, hack here.
1868 # genmf has no concept of conditionals (ie %ifeq), and MetaMake
1869 # ignores GNU Make ifeq() statements, but will process any #MM
1870 # headed lines in the file.
1872 # So, to make the following #MM lines conditional on whether we want
1873 # to build the ABI, Library, or both, we define build_abi= and
1874 # build_library as 'M' to enable, or '' to disable, which allows genmf
1875 # to do the following conversions:
1877 # #%(build_abi)M includes-foo: foo-include
1878 # becomes, when build_abi=M
1879 # #MM includes-foo: foo-include <= Processed by MetaMake
1880 # but, when build_abi= ...
1881 # #M includes-foo: foo-includes <= ignored by MetaMake! Yes!
1883 # Taking full blame for this: Jason S. McMullan <jason.mcmullan@gmail.com>
1885 # Define metamake targets and their dependencies
1888 #MM %(mmake)-makefile
1892 #M%(build_abi)- includes-all : %(mmake)-includes
1893 #M%(build_abi)- linklibs-%(modname): %(mmake)-linklib
1894 #M%(build_abi)- linklibs-%(modname)_rel : %(mmake)-linklib
1895 #M%(build_abi)- includes-%(modname): %(mmake)-includes
1896 #M%(build_abi)- includes-%(modname)_rel : %(mmake)-includes
1897 #M%(build_abi)- %(mmake) : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1898 #M%(build_abi) %(mmake)-linklib : %(mmake)-includes includes-%(uselibs)
1899 #M%(build_abi)- %(mmake)-quick : %(mmake)-includes-quick
1900 #M%(build_abi) %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1901 #M%(build_abi) includes-generate-deps %(mmake)-fd
1902 #M%(build_abi) %(mmake)-includes-quick
1903 #M%(build_abi) %(mmake)-includes-dirs
1904 #M%(build_abi) %(mmake)-fd
1907 #%(build_library)M %(mmake)-kobj : core-linklibs linklibs-%(uselibs)
1908 #%(build_library)M %(mmake)-kobj-quick :
1910 # Library with ABI targets:
1911 #%(build_library)%(build_abi) %(mmake)-kobj : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1912 #%(build_library)%(build_abi) %(mmake)-kobj-quick : %(mmake)-includes-quick
1914 # All MetaMake targets defined by this macro
1915 %(mmake)_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-clean
1917 ifeq (%(build_library),M)
1918 %(mmake)_ALLTARGETS += %(mmake)-kobj %(mmake)-kobj-quick
1921 ifeq (%(build_abi),M)
1922 %(mmake)_ALLTARGETS += %(mmake)-includes \
1923 %(mmake)-includes-quick %(mmake)-includes-dirs \
1924 %(mmake)-linklib %(mmake)-fd
1927 .PHONY : $(%(mmake)_ALLTARGETS) %(mmake)-makefile
1930 $(error using %build_module: modname may not be empty)
1933 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1936 # Default values for variables and arguments
1937 %(mmake)_DEFLINKLIBNAME := %(modname)
1938 ifneq (%(linklibname),)
1939 %(mmake)_LINKLIBNAME := %(linklibname)
1941 %(mmake)_LINKLIBNAME := $(%(mmake)_DEFLINKLIBNAME)
1943 %(mmake)_DEFCPPFLAGS := %(cppflags)
1944 ifneq (%(includedir),)
1945 %(mmake)_DEFCPPFLAGS += -I%(includedir)
1947 %(mmake)_DEFDFLAGS := %(cflags)
1949 %(mmake)_DFLAGS := %(dflags)
1951 %(mmake)_DFLAGS := $(%(mmake)_DEFDFLAGS)
1953 %(mmake)_DEFDXXFLAGS := %(cxxflags)
1954 ifneq (%(dxxflags),)
1955 %(mmake)_DXXFLAGS := %(dxxflags)
1957 %(mmake)_DXXFLAGS := $(%(mmake)_DEFDXXFLAGS)
1960 ifeq (%(compiler),target)
1961 %(mmake)_DEFDFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH) $(%(mmake)_DEFDFLAGS))
1962 %(mmake)_DEFDXXFLAGS := $(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH) $(%(mmake)_DEFDXXFLAGS))
1965 OBJDIR ?= $(GENDIR)/$(CURDIR)
1967 %(mmake)_OBJDIR := %(objdir)
1969 %(mmake)_OBJDIR := $(OBJDIR)/%(modname)
1972 ## Create genmodule include Makefile for the module
1974 %(mmake)-makefile : $(%(mmake)_OBJDIR)/Makefile.%(modname)%(modtype)
1976 %rule_genmodule_makefile \
1977 modname="%(modname)" modtype="%(modtype)" \
1978 modsuffix="%(modsuffix)" targetdir="$(%(mmake)_OBJDIR)" \
1979 conffile="%(conffile)"
1981 $(%(mmake)_OBJDIR)/Makefile.%(modname)%(modtype) : | $(%(mmake)_OBJDIR)
1983 GLOB_MKDIRS += $(%(mmake)_OBJDIR)
1985 # Do not parse these statements if metatarget is not appropriate
1986 ifneq ($(filter $(TARGET),$(%(mmake)_ALLTARGETS)),)
1988 # suppress makes warning that the Makefile doesnt yet exist
1989 # on early passes (it will generate the file as needed though)
1990 # when we include it.
1991 -include $(%(mmake)_OBJDIR)/Makefile.%(modname)%(modtype)
1993 %(mmake)_DEFMODDIR := $(%(modname)_MODDIR)
1994 ifeq (%(archspecific),yes)
1995 %(mmake)_DEFMODDIR := $(AROS_DIR_ARCH)/$(%(mmake)_DEFMODDIR)
1997 ifneq (%(moduledir),)
1998 %(mmake)_MODDIR := %(moduledir)
2000 %(mmake)_MODDIR := $(%(mmake)_DEFMODDIR)
2003 ## include files generation
2005 ifneq (%(includedir),)
2006 %(mmake)_INCDIR := %(includedir)
2008 %(mmake)_INCDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/$(AROS_DIR_INCLUDE)
2010 %(mmake)_LIBDEFSINC := $(%(mmake)_OBJDIR)/include/%(modname)_libdefs.h
2011 %(mmake)_DEFLIBDEFSINC := $(%(mmake)_OBJDIR)/include/%(modname)_deflibdefs.h
2013 ifeq (%(build_abi),M)
2014 %(mmake)-includes-quick : %(mmake)-includes
2015 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
2016 $(addprefix $(%(mmake)_INCDIR)/,$(%(modname)_INCLUDES)) \
2017 $(%(mmake)_LIBDEFSINC) $(%(mmake)_DEFLIBDEFSINC)
2019 ifneq ($(%(modname)_INCLUDES),)
2020 %rule_genmodule_includes modname="%(modname)" modtype="%(modtype)" \
2021 modsuffix="%(modsuffix)" targetdir="$(%(mmake)_OBJDIR)/include" \
2022 conffile="%(conffile)"
2024 %rule_copy_diff_multi \
2025 files=$(%(modname)_INCLUDES) srcdir="$(%(mmake)_OBJDIR)/include" targetdir=$(GENINCDIR) \
2026 stampfile="$(%(mmake)_OBJDIR)/%(modname)_geninc"
2028 %rule_copy_diff_multi \
2029 files=$(%(modname)_INCLUDES) srcdir="$(%(mmake)_OBJDIR)/include" targetdir=$(%(mmake)_INCDIR) \
2030 stampfile="$(%(mmake)_OBJDIR)/%(modname)_incs"
2032 %(mmake)_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
2034 TMP%(modname)_INCDIRS := \
2035 $(%(mmake)_OBJDIR)/include $(addprefix $(%(mmake)_OBJDIR)/include/,$(%(mmake)_INCDIRS)) \
2036 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(%(mmake)_INCDIRS)) \
2037 $(%(mmake)_INCDIR) $(addprefix $(%(mmake)_INCDIR)/,$(%(mmake)_INCDIRS))
2038 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget="%(mmake)-includes-dirs"
2044 %rule_genmodule_genlibdefs modname="%(modname)" modtype="%(modtype)" \
2045 modsuffix="%(modsuffix)" targetdir="$(%(mmake)_OBJDIR)/include" \
2046 conffile="%(conffile)" version="%(version)"
2048 $(%(mmake)_DEFLIBDEFSINC) : FILENAME := $(%(mmake)_LIBDEFSINC)
2049 $(%(mmake)_DEFLIBDEFSINC) :
2050 @$(ECHO) "Generating $@"
2051 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
2053 $(%(mmake)_LIBDEFSINC) $(%(mmake)_DEFLIBDEFSINC) : | $(%(mmake)_OBJDIR)/include
2054 GLOB_MKDIRS += $(%(mmake)_OBJDIR)/include
2056 ## Extra genmodule src files generation
2058 %rule_genmodule_files modname="%(modname)" modtype="%(modtype)" \
2059 modsuffix="%(modsuffix)" targetdir="$(%(mmake)_OBJDIR)" stubdir="$(%(mmake)_OBJDIR)/linklib" \
2060 conffile="%(conffile)"
2062 GLOB_MKDIRS += $(%(mmake)_OBJDIR)/linklib
2064 ifeq (%(build_abi),M)
2066 ifeq (%(includedir),)
2067 %(mmake)_FDDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/fd
2069 %(mmake)_FDDIR := %(includedir)/../fd
2071 %(mmake)-fd : $(%(mmake)_FDDIR)/%(modname)_lib.fd
2073 %rule_genmodule_fd modname="%(modname)" modtype="%(modtype)" \
2074 modsuffix="%(modsuffix)" targetdir=$(%(mmake)_FDDIR) conffile="%(conffile)"
2076 $(%(mmake)_FDDIR)/%(modname)_lib.fd : | $(%(mmake)_FDDIR)
2078 GLOB_MKDIRS += $(%(mmake)_FDDIR)
2083 %(mmake)_FILES := %(files)
2084 %(mmake)_OBJCFILES := %(objcfiles)
2085 %(mmake)_CXXFILES := %(cxxfiles)
2087 %(mmake)_LIBFILES := %(linklibfiles)
2089 %(mmake)_FDIRS := $(sort $(dir $(%(mmake)_FILES)))
2091 %(mmake)_FILEMATCH = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1)))
2092 %(mmake)_MATCHARCH = $(foreach matchfile,$(2),$(foreach archfile,$(1),$(if $(call %(mmake)_FILEMATCH,$(archfile),$(notdir $(matchfile))),$(matchfile),)))
2093 %(mmake)_FILTERARCH = $(filter-out $(call %(mmake)_MATCHARCH,$(1),$(2)),$(2))
2094 %(mmake)_STARTFILES := $(addprefix $(%(mmake)_OBJDIR)/,$(%(modname)_STARTFILES))
2095 %(mmake)_ENDFILES := $(addprefix $(%(mmake)_OBJDIR)/,$(%(modname)_ENDFILES))
2097 %(mmake)_ARCHOBJS := $(wildcard $(%(mmake)_OBJDIR)/arch/*.o)
2098 %(mmake)_LIBARCHOBJS := $(wildcard $(%(mmake)_OBJDIR)/linklib/arch/*.o)
2099 %(mmake)_ARCHFILES := $(basename $(notdir $(%(mmake)_ARCHOBJS)))
2100 %(mmake)_LIBARCHFILES := $(basename $(notdir $(%(mmake)_LIBARCHOBJS)))
2101 %(mmake)_C_NARCHFILES := $(call %(mmake)_FILTERARCH,$(%(mmake)_ARCHFILES),$(%(mmake)_FILES))
2102 %(mmake)_CXX_NARCHFILES := $(call %(mmake)_FILTERARCH,$(%(mmake)_ARCHFILES),$(%(mmake)_CXXFILES))
2103 %(mmake)_OBJC_NARCHFILES := $(call %(mmake)_FILTERARCH,$(%(mmake)_ARCHFILES),$(%(mmake)_OBJCFILES))
2104 %(mmake)_NLIBARCHFILES := $(call %(mmake)_FILTERARCH,$(%(mmake)_LIBARCHFILES),$(%(mmake)_LIBFILES))
2105 %(mmake)_ARCHNLIBFILES := $(call %(mmake)_FILTERARCH,$(%(mmake)_LIBFILES),$(%(mmake)_LIBARCHFILES))
2107 %(mmake)_CPPFLAGS := $(strip %(cppflags) -I$(%(mmake)_OBJDIR)/include -include $(%(mmake)_DEFLIBDEFSINC))
2108 ifneq (%(includedir),)
2109 %(mmake)_CPPFLAGS += -I%(includedir)
2111 %(mmake)_CFLAGS := $(strip %(cflags) $(%(modname)_CFLAGS))
2112 %(mmake)_LINKLIBCFLAGS := $(strip %(cflags) $(%(modname)_LINKLIBCFLAGS))
2113 %(mmake)_CXXFLAGS := $(strip %(cxxflags) $(%(modname)_CXXFLAGS))
2115 ifeq (%(compiler),target)
2116 %(mmake)_LTOFLAGS=$(strip $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH))
2117 %(mmake)_CFLAGS := $(strip $(%(mmake)_LTOFLAGS) $(%(mmake)_CFLAGS))
2118 %(mmake)_LINKLIBCFLAGS := $(strip $(%(mmake)_LTOFLAGS) $(%(mmake)_LINKLIBCFLAGS))
2119 %(mmake)_CXXFLAGS := $(strip $(%(mmake)_LTOFLAGS) $(%(mmake)_CXXFLAGS))
2122 %(mmake)_DFLAGS := $(strip $(%(mmake)_DFLAGS) $(%(modname)_DFLAGS))
2123 %(mmake)_LINKLIBDFLAGS := $(strip $(%(mmake)_DFLAGS) $(%(modname)_LINKLIBDFLAGS))
2124 %(mmake)_DXXFLAGS := $(strip $(%(mmake)_DXXFLAGS) $(%(modname)_DXXFLAGS))
2126 ifeq (%(modtype),library)
2127 %(mmake)_LIBSUFFIX :=
2129 %(mmake)_LIBSUFFIX := .%(modtype)
2133 %(mmake)_LIBDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/$(AROS_DIR_LIB)
2135 %(mmake)_LIBDIR := %(libdir)
2138 ifeq (%(build_abi),M)
2139 %(mmake)_LINKLIBCFILES := $(addprefix $(%(mmake)_OBJDIR)/linklib/,$(%(modname)_LINKLIBFILES))
2140 %(mmake)_LINKLIBAFILES := $(addprefix $(%(mmake)_OBJDIR)/linklib/,$(%(modname)_LINKLIBAFILES))
2141 ifeq ($(strip $(%(modname)_LINKLIBFILES) $(%(modname)_LINKLIBAFILES) %(linklibfiles) $(%(mmake)_ARCHNLIBFILES)),)
2144 %(mmake)_LINKLIB := $(%(mmake)_LIBDIR)/lib%(modname)$(%(mmake)_LIBSUFFIX).a
2145 ifneq (%(modname),$(%(mmake)_LINKLIBNAME))
2146 %(mmake)_LINKLIB += $(%(mmake)_LIBDIR)/lib$(%(mmake)_LINKLIBNAME)$(%(mmake)_LIBSUFFIX).a
2149 %(mmake)_LINKLIBFILES := $(%(mmake)_LINKLIBCFILES) $(%(mmake)_LINKLIBAFILES)
2151 %(mmake)_RELLINKLIBCFILES := $(addprefix $(%(mmake)_OBJDIR)/linklib/,$(%(modname)_RELLINKLIBFILES))
2152 %(mmake)_RELLINKLIBAFILES := $(addprefix $(%(mmake)_OBJDIR)/linklib/,$(%(modname)_RELLINKLIBAFILES))
2153 ifeq ($(strip $(%(modname)_RELLINKLIBFILES) $(%(modname)_RELLINKLIBAFILES) %(linklibfiles) $(%(mmake)_ARCHNLIBFILES)),)
2154 %(mmake)_RELLINKLIB :=
2156 %(mmake)_RELLINKLIB := $(%(mmake)_LIBDIR)/lib%(modname)_rel$(%(mmake)_LIBSUFFIX).a
2157 ifneq (%(modname),$(%(mmake)_LINKLIBNAME))
2158 %(mmake)_RELLINKLIB += $(%(mmake)_LIBDIR)/lib$(%(mmake)_LINKLIBNAME)_rel$(%(mmake)_LIBSUFFIX).a
2161 %(mmake)_RELLINKLIBFILES := $(%(mmake)_RELLINKLIBCFILES) $(%(mmake)_RELLINKLIBAFILES)
2164 %(mmake)_ENDOBJS := $(addsuffix .o,$(%(mmake)_ENDFILES))
2165 %(mmake)_LINKLIBOBJS:= $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/linklib/,$(notdir $(%(mmake)_NLIBARCHFILES))) $(addprefix $(%(mmake)_OBJDIR)/linklib/arch/,$(notdir $(%(mmake)_ARCHNLIBFILES))) $(%(mmake)_LINKLIBFILES)) \
2167 %(mmake)_RELLINKLIBOBJS := $(addsuffix .o,$(addprefix $(%(mmake)_OBJDIR)/linklib/,$(notdir $(%(mmake)_NLIBARCHFILES))) $(addprefix $(%(mmake)_OBJDIR)/linklib/arch/,$(notdir $(%(mmake)_ARCHNLIBFILES))) $(%(mmake)_RELLINKLIBFILES)) \
2169 $(%(mmake)_LINKLIBFILES) $(%(mmake)_RELLINKLIBFILES) : | $(%(mmake)_OBJDIR)/linklib
2170 $(%(mmake)_LINKLIBOBJS) $(%(mmake)_RELLINKLIBOBJS) : | $(%(mmake)_OBJDIR)/linklib
2172 %(mmake)_CCFILES := $(%(mmake)_C_NARCHFILES)
2173 %(mmake)_TARGETCCFILES := $(strip $(%(mmake)_STARTFILES) $(%(mmake)_ENDFILES))
2174 %(mmake)_LINKLIBCCFILES := $(strip $(%(mmake)_NLIBARCHFILES) $(%(mmake)_LINKLIBCFILES) $(%(mmake)_RELLINKLIBCFILES))
2175 %(mmake)_LINKLIBCCGENFILES := $(strip $(%(mmake)_LINKLIBCFILES) $(%(mmake)_RELLINKLIBCFILES))
2177 %rule_compile_cxx_multi mmake=%(mmake) \
2178 basenames=$(%(mmake)_CXX_NARCHFILES) targetdir="$(%(mmake)_OBJDIR)" \
2179 cppflags=$(%(mmake)_CPPFLAGS) cxxflags=$(%(mmake)_CXXFLAGS) dxxflags=$(%(mmake)_DXXFLAGS) \
2180 compiler="%(compiler)"
2181 %rule_compile_objc_multi mmake=%(mmake) \
2182 basenames=$(%(mmake)_OBJC_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
2183 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
2184 compiler="%(compiler)"
2185 %rule_compile_multi mmake=%(mmake) \
2186 basenames=$(%(mmake)_CCFILES) targetdir="$(%(mmake)_OBJDIR)" \
2187 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
2188 compiler="%(compiler)"
2189 %rule_compile_multi mmake=%(mmake) \
2190 basenames=$(%(mmake)_TARGETCCFILES) targetdir="$(%(mmake)_OBJDIR)" \
2191 cppflags="$(%(mmake)_CPPFLAGS) -D__AROS__" cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
2192 compiler="%(compiler)"
2193 %rule_compile_multi mmake=%(mmake) \
2194 basenames=$(%(mmake)_NLIBARCHFILES) targetdir="$(%(mmake)_OBJDIR)/linklib" \
2195 cppflags="$(%(mmake)_CPPFLAGS) -D__AROS__" cflags=$(%(mmake)_LINKLIBCFLAGS) dflags=$(%(mmake)_LINKLIBDFLAGS) \
2196 compiler="%(compiler)"
2197 %rule_compile_multi mmake=%(mmake) \
2198 basenames=$(%(mmake)_LINKLIBCCGENFILES) srcdir="$(%(mmake)_OBJDIR)/linklib" targetdir="$(%(mmake)_OBJDIR)/linklib" \
2199 cppflags="$(%(mmake)_CPPFLAGS) -D__AROS__" cflags=$(%(mmake)_LINKLIBCFLAGS) dflags=$(%(mmake)_LINKLIBDFLAGS) \
2200 compiler="%(compiler)"
2202 ifneq ($(%(mmake)_LINKLIBAFILES),)
2203 %rule_assemble_multi mmake=%(mmake) \
2204 cmd=$(%(mmake)_ASSEMBLER) basenames="$(%(mmake)_LINKLIBAFILES) $(%(mmake)_RELLINKLIBAFILES)" targetdir="$(%(mmake)_OBJDIR)/linklib" suffix=.S
2209 ifeq (%(modsuffix),)
2210 %(mmake)_SUFFIX := %(modtype)
2212 %(mmake)_SUFFIX := %(modsuffix)
2215 ifeq (%(build_library),M)
2216 # Handlers use dash instead of dot in their names
2217 ifeq ($(%(mmake)_SUFFIX),handler)
2218 %(mmake)_MODULE := %(prefix)/$(%(mmake)_MODDIR)/%(modname)-$(%(mmake)_SUFFIX)
2220 %(mmake)_MODULE := %(prefix)/$(%(mmake)_MODDIR)/%(modname).$(%(mmake)_SUFFIX)
2222 %(mmake)_KOBJ := $(KOBJSDIR)/%(modname)_$(%(mmake)_SUFFIX).o
2228 %(mmake)-quick : %(mmake)
2229 %(mmake) : $(%(mmake)_MODULE) $(%(mmake)_LINKLIB) $(%(mmake)_RELLINKLIB)
2230 ifeq (%(build_library),M)
2231 %(mmake)-kobj : $(%(mmake)_KOBJ) $(%(mmake)_LINKLIB) $(%(mmake)_RELLINKLIB)
2232 %(mmake)-kobj-quick : $(%(mmake)_KOBJ) $(%(mmake)_LINKLIB) $(%(mmake)_RELLINKLIB)
2234 ifeq (%(build_abi),M)
2235 %(mmake)-linklib : $(%(mmake)_LINKLIB) $(%(mmake)_RELLINKLIB)
2238 %(mmake)_OBJS := $(addsuffix .o,$(%(mmake)_STARTFILES)) $(%(mmake)_ARCHOBJS) \
2239 $(addprefix $(%(mmake)_OBJDIR)/,$(notdir $(%(mmake)_C_NARCHFILES:=.o) $(%(mmake)_CXXFILES:=.o)))
2241 ifeq (%(nostartup),yes)
2242 # Handlers always have entry point
2243 ifneq (%(modtype),handler)
2244 %(mmake)_STARTOBJS := $(addsuffix .o,$(addprefix $(GENDIR)/,$(RESIDENT_BEGIN)))
2248 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
2249 # This breaks con-handler build. Here we work around this
2250 ifeq (%(modname),con)
2251 %(mmake)_ERR := $(notdir $(%(mmake)_MODULE)).err
2253 %(mmake)_ERR := %(modname).err
2256 ifeq (%(build_library),M)
2257 # The module is linked from all the compiled .o files
2258 %rule_linkmodule module=$(%(mmake)_MODULE) objs="$(%(mmake)_STARTOBJS) $(%(mmake)_OBJS) $(USER_OBJS)" \
2259 endobj=$(%(mmake)_ENDOBJS) err=$(%(mmake)_ERR) objdir="$(%(mmake)_OBJDIR)" \
2260 cmd=$(%(mmake)_LINK) ldflags="$(LDFLAGS) $(%(modname)_LDFLAGS)" \
2261 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
2264 ifeq (%(build_abi),M)
2266 %(mmake)_LC_LINKLIBNAME := $(shell echo $(%(mmake)_LINKLIBNAME) | tr A-Z a-z)
2267 %(mmake)_LC_MODNAME := $(shell echo %(modname) | tr A-Z a-z)
2268 ifneq ($(%(mmake)_LINKLIB),)
2269 %rule_link_linklib mmake=%(mmake) libname="$(%(mmake)_LINKLIBNAME)$(%(mmake)_LIBSUFFIX)" objs=$(%(mmake)_LINKLIBOBJS) libdir="$(%(mmake)_LIBDIR)"
2270 ifneq ($(%(mmake)_LC_MODNAME),$(%(mmake)_LC_LINKLIBNAME))
2271 %rule_link_linklib mmake=%(mmake) libname="%(modname)$(%(mmake)_LIBSUFFIX)" objs=$(%(mmake)_LINKLIBOBJS) libdir="$(%(mmake)_LIBDIR)"
2274 $(%(mmake)_LINKLIB) : | $(%(mmake)_LIBDIR)
2275 GLOB_MKDIRS += $(%(mmake)_LIBDIR)
2278 ifneq ($(%(mmake)_RELLINKLIB),)
2279 %rule_link_linklib mmake=%(mmake) libname="$(%(mmake)_LINKLIBNAME)_rel$(%(mmake)_LIBSUFFIX)" objs=$(%(mmake)_RELLINKLIBOBJS) libdir="$(%(mmake)_LIBDIR)"
2280 ifneq ($(%(mmake)_LC_MODNAME),$(%(mmake)_LC_LINKLIBNAME))
2281 %rule_link_linklib mmake=%(mmake) libname="%(modname)_rel$(%(mmake)_LIBSUFFIX)" objs=$(%(mmake)_RELLINKLIBOBJS) libdir="$(%(mmake)_LIBDIR)"
2284 $(%(mmake)_RELLINKLIB) : | $(%(mmake)_LIBDIR)
2285 GLOB_MKDIRS += $(%(mmake)_LIBDIR)
2289 ifeq (%(build_library),M)
2290 # Link kernel object file
2291 %(mmake)_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
2293 # Make these symbols local
2294 %(mmake)_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
2295 UtilityBase ExpansionBase KeymapBase KernelBase
2297 %(mmake)_SYMBOLS := $(%(mmake)_KBASE)
2299 %(mmake)_KLIB := hiddstubs amiga arossupport autoinit libinit
2300 %(mmake)_KOBJ_LIBS := $(filter-out $(%(mmake)_KLIB),%(uselibs)) $(%(mmake)_KAUTOLIB)
2301 $(%(mmake)_KOBJ) : LINKLIBS:=$(%(mmake)_KOBJ_LIBS) $(%(modname)_LIBS)
2302 $(%(mmake)_KOBJ) : FILTBASES:=$(addprefix -L ,$(%(mmake)_SYMBOLS))
2303 $(%(mmake)_KOBJ) : USER_LDFLAGS:=$(USER_LDFLAGS)
2304 $(%(mmake)_KOBJ) : $(%(mmake)_OBJS) $(USER_OBJS) $(%(mmake)_ENDOBJS)
2305 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
2306 @$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
2307 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
2310 ## Dependency fine-tuning
2312 %(mmake)_DEPS := $(addprefix $(%(mmake)_OBJDIR)/,$(notdir $(%(mmake)_CCFILES:=.d) $(%(mmake)_TARGETCCFILES:=.d) $(%(mmake)_CXXFILES:=.d))) $(addprefix $(%(mmake)_OBJDIR)/linklib/,$(notdir $(%(mmake)_LINKLIBCCFILES:=.d)))
2314 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick" deps=$(%(mmake)_DEPS)
2316 $(%(mmake)_OBJS) $(%(mmake)_DEPS) : | $(%(mmake)_OBJDIR) $(%(mmake)_OBJDIR)/linklib
2317 $(%(mmake)_MODULE) : | %(prefix)/$(%(mmake)_MODDIR)
2318 $(%(mmake)_KOBJ) : | $(KOBJSDIR)
2319 GLOB_MKDIRS += $(%(mmake)_OBJDIR) %(prefix)/$(%(mmake)_MODDIR) $(KOBJSDIR)
2321 # Some include files need to be generated before the .c can be parsed.
2322 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick),) # Only for this target these deps are wanted
2324 %(mmake)_DFILE_DEPS := $(%(mmake)_LIBDEFSINC) $(%(mmake)_DEFLIBDEFSINC) \
2325 $(addprefix $(%(mmake)_INCDIR)/,$(%(modname)_INCLUDES))
2326 $(%(mmake)_DEPS) : $(%(mmake)_DFILE_DEPS)
2329 %(mmake)_TOCLEAN := $(%(mmake)_OBJS) $(%(mmake)_DEPS) \
2330 $(%(mmake)_MODULE) $(%(mmake)_LINKLIB) $(%(mmake)_KOBJ) \
2331 $(%(mmake)_OBJDIR)/Makefile.%(modname)%(modtype) \
2332 $(addprefix $(%(mmake)_OBJDIR)/include/,$(%(modname)_INCLUDES)) \
2333 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
2334 $(addprefix $(%(mmake)_INCDIR)/,$(%(modname)_INCLUDES)) \
2335 $(%(mmake)_OBJDIR)/%(modname)_geninc $(%(mmake)_OBJDIR)/%(modname)_incs \
2336 $(addsuffix .c,$(%(mmake)_LINKLIBFILES)) $(%(mmake)_LINKLIBOBJS) $(%(mmake)_LIBDEFSINC) \
2337 $(%(mmake)_DEFLIBDEFSINC) $(addsuffix .c,$(%(mmake)_STARTFILES) $(%(mmake)_ENDFILES)) \
2339 %(mmake)-clean : FILES := $(%(mmake)_TOCLEAN)
2341 @$(ECHO) "Cleaning up for module %(modname)"
2344 endif # $(TARGET) in $(%(mmake)_ALLTARGETS)
2346 #------------------------------------------------------------------------------
2348 #------------------------------------------------------------------------------
2349 # Build a module - ABI and library
2350 # Explanation of this macro is done in the developer's manual
2351 %define build_module mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2352 files="$(basename $(call WILDCARD, *.c))" \
2354 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2355 linklibfiles= linklibobjs= cflags=$(CFLAGS) cppflags=$(CPPFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= \
2356 objdir= moduledir= prefix=$(AROSDIR) \
2357 linklibname= uselibs= usehostlibs= \
2358 compiler=target lto=$(TARGET_LTO) nostartup=yes archspecific=no \
2362 %(mmake)_OBJDIR:=%(objdir)
2364 %(mmake)_OBJDIR:=$(OBJDIR)/%(modname)
2367 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2368 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2369 files="%(files)" objcfiles="%(objcfiles)" cxxfiles="%(cxxfiles)" \
2370 linklibname="%(linklibname)" \
2371 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2372 cflags="%(cflags)" cppflags="%(cppflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2373 objdir="$(%(mmake)_OBJDIR)" moduledir="%(moduledir)" prefix="%(prefix)" \
2374 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" lto=%(lto) \
2375 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2376 includedir="%(includedir)" libdir="%(libdir)" \
2377 build_abi=M build_library=M
2380 #------------------------------------------------------------------------------
2383 #------------------------------------------------------------------------------
2384 # Build a module skeleton ABI
2385 # This is a stripped-down version of build_module, it only creates include
2386 # files and the linklibs.
2387 # This is used when for plugins or classes with the same API, but no actual
2388 # implementation here.
2389 %define build_module_abi mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2390 linklibfiles= linklibobjs= cflags=$(CFLAGS) cppflags=$(CPPFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= \
2391 objdir= moduledir= prefix=$(AROSDIR) \
2392 linklibname= uselibs= usehostlibs= \
2393 compiler=target nostartup=yes archspecific=no \
2397 %(mmake)_OBJDIR:=%(objdir)
2399 %(mmake)_OBJDIR:=$(OBJDIR)/%(modname)
2402 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2403 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2404 linklibname="%(linklibname)" \
2405 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2406 cflags="%(cflags)" cppflags="%(cppflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2407 objdir="$(%(mmake)_OBJDIR)" moduledir="%(moduledir)" prefix="%(prefix)" \
2408 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" lto=%(lto) \
2409 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2410 includedir="%(includedir)" libdir="%(libdir)" \
2411 build_abi=M build_library=
2414 #------------------------------------------------------------------------------
2416 #------------------------------------------------------------------------------
2417 # Build a module library - no includes nor linklibs
2418 # Explanation of this macro is done in the developer's manual
2419 %define build_module_library mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2420 files="$(basename $(call WILDCARD, *.c))" \
2422 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2423 cflags=$(CFLAGS) cppflags=$(CPPFLAGS) dflags= cxxflags="$(CXXFLAGS)" dxxflags= \
2424 objdir= moduledir= prefix=$(AROSDIR) \
2425 uselibs= usehostlibs= \
2426 compiler=target lto=$(TARGET_LTO) nostartup=yes archspecific=no \
2430 %(mmake)_OBJDIR:=%(objdir)
2432 %(mmake)_OBJDIR:=$(OBJDIR)/%(modname)
2435 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2436 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2437 files="%(files)" objcfiles="%(objcfiles)" cxxfiles="%(cxxfiles)" \
2438 cflags="%(cflags)" cppflags="%(cppflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2439 objdir="$(%(mmake)_OBJDIR)" moduledir="%(moduledir)" prefix="%(prefix)" \
2440 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" lto=%(lto) \
2441 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2442 includedir="%(includedir)" libdir="%(libdir)" \
2443 build_abi= build_library=M
2446 #------------------------------------------------------------------------------
2450 #------------------------------------------------------------------------------
2452 # - mmake is the mmaketarget
2453 # - libname is the baselibname e.g. lib%(libname).a will be created
2454 # - files are the C source files to include in the lib. The list of files
2455 # has to be given without the .c suffix
2456 # - cxxfiles are C++ source files without suffix.
2457 # NB: files will be matched in the order .cpp > .cxx > .cc
2458 # - asmfiles are the asm files to include in the lib. The list of files has to
2459 # be given without the .s suffix
2460 # - objs additional object to link into the linklib. The objects have to be
2461 # given with full absolute path and the .o suffix.
2462 # - objdir is where the .o are generated. Defaults to $(GENDIR)/$(CURDIR)
2463 # - libdir is the directory where the linklib will be placed (default $(AROS_LIB))
2464 # - cflags are the flags to compile the source (default $(CFLAGS))
2465 # - dflags are the flags used during makedepend (default equal to cflags)
2466 # - aflags are the flags used during assembling (default $(AFLAGS))
2467 %define build_linklib mmake=/A libname=/A files= objcfiles= cxxfiles= \
2468 asmfiles= objs= objdir=$(GENDIR)/$(CURDIR) libdir=$(AROS_LIB) \
2470 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= cxxflags=$(CXXFLAGS) dxxflags= \
2471 aflags=$(AFLAGS) compiler=target lto=$(TARGET_LTO)
2473 # assign and generate the local variables used in this macro
2474 %(mmake)_LIBNAME := %(libname)
2475 %(mmake)_LINKLIB := %(libdir)/lib%(libname).a
2477 %(mmake)_FILES := %(files)
2478 %(mmake)_ASMFILES := %(asmfiles)
2479 %(mmake)_OBJCFILES := %(objcfiles)
2480 %(mmake)_CXXFILES := %(cxxfiles)
2482 %(mmake)_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
2483 %(mmake)_ARCHFILES := $(basename $(notdir $(%(mmake)_ARCHOBJS)))
2484 %(mmake)_C_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_FILES))
2485 %(mmake)_CXX_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_CXXFILES))
2486 %(mmake)_OBJC_NARCHFILES := $(filter-out $(%(mmake)_ARCHFILES),$(%(mmake)_OBJCFILES))
2488 %(mmake)_OBJS := $(%(mmake)_ARCHOBJS) \
2489 $(addprefix %(objdir)/,$(notdir $(%(mmake)_C_NARCHFILES:=.o) $(%(mmake)_CXX_NARCHFILES:=.o) $(%(mmake)_OBJC_NARCHFILES:=.o))) \
2491 %(mmake)_DEPS := $(patsubst %.o,%.d,$(%(mmake)_OBJS))
2493 %(mmake)_CPPFLAGS := %(cppflags)
2494 ifneq (%(includedir),)
2495 %(mmake)_CPPFLAGS += -I%(includedir)
2497 %(mmake)_CFLAGS := %(cflags)
2498 %(mmake)_CXXFLAGS := %(cxxflags)
2500 ifeq (%(compiler),target)
2501 %(mmake)_CFLAGS := $(strip $(LTO_CFLAGS) $(%(mmake)_CFLAGS))
2502 %(mmake)_CXXFLAGS := $(strip $(LTO_CFLAGS) $(%(mmake)_CXXFLAGS))
2505 %(mmake)_AFLAGS := %(aflags)
2506 %(mmake)_DFLAGS := %(dflags)
2508 %(mmake)_DFLAGS := %(dflags)
2510 %(mmake)_DFLAGS := $(%(mmake)_CFLAGS)
2512 %(mmake)_DXXFLAGS := %(dxxflags)
2513 ifneq (%(dxxflags),)
2514 %(mmake)_DXXFLAGS := %(dxxflags)
2516 %(mmake)_DXXFLAGS := $(%(mmake)_CXXFLAGS)
2519 .PHONY : %(mmake) %(mmake)-clean %(mmake)-quick
2522 %(mmake)-quick : %(mmake)
2524 #MM %(mmake) : includes-generate-deps
2525 %(mmake) : $(%(mmake)_LINKLIB)
2527 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
2529 %rule_compile_cxx_multi mmake=%(mmake) \
2530 basenames=$(%(mmake)_CXX_NARCHFILES) targetdir="%(objdir)" \
2531 cppflags=$(%(mmake)_CPPFLAGS) cxxflags=$(%(mmake)_CXXFLAGS) dxxflags=$(%(mmake)_DXXFLAGS) \
2532 compiler="%(compiler)"
2533 %rule_compile_objc_multi mmake=%(mmake) \
2534 basenames=$(%(mmake)_OBJC_NARCHFILES) targetdir=$(%(mmake)_OBJDIR) \
2535 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
2536 compiler="%(compiler)"
2537 %rule_compile_multi mmake=%(mmake) \
2538 basenames=$(%(mmake)_C_NARCHFILES) targetdir="%(objdir)" \
2539 cppflags=$(%(mmake)_CPPFLAGS) cflags=$(%(mmake)_CFLAGS) dflags=$(%(mmake)_DFLAGS) \
2540 compiler="%(compiler)"
2541 %rule_assemble basename=% targetdir="%(objdir)" \
2542 aflags=$(%(mmake)_AFLAGS)
2544 %rule_link_linklib mmake=%(mmake) libname="%(libname)" objs=$(%(mmake)_OBJS) libdir="%(libdir)" linker="%(compiler)"
2547 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(%(mmake)_DEPS)
2549 $(%(mmake)_OBJS) $(%(mmake)_DEPS) : | %(objdir)
2550 $(%(mmake)_LINKLIB) : | %(libdir)
2551 GLOB_MKDIRS += %(objdir) %(libdir)
2553 %(mmake)-clean : FILES := $(%(mmake)_OBJS) $(%(mmake)_LINKLIB) $(%(mmake)_DEPS)
2556 @$(ECHO) "Cleaning up for metatarget %(mmake)"
2560 #------------------------------------------------------------------------------
2563 #------------------------------------------------------------------------------
2565 # - mmake is the mmaketarget
2566 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
2567 # - description is the catalog description file (.cd), without the .cd suffix (default *.cd)
2568 # - subdir is the destination subdirectory of the catalogs
2569 # - name is the name of the destination catalog, without the .catalog suffix
2570 # - source is the path to the generated source code file
2571 # - dir is the base destination directory (default $(AROS_CATALOGS))
2572 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
2573 # - srcdir is the directory in which the *.cd and *.ct files are searched
2575 %define build_catalogs mmake=/A name=/A subdir=/A \
2576 catalogs= source="../strings.h" description= dir=$(AROS_CATALOGS) \
2577 sourcedescription=$(TOOLDIR)/C_h_aros srcdir=$(SRCDIR)/$(CURDIR)
2579 ifeq (%(description),)
2580 %(mmake)_DESC := $(basename $(wildcard %(srcdir)/*.cd))
2582 %(mmake)_DESC := %(description)
2585 %(mmake)_SRC := $(shell echo %(sourcedescription) | sed 's/^\(.\):\//\/\1\//')
2588 %(mmake)_LNGS := $(basename $(notdir $(call WILDCARD, %(srcdir)/*.ct)))
2590 %(mmake)_LNGS := %(catalogs)
2593 %(mmake)_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, $(%(mmake)_LNGS)))
2594 %(mmake)_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, $(%(mmake)_LNGS))) $(dir %(source))
2597 %(mmake) : $(%(mmake)_OBJS) %(source)
2599 $(%(mmake)_OBJS) : | $(%(mmake)_DIRS)
2600 GLOB_MKDIRS += $(%(mmake)_DIRS)
2602 %(dir)/%/%(subdir)/%(name).catalog : %(srcdir)/%.ct $(%(mmake)_DESC).cd
2603 @$(ECHO) "Creating %(name) catalog for language $*."
2604 @$(FLEXCAT) $(%(mmake)_DESC).cd $< CATALOG="%(dir)/$*/%(subdir)/%(name).catalog" || [ $$? -lt 10 ]
2607 %(source) : %(mmake)_DESC := $(%(mmake)_DESC)
2608 %(source) : %(mmake)_SRC := $(%(mmake)_SRC)
2609 %(source) : $(%(mmake)_DESC).cd $(%(mmake)_SRC).sd | $(dir %(source))
2610 @$(ECHO) "Creating %(name) catalog source file $@"
2611 @$(FLEXCAT) $(%(mmake)_DESC).cd $@=$(%(mmake)_SRC).sd
2614 %(mmake)-clean : FILES := $(%(mmake)_OBJS) %(source)
2617 @$(ECHO) "Cleaning up for metatarget %(mmake)"
2620 .PHONY: %(mmake) %(mmake)-clean
2623 #-----------------------------------------------------------------------------
2626 #-----------------------------------------------------------------------------
2628 # - mmake is the mmaketarget
2629 # - icons is a list of icon base names (i.e. without the .info suffix)
2630 # - dir is the destination directory
2631 # - srcdir is where *.png and *.info.src are sought
2632 #-----------------------------------------------------------------------------
2634 %define build_icons mmake=/A icons=/A dir=/A srcdir=$(SRCDIR)/$(CURDIR) image=
2636 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
2639 %(mmake) : $(BD_OBJS)
2643 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%.png
2644 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2645 @$(ILBMTOICON) $+ $@
2649 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%(image)
2650 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2651 @$(ILBMTOICON) $+ $@
2655 $(BD_OBJS) : | %(dir)
2656 GLOB_MKDIRS += %(dir)
2658 %(mmake)-clean : FILES := $(BD_OBJS)
2663 .PHONY: %(mmake) %(mmake)-clean
2666 #-----------------------------------------------------------------------------
2669 #------------------------------------------------------------------------------
2670 # Compile files for an arch-specific replacement of code for a module
2671 # - files: the basenames of the C files to compile.
2672 # - asmfiles: the basenames of the asm files to assemble.
2673 # - mainmmake: the mmake of the module in the main directory to compile these
2674 # arch specific files for.
2675 # - maindir: the object directory for the main module
2676 # - arch: the arch for which to compile these files. It can have the form
2677 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
2678 # - cflags (default $(CFLAGS)): the C flags to use for compilation
2679 # - dflags: the flags used during creation of dependency file. If not specified
2680 # the same value as cflags will be used
2681 # - aflags: the flags used during assembling
2682 # - compiler: (host, kernel or target) specifies which compiler to use. By default
2683 # the target compiler is used
2684 # - modname: arch_specific builds of modules (built using build_module) MUST
2685 # specify the name here matching the original module. this insures multiple modules
2686 # built from the same makefile will not pollute each other.
2687 %define build_archspecific files= cxxfiles= asmfiles= linklibfiles= linklibobjs= mainmmake=/A maindir=/A arch=/A \
2688 cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target objdir= modname=
2690 ifeq (%(files) %(linklibfiles) %(linklibobjs) %(asmfiles),)
2691 $(error no files or asmfiles given)
2694 ifneq (%(cxxfiles),)
2695 $(error cxx support is TODO)
2698 %buildid targets="%(mainmmake)-%(arch)"
2700 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2701 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2702 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2703 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2704 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2705 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2706 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2707 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2708 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2709 #MM- %(mainmmake)-kobj-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2710 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2711 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2712 #MM- %(mainmmake)-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2713 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2714 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2716 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
2719 BD_OBJROOT$(BDID) := %(objdir)
2722 BD_OBJROOT$(BDID) := $(GENDIR)/%(maindir)/%(modname)
2724 BD_OBJROOT$(BDID) := $(GENDIR)/%(maindir)
2727 BD_OBJDIR$(BDID) := $(BD_OBJROOT$(BDID))/arch
2728 BD_LIBOBJDIR$(BDID) := $(BD_OBJROOT$(BDID))/linklib/arch
2729 BD_FILEOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files)))) $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(cxxfiles))))
2730 BD_LINKLIBOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibfiles))))
2731 BD_LINKLIBARCHOBJS$(BDID) := $(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibobjs)))
2732 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
2733 BD_OBJS$(BDID) := $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) $(BD_ASMOBJS$(BDID))
2734 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files)))) $(addsuffix .d,$(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibfiles))))
2737 BD_DEFLIBDEFSINC$(BDID) := -include $(BD_OBJROOT$(BDID))/include/%(modname)_deflibdefs.h
2740 ifeq ($(TARGET),%(mainmmake)-%(arch)-quick)
2741 BD_TARGET := %(mainmmake)-%(arch)-quick
2743 BD_TARGET := %(mainmmake)-%(arch)
2747 ifeq ($(TARGET),$(BD_TARGET))
2748 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
2749 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(files)))
2750 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(linklibfiles)))
2751 vpath %.s $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2752 vpath %.S $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2755 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID)) $(BD_LIBOBJDIR$(BDID))
2756 GLOB_MKDIRS += $(BD_OBJDIR$(BDID)) $(BD_LIBOBJDIR$(BDID))
2759 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
2762 %(mainmmake)-%(arch)-quick :: $(BD_OBJS$(BDID))
2764 ifeq ($(findstring %(compiler),host kernel target),)
2765 $(error unknown compiler %(compiler))
2768 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=$(strip %(cppflags) -I$(BD_OBJROOT$(BDID)) $(BD_DEFLIBDEFSINC$(BDID)))
2770 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=%(cppflags)
2772 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
2773 ifeq (%(compiler),target)
2774 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(strip $(TARGET_CC) $(TARGET_SYSROOT))
2775 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=$(TMP_CPPFLAGS)
2776 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=$(strip $(TMP_CFLAGS) $(SAFETY_CFLAGS))
2777 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
2778 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
2780 ifeq (%(compiler),host)
2781 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(HOST_CC)
2782 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
2783 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
2785 ifeq (%(compiler),kernel)
2786 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))
2787 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CPPFLAGS:=$(strip $(KERNEL_CPPFLAGS) $(TMP_CPPFLAGS))
2788 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=$(strip $(ISA_FLAGS) $(KERNEL_CFLAGS) $(TMP_CFLAGS))
2789 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
2790 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
2793 ifeq ($(TARGET),$(BD_TARGET))
2794 $(BD_LIBOBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2795 %compile_q cmd=$(TMP_CMD) opt="$(strip $(TMP_CFLAGS) $(TMP_CPPFLAGS))" iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2796 $(BD_OBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2797 %compile_q cmd=$(TMP_CMD) opt="$(strip $(TMP_CFLAGS) $(TMP_CPPFLAGS))" iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2801 $(BD_DEPS$(BDID)) : TMP_CPPFLAGS:=$(strip %(cppflags) $(BD_DEFLIBDEFSINC$(BDID)))
2802 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags)
2804 $(BD_DEPS$(BDID)) : TMP_CPPFLAGS:=%(cppflags)
2805 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
2807 ifeq ($(TARGET),$(BD_TARGET))
2808 $(BD_LIBOBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2809 %mkdepend_q cc=$(TMP_CMD) flags="$(strip $(TMP_DFLAGS) $(TMP_CPPFLAGS))"
2811 $(BD_OBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2812 %mkdepend_q cc=$(TMP_CMD) flags="$(strip $(TMP_DFLAGS) $(TMP_CPPFLAGS))"
2815 $(BD_ASMOBJS$(BDID)) : CPPFLAGS:=%(cppflags)
2816 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
2818 ifeq ($(TARGET),$(BD_TARGET))
2819 $(BD_OBJDIR$(BDID))/%.o : %.s
2821 $(BD_OBJDIR$(BDID))/%.o : %.S
2825 %include_deps depstargets=$(BD_TARGET) deps=$(BD_DEPS$(BDID))
2827 #------------------------------------------------------------------------------
2830 #------------------------------------------------------------------------------
2831 # generate asm files from c files (for debugging purposes)
2834 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
2835 @$(TARGET_CC) $(TARGET_SYSROOT) -S $(CFLAGS) $(CPPFLAGS) $< -c -o $@
2837 #------------------------------------------------------------------------------
2840 #------------------------------------------------------------------------------
2841 # Copy files from one directory to another.
2843 %define copy_files_q mmake=/A files=$(FILES) src=. dst=/A
2845 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
2847 GLOB_MKDIRS += %(dst)
2853 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC))/, $(file)) $(addprefix %(dst)/, $(file))))
2856 #------------------------------------------------------------------------------
2859 #------------------------------------------------------------------------------
2860 # Copy a directory recursively to another place, preserving the original
2861 # hierarchical structure
2863 # src: the source directory whose content will be copied.
2864 # dst: the directories where to copy src's content. If not existing, they will be made.
2865 # excludefiles: files which must not be copied. Path must be relative to src.
2867 %define copy_dir_recursive mmake=/A src=. dst=/A excludefiles=
2873 @cd $(SRCDIR)/$(CURDIR) && $(CPYDIRREC) -s %(src) -d %(dst) -e %(excludefiles)
2876 #------------------------------------------------------------------------------
2879 #------------------------------------------------------------------------------
2880 # Copy include files into the includes directories. There are currently
2881 # two include directories. One for building AROS $(AROS_INCLUDES) and one
2882 # for building tools that need to run on the host system $(GENINCDIR). The
2883 # $(GENINCDIR) path must not contain any references to the C runtime
2884 # library header files.
2886 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
2887 dir= compiler=target includedir=$(AROS_INCLUDES)
2889 ifeq ($(findstring %(compiler),host kernel target),)
2890 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
2895 $(eval TMP_DIRREMAIN := $$$(TMP_DIR))
2896 TMP_DIRFIRST := $(subst $(TMP_DIRREMAIN),,$(TMP_DIR))
2897 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),$(dir %(includes)))
2898 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,$(notdir %(includes)))
2899 ifeq ($(TMP_DIRFIRST),/)
2900 BD_INC_PATH := %(dir)/
2902 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
2905 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
2906 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
2909 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
2912 ifeq (%(compiler),target)
2915 BD_INCL_FILES2 := $(subst %(dir),%(includedir)/%(path),$(dir %(includes)))
2916 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,$(notdir %(includes)))
2918 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,%(includes))
2921 BD_INCL_FILES += $(BD_INCL_FILES2)
2923 $(BD_INCL_FILES2) : %(includedir)/%(path)/% : $(BD_INC_PATH)%
2928 %(mmake) : $(BD_INCL_FILES)
2932 $(BD_INCL_FILES) : | $(dir $(BD_INCL_FILES))
2933 GLOB_MKDIRS += $(dir $(BD_INCL_FILES))
2935 #------------------------------------------------------------------------------
2938 #------------------------------------------------------------------------------
2939 %define make_hidd_stubs hidd=/A cppflags=$(CPPFLAGS) cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
2940 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
2941 STUBS_MEM := $(addsuffix .o,$(STUBS))
2942 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
2943 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
2944 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
2946 #MM- linklibs : hidd-%(hidd)-stubs
2947 #MM- %(parenttarget): hidd-%(hidd)-stubs
2948 #MM hidd-%(hidd)-stubs : includes includes-copy
2949 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
2951 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
2954 $(STUBS_OBJ) : $(STUBS_SRC)
2955 %compile_q cmd="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" opt="$(strip %(cflags) %(cppflags))" iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
2957 $(STUBS_DEP) : $(STUBS_SRC)
2958 %mkdepend_q flags="$(strip %(dflags) %(cppflags))"
2961 %mkdirs_q $(OBJDIR) $(AROS_LIB)
2965 -@$(RM) $(HIDD_LIB) $(OBJDIR)
2967 DEPS := $(DEPS) $(STUBS_DEP)
2970 #------------------------------------------------------------------------------
2973 #------------------------------------------------------------------------------
2974 # Build an imported source tree which uses the configure script from the
2975 # autoconf package. This rule will try to "integrate" the produced files as
2976 # much as possible in the AROS build, for example by putting libraries in the
2977 # standard library directory, includes in the standard include directory, and
2978 # so on. You can however override this behaviour.
2980 # As a special "bonus" for you, the PROGDIR environment variable is defined to
2981 # be %(bindir) (or its deduced value) when running "make install", and
2982 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
2983 # configure script some more parameters whose value depends upon the PROGDIR
2984 # env var, so that the program gets all its stuff installed in the proper place
2985 # when building it, but when running it from inside AROS it can also find that
2986 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
2987 # the configuration parameters set when running ./configure
2989 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
2990 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
2991 # to the name which has to follow it.
2995 # - mmake = the meta make target.
2996 # - package = name of the package to be built.
2997 # - srcdir = the location of the unpacked source code. Defaults
2998 # to $(SRCDIR)/$(CURDIR).
2999 # - prefix = the target directory. Must be an absolute path of the
3000 # host system. Defaults to $(AROS_CONTRIB).
3001 # - aros_prefix = set a path which is valid within the AROS filesystem.
3002 # Defaults to the value of the prefix option.
3003 # - extraoptions = additional options for the configure script.
3004 # - usecppflags = enable the use of cpp flags. some external configure
3005 # scripts will not set their own cppflags if it is already
3006 # set, so this allows them to be disabled (unless you can provide
3007 # all the options they would need)
3008 # - extracppflags = additional preprocessor flags.
3009 # - extracflags = additional flags to use with the C compiler.
3010 # - extracxxflags = additional flags to use with the C++ compiler.
3011 # - nix_dir_layout = if yes the binary will be stored in a bin subdirectory.
3012 # Defaults to the value of the nix argument.
3013 # - nix = enable u*nix path handling, i.e. a path like
3014 # /progdir//./file will be translated to
3015 # progdir:file during run-time. Defaults to no.
3016 # - compiler = target, host or kernel. Defaults to target.
3017 # - install_target = the command used for installing. Defaults to install. Leave
3018 # it empty if you want to suppress installing.
3019 # - preconfigure = a metatarget which is executed before configure is called.
3020 # - postconfigure = a metatarget which is executed after configure is called.
3021 # - postinstall = a metatarget which is executed after installing.
3022 # - install_env = set additional options for installing.
3023 # - use_build_env = if yes the configuration environment is used for
3024 # installing, too. Defaults to no.
3026 # The arguments aros_prefix, nix and nix_dir_layout are related. The logic is
3030 # --prefix = $(aros_prefix)
3031 # progdir = $(aros_prefix)/bin
3034 # --prefix = /PROGDIR
3035 # --bindir = /PROGDIR
3036 # --sbindir = /PROGDIR
3038 # --includedir = /INCLUDE
3039 # --oldincludedir = /INCLUDE
3041 # --prefix = $(aros_prefix)
3044 # progdir = $(aros_prefix)
3047 # bindir = $(prefix)
3048 # sbindir = $(prefix)
3049 # libdir = $(AROS_LIB)
3050 # includedir = $(AROS_INCLUDES)
3051 # oldincludedir = $(AROS_INCLUDES)
3055 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) \
3056 prefix= gendir= basedir=$(CURDIR) extraoptions= \
3057 usecppflags=yes extracppflags= extracflags="$(OPTIMIZATION_CFLAGS)" extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3058 hostisaflags="$(ISA_FLAGS)" targetisaflags="$(ISA_FLAGS)" \
3059 aros_prefix= nix_dir_layout= nix=no compiler=target crossbuild=no \
3060 install_target=install preconfigure= postconfigure= postinstall= \
3061 config_env_extra= install_env= use_build_env=no buildflags=yes gnuflags=yes nlsflag=yes xflag=yes
3064 %(mmake)-prefix := %(prefix)
3066 %(mmake)-prefix := $(AROS_CONTRIB)
3069 ifneq (%(aros_prefix),)
3070 %(mmake)-aros_prefix := %(aros_prefix)
3072 %(mmake)-aros_prefix := $(%(mmake)-prefix)
3078 %(mmake)-nix := $(BD_NIXFLAG)
3079 %(mmake)-volpfx := /
3080 %(mmake)-volsfx := /
3082 ifeq (%(nix_dir_layout),)
3083 %(mmake)-nix_dir_layout := yes
3086 %(mmake)-volsfx := :
3088 ifeq (%(nix_dir_layout),)
3089 %(mmake)-nix_dir_layout := no
3093 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
3095 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
3096 exec_prefix=$(%(mmake)-prefix) %(install_env)
3098 # Check if chosen compiler is valid
3099 ifeq ($(findstring %(compiler),host target kernel),)
3100 $(error unknown compiler %(compiler))
3103 # Set legacy 'host' variable based on chosen compiler
3104 ifeq (%(compiler),host)
3107 %(mmake)-pkgbasedir := $(HOSTGENDIR)
3109 %(mmake)-pkgbasedir := $(HOSTGENDIR)/%(basedir)
3114 %(mmake)-pkgbasedir := $(GENDIR)
3116 %(mmake)-pkgbasedir := $(GENDIR)/%(basedir)
3121 %(mmake)-pkgbasedir := %(gendir)
3123 %(mmake)-pkgbasedir := %(gendir)/%(basedir)
3128 %(mmake)-pkgdir := $(%(mmake)-pkgbasedir)
3130 %(mmake)-pkgdir := $(%(mmake)-pkgbasedir)/%(package)
3133 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
3134 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
3136 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
3137 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
3138 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
3141 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
3142 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
3144 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
3147 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
3149 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
3150 sbindir=$(%(mmake)-prefix) \
3151 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
3152 oldincludedir=$(AROS_INCLUDES) %(install_env)
3155 ifneq ($(DEBUG),yes)
3156 %(mmake)-s_flag = -s
3159 # Set up build environment, and options for configure script
3160 ifeq (%(compiler),host)
3161 # NB: We need to pass in our crosstoolsdir, but cannot set CFLAGS since it
3162 # confused configure scripts. We also cannot pass it via _FOR_BUILD
3163 # since that won't get picked up during configure.
3164 # We also cannot pass in the compiler including std flags so we need to use
3165 # the "plain" host compiler.
3166 %(mmake)-cfg-env := %(config_env_extra) \
3168 CXXCPP="$(HOST_CPP)" \
3169 CC="$(strip $(HOST_DEF_CC) $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include)" \
3170 CXX="$(strip $(HOST_CXX) $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include)" \
3171 LDFLAGS="-L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS)"
3172 ifeq (%(usecppflags),yes)
3173 %(mmake)-cfg-env += TARGET_CPPFLAGS="$(KERNEL_CPPFLAGS)"
3175 %(mmake)-cfg-env += TARGET_CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
3176 TARGET_CFLAGS="$(strip %(targetisaflags) $(KERNEL_CFLAGS) $(%(mmake)-s_flag))" \
3177 TARGET_CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
3178 TARGET_CXXFLAGS="$(strip $(KERNEL_CXXFLAGS) $(%(mmake)-s_flag))" \
3179 TARGET_AS="$(TARGET_AS)" \
3180 OBJCOPY="$(OBJCOPY)" \
3181 TARGET_RANLIB="$(RANLIB)" \
3182 TARGET_STRIP="$(STRIP_PLAIN)" \
3183 TARGET_NM="$(NM_PLAIN)" \
3184 TARGET_OBJCOPY="$(TARGET_OBJCOPY)"
3186 ifeq (%(compiler),target)
3187 %(mmake)-cfg-env := %(config_env_extra) \
3188 PKG_CONFIG_LIBDIR="$(AROS_DEVELOPER)/lib/pkgconfig" \
3189 PKG_CONFIG_SYSROOT_DIR="$(AROSDIR)"
3190 %(mmake)-cfg-env += CPP="$(strip $(TARGET_CPP) $(TARGET_SYSROOT))" \
3191 CXXCPP="$(strip $(TARGET_CPP) $(TARGET_SYSROOT))" \
3192 CC="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
3193 CXX="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
3194 LD="$(strip $(TARGET_LD))"
3195 ifeq (%(crossbuild),yes)
3196 %(mmake)-cfg-env += CFLAGS="$(strip %(targetisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) %(extracflags) $(%(mmake)-s_flag))" \
3197 CXXFLAGS="$(strip %(targetisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) %(extracxxflags) $(%(mmake)-s_flag))"
3198 ifeq (%(usecppflags),yes)
3199 %(mmake)-cfg-env += CPPFLAGS="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3202 %(mmake)-cfg-env += CFLAGS="$(strip %(targetisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) %(extracflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3203 CXXFLAGS="$(strip %(targetisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) %(extracxxflags) $(%(mmake)-nix) $(%(mmake)-s_flag))"
3204 ifeq (%(usecppflags),yes)
3205 %(mmake)-cfg-env += CPPFLAGS="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3208 %(mmake)-cfg-env += LDFLAGS="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))"
3209 ifeq (%(usecppflags),yes)
3210 %(mmake)-cfg-env += CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)"
3212 %(mmake)-cfg-env += CC_FOR_BUILD="$(strip $(HOST_DEF_CC))" \
3213 CFLAGS_FOR_BUILD="$(strip $(HOST_CFLAGS) $(%(mmake)-s_flag))" \
3214 CXX_FOR_BUILD="$(strip $(HOST_CXX))" \
3215 CXXFLAGS_FOR_BUILD="$(strip $(HOST_CXXFLAGS) $(%(mmake)-s_flag))" \
3216 LD_FOR_BUILD="$(strip $(HOST_LD))" \
3217 LDFLAGS_FOR_BUILD="$(strip $(HOST_LDFLAGS) $(%(mmake)-s_flag))"
3218 ifeq (%(usecppflags),yes)
3219 %(mmake)-cfg-env += CPPFLAGS_FOR_HOST="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3221 %(mmake)-cfg-env += CC_FOR_HOST="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
3222 CFLAGS_FOR_HOST="$(strip %(hostisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) -L$(AROS_DEVELOPER)/lib %(extracflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3223 CXX_FOR_HOST="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
3224 CXXFLAGS_FOR_HOST="$(strip %(hostisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) -L$(AROS_DEVELOPER)/lib %(extracxxflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3225 LD_FOR_HOST="$(strip $(TARGET_LD))" \
3226 LDFLAGS_FOR_HOST="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))"
3227 ifeq (%(usecppflags),yes)
3228 %(mmake)-cfg-env += CPPFLAGS_FOR_TARGET="$(strip $(BASE_CPPFLAGS) $(USER_CPPFLAGS) %(extracppflags))"
3230 %(mmake)-cfg-env += CC_FOR_TARGET="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
3231 CFLAGS_FOR_TARGET="$(strip %(targetisaflags) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) -L$(AROS_DEVELOPER)/lib %(extracflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3232 CXX_FOR_TARGET="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
3233 CXXFLAGS_FOR_TARGET="$(strip %(targetisaflags) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) -L$(AROS_DEVELOPER)/lib %(extracxxflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3234 LD_FOR_TARGET="$(strip $(TARGET_LD))" \
3235 LDFLAGS_FOR_TARGET="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
3236 AR="$(strip $(AR_PLAIN))" \
3237 AS="$(strip $(TARGET_AS))" \
3238 OBJCOPY="$(strip $(OBJCOPY))" \
3239 RANLIB="$(strip $(RANLIB))" \
3240 STRIP="$(strip $(STRIP_PLAIN))"
3241 ifeq (%(usecppflags),yes)
3242 %(mmake)-cfg-env += TARGET_CPPFLAGS="$(KERNEL_CPPFLAGS)"
3244 %(mmake)-cfg-env += TARGET_CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
3245 TARGET_CFLAGS="$(strip %(targetisaflags) $(KERNEL_CFLAGS) $(%(mmake)-s_flag))" \
3246 TARGET_CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
3247 TARGET_CXXFLAGS="$(strip $(KERNEL_CXXFLAGS) $(%(mmake)-s_flag))" \
3248 TARGET_AS="$(strip $(TARGET_AS))" \
3249 TARGET_RANLIB="$(strip $(RANLIB))" \
3250 TARGET_STRIP="$(strip $(STRIP_PLAIN))" \
3251 TARGET_NM="$(strip $(NM_PLAIN))"
3252 ifeq (%(buildflags),yes)
3253 %(mmake)-config_opts += --target=$(AROS_TARGET_CPU)-aros
3254 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)
3255 %(mmake)-config_opts += --host=$(AROS_TARGET_CPU)-aros
3257 ifeq (%(gnuflags),yes)
3258 %(mmake)-config_opts += --without-pic --disable-shared
3259 ifeq (%(nlsflag),yes)
3260 # disable native language support
3261 %(mmake)-config_opts += --disable-nls
3264 # disable X window system
3265 %(mmake)-config_opts += --without-x
3269 ifeq (%(compiler),kernel)
3270 %(mmake)-cfg-env := %(config_env_extra) \
3271 CPP="$(KERNEL_CPP)" \
3272 CXXCPP="$(KERNEL_CPP)"
3273 ifeq (%(usecppflags),yes)
3274 %(mmake)-cfg-env += CPPFLAGS="$(strip $(KERNEL_CPPFLAGS) %(extracppflags))"
3276 %(mmake)-cfg-env += CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
3277 CFLAGS="$(strip %(targetisaflags) $(KERNEL_CFLAGS) %(extracflags) $(%(mmake)-s_flag))" \
3278 CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
3279 CXXFLAGS="$(strip $(KERNEL_CXXFLAGS) %(extracxxflags) $(%(mmake)-s_flag))" \
3281 ifeq (%(usecppflags),yes)
3282 %(mmake)-cfg-env += CPPFLAGS_FOR_BUILD="$(HOST_CPPFLAGS)"
3284 %(mmake)-cfg-env += CC_FOR_BUILD="$(HOST_DEF_CC)" \
3285 CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
3286 CXX_FOR_BUILD="$(HOST_CXX)" \
3287 CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
3288 RANLIB="$(RANLIB)" \
3289 TARGET_RANLIB="$(RANLIB)" \
3290 TARGET_STRIP="$(STRIP_PLAIN)" \
3291 TARGET_NM="$(NM_PLAIN)"
3292 ifeq (%(buildflags),yes)
3293 %(mmake)-config_opts += --target=$(AROS_TARGET_CPU)-aros
3294 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)
3295 %(mmake)-config_opts += --host=$(AROS_TARGET_CPU)-aros
3297 ifeq (%(gnuflags),yes)
3298 %(mmake)-config_opts += --without-pic --disable-shared
3299 ifeq (%(nlsflag),yes)
3300 # disable native language support
3301 %(mmake)-config_opts += --disable-nls
3304 # disable X window system
3305 %(mmake)-config_opts += --without-x
3311 ifeq (%(use_build_env),yes)
3312 BUILD_ENV := $(%(mmake)-cfg-env)
3315 ifneq ("$(wildcard %(srcdir)/Makefile)","")
3316 # in an ideal world, we would depend on the files in the source directory,
3317 # so we could copy them when they change. unfortunately filenames with
3318 # spaces causes problems with this
3319 $(%(mmake)-pkgdir)/.local-copy:
3320 %mkdirs_q $(%(mmake)-pkgdir)
3321 @$(ECHO) "Copying Local-Build Sources to \`$(patsubst $(TOP)/%,%,$(abspath $(%(mmake)-pkgdir)))'"
3322 @$(CP) -Rf "%(srcdir)/." $(%(mmake)-pkgdir)/ && $(TOUCH) $@
3324 $(%(mmake)-pkgdir)/.files-touched : $(%(mmake)-pkgdir)/.local-copy
3326 %(mmake)-cfg-srcdir=$(%(mmake)-pkgdir)
3328 %(mmake)-cfg-srcdir=%(srcdir)
3330 %(mmake)-make-env := -C $(%(mmake)-pkgdir)
3332 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3334 # When building for the host, we don't need to build the
3335 # linklibs - this is especially true when building the
3336 # crosstool toolchain on 'foreign' architectures (such as
3337 # building PPC on x86)
3339 #MM- %(mmake)-host : setup includes %(mmake)-quick
3340 #MM- %(mmake)-target : setup includes core-linklibs %(mmake)-quick
3341 #MM- %(mmake): %(mmake)-%(compiler)
3343 # Using -j1 in install_command may result in a warning but finally
3344 # it does its job. make install for gcc does not work reliably for -jN
3346 ifneq (%(install_target),)
3347 %(mmake)-install_command = \
3348 $(ECHO) "Installing from build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))" && \
3349 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
3350 $(%(mmake)-make-env) %(install_target) -j1
3352 %(mmake)-uninstall_command = \
3353 $(RM) $(%(mmake)-installflag) && \
3354 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" \
3355 $(%(mmake)-install_opts) $(%(mmake)-make-env) uninstall
3357 %(mmake)-install_command := true
3358 %(mmake)-uninstall_command := true
3361 #MM- %(mmake)-quick : %(preconfigure) %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
3364 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3367 # N.B.: the make test for the targets being up to date generates a benign Error 1.
3369 $(%(mmake)-installflag) : $(%(mmake)-configflag)
3370 @$(IF) ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q $(%(mmake)-make-env); then \
3371 $(RM) $(%(mmake)-installflag) && \
3372 $(ECHO) "Performing build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))" && \
3373 $(BUILD_ENV) $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" $(%(mmake)-make-env) && \
3374 $(%(mmake)-install_command) && \
3375 $(TOUCH) $@ -r $^; \
3378 $(%(mmake)-pkgdir)/.files-touched:
3379 %mkdirs_q $(%(mmake)-pkgdir)
3380 @find %(srcdir) -exec $(TOUCH) -c -r $(%(mmake)-cfg-srcdir)/configure '{}' \; && \
3384 %(mmake)-uninstall :
3385 $(%(mmake)-uninstall_command)
3388 %(mmake)-configure : $(%(mmake)-configflag)
3390 $(%(mmake)-configflag) : TMP_SRCDIR := $(shell echo $(%(mmake)-cfg-srcdir) | sed 's/^\(.\):\//\/\1\//')
3391 $(%(mmake)-configflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
3393 %mkdirs_q $(%(mmake)-pkgdir)
3394 @$(ECHO) "Configuring build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))"
3395 @cd $(%(mmake)-pkgdir) && \
3396 find . -name config.cache -exec $(RM) '{}' \; && \
3397 $(%(mmake)-cfg-env) $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) %(extraoptions) && \
3401 %(mmake)-clean : %(mmake)-uninstall
3402 @$(RM) $(%(mmake)-pkgdir)
3404 #------------------------------------------------------------------------------
3407 #------------------------------------------------------------------------------
3408 # Build an imported source tree which uses cmake
3412 # - mmake = the meta make target.
3413 # - package = name of the package to be built.
3414 # - srcdir = the location of the unpacked source code. Defaults
3415 # to $(SRCDIR)/$(CURDIR).
3416 # - prefix = the target directory. Must be an absolute path of the
3417 # host system. Defaults to $(AROS_CONTRIB).
3418 # - aros_prefix = set a path which is valid within the AROS filesystem.
3419 # Defaults to the value of the prefix option.
3420 # - extraoptions = additional options for the cmake script.
3421 # - usecppflags = enable the use of cpp flags. some external cmake
3422 # scripts will not set their own cppflags if it is already
3423 # set, so this allows them to be disabled (unless you can provide
3424 # all the options they would need)
3425 # - cppflags = preprocessor flags.
3426 # - cflags = flags to use with the C compiler.
3427 # - cxxflags = flags to use with the C++ compiler.
3428 # - installoptions = additional options for the install step.
3431 %define build_with_cmake mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) gendir= prefix= \
3432 aros_prefix= extraoptions= installoptions= maketarget= compiler=target \
3433 usecppflags=yes cppflags=$(CPPFLAGS) cflags=$(CFLAGS) cxxflags=$(CXXFLAGS) ldflags=$(LDFLAGS)
3436 %(mmake)-prefix := %(prefix)
3438 %(mmake)-prefix := $(AROS_CONTRIB)
3441 ifneq (%(aros_prefix),)
3442 %(mmake)-aros_prefix := %(aros_prefix)
3444 %(mmake)-aros_prefix := $(%(mmake)-prefix)
3447 ifeq (%(compiler),host)
3448 BD_LDFLAGS := $(strip -L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS))
3449 BD_CFLAGS := $(strip $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include)
3450 BD_CXXFLAGS := $(strip $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include)
3451 BD_CPPFLAGS := $(HOST_CPPFLAGS)
3452 %(mmake)-cmake_opts := -DCMAKE_INSTALL_PREFIX=$(%(mmake)-prefix) -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(HOST_DEF_CC)" -DCMAKE_C_FLAGS="$(BD_CFLAGS)"
3453 ifeq (%(usecppflags),yes)
3454 %(mmake)-cmake_opts += -DCMAKE_CPP_FLAGS="$(BD_CPPFLAGS)"
3456 %(mmake)-cmake_opts += -DCMAKE_CXX_COMPILER="$(HOST_CXX)" -DCMAKE_CXX_FLAGS="$(BD_CXXFLAGS)"
3458 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
3460 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
3463 BD_LDFLAGS := %(ldflags)
3464 BD_CFLAGS := %(cflags)
3465 BD_CXXFLAGS := %(cxxflags)
3466 BD_CPPFLAGS := %(cppflags)
3467 %(mmake)-cmake_opts := -DCMAKE_TOOLCHAIN_FILE=$(GENDIR)/config/conf.cmake -DCMAKE_INSTALL_PREFIX=$(%(mmake)-prefix) -DCMAKE_C_FLAGS="$(strip $(BD_CFLAGS))"
3468 ifeq (%(usecppflags),yes)
3469 %(mmake)-cmake_opts += -DCMAKE_CPP_FLAGS="$(BD_CPPFLAGS)"
3471 %(mmake)-cmake_opts += -DCMAKE_CXX_FLAGS="$(strip $(BD_CXXFLAGS))" -DCMAKE_EXE_LINKER_FLAGS="$(strip $(BD_LDFLAGS))"
3473 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
3475 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
3480 %(mmake)-pkgdir := %(gendir)/$(CURDIR)
3482 %(mmake)-pkgdir := %(gendir)/$(CURDIR)/%(package)
3486 %(mmake)-cmakeflag := $(%(mmake)-pkgdir)/.cmake
3487 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
3489 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3491 #MM- %(mmake): setup includes core-linklibs %(mmake)-quick
3493 #MM- %(mmake)-quick : %(mmake)-cmake %(mmake)-build_and_install-quick
3496 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3498 $(%(mmake)-installflag) : $(%(mmake)-cmakeflag)
3499 $(IF) ! $(MAKE) -q -C $(%(mmake)-pkgdir); then \
3500 $(RM) $(%(mmake)-installflag) && \
3501 $(MAKE) -C $(%(mmake)-pkgdir) %(maketarget) && \
3502 cd $(%(mmake)-pkgdir) && \
3503 cmake %(installoptions) -P cmake_install.cmake && \
3504 $(TOUCH) $@ -r $^; \
3507 $(%(mmake)-pkgdir)/.files-touched:
3508 %mkdirs_q $(%(mmake)-pkgdir)
3509 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/CMakeLists.txt '{}' \; && \
3513 %(mmake)-cmake : $(%(mmake)-cmakeflag)
3515 $(%(mmake)-cmakeflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
3516 $(%(mmake)-cmakeflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
3518 %mkdirs_q $(%(mmake)-pkgdir)
3519 cd $(%(mmake)-pkgdir) && \
3520 $(RM) -Rf CMakeCache.txt CMakeFiles \; && \
3521 cmake $(%(mmake)-cmake_opts) %(extraoptions) $(TMP_SRCDIR) && \
3525 %(mmake)-clean : %(mmake)-uninstall
3526 @$(RM) $(%(mmake)-pkgdir)
3528 #------------------------------------------------------------------------------
3531 #------------------------------------------------------------------------------
3532 # Given an archive name, patches names and locations where to find them, fetch
3533 # the archive and the patches from any of those locations, unpack the archive
3534 # and then apply the patches.
3536 # Locations currently supported are http and ftp sites, plus local filesystem
3537 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
3538 # the fetch.sh script needs to be modified, since this macro relies on that script.
3542 # - mmake = mmaketarget
3543 # - archive_origins = list of locations where to find the archive. They are tried
3544 # in sequence, until the archive is found and fetching it
3545 # succeeded. If not specified, the current directory is assumed.
3546 # - archive = the archive name. Mandatory.
3547 # - suffixes = a list of suffixes to append to the package name plus the
3548 # version. Each one of them is tried until a matching archive is
3549 # found. They are appended to patches and these are tried the
3550 # same way as packages are.
3551 # - location = the local directory where to put the fetched archive and patches.
3552 # If not specified, the directory specified by destination is used.
3553 # - destination = the directory to unpack the archive to.
3554 # If not specified, the current directory is assumed.
3555 # - patches_origins = list of locations where to find the patches. They are tried
3556 # in sequence, until a patch is found and fetching it
3557 # succeeded. If not specified, the current directory is assumed.
3558 # - patches_specs = list of "patch specs". A patch spec is of the form
3559 # patch_name[:[patch_subdir][:patch_opt]].
3561 # - patch_name = the name of the patch file
3562 # - patch_subdir = the directory within \destination\ where to
3564 # - patch_opt = any options to pass to the `patch' command
3565 # when applying the patch.
3567 # The patch_subdir and patch_opt fields are optional.
3569 %define fetch mmake=/A archive_origins=. archive=/A suffixes= location= destination=. \
3570 patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
3574 ifneq (%(location),)
3575 %(mmake)-location := %(location)
3577 %(mmake)-location := %(destination)
3582 $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
3583 -d %(destination) -po "%(patches_origins)" -p "%(patches_specs)"
3585 #------------------------------------------------------------------------------
3588 #------------------------------------------------------------------------------
3589 # This macro can aid in patch creation for fetched ports. It temporarily creates another
3590 # unpatched source tree and runs diff against this and a previously fetched and possibly
3591 # patched tree. Depending on what happens after patching during a normal build it might
3592 # give best results if the new patch is created directly after fetch.
3596 # - mmake = mmaketarget
3597 # - archive = archive base name
3598 # - srcdir = the top level directory the package is unpacked to, useful if
3599 # an archive unpacks to a directory other than its name suggests.
3600 # this should not be deeper than a single path element.
3601 # - suffixes = a list of suffixes to append to the the package name plus the
3602 # version. Each one of them is tried until a matching archive is
3604 # - destination = the directory to unpack the archive to.
3605 # - excludes = diff patterns to exclude files or directories from the patch
3607 %define create_patch mmake=/A archive=/A srcdir= suffixes="tar.bz2 tar.gz" destination=/A excludes=
3611 ifneq (%(excludes),)
3612 %(mmake)-exclude := -X ./exclude.patterns
3616 %(mmake)-srcdir := %(srcdir)
3618 %(mmake)-srcdir := %(archive)
3621 #MM- %(mmake) : %(mmake)-diff
3622 #MM- %(mmake)-quick : %(mmake)-diff
3626 @$(FETCH) -a %(archive) -s "%(suffixes)" -l $(PORTSSOURCEDIR) -d %(destination)/tmp ; \
3627 $(MV) %(destination)/$(%(mmake)-srcdir) %(destination)/tmp/$(%(mmake)-srcdir).aros ; \
3628 cd %(destination)/tmp ; \
3629 $(FOR) f in %(excludes) ; do \
3630 $(ECHO) $$f >> ./exclude.patterns ; \
3632 diff -ruN $(%(mmake)-exclude) \
3633 $(%(mmake)-srcdir) \
3634 $(%(mmake)-srcdir).aros \
3635 >$(SRCDIR)/$(CURDIR)/%(archive)-aros-new.diff ; \
3636 $(MV) %(destination)/tmp/$(%(mmake)-srcdir).aros %(destination)/$(%(mmake)-srcdir) ; \
3637 $(RM) %(destination)/tmp
3639 #------------------------------------------------------------------------------
3642 #------------------------------------------------------------------------------
3643 # Joins the features of %fetch and %build_with_configure.
3645 # If a patch is provided, it *must* be named the following way:
3647 # <package name>-<version number>-aros.diff
3649 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3650 # CD'ing into the archive's extracted directory.
3652 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3653 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3654 # to make that patch fully comprehensive.
3658 # - mmake = the meta make target.
3659 # - package = the GNU package name, sans version and archive format suffixes.
3660 # - subpackage = ???
3661 # - compiler = same meaning as the one for the %build_with_configure macro.
3662 # - install_target = same meaning as the one for the %build_with_configure macro.
3663 # - version = the package's version number, or otherwise any other version string.
3664 # It gets appended to the package name to form the basename of the archive.
3665 # - suffixes = a list of suffixes to apped to the the package name plus the
3666 # version. Each one of them is tried until a matching archive is found.
3667 # Defaults to "tar.bz2 tar.gz".
3668 # - srcdir = the top level directory the package is unpacked to (see create_patch).
3669 # - builddir = override the location we expect to run configure/make in.
3670 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
3671 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
3672 # fetched or not. Default to no.
3673 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
3674 # - prefix = same meaning as the one for the %build_with_configure macro.
3675 # - aros_prefix = same meaning as the one for the %build_with_configure macro.
3676 # - extraoptions = same meaning as the one for the %build_with_configure macro.
3677 # - usecppflags = same meaning as the one for the %build_with_configure macro.
3678 # - extracppflags = same meaning as the one for the %build_with_configure macro.
3679 # - extracflags = same meaning as the one for the %build_with_configure macro.
3680 # - extracxxflags = same meaning as the one for the %build_with_configure macro.
3681 # - preconfigure = same meaning as the one for the %build_with_configure macro.
3682 # - postconfigure = same meaning as the one for the %build_with_configure macro.
3683 # - postinstall = same meaning as the one for the %build_with_configure macro.
3684 # - install_env = same meaning as the one for the %build_with_configure macro.
3685 # - use_build_env = same meaning as the one for the %build_with_configure macro.
3686 # - nix = same meaning as the one for the %build_with_configure macro.
3687 # - nix_dir_layout = same meaning as the one for the %build_with_configure macro.
3688 # - create_pkg = create a distributable package of the compiled sources, defaults to no
3690 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target crossbuild=no install_target=install \
3691 version=/A suffixes="tar.bz2 tar.gz" srcdir= builddir= gendir= basedir=$(CURDIR) package_repo= patch=no patch_repo= \
3692 prefix= aros_prefix= preconfigure= postconfigure= postinstall= \
3693 extraoptions= usecppflags=yes extracppflags= extracflags="$(OPTIMIZATION_CFLAGS)" extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3694 config_env_extra= install_env= use_build_env=no nix=no nix_dir_layout= create_pkg=no buildflags=yes gnuflags=yes nlsflag=yes xflag=yes hostisaflags="$(ISA_FLAGS)" targetisaflags="$(ISA_FLAGS)"
3696 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
3697 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
3698 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
3699 #MM- %(mmake)-create-patch : %(mmake)-%(subpackage)-create-patch
3701 %(mmake)-archbase := %(package)-%(version)
3703 ifeq (%(compiler),host)
3704 %(mmake)-portdir := $(HOSTDIR)/Ports/host/%(package)
3706 %(mmake)-portdir := $(PORTSDIR)/%(package)
3710 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
3712 %(mmake)-prefix := %(prefix)
3715 ifneq (%(subpackage),)
3716 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
3718 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
3722 %(mmake)-%(subpackage)-srcdir := %(srcdir)
3724 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
3727 ifneq (%(builddir),)
3728 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)/%(builddir)
3730 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)
3734 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-f,-p1
3736 %(mmake)-%(subpackage)-patches_specs := ::
3739 %fetch mmake="%(mmake)-%(subpackage)-fetch" archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
3740 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
3741 archive_origins=". %(package_repo)" \
3742 patches_specs=$(%(mmake)-%(subpackage)-patches_specs) patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
3744 %create_patch mmake="%(mmake)-%(subpackage)-create-patch" \
3745 archive=$(%(mmake)-%(subpackage)-archbase) \
3746 srcdir=$(%(mmake)-%(subpackage)-srcdir) \
3747 suffixes="%(suffixes)" \
3748 destination=$(%(mmake)-portdir)
3750 #MM- %(mmake) : %(mmake)-%(subpackage)
3752 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
3754 %(mmake)-%(subpackage)-package-basename := \
3755 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
3757 ifneq (%(create_pkg),no)
3758 %(mmake)-%(subpackage)-package := $(%(mmake)-%(subpackage)-package-basename).tar.bz2
3761 %build_with_configure mmake="%(mmake)-%(subpackage)" package="%(package)" compiler="%(compiler)" crossbuild="%(crossbuild)" install_target="%(install_target)" \
3762 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-builddir) gendir="%(gendir)" basedir="%(basedir)" \
3763 config_env_extra="%(config_env_extra)" install_env="%(install_env)" use_build_env="%(use_build_env)" \
3764 nix="%(nix)" nix_dir_layout="%(nix_dir_layout)" prefix=$(%(mmake)-prefix) aros_prefix="%(aros_prefix)" \
3765 preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall) %(mmake)-%(subpackage)-make-package" \
3766 extraoptions="%(extraoptions)" usecppflags="%(usecppflags)" extracppflags="%(extracppflags)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)" \
3767 buildflags=%(buildflags) gnuflags=%(gnuflags) nlsflag=%(nlsflag) xflag=%(xflag) hostisaflags=%(hostisaflags) targetisaflags=%(targetisaflags)
3769 .PHONY : %(mmake)-%(subpackage)-make-package %(mmake)-%(subpackage)-create-patch
3770 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
3773 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package)
3775 #There seems to be a bug, either with my clock or with make, 'cause it may happen
3776 #that $^ and $@ have exactly the same mtime, and in that case make tries
3777 #to rebuild $@ again, which would fail because the directory where
3778 #the package got installed would not exist anymore.
3779 #We work this around by using an if statement to manually check the mtimes.
3780 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
3781 @$(IF) $(TEST) $(%(mmake)-installflag) -nt $@ || ! $(TEST) -s $@; then \
3783 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
3784 $(MKDIR) -p "$(DISTDIR)/Packages" ; \
3785 $(MKDIR) -p "$(%(mmake)-prefix)" ; \
3786 cd $(%(mmake)-%(subpackage)-package-dir) ; \
3787 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
3788 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
3791 #------------------------------------------------------------------------------
3794 #------------------------------------------------------------------------------
3795 # Joins the features of %fetch and %build_with_configure, taking advantage of
3796 # the naming scheme of GNU packages. GNU packages names are in the form
3798 # <package name>-<version number>.<archive format suffix>
3800 # If a patch is provided, it *must* be named the following way:
3802 # <package name>-<version number>-aros.diff
3804 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3805 # CD'ing into the archive's extracted directory.
3807 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3808 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3809 # to make that patch fully comprehensive.
3811 # NOTE: GNU packages are always compiled with *nix semantics turned on.
3815 # Arguments have the same meaning as the one for the %fetch_and_build macro, except:
3817 # - prefix = defaults to $(GNUDIR).
3818 # - aros_prefix = defaults to /GNU.
3820 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A crossbuild=no suffixes="tar.bz2 tar.gz" \
3821 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
3822 aros_prefix=/GNU config_env_extra= preconfigure= postconfigure= postinstall= \
3823 extraoptions= usecppflags=yes extracppflags= extracflags="$(OPTIMIZATION_CFLAGS)" extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3824 nix=yes gnuflags=yes nlsflag=yes xflag=yes
3826 GNU_REPOSITORY := gnu://
3828 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
3829 crossbuild="%(crossbuild)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
3830 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
3831 patch="%(patch)" patch_repo="%(patch_repo)" \
3832 prefix="%(prefix)" aros_prefix="%(aros_prefix)" \
3833 extraoptions="%(extraoptions)" usecppflags="%(usecppflags)" extracppflags="%(extracppflags)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)" \
3834 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" \
3835 nix=%(nix) gnuflags=%(gnuflags) nlsflag=%(nlsflag) xflag=%(xflag)
3838 #------------------------------------------------------------------------------
3841 #------------------------------------------------------------------------------
3842 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
3843 # that the package is a "Developer" package, and as such it needs to be placed
3844 # under the $(AROS_DEVELOPER) directory, as a default.
3846 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
3847 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
3848 # "mmake" argument, because the metatarget is implicitely defined as
3850 # #MM- development-%(package)
3852 %define fetch_and_build_gnu_development package=/A subpackage= version=/A crossbuild=no suffixes="tar.bz2 tar.gz" \
3853 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPER) \
3854 aros_prefix=/Developer config_env_extra= preconfigure= postconfigure= postinstall= \
3855 extraoptions= usecppflags=yes extracppflags= extracflags="$(OPTIMIZATION_CFLAGS)" extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3856 nix=yes gnuflags=yes nlsflag=yes xflag=yes
3858 #MM- development : development-%(package)
3861 %fetch_and_build_gnu mmake="development-%(package)" package="%(package)" subpackage="%(subpackage)" \
3862 version="%(version)" crossbuild="%(crossbuild)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
3863 package_repo="%(package_repo)" \
3864 patch="%(patch)" patch_repo="%(patch_repo)" \
3865 prefix="%(prefix)" aros_prefix="%(aros_prefix)" \
3866 extraoptions="%(extraoptions)" usecppflags="%(usecppflags)" extracflags="%(extracflags)" extracppflags="%(extracppflags)" extracxxflags="%(extracxxflags)" \
3867 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="postinstall-%(package)-delete-la-files %(postinstall)" \
3868 nix=%(nix) gnuflags=%(gnuflags) nlsflag=%(nlsflag) xflag=%(xflag)
3871 postinstall-%(package)-delete-la-files:
3872 $(RM) %(prefix)/lib/*.la
3875 #------------------------------------------------------------------------------
3877 # Builds a kickstart package in PKG format
3881 # - mmake = target name
3882 # - file = destination file name with path
3884 # Other arguments are self-explanatory
3886 %define make_package mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
3887 arch_classes= arch_devs= arch_handlers= arch_hidds= arch_libs= arch_res=
3889 PKG_CLASSES := $(addprefix $(AROS_CLASSES)/,$(addsuffix .class, %(classes)))
3890 PKG_DEVICES := $(addprefix $(AROS_DEVS)/,$(addsuffix .device, %(devs)))
3891 PKG_HANDLERS := $(addprefix $(AROS_FS)/,$(addsuffix -handler, %(handlers)))
3892 PKG_HIDD := $(addprefix $(AROS_DEVS)/Drivers/,$(addsuffix .hidd, %(hidds)))
3893 PKG_LIBS := $(addprefix $(AROS_LIBRARIES)/,$(addsuffix .library, %(libs)))
3894 PKG_RESOURCES := $(addprefix $(AROS_DEVS)/,$(addsuffix .resource, %(res)))
3896 PKG_CLASSES_ARCH := $(addprefix $(AROS_CLASSES_ARCH)/,$(addsuffix .class, %(arch_classes)))
3897 PKG_DEVICES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .device, %(arch_devs)))
3898 PKG_HANDLERS_ARCH := $(addprefix $(AROS_FS_ARCH)/,$(addsuffix -handler, %(arch_handlers)))
3899 PKG_HIDD_ARCH := $(addprefix $(AROS_DEVS_ARCH)/Drivers/,$(addsuffix .hidd, %(arch_hidds)))
3900 PKG_LIBRARIES_ARCH := $(addprefix $(AROS_LIBRARIES_ARCH)/,$(addsuffix .library, %(arch_libs)))
3901 PKG_RESOURCES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .resource, %(arch_res)))
3903 PKG_FILES := $(PKG_CLASSES) $(PKG_DEVICES) $(PKG_HANDLERS) $(PKG_HIDD) $(PKG_LIBS) $(PKG_RESOURCES) \
3904 $(PKG_CLASSES_ARCH) $(PKG_DEVICES_ARCH) $(PKG_HANDLERS_ARCH) $(PKG_HIDD_ARCH) $(PKG_LIBRARIES_ARCH) $(PKG_RESOURCES_ARCH)
3905 PKG_DIR := $(dir %(file))
3911 %(mmake)-quick : %(file)
3913 %(file): $(PKG_FILES) | $(PKG_DIR)
3914 @$(ECHO) Packaging $@...
3915 @$(SRCDIR)/tools/package/pkg c $@ $^
3917 %compress_file mmake="%(mmake)" file="%(file)"
3919 GLOB_MKDIRS += $(PKG_DIR)
3923 #------------------------------------------------------------------------------
3924 # Compresses %(file) with a gzip.
3925 # Good in conjunction with for example %build_prog
3927 %define compress_file mmake=/A file=/A
3929 #MM- %(mmake)-gz : %(mmake) %(mmake)-gz-quick
3932 %(mmake)-gz-quick : %(file).gz
3935 @$(ECHO) Compressing $(subst $(TARGETDIR)/,,$^)...
3940 #------------------------------------------------------------------------------
3941 # Links a kickstart module in ELF format
3942 # Arguments are similar to make_package
3944 %define link_kickstart mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
3945 startup= uselibs= ldflags=$(LDFLAGS) map= deps=
3947 KOBJ_CLASSES := $(addprefix $(KOBJSDIR)/, $(addsuffix _class.o, %(classes)))
3948 KOBJ_DEVICES := $(addprefix $(KOBJSDIR)/, $(addsuffix _device.o, %(devs)))
3949 KOBJ_HANDLERS := $(addprefix $(KOBJSDIR)/, $(addsuffix _handler.o, %(handlers)))
3950 KOBJ_HIDD := $(addprefix $(KOBJSDIR)/, $(addsuffix _hidd.o, %(hidds)))
3951 KOBJ_LIBS := $(addprefix $(KOBJSDIR)/, $(addsuffix _library.o, %(libs)))
3952 KOBJ_RES := $(addprefix $(KOBJSDIR)/, $(addsuffix _resource.o, %(res)))
3955 KOBJ_STARTUP := $(GENDIR)/$(RESIDENT_BEGIN).o
3957 KOBJ_STARTUP := %(startup)
3960 KOBJS := $(KOBJ_STARTUP) $(KOBJ_CLASSES) $(KOBJ_HANDLERS) $(KOBJ_LIBS) $(KOBJ_DEVICES) $(KOBJ_HIDD) $(KOBJ_RES)
3962 TMP_LDFLAGS := %(ldflags)
3964 # Make a list of the lib files this program depends on.
3965 # In LDFLAGS remove white space between -L and directory
3966 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
3967 # Filter out only the libdirs and remove -L
3968 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
3970 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
3971 # Add normal linklib path
3972 TMP_DIRS += $(AROS_LIB)/
3973 # add lib and .a to static linklib names
3974 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
3975 # search for the linklibs in the given path, ignore ones not found
3976 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
3977 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
3980 TMP_DIRS += $(dir %(file))
3982 TMP_LDFLAGS += $(GENMAP) %(map)
3983 TMP_DIRS += $(dir %(map))
3986 #MM %(mmake) : %(deps)
3992 %(mmake)-quick : %(file)
3994 %(file): KOBJS := $(KOBJS)
3995 %(file): LDFLAGS := $(TMP_LDFLAGS) $(NOSTARTUP_LDFLAGS) \
3996 -static -nosysbase -Wl,-Ur
3997 %(file): LDLIBS := $(addprefix -l, %(uselibs))
3998 %(file): $(KOBJS) $(DEPLIBS) | $(TMP_DIRS)
3999 @$(ECHO) "Kickstart $(subst $(TARGETDIR)/,,$@)..."
4000 @$(TARGET_CC) $(TARGET_SYSROOT) -o $@ $(KOBJS) $(LDFLAGS) $(LDLIBS)
4002 @$(STRIP) $@ --only-keep-debug -o $@.dbg
4006 @$(OBJCOPY) --add-gnu-debuglink=$@.dbg $@
4009 %compress_file mmake="%(mmake)" file="%(file)"
4011 GLOB_MKDIRS += $(TMP_DIRS)
4015 #------------------------------------------------------------------------------
4016 # Generate generic rules for a subtarget
4018 %define subtarget parentmmake= mmake=/A mmbase=MM-
4019 #%(mmbase) %(parentmmake) : %(mmake)
4020 #%(mmbase) %(parentmmake)-includes : %(mmake)-includes
4021 #%(mmbase) %(parentmmake)-quick : %(mmake)-quick
4024 #------------------------------------------------------------------------------
4025 # Create a target directory
4027 %define directorytarget mmake=/A directory= icontarget= mmbase=MM-
4030 %mkdirs_q %(directory)
4032 #%(mmbase) %(mmake) : %(mmake)-makedir