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 BD_ASSEMBLER ?= $(TARGET_CC) $(TARGET_SYSROOT)
588 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TARGET_CC) $(TARGET_SYSROOT)
589 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_CFLAGS:=$(TARGET_CFLAGS) $(TMP_CFLAGS)
590 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_DFLAGS:=$(TARGET_CFLAGS) $(TMP_DFLAGS)
591 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
592 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
594 ifeq (%(compiler),host)
595 BD_LINK ?= $(HOST_CC) $(HOST_LDFLAGS)
596 BD_STRIP ?= $(HOST_STRIP)
597 BD_ASSEMBLER ?= $HOST_CC) $(HOST_SYSROOT)
598 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_CC)
599 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_CFLAGS:=$(HOST_CFLAGS) $(TMP_CFLAGS)
600 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_DFLAGS:=$(HOST_CFLAGS) $(TMP_DFLAGS)
601 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
602 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
604 ifeq (%(compiler),kernel)
605 BD_LINK ?= $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
606 BD_STRIP ?= $(ECHO) >/dev/null
607 BD_ASSEMBLER ?= $(KERNEL_CC) $(KERNEL_SYSROOT)
608 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
609 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_CFLAGS:=$(KERNEL_CFLAGS) $(TMP_CFLAGS)
610 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_DFLAGS:=$(KERNEL_CFLAGS) $(TMP_DFLAGS)
611 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
612 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
615 $(TMP_TARGETS) : CFLAGS := %(TMP_CFLAGS)
616 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.c
617 %compile_q cmd=$(CMD) opt=$(TMP_CFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
619 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.c
620 %mkdepend_q cc=$(CMD) flags=$(TMP_DFLAGS)
622 #------------------------------------------------------------------------------
625 #------------------------------------------------------------------------------
626 # Generate a rule to compile multiple C++ source files to an object file and
627 # generate the corresponding dependency files. The generated file will be put
628 # in the object directory without the directory part of the source file.
630 # - basenames: the basenames of the files to compile. The names may include
631 # relative or absolute path names. No wildcard is allowed. basenames will be
632 # matched to supported AROS_CXXEXTS.
633 # - cflags (default $(CFLAGS)): the C flags to use for compilation
634 # - dflags: the flags used during creation of dependency file. If not specified
635 # the same value as cflags will be used
636 # - targetdir: the directory to put the .o file and the .d file. By default
637 # it is put in the same directory as the .c file. When targetdir is not
638 # empty, path names will be stripped from the file names so that all files
639 # are in that dir and not in subdirectories.
640 # - compiler (default target): compiler to use, target, kernel or host
641 %define rule_compile_cxx_multi basenames=/A cxxflags=$(CXXFLAGS) dxxflags= \
642 targetdir= compiler=target
644 TMP_CXXABSBASENAMES := $(foreach TMP_CXXBASE,%(basenames),$(if $(filter /%,$(TMP_CXXBASE)),$(TMP_CXXBASE),$(abspath $(SRCDIR)/$(CURDIR)/$(TMP_CXXBASE))))
646 ifneq ($(TMP_CXXABSBASENAMES),)
648 TMP_CXXBASENAMES := $(basename $(TMP_CXXABSBASENAMES))
650 # Identify the "real" c++ files from the passed in basenames
651 TMP_CXXFILES := $(strip $(foreach TMP_CXXBASE,$(TMP_CXXABSBASENAMES), $(firstword $(wildcard $(foreach TMP_EXT, $(AROS_CXXEXTS),$(addsuffix .$(TMP_EXT),$(TMP_CXXBASE)))))))
654 TMP_CXXTARGETS := $(notdir $(TMP_CXXBASENAMES:=.o))
655 TMP_CXXDTARGETS := $(notdir $(TMP_CXXBASENAMES:=.d))
658 TMP_CXXTARGETS := $(addprefix %(targetdir)/,$(notdir $(TMP_CXXBASENAMES:=.o)))
659 TMP_CXXDTARGETS := $(addprefix %(targetdir)/,$(notdir $(TMP_CXXBASENAMES:=.d)))
660 TMP_WILDCARD := %(targetdir)/%
662 # Be sure that all source files are generated
663 $(TMP_CXXTARGETS) $(TMP_CXXDTARGETS) : | $(TMP_CXXFILES)
666 # Adjust compiler flags to suit C++
667 TMP_CXXFLAGS := %(cxxflags)
669 TMP_DXXFLAGS := %(cxxflags)
671 TMP_DXXFLAGS := %(dxxflags)
674 ifeq ($(findstring %(compiler),host kernel target),)
675 $(error unknown compiler %(compiler))
677 ifeq (%(compiler),host)
678 BD_LINK ?= $(HOST_CXX) $(HOST_LDFLAGS)
679 BD_STRIP ?= $(HOST_STRIP)
680 BD_ASSEMBLER ?= $(HOST_CC) $(HOST_SYSROOT)
681 TMP_CXXCMD:=$(HOST_CXX)
682 TMP_CXXFLAGS := $(HOST_CXXFLAGS) $(TMP_CXXFLAGS)
683 TMP_DXXFLAGS := $(HOST_CXXFLAGS) $(TMP_DXXFLAGS)
684 TMP_CXXIQUOTE:=$(HOST_IQUOTE)
685 TMP_CXXIQUOTE_END:=$(HOST_IQUOTE_END)
687 ifeq (%(compiler),target)
688 BD_LINK ?= $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
689 BD_STRIP ?= $(TARGET_STRIP)
690 BD_ASSEMBLER ?= $(TARGET_CC) $(TARGET_SYSROOT)
691 TMP_CXXCMD:=$(AROS_CXX) $(TARGET_SYSROOT)
692 TMP_CXXFLAGS := $(TARGET_CXXFLAGS) $(TMP_CXXFLAGS)
693 TMP_DXXFLAGS := $(TARGET_CXXFLAGS) $(TMP_DXXFLAGS)
694 TMP_CXXIQUOTE:=$(CFLAGS_IQUOTE)
695 TMP_CXXIQUOTE_END:=$(CFLAGS_IQUOTE_END)
697 ifeq (%(compiler),kernel)
698 KERNEL_CXX ?= $(KERNEL_CC)
699 BD_LINK ?= $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
700 BD_STRIP ?= $(ECHO) >/dev/null
701 BD_ASSEMBLER ?= $(KERNEL_CC) $(KERNEL_SYSROOT)
702 TMP_CXXCMD:=$(KERNEL_CXX) $(KERNEL_SYSROOT)
703 TMP_CXXFLAGS := $(KERNEL_CXXFLAGS) $(TMP_CXXFLAGS)
704 TMP_DXXFLAGS := $(KERNEL_CXXFLAGS) $(TMP_DXXFLAGS)
705 TMP_CXXIQUOTE:=$(KERNEL_IQUOTE)
706 TMP_CXXIQUOTE_END:=$(KERNEL_IQUOTE_END)
709 define cxx_multi_recipe_template
711 %compile_q cmd=$(TMP_CXXCMD) opt=$(TMP_CXXFLAGS) iquote=$(TMP_CXXIQUOTE) iquote_end=$(TMP_CXXIQUOTE_END) from=$(2) to=$(1).o
714 %mkdepend_q cc=$(TMP_CXXCMD) flags=$(TMP_DXXFLAGS) from=$(2) to=$(1).d
717 $(foreach TMP_CXXFILE,$(TMP_CXXFILES),$(eval $(call cxx_multi_recipe_template,$(notdir $(basename $(TMP_CXXFILE))),$(TMP_CXXFILE))))
719 $(foreach TMP_CXXFILE,$(TMP_CXXFILES),$(eval $(call cxx_multi_recipe_template,$(addprefix %(targetdir)/,$(notdir $(basename $(TMP_CXXFILE)))),$(TMP_CXXFILE))))
725 #------------------------------------------------------------------------------
728 #------------------------------------------------------------------------------
729 # Generate a rule to compile multiple ObjC source files to an object file and
730 # generate the corresponding dependency files. The generated file will be put
731 # in the object directory without the directory part of the source file.
733 # - basenames: the basenames of the files to compile. The names may include
734 # relative or absolute path names. No wildcard is allowed
735 # - cflags (default $(CFLAGS)): the C flags to use for compilation
736 # - dflags: the flags used during creation of dependency file. If not specified
737 # the same value as cflags will be used
738 # - targetdir: the directory to put the .o file and the .d file. By default
739 # it is put in the same directory as the .m file. When targetdir is not
740 # empty, path names will be stripped from the file names so that all files
741 # are in that dir and not in subdirectories.
742 # - compiler (default target): compiler to use, target, kernel or host
743 %define rule_compile_objc_multi basenames=/A cflags=$(CFLAGS) dflags= \
744 targetdir= compiler=target
746 ifneq (%(basenames),)
749 TMP_TARGETS := $(addsuffix .o,%(basenames))
750 TMP_DTARGETS := $(addsuffix .d,%(basenames))
753 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,%(basenames)))
754 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,%(basenames)))
755 TMP_WILDCARD := %(targetdir)/%
757 # Be sure that all .m files are generated
758 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .m,%(basenames))
760 # Be sure that all .m files are found
761 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
762 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
763 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
765 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
766 vpath %.m $(TMP_DIRS)
770 # Define the use of cross compiler
771 ifeq ($(TARGET_OBJC),)
772 TMP_CC := $(TARGET_CC)
774 TMP_CC := $(TARGET_OBJC)
777 # Adjust compiler flags to suit ObjC
778 TMP_OBJCFLAGS := %(cflags)
779 TMP_OBJCFLAGS := $(TMP_OBJCFLAGS) -isystem $(AROS_DEVELOPMENT)/include
780 TMP_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(TMP_OBJCFLAGS)))
782 TMP_OBJCDFLAGS := %(cflags)
784 TMP_OBJCDFLAGS := %(dflags)
787 ifeq ($(findstring %(compiler),host kernel target),)
788 $(error unknown compiler %(compiler))
790 ifeq (%(compiler),target)
791 BD_LINK ?= $(TMP_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
792 BD_STRIP ?= $(TARGET_STRIP)
793 BD_ASSEMBLER ?= $(TARGET_CC) $(TARGET_SYSROOT)
794 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TMP_CC) $(TARGET_SYSROOT)
795 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCFLAGS:=$(TARGET_CFLAGS) $(TMP_OBJCFLAGS)
796 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCDFLAGS:=$(TARGET_CFLAGS) $(TMP_OBJCDFLAGS)
797 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
798 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
800 ifeq (%(compiler),host)
801 BD_LINK ?= $(HOST_OBJC) $(HOST_LDFLAGS)
802 BD_STRIP ?= $(HOST_STRIP)
803 BD_ASSEMBLER ?= $(HOST_CC) $(HOST_SYSROOT)
804 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_OBJC)
805 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCFLAGS:=$(HOST_CFLAGS) $(TMP_OBJCFLAGS)
806 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCDFLAGS:=$(HOST_CFLAGS) $(TMP_OBJCDFLAGS)
807 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
808 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
810 ifeq (%(compiler),kernel)
811 KERNEL_OBJC ?= $(KERNEL_CC)
812 BD_LINK ?= $(KERNEL_OBJC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
813 BD_STRIP ?= $(ECHO) >/dev/null
814 BD_ASSEMBLER ?= $(KERNEL_CC) $(KERNEL_SYSROOT)
815 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_OBJC) $(KERNEL_SYSROOT)
816 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCFLAGS:=$(KERNEL_CFLAGS) $(TMP_OBJCFLAGS)
817 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCDFLAGS:=$(KERNEL_CFLAGS) $(TMP_OBJCDFLAGS)
818 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
819 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
822 $(TMP_TARGETS) : CFLAGS := $(TMP_OBJCFLAGS)
823 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.m
824 %compile_q cmd=$(CMD) opt=$(TMP_OBJCFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
826 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.m
827 %mkdepend_q cc=$(CMD) flags=$(DFLAGS)
832 #------------------------------------------------------------------------------
835 #------------------------------------------------------------------------------
836 # Make an alias from one arch specific build to another arch.
838 # - mainmmake: the mmake of the module in the main tree
839 # - arch: the current arch
840 # - alias: the alias to which this should point
841 %define rule_archalias mainmmake=\A arch=\A alias=\A
843 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
845 #------------------------------------------------------------------------------
848 #------------------------------------------------------------------------------
849 # Generate a rule to assemble a source file to an object file. Basename may
850 # contain a directory part, then the source file has to be in that directory.
851 # The generated file will be put in the object directory without the directory.
853 # - basename: the basename of the file to compile. Use % for a wildcard rule
854 # - flags (default $(AFLAGS)): the asm flags to use for assembling
855 # - targetdir: the directory to put the .o file in. By default it is put in the
856 # same directory as the .s file
857 %define rule_assemble basename=/A aflags=$(AFLAGS) targetdir=
860 %(basename).o : AFLAGS := %(aflags)
861 %(basename).o : %(basename).s
863 %(basename).o : %(basename).S
867 %(targetdir)/$(notdir %(basename)).o : AFLAGS := %(aflags)
868 %(targetdir)/$(notdir %(basename)).o : %(basename).s
870 %(targetdir)/$(notdir %(basename)).o : %(basename).S
875 #------------------------------------------------------------------------------
878 #------------------------------------------------------------------------------
879 # Generate a rule to assemble multiple source files to an object file. The
880 # generated file will be put in the object directory with the directory part
881 # of the source file stripped off.
883 # - basenames: the basenames of the files to compile. The names may include
884 # relative or absolute path names. No wildcard is allowed
885 # - aflags (default $(AFLAGS)): the flags to use for assembly
886 # - targetdir: the directory to put the .o file and the .d file. By default
887 # it is put in the same directory as the .c file. When targetdir is not
888 # empty, path names will be stripped from the file names so that all files
889 # are in that dir and not in subdirectories.
890 %define rule_assemble_multi cmd=$(BD_ASSEMBLER) basenames=/A aflags=$(AFLAGS) targetdir= suffix=.s
893 TMP_TARGETS := $(addsuffix .o,%(basenames))
896 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
897 TMP_WILDCARD := %(targetdir)/%
899 # Be sure that all .s files are generated
900 $(TMP_TARGETS) : | $(addsuffix %(suffix),%(basenames))
902 # Be sure that all .c files are found
903 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
904 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
905 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
907 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
908 vpath %%(suffix) $(TMP_DIRS)
913 $(TMP_TARGETS) : TMP_CMD:=%(cmd)
915 $(TMP_TARGETS) : AFLAGS := %(aflags)
916 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %%(suffix)
917 %assemble_q cmd=$(TMP_CMD) opt=$(AFLAGS)
919 #------------------------------------------------------------------------------
922 #------------------------------------------------------------------------------
923 # Link %(objs) to %(prog) using the libraries in %(uselibs)
924 %define rule_link_prog prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
925 usehostlibs= usestartup=yes detach=no nix=no cmd="$(AROS_CC) $(TARGET_SYSROOT)" strip=$(TARGET_STRIP)
930 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
932 ifeq (%(usestartup),no)
933 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
936 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
939 # Make a list of the lib files this program depends on.
940 # In LDFLAGS remove white space between -L and directory
941 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
942 # Filter out only the libdirs and remove -L
943 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
945 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
946 # Add normal linklib path
947 TMP_DIRS += $(AROS_LIB)/
948 # add lib and .a to static linklib names
949 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(TMP_EXTRA_LIBS)))
950 ifeq (%(usestartup),yes)
951 TMP_LIBS += startup.o
956 # search for the linklibs in the given path, ignore ones not found
957 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
958 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
961 %(prog) : OBJS := %(objs)
962 %(prog) : LDFLAGS := %(ldflags) $(TMP_EXTRA_LDFLAGS)
963 %(prog) : LIBS := $(addprefix -l,%(uselibs) $(TMP_EXTRA_LIBS) %(usehostlibs))
964 %(prog) : %(objs) $(TMP_DEPLIBS)
965 %link_q cmd="%(cmd)" strip="%(strip)" from=$(OBJS) opt=$(LDFLAGS) libs=$(LIBS)
967 #------------------------------------------------------------------------------
970 #------------------------------------------------------------------------------
971 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
972 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
973 %define rule_link_progs progs=/A targetdir=$(AROSDIR)/$(CURDIR) nix=%(nix) \
974 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
975 usestartup=yes detach=no cmd="$(AROS_CC) $(TARGET_SYSROOT)" strip=$(TARGET_STRIP)
980 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
982 ifeq (%(usestartup),no)
983 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
986 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
989 # Make a list of the lib files the programs depend on.
990 # In LDFLAGS remove white space between -L and directory
991 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
992 # Filter out only the libdirs and remove -L
993 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
995 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
996 # Add normal linklib path
997 TMP_DIRS += $(AROS_LIB)/
998 # add lib and .a to static linklib names
999 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(TMP_EXTRA_LIBS)))
1000 # search for the linklibs in the given path, ignore ones not found
1001 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
1002 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
1004 TMP_PROGS := $(addprefix %(targetdir)/,%(progs))
1006 $(TMP_PROGS) : LDFLAGS:= %(ldflags) $(TMP_EXTRA_LDFLAGS)
1007 $(TMP_PROGS) : LIBS:= $(addprefix -l,%(uselibs) $(TMP_EXTRA_LIBS) %(usehostlibs))
1008 $(TMP_PROGS) : %(targetdir)/% : %(objdir)/%.o $(TMP_DEPLIBS)
1009 %link_q cmd="%(cmd)" strip="%(strip)" from=$< opt=$(LDFLAGS) libs=$(LIBS)
1011 #------------------------------------------------------------------------------
1014 #------------------------------------------------------------------------------
1015 # Link the %(objs) to the library %(libdir)/lib%(libname).a
1016 %define rule_link_linklib libname=/A objs=/A libdir=$(AROS_LIB) linker=target
1018 ifeq (%(linker),target)
1019 %(libdir)/lib%(libname).a : TMP_AR:=$(AR)
1020 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(RANLIB)
1022 ifeq (%(linker),host)
1023 %(libdir)/lib%(libname).a : TMP_AR:=$(HOST_AR)
1024 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(HOST_RANLIB)
1026 ifeq (%(linker),kernel)
1027 %(libdir)/lib%(libname).a : TMP_AR:=$(KERNEL_AR)
1028 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(KERNEL_RANLIB)
1031 %(libdir)/lib%(libname).a : %(objs)
1032 %mklib_q from=$^ ar=$(TMP_AR) ranlib=$(TMP_RANLIB)
1034 #------------------------------------------------------------------------------
1036 #------------------------------------------------------------------------------
1037 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
1038 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
1039 %define rule_linkmodule module=/A objs=/A endobj=/A err=/A objdir=$(OBJDIR) \
1040 cmd="$(AROS_CC) $(TARGET_SYSROOT)" ldflags=$(LDFLAGS) uselibs= usehostlibs=
1042 TMP_LDFLAGS := %(ldflags)
1043 # Make a list of the lib files the programs depend on.
1044 # In LDFLAGS remove white space between -L and directory
1045 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
1046 # Filter out only the libdirs and remove -L
1047 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
1049 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
1050 # Add normal linklib path
1051 TMP_DIRS += $(AROS_LIB)/
1052 # add lib and .a to static linklib names
1053 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
1054 # search for the linklibs in the given path, ignore ones not found
1055 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
1056 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
1059 %(module) : LIB_NAMES := %(uselibs)
1060 %(module) : OBJS := %(objs)
1061 %(module) : ENDTAG := %(endobj)
1062 %(module) : ERR := %(err)
1063 %(module) : OBJDIR := %(objdir)
1064 %(module) : LDFLAGS := $(TMP_LDFLAGS)
1065 ifeq (%(usehostlibs),)
1066 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES))
1068 # Warning: the -L/usr/lib here can result in modules
1069 # linking against host libs instead of AROS libs (e.g stdc++) !!
1070 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES)) \
1071 -L/usr/lib $(addprefix -l,%(usehostlibs))
1073 %(module) : %(objs) %(endobj) $(TMP_DEPLIBS) $(USER_DEPLIBS)
1074 %link_module_q cmd="%(cmd)" err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS) objdir=$(OBJDIR) ldflags=$(LDFLAGS)
1077 #------------------------------------------------------------------------------
1080 #------------------------------------------------------------------------------
1081 # Generate the libdefs.h include file for a module.
1082 %define rule_genmodule_genlibdefs modname=/A modtype=/A modsuffix= conffile= targetdir= version=
1084 TMP_TARGET := %(modname)_libdefs.h
1085 TMP_DEPS := $(GENMODULE)
1087 ifneq (%(conffile),)
1088 ifeq ($(dir %(conffile)),./)
1089 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1090 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1092 TMP_OPTS += -c %(conffile)
1093 TMP_DEPS += %(conffile)
1096 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1097 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1099 ifneq (%(modsuffix),)
1100 TMP_OPTS += -s %(modsuffix)
1102 ifneq (%(targetdir),)
1103 TMP_OPTS += -d %(targetdir)
1104 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1107 TMP_OPTS += -v %(version)
1110 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1111 $(TMP_TARGET) : MODNAME := %(modname)
1112 $(TMP_TARGET) : MODTYPE := %(modtype)
1113 $(TMP_TARGET) : $(TMP_DEPS)
1114 @$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1115 @$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
1117 #------------------------------------------------------------------------------
1119 #------------------------------------------------------------------------------
1120 # Generate the _lib.fd file for a module.
1121 %define rule_genmodule_fd modname=/A modtype=/A modsuffix= conffile= targetdir=
1123 TMP_TARGET := %(modname)_lib.fd
1124 TMP_DEPS := $(GENMODULE)
1126 ifneq (%(conffile),)
1127 ifeq ($(dir %(conffile)),./)
1128 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1129 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1131 TMP_OPTS += -c %(conffile)
1132 TMP_DEPS += %(conffile)
1135 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1136 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1138 ifneq (%(modsuffix),)
1139 TMP_OPTS += -s %(modsuffix)
1141 ifneq (%(targetdir),)
1142 TMP_OPTS += -d %(targetdir)
1143 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1146 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1147 $(TMP_TARGET) : MODNAME := %(modname)
1148 $(TMP_TARGET) : MODTYPE := %(modtype)
1149 $(TMP_TARGET) : $(TMP_DEPS)
1150 @$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1151 @$(GENMODULE) $(OPTS) writefd $(MODNAME) $(MODTYPE)
1153 #------------------------------------------------------------------------------
1155 #------------------------------------------------------------------------------
1156 # Generate a Makefile.%(modname)%(modtype) with the genmodule program and include this
1157 # generated file in this Makefile
1158 %define rule_genmodule_makefile modname=/A modtype=/A modsuffix= conffile= \
1161 TMP_TARGET := Makefile.%(modname)%(modtype)
1162 TMP_DEPS := $(GENMODULE)
1164 ifneq (%(conffile),)
1165 ifeq ($(dir %(conffile)),./)
1166 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1167 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1169 TMP_OPTS += -c %(conffile)
1170 TMP_DEPS += %(conffile)
1173 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1174 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1176 ifneq (%(modsuffix),)
1177 TMP_OPTS += -s %(modsuffix)
1179 ifneq (%(targetdir),)
1180 TMP_OPTS += -d %(targetdir)
1181 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1184 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1185 $(TMP_TARGET) : MODNAME := %(modname)
1186 $(TMP_TARGET) : MODTYPE := %(modtype)
1187 $(TMP_TARGET) : $(TMP_DEPS)
1188 @$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
1190 #------------------------------------------------------------------------------
1193 #------------------------------------------------------------------------------
1194 # Generate the support files for compiling a module. This includes include
1195 # files and source files. This rule has to be preceeded by
1196 # %rule_genmodule_makefile
1197 %define rule_genmodule_files modname=/A modtype=/A modsuffix= targetdir= \
1200 TMP_TARGETS := $(%(modname)_STARTFILES) $(%(modname)_ENDFILES) \
1201 $(%(modname)_LINKLIBFILES) $(%(modname)_RELLINKLIBFILES)
1202 TMP_TARGETS := $(addsuffix .c,$(TMP_TARGETS)) \
1203 $(addsuffix .S, $(%(modname)_LINKLIBAFILES) $(%(modname)_RELLINKLIBAFILES))
1205 TMP_DEPS := $(GENMODULE)
1208 ifneq (%(conffile),)
1209 ifeq ($(dir %(conffile)),./)
1210 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1211 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1213 TMP_OPTS += -c %(conffile)
1214 TMP_DEPS += %(conffile)
1217 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1218 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1220 ifneq (%(modsuffix),)
1221 TMP_OPTS += -s %(modsuffix)
1223 ifneq (%(targetdir),)
1224 TMP_OPTS += -d %(targetdir)
1225 TMP_TARGETDIR := $(shell echo %(targetdir) | sed 's/^\(.\):\//\/\1\//')
1226 TMP_TARGETS := $(addprefix $(TMP_TARGETDIR)/,$(TMP_TARGETS))
1229 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
1230 $(TMP_TARGETS) : MODNAME := %(modname)
1231 $(TMP_TARGETS) : MODTYPE := %(modtype)
1232 $(TMP_TARGETS) : $(TMP_DEPS)
1233 @$(ECHO) "Generating support files for module $(MODNAME$(BDID))"
1234 ifneq (%(conffile),lib.conf)
1235 @$(IF) $(TEST) -f lib.conf; then \
1236 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
1239 @$(IF) $(TEST) -f libdefs.h; then \
1240 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
1242 @$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
1244 #------------------------------------------------------------------------------
1247 #------------------------------------------------------------------------------
1248 # Generate the support files for compiling a module. This includes include
1249 # files and source files.
1250 %define rule_genmodule_includes modname=/A modtype=/A modsuffix= \
1251 targetdir= conffile=
1253 ifneq ($(%(modname)_INCLUDES),)
1254 TMP_TARGETS := $(%(modname)_INCLUDES)
1256 TMP_DEPS := $(GENMODULE)
1259 ifneq (%(conffile),)
1260 ifeq ($(dir %(conffile)),./)
1261 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1262 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1264 TMP_OPTS += -c %(conffile)
1265 TMP_DEPS += %(conffile)
1268 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1269 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1271 ifneq (%(modsuffix),)
1272 TMP_OPTS += -s %(modsuffix)
1274 ifneq (%(targetdir),)
1275 TMP_OPTS += -d %(targetdir)
1276 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
1279 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
1280 $(TMP_TARGETS) : MODNAME := %(modname)
1281 $(TMP_TARGETS) : MODTYPE := %(modtype)
1282 $(TMP_TARGETS) : $(TMP_DEPS)
1283 @$(ECHO) "Generating $(MODNAME).$(MODTYPE) includes"
1284 @$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
1287 #------------------------------------------------------------------------------
1289 #------------------------------------------------------------------------------
1290 # Link %(objs) to binary blob in %(file) using %(name) as name of embedded binary object
1291 # 'start' is an optional starting address
1292 # 'ldflags' is optional additional flags for the linker
1293 %define rule_link_binary file=/A name=/A objs= files= start=0 ldflags=
1295 BD_OUTDIR := $(dir %(file))
1296 # This trick removes the trailing '/', otherwise findstring below fails, causing a warning
1297 BD_OUTDIR := $(subst /*,,$(addsuffix *,$(BD_OUTDIR)))
1298 BD_TMPDIR := $(GENDIR)/$(CURDIR)
1299 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(notdir %(files))))
1300 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(notdir %(files))))
1303 %rule_compile_multi basenames="%(files)" targetdir=$(BD_OBJDIR)
1305 %(file) : $(BD_OBJS) $(BD_DEPS) $(BD_OUTDIR)
1306 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)..."
1307 @$(KERNEL_LD) %(ldflags) --entry=%(start) --oformat=binary -Ttext=%(start) -o $(BD_TMPDIR)/%(name) $(BD_OBJS)
1308 @cd $(BD_TMPDIR) && $(AROS_LD) %(ldflags) -r --format binary %(name) -o $@
1310 ifeq ($(findstring $(BD_OUTDIR),$(GLOB_MKDIRS)),)
1311 GLOB_MKDIRS += $(BD_OUTDIR)
1316 #------------------------------------------------------------------------------
1317 # Common rules for all makefiles
1319 # Delete generated makefiles
1322 @$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
1324 include $(SRCDIR)/config/make.tail
1326 BDID := $(BDTARGETID)
1328 #------------------------------------------------------------------------------
1331 #############################################################################
1332 #############################################################################
1334 ## Here are the mmakefile build macros. These are macros that takes care ##
1335 ## of everything to go from the sources to the generated target. Also all ##
1336 ## intermediate files and directories that are needed are created by these ##
1339 #############################################################################
1340 #############################################################################
1342 #------------------------------------------------------------------------------
1344 %define build_prog mmake=/A progname=/A files=$(BD_PROGNAME) cxxfiles= \
1346 asmfiles= objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1347 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_CXXFLAGS) ldflags=$(LDFLAGS) \
1348 aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
1349 includedir= libdir= \
1350 compiler=target linker=
1354 BD_PROGNAME := %(progname)
1355 BD_OBJDIR := %(objdir)
1356 BD_TARGETDIR := %(targetdir)
1357 BD_LINKER := %(linker)
1359 # If not supplied, linker is equal to compiler
1360 ifeq ($(BD_LINKER),)
1361 BD_LINKER := %(compiler)
1364 BD_FILES := %(files)
1365 BD_OBJCFILES := %(objcfiles)
1366 BD_ASMFILES := %(asmfiles)
1367 BD_CXXFILES := %(cxxfiles)
1369 BD_ARCHOBJS := $(wildcard $(BD_OBJDIR)/arch/*.o)
1370 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1371 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1373 TMP_FILES := $(BD_NARCHFILES) $(BD_CXXFILES) $(BD_ASMFILES) $(BD_OBJCFILES)
1374 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(notdir $(TMP_FILES))))
1375 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(notdir $(TMP_FILES))))
1377 BD_CFLAGS := %(cflags)
1378 BD_CXXFLAGS := %(cxxflags)
1379 ifneq (%(includedir),)
1380 BD_CFLAGS += -I%(includedir)
1381 BD_CXXFLAGS += -I%(includedir)
1383 BD_AFLAGS := %(aflags)
1384 ifneq (%(includedir),)
1385 BD_AFLAGS += -I%(includedir)
1387 BD_DFLAGS := %(dflags)
1388 BD_DXXFLAGS := %(dxxflags)
1389 BD_LDFLAGS := %(ldflags)
1391 BD_LDFLAGS += -L%(libdir)
1395 %(mmake)-quick : %(mmake)
1397 #MM %(mmake) : includes-generate-deps core-linklibs linklibs-%(uselibs)
1398 %(mmake) : $(BD_TARGETDIR)/$(BD_PROGNAME)
1400 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick %(mmake)-gz-quick),)
1401 %rule_compile_cxx_multi basenames=$(BD_CXXFILES) targetdir=$(BD_OBJDIR) \
1402 cxxflags=$(BD_CXXFLAGS) dxxflags=$(BD_DXXFLAGS) compiler="%(compiler)"
1403 %rule_compile_objc_multi basenames=$(BD_OBJCFILES) targetdir=$(BD_OBJDIR) \
1404 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler="%(compiler)"
1405 %rule_compile_multi basenames=$(BD_NARCHFILES) targetdir=$(BD_OBJDIR) \
1406 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler="%(compiler)"
1407 %rule_assemble_multi basenames=$(BD_ASMFILES) targetdir=$(BD_OBJDIR) \
1410 %rule_link_prog prog=$(BD_TARGETDIR)/$(BD_PROGNAME) \
1411 objs="$(BD_OBJS) $(BD_ARCHOBJS) $(USER_OBJS)" ldflags=$(BD_LDFLAGS) \
1412 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1413 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)" \
1414 cmd=$(BD_LINK) strip=$(BD_STRIP)
1418 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1420 $(BD_OBJS) $(BD_DEPS) : | $(BD_OBJDIR)
1421 $(BD_TARGETDIR)/$(BD_PROGNAME) : | $(BD_TARGETDIR)
1422 GLOB_MKDIRS += $(BD_OBJDIR) $(BD_TARGETDIR)
1424 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_TARGETDIR)/$(BD_PROGNAME) $(BD_DEPS)
1427 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1431 #------------------------------------------------------------------------------
1434 #------------------------------------------------------------------------------
1435 # Build programs, for every C file an executable will be built with the same
1436 # name as the C file
1437 %define build_progs mmake=/A files=/A nix=no \
1438 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1439 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
1440 includedir= libdir= \
1441 uselibs= usehostlibs= usestartup=yes detach=no
1445 BD_OBJDIR := %(objdir)
1446 BD_TARGETDIR := %(targetdir)
1448 BD_FILES := %(files)
1449 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1450 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1451 BD_EXES := $(addprefix $(BD_TARGETDIR)/,$(BD_FILES))
1453 BD_CFLAGS := %(cflags)
1454 ifneq (%(includedir),)
1455 BD_CFLAGS += -I%(includedir)
1457 BD_DFLAGS := %(dflags)
1458 BD_LDFLAGS := %(ldflags)
1460 BD_LDFLAGS += -L%(libdir)
1464 %(mmake)-quick : %(mmake)
1466 #MM %(mmake) : includes-generate-deps core-linklibs linklibs-%(uselibs)
1467 %(mmake) : $(BD_EXES)
1469 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1470 %rule_compile_multi basenames=$(BD_FILES) targetdir=$(BD_OBJDIR) \
1471 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1473 %rule_link_progs progs=$(BD_FILES) nix="%(nix)" \
1474 targetdir=$(BD_TARGETDIR) objdir=$(BD_OBJDIR) \
1475 ldflags=$(BD_LDFLAGS) \
1476 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1477 usestartup="%(usestartup)" detach="%(detach)" \
1478 cmd=$(BD_LINK) strip=$(BD_STRIP)
1482 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1484 $(addprefix $(BD_TARGETDIR)/,$(BD_FILES)) : | $(BD_TARGETDIR)
1485 $(BD_DEPS) $(BD_OBJS) : | $(BD_OBJDIR)
1486 GLOB_MKDIRS += $(BD_TARGETDIR) $(BD_OBJDIR)
1488 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_EXES) $(BD_DEPS)
1491 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1495 #------------------------------------------------------------------------------
1498 #------------------------------------------------------------------------------
1500 # This is a bare version: It just compiles and links the given files. It is
1501 # assumed that all needed boiler plate code is in the files. This should only
1502 # be used for compiling external code. For AROS code use %build_module
1503 %define build_module_simple mmake=/A modname=/A modtype=/A \
1504 files="$(basename $(call WILDCARD, *.c))" \
1505 cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1506 objdir=$(OBJDIR) moduledir= \
1507 uselibs= usehostlibs= compiler=target
1509 # Define metamake targets and their dependencies
1510 #MM %(mmake) : core-linklibs includes-generate-deps
1511 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1512 #MM %(mmake)-kobj-quick
1516 BD_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj
1518 .PHONY : $(BD_ALLTARGETS)
1521 $(error using %build_module_simple: modname may not be empty)
1524 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1527 # Default values for variables and arguments
1528 BD_DEFLINKLIBNAME := %(modname)
1529 BD_DEFDFLAGS := %(cflags)
1530 BD_DEFDXXFLAGS := %(dxxflags)
1531 OBJDIR ?= $(GENDIR)/$(CURDIR)
1532 BD_MODDIR := %(moduledir)
1533 ifeq ($(BD_MODDIR),)
1534 ifeq (%(modtype),library)
1535 BD_MODDIR := $(AROS_LIBRARIES)
1537 ifeq (%(modtype),gadget)
1538 BD_MODDIR := $(AROS_GADGETS)
1540 ifeq (%(modtype),datatype)
1541 BD_MODDIR := $(AROS_DATATYPES)
1543 ifeq (%(modtype),handler)
1544 BD_MODDIR := $(AROS_FS)
1546 ifeq (%(modtype),device)
1547 BD_MODDIR := $(AROS_DEVS)
1549 ifeq (%(modtype),resource)
1550 BD_MODDIR := $(AROS_RESOURCES)
1552 ifeq (%(modtype),hook)
1553 BD_MODDIR := $(AROS_RESOURCES)
1555 ifeq (%(modtype),mui)
1556 BD_MODDIR := $(AROS_CLASSES)/Zune
1558 ifeq (%(modtype),mcc)
1559 BD_MODDIR := $(AROS_CLASSES)/Zune
1561 ifeq (%(modtype),mcp)
1562 BD_MODDIR := $(AROS_CLASSES)/Zune
1564 ifeq (%(modtype),usbclass)
1565 BD_MODDIR := $(AROS_CLASSES)/USB
1567 ifeq (%(modtype),hidd)
1568 BD_MODDIR := $(AROS_DRIVERS)
1570 ifeq (%(modtype),printer)
1571 BD_MODDIR := $(AROS_PRINTERS)
1574 ifeq ($(BD_MODDIR),)
1575 $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1578 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1579 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1580 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),%(files))
1582 %rule_compile_multi \
1583 basenames=$(BD_NARCHFILES) targetdir="%(objdir)" \
1584 cflags="%(cflags)" dflags="%(dflags)" \
1585 compiler="%(compiler)"
1587 # Handlers use dash instead of dot in their names
1588 ifeq (%(modtype),handler)
1589 BD_MODULE := $(BD_MODDIR)/%(modname)-%(modtype)
1591 ifeq (%(modtype),printer)
1592 BD_MODULE := $(BD_MODDIR)/%(modname)
1594 BD_MODULE := $(BD_MODDIR)/%(modname).%(modtype)
1597 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1599 %(mmake)-quick : %(mmake)
1600 %(mmake)-kobj-quick : $(BD_KOBJ)
1601 %(mmake) : $(BD_MODULE)
1602 %(mmake)-kobj : $(BD_KOBJ)
1604 # The module is linked from all the compiled .o files
1605 BD_OBJS := $(BD_ARCHOBJS) $(addprefix %(objdir)/, $(addsuffix .o,$(notdir $(BD_NARCHFILES))))
1607 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
1608 # This breaks con-handler build. Here we work around this
1609 ifeq (%(modname),con)
1610 BD_ERR := $(notdir $(BD_MODULE)).err
1612 BD_ERR := %(modname).err
1615 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1616 endobj= err=$(BD_ERR) objdir="%(objdir)" \
1617 ldflags="$(LDFLAGS) $(%(modname)_LDFLAGS)" \
1618 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
1620 # Link kernel object file
1621 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1623 # Make these symbols local
1624 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1625 UtilityBase ExpansionBase KeymapBase KernelBase
1627 BD_SYMBOLS := $(BD_KBASE)
1629 BD_KLIB := hiddstubs amiga arossupport autoinit libinit
1630 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1631 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1632 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
1633 $(BD_KOBJ) : USER_LDFLAGS := $(USER_LDFLAGS)
1634 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1635 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
1636 @$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1637 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
1640 ## Dependency fine-tuning
1642 BD_DEPS := $(addprefix %(objdir)/, $(addsuffix .d,%(files)))
1643 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1645 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1646 $(BD_MODULE) : | $(BD_MODDIR)
1647 $(BD_KOBJ) : | $(KOBJSDIR)
1648 GLOB_MKDIRS += %(objdir) $(BD_MODDIR) $(KOBJSDIR)
1650 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_MODULE) $(BD_KOBJ) $(BD_DEPS)
1652 @$(ECHO) "Cleaning up for module %(modname)"
1655 #------------------------------------------------------------------------------
1658 #------------------------------------------------------------------------------
1659 # Build a module - core routine
1660 # Explanation of this macro is done in the developer's manual
1661 %define build_module_core mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
1662 files="$(basename $(call WILDCARD, *.c))" \
1663 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
1664 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_DEFDXXFLAGS) \
1665 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
1666 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
1667 compiler=target nostartup=yes archspecific=no \
1668 includedir= libdir= \
1669 build_abi= build_library=
1671 # We will employ a terrifying, but unavoidable, hack here.
1672 # genmf has no concept of conditionals (ie %ifeq), and MetaMake
1673 # ignores GNU Make ifeq() statements, but will process any #MM
1674 # headed lines in the file.
1676 # So, to make the following #MM lines conditional on whether we want
1677 # to build the ABI, Library, or both, we define build_abi= and
1678 # build_library as 'M' to enable, or '' to disable, which allows genmf
1679 # to do the following conversions:
1681 # #%(build_abi)M includes-foo: foo-include
1682 # becomes, when build_abi=M
1683 # #MM includes-foo: foo-include <= Processed by MetaMake
1684 # but, when build_abi= ...
1685 # #M includes-foo: foo-includes <= ignored by MetaMake! Yes!
1687 # Taking full blame for this: Jason S. McMullan <jason.mcmullan@gmail.com>
1689 # Define metamake targets and their dependencies
1692 #MM %(mmake)-makefile
1696 #M%(build_abi)- includes-all : %(mmake)-includes
1697 #M%(build_abi)- linklibs-%(modname): %(mmake)-linklib
1698 #M%(build_abi)- linklibs-%(modname)_rel : %(mmake)-linklib
1699 #M%(build_abi)- includes-%(modname): %(mmake)-includes
1700 #M%(build_abi)- includes-%(modname)_rel : %(mmake)-includes
1701 #M%(build_abi)- %(mmake) : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1702 #M%(build_abi) %(mmake)-linklib : %(mmake)-includes includes-%(uselibs)
1703 #M%(build_abi)- %(mmake)-quick : %(mmake)-includes-quick
1704 #M%(build_abi) %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1705 #M%(build_abi) includes-generate-deps %(mmake)-fd
1706 #M%(build_abi) %(mmake)-includes-quick
1707 #M%(build_abi) %(mmake)-includes-dirs
1708 #M%(build_abi) %(mmake)-fd
1711 #%(build_library)M %(mmake)-kobj : core-linklibs linklibs-%(uselibs)
1712 #%(build_library)M %(mmake)-kobj-quick :
1714 # Library with ABI targets:
1715 #%(build_library)%(build_abi) %(mmake)-kobj : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1716 #%(build_library)%(build_abi) %(mmake)-kobj-quick : %(mmake)-includes-quick
1718 # All MetaMake targets defined by this macro
1719 BD_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-clean
1721 ifeq (%(build_library),M)
1722 BD_ALLTARGETS += %(mmake)-kobj %(mmake)-kobj-quick
1725 ifeq (%(build_abi),M)
1726 BD_ALLTARGETS += %(mmake)-includes \
1727 %(mmake)-includes-quick %(mmake)-includes-dirs \
1728 %(mmake)-linklib %(mmake)-fd
1731 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1734 $(error using %build_module: modname may not be empty)
1737 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1740 # Default values for variables and arguments
1741 BD_DEFLINKLIBNAME := %(modname)
1742 BD_DEFDFLAGS := %(cflags)
1743 BD_DEFDXXFLAGS := %(cxxflags)
1744 ifneq (%(includedir),)
1745 BD_DEFDFLAGS += -I%(includedir)
1746 BD_DEFDXXFLAGS += -I%(includedir)
1748 OBJDIR ?= $(GENDIR)/$(CURDIR)
1750 ## Create genmodule include Makefile for the module
1752 %(mmake)-makefile : %(objdir)/Makefile.%(modname)%(modtype)
1754 %rule_genmodule_makefile \
1755 modname="%(modname)" modtype="%(modtype)" \
1756 modsuffix="%(modsuffix)" targetdir="%(objdir)" \
1757 conffile="%(conffile)"
1759 %(objdir)/Makefile.%(modname)%(modtype) : | %(objdir)
1761 GLOB_MKDIRS += %(objdir)
1763 # Do not parse these statements if metatarget is not appropriate
1764 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1766 include %(objdir)/Makefile.%(modname)%(modtype)
1768 BD_DEFMODDIR := $(%(modname)_MODDIR)
1769 ifeq (%(archspecific),yes)
1770 BD_DEFMODDIR := $(AROS_DIR_ARCH)/$(BD_DEFMODDIR)
1774 ## include files generation
1776 ifneq (%(includedir),)
1777 BD_INCDIR := %(includedir)
1779 BD_INCDIR := %(prefix)/$(AROS_DIR_INCLUDE)
1781 BD_LIBDEFSINC := %(objdir)/include/%(modname)_libdefs.h
1782 BD_DEFLIBDEFSINC := %(objdir)/include/%(modname)_deflibdefs.h
1784 ifeq (%(build_abi),M)
1785 %(mmake)-includes-quick : %(mmake)-includes
1786 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1787 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1788 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1790 ifneq ($(%(modname)_INCLUDES),)
1791 %rule_genmodule_includes modname="%(modname)" modtype="%(modtype)" \
1792 modsuffix="%(modsuffix)" targetdir="%(objdir)/include" \
1793 conffile="%(conffile)"
1795 %rule_copy_diff_multi \
1796 files=$(%(modname)_INCLUDES) srcdir="%(objdir)/include" targetdir=$(GENINCDIR) \
1797 stampfile="%(objdir)/%(modname)_geninc"
1799 %rule_copy_diff_multi \
1800 files=$(%(modname)_INCLUDES) srcdir="%(objdir)/include" targetdir=$(BD_INCDIR) \
1801 stampfile="%(objdir)/%(modname)_incs"
1803 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1805 TMP%(modname)_INCDIRS := \
1806 %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1807 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1808 $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1809 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget="%(mmake)-includes-dirs"
1815 %rule_genmodule_genlibdefs modname="%(modname)" modtype="%(modtype)" \
1816 modsuffix="%(modsuffix)" targetdir="%(objdir)/include" \
1817 conffile="%(conffile)" version="%(version)"
1819 $(BD_DEFLIBDEFSINC) : FILENAME := $(BD_LIBDEFSINC)
1820 $(BD_DEFLIBDEFSINC) :
1821 @$(ECHO) "Generating $@"
1822 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1824 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) : | %(objdir)/include
1825 GLOB_MKDIRS += %(objdir)/include
1827 ## Extra genmodule src files generation
1829 %rule_genmodule_files modname="%(modname)" modtype="%(modtype)" \
1830 modsuffix="%(modsuffix)" targetdir="%(objdir)" \
1831 conffile="%(conffile)"
1834 ifeq (%(build_abi),M)
1836 ifeq (%(includedir),)
1837 BD_FDDIR := %(prefix)/$(AROS_DIR_DEVELOPMENT)/fd
1839 BD_FDDIR := %(includedir)/../fd
1841 %(mmake)-fd : $(BD_FDDIR)/%(modname)_lib.fd
1843 %rule_genmodule_fd modname="%(modname)" modtype="%(modtype)" \
1844 modsuffix="%(modsuffix)" targetdir=$(BD_FDDIR) conffile="%(conffile)"
1846 $(BD_FDDIR)/%(modname)_lib.fd : | $(BD_FDDIR)
1848 GLOB_MKDIRS += $(BD_FDDIR)
1853 BD_FILES := %(files)
1854 BD_CXXFILES := %(cxxfiles)
1856 BD_FDIRS := $(sort $(dir $(BD_FILES)))
1858 BD_STARTFILES := $(addprefix %(objdir)/,$(%(modname)_STARTFILES))
1859 BD_ENDFILES := $(addprefix %(objdir)/,$(%(modname)_ENDFILES))
1861 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1862 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1863 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1865 BD_CFLAGS := %(cflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC) $(%(modname)_CFLAGS)
1866 BD_CXXFLAGS := %(cxxflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC) $(%(modname)_CXXFLAGS)
1867 ifneq (%(includedir),)
1868 BD_CFLAGS += -I%(includedir)
1869 BD_CXXFLAGS += -I%(includedir)
1871 BD_DFLAGS := %(dflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC) $(%(modname)_DFLAGS)
1872 BD_DXXFLAGS := %(dxxflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC) $(%(modname)_DXXFLAGS)
1874 ifeq (%(modtype),library)
1877 BD_LIBSUFFIX := .%(modtype)
1881 BD_LIBDIR := %(prefix)/$(AROS_DIR_LIB)
1883 BD_LIBDIR := %(libdir)
1886 ifeq (%(build_abi),M)
1887 BD_LINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBFILES))
1888 BD_LINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBAFILES))
1889 ifeq ($(strip $(%(modname)_LINKLIBFILES) $(%(modname)_LINKLIBAFILES) %(linklibfiles)),)
1892 BD_LINKLIB := $(BD_LIBDIR)/lib%(modname)$(BD_LIBSUFFIX).a
1893 ifneq (%(modname),%(linklibname))
1894 BD_LINKLIB += $(BD_LIBDIR)/lib%(linklibname)$(BD_LIBSUFFIX).a
1897 BD_LINKLIBFILES := $(BD_LINKLIBCFILES) $(BD_LINKLIBAFILES)
1899 BD_RELLINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_RELLINKLIBFILES))
1900 BD_RELLINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_RELLINKLIBAFILES))
1901 ifeq ($(strip $(%(modname)_RELLINKLIBFILES) $(%(modname)_RELLINKLIBAFILES) %(linklibfiles)),)
1904 BD_RELLINKLIB := $(BD_LIBDIR)/lib%(modname)_rel$(BD_LIBSUFFIX).a
1905 ifneq (%(modname),%(linklibname))
1906 BD_RELLINKLIB += $(BD_LIBDIR)/lib%(linklibname)_rel$(BD_LIBSUFFIX).a
1909 BD_RELLINKLIBFILES := $(BD_RELLINKLIBCFILES) $(BD_RELLINKLIBAFILES)
1912 BD_CCFILES := $(BD_NARCHFILES) %(linklibfiles)
1913 BD_TARGETCCFILES := $(BD_STARTFILES) $(BD_ENDFILES) $(BD_LINKLIBCFILES) \
1914 $(BD_RELLINKLIBCFILES)
1916 %rule_compile_cxx_multi \
1917 basenames=$(BD_CXXFILES) targetdir="%(objdir)" \
1918 cxxflags=$(BD_CXXFLAGS) dxxflags=$(BD_DXXFLAGS) \
1919 compiler="%(compiler)"
1920 %rule_compile_multi \
1921 basenames=$(BD_CCFILES) targetdir="%(objdir)" \
1922 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) \
1923 compiler="%(compiler)"
1924 %rule_compile_multi \
1925 basenames=$(BD_TARGETCCFILES) targetdir="%(objdir)" \
1926 cflags="$(BD_CFLAGS) -D__AROS__" dflags=$(BD_DFLAGS) \
1927 compiler="%(compiler)"
1929 ifneq ($(BD_LINKLIBAFILES),)
1930 %rule_assemble_multi \
1931 basenames="$(BD_LINKLIBAFILES) $(BD_RELLINKLIBAFILES)" targetdir="%(objdir)" suffix=.S
1936 ifeq (%(modsuffix),)
1937 BD_SUFFIX := %(modtype)
1939 BD_SUFFIX := %(modsuffix)
1942 ifeq (%(build_library),M)
1943 # Handlers use dash instead of dot in their names
1944 ifeq ($(BD_SUFFIX),handler)
1945 BD_MODULE := %(prefix)/%(moduledir)/%(modname)-$(BD_SUFFIX)
1947 BD_MODULE := %(prefix)/%(moduledir)/%(modname).$(BD_SUFFIX)
1949 BD_KOBJ := $(KOBJSDIR)/%(modname)_$(BD_SUFFIX).o
1955 %(mmake)-quick : %(mmake)
1956 %(mmake) : $(BD_MODULE) $(BD_LINKLIB) $(BD_RELLINKLIB)
1957 ifeq (%(build_library),M)
1958 %(mmake)-kobj : $(BD_KOBJ) $(BD_LINKLIB) $(BD_RELLINKLIB)
1959 %(mmake)-kobj-quick : $(BD_KOBJ) $(BD_LINKLIB) $(BD_RELLINKLIB)
1961 ifeq (%(build_abi),M)
1962 %(mmake)-linklib : $(BD_LINKLIB) $(BD_RELLINKLIB)
1965 BD_OBJS := $(addsuffix .o,$(BD_STARTFILES)) $(BD_ARCHOBJS) \
1966 $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES:=.o) $(BD_CXXFILES:=.o)))
1968 ifeq (%(nostartup),yes)
1969 # Handlers always have entry point
1970 ifneq (%(modtype),handler)
1971 BD_STARTOBJS := $(addsuffix .o,$(addprefix $(GENDIR)/,$(RESIDENT_BEGIN)))
1975 BD_ENDOBJS := $(addsuffix .o,$(BD_ENDFILES))
1976 BD_LINKLIBOBJS:= $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_LINKLIBFILES)) \
1979 := $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_RELLINKLIBFILES)) \
1982 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
1983 # This breaks con-handler build. Here we work around this
1984 ifeq (%(modname),con)
1985 BD_ERR := $(notdir $(BD_MODULE)).err
1987 BD_ERR := %(modname).err
1990 ifeq (%(build_library),M)
1991 # The module is linked from all the compiled .o files
1992 %rule_linkmodule module=$(BD_MODULE) objs="$(BD_STARTOBJS) $(BD_OBJS) $(USER_OBJS)" \
1993 endobj=$(BD_ENDOBJS) err=$(BD_ERR) objdir="%(objdir)" \
1994 cmd=$(BD_LINK) ldflags="$(LDFLAGS) $(%(modname)_LDFLAGS)" \
1995 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
1998 ifeq (%(build_abi),M)
2000 BD_LINKLIBNAME := $(shell echo %(linklibname) | tr A-Z a-z)
2001 BD_MODNAME := $(shell echo %(modname) | tr A-Z a-z)
2002 ifneq ($(BD_LINKLIB),)
2003 %rule_link_linklib libname="%(linklibname)$(BD_LIBSUFFIX)" objs=$(BD_LINKLIBOBJS) libdir="$(BD_LIBDIR)"
2004 ifneq ($(BD_MODNAME),$(BD_LINKLIBNAME))
2005 %rule_link_linklib libname="%(modname)$(BD_LIBSUFFIX)" objs=$(BD_LINKLIBOBJS) libdir="$(BD_LIBDIR)"
2008 $(BD_LINKLIB) : | $(BD_LIBDIR)
2009 GLOB_MKDIRS += $(BD_LIBDIR)
2012 ifneq ($(BD_RELLINKLIB),)
2013 %rule_link_linklib libname="%(linklibname)_rel$(BD_LIBSUFFIX)" objs=$(BD_RELLINKLIBOBJS) libdir="$(BD_LIBDIR)"
2014 ifneq ($(BD_MODNAME),$(BD_LINKLIBNAME))
2015 %rule_link_linklib libname="%(modname)_rel$(BD_LIBSUFFIX)" objs=$(BD_RELLINKLIBOBJS) libdir="$(BD_LIBDIR)"
2018 $(BD_RELLINKLIB) : | $(BD_LIBDIR)
2019 GLOB_MKDIRS += $(BD_LIBDIR)
2023 ifeq (%(build_library),M)
2024 # Link kernel object file
2025 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
2027 # Make these symbols local
2028 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
2029 UtilityBase ExpansionBase KeymapBase KernelBase
2031 BD_SYMBOLS := $(BD_KBASE)
2033 BD_KLIB := hiddstubs amiga arossupport autoinit libinit
2034 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
2035 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS) $(%(modname)_LIBS)
2036 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
2037 $(BD_KOBJ) : USER_LDFLAGS:=$(USER_LDFLAGS)
2038 $(BD_KOBJ) : $(BD_OBJS) $(USER_OBJS) $(BD_ENDOBJS)
2039 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
2040 @$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
2041 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
2044 ## Dependency fine-tuning
2046 BD_DEPS := $(addprefix %(objdir)/,$(notdir $(BD_CCFILES:=.d) $(BD_TARGETCCFILES:=.d) $(BD_CXXFILES:=.d)))
2048 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick" deps=$(BD_DEPS)
2050 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
2051 $(BD_MODULE) : | %(prefix)/%(moduledir)
2052 $(BD_KOBJ) : | $(KOBJSDIR)
2053 GLOB_MKDIRS += %(objdir) %(prefix)/%(moduledir) $(KOBJSDIR)
2055 # Some include files need to be generated before the .c can be parsed.
2056 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick),) # Only for this target these deps are wanted
2058 BD_DFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
2059 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES))
2060 $(BD_DEPS) : $(BD_DFILE_DEPS)
2063 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) \
2064 $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
2065 %(objdir)/Makefile.%(modname)%(modtype) \
2066 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
2067 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
2068 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
2069 %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
2070 $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
2071 $(BD_DEFLIBDEFSINC) $(addsuffix .c,$(BD_STARTFILES) $(BD_ENDFILES)) \
2073 %(mmake)-clean : FILES := $(BD_TOCLEAN)
2075 @$(ECHO) "Cleaning up for module %(modname)"
2078 endif # $(TARGET) in $(BD_ALLTARGETS)
2080 #------------------------------------------------------------------------------
2082 #------------------------------------------------------------------------------
2083 # Build a module - ABI and library
2084 # Explanation of this macro is done in the developer's manual
2085 %define build_module mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2086 files="$(basename $(call WILDCARD, *.c))" \
2087 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2088 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_DEFDXXFLAGS) \
2089 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
2090 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
2091 compiler=target nostartup=yes archspecific=no \
2094 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2095 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2096 files="%(files)" cxxfiles="%(cxxfiles)" \
2097 linklibname="%(linklibname)" \
2098 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2099 cflags="%(cflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2100 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2101 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" \
2102 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2103 includedir="%(includedir)" libdir="%(libdir)" \
2104 build_abi=M build_library=M
2107 #------------------------------------------------------------------------------
2110 #------------------------------------------------------------------------------
2111 # Build a module skeleton ABI
2112 # This is a stripped-down version of build_module, it only creates include
2113 # files and the linklibs.
2114 # This is used when for plugins or classes with the same API, but no actual
2115 # implementation here.
2116 %define build_module_abi mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2117 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_DEFDXXFLAGS) \
2118 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
2119 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
2120 compiler=target nostartup=yes archspecific=no \
2123 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2124 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2125 linklibname="%(linklibname)" \
2126 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2127 cflags="%(cflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2128 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2129 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" \
2130 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2131 includedir="%(includedir)" libdir="%(libdir)" \
2132 build_abi=M build_library=
2135 #------------------------------------------------------------------------------
2137 #------------------------------------------------------------------------------
2138 # Build a module library - no includes nor linklibs
2139 # Explanation of this macro is done in the developer's manual
2140 %define build_module_library mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2141 files="$(basename $(call WILDCARD, *.c))" \
2142 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2143 cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) cxxflags="$(CXXFLAGS)" dxxflags="$(BD_DEFDXXFLAGS)" \
2144 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
2145 uselibs= usehostlibs= \
2146 compiler=target nostartup=yes archspecific=no \
2149 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2150 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2151 files="%(files)" cxxfiles="%(cxxfiles)" \
2152 cflags="%(cflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2153 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2154 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" \
2155 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2156 includedir="%(includedir)" libdir="%(libdir)" \
2157 build_abi= build_library=M
2160 #------------------------------------------------------------------------------
2164 #------------------------------------------------------------------------------
2166 # - mmake is the mmaketarget
2167 # - libname is the baselibname e.g. lib%(libname).a will be created
2168 # - files are the C source files to include in the lib. The list of files
2169 # has to be given without the .c suffix
2170 # - cxxfiles are C++ source files without suffix.
2171 # NB: files will be matched in the order .cpp > .cxx > .cc
2172 # - asmfiles are the asm files to include in the lib. The list of files has to
2173 # be given without the .s suffix
2174 # - objs additional object to link into the linklib. The objects have to be
2175 # given with full absolute path and the .o suffix.
2176 # - objdir is where the .o are generated. Defaults to $(GENDIR)/$(CURDIR)
2177 # - libdir is the directory where the linklib will be placed (default $(AROS_LIB))
2178 # - cflags are the flags to compile the source (default $(CFLAGS))
2179 # - dflags are the flags use during makedepend (default equal to cflags)
2180 # - aflags are the flags use during assembling (default $(AFLAGS))
2181 # - libdir is the directory where the linklib will be placed (default $(AROS_LIB))
2182 %define build_linklib mmake=/A libname=/A files= cxxfiles= \
2183 asmfiles= objs= objdir=$(GENDIR)/$(CURDIR) libdir=$(AROS_LIB) \
2185 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_CXXFLAGS) \
2186 aflags=$(AFLAGS) compiler=target
2188 # assign and generate the local variables used in this macro
2189 BD_LIBNAME := %(libname)
2190 BD_LINKLIB := %(libdir)/lib%(libname).a
2192 BD_FILES := %(files)
2193 BD_ASMFILES := %(asmfiles)
2194 BD_CXXFILES := %(cxxfiles)
2196 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
2197 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
2198 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
2200 BD_OBJS := $(BD_ARCHOBJS) \
2201 $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES:=.o) $(BD_CXXFILES:=.o) $(BD_ASMFILES:=.o))) \
2203 BD_DEPS := $(patsubst %.o,%.d,$(BD_OBJS))
2205 BD_CFLAGS := %(cflags)
2206 BD_CXXFLAGS := %(cxxflags)
2207 ifneq (%(includedir),)
2208 BD_CFLAGS += -I%(includedir)
2209 BD_CXXFLAGS += -I%(includedir)
2211 BD_AFLAGS := %(aflags)
2212 BD_DFLAGS := %(dflags)
2213 BD_DXXFLAGS := %(dxxflags)
2215 .PHONY : %(mmake) %(mmake)-clean %(mmake)-quick
2218 %(mmake)-quick : %(mmake)
2220 #MM %(mmake) : includes-generate-deps
2221 %(mmake) : $(BD_LINKLIB)
2223 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
2225 %rule_compile_cxx_multi basenames=$(BD_CXXFILES) targetdir="%(objdir)" \
2226 compiler="%(compiler)" cxxflags=$(BD_CXXFLAGS) dxxflags=$(BD_DXXFLAGS)
2227 %rule_compile_multi basenames=$(BD_FILES) targetdir="%(objdir)" \
2228 compiler="%(compiler)" cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
2229 %rule_assemble basename=% targetdir="%(objdir)" \
2232 %rule_link_linklib libname="%(libname)" objs=$(BD_OBJS) libdir="%(libdir)" linker="%(compiler)"
2235 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
2237 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
2238 $(BD_LINKLIB) : | %(libdir)
2239 GLOB_MKDIRS += %(objdir) %(libdir)
2241 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_LINKLIB) $(BD_DEPS)
2244 @$(ECHO) "Cleaning up for metatarget %(mmake)"
2248 #------------------------------------------------------------------------------
2251 #------------------------------------------------------------------------------
2253 # - mmake is the mmaketarget
2254 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
2255 # - description is the catalog description file (.cd), without the .cd suffix (default *.cd)
2256 # - subdir is the destination subdirectory of the catalogs
2257 # - name is the name of the destination catalog, without the .catalog suffix
2258 # - source is the path to the generated source code file
2259 # - dir is the base destination directory (default $(AROS_CATALOGS))
2260 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
2261 # - srcdir is the directory in which the *.cd and *.ct files are searched
2263 %define build_catalogs mmake=/A name=/A subdir=/A \
2264 catalogs= source="../strings.h" description= dir=$(AROS_CATALOGS) \
2265 sourcedescription=$(TOOLDIR)/C_h_aros srcdir=$(SRCDIR)/$(CURDIR)
2267 ifeq (%(description),)
2268 BD_DESC := $(basename $(wildcard %(srcdir)/*.cd))
2270 BD_DESC := %(description)
2273 BD_SRC := $(shell echo %(sourcedescription) | sed 's/^\(.\):\//\/\1\//')
2276 BD_LNGS := $(basename $(notdir $(call WILDCARD, %(srcdir)/*.ct)))
2278 BD_LNGS := %(catalogs)
2281 BD_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, $(BD_LNGS)))
2282 BD_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, $(BD_LNGS))) $(dir %(source))
2285 %(mmake) : $(BD_OBJS) %(source)
2287 $(BD_OBJS) : | $(BD_DIRS)
2288 GLOB_MKDIRS += $(BD_DIRS)
2290 %(dir)/%/%(subdir)/%(name).catalog : %(srcdir)/%.ct $(BD_DESC).cd
2291 @$(ECHO) "Creating %(name) catalog for language $*."
2292 @$(FLEXCAT) $(BD_DESC).cd $< CATALOG="%(dir)/$*/%(subdir)/%(name).catalog" || [ $$? -lt 10 ]
2295 %(source) : BD_DESC := $(BD_DESC)
2296 %(source) : BD_SRC := $(BD_SRC)
2297 %(source) : $(BD_DESC).cd $(BD_SRC).sd | $(dir %(source))
2298 @$(ECHO) "Creating %(name) catalog source file $@"
2299 @$(FLEXCAT) $(BD_DESC).cd $@=$(BD_SRC).sd
2302 %(mmake)-clean : FILES := $(BD_OBJS) %(source)
2305 @$(ECHO) "Cleaning up for metatarget %(mmake)"
2308 .PHONY: %(mmake) %(mmake)-clean
2311 #-----------------------------------------------------------------------------
2314 #-----------------------------------------------------------------------------
2316 # - mmake is the mmaketarget
2317 # - icons is a list of icon base names (ie. without the .info suffix)
2318 # - dir is the destination directory
2319 # - srcdir is where *.png and *.info.src are searched
2320 #-----------------------------------------------------------------------------
2322 %define build_icons mmake=/A icons=/A dir=/A srcdir=$(SRCDIR)/$(CURDIR) image=
2324 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
2327 %(mmake) : $(BD_OBJS)
2331 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%.png
2332 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2333 @$(ILBMTOICON) $+ $@
2337 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%(image)
2338 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2339 @$(ILBMTOICON) $+ $@
2343 $(BD_OBJS) : | %(dir)
2344 GLOB_MKDIRS += %(dir)
2346 %(mmake)-clean : FILES := $(BD_OBJS)
2351 .PHONY: %(mmake) %(mmake)-clean
2354 #-----------------------------------------------------------------------------
2357 #------------------------------------------------------------------------------
2358 # Compile files for an arch-specific replacement of code for a module
2359 # - files: the basenames of the C files to compile.
2360 # - asmfiles: the basenames of the asm files to assemble.
2361 # - mainmmake: the mmake of the module in the main directory to compile these
2362 # arch specific files for.
2363 # - maindir: the object directory for the main module
2364 # - arch: the arch for which to compile these files. It can have the form
2365 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
2366 # - cflags (default $(CFLAGS)): the C flags to use for compilation
2367 # - dflags: the flags used during creation of dependency file. If not specified
2368 # the same value as cflags will be used
2369 # - aflags: the flags used during assembling
2370 # - compiler: (host, kernel or target) specifies which compiler to use. By default
2371 # the target compiler is used
2372 %define build_archspecific files= asmfiles= mainmmake=/A maindir=/A arch=/A \
2373 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
2375 ifeq (%(files) %(asmfiles),)
2376 $(error no files or asmfiles given)
2379 %buildid targets="%(mainmmake)-%(arch)"
2381 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2382 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2383 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2384 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2385 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2386 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2387 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2388 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2389 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2390 #MM- %(mainmmake)-kobj-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2391 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2392 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2393 #MM- %(mainmmake)-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2394 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2395 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2397 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
2399 BD_OBJDIR$(BDID) := $(GENDIR)/%(maindir)/arch
2400 BD_COBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
2401 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
2402 BD_OBJS$(BDID) := $(BD_COBJS$(BDID)) $(BD_ASMOBJS$(BDID))
2403 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
2405 ifneq (%(modulename),)
2406 BD_DEFLIBDEFSINC$(BDID) := -include $(GENDIR)/%(maindir)/include/%(modulename)_deflibdefs.h
2409 ifeq ($(TARGET),%(mainmmake)-%(arch)-quick)
2410 BD_TARGET := %(mainmmake)-%(arch)-quick
2412 BD_TARGET := %(mainmmake)-%(arch)
2416 ifeq ($(TARGET),$(BD_TARGET))
2417 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
2418 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(files)))
2419 vpath %.s $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2420 vpath %.S $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2423 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID))
2424 GLOB_MKDIRS += $(BD_OBJDIR$(BDID))
2427 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
2430 %(mainmmake)-%(arch)-quick :: $(BD_OBJS$(BDID))
2432 ifeq ($(findstring %(compiler),host kernel target),)
2433 $(error unknown compiler %(compiler))
2435 ifeq (%(compiler),target)
2436 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_CFLAGS)
2437 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
2438 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
2440 ifeq (%(compiler),host)
2441 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(HOST_CC)
2442 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
2443 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
2445 ifeq (%(compiler),kernel)
2446 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_CFLAGS)
2447 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
2448 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
2450 ifneq (%(modulename),)
2451 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) $(BD_DEFLIBDEFSINC$(BDID))
2453 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
2455 ifeq ($(TARGET),$(BD_TARGET))
2456 $(BD_OBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2457 %compile_q cmd=$(TMP_CMD) opt=$(TMP_CFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2461 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags) $(BD_DEFLIBDEFSINC$(BDID))
2463 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
2465 ifeq ($(TARGET),$(BD_TARGET))
2466 $(BD_OBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2467 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
2470 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
2472 ifeq ($(TARGET),$(BD_TARGET))
2473 $(BD_OBJDIR$(BDID))/%.o : %.s
2474 %assemble_q opt=$(AFLAGS)
2475 $(BD_OBJDIR$(BDID))/%.o : %.S
2476 %assemble_q opt=$(AFLAGS)
2479 %include_deps depstargets=$(BD_TARGET) deps=$(BD_DEPS$(BDID))
2481 #------------------------------------------------------------------------------
2484 #------------------------------------------------------------------------------
2485 # generate asm files from c files (for debugging purposes)
2488 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
2489 @$(TARGET_CC) $(TARGET_SYSROOT) -S $(CFLAGS) $(TARGET_CFLAGS) $< -c -o $@
2491 #------------------------------------------------------------------------------
2494 #------------------------------------------------------------------------------
2495 # Copy files from one directory to another.
2497 %define copy_files_q mmake=/A files=$(FILES) src=. dst=/A
2499 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
2501 GLOB_MKDIRS += %(dst)
2507 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC))/, $(file)) $(addprefix %(dst)/, $(file))))
2510 #------------------------------------------------------------------------------
2513 #------------------------------------------------------------------------------
2514 # Copy a directory recursively to another place, preserving the original
2515 # hierarchical structure
2517 # src: the source directory whose content will be copied.
2518 # dst: the directories where to copy src's content. If not existing, they will be made.
2519 # excludefiles: files which must not be copied. Path must be relative to src.
2521 %define copy_dir_recursive mmake=/A src=. dst=/A excludefiles=
2527 @cd $(SRCDIR)/$(CURDIR) && $(CPYDIRREC) -s %(src) -d %(dst) -e %(excludefiles)
2530 #------------------------------------------------------------------------------
2533 #------------------------------------------------------------------------------
2534 # Copy include files into the includes directories. There are currently
2535 # two include directories. One for building AROS $(AROS_INCLUDES) and one
2536 # for building tools that need to run on the host system $(GENINCDIR). The
2537 # $(GENINCDIR) path must not contain any references to the C runtime
2538 # library header files.
2540 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
2541 dir= compiler=target includedir=$(AROS_INCLUDES)
2543 ifeq ($(findstring %(compiler),host kernel target),)
2544 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
2549 $(eval TMP_DIRREMAIN := $$$(TMP_DIR))
2550 TMP_DIRFIRST := $(subst $(TMP_DIRREMAIN),,$(TMP_DIR))
2551 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),$(dir %(includes)))
2552 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,$(notdir %(includes)))
2553 ifeq ($(TMP_DIRFIRST),/)
2554 BD_INC_PATH := %(dir)/
2556 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
2559 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
2560 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
2563 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
2567 ifeq (%(compiler),target)
2570 BD_INCL_FILES2 := $(subst %(dir),%(includedir)/%(path),$(dir %(includes)))
2571 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,$(notdir %(includes)))
2573 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,%(includes))
2576 BD_INCL_FILES += $(BD_INCL_FILES2)
2578 $(BD_INCL_FILES2) : %(includedir)/%(path)/% : $(BD_INC_PATH)%
2583 %(mmake) : $(BD_INCL_FILES)
2587 $(BD_INCL_FILES) : | $(dir $(BD_INCL_FILES))
2588 GLOB_MKDIRS += $(dir $(BD_INCL_FILES))
2590 #------------------------------------------------------------------------------
2593 #------------------------------------------------------------------------------
2594 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
2595 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
2596 STUBS_MEM := $(addsuffix .o,$(STUBS))
2597 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
2598 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
2599 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
2601 #MM- linklibs : hidd-%(hidd)-stubs
2602 #MM- %(parenttarget): hidd-%(hidd)-stubs
2603 #MM hidd-%(hidd)-stubs : includes includes-copy
2604 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
2606 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
2609 $(STUBS_OBJ) : $(STUBS_SRC)
2610 %compile_q cmd="$(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_CFLAGS)" opt="%(cflags)" iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
2612 $(STUBS_DEP) : $(STUBS_SRC)
2613 %mkdepend_q flags="%(dflags)"
2616 %mkdirs_q $(OBJDIR) $(AROS_LIB)
2620 -@$(RM) $(HIDD_LIB) $(OBJDIR)
2622 DEPS := $(DEPS) $(STUBS_DEP)
2625 #------------------------------------------------------------------------------
2628 #------------------------------------------------------------------------------
2629 # Build an imported source tree which uses the configure script from the
2630 # autoconf package. This rule will try to "integrate" the produced files as
2631 # much as possible in the AROS build, for example by putting libraries in the
2632 # standard library directory, includes in the standard include directory, and
2633 # so on. You can however override this behaviour.
2635 # As a special "bonus" for you, the PROGDIR environment variable is defined to
2636 # be %(bindir) (or its deduced value) when running "make install", and
2637 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
2638 # configure script some more parameters whose value depends upon the PROGDIR
2639 # env var, so that the program gets all its stuff installed in the proper place
2640 # when building it, but when running it from inside AROS it can also find that
2641 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
2642 # the configuration parameters set when running ./configure
2644 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
2645 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
2646 # to the name which has to follow it.
2650 # - mmake = the meta make target.
2651 # - package = name of the package to be built.
2652 # - srcdir = the location of the unpacked source code. Defaults
2653 # to $(SRCDIR)/$(CURDIR).
2654 # - prefix = the target directory. Must be an absolute path of the
2655 # host system. Defaults to $(AROS_CONTRIB).
2656 # - aros_prefix = set a path which is valid within the AROS filesystem.
2657 # Defaults to the value of the prefix option.
2658 # - extraoptions = additional options for the configure script.
2659 # - extracflags = additional flags to use with the C compiler.
2660 # - extracxxflags = additional flags to use with the C++ compiler.
2661 # - nix_dir_layout = if yes the binary will be stored in a bin subdirectory.
2662 # Defaults to the value of the nix argument.
2663 # - nix = enable u*nix path handling, i.e. a path like
2664 # /progdir//./file will be translated to
2665 # progdir:file during run-time. Defaults to no.
2666 # - compiler = target, host or kernel. Defaults to target.
2667 # - install_target = the command used for installing. Defaults to install. Leave
2668 # it empty if you want to suppress installing.
2669 # - preconfigure = a metatarget which is executed before configure is called.
2670 # - postconfigure = a metatarget which is executed after configure is called.
2671 # - postinstall = a metatarget which is executed after installing.
2672 # - install_env = set additional options for installing.
2673 # - use_build_env = if yes the configuration environment is used for
2674 # installing, too. Defaults to no.
2676 # The arguments aros_prefix, nix and nix_dir_layout are related. The logic is
2680 # --prefix = $(aros_prefix)
2681 # progdir = $(aros_prefix)/bin
2684 # --prefix = /PROGDIR
2685 # --bindir = /PROGDIR
2686 # --sbindir = /PROGDIR
2688 # --includedir = /INCLUDE
2689 # --oldincludedir = /INCLUDE
2691 # --prefix = $(aros_prefix)
2694 # progdir = $(aros_prefix)
2697 # bindir = $(prefix)
2698 # sbindir = $(prefix)
2699 # libdir = $(AROS_LIB)
2700 # includedir = $(AROS_INCLUDES)
2701 # oldincludedir = $(AROS_INCLUDES)
2705 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) gendir= prefix= \
2706 aros_prefix= extraoptions= extracflags= extracxxflags= nix_dir_layout= nix=no compiler=target \
2707 install_target=install preconfigure= postconfigure= postinstall= \
2708 config_env_extra= install_env= use_build_env=no
2711 %(mmake)-prefix := %(prefix)
2713 %(mmake)-prefix := $(AROS_CONTRIB)
2716 ifneq (%(aros_prefix),)
2717 %(mmake)-aros_prefix := %(aros_prefix)
2719 %(mmake)-aros_prefix := $(%(mmake)-prefix)
2725 %(mmake)-nix := $(BD_NIXFLAG)
2726 %(mmake)-volpfx := /
2727 %(mmake)-volsfx := /
2729 ifeq (%(nix_dir_layout),)
2730 %(mmake)-nix_dir_layout := yes
2733 %(mmake)-volsfx := :
2735 ifeq (%(nix_dir_layout),)
2736 %(mmake)-nix_dir_layout := no
2740 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
2742 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
2743 exec_prefix=$(%(mmake)-prefix) %(install_env)
2745 # Check if chosen compiler is valid
2746 ifeq ($(findstring %(compiler),host target kernel),)
2747 $(error unknown compiler %(compiler))
2750 # Set legacy 'host' variable based on chosen compiler
2751 ifeq (%(compiler),host)
2754 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
2756 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
2761 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
2763 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
2768 %(mmake)-pkgdir := %(gendir)/$(CURDIR)
2770 %(mmake)-pkgdir := %(gendir)/$(CURDIR)/%(package)
2774 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
2775 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
2777 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
2778 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
2779 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2782 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
2783 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
2785 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2788 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
2790 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
2791 sbindir=$(%(mmake)-prefix) \
2792 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
2793 oldincludedir=$(AROS_INCLUDES) %(install_env)
2796 ifneq ($(DEBUG),yes)
2797 %(mmake)-s_flag = -s
2800 # Set up build environment, and options for configure script
2801 ifeq (%(compiler),host)
2802 # NB: We need to pass in our crosstoolsdir, but cannot set CLFAGS since it
2803 # confused configure scripts. We also cannot pass it via _FOR_BUILD
2804 # since that wont get picked up during configure.
2805 # We also cannot pass in the compiler including std flags so we need to use
2806 # the "plain" host compiler.
2807 CONFIG_ENV := %(config_env_extra) \
2809 CXXCPP="$(HOST_CPP)" \
2810 CC="$(HOST_DEF_CC) $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include" \
2811 CXX="$(HOST_CXX) $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include" \
2812 LDFLAGS="-L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS)" \
2813 TARGET_CC="$(KERNEL_CC) $(KERNEL_SYSROOT)" \
2814 TARGET_CFLAGS="$(KERNEL_CFLAGS) $(%(mmake)-s_flag)" \
2815 TARGET_CXX="$(KERNEL_CXX) $(KERNEL_SYSROOT)" \
2816 TARGET_CXXFLAGS="$(KERNEL_CXXFLAGS) $(%(mmake)-s_flag)" \
2817 TARGET_AS="$(TARGET_AS)" \
2818 OBJCOPY="$(OBJCOPY)" \
2819 TARGET_RANLIB="$(RANLIB)" \
2820 TARGET_STRIP="$(STRIP_PLAIN)" \
2821 TARGET_NM="$(NM_PLAIN)" \
2822 TARGET_OBJCOPY="$(TARGET_OBJCOPY)"
2824 ifeq (%(compiler),target)
2825 CONFIG_ENV := %(config_env_extra) \
2826 PKG_CONFIG_LIBDIR="$(AROS_DEVELOPMENT)/lib/pkgconfig" \
2827 PKG_CONFIG_SYSROOT_DIR="$(AROSDIR)" \
2828 CPP="$(TARGET_CPP) $(TARGET_SYSROOT)" \
2829 CXXCPP="$(TARGET_CPP) $(TARGET_SYSROOT)" \
2830 CC="$(TARGET_CC) $(TARGET_SYSROOT)" \
2831 CFLAGS=" $(TARGET_CFLAGS) $(DEBUG_CFLAGS) $(OPTIMIZATION_CFLAGS) %(extracflags) $(ISA_FLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2832 CXX="$(TARGET_CXX) $(TARGET_SYSROOT)" \
2833 CXXFLAGS=" $(TARGET_CXXFLAGS) $(DEBUG_CFLAGS) $(OPTIMIZATION_CFLAGS) %(extracxxflags) $(ISA_FLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2834 LDFLAGS="-L$(AROS_DEVELOPMENT)/lib $(USER_LDFLAGS)" \
2836 CC_FOR_BUILD="$(HOST_DEF_CC)" \
2837 CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
2838 CXX_FOR_BUILD="$(HOST_CXX)" \
2839 CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
2840 RANLIB="$(RANLIB)" \
2842 STRIP="$(STRIP_PLAIN)" \
2843 TARGET_CC="$(KERNEL_CC) $(KERNEL_SYSROOT)" \
2844 TARGET_CFLAGS="$(KERNEL_CFLAGS) $(%(mmake)-s_flag)" \
2845 TARGET_CXX="$(KERNEL_CXX) $(KERNEL_SYSROOT)" \
2846 TARGET_CXXFLAGS="$(KERNEL_CXXFLAGS) $(%(mmake)-s_flag)" \
2847 TARGET_AS="$(TARGET_AS)" \
2848 OBJCOPY="$(OBJCOPY)" \
2849 TARGET_RANLIB="$(RANLIB)" \
2850 TARGET_STRIP="$(STRIP_PLAIN)"\
2851 TARGET_NM="$(NM_PLAIN)" \
2852 CC_FOR_TARGET="$(TARGET_CC) $(TARGET_SYSROOT)" \
2853 CFLAGS_FOR_TARGET="$(TARGET_CFLAGS) -L$(AROS_DEVELOPMENT)/lib %(extracflags) $(ISA_FLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2854 CXX_FOR_TARGET="$(TARGET_CXX) $(TARGET_SYSROOT)" \
2855 CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS) -L$(AROS_DEVELOPMENT)/lib %(extracxxflags) $(ISA_FLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)"
2856 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)\
2857 --host=$(AROS_TARGET_CPU)-aros\
2858 --target=$(AROS_TARGET_CPU)-aros\
2860 --without-x --without-pic --disable-shared
2862 ifeq (%(compiler),kernel)
2863 CONFIG_ENV := %(config_env_extra) \
2864 CPP="$(KERNEL_CPP)" \
2865 CXXCPP="$(KERNEL_CPP)" \
2866 CC="$(KERNEL_CC) $(KERNEL_SYSROOT)" \
2867 CFLAGS="$(KERNEL_CFLAGS) %(extracflags) $(%(mmake)-s_flag)" \
2868 CXX="$(KERNEL_CXX) $(KERNEL_SYSROOT)" \
2869 CXXFLAGS="$(KERNEL_CXXFLAGS) %(extracxxflags) $(%(mmake)-s_flag)" \
2871 CC_FOR_BUILD="$(HOST_DEF_CC)" \
2872 CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
2873 CXX_FOR_BUILD="$(HOST_CXX)" \
2874 CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
2875 RANLIB="$(RANLIB)" \
2876 TARGET_RANLIB="$(RANLIB)" \
2877 TARGET_STRIP="$(STRIP_PLAIN)" \
2878 TARGET_NM="$(NM_PLAIN)"
2879 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)\
2880 --host=$(AROS_TARGET_CPU)-aros\
2881 --target=$(AROS_TARGET_CPU)-aros --disable-nls\
2882 --without-x --without-pic --disable-shared
2885 ifeq (%(use_build_env),yes)
2886 BUILD_ENV := $(CONFIG_ENV)
2889 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
2891 # When building for the host, we don't need to build the
2892 # linklibs - this is especially true when building the
2893 # crosstool toolchain on 'foreign' architectures (such as
2894 # building PPC on x86)
2896 #MM- %(mmake)-host : setup includes %(mmake)-quick
2897 #MM- %(mmake)-target : setup includes core-linklibs %(mmake)-quick
2898 #MM- %(mmake): %(mmake)-%(compiler)
2900 # Using -j1 in install_command may result in a warning but finally
2901 # it does its job. make install for gcc does not work reliably for -jN
2903 ifneq (%(install_target),)
2904 %(mmake)-install_command = \
2905 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2906 -C $(%(mmake)-pkgdir) %(install_target) -j1
2908 %(mmake)-uninstall_command = \
2909 $(RM) $(%(mmake)-installflag) && \
2910 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" \
2911 $(%(mmake)-install_opts) -C $(%(mmake)-pkgdir) uninstall
2913 %(mmake)-install_command := true
2914 %(mmake)-uninstall_command := true
2917 #MM- %(mmake)-quick : %(preconfigure) %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
2920 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
2922 $(%(mmake)-installflag) : $(%(mmake)-configflag)
2923 if ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q -C $(%(mmake)-pkgdir); then \
2924 $(RM) $(%(mmake)-installflag) && \
2925 $(BUILD_ENV) $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)"\
2926 -C $(%(mmake)-pkgdir) && \
2927 $(%(mmake)-install_command) && \
2928 $(TOUCH) $@ -r $^; \
2931 $(%(mmake)-pkgdir)/.files-touched:
2932 %mkdirs_q $(%(mmake)-pkgdir)
2933 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/configure '{}' \; && \
2937 %(mmake)-uninstall :
2938 $(%(mmake)-uninstall_command)
2941 %(mmake)-configure : $(%(mmake)-configflag)
2943 $(%(mmake)-configflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
2944 $(%(mmake)-configflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2946 %mkdirs_q $(%(mmake)-pkgdir)
2947 cd $(%(mmake)-pkgdir) && \
2948 find . -name config.cache -exec $(RM) '{}' \; && \
2949 $(CONFIG_ENV) $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) \
2950 %(extraoptions) && \
2954 %(mmake)-clean : %(mmake)-uninstall
2955 @$(RM) $(%(mmake)-pkgdir)
2957 #------------------------------------------------------------------------------
2960 #------------------------------------------------------------------------------
2961 # Build an imported source tree which uses cmake
2965 # - mmake = the meta make target.
2966 # - package = name of the package to be built.
2967 # - srcdir = the location of the unpacked source code. Defaults
2968 # to $(SRCDIR)/$(CURDIR).
2969 # - prefix = the target directory. Must be an absolute path of the
2970 # host system. Defaults to $(AROS_CONTRIB).
2971 # - aros_prefix = set a path which is valid within the AROS filesystem.
2972 # Defaults to the value of the prefix option.
2973 # - extraoptions = additional options for the cmake script.
2974 # - installoptions = additional options for the install step.
2977 %define build_with_cmake mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) gendir= prefix= \
2978 aros_prefix= extraoptions= installoptions= maketarget= compiler=target \
2979 cflags=$(CFLAGS) cxxflags=$(CXXFLAGS) ldflags=$(LDFLAGS)
2982 %(mmake)-prefix := %(prefix)
2984 %(mmake)-prefix := $(AROS_CONTRIB)
2987 ifneq (%(aros_prefix),)
2988 %(mmake)-aros_prefix := %(aros_prefix)
2990 %(mmake)-aros_prefix := $(%(mmake)-prefix)
2993 ifeq (%(compiler),host)
2994 BD_LDFLAGS := -L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS)
2995 BD_CFLAGS := $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include
2996 BD_CXXFLAGS := $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include
2997 %(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)"
2999 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
3001 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
3004 BD_LDFLAGS := %(ldflags)
3005 BD_CFLAGS := %(cflags)
3006 BD_CXXFLAGS := %(cxxflags)
3007 %(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)"
3009 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
3011 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
3016 %(mmake)-pkgdir := %(gendir)/$(CURDIR)
3018 %(mmake)-pkgdir := %(gendir)/$(CURDIR)/%(package)
3022 %(mmake)-cmakeflag := $(%(mmake)-pkgdir)/.cmake
3023 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
3025 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3027 #MM- %(mmake): setup includes core-linklibs %(mmake)-quick
3029 #MM- %(mmake)-quick : %(mmake)-cmake %(mmake)-build_and_install-quick
3032 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3034 $(%(mmake)-installflag) : $(%(mmake)-cmakeflag)
3035 if ! $(MAKE) -q -C $(%(mmake)-pkgdir); then \
3036 $(RM) $(%(mmake)-installflag) && \
3037 $(MAKE) -C $(%(mmake)-pkgdir) %(maketarget) && \
3038 cd $(%(mmake)-pkgdir) && \
3039 cmake %(installoptions) -P cmake_install.cmake && \
3040 $(TOUCH) $@ -r $^; \
3043 $(%(mmake)-pkgdir)/.files-touched:
3044 %mkdirs_q $(%(mmake)-pkgdir)
3045 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/CMakeLists.txt '{}' \; && \
3049 %(mmake)-cmake : $(%(mmake)-cmakeflag)
3051 $(%(mmake)-cmakeflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
3052 $(%(mmake)-cmakeflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
3054 %mkdirs_q $(%(mmake)-pkgdir)
3055 cd $(%(mmake)-pkgdir) && \
3056 $(RM) -Rf CMakeCache.txt CMakeFiles \; && \
3057 cmake $(%(mmake)-cmake_opts) %(extraoptions) $(TMP_SRCDIR) && \
3061 %(mmake)-clean : %(mmake)-uninstall
3062 @$(RM) $(%(mmake)-pkgdir)
3064 #------------------------------------------------------------------------------
3067 #------------------------------------------------------------------------------
3068 # Given an archive name, patches names and locations where to find them, fetch
3069 # the archive and the patches from any of those locations, unpack the archive
3070 # and then apply the patches.
3072 # Locations currently supported are http and ftp sites, plus local filesystem
3073 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
3074 # the fetch.sh script needs to be modified, since this macro relies on that script.
3078 # - mmake = mmaketarget
3079 # - archive_origins = list of locations where to find the archive. They are tried
3080 # in sequence, until the archive is found and fetching it
3081 # succeeded. If not specified, the current directory is assumed.
3082 # - archive = the archive name. Mandatory.
3083 # - suffixes = a list of suffixes to append to the the package name plus the
3084 # version. Each one of them is tried until a matching archive is
3085 # found. They are appended to patches and these are tried the
3086 # same way as packages are.
3087 # - location = the local directory where to put the fetched archive and patches.
3088 # If not specified, the directory specified by destination is used.
3089 # - destination = the directory to unpack the archive to.
3090 # If not specified, the current directory is assumed.
3091 # - patches_origins = list of locations where to find the patches. They are tried
3092 # in sequence, until a patch is found and fetching it
3093 # succeeded. If not specified, the current directory is assumed.
3094 # - patches_specs = list of "patch specs". A patch spec is of the form
3095 # patch_name[:[patch_subdir][:patch_opt]].
3097 # - patch_name = the name of the patch file
3098 # - patch_subdir = the directory within \destination\ where to
3100 # - patch_opt = any options to pass to the `patch' command
3101 # when applying the patch.
3103 # The patch_subdir and patch_opt fields are optional.
3105 %define fetch mmake=/A archive_origins=. archive=/A suffixes= location= destination=. \
3106 patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
3110 ifneq (%(location),)
3111 %(mmake)-location := %(location)
3113 %(mmake)-location := %(destination)
3118 $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
3119 -d %(destination) -po "%(patches_origins)" -p "%(patches_specs)"
3121 #------------------------------------------------------------------------------
3124 #------------------------------------------------------------------------------
3125 # This macro can aid in patch creation for fetched ports. It temporarily creates another
3126 # unpatched source tree and runs diff against this and a previously fetched and possibly
3127 # patched tree. Depending on what happens after patching during a normal build it might
3128 # give best results if the new patch is created directly after fetch.
3132 # - mmake = mmaketarget
3133 # - archive = archive base name
3134 # - srcdir = the top level directory the package is unpacked to, useful if
3135 # an archive unpacks to a directory other than its name suggests.
3136 # this should not be deeper than a single path element.
3137 # - suffixes = a list of suffixes to append to the the package name plus the
3138 # version. Each one of them is tried until a matching archive is
3140 # - destination = the directory to unpack the archive to.
3141 # - excludes = diff patterns to exclude files or directories from the patch
3143 %define create_patch mmake=/A archive=/A srcdir= suffixes="tar.bz2 tar.gz" destination=/A excludes=
3147 ifneq (%(excludes),)
3148 %(mmake)-exclude := -X ./exclude.patterns
3152 %(mmake)-srcdir := %(srcdir)
3154 %(mmake)-srcdir := %(archive)
3157 #MM- %(mmake) : %(mmake)-diff
3158 #MM- %(mmake)-quick : %(mmake)-diff
3162 @$(FETCH) -a %(archive) -s "%(suffixes)" -l $(PORTSSOURCEDIR) -d %(destination)/tmp ; \
3163 $(MV) %(destination)/$(%(mmake)-srcdir) %(destination)/tmp/$(%(mmake)-srcdir).aros ; \
3164 cd %(destination)/tmp ; \
3165 $(FOR) f in %(excludes) ; do \
3166 $(ECHO) $$f >> ./exclude.patterns ; \
3168 diff -ruN $(%(mmake)-exclude) \
3169 $(%(mmake)-srcdir) \
3170 $(%(mmake)-srcdir).aros \
3171 >$(SRCDIR)/$(CURDIR)/%(archive)-aros-new.diff ; \
3172 $(MV) %(destination)/tmp/$(%(mmake)-srcdir).aros %(destination)/$(%(mmake)-srcdir) ; \
3173 $(RM) %(destination)/tmp
3175 #------------------------------------------------------------------------------
3178 #------------------------------------------------------------------------------
3179 # Joins the features of %fetch and %build_with_configure.
3181 # If a patch is provided, it *must* be named the following way:
3183 # <package name>-<version number>-aros.diff
3185 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3186 # CD'ing into the archive's extracted directory.
3188 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3189 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3190 # to make that patch fully comprehensive.
3194 # - mmake = the meta make target.
3195 # - package = the GNU package name, sans version and archive format suffixes.
3196 # - subpackage = ???
3197 # - compiler = same meaning as the one for the %build_with_configure macro.
3198 # - install_target = same meaning as the one for the %build_with_configure macro.
3199 # - version = the package's version number, or otherwise any other version string.
3200 # It gets appended to the package name to form the basename of the archive.
3201 # - suffixes = a list of suffixes to apped to the the package name plus the
3202 # version. Each one of them is tried until a matching archive is found.
3203 # Defaults to "tar.bz2 tar.gz".
3204 # - srcdir = the top level directory the package is unpacked to (see create_patch).
3205 # - builddir = override the location we expect to run configure/make in.
3206 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
3207 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
3208 # fetched or not. Default to no.
3209 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
3210 # - prefix = same meaning as the one for the %build_with_configure macro.
3211 # - aros_prefix = same meaning as the one for the %build_with_configure macro.
3212 # - extraoptions = same meaning as the one for the %build_with_configure macro.
3213 # - extracflags = same meaning as the one for the %build_with_configure macro.
3214 # - extracxxflags = same meaning as the one for the %build_with_configure macro.
3215 # - preconfigure = same meaning as the one for the %build_with_configure macro.
3216 # - postconfigure = same meaning as the one for the %build_with_configure macro.
3217 # - postinstall = same meaning as the one for the %build_with_configure macro.
3218 # - install_env = same meaning as the one for the %build_with_configure macro.
3219 # - use_build_env = same meaning as the one for the %build_with_configure macro.
3220 # - nix = same meaning as the one for the %build_with_configure macro.
3221 # - nix_dir_layout = same meaning as the one for the %build_with_configure macro.
3222 # - create_pkg = create a distributable package of the compiled sources, defaults to no
3224 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target install_target=install \
3225 version=/A suffixes="tar.bz2 tar.gz" srcdir= builddir= gendir= package_repo= patch=no patch_repo= \
3226 prefix= aros_prefix= extraoptions= extracflags= extracxxflags= preconfigure= postconfigure= postinstall= \
3227 config_env_extra= install_env= use_build_env=no nix=no nix_dir_layout= create_pkg=no
3229 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
3230 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
3231 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
3232 #MM- %(mmake)-create-patch : %(mmake)-%(subpackage)-create-patch
3234 %(mmake)-archbase := %(package)-%(version)
3236 ifeq (%(compiler),host)
3237 %(mmake)-portdir := $(HOSTDIR)/Ports/host/%(package)
3239 %(mmake)-portdir := $(PORTSDIR)/%(package)
3243 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
3245 %(mmake)-prefix := %(prefix)
3248 ifneq (%(subpackage),)
3249 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
3251 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
3255 %(mmake)-%(subpackage)-srcdir := %(srcdir)
3257 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
3260 ifneq (%(builddir),)
3261 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)/%(builddir)
3263 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)
3267 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-f,-p1
3269 %(mmake)-%(subpackage)-patches_specs := ::
3272 %fetch mmake="%(mmake)-%(subpackage)-fetch" archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
3273 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
3274 archive_origins=". %(package_repo)" \
3275 patches_specs=$(%(mmake)-%(subpackage)-patches_specs) patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
3277 %create_patch mmake="%(mmake)-%(subpackage)-create-patch" \
3278 archive=$(%(mmake)-%(subpackage)-archbase) \
3279 srcdir=$(%(mmake)-%(subpackage)-srcdir) \
3280 suffixes="%(suffixes)" \
3281 destination=$(%(mmake)-portdir)
3283 #MM- %(mmake) : %(mmake)-%(subpackage)
3285 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
3287 %(mmake)-%(subpackage)-package-basename := \
3288 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
3290 ifneq (%(create_pkg),no)
3291 %(mmake)-%(subpackage)-package := $(%(mmake)-%(subpackage)-package-basename).tar.bz2
3294 %build_with_configure mmake="%(mmake)-%(subpackage)" package="%(package)" compiler="%(compiler)" install_target="%(install_target)" \
3295 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-builddir) gendir="%(gendir)" \
3296 config_env_extra="%(config_env_extra)" install_env="%(install_env)" use_build_env="%(use_build_env)" \
3297 nix="%(nix)" nix_dir_layout="%(nix_dir_layout)" prefix=$(%(mmake)-prefix) \
3298 aros_prefix="%(aros_prefix)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
3299 %(mmake)-%(subpackage)-make-package" extraoptions="%(extraoptions)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)"
3301 .PHONY : %(mmake)-%(subpackage)-make-package %(mmake)-%(subpackage)-create-patch
3302 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
3305 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package)
3307 #There seems to be a bug, either with my clock or with make, 'cause it may happen
3308 #that $^ and $@ have exactly the same mtime, and in that case make tries
3309 #to rebuild $@ again, which would fail because the directory where
3310 #the package got installed would not exist anymore.
3311 #We work this around by using an if statement to manually check the mtimes.
3312 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
3313 @$(IF) test $(%(mmake)-installflag) -nt $@ || ! test -f $@; then \
3315 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
3316 mkdir -p "$(DISTDIR)/Packages" ; \
3317 mkdir -p "$(%(mmake)-prefix)" ; \
3318 cd $(%(mmake)-%(subpackage)-package-dir) ; \
3319 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
3320 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
3323 #------------------------------------------------------------------------------
3326 #------------------------------------------------------------------------------
3327 # Joins the features of %fetch and %build_with_configure, taking advantage of
3328 # the naming scheme of GNU packages. GNU packages names are in the form
3330 # <package name>-<version number>.<archive format suffix>
3332 # If a patch is provided, it *must* be named the following way:
3334 # <package name>-<version number>-aros.diff
3336 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3337 # CD'ing into the archive's extracted directory.
3339 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3340 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3341 # to make that patch fully comprehensive.
3343 # NOTE: GNU packages are always compiled with *nix semantics turned on.
3347 # Arguments have the same meaning as the one for the %fetch_and_build macro, except:
3349 # - prefix = defaults to $(GNUDIR).
3350 # - aros_prefix = defaults to /GNU.
3352 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
3353 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
3354 aros_prefix=/GNU extraoptions= extracflags= extracxxflags= config_env_extra= preconfigure= postconfigure= postinstall=
3356 GNU_REPOSITORY := gnu://
3358 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
3359 suffixes="%(suffixes)" srcdir="%(srcdir)" \
3360 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
3361 patch="%(patch)" patch_repo="%(patch_repo)" \
3362 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)" \
3363 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=yes
3366 #------------------------------------------------------------------------------
3369 #------------------------------------------------------------------------------
3370 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
3371 # that the package is a "Development" package, and as such it needs to be placed
3372 # under the $(AROS_DEVELOPMENT) directory, as a default.
3374 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
3375 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
3376 # "mmake" argument, because the metatarget is implicitely defined as
3378 # #MM- development-%(package)
3380 %define fetch_and_build_gnu_development package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
3381 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPMENT) \
3382 aros_prefix=/Development config_env_extra= preconfigure= postconfigure= postinstall= extraoptions= extracflags= extracxxflags=
3384 #MM- development : development-%(package)
3387 %fetch_and_build_gnu mmake="development-%(package)" package="%(package)" subpackage="%(subpackage)" \
3388 version="%(version)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
3389 package_repo="%(package_repo)" patch="%(patch)" patch_repo="%(patch_repo)" prefix="%(prefix)" \
3390 aros_prefix="%(aros_prefix)" config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="postinstall-%(package)-delete-la-files %(postinstall)" \
3391 extraoptions="%(extraoptions)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)"
3394 postinstall-%(package)-delete-la-files:
3395 $(RM) $(AROS_DEVELOPMENT)/lib/*.la
3398 #------------------------------------------------------------------------------
3400 # Builds a kickstart package in PKG format
3404 # - mmake = target name
3405 # - file = destination file name with path
3407 # Other arguments are self-explanatory
3409 %define make_package mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
3410 arch_classes= arch_devs= arch_handlers= arch_hidds= arch_libs= arch_res=
3412 PKG_CLASSES := $(addprefix $(AROS_CLASSES)/,$(addsuffix .class, %(classes)))
3413 PKG_DEVICES := $(addprefix $(AROS_DEVS)/,$(addsuffix .device, %(devs)))
3414 PKG_HANDLERS := $(addprefix $(AROS_FS)/,$(addsuffix -handler, %(handlers)))
3415 PKG_HIDD := $(addprefix $(AROS_DEVS)/Drivers/,$(addsuffix .hidd, %(hidds)))
3416 PKG_LIBS := $(addprefix $(AROS_LIBRARIES)/,$(addsuffix .library, %(libs)))
3417 PKG_RESOURCES := $(addprefix $(AROS_DEVS)/,$(addsuffix .resource, %(res)))
3419 PKG_CLASSES_ARCH := $(addprefix $(AROS_CLASSES_ARCH)/,$(addsuffix .class, %(arch_classes)))
3420 PKG_DEVICES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .device, %(arch_devs)))
3421 PKG_HANDLERS_ARCH := $(addprefix $(AROS_FS_ARCH)/,$(addsuffix -handler, %(arch_handlers)))
3422 PKG_HIDD_ARCH := $(addprefix $(AROS_DEVS_ARCH)/Drivers/,$(addsuffix .hidd, %(arch_hidds)))
3423 PKG_LIBRARIES_ARCH := $(addprefix $(AROS_LIBRARIES_ARCH)/,$(addsuffix .library, %(arch_libs)))
3424 PKG_RESOURCES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .resource, %(arch_res)))
3426 PKG_FILES := $(PKG_CLASSES) $(PKG_DEVICES) $(PKG_HANDLERS) $(PKG_HIDD) $(PKG_LIBS) $(PKG_RESOURCES) \
3427 $(PKG_CLASSES_ARCH) $(PKG_DEVICES_ARCH) $(PKG_HANDLERS_ARCH) $(PKG_HIDD_ARCH) $(PKG_LIBRARIES_ARCH) $(PKG_RESOURCES_ARCH)
3428 PKG_DIR := $(dir %(file))
3434 %(mmake)-quick : %(file)
3436 %(file): $(PKG_FILES) | $(PKG_DIR)
3437 @$(ECHO) Packaging $@...
3438 @$(SRCDIR)/tools/package/pkg c $@ $^
3440 %compress_file mmake="%(mmake)" file="%(file)"
3442 GLOB_MKDIRS += $(PKG_DIR)
3446 #------------------------------------------------------------------------------
3447 # Compresses %(file) with a gzip.
3448 # Good in conjunction with for example %build_prog
3450 %define compress_file mmake=/A file=/A
3452 #MM- %(mmake)-gz : %(mmake) %(mmake)-gz-quick
3455 %(mmake)-gz-quick : %(file).gz
3458 @$(ECHO) Compressing $(subst $(TARGETDIR)/,,$^)...
3463 #------------------------------------------------------------------------------
3464 # Links a kickstart module in ELF format
3465 # Arguments are similar to make_package
3467 %define link_kickstart mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
3468 startup= uselibs= ldflags=$(LDFLAGS) map= deps=
3470 KOBJ_CLASSES := $(addprefix $(KOBJSDIR)/, $(addsuffix _class.o, %(classes)))
3471 KOBJ_DEVICES := $(addprefix $(KOBJSDIR)/, $(addsuffix _device.o, %(devs)))
3472 KOBJ_HANDLERS := $(addprefix $(KOBJSDIR)/, $(addsuffix _handler.o, %(handlers)))
3473 KOBJ_HIDD := $(addprefix $(KOBJSDIR)/, $(addsuffix _hidd.o, %(hidds)))
3474 KOBJ_LIBS := $(addprefix $(KOBJSDIR)/, $(addsuffix _library.o, %(libs)))
3475 KOBJ_RES := $(addprefix $(KOBJSDIR)/, $(addsuffix _resource.o, %(res)))
3478 KOBJ_STARTUP := $(GENDIR)/$(RESIDENT_BEGIN).o
3480 KOBJ_STARTUP := %(startup)
3483 KOBJS := $(KOBJ_STARTUP) $(KOBJ_CLASSES) $(KOBJ_HANDLERS) $(KOBJ_LIBS) $(KOBJ_DEVICES) $(KOBJ_HIDD) $(KOBJ_RES)
3485 TMP_LDFLAGS := %(ldflags)
3487 # Make a list of the lib files this program depends on.
3488 # In LDFLAGS remove white space between -L and directory
3489 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
3490 # Filter out only the libdirs and remove -L
3491 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
3493 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
3494 # Add normal linklib path
3495 TMP_DIRS += $(AROS_LIB)/
3496 # add lib and .a to static linklib names
3497 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
3498 # search for the linklibs in the given path, ignore ones not found
3499 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
3500 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
3503 TMP_DIRS += $(dir %(file))
3505 TMP_LDFLAGS += $(GENMAP) %(map)
3506 TMP_DIRS += $(dir %(map))
3509 #MM %(mmake) : %(deps)
3515 %(mmake)-quick : %(file)
3517 %(file): KOBJS := $(KOBJS)
3518 %(file): LDFLAGS := $(TMP_LDFLAGS) $(NOSTARTUP_LDFLAGS) \
3519 -static -nosysbase -Wl,-Ur
3520 %(file): LDLIBS := $(addprefix -l, %(uselibs))
3521 %(file): $(KOBJS) $(DEPLIBS) | $(TMP_DIRS)
3522 @$(ECHO) "Kickstart $(subst $(TARGETDIR)/,,$@)..."
3523 @$(TARGET_CC) $(TARGET_SYSROOT) -o $@ $(KOBJS) $(LDFLAGS) $(LDLIBS)
3526 %compress_file mmake="%(mmake)" file="%(file)"
3528 GLOB_MKDIRS += $(TMP_DIRS)