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="$(TARGET_CC) $(TARGET_SYSROOT)" opt="$(TARGET_CFLAGS) $(CFLAGS)" 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) -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) -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) -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="$(CC) $(TARGET_SYSROOT)" opt=$(AFLAGS) 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="$(AROS_CC) $(TARGET_SYSROOT)" opt=$(LDFLAGS) from=$< to=$@ libs=$(LIBS) strip=$(STRIP)
66 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,%(to))..."
67 @$(IF) %(cmd) %(from) -o %(to) %(opt) %(libs) 2>&1 > $(GENDIR)/cerrors 2>&1 ; then \
68 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
69 $(ECHO) "%(to): %(cmd) %(from) -o %(to) %(opt) %(libs)" >> $(GENDIR)/errors ; \
70 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
75 $(ECHO) "Link failed: %(cmd) %(from) -o %(to) %(opt) %(libs)" 1>&2 ; \
76 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
81 #------------------------------------------------------------------------------
84 #-------------------------------------------------------------------------
85 # Link a module based upon a number of arguments and the standard $(LIBS)
86 # and $(DEPLIBS) make variables.
88 %define link_module_q cmd="$(AROS_CC) $(TARGET_SYSROOT)" err="$(notdir $@).err" objs=/A endtag= module=$(MODULE) ldflags=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
89 @$(ECHO) "Building $(subst $(TARGETDIR)/,,$@) ..."
90 @if %(cmd) $(NOSTARTUP_LDFLAGS) \
91 $(GENMAP) %(objdir)/%(module).map \
92 %(objs) %(libs) %(ldflags) %(endtag) \
93 -o $@ 2>&1 > %(objdir)/%(err); \
95 cat %(objdir)/%(err); \
97 echo "%(cmd) $(NOSTARTUP_LDFLAGS) $(GENMAP) %(objdir)/%(module).map %(objs) %(libs) %(ldflags) %(endtag) -o $@"; \
98 cat %(objdir)/%(err); \
102 @if $(TEST) ! -s %(objdir)/%(err) ; then $(RM) %(objdir)/%(err) ; fi
105 #------------------------------------------------------------------------------
108 #------------------------------------------------------------------------------
110 %define mklib_q ar=$(AR) ranlib=$(RANLIB) to=$@ from=$(OBJS)
111 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,%(to))..."
115 #------------------------------------------------------------------------------
118 #------------------------------------------------------------------------------
119 # Create the dependency file %(to) for %(from)
120 %define mkdepend_q flags=$(CFLAGS) from=$< to=$@ cc="$(AROS_CC) $(TARGET_SYSROOT)"
121 %mkdir_q dir="$(dir %(to))"
122 @$(ECHO) "Makedepend $(if $(filter /%,%(from)),$(if $(filter $(SRCDIR)/%,$(abspath %(from))),$(patsubst $(SRCDIR)/%,%,$(abspath %(from))),$(patsubst $(TOP)/%,%,$(abspath %(from)))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/%(from))))..."
123 @AROS_CC="%(cc)" $(MKDEPEND) %(flags) -I$(TOP)/$(CURDIR) -I$(SRCDIR)/$(CURDIR) %(from) -o %(to)
125 #------------------------------------------------------------------------------
128 #------------------------------------------------------------------------------
129 # Create one directory without any output
130 %define mkdir_q dir=.
131 @$(IF) $(TEST) ! -d %(dir) ; then $(MKDIR) %(dir) ; else $(NOP) ; fi
133 #------------------------------------------------------------------------------
136 #------------------------------------------------------------------------------
137 # Create several directories without any output
138 %define mkdirs_q dirs=/M
139 @$(FOR) dir in %(dirs) ; do \
140 $(IF) $(TEST) ! -d $$dir ; then $(MKDIR) $$dir ; else $(NOP) ; fi ; \
143 #------------------------------------------------------------------------------
146 #############################################################################
147 #############################################################################
149 ## Here are the mmakefile macros that are used to do certain tasks in a ##
150 ## mmakefile. They consist of one or more full makefile rules. ##
151 ## In general the files generated in these macros are also defined as ##
152 ## make targets so that they can be used as a dependency in other rules ##
154 #############################################################################
155 #############################################################################
157 #------------------------------------------------------------------------------
158 # Generate a unique id for each of the %build... rules
159 %define buildid targets=/A
161 ifneq ($(filter $(TARGET),%(targets)),)
162 BDTARGETID := $(BDID)
165 #------------------------------------------------------------------------------
168 #------------------------------------------------------------------------------
169 # Copy file %(from) to %(to) in a makefile rule
170 %define rule_copy from=/A to=/A
174 #------------------------------------------------------------------------------
177 #------------------------------------------------------------------------------
178 # Copy the files %(files) to %(targetdir). For each file in %(files),
179 # %(srcdir)/file is copied to %(targetdir)/file. The targetdir and the
180 # appropriate subdirs are not generated by this rule so they have to be
182 %define rule_copy_multi files=/A targetdir=/A srcdir=.
184 $(addprefix %(targetdir)/,%(files)) : %(targetdir)/% : %(srcdir)/%
187 #------------------------------------------------------------------------------
190 #------------------------------------------------------------------------------
191 # Copy the files %(files) to %(targetdir). For each file in %(files),
192 # %(srcdir)/file is copied to %(targetdir)/file if these files are different.
193 # %(stampfile) is used to keep track of when the last time the comparison has
194 # been done. The targetdir and the appropriate subdirs are not generated by
195 # this rule so they have to be present.
196 %define rule_copy_diff_multi files=/A targetdir=/A srcdir=. \
197 stampfile=$(TMP_SRCDIR)/.copy_stamp
199 TMP_SRCDIR := %(srcdir)
201 $(addprefix %(targetdir)/,%(files)) : | %(stampfile)
203 %(stampfile) : COPYSRCDIR := %(srcdir)
204 %(stampfile) : TGTDIR := %(targetdir)
205 %(stampfile) : FILES := %(files)
206 %(stampfile) : $(addprefix %(srcdir)/,%(files))
207 @for f in $(FILES); do \
208 $(IF) ! $(CMP) -s $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; then \
209 $(CP) $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; \
214 #------------------------------------------------------------------------------
217 #------------------------------------------------------------------------------
218 # Will join all the files in %(from) to %(to). When text is specified it will
220 # Restriction: at the moment when using a non-empty target dir %(from) may
222 %define rule_join to=/A from=/A text=
230 #------------------------------------------------------------------------------
233 #------------------------------------------------------------------------------
234 # Include the dependency files and add some internal rules
235 # When depstargets is provided the depencies will only be included when one of
236 # these targets is the $(TARGET). Otherwise the dependencies will only be
237 # included when the $(TARGET) is not for setup or clean
238 %define include_deps deps=$(DEPS)/M depstargets=
240 ifneq (%(depstargets),)
241 ifneq ($(findstring $(TARGET),%(depstargets)),)
245 ifeq (,$(filter clean% %clean %clean% setup% includes% %setup,$(TARGET)))
251 #------------------------------------------------------------------------------
254 #------------------------------------------------------------------------------
255 # Create the directories %(dirs). The creation will be done by adding rules to
256 # the %(setuptarget) make target with setup as the default.
257 %define rule_makedirs dirs=/A setuptarget=setup
259 %(setuptarget) :: %(dirs)
261 GLOB_MKDIRS += %(dirs)
264 #------------------------------------------------------------------------------
267 #------------------------------------------------------------------------------
268 # Generate a rule to compile a C source file to an object file and generate
269 # the dependency file. Basename may contain a directory part, then the source
270 # file has to be in that directory. The generated file will be put in the
271 # object directory without the directory.
273 # - basename: the basename of the file to compile. Use % for a wildcard rule
274 # - cflags (default $(CFLAGS)): the C flags to use for compilation
275 # - dflags: the flags used during creation of dependency file. If not specified
276 # the same value as cflags will be used
277 # - targetdir: the directory to put the .o file and the .d file. By default
278 # it is put in the same directory as the .c file
279 %define rule_compile basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target
284 TMP_TARGETBASE := %(basename)
286 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
289 # Adjust compiler flags to suit C
290 TMP_CFLAGS := %(cflags)
291 TMP_CFLAGS := $(subst -fpermissive,, $(TMP_CFLAGS))
293 TMP_DFLAGS := %(cflags)
295 TMP_DFLAGS := %(dflags)
298 ifeq ($(findstring %(compiler),host kernel target),)
299 $(error unknown compiler %(compiler))
301 ifeq (%(compiler),target)
302 BD_LINK ?= $(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
303 BD_STRIP ?= $(TARGET_STRIP)
304 $(TMP_TARGETBASE).o : TMP_CMD:=$(TARGET_CC) $(TARGET_SYSROOT)
305 $(TMP_TARGETBASE).d : TMP_CMD:=$(TARGET_CC) $(TARGET_SYSROOT)
306 $(TMP_TARGETBASE).o : TMP_CFLAGS:=$(TARGET_CFLAGS) $(TMP_CFLAGS)
307 $(TMP_TARGETBASE).d : TMP_DFLAGS:=$(TARGET_CFLAGS) $(TMP_DFLAGS)
308 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
309 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
310 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
311 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
313 ifeq (%(compiler),host)
314 BD_LINK ?= $(HOST_CC) $(HOST_LDFLAGS)
315 BD_STRIP ?= $(HOST_STRIP)
316 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
317 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
318 $(TMP_TARGETBASE).o : TMP_CFLAGS:=$(HOST_CFLAGS) $(TMP_CFLAGS)
319 $(TMP_TARGETBASE).d : TMP_DFLAGS:=$(HOST_CFLAGS) $(TMP_DFLAGS)
320 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
321 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
322 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
323 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
325 ifeq (%(compiler),kernel)
326 BD_LINK ?= $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
327 BD_STRIP ?= $(ECHO) >/dev/null
328 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
329 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
330 $(TMP_TARGETBASE).o : TMP_CFLAGS:=$(KERNEL_CFLAGS) $(TMP_CFLAGS)
331 $(TMP_TARGETBASE).d : TMP_DFLAGS:=$(KERNEL_CFLAGS) $(TMP_DFLAGS)
332 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
333 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
334 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
335 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
338 $(TMP_TARGETBASE).o : CFLAGS := $(TMP_CFLAGS)
339 $(TMP_TARGETBASE).o : %(basename).c
340 %compile_q cmd=$(TMP_CMD) opt=$(TMP_CFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
343 $(TMP_TARGETBASE).d : TMP_DFLAGS:=$(BD_NIXFLAG) $(TMP_DFLAGS)
345 $(TMP_TARGETBASE).d : %(basename).c
346 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
348 #------------------------------------------------------------------------------
351 #------------------------------------------------------------------------------
352 # Generate a rule to compile a C++ source file to an object file and generate
353 # the dependency file. Basename may contain a directory part, then the source
354 # file has to be in that directory. The generated file will be put in the
355 # object directory without the directory.
357 # - basename: the basename of the file to compile. Use % for a wildcard rule
358 # - cflags (default $(CFLAGS)): the C flags to use for compilation
359 # - dflags: the flags used during creation of dependency file. If not specified
360 # the same value as cflags will be used
361 # - targetdir: the directory to put the .o file and the .d file. By default
362 # it is put in the same directory as the .c file
363 %define rule_compile_cxx basename=/A cxxflags=$(CXXFLAGS) dxxflags= targetdir= compiler=target
368 TMP_TARGETBASE := %(basename)
370 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
373 # Adjust compiler flags to suit C++
374 TMP_CXXFLAGS := %(cxxflags)
376 TMP_DXXFLAGS := %(cxxflags)
378 TMP_DXXFLAGS := %(dxxflags)
381 ifeq ($(findstring %(compiler),host kernel target),)
382 $(error unknown compiler %(compiler))
384 ifeq (%(compiler),target)
385 BD_LINK ?= $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
386 BD_STRIP ?= $(TARGET_STRIP)
387 $(TMP_TARGETBASE).o : TMP_CMD:=$(AROS_CXX) $(TARGET_SYSROOT)
388 $(TMP_TARGETBASE).d : TMP_CMD:=$(AROS_CXX) $(TARGET_SYSROOT)
389 $(TMP_TARGETBASE).o : TMP_CXXFLAGS:=$(TARGET_CXXFLAGS) $(TMP_CXXFLAGS)
390 $(TMP_TARGETBASE).d : TMP_DXXFLAGS:=$(TARGET_CXXFLAGS) $(TMP_DXXFLAGS)
391 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
392 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
393 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
394 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
396 ifeq (%(compiler),host)
397 BD_LINK ?= $(HOST_CXX) $(HOST_LDFLAGS)
398 BD_STRIP ?= $(HOST_STRIP)
399 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CXX)
400 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CXX)
401 $(TMP_TARGETBASE).o : TMP_CXXFLAGS:=$(HOST_CXXFLAGS) $(TMP_CXXFLAGS)
402 $(TMP_TARGETBASE).d : TMP_DXXFLAGS:=$(HOST_CXXFLAGS) $(TMP_DXXFLAGS)
403 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
404 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
405 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
406 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
408 ifeq (%(compiler),kernel)
409 KERNEL_CXX ?= $(KERNEL_CC)
410 BD_LINK ?= $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
411 BD_STRIP ?= $(ECHO) >/dev/null
412 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CXX) $(KERNEL_SYSROOT)
413 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CXX) $(KERNEL_SYSROOT)
414 $(TMP_TARGETBASE).o : TMP_CXXFLAGS:=$(KERNEL_CXXFLAGS) $(TMP_CXXFLAGS)
415 $(TMP_TARGETBASE).d : TMP_DXXFLAGS:=$(KERNEL_CXXFLAGS) $(TMP_DXXFLAGS)
416 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
417 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
418 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
419 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
422 $(TMP_TARGETBASE).o : CXXFLAGS := $(TMP_CXXFLAGS)
423 $(TMP_TARGETBASE).o : %(basename).cpp
424 %compile_q cmd=$(TMP_CMD) opt=$(TMP_CXXFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
427 $(TMP_TARGETBASE).d : TMP_DXXFLAGS:=$(BD_NIXFLAG) $(TMP_DXXFLAGS)
429 $(TMP_TARGETBASE).d : %(basename).cpp
430 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DXXFLAGS)
435 #------------------------------------------------------------------------------
438 #------------------------------------------------------------------------------
439 # Generate a rule to compile an ObjC source file to an object file and generate
440 # the dependency file. Basename may contain a directory part, then the source
441 # file has to be in that directory. The generated file will be put in the
442 # object directory without the directory.
444 # - basename: the basename of the file to compile. Use % for a wildcard rule
445 # - cflags (default $(CFLAGS)): the C flags to use for compilation
446 # - dflags: the flags used during creation of dependency file. If not specified
447 # the same value as cflags will be used
448 # - targetdir: the directory to put the .o file and the .d file. By default
449 # it is put in the same directory as the .m file
450 %define rule_compile_objc basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target
455 TMP_TARGETBASE := %(basename)
457 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
460 # Adjust compiler flags to suit ObjC
461 TMP_OBJCFLAGS := %(cflags)
462 TMP_OBJCFLAGS := $(TMP_OBJCFLAGS) -isystem $(AROS_DEVELOPMENT)/include
463 TMP_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(TMP_OBJCFLAGS)))
465 TMP_OBJCDFLAGS := %(cflags)
467 TMP_OBJCDFLAGS := %(dflags)
470 # Define the use of cross compiler
471 ifeq ($(TARGET_OBJC),)
472 TMP_CC := $(TARGET_CC)
474 TMP_CC := $(TARGET_OBJC)
477 ifeq ($(findstring %(compiler),host kernel target),)
478 $(error unknown compiler %(compiler))
480 ifeq (%(compiler),target)
481 BD_LINK ?= $(TMP_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
482 BD_STRIP ?= $(TARGET_STRIP)
483 $(TMP_TARGETBASE).o : TMP_CMD:=$(TMP_CC) $(TARGET_SYSROOT)
484 $(TMP_TARGETBASE).d : TMP_CMD:=$(TMP_CC) $(TARGET_SYSROOT)
485 $(TMP_TARGETBASE).o : TMP_OBJCFLAGS:=$(TARGET_CFLAGS) $(TMP_OBJCFLAGS)
486 $(TMP_TARGETBASE).d : TMP_OBJCDFLAGS:=$(TARGET_CFLAGS) $(TMP_OBJCDFLAGS)
487 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
488 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
489 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
490 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
492 ifeq (%(compiler),host)
493 BD_LINK ?= $(HOST_CC) $(HOST_LDFLAGS)
494 BD_STRIP ?= $(HOST_STRIP)
495 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
496 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
497 $(TMP_TARGETBASE).o : TMP_OBJCFLAGS:=$(HOST_CFLAGS) $(TMP_OBJCFLAGS)
498 $(TMP_TARGETBASE).d : TMP_OBJCDFLAGS:=$(HOST_CFLAGS) $(TMP_OBJCDFLAGS)
499 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
500 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
501 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
502 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
504 ifeq (%(compiler),kernel)
505 BD_LINK ?= $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
506 BD_STRIP ?= $(ECHO) >/dev/null
507 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
508 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
509 $(TMP_TARGETBASE).o : TMP_OBJCFLAGS:=$(KERNEL_CFLAGS) $(TMP_OBJCFLAGS)
510 $(TMP_TARGETBASE).d : TMP_OBJCDFLAGS:=$(KERNEL_CFLAGS) $(TMP_OBJCDFLAGS)
511 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
512 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
513 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
514 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
517 $(TMP_TARGETBASE).o : CFLAGS := $(TMP_OBJCFLAGS)
518 $(TMP_TARGETBASE).o : %(basename).m
519 %compile_q cmd=$(TMP_CMD) opt=$(TMP_OBJCFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
522 $(TMP_TARGETBASE).d : TMP_OBJCDFLAGS:=$(BD_NIXFLAG) $(TMP_OBJCDFLAGS)
524 $(TMP_TARGETBASE).d : %(basename).m
525 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_OBJCDFLAGS)
530 #------------------------------------------------------------------------------
533 #------------------------------------------------------------------------------
534 # Generate a rule to compile multiple C source files to an object file and
535 # generate the corresponding dependency files. The generated file will be put
536 # in the object directory without the directory part of the source file.
538 # - basenames: the basenames of the files to compile. The names may include
539 # relative or absolute path names. No wildcard is allowed
540 # - cflags (default $(CFLAGS)): the C flags to use for compilation
541 # - dflags: the flags used during creation of dependency file. If not specified
542 # the same value as cflags will be used
543 # - targetdir: the directory to put the .o file and the .d file. By default
544 # it is put in the same directory as the .c file. When targetdir is not
545 # empty, path names will be stripped from the file names so that all files
546 # are in that dir and not in subdirectories.
547 # - compiler (default target): compiler to use, target, kernel or host
548 %define rule_compile_multi basenames=/A cflags=$(CFLAGS) dflags= targetdir= \
552 TMP_TARGETS := $(addsuffix .o,%(basenames))
553 TMP_DTARGETS := $(addsuffix .d,%(basenames))
556 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
557 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
558 TMP_WILDCARD := %(targetdir)/%
560 # Be sure that all .c files are generated
561 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .c,%(basenames))
563 # Be sure that all .c files are found
564 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
565 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
566 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
568 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
569 vpath %.c $(TMP_DIRS)
574 TMP_CFLAGS := %(cflags)
576 TMP_DFLAGS := %(cflags)
578 TMP_DFLAGS := %(dflags)
581 ifeq ($(findstring %(compiler),host kernel target),)
582 $(error unknown compiler %(compiler))
584 ifeq (%(compiler),target)
585 BD_LINK ?= $(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
586 BD_STRIP ?= $(TARGET_STRIP)
587 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TARGET_CC) $(TARGET_SYSROOT)
588 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_CFLAGS:=$(TARGET_CFLAGS) $(TMP_CFLAGS)
589 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_DFLAGS:=$(TARGET_CFLAGS) $(TMP_DFLAGS)
590 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
591 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
593 ifeq (%(compiler),host)
594 BD_LINK ?= $(HOST_CC) $(HOST_LDFLAGS)
595 BD_STRIP ?= $(HOST_STRIP)
596 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_CC)
597 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_CFLAGS:=$(HOST_CFLAGS) $(TMP_CFLAGS)
598 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_DFLAGS:=$(HOST_CFLAGS) $(TMP_DFLAGS)
599 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
600 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
602 ifeq (%(compiler),kernel)
603 BD_LINK ?= $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
604 BD_STRIP ?= $(ECHO) >/dev/null
605 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
606 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_CFLAGS:=$(KERNEL_CFLAGS) $(TMP_CFLAGS)
607 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_DFLAGS:=$(KERNEL_CFLAGS) $(TMP_DFLAGS)
608 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
609 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
612 $(TMP_TARGETS) : CFLAGS := %(TMP_CFLAGS)
613 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.c
614 %compile_q cmd=$(CMD) opt=$(TMP_CFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
616 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.c
617 %mkdepend_q cc=$(CMD) flags=$(TMP_DFLAGS)
619 #------------------------------------------------------------------------------
622 #------------------------------------------------------------------------------
623 # Generate a rule to compile multiple C++ source files to an object file and
624 # generate the corresponding dependency files. The generated file will be put
625 # in the object directory without the directory part of the source file.
627 # - basenames: the basenames of the files to compile. The names may include
628 # relative or absolute path names. No wildcard is allowed. basenames will be
629 # matched to supported AROS_CXXEXTS.
630 # - cflags (default $(CFLAGS)): the C flags to use for compilation
631 # - dflags: the flags used during creation of dependency file. If not specified
632 # the same value as cflags will be used
633 # - targetdir: the directory to put the .o file and the .d file. By default
634 # it is put in the same directory as the .c file. When targetdir is not
635 # empty, path names will be stripped from the file names so that all files
636 # are in that dir and not in subdirectories.
637 # - compiler (default target): compiler to use, target, kernel or host
638 %define rule_compile_cxx_multi basenames=/A cxxflags=$(CXXFLAGS) dxxflags= \
639 targetdir= compiler=target
641 TMP_CXXABSBASENAMES := $(foreach TMP_CXXBASE,%(basenames),$(if $(filter /%,$(TMP_CXXBASE)),$(TMP_CXXBASE),$(abspath $(SRCDIR)/$(CURDIR)/$(TMP_CXXBASE))))
643 ifneq ($(TMP_CXXABSBASENAMES),)
645 TMP_CXXBASENAMES := $(basename $(TMP_CXXABSBASENAMES))
647 # Identify the "real" c++ files from the passed in basenames
648 TMP_CXXFILES := $(strip $(foreach TMP_CXXBASE,$(TMP_CXXABSBASENAMES), $(firstword $(wildcard $(foreach TMP_EXT, $(AROS_CXXEXTS),$(addsuffix .$(TMP_EXT),$(TMP_CXXBASE)))))))
651 TMP_CXXTARGETS := $(notdir $(TMP_CXXBASENAMES:=.o))
652 TMP_CXXDTARGETS := $(notdir $(TMP_CXXBASENAMES:=.d))
655 TMP_CXXTARGETS := $(addprefix %(targetdir)/,$(notdir $(TMP_CXXBASENAMES:=.o)))
656 TMP_CXXDTARGETS := $(addprefix %(targetdir)/,$(notdir $(TMP_CXXBASENAMES:=.d)))
657 TMP_WILDCARD := %(targetdir)/%
659 # Be sure that all source files are generated
660 $(TMP_CXXTARGETS) $(TMP_CXXDTARGETS) : | $(TMP_CXXFILES)
663 # Adjust compiler flags to suit C++
664 TMP_CXXFLAGS := %(cxxflags)
666 TMP_DXXFLAGS := %(cxxflags)
668 TMP_DXXFLAGS := %(dxxflags)
671 ifeq ($(findstring %(compiler),host kernel target),)
672 $(error unknown compiler %(compiler))
674 ifeq (%(compiler),host)
675 BD_LINK ?= $(HOST_CXX) $(HOST_LDFLAGS)
676 BD_STRIP ?= $(HOST_STRIP)
677 TMP_CXXCMD:=$(HOST_CXX)
678 TMP_CXXFLAGS := $(HOST_CXXFLAGS) $(TMP_CXXFLAGS)
679 TMP_DXXFLAGS := $(HOST_CXXFLAGS) $(TMP_DXXFLAGS)
680 TMP_CXXIQUOTE:=$(HOST_IQUOTE)
681 TMP_CXXIQUOTE_END:=$(HOST_IQUOTE_END)
683 ifeq (%(compiler),target)
684 BD_LINK ?= $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
685 BD_STRIP ?= $(TARGET_STRIP)
686 TMP_CXXCMD:=$(AROS_CXX) $(TARGET_SYSROOT)
687 TMP_CXXFLAGS := $(TARGET_CXXFLAGS) $(TMP_CXXFLAGS)
688 TMP_DXXFLAGS := $(TARGET_CXXFLAGS) $(TMP_DXXFLAGS)
689 TMP_CXXIQUOTE:=$(CFLAGS_IQUOTE)
690 TMP_CXXIQUOTE_END:=$(CFLAGS_IQUOTE_END)
692 ifeq (%(compiler),kernel)
693 KERNEL_CXX ?= $(KERNEL_CC)
694 BD_LINK ?= $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
695 BD_STRIP ?= $(ECHO) >/dev/null
696 TMP_CXXCMD:=$(KERNEL_CXX) $(KERNEL_SYSROOT)
697 TMP_CXXFLAGS := $(KERNEL_CXXFLAGS) $(TMP_CXXFLAGS)
698 TMP_DXXFLAGS := $(KERNEL_CXXFLAGS) $(TMP_DXXFLAGS)
699 TMP_CXXIQUOTE:=$(KERNEL_IQUOTE)
700 TMP_CXXIQUOTE_END:=$(KERNEL_IQUOTE_END)
703 define cxx_multi_recipe_template
705 %compile_q cmd=$(TMP_CXXCMD) opt=$(TMP_CXXFLAGS) iquote=$(TMP_CXXIQUOTE) iquote_end=$(TMP_CXXIQUOTE_END) from=$(2) to=$(1).o
708 %mkdepend_q cc=$(TMP_CXXCMD) flags=$(TMP_DXXFLAGS) from=$(2) to=$(1).d
711 $(foreach TMP_CXXFILE,$(TMP_CXXFILES),$(eval $(call cxx_multi_recipe_template,$(notdir $(basename $(TMP_CXXFILE))),$(TMP_CXXFILE))))
713 $(foreach TMP_CXXFILE,$(TMP_CXXFILES),$(eval $(call cxx_multi_recipe_template,$(addprefix %(targetdir)/,$(notdir $(basename $(TMP_CXXFILE)))),$(TMP_CXXFILE))))
719 #------------------------------------------------------------------------------
722 #------------------------------------------------------------------------------
723 # Generate a rule to compile multiple ObjC source files to an object file and
724 # generate the corresponding dependency files. The generated file will be put
725 # in the object directory without the directory part of the source file.
727 # - basenames: the basenames of the files to compile. The names may include
728 # relative or absolute path names. No wildcard is allowed
729 # - cflags (default $(CFLAGS)): the C flags to use for compilation
730 # - dflags: the flags used during creation of dependency file. If not specified
731 # the same value as cflags will be used
732 # - targetdir: the directory to put the .o file and the .d file. By default
733 # it is put in the same directory as the .m file. When targetdir is not
734 # empty, path names will be stripped from the file names so that all files
735 # are in that dir and not in subdirectories.
736 # - compiler (default target): compiler to use, target, kernel or host
737 %define rule_compile_objc_multi basenames=/A cflags=$(CFLAGS) dflags= \
738 targetdir= compiler=target
740 ifneq (%(basenames),)
743 TMP_TARGETS := $(addsuffix .o,%(basenames))
744 TMP_DTARGETS := $(addsuffix .d,%(basenames))
747 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,%(basenames)))
748 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,%(basenames)))
749 TMP_WILDCARD := %(targetdir)/%
751 # Be sure that all .m files are generated
752 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .m,%(basenames))
754 # Be sure that all .m files are found
755 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
756 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
757 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
759 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
760 vpath %.m $(TMP_DIRS)
764 # Define the use of cross compiler
765 ifeq ($(TARGET_OBJC),)
766 TMP_CC := $(TARGET_CC)
768 TMP_CC := $(TARGET_OBJC)
771 # Adjust compiler flags to suit ObjC
772 TMP_OBJCFLAGS := %(cflags)
773 TMP_OBJCFLAGS := $(TMP_OBJCFLAGS) -isystem $(AROS_DEVELOPMENT)/include
774 TMP_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(TMP_OBJCFLAGS)))
776 TMP_OBJCDFLAGS := %(cflags)
778 TMP_OBJCDFLAGS := %(dflags)
781 ifeq ($(findstring %(compiler),host kernel target),)
782 $(error unknown compiler %(compiler))
784 ifeq (%(compiler),target)
785 BD_LINK ?= $(TMP_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
786 BD_STRIP ?= $(TARGET_STRIP)
787 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TMP_CC) $(TARGET_SYSROOT)
788 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCFLAGS:=$(TARGET_CFLAGS) $(TMP_OBJCFLAGS)
789 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCDFLAGS:=$(TARGET_CFLAGS) $(TMP_OBJCDFLAGS)
790 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
791 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
793 ifeq (%(compiler),host)
794 BD_LINK ?= $(HOST_OBJC) $(HOST_LDFLAGS)
795 BD_STRIP ?= $(HOST_STRIP)
796 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_OBJC)
797 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCFLAGS:=$(HOST_CFLAGS) $(TMP_OBJCFLAGS)
798 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCDFLAGS:=$(HOST_CFLAGS) $(TMP_OBJCDFLAGS)
799 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
800 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
802 ifeq (%(compiler),kernel)
803 KERNEL_OBJC ?= $(KERNEL_CC)
804 BD_LINK ?= $(KERNEL_OBJC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
805 BD_STRIP ?= $(ECHO) >/dev/null
806 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_OBJC) $(KERNEL_SYSROOT)
807 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCFLAGS:=$(KERNEL_CFLAGS) $(TMP_OBJCFLAGS)
808 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCDFLAGS:=$(KERNEL_CFLAGS) $(TMP_OBJCDFLAGS)
809 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
810 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
813 $(TMP_TARGETS) : CFLAGS := $(TMP_OBJCFLAGS)
814 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.m
815 %compile_q cmd=$(CMD) opt=$(TMP_OBJCFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
817 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.m
818 %mkdepend_q cc=$(CMD) flags=$(DFLAGS)
823 #------------------------------------------------------------------------------
826 #------------------------------------------------------------------------------
827 # Make an alias from one arch specific build to another arch.
829 # - mainmmake: the mmake of the module in the main tree
830 # - arch: the current arch
831 # - alias: the alias to which this should point
832 %define rule_archalias mainmmake=\A arch=\A alias=\A
834 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
836 #------------------------------------------------------------------------------
839 #------------------------------------------------------------------------------
840 # Generate a rule to assemble a source file to an object file. Basename may
841 # contain a directory part, then the source file has to be in that directory.
842 # The generated file will be put in the object directory without the directory.
844 # - basename: the basename of the file to compile. Use % for a wildcard rule
845 # - flags (default $(AFLAGS)): the asm flags to use for assembling
846 # - targetdir: the directory to put the .o file in. By default it is put in the
847 # same directory as the .s file
848 %define rule_assemble basename=/A aflags=$(AFLAGS) targetdir=
851 %(basename).o : AFLAGS := %(aflags)
852 %(basename).o : %(basename).s
854 %(basename).o : %(basename).S
858 %(targetdir)/$(notdir %(basename)).o : AFLAGS := %(aflags)
859 %(targetdir)/$(notdir %(basename)).o : %(basename).s
861 %(targetdir)/$(notdir %(basename)).o : %(basename).S
866 #------------------------------------------------------------------------------
869 #------------------------------------------------------------------------------
870 # Generate a rule to assemble multiple source files to an object file. The
871 # generated file will be put in the object directory with the directory part
872 # of the source file stripped off.
874 # - basenames: the basenames of the files to compile. The names may include
875 # relative or absolute path names. No wildcard is allowed
876 # - aflags (default $(AFLAGS)): the flags to use for assembly
877 # - targetdir: the directory to put the .o file and the .d file. By default
878 # it is put in the same directory as the .c file. When targetdir is not
879 # empty, path names will be stripped from the file names so that all files
880 # are in that dir and not in subdirectories.
881 %define rule_assemble_multi basenames=/A aflags=$(AFLAGS) targetdir= suffix=.s compiler=target
884 TMP_TARGETS := $(addsuffix .o,%(basenames))
887 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
888 TMP_WILDCARD := %(targetdir)/%
890 # Be sure that all .s files are generated
891 $(TMP_TARGETS) : | $(addsuffix %(suffix),%(basenames))
893 # Be sure that all .c files are found
894 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
895 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
896 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
898 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
899 vpath %%(suffix) $(TMP_DIRS)
904 ifeq ($(findstring %(compiler),host kernel target),)
905 $(error unknown compiler %(compiler))
907 ifeq (%(compiler),target)
908 $(TMP_TARGETS) : TMP_CMD:=$(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_CFLAGS)
910 ifeq (%(compiler),host)
911 $(TMP_TARGETS) : TMP_CMD:=$(HOST_CC)
913 ifeq (%(compiler),kernel)
914 $(TMP_TARGETS) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_CFLAGS)
917 $(TMP_TARGETS) : AFLAGS := %(aflags)
918 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %%(suffix)
919 %assemble_q cmd=$(TMP_CMD) opt=$(AFLAGS)
921 #------------------------------------------------------------------------------
924 #------------------------------------------------------------------------------
925 # Link %(objs) to %(prog) using the libraries in %(uselibs)
926 %define rule_link_prog prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
927 usehostlibs= usestartup=yes detach=no nix=no cmd="$(AROS_CC) $(TARGET_SYSROOT)" strip=$(TARGET_STRIP)
932 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
934 ifeq (%(usestartup),no)
935 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
938 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
941 # Make a list of the lib files this program depends on.
942 # In LDFLAGS remove white space between -L and directory
943 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
944 # Filter out only the libdirs and remove -L
945 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
947 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
948 # Add normal linklib path
949 TMP_DIRS += $(AROS_LIB)/
950 # add lib and .a to static linklib names
951 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(TMP_EXTRA_LIBS)))
952 ifeq (%(usestartup),yes)
953 TMP_LIBS += startup.o
958 # search for the linklibs in the given path, ignore ones not found
959 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
960 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
963 %(prog) : OBJS := %(objs)
964 %(prog) : LDFLAGS := %(ldflags) $(TMP_EXTRA_LDFLAGS)
965 %(prog) : LIBS := $(addprefix -l,%(uselibs) $(TMP_EXTRA_LIBS) %(usehostlibs))
966 %(prog) : %(objs) $(TMP_DEPLIBS)
967 %link_q cmd="%(cmd)" strip="%(strip)" from=$(OBJS) opt=$(LDFLAGS) libs=$(LIBS)
969 #------------------------------------------------------------------------------
972 #------------------------------------------------------------------------------
973 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
974 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
975 %define rule_link_progs progs=/A targetdir=$(AROSDIR)/$(CURDIR) nix=%(nix) \
976 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
977 usestartup=yes detach=no cmd="$(AROS_CC) $(TARGET_SYSROOT)" strip=$(TARGET_STRIP)
982 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
984 ifeq (%(usestartup),no)
985 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
988 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
991 # Make a list of the lib files the programs depend on.
992 # In LDFLAGS remove white space between -L and directory
993 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
994 # Filter out only the libdirs and remove -L
995 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
997 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
998 # Add normal linklib path
999 TMP_DIRS += $(AROS_LIB)/
1000 # add lib and .a to static linklib names
1001 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(TMP_EXTRA_LIBS)))
1002 # search for the linklibs in the given path, ignore ones not found
1003 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
1004 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
1006 TMP_PROGS := $(addprefix %(targetdir)/,%(progs))
1008 $(TMP_PROGS) : LDFLAGS:= %(ldflags) $(TMP_EXTRA_LDFLAGS)
1009 $(TMP_PROGS) : LIBS:= $(addprefix -l,%(uselibs) $(TMP_EXTRA_LIBS) %(usehostlibs))
1010 $(TMP_PROGS) : %(targetdir)/% : %(objdir)/%.o $(TMP_DEPLIBS)
1011 %link_q cmd="%(cmd)" strip="%(strip)" from=$< opt=$(LDFLAGS) libs=$(LIBS)
1013 #------------------------------------------------------------------------------
1016 #------------------------------------------------------------------------------
1017 # Link the %(objs) to the library %(libdir)/lib%(libname).a
1018 %define rule_link_linklib libname=/A objs=/A libdir=$(AROS_LIB) linker=target
1020 ifeq (%(linker),target)
1021 %(libdir)/lib%(libname).a : TMP_AR:=$(AR)
1022 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(RANLIB)
1024 ifeq (%(linker),host)
1025 %(libdir)/lib%(libname).a : TMP_AR:=$(HOST_AR)
1026 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(HOST_RANLIB)
1028 ifeq (%(linker),kernel)
1029 %(libdir)/lib%(libname).a : TMP_AR:=$(KERNEL_AR)
1030 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(KERNEL_RANLIB)
1033 %(libdir)/lib%(libname).a : %(objs)
1034 %mklib_q from=$^ ar=$(TMP_AR) ranlib=$(TMP_RANLIB)
1036 #------------------------------------------------------------------------------
1038 #------------------------------------------------------------------------------
1039 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
1040 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
1041 %define rule_linkmodule module=/A objs=/A endobj=/A err=/A objdir=$(OBJDIR) \
1042 cmd="$(AROS_CC) $(TARGET_SYSROOT)" ldflags=$(LDFLAGS) uselibs= usehostlibs=
1044 TMP_LDFLAGS := %(ldflags)
1045 # Make a list of the lib files the programs depend on.
1046 # In LDFLAGS remove white space between -L and directory
1047 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
1048 # Filter out only the libdirs and remove -L
1049 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
1051 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
1052 # Add normal linklib path
1053 TMP_DIRS += $(AROS_LIB)/
1054 # add lib and .a to static linklib names
1055 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
1056 # search for the linklibs in the given path, ignore ones not found
1057 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
1058 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
1061 %(module) : LIB_NAMES := %(uselibs)
1062 %(module) : OBJS := %(objs)
1063 %(module) : ENDTAG := %(endobj)
1064 %(module) : ERR := %(err)
1065 %(module) : OBJDIR := %(objdir)
1066 %(module) : LDFLAGS := $(TMP_LDFLAGS)
1067 ifeq (%(usehostlibs),)
1068 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES))
1070 # Warning: the -L/usr/lib here can result in modules
1071 # linking against host libs instead of AROS libs (e.g stdc++) !!
1072 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES)) \
1073 -L/usr/lib $(addprefix -l,%(usehostlibs))
1075 %(module) : %(objs) %(endobj) $(TMP_DEPLIBS) $(USER_DEPLIBS)
1076 %link_module_q cmd="%(cmd)" err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS) objdir=$(OBJDIR) ldflags=$(LDFLAGS)
1079 #------------------------------------------------------------------------------
1082 #------------------------------------------------------------------------------
1083 # Generate the libdefs.h include file for a module.
1084 %define rule_genmodule_genlibdefs modname=/A modtype=/A modsuffix= conffile= targetdir= version=
1086 TMP_TARGET := %(modname)_libdefs.h
1087 TMP_DEPS := $(GENMODULE)
1089 ifneq (%(conffile),)
1090 ifeq ($(dir %(conffile)),./)
1091 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1092 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1094 TMP_OPTS += -c %(conffile)
1095 TMP_DEPS += %(conffile)
1098 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1099 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1101 ifneq (%(modsuffix),)
1102 TMP_OPTS += -s %(modsuffix)
1104 ifneq (%(targetdir),)
1105 TMP_OPTS += -d %(targetdir)
1106 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1109 TMP_OPTS += -v %(version)
1112 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1113 $(TMP_TARGET) : MODNAME := %(modname)
1114 $(TMP_TARGET) : MODTYPE := %(modtype)
1115 $(TMP_TARGET) : $(TMP_DEPS)
1116 @$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1117 @$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
1119 #------------------------------------------------------------------------------
1121 #------------------------------------------------------------------------------
1122 # Generate the _lib.fd file for a module.
1123 %define rule_genmodule_fd modname=/A modtype=/A modsuffix= conffile= targetdir=
1125 TMP_TARGET := %(modname)_lib.fd
1126 TMP_DEPS := $(GENMODULE)
1128 ifneq (%(conffile),)
1129 ifeq ($(dir %(conffile)),./)
1130 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1131 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1133 TMP_OPTS += -c %(conffile)
1134 TMP_DEPS += %(conffile)
1137 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1138 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1140 ifneq (%(modsuffix),)
1141 TMP_OPTS += -s %(modsuffix)
1143 ifneq (%(targetdir),)
1144 TMP_OPTS += -d %(targetdir)
1145 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1148 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1149 $(TMP_TARGET) : MODNAME := %(modname)
1150 $(TMP_TARGET) : MODTYPE := %(modtype)
1151 $(TMP_TARGET) : $(TMP_DEPS)
1152 @$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1153 @$(GENMODULE) $(OPTS) writefd $(MODNAME) $(MODTYPE)
1155 #------------------------------------------------------------------------------
1157 #------------------------------------------------------------------------------
1158 # Generate a Makefile.%(modname)%(modtype) with the genmodule program and include this
1159 # generated file in this Makefile
1160 %define rule_genmodule_makefile modname=/A modtype=/A modsuffix= conffile= \
1163 TMP_TARGET := Makefile.%(modname)%(modtype)
1164 TMP_DEPS := $(GENMODULE)
1166 ifneq (%(conffile),)
1167 ifeq ($(dir %(conffile)),./)
1168 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1169 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1171 TMP_OPTS += -c %(conffile)
1172 TMP_DEPS += %(conffile)
1175 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1176 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1178 ifneq (%(modsuffix),)
1179 TMP_OPTS += -s %(modsuffix)
1181 ifneq (%(targetdir),)
1182 TMP_OPTS += -d %(targetdir)
1183 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1186 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1187 $(TMP_TARGET) : MODNAME := %(modname)
1188 $(TMP_TARGET) : MODTYPE := %(modtype)
1189 $(TMP_TARGET) : $(TMP_DEPS)
1190 @$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
1192 #------------------------------------------------------------------------------
1195 #------------------------------------------------------------------------------
1196 # Generate the support files for compiling a module. This includes include
1197 # files and source files. This rule has to be preceeded by
1198 # %rule_genmodule_makefile
1199 %define rule_genmodule_files modname=/A modtype=/A modsuffix= targetdir= \
1202 TMP_TARGETS := $(%(modname)_STARTFILES) $(%(modname)_ENDFILES) \
1203 $(%(modname)_LINKLIBFILES) $(%(modname)_RELLINKLIBFILES)
1204 TMP_TARGETS := $(addsuffix .c,$(TMP_TARGETS)) \
1205 $(addsuffix .S, $(%(modname)_LINKLIBAFILES) $(%(modname)_RELLINKLIBAFILES))
1207 TMP_DEPS := $(GENMODULE)
1210 ifneq (%(conffile),)
1211 ifeq ($(dir %(conffile)),./)
1212 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1213 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1215 TMP_OPTS += -c %(conffile)
1216 TMP_DEPS += %(conffile)
1219 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1220 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1222 ifneq (%(modsuffix),)
1223 TMP_OPTS += -s %(modsuffix)
1225 ifneq (%(targetdir),)
1226 TMP_OPTS += -d %(targetdir)
1227 TMP_TARGETDIR := $(shell echo %(targetdir) | sed 's/^\(.\):\//\/\1\//')
1228 TMP_TARGETS := $(addprefix $(TMP_TARGETDIR)/,$(TMP_TARGETS))
1231 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
1232 $(TMP_TARGETS) : MODNAME := %(modname)
1233 $(TMP_TARGETS) : MODTYPE := %(modtype)
1234 $(TMP_TARGETS) : $(TMP_DEPS)
1235 @$(ECHO) "Generating support files for module $(MODNAME$(BDID))"
1236 ifneq (%(conffile),lib.conf)
1237 @$(IF) $(TEST) -f lib.conf; then \
1238 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
1241 @$(IF) $(TEST) -f libdefs.h; then \
1242 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
1244 @$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
1246 #------------------------------------------------------------------------------
1249 #------------------------------------------------------------------------------
1250 # Generate the support files for compiling a module. This includes include
1251 # files and source files.
1252 %define rule_genmodule_includes modname=/A modtype=/A modsuffix= \
1253 targetdir= conffile=
1255 ifneq ($(%(modname)_INCLUDES),)
1256 TMP_TARGETS := $(%(modname)_INCLUDES)
1258 TMP_DEPS := $(GENMODULE)
1261 ifneq (%(conffile),)
1262 ifeq ($(dir %(conffile)),./)
1263 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1264 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1266 TMP_OPTS += -c %(conffile)
1267 TMP_DEPS += %(conffile)
1270 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1271 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1273 ifneq (%(modsuffix),)
1274 TMP_OPTS += -s %(modsuffix)
1276 ifneq (%(targetdir),)
1277 TMP_OPTS += -d %(targetdir)
1278 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
1281 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
1282 $(TMP_TARGETS) : MODNAME := %(modname)
1283 $(TMP_TARGETS) : MODTYPE := %(modtype)
1284 $(TMP_TARGETS) : $(TMP_DEPS)
1285 @$(ECHO) "Generating $(MODNAME).$(MODTYPE) includes"
1286 @$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
1289 #------------------------------------------------------------------------------
1291 #------------------------------------------------------------------------------
1292 # Link %(objs) to binary blob in %(file) using %(name) as name of embedded binary object
1293 # 'start' is an optional starting address
1294 # 'ldflags' is optional additional flags for the linker
1295 %define rule_link_binary file=/A name=/A objs= files= start=0 ldflags=
1297 BD_OUTDIR := $(dir %(file))
1298 # This trick removes the trailing '/', otherwise findstring below fails, causing a warning
1299 BD_OUTDIR := $(subst /*,,$(addsuffix *,$(BD_OUTDIR)))
1300 BD_TMPDIR := $(GENDIR)/$(CURDIR)
1301 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(notdir %(files))))
1302 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(notdir %(files))))
1305 %rule_compile_multi basenames="%(files)" targetdir=$(BD_OBJDIR)
1307 %(file) : $(BD_OBJS) $(BD_DEPS) $(BD_OUTDIR)
1308 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)..."
1309 @$(KERNEL_LD) %(ldflags) --entry=%(start) --oformat=binary -Ttext=%(start) -o $(BD_TMPDIR)/%(name) $(BD_OBJS)
1310 @cd $(BD_TMPDIR) && $(AROS_LD) %(ldflags) -r --format binary %(name) -o $@
1312 ifeq ($(findstring $(BD_OUTDIR),$(GLOB_MKDIRS)),)
1313 GLOB_MKDIRS += $(BD_OUTDIR)
1318 #------------------------------------------------------------------------------
1319 # Common rules for all makefiles
1321 # Delete generated makefiles
1324 @$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
1326 include $(SRCDIR)/config/make.tail
1328 BDID := $(BDTARGETID)
1330 #------------------------------------------------------------------------------
1333 #############################################################################
1334 #############################################################################
1336 ## Here are the mmakefile build macros. These are macros that takes care ##
1337 ## of everything to go from the sources to the generated target. Also all ##
1338 ## intermediate files and directories that are needed are created by these ##
1341 #############################################################################
1342 #############################################################################
1344 #------------------------------------------------------------------------------
1346 %define build_prog mmake=/A progname=/A files=$(BD_PROGNAME) cxxfiles= \
1348 asmfiles= objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1349 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_CXXFLAGS) ldflags=$(LDFLAGS) \
1350 aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
1351 includedir= libdir= \
1352 compiler=target linker=
1356 BD_PROGNAME := %(progname)
1357 BD_OBJDIR := %(objdir)
1358 BD_TARGETDIR := %(targetdir)
1359 BD_LINKER := %(linker)
1361 # If not supplied, linker is equal to compiler
1362 ifeq ($(BD_LINKER),)
1363 BD_LINKER := %(compiler)
1366 BD_FILES := %(files)
1367 BD_OBJCFILES := %(objcfiles)
1368 BD_ASMFILES := %(asmfiles)
1369 BD_CXXFILES := %(cxxfiles)
1371 BD_ARCHOBJS := $(wildcard $(BD_OBJDIR)/arch/*.o)
1372 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1373 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1375 TMP_FILES := $(BD_NARCHFILES) $(BD_CXXFILES) $(BD_ASMFILES) $(BD_OBJCFILES)
1376 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(notdir $(TMP_FILES))))
1377 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(notdir $(TMP_FILES))))
1379 BD_CFLAGS := %(cflags)
1380 BD_CXXFLAGS := %(cxxflags)
1381 ifneq (%(includedir),)
1382 BD_CFLAGS += -I%(includedir)
1383 BD_CXXFLAGS += -I%(includedir)
1385 BD_AFLAGS := %(aflags)
1386 ifneq (%(includedir),)
1387 BD_AFLAGS += -I%(includedir)
1389 BD_DFLAGS := %(dflags)
1390 BD_DXXFLAGS := %(dxxflags)
1391 BD_LDFLAGS := %(ldflags)
1393 BD_LDFLAGS += -L%(libdir)
1397 %(mmake)-quick : %(mmake)
1399 #MM %(mmake) : includes-generate-deps core-linklibs linklibs-%(uselibs)
1400 %(mmake) : $(BD_TARGETDIR)/$(BD_PROGNAME)
1402 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick %(mmake)-gz-quick),)
1403 %rule_compile_cxx_multi basenames=$(BD_CXXFILES) targetdir=$(BD_OBJDIR) \
1404 cxxflags=$(BD_CXXFLAGS) dxxflags=$(BD_DXXFLAGS) compiler="%(compiler)"
1405 %rule_compile_objc_multi basenames=$(BD_OBJCFILES) targetdir=$(BD_OBJDIR) \
1406 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler="%(compiler)"
1407 %rule_compile_multi basenames=$(BD_NARCHFILES) targetdir=$(BD_OBJDIR) \
1408 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler="%(compiler)"
1409 %rule_assemble_multi basenames=$(BD_ASMFILES) targetdir=$(BD_OBJDIR) \
1410 aflags=$(BD_AFLAGS) compiler="%(compiler)"
1412 %rule_link_prog prog=$(BD_TARGETDIR)/$(BD_PROGNAME) \
1413 objs="$(BD_OBJS) $(BD_ARCHOBJS) $(USER_OBJS)" ldflags=$(BD_LDFLAGS) \
1414 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1415 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)" \
1416 cmd=$(BD_LINK) strip=$(BD_STRIP)
1420 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1422 $(BD_OBJS) $(BD_DEPS) : | $(BD_OBJDIR)
1423 $(BD_TARGETDIR)/$(BD_PROGNAME) : | $(BD_TARGETDIR)
1424 GLOB_MKDIRS += $(BD_OBJDIR) $(BD_TARGETDIR)
1426 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_TARGETDIR)/$(BD_PROGNAME) $(BD_DEPS)
1429 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1433 #------------------------------------------------------------------------------
1436 #------------------------------------------------------------------------------
1437 # Build programs, for every C file an executable will be built with the same
1438 # name as the C file
1439 %define build_progs mmake=/A files=/A nix=no \
1440 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1441 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
1442 includedir= libdir= \
1443 uselibs= usehostlibs= usestartup=yes detach=no
1447 BD_OBJDIR := %(objdir)
1448 BD_TARGETDIR := %(targetdir)
1450 BD_FILES := %(files)
1451 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1452 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1453 BD_EXES := $(addprefix $(BD_TARGETDIR)/,$(BD_FILES))
1455 BD_CFLAGS := %(cflags)
1456 ifneq (%(includedir),)
1457 BD_CFLAGS += -I%(includedir)
1459 BD_DFLAGS := %(dflags)
1460 BD_LDFLAGS := %(ldflags)
1462 BD_LDFLAGS += -L%(libdir)
1466 %(mmake)-quick : %(mmake)
1468 #MM %(mmake) : includes-generate-deps core-linklibs linklibs-%(uselibs)
1469 %(mmake) : $(BD_EXES)
1471 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1472 %rule_compile_multi basenames=$(BD_FILES) targetdir=$(BD_OBJDIR) \
1473 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1475 %rule_link_progs progs=$(BD_FILES) nix="%(nix)" \
1476 targetdir=$(BD_TARGETDIR) objdir=$(BD_OBJDIR) \
1477 ldflags=$(BD_LDFLAGS) \
1478 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1479 usestartup="%(usestartup)" detach="%(detach)" \
1480 cmd=$(BD_LINK) strip=$(BD_STRIP)
1484 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1486 $(addprefix $(BD_TARGETDIR)/,$(BD_FILES)) : | $(BD_TARGETDIR)
1487 $(BD_DEPS) $(BD_OBJS) : | $(BD_OBJDIR)
1488 GLOB_MKDIRS += $(BD_TARGETDIR) $(BD_OBJDIR)
1490 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_EXES) $(BD_DEPS)
1493 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1497 #------------------------------------------------------------------------------
1500 #------------------------------------------------------------------------------
1502 # This is a bare version: It just compiles and links the given files. It is
1503 # assumed that all needed boiler plate code is in the files. This should only
1504 # be used for compiling external code. For AROS code use %build_module
1505 %define build_module_simple mmake=/A modname=/A modtype=/A \
1506 files="$(basename $(call WILDCARD, *.c))" \
1507 cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1508 objdir=$(OBJDIR) moduledir= \
1509 uselibs= usehostlibs= compiler=target
1511 # Define metamake targets and their dependencies
1512 #MM %(mmake) : core-linklibs includes-generate-deps
1513 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1514 #MM %(mmake)-kobj-quick
1518 BD_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj
1520 .PHONY : $(BD_ALLTARGETS)
1523 $(error using %build_module_simple: modname may not be empty)
1526 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1529 # Default values for variables and arguments
1530 BD_DEFLINKLIBNAME := %(modname)
1531 BD_DEFDFLAGS := %(cflags)
1532 BD_DEFDXXFLAGS := %(dxxflags)
1533 OBJDIR ?= $(GENDIR)/$(CURDIR)
1534 BD_MODDIR := %(moduledir)
1535 ifeq ($(BD_MODDIR),)
1536 ifeq (%(modtype),library)
1537 BD_MODDIR := $(AROS_LIBRARIES)
1539 ifeq (%(modtype),gadget)
1540 BD_MODDIR := $(AROS_GADGETS)
1542 ifeq (%(modtype),datatype)
1543 BD_MODDIR := $(AROS_DATATYPES)
1545 ifeq (%(modtype),handler)
1546 BD_MODDIR := $(AROS_FS)
1548 ifeq (%(modtype),device)
1549 BD_MODDIR := $(AROS_DEVS)
1551 ifeq (%(modtype),resource)
1552 BD_MODDIR := $(AROS_RESOURCES)
1554 ifeq (%(modtype),hook)
1555 BD_MODDIR := $(AROS_RESOURCES)
1557 ifeq (%(modtype),mui)
1558 BD_MODDIR := $(AROS_CLASSES)/Zune
1560 ifeq (%(modtype),mcc)
1561 BD_MODDIR := $(AROS_CLASSES)/Zune
1563 ifeq (%(modtype),mcp)
1564 BD_MODDIR := $(AROS_CLASSES)/Zune
1566 ifeq (%(modtype),usbclass)
1567 BD_MODDIR := $(AROS_CLASSES)/USB
1569 ifeq (%(modtype),hidd)
1570 BD_MODDIR := $(AROS_DRIVERS)
1572 ifeq (%(modtype),printer)
1573 BD_MODDIR := $(AROS_PRINTERS)
1576 ifeq ($(BD_MODDIR),)
1577 $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1580 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1581 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1582 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),%(files))
1584 %rule_compile_multi \
1585 basenames=$(BD_NARCHFILES) targetdir="%(objdir)" \
1586 cflags="%(cflags)" dflags="%(dflags)" \
1587 compiler="%(compiler)"
1589 # Handlers use dash instead of dot in their names
1590 ifeq (%(modtype),handler)
1591 BD_MODULE := $(BD_MODDIR)/%(modname)-%(modtype)
1593 ifeq (%(modtype),printer)
1594 BD_MODULE := $(BD_MODDIR)/%(modname)
1596 BD_MODULE := $(BD_MODDIR)/%(modname).%(modtype)
1599 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1601 %(mmake)-quick : %(mmake)
1602 %(mmake)-kobj-quick : $(BD_KOBJ)
1603 %(mmake) : $(BD_MODULE)
1604 %(mmake)-kobj : $(BD_KOBJ)
1606 # The module is linked from all the compiled .o files
1607 BD_OBJS := $(BD_ARCHOBJS) $(addprefix %(objdir)/, $(addsuffix .o,$(notdir $(BD_NARCHFILES))))
1609 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
1610 # This breaks con-handler build. Here we work around this
1611 ifeq (%(modname),con)
1612 BD_ERR := $(notdir $(BD_MODULE)).err
1614 BD_ERR := %(modname).err
1617 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1618 endobj= err=$(BD_ERR) objdir="%(objdir)" \
1619 ldflags="$(LDFLAGS) $(%(modname)_LDFLAGS)" \
1620 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
1622 # Link kernel object file
1623 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1625 # Make these symbols local
1626 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1627 UtilityBase ExpansionBase KeymapBase KernelBase
1629 BD_SYMBOLS := $(BD_KBASE)
1631 BD_KLIB := hiddstubs amiga arossupport autoinit libinit
1632 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1633 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1634 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
1635 $(BD_KOBJ) : USER_LDFLAGS := $(USER_LDFLAGS)
1636 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1637 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
1638 @$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1639 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
1642 ## Dependency fine-tuning
1644 BD_DEPS := $(addprefix %(objdir)/, $(addsuffix .d,%(files)))
1645 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1647 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1648 $(BD_MODULE) : | $(BD_MODDIR)
1649 $(BD_KOBJ) : | $(KOBJSDIR)
1650 GLOB_MKDIRS += %(objdir) $(BD_MODDIR) $(KOBJSDIR)
1652 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_MODULE) $(BD_KOBJ) $(BD_DEPS)
1654 @$(ECHO) "Cleaning up for module %(modname)"
1657 #------------------------------------------------------------------------------
1660 #------------------------------------------------------------------------------
1661 # Build a module - core routine
1662 # Explanation of this macro is done in the developer's manual
1663 %define build_module_core mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
1664 files="$(basename $(call WILDCARD, *.c))" \
1665 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
1666 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_DEFDXXFLAGS) \
1667 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
1668 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
1669 compiler=target nostartup=yes archspecific=no \
1670 includedir= libdir= \
1671 build_abi= build_library=
1673 # We will employ a terrifying, but unavoidable, hack here.
1674 # genmf has no concept of conditionals (ie %ifeq), and MetaMake
1675 # ignores GNU Make ifeq() statements, but will process any #MM
1676 # headed lines in the file.
1678 # So, to make the following #MM lines conditional on whether we want
1679 # to build the ABI, Library, or both, we define build_abi= and
1680 # build_library as 'M' to enable, or '' to disable, which allows genmf
1681 # to do the following conversions:
1683 # #%(build_abi)M includes-foo: foo-include
1684 # becomes, when build_abi=M
1685 # #MM includes-foo: foo-include <= Processed by MetaMake
1686 # but, when build_abi= ...
1687 # #M includes-foo: foo-includes <= ignored by MetaMake! Yes!
1689 # Taking full blame for this: Jason S. McMullan <jason.mcmullan@gmail.com>
1691 # Define metamake targets and their dependencies
1694 #MM %(mmake)-makefile
1698 #M%(build_abi)- includes-all : %(mmake)-includes
1699 #M%(build_abi)- linklibs-%(modname): %(mmake)-linklib
1700 #M%(build_abi)- linklibs-%(modname)_rel : %(mmake)-linklib
1701 #M%(build_abi)- includes-%(modname): %(mmake)-includes
1702 #M%(build_abi)- includes-%(modname)_rel : %(mmake)-includes
1703 #M%(build_abi)- %(mmake) : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1704 #M%(build_abi) %(mmake)-linklib : %(mmake)-includes includes-%(uselibs)
1705 #M%(build_abi)- %(mmake)-quick : %(mmake)-includes-quick
1706 #M%(build_abi) %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1707 #M%(build_abi) includes-generate-deps %(mmake)-fd
1708 #M%(build_abi) %(mmake)-includes-quick
1709 #M%(build_abi) %(mmake)-includes-dirs
1710 #M%(build_abi) %(mmake)-fd
1713 #%(build_library)M %(mmake)-kobj : core-linklibs linklibs-%(uselibs)
1714 #%(build_library)M %(mmake)-kobj-quick :
1716 # Library with ABI targets:
1717 #%(build_library)%(build_abi) %(mmake)-kobj : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1718 #%(build_library)%(build_abi) %(mmake)-kobj-quick : %(mmake)-includes-quick
1720 # All MetaMake targets defined by this macro
1721 BD_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-clean
1723 ifeq (%(build_library),M)
1724 BD_ALLTARGETS += %(mmake)-kobj %(mmake)-kobj-quick
1727 ifeq (%(build_abi),M)
1728 BD_ALLTARGETS += %(mmake)-includes \
1729 %(mmake)-includes-quick %(mmake)-includes-dirs \
1730 %(mmake)-linklib %(mmake)-fd
1733 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1736 $(error using %build_module: modname may not be empty)
1739 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1742 # Default values for variables and arguments
1743 BD_DEFLINKLIBNAME := %(modname)
1744 BD_DEFDFLAGS := %(cflags)
1745 BD_DEFDXXFLAGS := %(cxxflags)
1746 ifneq (%(includedir),)
1747 BD_DEFDFLAGS += -I%(includedir)
1748 BD_DEFDXXFLAGS += -I%(includedir)
1750 OBJDIR ?= $(GENDIR)/$(CURDIR)
1752 ## Create genmodule include Makefile for the module
1754 %(mmake)-makefile : %(objdir)/Makefile.%(modname)%(modtype)
1756 %rule_genmodule_makefile \
1757 modname="%(modname)" modtype="%(modtype)" \
1758 modsuffix="%(modsuffix)" targetdir="%(objdir)" \
1759 conffile="%(conffile)"
1761 %(objdir)/Makefile.%(modname)%(modtype) : | %(objdir)
1763 GLOB_MKDIRS += %(objdir)
1765 # Do not parse these statements if metatarget is not appropriate
1766 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1768 include %(objdir)/Makefile.%(modname)%(modtype)
1770 BD_DEFMODDIR := $(%(modname)_MODDIR)
1771 ifeq (%(archspecific),yes)
1772 BD_DEFMODDIR := $(AROS_DIR_ARCH)/$(BD_DEFMODDIR)
1776 ## include files generation
1778 ifneq (%(includedir),)
1779 BD_INCDIR := %(includedir)
1781 BD_INCDIR := %(prefix)/$(AROS_DIR_INCLUDE)
1783 BD_LIBDEFSINC := %(objdir)/include/%(modname)_libdefs.h
1784 BD_DEFLIBDEFSINC := %(objdir)/include/%(modname)_deflibdefs.h
1786 ifeq (%(build_abi),M)
1787 %(mmake)-includes-quick : %(mmake)-includes
1788 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1789 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1790 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1792 ifneq ($(%(modname)_INCLUDES),)
1793 %rule_genmodule_includes modname="%(modname)" modtype="%(modtype)" \
1794 modsuffix="%(modsuffix)" targetdir="%(objdir)/include" \
1795 conffile="%(conffile)"
1797 %rule_copy_diff_multi \
1798 files=$(%(modname)_INCLUDES) srcdir="%(objdir)/include" targetdir=$(GENINCDIR) \
1799 stampfile="%(objdir)/%(modname)_geninc"
1801 %rule_copy_diff_multi \
1802 files=$(%(modname)_INCLUDES) srcdir="%(objdir)/include" targetdir=$(BD_INCDIR) \
1803 stampfile="%(objdir)/%(modname)_incs"
1805 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1807 TMP%(modname)_INCDIRS := \
1808 %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1809 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1810 $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1811 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget="%(mmake)-includes-dirs"
1817 %rule_genmodule_genlibdefs modname="%(modname)" modtype="%(modtype)" \
1818 modsuffix="%(modsuffix)" targetdir="%(objdir)/include" \
1819 conffile="%(conffile)" version="%(version)"
1821 $(BD_DEFLIBDEFSINC) : FILENAME := $(BD_LIBDEFSINC)
1822 $(BD_DEFLIBDEFSINC) :
1823 @$(ECHO) "Generating $@"
1824 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1826 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) : | %(objdir)/include
1827 GLOB_MKDIRS += %(objdir)/include
1829 ## Extra genmodule src files generation
1831 %rule_genmodule_files modname="%(modname)" modtype="%(modtype)" \
1832 modsuffix="%(modsuffix)" targetdir="%(objdir)" \
1833 conffile="%(conffile)"
1836 ifeq (%(build_abi),M)
1838 ifeq (%(includedir),)
1839 BD_FDDIR := %(prefix)/$(AROS_DIR_DEVELOPMENT)/fd
1841 BD_FDDIR := %(includedir)/../fd
1843 %(mmake)-fd : $(BD_FDDIR)/%(modname)_lib.fd
1845 %rule_genmodule_fd modname="%(modname)" modtype="%(modtype)" \
1846 modsuffix="%(modsuffix)" targetdir=$(BD_FDDIR) conffile="%(conffile)"
1848 $(BD_FDDIR)/%(modname)_lib.fd : | $(BD_FDDIR)
1850 GLOB_MKDIRS += $(BD_FDDIR)
1855 BD_FILES := %(files)
1856 BD_CXXFILES := %(cxxfiles)
1858 BD_FDIRS := $(sort $(dir $(BD_FILES)))
1860 BD_STARTFILES := $(addprefix %(objdir)/,$(%(modname)_STARTFILES))
1861 BD_ENDFILES := $(addprefix %(objdir)/,$(%(modname)_ENDFILES))
1863 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1864 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1865 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1867 BD_CFLAGS := %(cflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC) $(%(modname)_CFLAGS)
1868 BD_CXXFLAGS := %(cxxflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC) $(%(modname)_CXXFLAGS)
1869 ifneq (%(includedir),)
1870 BD_CFLAGS += -I%(includedir)
1871 BD_CXXFLAGS += -I%(includedir)
1873 BD_DFLAGS := %(dflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC) $(%(modname)_DFLAGS)
1874 BD_DXXFLAGS := %(dxxflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC) $(%(modname)_DXXFLAGS)
1876 ifeq (%(modtype),library)
1879 BD_LIBSUFFIX := .%(modtype)
1883 BD_LIBDIR := %(prefix)/$(AROS_DIR_LIB)
1885 BD_LIBDIR := %(libdir)
1888 ifeq (%(build_abi),M)
1889 BD_LINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBFILES))
1890 BD_LINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBAFILES))
1891 ifeq ($(strip $(%(modname)_LINKLIBFILES) $(%(modname)_LINKLIBAFILES) %(linklibfiles)),)
1894 BD_LINKLIB := $(BD_LIBDIR)/lib%(modname)$(BD_LIBSUFFIX).a
1895 ifneq (%(modname),%(linklibname))
1896 BD_LINKLIB += $(BD_LIBDIR)/lib%(linklibname)$(BD_LIBSUFFIX).a
1899 BD_LINKLIBFILES := $(BD_LINKLIBCFILES) $(BD_LINKLIBAFILES)
1901 BD_RELLINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_RELLINKLIBFILES))
1902 BD_RELLINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_RELLINKLIBAFILES))
1903 ifeq ($(strip $(%(modname)_RELLINKLIBFILES) $(%(modname)_RELLINKLIBAFILES) %(linklibfiles)),)
1906 BD_RELLINKLIB := $(BD_LIBDIR)/lib%(modname)_rel$(BD_LIBSUFFIX).a
1907 ifneq (%(modname),%(linklibname))
1908 BD_RELLINKLIB += $(BD_LIBDIR)/lib%(linklibname)_rel$(BD_LIBSUFFIX).a
1911 BD_RELLINKLIBFILES := $(BD_RELLINKLIBCFILES) $(BD_RELLINKLIBAFILES)
1914 BD_CCFILES := $(BD_NARCHFILES) %(linklibfiles)
1915 BD_TARGETCCFILES := $(BD_STARTFILES) $(BD_ENDFILES) $(BD_LINKLIBCFILES) \
1916 $(BD_RELLINKLIBCFILES)
1918 %rule_compile_cxx_multi \
1919 basenames=$(BD_CXXFILES) targetdir="%(objdir)" \
1920 cxxflags=$(BD_CXXFLAGS) dxxflags=$(BD_DXXFLAGS) \
1921 compiler="%(compiler)"
1922 %rule_compile_multi \
1923 basenames=$(BD_CCFILES) targetdir="%(objdir)" \
1924 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) \
1925 compiler="%(compiler)"
1926 %rule_compile_multi \
1927 basenames=$(BD_TARGETCCFILES) targetdir="%(objdir)" \
1928 cflags="$(BD_CFLAGS) -D__AROS__" dflags=$(BD_DFLAGS) \
1929 compiler="%(compiler)"
1931 ifneq ($(BD_LINKLIBAFILES),)
1932 %rule_assemble_multi \
1933 basenames="$(BD_LINKLIBAFILES) $(BD_RELLINKLIBAFILES)" targetdir="%(objdir)" suffix=.S
1938 ifeq (%(modsuffix),)
1939 BD_SUFFIX := %(modtype)
1941 BD_SUFFIX := %(modsuffix)
1944 ifeq (%(build_library),M)
1945 # Handlers use dash instead of dot in their names
1946 ifeq ($(BD_SUFFIX),handler)
1947 BD_MODULE := %(prefix)/%(moduledir)/%(modname)-$(BD_SUFFIX)
1949 BD_MODULE := %(prefix)/%(moduledir)/%(modname).$(BD_SUFFIX)
1951 BD_KOBJ := $(KOBJSDIR)/%(modname)_$(BD_SUFFIX).o
1957 %(mmake)-quick : %(mmake)
1958 %(mmake) : $(BD_MODULE) $(BD_LINKLIB) $(BD_RELLINKLIB)
1959 ifeq (%(build_library),M)
1960 %(mmake)-kobj : $(BD_KOBJ) $(BD_LINKLIB) $(BD_RELLINKLIB)
1961 %(mmake)-kobj-quick : $(BD_KOBJ) $(BD_LINKLIB) $(BD_RELLINKLIB)
1963 ifeq (%(build_abi),M)
1964 %(mmake)-linklib : $(BD_LINKLIB) $(BD_RELLINKLIB)
1967 BD_OBJS := $(addsuffix .o,$(BD_STARTFILES)) $(BD_ARCHOBJS) \
1968 $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES:=.o) $(BD_CXXFILES:=.o)))
1970 ifeq (%(nostartup),yes)
1971 # Handlers always have entry point
1972 ifneq (%(modtype),handler)
1973 BD_STARTOBJS := $(addsuffix .o,$(addprefix $(GENDIR)/,$(RESIDENT_BEGIN)))
1977 BD_ENDOBJS := $(addsuffix .o,$(BD_ENDFILES))
1978 BD_LINKLIBOBJS:= $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_LINKLIBFILES)) \
1981 := $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_RELLINKLIBFILES)) \
1984 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
1985 # This breaks con-handler build. Here we work around this
1986 ifeq (%(modname),con)
1987 BD_ERR := $(notdir $(BD_MODULE)).err
1989 BD_ERR := %(modname).err
1992 ifeq (%(build_library),M)
1993 # The module is linked from all the compiled .o files
1994 %rule_linkmodule module=$(BD_MODULE) objs="$(BD_STARTOBJS) $(BD_OBJS) $(USER_OBJS)" \
1995 endobj=$(BD_ENDOBJS) err=$(BD_ERR) objdir="%(objdir)" \
1996 cmd=$(BD_LINK) ldflags="$(LDFLAGS) $(%(modname)_LDFLAGS)" \
1997 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
2000 ifeq (%(build_abi),M)
2002 BD_LINKLIBNAME := $(shell echo %(linklibname) | tr A-Z a-z)
2003 BD_MODNAME := $(shell echo %(modname) | tr A-Z a-z)
2004 ifneq ($(BD_LINKLIB),)
2005 %rule_link_linklib libname="%(linklibname)$(BD_LIBSUFFIX)" objs=$(BD_LINKLIBOBJS) libdir="$(BD_LIBDIR)"
2006 ifneq ($(BD_MODNAME),$(BD_LINKLIBNAME))
2007 %rule_link_linklib libname="%(modname)$(BD_LIBSUFFIX)" objs=$(BD_LINKLIBOBJS) libdir="$(BD_LIBDIR)"
2010 $(BD_LINKLIB) : | $(BD_LIBDIR)
2011 GLOB_MKDIRS += $(BD_LIBDIR)
2014 ifneq ($(BD_RELLINKLIB),)
2015 %rule_link_linklib libname="%(linklibname)_rel$(BD_LIBSUFFIX)" objs=$(BD_RELLINKLIBOBJS) libdir="$(BD_LIBDIR)"
2016 ifneq ($(BD_MODNAME),$(BD_LINKLIBNAME))
2017 %rule_link_linklib libname="%(modname)_rel$(BD_LIBSUFFIX)" objs=$(BD_RELLINKLIBOBJS) libdir="$(BD_LIBDIR)"
2020 $(BD_RELLINKLIB) : | $(BD_LIBDIR)
2021 GLOB_MKDIRS += $(BD_LIBDIR)
2025 ifeq (%(build_library),M)
2026 # Link kernel object file
2027 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
2029 # Make these symbols local
2030 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
2031 UtilityBase ExpansionBase KeymapBase KernelBase
2033 BD_SYMBOLS := $(BD_KBASE)
2035 BD_KLIB := hiddstubs amiga arossupport autoinit libinit
2036 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
2037 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS) $(%(modname)_LIBS)
2038 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
2039 $(BD_KOBJ) : USER_LDFLAGS:=$(USER_LDFLAGS)
2040 $(BD_KOBJ) : $(BD_OBJS) $(USER_OBJS) $(BD_ENDOBJS)
2041 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
2042 @$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
2043 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
2046 ## Dependency fine-tuning
2048 BD_DEPS := $(addprefix %(objdir)/,$(notdir $(BD_CCFILES:=.d) $(BD_TARGETCCFILES:=.d) $(BD_CXXFILES:=.d)))
2050 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick" deps=$(BD_DEPS)
2052 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
2053 $(BD_MODULE) : | %(prefix)/%(moduledir)
2054 $(BD_KOBJ) : | $(KOBJSDIR)
2055 GLOB_MKDIRS += %(objdir) %(prefix)/%(moduledir) $(KOBJSDIR)
2057 # Some include files need to be generated before the .c can be parsed.
2058 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick),) # Only for this target these deps are wanted
2060 BD_DFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
2061 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES))
2062 $(BD_DEPS) : $(BD_DFILE_DEPS)
2065 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) \
2066 $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
2067 %(objdir)/Makefile.%(modname)%(modtype) \
2068 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
2069 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
2070 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
2071 %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
2072 $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
2073 $(BD_DEFLIBDEFSINC) $(addsuffix .c,$(BD_STARTFILES) $(BD_ENDFILES)) \
2075 %(mmake)-clean : FILES := $(BD_TOCLEAN)
2077 @$(ECHO) "Cleaning up for module %(modname)"
2080 endif # $(TARGET) in $(BD_ALLTARGETS)
2082 #------------------------------------------------------------------------------
2084 #------------------------------------------------------------------------------
2085 # Build a module - ABI and library
2086 # Explanation of this macro is done in the developer's manual
2087 %define build_module mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2088 files="$(basename $(call WILDCARD, *.c))" \
2089 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2090 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_DEFDXXFLAGS) \
2091 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
2092 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
2093 compiler=target nostartup=yes archspecific=no \
2096 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2097 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2098 files="%(files)" cxxfiles="%(cxxfiles)" \
2099 linklibname="%(linklibname)" \
2100 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2101 cflags="%(cflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2102 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2103 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" \
2104 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2105 includedir="%(includedir)" libdir="%(libdir)" \
2106 build_abi=M build_library=M
2109 #------------------------------------------------------------------------------
2112 #------------------------------------------------------------------------------
2113 # Build a module skeleton ABI
2114 # This is a stripped-down version of build_module, it only creates include
2115 # files and the linklibs.
2116 # This is used when for plugins or classes with the same API, but no actual
2117 # implementation here.
2118 %define build_module_abi mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2119 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_DEFDXXFLAGS) \
2120 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
2121 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
2122 compiler=target nostartup=yes archspecific=no \
2125 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2126 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2127 linklibname="%(linklibname)" \
2128 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2129 cflags="%(cflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2130 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2131 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" \
2132 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2133 includedir="%(includedir)" libdir="%(libdir)" \
2134 build_abi=M build_library=
2137 #------------------------------------------------------------------------------
2139 #------------------------------------------------------------------------------
2140 # Build a module library - no includes nor linklibs
2141 # Explanation of this macro is done in the developer's manual
2142 %define build_module_library mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2143 files="$(basename $(call WILDCARD, *.c))" \
2144 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2145 cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) cxxflags="$(CXXFLAGS)" dxxflags="$(BD_DEFDXXFLAGS)" \
2146 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
2147 uselibs= usehostlibs= \
2148 compiler=target nostartup=yes archspecific=no \
2151 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2152 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2153 files="%(files)" cxxfiles="%(cxxfiles)" \
2154 cflags="%(cflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2155 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2156 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" \
2157 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2158 includedir="%(includedir)" libdir="%(libdir)" \
2159 build_abi= build_library=M
2162 #------------------------------------------------------------------------------
2166 #------------------------------------------------------------------------------
2168 # - mmake is the mmaketarget
2169 # - libname is the baselibname e.g. lib%(libname).a will be created
2170 # - files are the C source files to include in the lib. The list of files
2171 # has to be given without the .c suffix
2172 # - cxxfiles are C++ source files without suffix.
2173 # NB: files will be matched in the order .cpp > .cxx > .cc
2174 # - asmfiles are the asm files to include in the lib. The list of files has to
2175 # be given without the .s suffix
2176 # - objs additional object to link into the linklib. The objects have to be
2177 # given with full absolute path and the .o suffix.
2178 # - objdir is where the .o are generated. Defaults to $(GENDIR)/$(CURDIR)
2179 # - libdir is the directory where the linklib will be placed (default $(AROS_LIB))
2180 # - cflags are the flags to compile the source (default $(CFLAGS))
2181 # - dflags are the flags use during makedepend (default equal to cflags)
2182 # - aflags are the flags use during assembling (default $(AFLAGS))
2183 # - libdir is the directory where the linklib will be placed (default $(AROS_LIB))
2184 %define build_linklib mmake=/A libname=/A files= cxxfiles= \
2185 asmfiles= objs= objdir=$(GENDIR)/$(CURDIR) libdir=$(AROS_LIB) \
2187 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_CXXFLAGS) \
2188 aflags=$(AFLAGS) compiler=target
2190 # assign and generate the local variables used in this macro
2191 BD_LIBNAME := %(libname)
2192 BD_LINKLIB := %(libdir)/lib%(libname).a
2194 BD_FILES := %(files)
2195 BD_ASMFILES := %(asmfiles)
2196 BD_CXXFILES := %(cxxfiles)
2198 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
2199 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
2200 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
2202 BD_OBJS := $(BD_ARCHOBJS) \
2203 $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES:=.o) $(BD_CXXFILES:=.o) $(BD_ASMFILES:=.o))) \
2205 BD_DEPS := $(patsubst %.o,%.d,$(BD_OBJS))
2207 BD_CFLAGS := %(cflags)
2208 BD_CXXFLAGS := %(cxxflags)
2209 ifneq (%(includedir),)
2210 BD_CFLAGS += -I%(includedir)
2211 BD_CXXFLAGS += -I%(includedir)
2213 BD_AFLAGS := %(aflags)
2214 BD_DFLAGS := %(dflags)
2215 BD_DXXFLAGS := %(dxxflags)
2217 .PHONY : %(mmake) %(mmake)-clean %(mmake)-quick
2220 %(mmake)-quick : %(mmake)
2222 #MM %(mmake) : includes-generate-deps
2223 %(mmake) : $(BD_LINKLIB)
2225 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
2227 %rule_compile_cxx_multi basenames=$(BD_CXXFILES) targetdir="%(objdir)" \
2228 compiler="%(compiler)" cxxflags=$(BD_CXXFLAGS) dxxflags=$(BD_DXXFLAGS)
2229 %rule_compile_multi basenames=$(BD_FILES) targetdir="%(objdir)" \
2230 compiler="%(compiler)" cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
2231 %rule_assemble basename=% targetdir="%(objdir)" \
2234 %rule_link_linklib libname="%(libname)" objs=$(BD_OBJS) libdir="%(libdir)" linker="%(compiler)"
2237 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
2239 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
2240 $(BD_LINKLIB) : | %(libdir)
2241 GLOB_MKDIRS += %(objdir) %(libdir)
2243 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_LINKLIB) $(BD_DEPS)
2246 @$(ECHO) "Cleaning up for metatarget %(mmake)"
2250 #------------------------------------------------------------------------------
2253 #------------------------------------------------------------------------------
2255 # - mmake is the mmaketarget
2256 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
2257 # - description is the catalog description file (.cd), without the .cd suffix (default *.cd)
2258 # - subdir is the destination subdirectory of the catalogs
2259 # - name is the name of the destination catalog, without the .catalog suffix
2260 # - source is the path to the generated source code file
2261 # - dir is the base destination directory (default $(AROS_CATALOGS))
2262 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
2263 # - srcdir is the directory in which the *.cd and *.ct files are searched
2265 %define build_catalogs mmake=/A name=/A subdir=/A \
2266 catalogs= source="../strings.h" description= dir=$(AROS_CATALOGS) \
2267 sourcedescription=$(TOOLDIR)/C_h_aros srcdir=$(SRCDIR)/$(CURDIR)
2269 ifeq (%(description),)
2270 BD_DESC := $(basename $(wildcard %(srcdir)/*.cd))
2272 BD_DESC := %(description)
2275 BD_SRC := $(shell echo %(sourcedescription) | sed 's/^\(.\):\//\/\1\//')
2278 BD_LNGS := $(basename $(notdir $(call WILDCARD, %(srcdir)/*.ct)))
2280 BD_LNGS := %(catalogs)
2283 BD_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, $(BD_LNGS)))
2284 BD_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, $(BD_LNGS))) $(dir %(source))
2287 %(mmake) : $(BD_OBJS) %(source)
2289 $(BD_OBJS) : | $(BD_DIRS)
2290 GLOB_MKDIRS += $(BD_DIRS)
2292 %(dir)/%/%(subdir)/%(name).catalog : %(srcdir)/%.ct $(BD_DESC).cd
2293 @$(ECHO) "Creating %(name) catalog for language $*."
2294 @$(FLEXCAT) $(BD_DESC).cd $< CATALOG="%(dir)/$*/%(subdir)/%(name).catalog" || [ $$? -lt 10 ]
2297 %(source) : BD_DESC := $(BD_DESC)
2298 %(source) : BD_SRC := $(BD_SRC)
2299 %(source) : $(BD_DESC).cd $(BD_SRC).sd | $(dir %(source))
2300 @$(ECHO) "Creating %(name) catalog source file $@"
2301 @$(FLEXCAT) $(BD_DESC).cd $@=$(BD_SRC).sd
2304 %(mmake)-clean : FILES := $(BD_OBJS) %(source)
2307 @$(ECHO) "Cleaning up for metatarget %(mmake)"
2310 .PHONY: %(mmake) %(mmake)-clean
2313 #-----------------------------------------------------------------------------
2316 #-----------------------------------------------------------------------------
2318 # - mmake is the mmaketarget
2319 # - icons is a list of icon base names (ie. without the .info suffix)
2320 # - dir is the destination directory
2321 # - srcdir is where *.png and *.info.src are searched
2322 #-----------------------------------------------------------------------------
2324 %define build_icons mmake=/A icons=/A dir=/A srcdir=$(SRCDIR)/$(CURDIR) image=
2326 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
2329 %(mmake) : $(BD_OBJS)
2333 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%.png
2334 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2335 @$(ILBMTOICON) $+ $@
2339 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%(image)
2340 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2341 @$(ILBMTOICON) $+ $@
2345 $(BD_OBJS) : | %(dir)
2346 GLOB_MKDIRS += %(dir)
2348 %(mmake)-clean : FILES := $(BD_OBJS)
2353 .PHONY: %(mmake) %(mmake)-clean
2356 #-----------------------------------------------------------------------------
2359 #------------------------------------------------------------------------------
2360 # Compile files for an arch-specific replacement of code for a module
2361 # - files: the basenames of the C files to compile.
2362 # - asmfiles: the basenames of the asm files to assemble.
2363 # - mainmmake: the mmake of the module in the main directory to compile these
2364 # arch specific files for.
2365 # - maindir: the object directory for the main module
2366 # - arch: the arch for which to compile these files. It can have the form
2367 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
2368 # - cflags (default $(CFLAGS)): the C flags to use for compilation
2369 # - dflags: the flags used during creation of dependency file. If not specified
2370 # the same value as cflags will be used
2371 # - aflags: the flags used during assembling
2372 # - compiler: (host, kernel or target) specifies which compiler to use. By default
2373 # the target compiler is used
2374 %define build_archspecific files= asmfiles= mainmmake=/A maindir=/A arch=/A \
2375 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
2377 ifeq (%(files) %(asmfiles),)
2378 $(error no files or asmfiles given)
2381 %buildid targets="%(mainmmake)-%(arch)"
2383 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2384 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2385 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2386 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2387 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2388 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2389 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2390 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2391 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2392 #MM- %(mainmmake)-kobj-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2393 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2394 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2395 #MM- %(mainmmake)-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2396 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2397 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2399 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
2401 BD_OBJDIR$(BDID) := $(GENDIR)/%(maindir)/arch
2402 BD_COBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
2403 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
2404 BD_OBJS$(BDID) := $(BD_COBJS$(BDID)) $(BD_ASMOBJS$(BDID))
2405 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
2407 ifneq (%(modulename),)
2408 BD_DEFLIBDEFSINC$(BDID) := -include $(GENDIR)/%(maindir)/include/%(modulename)_deflibdefs.h
2411 ifeq ($(TARGET),%(mainmmake)-%(arch)-quick)
2412 BD_TARGET := %(mainmmake)-%(arch)-quick
2414 BD_TARGET := %(mainmmake)-%(arch)
2418 ifeq ($(TARGET),$(BD_TARGET))
2419 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
2420 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(files)))
2421 vpath %.s $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2422 vpath %.S $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2425 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID))
2426 GLOB_MKDIRS += $(BD_OBJDIR$(BDID))
2429 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
2432 %(mainmmake)-%(arch)-quick :: $(BD_OBJS$(BDID))
2434 ifeq ($(findstring %(compiler),host kernel target),)
2435 $(error unknown compiler %(compiler))
2437 ifeq (%(compiler),target)
2438 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_CFLAGS)
2439 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
2440 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
2442 ifeq (%(compiler),host)
2443 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(HOST_CC)
2444 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
2445 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
2447 ifeq (%(compiler),kernel)
2448 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_CFLAGS)
2449 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
2450 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
2452 ifneq (%(modulename),)
2453 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) $(BD_DEFLIBDEFSINC$(BDID))
2455 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
2457 ifeq ($(TARGET),$(BD_TARGET))
2458 $(BD_OBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2459 %compile_q cmd=$(TMP_CMD) opt=$(TMP_CFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2463 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags) $(BD_DEFLIBDEFSINC$(BDID))
2465 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
2467 ifeq ($(TARGET),$(BD_TARGET))
2468 $(BD_OBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2469 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
2472 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
2474 ifeq ($(TARGET),$(BD_TARGET))
2475 $(BD_OBJDIR$(BDID))/%.o : %.s
2476 %assemble_q opt=$(AFLAGS)
2477 $(BD_OBJDIR$(BDID))/%.o : %.S
2478 %assemble_q opt=$(AFLAGS)
2481 %include_deps depstargets=$(BD_TARGET) deps=$(BD_DEPS$(BDID))
2483 #------------------------------------------------------------------------------
2486 #------------------------------------------------------------------------------
2487 # generate asm files from c files (for debugging purposes)
2490 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
2491 @$(TARGET_CC) $(TARGET_SYSROOT) -S $(CFLAGS) $(TARGET_CFLAGS) $< -c -o $@
2493 #------------------------------------------------------------------------------
2496 #------------------------------------------------------------------------------
2497 # Copy files from one directory to another.
2499 %define copy_files_q mmake=/A files=$(FILES) src=. dst=/A
2501 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
2503 GLOB_MKDIRS += %(dst)
2509 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC))/, $(file)) $(addprefix %(dst)/, $(file))))
2512 #------------------------------------------------------------------------------
2515 #------------------------------------------------------------------------------
2516 # Copy a directory recursively to another place, preserving the original
2517 # hierarchical structure
2519 # src: the source directory whose content will be copied.
2520 # dst: the directories where to copy src's content. If not existing, they will be made.
2521 # excludefiles: files which must not be copied. Path must be relative to src.
2523 %define copy_dir_recursive mmake=/A src=. dst=/A excludefiles=
2529 @cd $(SRCDIR)/$(CURDIR) && $(CPYDIRREC) -s %(src) -d %(dst) -e %(excludefiles)
2532 #------------------------------------------------------------------------------
2535 #------------------------------------------------------------------------------
2536 # Copy include files into the includes directories. There are currently
2537 # two include directories. One for building AROS $(AROS_INCLUDES) and one
2538 # for building tools that need to run on the host system $(GENINCDIR). The
2539 # $(GENINCDIR) path must not contain any references to the C runtime
2540 # library header files.
2542 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
2543 dir= compiler=target includedir=$(AROS_INCLUDES)
2545 ifeq ($(findstring %(compiler),host kernel target),)
2546 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
2551 $(eval TMP_DIRREMAIN := $$$(TMP_DIR))
2552 TMP_DIRFIRST := $(subst $(TMP_DIRREMAIN),,$(TMP_DIR))
2553 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),$(dir %(includes)))
2554 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,$(notdir %(includes)))
2555 ifeq ($(TMP_DIRFIRST),/)
2556 BD_INC_PATH := %(dir)/
2558 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
2561 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
2562 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
2565 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
2569 ifeq (%(compiler),target)
2572 BD_INCL_FILES2 := $(subst %(dir),%(includedir)/%(path),$(dir %(includes)))
2573 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,$(notdir %(includes)))
2575 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,%(includes))
2578 BD_INCL_FILES += $(BD_INCL_FILES2)
2580 $(BD_INCL_FILES2) : %(includedir)/%(path)/% : $(BD_INC_PATH)%
2585 %(mmake) : $(BD_INCL_FILES)
2589 $(BD_INCL_FILES) : | $(dir $(BD_INCL_FILES))
2590 GLOB_MKDIRS += $(dir $(BD_INCL_FILES))
2592 #------------------------------------------------------------------------------
2595 #------------------------------------------------------------------------------
2596 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
2597 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
2598 STUBS_MEM := $(addsuffix .o,$(STUBS))
2599 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
2600 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
2601 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
2603 #MM- linklibs : hidd-%(hidd)-stubs
2604 #MM- %(parenttarget): hidd-%(hidd)-stubs
2605 #MM hidd-%(hidd)-stubs : includes includes-copy
2606 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
2608 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
2611 $(STUBS_OBJ) : $(STUBS_SRC)
2612 %compile_q cmd="$(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_CFLAGS)" opt="%(cflags)" iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
2614 $(STUBS_DEP) : $(STUBS_SRC)
2615 %mkdepend_q flags="%(dflags)"
2618 %mkdirs_q $(OBJDIR) $(AROS_LIB)
2622 -@$(RM) $(HIDD_LIB) $(OBJDIR)
2624 DEPS := $(DEPS) $(STUBS_DEP)
2627 #------------------------------------------------------------------------------
2630 #------------------------------------------------------------------------------
2631 # Build an imported source tree which uses the configure script from the
2632 # autoconf package. This rule will try to "integrate" the produced files as
2633 # much as possible in the AROS build, for example by putting libraries in the
2634 # standard library directory, includes in the standard include directory, and
2635 # so on. You can however override this behaviour.
2637 # As a special "bonus" for you, the PROGDIR environment variable is defined to
2638 # be %(bindir) (or its deduced value) when running "make install", and
2639 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
2640 # configure script some more parameters whose value depends upon the PROGDIR
2641 # env var, so that the program gets all its stuff installed in the proper place
2642 # when building it, but when running it from inside AROS it can also find that
2643 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
2644 # the configuration parameters set when running ./configure
2646 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
2647 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
2648 # to the name which has to follow it.
2652 # - mmake = the meta make target.
2653 # - package = name of the package to be built.
2654 # - srcdir = the location of the unpacked source code. Defaults
2655 # to $(SRCDIR)/$(CURDIR).
2656 # - prefix = the target directory. Must be an absolute path of the
2657 # host system. Defaults to $(AROS_CONTRIB).
2658 # - aros_prefix = set a path which is valid within the AROS filesystem.
2659 # Defaults to the value of the prefix option.
2660 # - extraoptions = additional options for the configure script.
2661 # - extracflags = additional flags to use with the C compiler.
2662 # - extracxxflags = additional flags to use with the C++ compiler.
2663 # - nix_dir_layout = if yes the binary will be stored in a bin subdirectory.
2664 # Defaults to the value of the nix argument.
2665 # - nix = enable u*nix path handling, i.e. a path like
2666 # /progdir//./file will be translated to
2667 # progdir:file during run-time. Defaults to no.
2668 # - compiler = target, host or kernel. Defaults to target.
2669 # - install_target = the command used for installing. Defaults to install. Leave
2670 # it empty if you want to suppress installing.
2671 # - preconfigure = a metatarget which is executed before configure is called.
2672 # - postconfigure = a metatarget which is executed after configure is called.
2673 # - postinstall = a metatarget which is executed after installing.
2674 # - install_env = set additional options for installing.
2675 # - use_build_env = if yes the configuration environment is used for
2676 # installing, too. Defaults to no.
2678 # The arguments aros_prefix, nix and nix_dir_layout are related. The logic is
2682 # --prefix = $(aros_prefix)
2683 # progdir = $(aros_prefix)/bin
2686 # --prefix = /PROGDIR
2687 # --bindir = /PROGDIR
2688 # --sbindir = /PROGDIR
2690 # --includedir = /INCLUDE
2691 # --oldincludedir = /INCLUDE
2693 # --prefix = $(aros_prefix)
2696 # progdir = $(aros_prefix)
2699 # bindir = $(prefix)
2700 # sbindir = $(prefix)
2701 # libdir = $(AROS_LIB)
2702 # includedir = $(AROS_INCLUDES)
2703 # oldincludedir = $(AROS_INCLUDES)
2707 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) gendir= prefix= \
2708 aros_prefix= extraoptions= extracflags= extracxxflags= nix_dir_layout= nix=no compiler=target \
2709 install_target=install preconfigure= postconfigure= postinstall= \
2710 config_env_extra= install_env= use_build_env=no
2713 %(mmake)-prefix := %(prefix)
2715 %(mmake)-prefix := $(AROS_CONTRIB)
2718 ifneq (%(aros_prefix),)
2719 %(mmake)-aros_prefix := %(aros_prefix)
2721 %(mmake)-aros_prefix := $(%(mmake)-prefix)
2727 %(mmake)-nix := $(BD_NIXFLAG)
2728 %(mmake)-volpfx := /
2729 %(mmake)-volsfx := /
2731 ifeq (%(nix_dir_layout),)
2732 %(mmake)-nix_dir_layout := yes
2735 %(mmake)-volsfx := :
2737 ifeq (%(nix_dir_layout),)
2738 %(mmake)-nix_dir_layout := no
2742 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
2744 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
2745 exec_prefix=$(%(mmake)-prefix) %(install_env)
2747 # Check if chosen compiler is valid
2748 ifeq ($(findstring %(compiler),host target kernel),)
2749 $(error unknown compiler %(compiler))
2752 # Set legacy 'host' variable based on chosen compiler
2753 ifeq (%(compiler),host)
2756 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
2758 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
2763 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
2765 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
2770 %(mmake)-pkgdir := %(gendir)/$(CURDIR)
2772 %(mmake)-pkgdir := %(gendir)/$(CURDIR)/%(package)
2776 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
2777 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
2779 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
2780 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
2781 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2784 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
2785 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
2787 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2790 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
2792 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
2793 sbindir=$(%(mmake)-prefix) \
2794 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
2795 oldincludedir=$(AROS_INCLUDES) %(install_env)
2798 ifneq ($(DEBUG),yes)
2799 %(mmake)-s_flag = -s
2802 # Set up build environment, and options for configure script
2803 ifeq (%(compiler),host)
2804 CONFIG_ENV := %(config_env_extra) \
2806 CXXCPP="$(HOST_CPP)" \
2807 CC="$(HOST_DEF_CC)" \
2808 CFLAGS_FOR_BUILD="$(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include" \
2810 CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include" \
2811 LDFLAGS="-L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS)" \
2812 TARGET_CC="$(KERNEL_CC) $(KERNEL_SYSROOT)" \
2813 TARGET_CFLAGS="$(KERNEL_CFLAGS) $(%(mmake)-s_flag)" \
2814 TARGET_CXX="$(KERNEL_CXX) $(KERNEL_SYSROOT)" \
2815 TARGET_CXXFLAGS="$(KERNEL_CXXFLAGS) $(%(mmake)-s_flag)" \
2816 TARGET_AS="$(TARGET_AS)" \
2817 OBJCOPY="$(OBJCOPY)" \
2818 TARGET_RANLIB="$(RANLIB)" \
2819 TARGET_STRIP="$(STRIP_PLAIN)" \
2820 TARGET_NM="$(NM_PLAIN)" \
2821 TARGET_OBJCOPY="$(TARGET_OBJCOPY)"
2823 ifeq (%(compiler),target)
2824 CONFIG_ENV := %(config_env_extra) \
2825 PKG_CONFIG_LIBDIR="$(AROS_DEVELOPMENT)/lib/pkgconfig" \
2826 PKG_CONFIG_SYSROOT_DIR="$(AROSDIR)" \
2827 CPP="$(TARGET_CPP) $(TARGET_SYSROOT)" \
2828 CXXCPP="$(TARGET_CPP) $(TARGET_SYSROOT)" \
2829 CC="$(TARGET_CC) $(TARGET_SYSROOT)" \
2830 CFLAGS=" $(TARGET_CFLAGS) $(DEBUG_CFLAGS) $(OPTIMIZATION_CFLAGS) %(extracflags) $(ISA_FLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2831 CXX="$(TARGET_CXX) $(TARGET_SYSROOT)" \
2832 CXXFLAGS=" $(TARGET_CXXFLAGS) $(DEBUG_CFLAGS) $(OPTIMIZATION_CFLAGS) %(extracxxflags) $(ISA_FLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2833 LDFLAGS="-L$(AROS_DEVELOPMENT)/lib $(USER_LDFLAGS)" \
2835 CC_FOR_BUILD="$(HOST_DEF_CC)" \
2836 CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
2837 CXX_FOR_BUILD="$(HOST_CXX)" \
2838 CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
2839 RANLIB="$(RANLIB)" \
2841 STRIP="$(STRIP_PLAIN)" \
2842 TARGET_CC="$(KERNEL_CC) $(KERNEL_SYSROOT)" \
2843 TARGET_CFLAGS="$(KERNEL_CFLAGS) $(%(mmake)-s_flag)" \
2844 TARGET_CXX="$(KERNEL_CXX) $(KERNEL_SYSROOT)" \
2845 TARGET_CXXFLAGS="$(KERNEL_CXXFLAGS) $(%(mmake)-s_flag)" \
2846 TARGET_AS="$(TARGET_AS)" \
2847 OBJCOPY="$(OBJCOPY)" \
2848 TARGET_RANLIB="$(RANLIB)" \
2849 TARGET_STRIP="$(STRIP_PLAIN)"\
2850 TARGET_NM="$(NM_PLAIN)" \
2851 CC_FOR_TARGET="$(TARGET_CC) $(TARGET_SYSROOT)" \
2852 CFLAGS_FOR_TARGET="$(TARGET_CFLAGS) -L$(AROS_DEVELOPMENT)/lib %(extracflags) $(ISA_FLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2853 CXX_FOR_TARGET="$(TARGET_CXX) $(TARGET_SYSROOT)" \
2854 CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS) -L$(AROS_DEVELOPMENT)/lib %(extracxxflags) $(ISA_FLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)"
2855 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)\
2856 --host=$(AROS_TARGET_CPU)-aros\
2857 --target=$(AROS_TARGET_CPU)-aros\
2859 --without-x --without-pic --disable-shared
2861 ifeq (%(compiler),kernel)
2862 CONFIG_ENV := %(config_env_extra) \
2863 CPP="$(KERNEL_CPP)" \
2864 CXXCPP="$(KERNEL_CPP)" \
2865 CC="$(KERNEL_CC) $(KERNEL_SYSROOT)" \
2866 CFLAGS="$(KERNEL_CFLAGS) %(extracflags) $(%(mmake)-s_flag)" \
2867 CXX="$(KERNEL_CXX) $(KERNEL_SYSROOT)" \
2868 CXXFLAGS="$(KERNEL_CXXFLAGS) %(extracxxflags) $(%(mmake)-s_flag)" \
2870 CC_FOR_BUILD="$(HOST_DEF_CC)" \
2871 CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
2872 CXX_FOR_BUILD="$(HOST_CXX)" \
2873 CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
2874 RANLIB="$(RANLIB)" \
2875 TARGET_RANLIB="$(RANLIB)" \
2876 TARGET_STRIP="$(STRIP_PLAIN)" \
2877 TARGET_NM="$(NM_PLAIN)"
2878 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)\
2879 --host=$(AROS_TARGET_CPU)-aros\
2880 --target=$(AROS_TARGET_CPU)-aros --disable-nls\
2881 --without-x --without-pic --disable-shared
2884 ifeq (%(use_build_env),yes)
2885 BUILD_ENV := $(CONFIG_ENV)
2888 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
2890 # When building for the host, we don't need to build the
2891 # linklibs - this is especially true when building the
2892 # crosstool toolchain on 'foreign' architectures (such as
2893 # building PPC on x86)
2895 #MM- %(mmake)-host : setup includes %(mmake)-quick
2896 #MM- %(mmake)-target : setup includes core-linklibs %(mmake)-quick
2897 #MM- %(mmake): %(mmake)-%(compiler)
2899 # Using -j1 in install_command may result in a warning but finally
2900 # it does its job. make install for gcc does not work reliably for -jN
2902 ifneq (%(install_target),)
2903 %(mmake)-install_command = \
2904 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2905 -C $(%(mmake)-pkgdir) %(install_target) -j1
2907 %(mmake)-uninstall_command = \
2908 $(RM) $(%(mmake)-installflag) && \
2909 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" \
2910 $(%(mmake)-install_opts) -C $(%(mmake)-pkgdir) uninstall
2912 %(mmake)-install_command := true
2913 %(mmake)-uninstall_command := true
2916 #MM- %(mmake)-quick : %(preconfigure) %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
2919 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
2921 $(%(mmake)-installflag) : $(%(mmake)-configflag)
2922 if ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q -C $(%(mmake)-pkgdir); then \
2923 $(RM) $(%(mmake)-installflag) && \
2924 $(BUILD_ENV) $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)"\
2925 -C $(%(mmake)-pkgdir) && \
2926 $(%(mmake)-install_command) && \
2927 $(TOUCH) $@ -r $^; \
2930 $(%(mmake)-pkgdir)/.files-touched:
2931 %mkdirs_q $(%(mmake)-pkgdir)
2932 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/configure '{}' \; && \
2936 %(mmake)-uninstall :
2937 $(%(mmake)-uninstall_command)
2940 %(mmake)-configure : $(%(mmake)-configflag)
2942 $(%(mmake)-configflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
2943 $(%(mmake)-configflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2945 %mkdirs_q $(%(mmake)-pkgdir)
2946 cd $(%(mmake)-pkgdir) && \
2947 find . -name config.cache -exec $(RM) '{}' \; && \
2948 $(CONFIG_ENV) $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) \
2949 %(extraoptions) && \
2953 %(mmake)-clean : %(mmake)-uninstall
2954 @$(RM) $(%(mmake)-pkgdir)
2956 #------------------------------------------------------------------------------
2959 #------------------------------------------------------------------------------
2960 # Build an imported source tree which uses cmake
2964 # - mmake = the meta make target.
2965 # - package = name of the package to be built.
2966 # - srcdir = the location of the unpacked source code. Defaults
2967 # to $(SRCDIR)/$(CURDIR).
2968 # - prefix = the target directory. Must be an absolute path of the
2969 # host system. Defaults to $(AROS_CONTRIB).
2970 # - aros_prefix = set a path which is valid within the AROS filesystem.
2971 # Defaults to the value of the prefix option.
2972 # - extraoptions = additional options for the cmake script.
2973 # - installoptions = additional options for the install step.
2976 %define build_with_cmake mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) gendir= prefix= \
2977 aros_prefix= extraoptions= installoptions= maketarget= compiler=target \
2978 cflags=$(CFLAGS) cxxflags=$(CXXFLAGS) ldflags=$(LDFLAGS)
2981 %(mmake)-prefix := %(prefix)
2983 %(mmake)-prefix := $(AROS_CONTRIB)
2986 ifneq (%(aros_prefix),)
2987 %(mmake)-aros_prefix := %(aros_prefix)
2989 %(mmake)-aros_prefix := $(%(mmake)-prefix)
2992 ifeq (%(compiler),host)
2993 BD_LDFLAGS := -L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS)
2994 BD_CFLAGS := $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include
2995 BD_CXXFLAGS := $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include
2996 %(mmake)-cmake_opts := -DCMAKE_INSTALL_PREFIX=$(%(mmake)-prefix) -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(HOST_DEF_CC)" -DCMAKE_C_FLAGS="$(BD_CFLAGS)" -DCMAKE_CXX_COMPILER="$(HOST_CXX)" -DCMAKE_CXX_FLAGS="$(BD_CXXFLAGS)"
2998 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
3000 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
3003 BD_LDFLAGS := %(ldflags)
3004 BD_CFLAGS := %(cflags)
3005 BD_CXXFLAGS := %(cxxflags)
3006 %(mmake)-cmake_opts := -DCMAKE_TOOLCHAIN_FILE=$(GENDIR)/config/conf.cmake -DCMAKE_INSTALL_PREFIX=$(%(mmake)-prefix) -DCMAKE_C_FLAGS="$(BD_CFLAGS)" -DCMAKE_CXX_FLAGS="$(BD_CXXFLAGS)" -DCMAKE_EXE_LINKER_FLAGS="$(BD_LDFLAGS)"
3008 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
3010 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
3015 %(mmake)-pkgdir := %(gendir)/$(CURDIR)
3017 %(mmake)-pkgdir := %(gendir)/$(CURDIR)/%(package)
3021 %(mmake)-cmakeflag := $(%(mmake)-pkgdir)/.cmake
3022 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
3024 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3026 #MM- %(mmake): setup includes core-linklibs %(mmake)-quick
3028 #MM- %(mmake)-quick : %(mmake)-cmake %(mmake)-build_and_install-quick
3031 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3033 $(%(mmake)-installflag) : $(%(mmake)-cmakeflag)
3034 if ! $(MAKE) -q -C $(%(mmake)-pkgdir); then \
3035 $(RM) $(%(mmake)-installflag) && \
3036 $(MAKE) -C $(%(mmake)-pkgdir) %(maketarget) && \
3037 cd $(%(mmake)-pkgdir) && \
3038 cmake %(installoptions) -P cmake_install.cmake && \
3039 $(TOUCH) $@ -r $^; \
3042 $(%(mmake)-pkgdir)/.files-touched:
3043 %mkdirs_q $(%(mmake)-pkgdir)
3044 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/CMakeLists.txt '{}' \; && \
3048 %(mmake)-cmake : $(%(mmake)-cmakeflag)
3050 $(%(mmake)-cmakeflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
3051 $(%(mmake)-cmakeflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
3053 %mkdirs_q $(%(mmake)-pkgdir)
3054 cd $(%(mmake)-pkgdir) && \
3055 $(RM) -Rf CMakeCache.txt CMakeFiles \; && \
3056 cmake $(%(mmake)-cmake_opts) %(extraoptions) $(TMP_SRCDIR) && \
3060 %(mmake)-clean : %(mmake)-uninstall
3061 @$(RM) $(%(mmake)-pkgdir)
3063 #------------------------------------------------------------------------------
3066 #------------------------------------------------------------------------------
3067 # Given an archive name, patches names and locations where to find them, fetch
3068 # the archive and the patches from any of those locations, unpack the archive
3069 # and then apply the patches.
3071 # Locations currently supported are http and ftp sites, plus local filesystem
3072 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
3073 # the fetch.sh script needs to be modified, since this macro relies on that script.
3077 # - mmake = mmaketarget
3078 # - archive_origins = list of locations where to find the archive. They are tried
3079 # in sequence, until the archive is found and fetching it
3080 # succeeded. If not specified, the current directory is assumed.
3081 # - archive = the archive name. Mandatory.
3082 # - suffixes = a list of suffixes to append to the the package name plus the
3083 # version. Each one of them is tried until a matching archive is
3084 # found. They are appended to patches and these are tried the
3085 # same way as packages are.
3086 # - location = the local directory where to put the fetched archive and patches.
3087 # If not specified, the directory specified by destination is used.
3088 # - destination = the directory to unpack the archive to.
3089 # If not specified, the current directory is assumed.
3090 # - patches_origins = list of locations where to find the patches. They are tried
3091 # in sequence, until a patch is found and fetching it
3092 # succeeded. If not specified, the current directory is assumed.
3093 # - patches_specs = list of "patch specs". A patch spec is of the form
3094 # patch_name[:[patch_subdir][:patch_opt]].
3096 # - patch_name = the name of the patch file
3097 # - patch_subdir = the directory within \destination\ where to
3099 # - patch_opt = any options to pass to the `patch' command
3100 # when applying the patch.
3102 # The patch_subdir and patch_opt fields are optional.
3104 %define fetch mmake=/A archive_origins=. archive=/A suffixes= location= destination=. \
3105 patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
3109 ifneq (%(location),)
3110 %(mmake)-location := %(location)
3112 %(mmake)-location := %(destination)
3117 $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
3118 -d %(destination) -po "%(patches_origins)" -p "%(patches_specs)"
3120 #------------------------------------------------------------------------------
3123 #------------------------------------------------------------------------------
3124 # This macro can aid in patch creation for fetched ports. It temporarily creates another
3125 # unpatched source tree and runs diff against this and a previously fetched and possibly
3126 # patched tree. Depending on what happens after patching during a normal build it might
3127 # give best results if the new patch is created directly after fetch.
3131 # - mmake = mmaketarget
3132 # - archive = archive base name
3133 # - srcdir = the top level directory the package is unpacked to, useful if
3134 # an archive unpacks to a directory other than its name suggests.
3135 # this should not be deeper than a single path element.
3136 # - suffixes = a list of suffixes to append to the the package name plus the
3137 # version. Each one of them is tried until a matching archive is
3139 # - destination = the directory to unpack the archive to.
3140 # - excludes = diff patterns to exclude files or directories from the patch
3142 %define create_patch mmake=/A archive=/A srcdir= suffixes="tar.bz2 tar.gz" destination=/A excludes=
3146 ifneq (%(excludes),)
3147 %(mmake)-exclude := -X ./exclude.patterns
3151 %(mmake)-srcdir := %(srcdir)
3153 %(mmake)-srcdir := %(archive)
3156 #MM- %(mmake) : %(mmake)-diff
3157 #MM- %(mmake)-quick : %(mmake)-diff
3161 @$(FETCH) -a %(archive) -s "%(suffixes)" -l $(PORTSSOURCEDIR) -d %(destination)/tmp ; \
3162 $(MV) %(destination)/$(%(mmake)-srcdir) %(destination)/tmp/$(%(mmake)-srcdir).aros ; \
3163 cd %(destination)/tmp ; \
3164 $(FOR) f in %(excludes) ; do \
3165 $(ECHO) $$f >> ./exclude.patterns ; \
3167 diff -ruN $(%(mmake)-exclude) \
3168 $(%(mmake)-srcdir) \
3169 $(%(mmake)-srcdir).aros \
3170 >$(SRCDIR)/$(CURDIR)/%(archive)-aros-new.diff ; \
3171 $(MV) %(destination)/tmp/$(%(mmake)-srcdir).aros %(destination)/$(%(mmake)-srcdir) ; \
3172 $(RM) %(destination)/tmp
3174 #------------------------------------------------------------------------------
3177 #------------------------------------------------------------------------------
3178 # Joins the features of %fetch and %build_with_configure.
3180 # If a patch is provided, it *must* be named the following way:
3182 # <package name>-<version number>-aros.diff
3184 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3185 # CD'ing into the archive's extracted directory.
3187 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3188 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3189 # to make that patch fully comprehensive.
3193 # - mmake = the meta make target.
3194 # - package = the GNU package name, sans version and archive format suffixes.
3195 # - subpackage = ???
3196 # - compiler = same meaning as the one for the %build_with_configure macro.
3197 # - install_target = same meaning as the one for the %build_with_configure macro.
3198 # - version = the package's version number, or otherwise any other version string.
3199 # It gets appended to the package name to form the basename of the archive.
3200 # - suffixes = a list of suffixes to apped to the the package name plus the
3201 # version. Each one of them is tried until a matching archive is found.
3202 # Defaults to "tar.bz2 tar.gz".
3203 # - srcdir = the top level directory the package is unpacked to (see create_patch).
3204 # - builddir = override the location we expect to run configure/make in.
3205 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
3206 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
3207 # fetched or not. Default to no.
3208 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
3209 # - prefix = same meaning as the one for the %build_with_configure macro.
3210 # - aros_prefix = same meaning as the one for the %build_with_configure macro.
3211 # - extraoptions = same meaning as the one for the %build_with_configure macro.
3212 # - extracflags = same meaning as the one for the %build_with_configure macro.
3213 # - extracxxflags = same meaning as the one for the %build_with_configure macro.
3214 # - preconfigure = same meaning as the one for the %build_with_configure macro.
3215 # - postconfigure = same meaning as the one for the %build_with_configure macro.
3216 # - postinstall = same meaning as the one for the %build_with_configure macro.
3217 # - install_env = same meaning as the one for the %build_with_configure macro.
3218 # - use_build_env = same meaning as the one for the %build_with_configure macro.
3219 # - nix = same meaning as the one for the %build_with_configure macro.
3220 # - nix_dir_layout = same meaning as the one for the %build_with_configure macro.
3221 # - create_pkg = create a distributable package of the compiled sources, defaults to no
3223 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target install_target=install \
3224 version=/A suffixes="tar.bz2 tar.gz" srcdir= builddir= gendir= package_repo= patch=no patch_repo= \
3225 prefix= aros_prefix= extraoptions= extracflags= extracxxflags= preconfigure= postconfigure= postinstall= \
3226 config_env_extra= install_env= use_build_env=no nix=no nix_dir_layout= create_pkg=no
3228 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
3229 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
3230 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
3231 #MM- %(mmake)-create-patch : %(mmake)-%(subpackage)-create-patch
3233 %(mmake)-archbase := %(package)-%(version)
3235 ifeq (%(compiler),host)
3236 %(mmake)-portdir := $(HOSTDIR)/Ports/host/%(package)
3238 %(mmake)-portdir := $(PORTSDIR)/%(package)
3242 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
3244 %(mmake)-prefix := %(prefix)
3247 ifneq (%(subpackage),)
3248 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
3250 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
3254 %(mmake)-%(subpackage)-srcdir := %(srcdir)
3256 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
3259 ifneq (%(builddir),)
3260 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)/%(builddir)
3262 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)
3266 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-f,-p1
3268 %(mmake)-%(subpackage)-patches_specs := ::
3271 %fetch mmake="%(mmake)-%(subpackage)-fetch" archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
3272 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
3273 archive_origins=". %(package_repo)" \
3274 patches_specs=$(%(mmake)-%(subpackage)-patches_specs) patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
3276 %create_patch mmake="%(mmake)-%(subpackage)-create-patch" \
3277 archive=$(%(mmake)-%(subpackage)-archbase) \
3278 srcdir=$(%(mmake)-%(subpackage)-srcdir) \
3279 suffixes="%(suffixes)" \
3280 destination=$(%(mmake)-portdir)
3282 #MM- %(mmake) : %(mmake)-%(subpackage)
3284 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
3286 %(mmake)-%(subpackage)-package-basename := \
3287 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
3289 ifneq (%(create_pkg),no)
3290 %(mmake)-%(subpackage)-package := $(%(mmake)-%(subpackage)-package-basename).tar.bz2
3293 %build_with_configure mmake="%(mmake)-%(subpackage)" package="%(package)" compiler="%(compiler)" install_target="%(install_target)" \
3294 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-builddir) gendir="%(gendir)" \
3295 config_env_extra="%(config_env_extra)" install_env="%(install_env)" use_build_env="%(use_build_env)" \
3296 nix="%(nix)" nix_dir_layout="%(nix_dir_layout)" prefix=$(%(mmake)-prefix) \
3297 aros_prefix="%(aros_prefix)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
3298 %(mmake)-%(subpackage)-make-package" extraoptions="%(extraoptions)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)"
3300 .PHONY : %(mmake)-%(subpackage)-make-package %(mmake)-%(subpackage)-create-patch
3301 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
3304 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package)
3306 #There seems to be a bug, either with my clock or with make, 'cause it may happen
3307 #that $^ and $@ have exactly the same mtime, and in that case make tries
3308 #to rebuild $@ again, which would fail because the directory where
3309 #the package got installed would not exist anymore.
3310 #We work this around by using an if statement to manually check the mtimes.
3311 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
3312 @$(IF) test $(%(mmake)-installflag) -nt $@ || ! test -f $@; then \
3314 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
3315 mkdir -p "$(DISTDIR)/Packages" ; \
3316 mkdir -p "$(%(mmake)-prefix)" ; \
3317 cd $(%(mmake)-%(subpackage)-package-dir) ; \
3318 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
3319 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
3322 #------------------------------------------------------------------------------
3325 #------------------------------------------------------------------------------
3326 # Joins the features of %fetch and %build_with_configure, taking advantage of
3327 # the naming scheme of GNU packages. GNU packages names are in the form
3329 # <package name>-<version number>.<archive format suffix>
3331 # If a patch is provided, it *must* be named the following way:
3333 # <package name>-<version number>-aros.diff
3335 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3336 # CD'ing into the archive's extracted directory.
3338 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3339 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3340 # to make that patch fully comprehensive.
3342 # NOTE: GNU packages are always compiled with *nix semantics turned on.
3346 # Arguments have the same meaning as the one for the %fetch_and_build macro, except:
3348 # - prefix = defaults to $(GNUDIR).
3349 # - aros_prefix = defaults to /GNU.
3351 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
3352 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
3353 aros_prefix=/GNU extraoptions= extracflags= extracxxflags= config_env_extra= preconfigure= postconfigure= postinstall=
3355 GNU_REPOSITORY := gnu://
3357 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
3358 suffixes="%(suffixes)" srcdir="%(srcdir)" \
3359 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
3360 patch="%(patch)" patch_repo="%(patch_repo)" \
3361 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)" \
3362 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=yes
3365 #------------------------------------------------------------------------------
3368 #------------------------------------------------------------------------------
3369 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
3370 # that the package is a "Development" package, and as such it needs to be placed
3371 # under the $(AROS_DEVELOPMENT) directory, as a default.
3373 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
3374 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
3375 # "mmake" argument, because the metatarget is implicitely defined as
3377 # #MM- development-%(package)
3379 %define fetch_and_build_gnu_development package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
3380 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPMENT) \
3381 aros_prefix=/Development config_env_extra= preconfigure= postconfigure= postinstall= extraoptions= extracflags= extracxxflags=
3383 #MM- development : development-%(package)
3386 %fetch_and_build_gnu mmake="development-%(package)" package="%(package)" subpackage="%(subpackage)" \
3387 version="%(version)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
3388 package_repo="%(package_repo)" patch="%(patch)" patch_repo="%(patch_repo)" prefix="%(prefix)" \
3389 aros_prefix="%(aros_prefix)" config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="postinstall-%(package)-delete-la-files %(postinstall)" \
3390 extraoptions="%(extraoptions)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)"
3393 postinstall-%(package)-delete-la-files:
3394 $(RM) $(AROS_DEVELOPMENT)/lib/*.la
3397 #------------------------------------------------------------------------------
3399 # Builds a kickstart package in PKG format
3403 # - mmake = target name
3404 # - file = destination file name with path
3406 # Other arguments are self-explanatory
3408 %define make_package mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
3409 arch_classes= arch_devs= arch_handlers= arch_hidds= arch_libs= arch_res=
3411 PKG_CLASSES := $(addprefix $(AROS_CLASSES)/,$(addsuffix .class, %(classes)))
3412 PKG_DEVICES := $(addprefix $(AROS_DEVS)/,$(addsuffix .device, %(devs)))
3413 PKG_HANDLERS := $(addprefix $(AROS_FS)/,$(addsuffix -handler, %(handlers)))
3414 PKG_HIDD := $(addprefix $(AROS_DEVS)/Drivers/,$(addsuffix .hidd, %(hidds)))
3415 PKG_LIBS := $(addprefix $(AROS_LIBRARIES)/,$(addsuffix .library, %(libs)))
3416 PKG_RESOURCES := $(addprefix $(AROS_DEVS)/,$(addsuffix .resource, %(res)))
3418 PKG_CLASSES_ARCH := $(addprefix $(AROS_CLASSES_ARCH)/,$(addsuffix .class, %(arch_classes)))
3419 PKG_DEVICES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .device, %(arch_devs)))
3420 PKG_HANDLERS_ARCH := $(addprefix $(AROS_FS_ARCH)/,$(addsuffix -handler, %(arch_handlers)))
3421 PKG_HIDD_ARCH := $(addprefix $(AROS_DEVS_ARCH)/Drivers/,$(addsuffix .hidd, %(arch_hidds)))
3422 PKG_LIBRARIES_ARCH := $(addprefix $(AROS_LIBRARIES_ARCH)/,$(addsuffix .library, %(arch_libs)))
3423 PKG_RESOURCES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .resource, %(arch_res)))
3425 PKG_FILES := $(PKG_CLASSES) $(PKG_DEVICES) $(PKG_HANDLERS) $(PKG_HIDD) $(PKG_LIBS) $(PKG_RESOURCES) \
3426 $(PKG_CLASSES_ARCH) $(PKG_DEVICES_ARCH) $(PKG_HANDLERS_ARCH) $(PKG_HIDD_ARCH) $(PKG_LIBRARIES_ARCH) $(PKG_RESOURCES_ARCH)
3427 PKG_DIR := $(dir %(file))
3433 %(mmake)-quick : %(file)
3435 %(file): $(PKG_FILES) | $(PKG_DIR)
3436 @$(ECHO) Packaging $@...
3437 @$(SRCDIR)/tools/package/pkg c $@ $^
3439 %compress_file mmake="%(mmake)" file="%(file)"
3441 GLOB_MKDIRS += $(PKG_DIR)
3445 #------------------------------------------------------------------------------
3446 # Compresses %(file) with a gzip.
3447 # Good in conjunction with for example %build_prog
3449 %define compress_file mmake=/A file=/A
3451 #MM- %(mmake)-gz : %(mmake) %(mmake)-gz-quick
3454 %(mmake)-gz-quick : %(file).gz
3457 @$(ECHO) Compressing $(subst $(TARGETDIR)/,,$^)...
3462 #------------------------------------------------------------------------------
3463 # Links a kickstart module in ELF format
3464 # Arguments are similar to make_package
3466 %define link_kickstart mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
3467 startup= uselibs= ldflags=$(LDFLAGS) map= deps=
3469 KOBJ_CLASSES := $(addprefix $(KOBJSDIR)/, $(addsuffix _class.o, %(classes)))
3470 KOBJ_DEVICES := $(addprefix $(KOBJSDIR)/, $(addsuffix _device.o, %(devs)))
3471 KOBJ_HANDLERS := $(addprefix $(KOBJSDIR)/, $(addsuffix _handler.o, %(handlers)))
3472 KOBJ_HIDD := $(addprefix $(KOBJSDIR)/, $(addsuffix _hidd.o, %(hidds)))
3473 KOBJ_LIBS := $(addprefix $(KOBJSDIR)/, $(addsuffix _library.o, %(libs)))
3474 KOBJ_RES := $(addprefix $(KOBJSDIR)/, $(addsuffix _resource.o, %(res)))
3477 KOBJ_STARTUP := $(GENDIR)/$(RESIDENT_BEGIN).o
3479 KOBJ_STARTUP := %(startup)
3482 KOBJS := $(KOBJ_STARTUP) $(KOBJ_CLASSES) $(KOBJ_HANDLERS) $(KOBJ_LIBS) $(KOBJ_DEVICES) $(KOBJ_HIDD) $(KOBJ_RES)
3484 TMP_LDFLAGS := %(ldflags)
3486 # Make a list of the lib files this program depends on.
3487 # In LDFLAGS remove white space between -L and directory
3488 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
3489 # Filter out only the libdirs and remove -L
3490 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
3492 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
3493 # Add normal linklib path
3494 TMP_DIRS += $(AROS_LIB)/
3495 # add lib and .a to static linklib names
3496 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
3497 # search for the linklibs in the given path, ignore ones not found
3498 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
3499 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
3502 TMP_DIRS += $(dir %(file))
3504 TMP_LDFLAGS += $(GENMAP) %(map)
3505 TMP_DIRS += $(dir %(map))
3508 #MM %(mmake) : %(deps)
3514 %(mmake)-quick : %(file)
3516 %(file): KOBJS := $(KOBJS)
3517 %(file): LDFLAGS := $(TMP_LDFLAGS) $(NOSTARTUP_LDFLAGS) \
3518 -static -nosysbase -Wl,-Ur
3519 %(file): LDLIBS := $(addprefix -l, %(uselibs))
3520 %(file): $(KOBJS) $(DEPLIBS) | $(TMP_DIRS)
3521 @$(ECHO) "Kickstart $(subst $(TARGETDIR)/,,$@)..."
3522 @$(TARGET_CC) $(TARGET_SYSROOT) -o $@ $(KOBJS) $(LDFLAGS) $(LDLIBS)
3525 %compress_file mmake="%(mmake)" file="%(file)"
3527 GLOB_MKDIRS += $(TMP_DIRS)