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) objdir=$(GENDIR)/$(CURDIR)
66 @$(eval LINKTARGET=%(to))
67 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$(LINKTARGET))..."
68 @$(eval LINKTMPFILE=%(objdir)/$(notdir $(LINKTARGET)))
69 @$(IF) %(cmd) %(from) -o $(LINKTMPFILE) %(opt) %(libs) 2>&1 > $(GENDIR)/cerrors 2>&1 ; then \
70 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
71 $(ECHO) "$(LINKTARGET): %(cmd) %(from) -o $(LINKTARGET) %(opt) %(libs)" >> $(GENDIR)/errors ; \
72 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
76 $(CP) $(LINKTMPFILE) $(LINKTARGET) ; \
78 $(ECHO) "Link failed: %(cmd) %(from) -o $(LINKTARGET) %(opt) %(libs)" 1>&2 ; \
79 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
82 %(strip) $(LINKTARGET)
84 #------------------------------------------------------------------------------
87 #-------------------------------------------------------------------------
88 # Link a module based upon a number of arguments and the standard $(LIBS)
89 # and $(DEPLIBS) make variables.
91 %define link_module_q cmd="$(AROS_CC) $(TARGET_SYSROOT)" err="$(notdir $@).err" objs=/A endtag= module=$(MODULE) ldflags=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
92 @$(ECHO) "Building $(subst $(TARGETDIR)/,,$@) ..."
93 @$(IF) %(cmd) $(NOSTARTUP_LDFLAGS) \
94 $(GENMAP) %(objdir)/%(module).map \
95 %(objs) %(libs) %(ldflags) %(endtag) \
96 -o $@ 2>&1 > %(objdir)/%(err); \
98 cat %(objdir)/%(err); \
100 echo "%(cmd) $(NOSTARTUP_LDFLAGS) $(GENMAP) %(objdir)/%(module).map %(objs) %(libs) %(ldflags) %(endtag) -o $@"; \
101 cat %(objdir)/%(err); \
105 @if $(TEST) ! -s %(objdir)/%(err) ; then $(RM) %(objdir)/%(err) ; fi
108 #------------------------------------------------------------------------------
111 #------------------------------------------------------------------------------
113 %define mklib_q ar=$(AR) ranlib=$(RANLIB) to=$@ from=$(OBJS)
114 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,%(to))..."
118 #------------------------------------------------------------------------------
121 #------------------------------------------------------------------------------
122 # Create the dependency file %(to) for %(from)
123 %define mkdepend_q flags=$(CFLAGS) from=$< to=$@ cc="$(AROS_CC) $(TARGET_SYSROOT)"
124 %mkdir_q dir="$(dir %(to))"
125 @$(ECHO) "Makedepend $(if $(filter /%,%(from)),$(if $(filter $(SRCDIR)/%,$(abspath %(from))),$(patsubst $(SRCDIR)/%,%,$(abspath %(from))),$(patsubst $(TOP)/%,%,$(abspath %(from)))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/%(from))))..."
126 @AROS_CC="%(cc)" $(MKDEPEND) %(flags) -I$(TOP)/$(CURDIR) -I$(SRCDIR)/$(CURDIR) %(from) -o %(to)
128 #------------------------------------------------------------------------------
131 #------------------------------------------------------------------------------
132 # Create one directory without any output
133 %define mkdir_q dir=.
134 @$(IF) $(TEST) ! -d %(dir) ; then $(MKDIR) %(dir) ; else $(NOP) ; fi
136 #------------------------------------------------------------------------------
139 #------------------------------------------------------------------------------
140 # Create several directories without any output
141 %define mkdirs_q dirs=/M
142 @$(FOR) dir in %(dirs) ; do \
143 $(IF) $(TEST) ! -d $$dir ; then $(MKDIR) $$dir ; else $(NOP) ; fi ; \
146 #------------------------------------------------------------------------------
149 #############################################################################
150 #############################################################################
152 ## Here are the mmakefile macros that are used to do certain tasks in a ##
153 ## mmakefile. They consist of one or more full makefile rules. ##
154 ## In general the files generated in these macros are also defined as ##
155 ## make targets so that they can be used as a dependency in other rules ##
157 #############################################################################
158 #############################################################################
160 #------------------------------------------------------------------------------
161 # Generate a unique id for each of the %build... rules
162 %define buildid targets=/A
164 ifneq ($(filter $(TARGET),%(targets)),)
165 BDTARGETID := $(BDID)
168 #------------------------------------------------------------------------------
171 #------------------------------------------------------------------------------
172 # Copy file %(from) to %(to) in a makefile rule
173 %define rule_copy from=/A to=/A
177 #------------------------------------------------------------------------------
180 #------------------------------------------------------------------------------
181 # Copy the files %(files) to %(targetdir). For each file in %(files),
182 # %(srcdir)/file is copied to %(targetdir)/file. The targetdir and the
183 # appropriate subdirs are not generated by this rule so they have to be
185 %define rule_copy_multi files=/A targetdir=/A srcdir=.
187 $(addprefix %(targetdir)/,%(files)) : %(targetdir)/% : %(srcdir)/%
190 #------------------------------------------------------------------------------
193 #------------------------------------------------------------------------------
194 # Copy the files %(files) to %(targetdir). For each file in %(files),
195 # %(srcdir)/file is copied to %(targetdir)/file if these files are different.
196 # %(stampfile) is used to keep track of when the last time the comparison has
197 # been done. The targetdir and the appropriate subdirs are not generated by
198 # this rule so they have to be present.
199 %define rule_copy_diff_multi files=/A targetdir=/A srcdir=. \
200 stampfile=$(TMP_SRCDIR)/.copy_stamp
202 TMP_SRCDIR := %(srcdir)
204 $(addprefix %(targetdir)/,%(files)) : | %(stampfile)
206 %(stampfile) : COPYSRCDIR := %(srcdir)
207 %(stampfile) : TGTDIR := %(targetdir)
208 %(stampfile) : FILES := %(files)
209 %(stampfile) : $(addprefix %(srcdir)/,%(files))
210 @for f in $(FILES); do \
211 $(IF) ! $(CMP) -s $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; then \
212 $(CP) $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; \
217 #------------------------------------------------------------------------------
220 #------------------------------------------------------------------------------
221 # Will join all the files in %(from) to %(to). When text is specified it will
223 # Restriction: at the moment when using a non-empty target dir %(from) may
225 %define rule_join to=/A from=/A text=
233 #------------------------------------------------------------------------------
236 #------------------------------------------------------------------------------
237 # Include the dependency files and add some internal rules
238 # When depstargets is provided the depencies will only be included when one of
239 # these targets is the $(TARGET). Otherwise the dependencies will only be
240 # included when the $(TARGET) is not for setup or clean
241 %define include_deps deps=$(DEPS)/M depstargets=
243 ifneq (%(depstargets),)
244 ifneq ($(findstring $(TARGET),%(depstargets)),)
248 ifeq (,$(filter clean% %clean %clean% setup% includes% %setup,$(TARGET)))
254 #------------------------------------------------------------------------------
257 #------------------------------------------------------------------------------
258 # Create the directories %(dirs). The creation will be done by adding rules to
259 # the %(setuptarget) make target with setup as the default.
260 %define rule_makedirs dirs=/A setuptarget=setup
262 %(setuptarget) :: %(dirs)
264 GLOB_MKDIRS += %(dirs)
267 #------------------------------------------------------------------------------
270 #------------------------------------------------------------------------------
271 # Generate a rule to compile a C source file to an object file and generate
272 # the dependency file. Basename may contain a directory part, then the source
273 # file has to be in that directory. The generated file will be put in the
274 # object directory without the directory.
276 # - basename: the basename of the file to compile. Use % for a wildcard rule
277 # - cflags (default $(CFLAGS)): the C flags to use for compilation
278 # - dflags: the flags used during creation of dependency file. If not specified
279 # the same value as cflags will be used
280 # - targetdir: the directory to put the .o file and the .d file. By default
281 # it is put in the same directory as the .c file
282 %define rule_compile basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target
287 TMP_TARGETBASE := %(basename)
289 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
292 # Adjust compiler flags to suit C
293 TMP_CFLAGS := %(cflags)
294 TMP_CFLAGS := $(subst -fpermissive,, $(TMP_CFLAGS))
296 TMP_DFLAGS := %(cflags)
298 TMP_DFLAGS := %(dflags)
301 ifeq ($(findstring %(compiler),host kernel target),)
302 $(error unknown compiler %(compiler))
304 ifeq (%(compiler),target)
305 BD_LINK ?= $(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
306 BD_STRIP ?= $(TARGET_STRIP)
307 $(TMP_TARGETBASE).o : TMP_CMD:=$(TARGET_CC) $(TARGET_SYSROOT)
308 $(TMP_TARGETBASE).d : TMP_CMD:=$(TARGET_CC) $(TARGET_SYSROOT)
309 $(TMP_TARGETBASE).o : TMP_CFLAGS:=$(TARGET_CFLAGS) $(TMP_CFLAGS)
310 $(TMP_TARGETBASE).d : TMP_DFLAGS:=$(TARGET_CFLAGS) $(TMP_DFLAGS)
311 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
312 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
313 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
314 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
316 ifeq (%(compiler),host)
317 BD_LINK ?= $(HOST_CC) $(HOST_LDFLAGS)
318 BD_STRIP ?= $(HOST_STRIP)
319 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
320 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
321 $(TMP_TARGETBASE).o : TMP_CFLAGS:=$(HOST_CFLAGS) $(TMP_CFLAGS)
322 $(TMP_TARGETBASE).d : TMP_DFLAGS:=$(HOST_CFLAGS) $(TMP_DFLAGS)
323 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
324 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
325 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
326 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
328 ifeq (%(compiler),kernel)
329 BD_LINK ?= $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
330 BD_STRIP ?= $(ECHO) >/dev/null
331 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
332 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
333 $(TMP_TARGETBASE).o : TMP_CFLAGS:=$(KERNEL_CFLAGS) $(TMP_CFLAGS)
334 $(TMP_TARGETBASE).d : TMP_DFLAGS:=$(KERNEL_CFLAGS) $(TMP_DFLAGS)
335 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
336 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
337 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
338 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
341 $(TMP_TARGETBASE).o : CFLAGS := $(TMP_CFLAGS)
342 $(TMP_TARGETBASE).o : %(basename).c
343 %compile_q cmd=$(TMP_CMD) opt=$(TMP_CFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
346 $(TMP_TARGETBASE).d : TMP_DFLAGS:=$(BD_NIXFLAG) $(TMP_DFLAGS)
348 $(TMP_TARGETBASE).d : %(basename).c
349 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
351 #------------------------------------------------------------------------------
354 #------------------------------------------------------------------------------
355 # Generate a rule to compile a C++ source file to an object file and generate
356 # the dependency file. Basename may contain a directory part, then the source
357 # file has to be in that directory. The generated file will be put in the
358 # object directory without the directory.
360 # - basename: the basename of the file to compile. Use % for a wildcard rule
361 # - cflags (default $(CFLAGS)): the C flags to use for compilation
362 # - dflags: the flags used during creation of dependency file. If not specified
363 # the same value as cflags will be used
364 # - targetdir: the directory to put the .o file and the .d file. By default
365 # it is put in the same directory as the .c file
366 %define rule_compile_cxx basename=/A cxxflags=$(CXXFLAGS) dxxflags= targetdir= compiler=target
371 TMP_TARGETBASE := %(basename)
373 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
376 # Adjust compiler flags to suit C++
377 TMP_CXXFLAGS := %(cxxflags)
379 TMP_DXXFLAGS := %(cxxflags)
381 TMP_DXXFLAGS := %(dxxflags)
384 ifeq ($(findstring %(compiler),host kernel target),)
385 $(error unknown compiler %(compiler))
387 ifeq (%(compiler),target)
388 BD_LINK ?= $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
389 BD_STRIP ?= $(TARGET_STRIP)
390 $(TMP_TARGETBASE).o : TMP_CMD:=$(AROS_CXX) $(TARGET_SYSROOT)
391 $(TMP_TARGETBASE).d : TMP_CMD:=$(AROS_CXX) $(TARGET_SYSROOT)
392 $(TMP_TARGETBASE).o : TMP_CXXFLAGS:=$(TARGET_CXXFLAGS) $(TMP_CXXFLAGS)
393 $(TMP_TARGETBASE).d : TMP_DXXFLAGS:=$(TARGET_CXXFLAGS) $(TMP_DXXFLAGS)
394 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
395 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
396 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
397 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
399 ifeq (%(compiler),host)
400 BD_LINK ?= $(HOST_CXX) $(HOST_LDFLAGS)
401 BD_STRIP ?= $(HOST_STRIP)
402 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CXX)
403 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CXX)
404 $(TMP_TARGETBASE).o : TMP_CXXFLAGS:=$(HOST_CXXFLAGS) $(TMP_CXXFLAGS)
405 $(TMP_TARGETBASE).d : TMP_DXXFLAGS:=$(HOST_CXXFLAGS) $(TMP_DXXFLAGS)
406 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
407 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
408 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
409 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
411 ifeq (%(compiler),kernel)
412 KERNEL_CXX ?= $(KERNEL_CC)
413 BD_LINK ?= $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
414 BD_STRIP ?= $(ECHO) >/dev/null
415 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CXX) $(KERNEL_SYSROOT)
416 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CXX) $(KERNEL_SYSROOT)
417 $(TMP_TARGETBASE).o : TMP_CXXFLAGS:=$(KERNEL_CXXFLAGS) $(TMP_CXXFLAGS)
418 $(TMP_TARGETBASE).d : TMP_DXXFLAGS:=$(KERNEL_CXXFLAGS) $(TMP_DXXFLAGS)
419 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
420 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
421 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
422 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
425 $(TMP_TARGETBASE).o : CXXFLAGS := $(TMP_CXXFLAGS)
426 $(TMP_TARGETBASE).o : %(basename).cpp
427 %compile_q cmd=$(TMP_CMD) opt=$(TMP_CXXFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
430 $(TMP_TARGETBASE).d : TMP_DXXFLAGS:=$(BD_NIXFLAG) $(TMP_DXXFLAGS)
432 $(TMP_TARGETBASE).d : %(basename).cpp
433 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DXXFLAGS)
438 #------------------------------------------------------------------------------
441 #------------------------------------------------------------------------------
442 # Generate a rule to compile an ObjC source file to an object file and generate
443 # the dependency file. Basename may contain a directory part, then the source
444 # file has to be in that directory. The generated file will be put in the
445 # object directory without the directory.
447 # - basename: the basename of the file to compile. Use % for a wildcard rule
448 # - cflags (default $(CFLAGS)): the C flags to use for compilation
449 # - dflags: the flags used during creation of dependency file. If not specified
450 # the same value as cflags will be used
451 # - targetdir: the directory to put the .o file and the .d file. By default
452 # it is put in the same directory as the .m file
453 %define rule_compile_objc basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target
458 TMP_TARGETBASE := %(basename)
460 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
463 # Adjust compiler flags to suit ObjC
464 TMP_OBJCFLAGS := %(cflags)
465 TMP_OBJCFLAGS := $(TMP_OBJCFLAGS) -isystem $(AROS_DEVELOPMENT)/include
466 TMP_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(TMP_OBJCFLAGS)))
468 TMP_OBJCDFLAGS := %(cflags)
470 TMP_OBJCDFLAGS := %(dflags)
473 # Define the use of cross compiler
474 ifeq ($(TARGET_OBJC),)
475 TMP_CC := $(TARGET_CC)
477 TMP_CC := $(TARGET_OBJC)
480 ifeq ($(findstring %(compiler),host kernel target),)
481 $(error unknown compiler %(compiler))
483 ifeq (%(compiler),target)
484 BD_LINK ?= $(TMP_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
485 BD_STRIP ?= $(TARGET_STRIP)
486 $(TMP_TARGETBASE).o : TMP_CMD:=$(TMP_CC) $(TARGET_SYSROOT)
487 $(TMP_TARGETBASE).d : TMP_CMD:=$(TMP_CC) $(TARGET_SYSROOT)
488 $(TMP_TARGETBASE).o : TMP_OBJCFLAGS:=$(TARGET_CFLAGS) $(TMP_OBJCFLAGS)
489 $(TMP_TARGETBASE).d : TMP_OBJCDFLAGS:=$(TARGET_CFLAGS) $(TMP_OBJCDFLAGS)
490 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
491 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
492 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
493 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
495 ifeq (%(compiler),host)
496 BD_LINK ?= $(HOST_CC) $(HOST_LDFLAGS)
497 BD_STRIP ?= $(HOST_STRIP)
498 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
499 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
500 $(TMP_TARGETBASE).o : TMP_OBJCFLAGS:=$(HOST_CFLAGS) $(TMP_OBJCFLAGS)
501 $(TMP_TARGETBASE).d : TMP_OBJCDFLAGS:=$(HOST_CFLAGS) $(TMP_OBJCDFLAGS)
502 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
503 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
504 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
505 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
507 ifeq (%(compiler),kernel)
508 BD_LINK ?= $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
509 BD_STRIP ?= $(ECHO) >/dev/null
510 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
511 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
512 $(TMP_TARGETBASE).o : TMP_OBJCFLAGS:=$(KERNEL_CFLAGS) $(TMP_OBJCFLAGS)
513 $(TMP_TARGETBASE).d : TMP_OBJCDFLAGS:=$(KERNEL_CFLAGS) $(TMP_OBJCDFLAGS)
514 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
515 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
516 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
517 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
520 $(TMP_TARGETBASE).o : CFLAGS := $(TMP_OBJCFLAGS)
521 $(TMP_TARGETBASE).o : %(basename).m
522 %compile_q cmd=$(TMP_CMD) opt=$(TMP_OBJCFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
525 $(TMP_TARGETBASE).d : TMP_OBJCDFLAGS:=$(BD_NIXFLAG) $(TMP_OBJCDFLAGS)
527 $(TMP_TARGETBASE).d : %(basename).m
528 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_OBJCDFLAGS)
533 #------------------------------------------------------------------------------
536 #------------------------------------------------------------------------------
537 # Generate a rule to compile multiple C source files to an object file and
538 # generate the corresponding dependency files. The generated file will be put
539 # in the object directory without the directory part of the source file.
541 # - basenames: the basenames of the files to compile. The names may include
542 # relative or absolute path names. No wildcard is allowed
543 # - cflags (default $(CFLAGS)): the C flags to use for compilation
544 # - dflags: the flags used during creation of dependency file. If not specified
545 # the same value as cflags will be used
546 # - targetdir: the directory to put the .o file and the .d file. By default
547 # it is put in the same directory as the .c file. When targetdir is not
548 # empty, path names will be stripped from the file names so that all files
549 # are in that dir and not in subdirectories.
550 # - compiler (default target): compiler to use, target, kernel or host
551 %define rule_compile_multi basenames=/A cflags=$(CFLAGS) dflags= targetdir= \
555 TMP_TARGETS := $(addsuffix .o,%(basenames))
556 TMP_DTARGETS := $(addsuffix .d,%(basenames))
559 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
560 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
561 TMP_WILDCARD := %(targetdir)/%
563 # Be sure that all .c files are generated
564 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .c,%(basenames))
566 # Be sure that all .c files are found
567 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
568 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
569 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
571 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
572 vpath %.c $(TMP_DIRS)
577 TMP_CFLAGS := %(cflags)
579 TMP_DFLAGS := %(cflags)
581 TMP_DFLAGS := %(dflags)
584 ifeq ($(findstring %(compiler),host kernel target),)
585 $(error unknown compiler %(compiler))
587 ifeq (%(compiler),target)
588 BD_LINK ?= $(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
589 BD_STRIP ?= $(TARGET_STRIP)
590 BD_ASSEMBLER ?= $(TARGET_CC) $(TARGET_SYSROOT)
591 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TARGET_CC) $(TARGET_SYSROOT)
592 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_CFLAGS:=$(TARGET_CFLAGS) $(TMP_CFLAGS)
593 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_DFLAGS:=$(TARGET_CFLAGS) $(TMP_DFLAGS)
594 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
595 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
597 ifeq (%(compiler),host)
598 BD_LINK ?= $(HOST_CC) $(HOST_LDFLAGS)
599 BD_STRIP ?= $(HOST_STRIP)
600 BD_ASSEMBLER ?= $HOST_CC) $(HOST_SYSROOT)
601 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_CC)
602 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_CFLAGS:=$(HOST_CFLAGS) $(TMP_CFLAGS)
603 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_DFLAGS:=$(HOST_CFLAGS) $(TMP_DFLAGS)
604 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
605 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
607 ifeq (%(compiler),kernel)
608 BD_LINK ?= $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
609 BD_STRIP ?= $(ECHO) >/dev/null
610 BD_ASSEMBLER ?= $(KERNEL_CC) $(KERNEL_SYSROOT)
611 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
612 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_CFLAGS:=$(KERNEL_CFLAGS) $(TMP_CFLAGS)
613 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_DFLAGS:=$(KERNEL_CFLAGS) $(TMP_DFLAGS)
614 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
615 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
618 $(TMP_TARGETS) : CFLAGS := %(TMP_CFLAGS)
619 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.c
620 %compile_q cmd=$(CMD) opt=$(TMP_CFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
622 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.c
623 %mkdepend_q cc=$(CMD) flags=$(TMP_DFLAGS)
625 #------------------------------------------------------------------------------
628 #------------------------------------------------------------------------------
629 # Generate a rule to compile multiple C++ source files to an object file and
630 # generate the corresponding dependency files. The generated file will be put
631 # in the object directory without the directory part of the source file.
633 # - basenames: the basenames of the files to compile. The names may include
634 # relative or absolute path names. No wildcard is allowed. basenames will be
635 # matched to supported AROS_CXXEXTS.
636 # - cflags (default $(CFLAGS)): the C flags to use for compilation
637 # - dflags: the flags used during creation of dependency file. If not specified
638 # the same value as cflags will be used
639 # - targetdir: the directory to put the .o file and the .d file. By default
640 # it is put in the same directory as the .c file. When targetdir is not
641 # empty, path names will be stripped from the file names so that all files
642 # are in that dir and not in subdirectories.
643 # - compiler (default target): compiler to use, target, kernel or host
644 %define rule_compile_cxx_multi basenames=/A cxxflags=$(CXXFLAGS) dxxflags= \
645 targetdir= compiler=target
647 TMP_CXXABSBASENAMES := $(foreach TMP_CXXBASE,%(basenames),$(if $(filter /%,$(TMP_CXXBASE)),$(TMP_CXXBASE),$(abspath $(SRCDIR)/$(CURDIR)/$(TMP_CXXBASE))))
649 ifneq ($(TMP_CXXABSBASENAMES),)
651 TMP_CXXBASENAMES := $(basename $(TMP_CXXABSBASENAMES))
653 # Identify the "real" c++ files from the passed in basenames
654 TMP_CXXFILES := $(strip $(foreach TMP_CXXBASE,$(TMP_CXXABSBASENAMES), $(firstword $(wildcard $(foreach TMP_EXT, $(AROS_CXXEXTS),$(addsuffix .$(TMP_EXT),$(TMP_CXXBASE)))))))
657 TMP_CXXTARGETS := $(notdir $(TMP_CXXBASENAMES:=.o))
658 TMP_CXXDTARGETS := $(notdir $(TMP_CXXBASENAMES:=.d))
661 TMP_CXXTARGETS := $(addprefix %(targetdir)/,$(notdir $(TMP_CXXBASENAMES:=.o)))
662 TMP_CXXDTARGETS := $(addprefix %(targetdir)/,$(notdir $(TMP_CXXBASENAMES:=.d)))
663 TMP_WILDCARD := %(targetdir)/%
665 # Be sure that all source files are generated
666 $(TMP_CXXTARGETS) $(TMP_CXXDTARGETS) : | $(TMP_CXXFILES)
669 # Adjust compiler flags to suit C++
670 TMP_CXXFLAGS := %(cxxflags)
672 TMP_DXXFLAGS := %(cxxflags)
674 TMP_DXXFLAGS := %(dxxflags)
677 ifeq ($(findstring %(compiler),host kernel target),)
678 $(error unknown compiler %(compiler))
680 ifeq (%(compiler),host)
681 BD_LINK ?= $(HOST_CXX) $(HOST_LDFLAGS)
682 BD_STRIP ?= $(HOST_STRIP)
683 BD_ASSEMBLER ?= $(HOST_CC) $(HOST_SYSROOT)
684 TMP_CXXCMD:=$(HOST_CXX)
685 TMP_CXXFLAGS := $(HOST_CXXFLAGS) $(TMP_CXXFLAGS)
686 TMP_DXXFLAGS := $(HOST_CXXFLAGS) $(TMP_DXXFLAGS)
687 TMP_CXXIQUOTE:=$(HOST_IQUOTE)
688 TMP_CXXIQUOTE_END:=$(HOST_IQUOTE_END)
690 ifeq (%(compiler),target)
691 BD_LINK ?= $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
692 BD_STRIP ?= $(TARGET_STRIP)
693 BD_ASSEMBLER ?= $(TARGET_CC) $(TARGET_SYSROOT)
694 TMP_CXXCMD:=$(AROS_CXX) $(TARGET_SYSROOT)
695 TMP_CXXFLAGS := $(TARGET_CXXFLAGS) $(TMP_CXXFLAGS)
696 TMP_DXXFLAGS := $(TARGET_CXXFLAGS) $(TMP_DXXFLAGS)
697 TMP_CXXIQUOTE:=$(CFLAGS_IQUOTE)
698 TMP_CXXIQUOTE_END:=$(CFLAGS_IQUOTE_END)
700 ifeq (%(compiler),kernel)
701 KERNEL_CXX ?= $(KERNEL_CC)
702 BD_LINK ?= $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
703 BD_STRIP ?= $(ECHO) >/dev/null
704 BD_ASSEMBLER ?= $(KERNEL_CC) $(KERNEL_SYSROOT)
705 TMP_CXXCMD:=$(KERNEL_CXX) $(KERNEL_SYSROOT)
706 TMP_CXXFLAGS := $(KERNEL_CXXFLAGS) $(TMP_CXXFLAGS)
707 TMP_DXXFLAGS := $(KERNEL_CXXFLAGS) $(TMP_DXXFLAGS)
708 TMP_CXXIQUOTE:=$(KERNEL_IQUOTE)
709 TMP_CXXIQUOTE_END:=$(KERNEL_IQUOTE_END)
712 define cxx_multi_recipe_template
714 %compile_q cmd=$(TMP_CXXCMD) opt=$(TMP_CXXFLAGS) iquote=$(TMP_CXXIQUOTE) iquote_end=$(TMP_CXXIQUOTE_END) from=$(2) to=$(1).o
717 %mkdepend_q cc=$(TMP_CXXCMD) flags=$(TMP_DXXFLAGS) from=$(2) to=$(1).d
720 $(foreach TMP_CXXFILE,$(TMP_CXXFILES),$(eval $(call cxx_multi_recipe_template,$(notdir $(basename $(TMP_CXXFILE))),$(TMP_CXXFILE))))
722 $(foreach TMP_CXXFILE,$(TMP_CXXFILES),$(eval $(call cxx_multi_recipe_template,$(addprefix %(targetdir)/,$(notdir $(basename $(TMP_CXXFILE)))),$(TMP_CXXFILE))))
728 #------------------------------------------------------------------------------
731 #------------------------------------------------------------------------------
732 # Generate a rule to compile multiple ObjC source files to an object file and
733 # generate the corresponding dependency files. The generated file will be put
734 # in the object directory without the directory part of the source file.
736 # - basenames: the basenames of the files to compile. The names may include
737 # relative or absolute path names. No wildcard is allowed
738 # - cflags (default $(CFLAGS)): the C flags to use for compilation
739 # - dflags: the flags used during creation of dependency file. If not specified
740 # the same value as cflags will be used
741 # - targetdir: the directory to put the .o file and the .d file. By default
742 # it is put in the same directory as the .m file. When targetdir is not
743 # empty, path names will be stripped from the file names so that all files
744 # are in that dir and not in subdirectories.
745 # - compiler (default target): compiler to use, target, kernel or host
746 %define rule_compile_objc_multi basenames=/A cflags=$(CFLAGS) dflags= \
747 targetdir= compiler=target
749 ifneq (%(basenames),)
752 TMP_TARGETS := $(addsuffix .o,%(basenames))
753 TMP_DTARGETS := $(addsuffix .d,%(basenames))
756 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,%(basenames)))
757 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,%(basenames)))
758 TMP_WILDCARD := %(targetdir)/%
760 # Be sure that all .m files are generated
761 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .m,%(basenames))
763 # Be sure that all .m files are found
764 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
765 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
766 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
768 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
769 vpath %.m $(TMP_DIRS)
773 # Define the use of cross compiler
774 ifeq ($(TARGET_OBJC),)
775 TMP_CC := $(TARGET_CC)
777 TMP_CC := $(TARGET_OBJC)
780 # Adjust compiler flags to suit ObjC
781 TMP_OBJCFLAGS := %(cflags)
782 TMP_OBJCFLAGS := $(TMP_OBJCFLAGS) -isystem $(AROS_DEVELOPMENT)/include
783 TMP_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(TMP_OBJCFLAGS)))
785 TMP_OBJCDFLAGS := %(cflags)
787 TMP_OBJCDFLAGS := %(dflags)
790 ifeq ($(findstring %(compiler),host kernel target),)
791 $(error unknown compiler %(compiler))
793 ifeq (%(compiler),target)
794 BD_LINK ?= $(TMP_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
795 BD_STRIP ?= $(TARGET_STRIP)
796 BD_ASSEMBLER ?= $(TARGET_CC) $(TARGET_SYSROOT)
797 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TMP_CC) $(TARGET_SYSROOT)
798 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCFLAGS:=$(TARGET_CFLAGS) $(TMP_OBJCFLAGS)
799 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCDFLAGS:=$(TARGET_CFLAGS) $(TMP_OBJCDFLAGS)
800 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
801 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
803 ifeq (%(compiler),host)
804 BD_LINK ?= $(HOST_OBJC) $(HOST_LDFLAGS)
805 BD_STRIP ?= $(HOST_STRIP)
806 BD_ASSEMBLER ?= $(HOST_CC) $(HOST_SYSROOT)
807 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_OBJC)
808 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCFLAGS:=$(HOST_CFLAGS) $(TMP_OBJCFLAGS)
809 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCDFLAGS:=$(HOST_CFLAGS) $(TMP_OBJCDFLAGS)
810 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
811 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
813 ifeq (%(compiler),kernel)
814 KERNEL_OBJC ?= $(KERNEL_CC)
815 BD_LINK ?= $(KERNEL_OBJC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
816 BD_STRIP ?= $(ECHO) >/dev/null
817 BD_ASSEMBLER ?= $(KERNEL_CC) $(KERNEL_SYSROOT)
818 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_OBJC) $(KERNEL_SYSROOT)
819 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCFLAGS:=$(KERNEL_CFLAGS) $(TMP_OBJCFLAGS)
820 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCDFLAGS:=$(KERNEL_CFLAGS) $(TMP_OBJCDFLAGS)
821 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
822 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
825 $(TMP_TARGETS) : CFLAGS := $(TMP_OBJCFLAGS)
826 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.m
827 %compile_q cmd=$(CMD) opt=$(TMP_OBJCFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
829 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.m
830 %mkdepend_q cc=$(CMD) flags=$(DFLAGS)
835 #------------------------------------------------------------------------------
838 #------------------------------------------------------------------------------
839 # Make an alias from one arch specific build to another arch.
841 # - mainmmake: the mmake of the module in the main tree
842 # - arch: the current arch
843 # - alias: the alias to which this should point
844 %define rule_archalias mainmmake=\A arch=\A alias=\A
846 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
848 #------------------------------------------------------------------------------
851 #------------------------------------------------------------------------------
852 # Generate a rule to assemble a source file to an object file. Basename may
853 # contain a directory part, then the source file has to be in that directory.
854 # The generated file will be put in the object directory without the directory.
856 # - basename: the basename of the file to compile. Use % for a wildcard rule
857 # - flags (default $(AFLAGS)): the asm flags to use for assembling
858 # - targetdir: the directory to put the .o file in. By default it is put in the
859 # same directory as the .s file
860 %define rule_assemble basename=/A aflags=$(AFLAGS) targetdir=
863 %(basename).o : AFLAGS := %(aflags)
864 %(basename).o : %(basename).s
866 %(basename).o : %(basename).S
870 %(targetdir)/$(notdir %(basename)).o : AFLAGS := %(aflags)
871 %(targetdir)/$(notdir %(basename)).o : %(basename).s
873 %(targetdir)/$(notdir %(basename)).o : %(basename).S
878 #------------------------------------------------------------------------------
881 #------------------------------------------------------------------------------
882 # Generate a rule to assemble multiple source files to an object file. The
883 # generated file will be put in the object directory with the directory part
884 # of the source file stripped off.
886 # - basenames: the basenames of the files to compile. The names may include
887 # relative or absolute path names. No wildcard is allowed
888 # - aflags (default $(AFLAGS)): the flags to use for assembly
889 # - targetdir: the directory to put the .o file and the .d file. By default
890 # it is put in the same directory as the .c file. When targetdir is not
891 # empty, path names will be stripped from the file names so that all files
892 # are in that dir and not in subdirectories.
893 %define rule_assemble_multi cmd="$(CC) $(TARGET_SYSROOT)" basenames=/A aflags=$(AFLAGS) targetdir= suffix=.s
896 TMP_TARGETS := $(addsuffix .o,%(basenames))
899 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
900 TMP_WILDCARD := %(targetdir)/%
902 # Be sure that all .s files are generated
903 $(TMP_TARGETS) : | $(addsuffix %(suffix),%(basenames))
905 # Be sure that all .c files are found
906 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
907 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
908 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
910 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
911 vpath %%(suffix) $(TMP_DIRS)
916 BD_ASSEMBLER ?= %(cmd)
918 $(TMP_TARGETS) : TMP_CMD:= $(BD_ASSEMBLER)
920 $(TMP_TARGETS) : AFLAGS := %(aflags)
921 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %%(suffix)
922 %assemble_q cmd=$(TMP_CMD)
924 #------------------------------------------------------------------------------
927 #------------------------------------------------------------------------------
928 # Link %(objs) to %(prog) using the libraries in %(uselibs)
929 %define rule_link_prog prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
930 usehostlibs= usestartup=yes detach=no nix=no cmd="$(AROS_CC) $(TARGET_SYSROOT)" strip=$(TARGET_STRIP) objdir=$(GENDIR)/$(CURDIR)
935 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
937 ifeq (%(usestartup),no)
938 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
941 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
944 # Make a list of the lib files this program depends on.
945 # In LDFLAGS remove white space between -L and directory
946 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
947 # Filter out only the libdirs and remove -L
948 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
950 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
951 # Add normal linklib path
952 TMP_DIRS += $(AROS_LIB)/
953 # add lib and .a to static linklib names
954 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(TMP_EXTRA_LIBS)))
955 ifeq (%(usestartup),yes)
956 TMP_LIBS += startup.o
961 # search for the linklibs in the given path, ignore ones not found
962 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
963 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
966 %(prog) : OBJDIR := %(objdir)
967 %(prog) : OBJS := %(objs)
968 %(prog) : LDFLAGS := %(ldflags) $(TMP_EXTRA_LDFLAGS)
969 %(prog) : LIBS := $(addprefix -l,%(uselibs) $(TMP_EXTRA_LIBS) %(usehostlibs))
970 %(prog) : %(objs) $(TMP_DEPLIBS)
971 %link_q cmd="%(cmd)" strip="%(strip)" from=$(OBJS) opt=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
973 #------------------------------------------------------------------------------
976 #------------------------------------------------------------------------------
977 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
978 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
979 %define rule_link_progs progs=/A targetdir=$(AROSDIR)/$(CURDIR) nix=%(nix) \
980 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
981 usestartup=yes detach=no cmd="$(AROS_CC) $(TARGET_SYSROOT)" strip=$(TARGET_STRIP)
986 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
988 ifeq (%(usestartup),no)
989 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
992 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
995 # Make a list of the lib files the programs depend on.
996 # In LDFLAGS remove white space between -L and directory
997 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
998 # Filter out only the libdirs and remove -L
999 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
1001 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
1002 # Add normal linklib path
1003 TMP_DIRS += $(AROS_LIB)/
1004 # add lib and .a to static linklib names
1005 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(TMP_EXTRA_LIBS)))
1006 # search for the linklibs in the given path, ignore ones not found
1007 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
1008 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
1010 TMP_PROGS := $(addprefix %(targetdir)/,%(progs))
1012 $(TMP_PROGS) : OBJDIR := %(objdir)
1013 $(TMP_PROGS) : LDFLAGS := %(ldflags) $(TMP_EXTRA_LDFLAGS)
1014 $(TMP_PROGS) : LIBS := $(addprefix -l,%(uselibs) $(TMP_EXTRA_LIBS) %(usehostlibs))
1015 $(TMP_PROGS) : %(targetdir)/% : %(objdir)/%.o $(TMP_DEPLIBS)
1016 %link_q cmd="%(cmd)" strip="%(strip)" from=$< opt=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
1018 #------------------------------------------------------------------------------
1021 #------------------------------------------------------------------------------
1022 # Link the %(objs) to the library %(libdir)/lib%(libname).a
1023 %define rule_link_linklib libname=/A objs=/A libdir=$(AROS_LIB) linker=target
1025 ifeq (%(linker),target)
1026 %(libdir)/lib%(libname).a : TMP_AR:=$(AR)
1027 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(RANLIB)
1029 ifeq (%(linker),host)
1030 %(libdir)/lib%(libname).a : TMP_AR:=$(HOST_AR)
1031 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(HOST_RANLIB)
1033 ifeq (%(linker),kernel)
1034 %(libdir)/lib%(libname).a : TMP_AR:=$(KERNEL_AR)
1035 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(KERNEL_RANLIB)
1038 %(libdir)/lib%(libname).a : %(objs)
1039 %mklib_q from=$^ ar=$(TMP_AR) ranlib=$(TMP_RANLIB)
1041 #------------------------------------------------------------------------------
1043 #------------------------------------------------------------------------------
1044 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
1045 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
1046 %define rule_linkmodule module=/A objs=/A endobj=/A err=/A objdir=$(OBJDIR) \
1047 cmd="$(AROS_CC) $(TARGET_SYSROOT)" ldflags=$(LDFLAGS) uselibs= usehostlibs=
1049 TMP_LDFLAGS := %(ldflags)
1050 # Make a list of the lib files the programs depend on.
1051 # In LDFLAGS remove white space between -L and directory
1052 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
1053 # Filter out only the libdirs and remove -L
1054 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
1056 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
1057 # Add normal linklib path
1058 TMP_DIRS += $(AROS_LIB)/
1059 # add lib and .a to static linklib names
1060 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
1061 # search for the linklibs in the given path, ignore ones not found
1062 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
1063 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
1066 %(module) : LIB_NAMES := %(uselibs)
1067 %(module) : OBJS := %(objs)
1068 %(module) : ENDTAG := %(endobj)
1069 %(module) : ERR := %(err)
1070 %(module) : OBJDIR := %(objdir)
1071 %(module) : LDFLAGS := $(TMP_LDFLAGS)
1072 ifeq (%(usehostlibs),)
1073 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES))
1075 # Warning: the -L/usr/lib here can result in modules
1076 # linking against host libs instead of AROS libs (e.g stdc++) !!
1077 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES)) \
1078 -L/usr/lib $(addprefix -l,%(usehostlibs))
1080 %(module) : %(objs) %(endobj) $(TMP_DEPLIBS) $(USER_DEPLIBS)
1081 %link_module_q cmd="%(cmd)" err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS) objdir=$(OBJDIR) ldflags=$(LDFLAGS)
1084 #------------------------------------------------------------------------------
1087 #------------------------------------------------------------------------------
1088 # Generate the libdefs.h include file for a module.
1089 %define rule_genmodule_genlibdefs modname=/A modtype=/A modsuffix= conffile= targetdir= version=
1091 TMP_TARGET := %(modname)_libdefs.h
1092 TMP_DEPS := $(GENMODULE)
1094 ifneq (%(conffile),)
1095 ifeq ($(dir %(conffile)),./)
1096 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1097 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1099 TMP_OPTS += -c %(conffile)
1100 TMP_DEPS += %(conffile)
1103 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1104 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1106 ifneq (%(modsuffix),)
1107 TMP_OPTS += -s %(modsuffix)
1109 ifneq (%(targetdir),)
1110 TMP_OPTS += -d %(targetdir)
1111 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1114 TMP_OPTS += -v %(version)
1117 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1118 $(TMP_TARGET) : MODNAME := %(modname)
1119 $(TMP_TARGET) : MODTYPE := %(modtype)
1120 $(TMP_TARGET) : $(TMP_DEPS)
1121 @$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1122 @$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
1124 #------------------------------------------------------------------------------
1126 #------------------------------------------------------------------------------
1127 # Generate the _lib.fd file for a module.
1128 %define rule_genmodule_fd modname=/A modtype=/A modsuffix= conffile= targetdir=
1130 TMP_TARGET := %(modname)_lib.fd
1131 TMP_DEPS := $(GENMODULE)
1133 ifneq (%(conffile),)
1134 ifeq ($(dir %(conffile)),./)
1135 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1136 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1138 TMP_OPTS += -c %(conffile)
1139 TMP_DEPS += %(conffile)
1142 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1143 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1145 ifneq (%(modsuffix),)
1146 TMP_OPTS += -s %(modsuffix)
1148 ifneq (%(targetdir),)
1149 TMP_OPTS += -d %(targetdir)
1150 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1153 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1154 $(TMP_TARGET) : MODNAME := %(modname)
1155 $(TMP_TARGET) : MODTYPE := %(modtype)
1156 $(TMP_TARGET) : $(TMP_DEPS)
1157 @$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1158 @$(GENMODULE) $(OPTS) writefd $(MODNAME) $(MODTYPE)
1160 #------------------------------------------------------------------------------
1162 #------------------------------------------------------------------------------
1163 # Generate a Makefile.%(modname)%(modtype) with the genmodule program and include this
1164 # generated file in this Makefile
1165 %define rule_genmodule_makefile modname=/A modtype=/A modsuffix= conffile= \
1168 TMP_TARGET := Makefile.%(modname)%(modtype)
1169 TMP_DEPS := $(GENMODULE)
1171 ifneq (%(conffile),)
1172 ifeq ($(dir %(conffile)),./)
1173 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1174 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1176 TMP_OPTS += -c %(conffile)
1177 TMP_DEPS += %(conffile)
1180 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1181 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1183 ifneq (%(modsuffix),)
1184 TMP_OPTS += -s %(modsuffix)
1186 ifneq (%(targetdir),)
1187 TMP_OPTS += -d %(targetdir)
1188 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1191 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1192 $(TMP_TARGET) : MODNAME := %(modname)
1193 $(TMP_TARGET) : MODTYPE := %(modtype)
1194 $(TMP_TARGET) : $(TMP_DEPS)
1195 @$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
1197 #------------------------------------------------------------------------------
1200 #------------------------------------------------------------------------------
1201 # Generate the support files for compiling a module. This includes include
1202 # files and source files. This rule has to be preceeded by
1203 # %rule_genmodule_makefile
1204 %define rule_genmodule_files modname=/A modtype=/A modsuffix= targetdir= \
1207 TMP_TARGETS := $(%(modname)_STARTFILES) $(%(modname)_ENDFILES) \
1208 $(%(modname)_LINKLIBFILES) $(%(modname)_RELLINKLIBFILES)
1209 TMP_TARGETS := $(addsuffix .c,$(TMP_TARGETS)) \
1210 $(addsuffix .S, $(%(modname)_LINKLIBAFILES) $(%(modname)_RELLINKLIBAFILES))
1212 TMP_DEPS := $(GENMODULE)
1215 ifneq (%(conffile),)
1216 ifeq ($(dir %(conffile)),./)
1217 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1218 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1220 TMP_OPTS += -c %(conffile)
1221 TMP_DEPS += %(conffile)
1224 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1225 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1227 ifneq (%(modsuffix),)
1228 TMP_OPTS += -s %(modsuffix)
1230 ifneq (%(targetdir),)
1231 TMP_OPTS += -d %(targetdir)
1232 TMP_TARGETDIR := $(shell echo %(targetdir) | sed 's/^\(.\):\//\/\1\//')
1233 TMP_TARGETS := $(addprefix $(TMP_TARGETDIR)/,$(TMP_TARGETS))
1236 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
1237 $(TMP_TARGETS) : MODNAME := %(modname)
1238 $(TMP_TARGETS) : MODTYPE := %(modtype)
1239 $(TMP_TARGETS) : $(TMP_DEPS)
1240 @$(ECHO) "Generating support files for module $(MODNAME$(BDID))"
1241 ifneq (%(conffile),lib.conf)
1242 @$(IF) $(TEST) -f lib.conf; then \
1243 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
1246 @$(IF) $(TEST) -f libdefs.h; then \
1247 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
1249 @$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
1251 #------------------------------------------------------------------------------
1254 #------------------------------------------------------------------------------
1255 # Generate the support files for compiling a module. This includes include
1256 # files and source files.
1257 %define rule_genmodule_includes modname=/A modtype=/A modsuffix= \
1258 targetdir= conffile=
1260 ifneq ($(%(modname)_INCLUDES),)
1261 TMP_TARGETS := $(%(modname)_INCLUDES)
1263 TMP_DEPS := $(GENMODULE)
1266 ifneq (%(conffile),)
1267 ifeq ($(dir %(conffile)),./)
1268 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1269 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1271 TMP_OPTS += -c %(conffile)
1272 TMP_DEPS += %(conffile)
1275 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1276 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1278 ifneq (%(modsuffix),)
1279 TMP_OPTS += -s %(modsuffix)
1281 ifneq (%(targetdir),)
1282 TMP_OPTS += -d %(targetdir)
1283 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
1286 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
1287 $(TMP_TARGETS) : MODNAME := %(modname)
1288 $(TMP_TARGETS) : MODTYPE := %(modtype)
1289 $(TMP_TARGETS) : $(TMP_DEPS)
1290 @$(ECHO) "Generating $(MODNAME).$(MODTYPE) includes"
1291 @$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
1294 #------------------------------------------------------------------------------
1296 #------------------------------------------------------------------------------
1297 # Link %(objs) to binary blob in %(file) using %(name) as name of embedded binary object
1298 # 'start' is an optional starting address
1299 # 'ldflags' is optional additional flags for the linker
1300 %define rule_link_binary file=/A name=/A objs= files= start=0 ldflags=
1302 BD_OUTDIR := $(dir %(file))
1303 # This trick removes the trailing '/', otherwise findstring below fails, causing a warning
1304 BD_OUTDIR := $(subst /*,,$(addsuffix *,$(BD_OUTDIR)))
1305 BD_TMPDIR := $(GENDIR)/$(CURDIR)
1306 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(notdir %(files))))
1307 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(notdir %(files))))
1310 %rule_compile_multi basenames="%(files)" targetdir=$(BD_OBJDIR)
1312 %(file) : $(BD_OBJS) $(BD_DEPS) $(BD_OUTDIR)
1313 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)..."
1314 @$(KERNEL_LD) %(ldflags) --entry=%(start) --oformat=binary -Ttext=%(start) -o $(BD_TMPDIR)/%(name) $(BD_OBJS)
1315 @cd $(BD_TMPDIR) && $(AROS_LD) %(ldflags) -r --format binary %(name) -o $@
1317 ifeq ($(findstring $(BD_OUTDIR),$(GLOB_MKDIRS)),)
1318 GLOB_MKDIRS += $(BD_OUTDIR)
1323 #------------------------------------------------------------------------------
1324 # Common rules for all makefiles
1326 # Delete generated makefiles
1329 @$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
1331 include $(SRCDIR)/config/make.tail
1333 BDID := $(BDTARGETID)
1335 #------------------------------------------------------------------------------
1338 #############################################################################
1339 #############################################################################
1341 ## Here are the mmakefile build macros. These are macros that takes care ##
1342 ## of everything to go from the sources to the generated target. Also all ##
1343 ## intermediate files and directories that are needed are created by these ##
1346 #############################################################################
1347 #############################################################################
1349 #------------------------------------------------------------------------------
1351 %define build_prog mmake=/A progname=/A files=$(BD_PROGNAME) cxxfiles= \
1353 asmfiles= objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1354 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_CXXFLAGS) ldflags=$(LDFLAGS) \
1355 aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
1356 includedir= libdir= \
1357 compiler=target linker= lto=$(TARGET_LTO)
1361 BD_PROGNAME := %(progname)
1362 BD_OBJDIR := %(objdir)
1363 BD_TARGETDIR := %(targetdir)
1364 BD_LINKER := %(linker)
1366 # If not supplied, linker is equal to compiler
1367 ifeq ($(BD_LINKER),)
1368 BD_LINKER := %(compiler)
1371 BD_FILES := %(files)
1372 BD_OBJCFILES := %(objcfiles)
1373 BD_ASMFILES := %(asmfiles)
1374 BD_CXXFILES := %(cxxfiles)
1376 BD_ARCHOBJS := $(wildcard $(BD_OBJDIR)/arch/*.o)
1377 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1378 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1380 TMP_FILES := $(BD_NARCHFILES) $(BD_CXXFILES) $(BD_ASMFILES) $(BD_OBJCFILES)
1381 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(notdir $(TMP_FILES))))
1382 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(notdir $(TMP_FILES))))
1384 BD_CFLAGS := %(cflags)
1385 BD_CXXFLAGS := %(cxxflags)
1387 ifeq (%(compiler),target)
1388 BD_CFLAGS := $(CFLAGS_LTO) $(BD_CFLAGS)
1389 BD_CXXFLAGS := $(CFLAGS_LTO) $(BD_CXXFLAGS)
1392 ifneq (%(includedir),)
1393 BD_CFLAGS += -I%(includedir)
1394 BD_CXXFLAGS += -I%(includedir)
1396 BD_AFLAGS := %(aflags)
1397 ifneq (%(includedir),)
1398 BD_AFLAGS += -I%(includedir)
1400 BD_DFLAGS := %(dflags)
1401 BD_DXXFLAGS := %(dxxflags)
1402 BD_LDFLAGS := %(ldflags)
1404 BD_LDFLAGS += -L%(libdir)
1408 %(mmake)-quick : %(mmake)
1410 #MM %(mmake) : includes-generate-deps core-linklibs linklibs-%(uselibs)
1411 %(mmake) : $(BD_TARGETDIR)/$(BD_PROGNAME)
1413 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick %(mmake)-gz-quick),)
1414 %rule_compile_cxx_multi basenames=$(BD_CXXFILES) targetdir=$(BD_OBJDIR) \
1415 cxxflags=$(BD_CXXFLAGS) dxxflags=$(BD_DXXFLAGS) compiler="%(compiler)"
1416 %rule_compile_objc_multi basenames=$(BD_OBJCFILES) targetdir=$(BD_OBJDIR) \
1417 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler="%(compiler)"
1418 %rule_compile_multi basenames=$(BD_NARCHFILES) targetdir=$(BD_OBJDIR) \
1419 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler="%(compiler)"
1420 %rule_assemble_multi cmd=$(BD_ASSEMBLER) basenames=$(BD_ASMFILES) targetdir=$(BD_OBJDIR) \
1423 %rule_link_prog prog=$(BD_TARGETDIR)/$(BD_PROGNAME) \
1424 objs="$(BD_OBJS) $(BD_ARCHOBJS) $(USER_OBJS)" ldflags=$(BD_LDFLAGS) \
1425 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1426 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)" \
1427 cmd=$(BD_LINK) strip=$(BD_STRIP) objdir=$(BD_OBJDIR)
1431 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1433 $(BD_OBJS) $(BD_DEPS) : | $(BD_OBJDIR)
1434 $(BD_TARGETDIR)/$(BD_PROGNAME) : | $(BD_TARGETDIR)
1435 GLOB_MKDIRS += $(BD_OBJDIR) $(BD_TARGETDIR)
1437 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_TARGETDIR)/$(BD_PROGNAME) $(BD_DEPS)
1440 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1444 #------------------------------------------------------------------------------
1447 #------------------------------------------------------------------------------
1448 # Build programs, for every C file an executable will be built with the same
1449 # name as the C file
1450 %define build_progs mmake=/A files=/A nix=no \
1451 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1452 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
1453 includedir= libdir= \
1455 uselibs= usehostlibs= usestartup=yes detach=no lto=$(TARGET_LTO)
1459 BD_OBJDIR := %(objdir)
1460 BD_TARGETDIR := %(targetdir)
1462 BD_FILES := %(files)
1463 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1464 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1465 BD_EXES := $(addprefix $(BD_TARGETDIR)/,$(BD_FILES))
1467 BD_CFLAGS := %(cflags)
1469 ifeq (%(compiler),target)
1470 BD_CFLAGS := $(CFLAGS_LTO) $(BD_CFLAGS)
1473 ifneq (%(includedir),)
1474 BD_CFLAGS += -I%(includedir)
1476 BD_DFLAGS := %(dflags)
1477 BD_LDFLAGS := %(ldflags)
1479 BD_LDFLAGS += -L%(libdir)
1483 %(mmake)-quick : %(mmake)
1485 #MM %(mmake) : includes-generate-deps core-linklibs linklibs-%(uselibs)
1486 %(mmake) : $(BD_EXES)
1488 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1489 %rule_compile_multi basenames=$(BD_FILES) targetdir=$(BD_OBJDIR) \
1490 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler="%(compiler)"
1492 %rule_link_progs progs=$(BD_FILES) nix="%(nix)" \
1493 targetdir=$(BD_TARGETDIR) objdir=$(BD_OBJDIR) \
1494 ldflags=$(BD_LDFLAGS) \
1495 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1496 usestartup="%(usestartup)" detach="%(detach)" \
1497 cmd=$(BD_LINK) strip=$(BD_STRIP) objdir=$(BD_OBJDIR)
1501 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1503 $(addprefix $(BD_TARGETDIR)/,$(BD_FILES)) : | $(BD_TARGETDIR)
1504 $(BD_DEPS) $(BD_OBJS) : | $(BD_OBJDIR)
1505 GLOB_MKDIRS += $(BD_TARGETDIR) $(BD_OBJDIR)
1507 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_EXES) $(BD_DEPS)
1510 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1514 #------------------------------------------------------------------------------
1517 #------------------------------------------------------------------------------
1519 # This is a bare version: It just compiles and links the given files. It is
1520 # assumed that all needed boiler plate code is in the files. This should only
1521 # be used for compiling external code. For AROS code use %build_module
1522 %define build_module_simple mmake=/A modname=/A modtype=/A \
1523 files="$(basename $(call WILDCARD, *.c))" \
1524 cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1525 objdir=$(OBJDIR) moduledir= \
1526 uselibs= usehostlibs= compiler=target
1528 # Define metamake targets and their dependencies
1529 #MM %(mmake) : core-linklibs includes-generate-deps
1530 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1531 #MM %(mmake)-kobj-quick
1535 BD_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj
1537 .PHONY : $(BD_ALLTARGETS)
1540 $(error using %build_module_simple: modname may not be empty)
1543 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1546 # Default values for variables and arguments
1547 BD_DEFLINKLIBNAME := %(modname)
1548 BD_DEFDFLAGS := %(cflags)
1549 BD_DEFDXXFLAGS := %(dxxflags)
1550 OBJDIR ?= $(GENDIR)/$(CURDIR)
1551 BD_MODDIR := %(moduledir)
1552 ifeq ($(BD_MODDIR),)
1553 ifeq (%(modtype),library)
1554 BD_MODDIR := $(AROS_LIBRARIES)
1556 ifeq (%(modtype),gadget)
1557 BD_MODDIR := $(AROS_GADGETS)
1559 ifeq (%(modtype),datatype)
1560 BD_MODDIR := $(AROS_DATATYPES)
1562 ifeq (%(modtype),handler)
1563 BD_MODDIR := $(AROS_FS)
1565 ifeq (%(modtype),device)
1566 BD_MODDIR := $(AROS_DEVS)
1568 ifeq (%(modtype),resource)
1569 BD_MODDIR := $(AROS_RESOURCES)
1571 ifeq (%(modtype),hook)
1572 BD_MODDIR := $(AROS_RESOURCES)
1574 ifeq (%(modtype),mui)
1575 BD_MODDIR := $(AROS_CLASSES)/Zune
1577 ifeq (%(modtype),mcc)
1578 BD_MODDIR := $(AROS_CLASSES)/Zune
1580 ifeq (%(modtype),mcp)
1581 BD_MODDIR := $(AROS_CLASSES)/Zune
1583 ifeq (%(modtype),usbclass)
1584 BD_MODDIR := $(AROS_CLASSES)/USB
1586 ifeq (%(modtype),hidd)
1587 BD_MODDIR := $(AROS_DRIVERS)
1589 ifeq (%(modtype),printer)
1590 BD_MODDIR := $(AROS_PRINTERS)
1593 ifeq ($(BD_MODDIR),)
1594 $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1597 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1598 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1599 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),%(files))
1601 %rule_compile_multi \
1602 basenames=$(BD_NARCHFILES) targetdir="%(objdir)" \
1603 cflags="%(cflags)" dflags="%(dflags)" \
1604 compiler="%(compiler)"
1606 # Handlers use dash instead of dot in their names
1607 ifeq (%(modtype),handler)
1608 BD_MODULE := $(BD_MODDIR)/%(modname)-%(modtype)
1610 ifeq (%(modtype),printer)
1611 BD_MODULE := $(BD_MODDIR)/%(modname)
1613 BD_MODULE := $(BD_MODDIR)/%(modname).%(modtype)
1616 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1618 %(mmake)-quick : %(mmake)
1619 %(mmake)-kobj-quick : $(BD_KOBJ)
1620 %(mmake) : $(BD_MODULE)
1621 %(mmake)-kobj : $(BD_KOBJ)
1623 # The module is linked from all the compiled .o files
1624 BD_OBJS := $(BD_ARCHOBJS) $(addprefix %(objdir)/, $(addsuffix .o,$(notdir $(BD_NARCHFILES))))
1626 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
1627 # This breaks con-handler build. Here we work around this
1628 ifeq (%(modname),con)
1629 BD_ERR := $(notdir $(BD_MODULE)).err
1631 BD_ERR := %(modname).err
1634 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1635 endobj= err=$(BD_ERR) objdir="%(objdir)" \
1636 ldflags="$(LDFLAGS) $(%(modname)_LDFLAGS)" \
1637 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
1639 # Link kernel object file
1640 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1642 # Make these symbols local
1643 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1644 UtilityBase ExpansionBase KeymapBase KernelBase
1646 BD_SYMBOLS := $(BD_KBASE)
1648 BD_KLIB := hiddstubs amiga arossupport autoinit libinit
1649 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1650 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1651 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
1652 $(BD_KOBJ) : USER_LDFLAGS := $(USER_LDFLAGS)
1653 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1654 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
1655 @$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1656 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
1659 ## Dependency fine-tuning
1661 BD_DEPS := $(addprefix %(objdir)/, $(addsuffix .d,%(files)))
1662 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1664 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1665 $(BD_MODULE) : | $(BD_MODDIR)
1666 $(BD_KOBJ) : | $(KOBJSDIR)
1667 GLOB_MKDIRS += %(objdir) $(BD_MODDIR) $(KOBJSDIR)
1669 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_MODULE) $(BD_KOBJ) $(BD_DEPS)
1671 @$(ECHO) "Cleaning up for module %(modname)"
1674 #------------------------------------------------------------------------------
1677 #------------------------------------------------------------------------------
1678 # Build a module - core routine
1679 # Explanation of this macro is done in the developer's manual
1680 %define build_module_core mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
1681 files="$(basename $(call WILDCARD, *.c))" \
1682 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
1683 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_DEFDXXFLAGS) \
1684 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
1685 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
1686 compiler=target nostartup=yes archspecific=no \
1687 includedir= libdir= \
1688 build_abi= build_library=
1690 # We will employ a terrifying, but unavoidable, hack here.
1691 # genmf has no concept of conditionals (ie %ifeq), and MetaMake
1692 # ignores GNU Make ifeq() statements, but will process any #MM
1693 # headed lines in the file.
1695 # So, to make the following #MM lines conditional on whether we want
1696 # to build the ABI, Library, or both, we define build_abi= and
1697 # build_library as 'M' to enable, or '' to disable, which allows genmf
1698 # to do the following conversions:
1700 # #%(build_abi)M includes-foo: foo-include
1701 # becomes, when build_abi=M
1702 # #MM includes-foo: foo-include <= Processed by MetaMake
1703 # but, when build_abi= ...
1704 # #M includes-foo: foo-includes <= ignored by MetaMake! Yes!
1706 # Taking full blame for this: Jason S. McMullan <jason.mcmullan@gmail.com>
1708 # Define metamake targets and their dependencies
1711 #MM %(mmake)-makefile
1715 #M%(build_abi)- includes-all : %(mmake)-includes
1716 #M%(build_abi)- linklibs-%(modname): %(mmake)-linklib
1717 #M%(build_abi)- linklibs-%(modname)_rel : %(mmake)-linklib
1718 #M%(build_abi)- includes-%(modname): %(mmake)-includes
1719 #M%(build_abi)- includes-%(modname)_rel : %(mmake)-includes
1720 #M%(build_abi)- %(mmake) : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1721 #M%(build_abi) %(mmake)-linklib : %(mmake)-includes includes-%(uselibs)
1722 #M%(build_abi)- %(mmake)-quick : %(mmake)-includes-quick
1723 #M%(build_abi) %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1724 #M%(build_abi) includes-generate-deps %(mmake)-fd
1725 #M%(build_abi) %(mmake)-includes-quick
1726 #M%(build_abi) %(mmake)-includes-dirs
1727 #M%(build_abi) %(mmake)-fd
1730 #%(build_library)M %(mmake)-kobj : core-linklibs linklibs-%(uselibs)
1731 #%(build_library)M %(mmake)-kobj-quick :
1733 # Library with ABI targets:
1734 #%(build_library)%(build_abi) %(mmake)-kobj : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1735 #%(build_library)%(build_abi) %(mmake)-kobj-quick : %(mmake)-includes-quick
1737 # All MetaMake targets defined by this macro
1738 BD_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-clean
1740 ifeq (%(build_library),M)
1741 BD_ALLTARGETS += %(mmake)-kobj %(mmake)-kobj-quick
1744 ifeq (%(build_abi),M)
1745 BD_ALLTARGETS += %(mmake)-includes \
1746 %(mmake)-includes-quick %(mmake)-includes-dirs \
1747 %(mmake)-linklib %(mmake)-fd
1750 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1753 $(error using %build_module: modname may not be empty)
1756 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1759 # Default values for variables and arguments
1760 BD_DEFLINKLIBNAME := %(modname)
1761 BD_DEFDFLAGS := %(cflags)
1762 BD_DEFDXXFLAGS := %(cxxflags)
1763 ifneq (%(includedir),)
1764 BD_DEFDFLAGS += -I%(includedir)
1765 BD_DEFDXXFLAGS += -I%(includedir)
1767 OBJDIR ?= $(GENDIR)/$(CURDIR)
1769 ## Create genmodule include Makefile for the module
1771 %(mmake)-makefile : %(objdir)/Makefile.%(modname)%(modtype)
1773 %rule_genmodule_makefile \
1774 modname="%(modname)" modtype="%(modtype)" \
1775 modsuffix="%(modsuffix)" targetdir="%(objdir)" \
1776 conffile="%(conffile)"
1778 %(objdir)/Makefile.%(modname)%(modtype) : | %(objdir)
1780 GLOB_MKDIRS += %(objdir)
1782 # Do not parse these statements if metatarget is not appropriate
1783 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1785 include %(objdir)/Makefile.%(modname)%(modtype)
1787 BD_DEFMODDIR := $(%(modname)_MODDIR)
1788 ifeq (%(archspecific),yes)
1789 BD_DEFMODDIR := $(AROS_DIR_ARCH)/$(BD_DEFMODDIR)
1793 ## include files generation
1795 ifneq (%(includedir),)
1796 BD_INCDIR := %(includedir)
1798 BD_INCDIR := %(prefix)/$(AROS_DIR_INCLUDE)
1800 BD_LIBDEFSINC := %(objdir)/include/%(modname)_libdefs.h
1801 BD_DEFLIBDEFSINC := %(objdir)/include/%(modname)_deflibdefs.h
1803 ifeq (%(build_abi),M)
1804 %(mmake)-includes-quick : %(mmake)-includes
1805 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1806 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1807 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1809 ifneq ($(%(modname)_INCLUDES),)
1810 %rule_genmodule_includes modname="%(modname)" modtype="%(modtype)" \
1811 modsuffix="%(modsuffix)" targetdir="%(objdir)/include" \
1812 conffile="%(conffile)"
1814 %rule_copy_diff_multi \
1815 files=$(%(modname)_INCLUDES) srcdir="%(objdir)/include" targetdir=$(GENINCDIR) \
1816 stampfile="%(objdir)/%(modname)_geninc"
1818 %rule_copy_diff_multi \
1819 files=$(%(modname)_INCLUDES) srcdir="%(objdir)/include" targetdir=$(BD_INCDIR) \
1820 stampfile="%(objdir)/%(modname)_incs"
1822 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1824 TMP%(modname)_INCDIRS := \
1825 %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1826 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1827 $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1828 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget="%(mmake)-includes-dirs"
1834 %rule_genmodule_genlibdefs modname="%(modname)" modtype="%(modtype)" \
1835 modsuffix="%(modsuffix)" targetdir="%(objdir)/include" \
1836 conffile="%(conffile)" version="%(version)"
1838 $(BD_DEFLIBDEFSINC) : FILENAME := $(BD_LIBDEFSINC)
1839 $(BD_DEFLIBDEFSINC) :
1840 @$(ECHO) "Generating $@"
1841 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1843 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) : | %(objdir)/include
1844 GLOB_MKDIRS += %(objdir)/include
1846 ## Extra genmodule src files generation
1848 %rule_genmodule_files modname="%(modname)" modtype="%(modtype)" \
1849 modsuffix="%(modsuffix)" targetdir="%(objdir)" \
1850 conffile="%(conffile)"
1853 ifeq (%(build_abi),M)
1855 ifeq (%(includedir),)
1856 BD_FDDIR := %(prefix)/$(AROS_DIR_DEVELOPMENT)/fd
1858 BD_FDDIR := %(includedir)/../fd
1860 %(mmake)-fd : $(BD_FDDIR)/%(modname)_lib.fd
1862 %rule_genmodule_fd modname="%(modname)" modtype="%(modtype)" \
1863 modsuffix="%(modsuffix)" targetdir=$(BD_FDDIR) conffile="%(conffile)"
1865 $(BD_FDDIR)/%(modname)_lib.fd : | $(BD_FDDIR)
1867 GLOB_MKDIRS += $(BD_FDDIR)
1872 BD_FILES := %(files)
1873 BD_CXXFILES := %(cxxfiles)
1875 BD_FDIRS := $(sort $(dir $(BD_FILES)))
1877 BD_STARTFILES := $(addprefix %(objdir)/,$(%(modname)_STARTFILES))
1878 BD_ENDFILES := $(addprefix %(objdir)/,$(%(modname)_ENDFILES))
1880 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1881 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1882 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1884 BD_CFLAGS := %(cflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC) $(%(modname)_CFLAGS)
1885 BD_CXXFLAGS := %(cxxflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC) $(%(modname)_CXXFLAGS)
1886 # ifeq (%(compiler),target)
1887 # BD_CFLAGS := $(CFLAGS_LTO) $(BD_CFLAGS)
1888 # BD_CXXFLAGS := $(CFLAGS_LTO) $(BD_CXXFLAGS)
1890 ifneq (%(includedir),)
1891 BD_CFLAGS += -I%(includedir)
1892 BD_CXXFLAGS += -I%(includedir)
1894 BD_DFLAGS := %(dflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC) $(%(modname)_DFLAGS)
1895 BD_DXXFLAGS := %(dxxflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC) $(%(modname)_DXXFLAGS)
1897 ifeq (%(modtype),library)
1900 BD_LIBSUFFIX := .%(modtype)
1904 BD_LIBDIR := %(prefix)/$(AROS_DIR_LIB)
1906 BD_LIBDIR := %(libdir)
1909 ifeq (%(build_abi),M)
1910 BD_LINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBFILES))
1911 BD_LINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBAFILES))
1912 ifeq ($(strip $(%(modname)_LINKLIBFILES) $(%(modname)_LINKLIBAFILES) %(linklibfiles)),)
1915 BD_LINKLIB := $(BD_LIBDIR)/lib%(modname)$(BD_LIBSUFFIX).a
1916 ifneq (%(modname),%(linklibname))
1917 BD_LINKLIB += $(BD_LIBDIR)/lib%(linklibname)$(BD_LIBSUFFIX).a
1920 BD_LINKLIBFILES := $(BD_LINKLIBCFILES) $(BD_LINKLIBAFILES)
1922 BD_RELLINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_RELLINKLIBFILES))
1923 BD_RELLINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_RELLINKLIBAFILES))
1924 ifeq ($(strip $(%(modname)_RELLINKLIBFILES) $(%(modname)_RELLINKLIBAFILES) %(linklibfiles)),)
1927 BD_RELLINKLIB := $(BD_LIBDIR)/lib%(modname)_rel$(BD_LIBSUFFIX).a
1928 ifneq (%(modname),%(linklibname))
1929 BD_RELLINKLIB += $(BD_LIBDIR)/lib%(linklibname)_rel$(BD_LIBSUFFIX).a
1932 BD_RELLINKLIBFILES := $(BD_RELLINKLIBCFILES) $(BD_RELLINKLIBAFILES)
1935 BD_CCFILES := $(BD_NARCHFILES) %(linklibfiles)
1936 BD_TARGETCCFILES := $(BD_STARTFILES) $(BD_ENDFILES) $(BD_LINKLIBCFILES) \
1937 $(BD_RELLINKLIBCFILES)
1939 %rule_compile_cxx_multi \
1940 basenames=$(BD_CXXFILES) targetdir="%(objdir)" \
1941 cxxflags=$(BD_CXXFLAGS) dxxflags=$(BD_DXXFLAGS) \
1942 compiler="%(compiler)"
1943 %rule_compile_multi \
1944 basenames=$(BD_CCFILES) targetdir="%(objdir)" \
1945 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) \
1946 compiler="%(compiler)"
1947 %rule_compile_multi \
1948 basenames=$(BD_TARGETCCFILES) targetdir="%(objdir)" \
1949 cflags="$(BD_CFLAGS) -D__AROS__" dflags=$(BD_DFLAGS) \
1950 compiler="%(compiler)"
1952 ifneq ($(BD_LINKLIBAFILES),)
1953 %rule_assemble_multi \
1954 cmd=$(BD_ASSEMBLER) basenames="$(BD_LINKLIBAFILES) $(BD_RELLINKLIBAFILES)" targetdir="%(objdir)" suffix=.S
1959 ifeq (%(modsuffix),)
1960 BD_SUFFIX := %(modtype)
1962 BD_SUFFIX := %(modsuffix)
1965 ifeq (%(build_library),M)
1966 # Handlers use dash instead of dot in their names
1967 ifeq ($(BD_SUFFIX),handler)
1968 BD_MODULE := %(prefix)/%(moduledir)/%(modname)-$(BD_SUFFIX)
1970 BD_MODULE := %(prefix)/%(moduledir)/%(modname).$(BD_SUFFIX)
1972 BD_KOBJ := $(KOBJSDIR)/%(modname)_$(BD_SUFFIX).o
1978 %(mmake)-quick : %(mmake)
1979 %(mmake) : $(BD_MODULE) $(BD_LINKLIB) $(BD_RELLINKLIB)
1980 ifeq (%(build_library),M)
1981 %(mmake)-kobj : $(BD_KOBJ) $(BD_LINKLIB) $(BD_RELLINKLIB)
1982 %(mmake)-kobj-quick : $(BD_KOBJ) $(BD_LINKLIB) $(BD_RELLINKLIB)
1984 ifeq (%(build_abi),M)
1985 %(mmake)-linklib : $(BD_LINKLIB) $(BD_RELLINKLIB)
1988 BD_OBJS := $(addsuffix .o,$(BD_STARTFILES)) $(BD_ARCHOBJS) \
1989 $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES:=.o) $(BD_CXXFILES:=.o)))
1991 ifeq (%(nostartup),yes)
1992 # Handlers always have entry point
1993 ifneq (%(modtype),handler)
1994 BD_STARTOBJS := $(addsuffix .o,$(addprefix $(GENDIR)/,$(RESIDENT_BEGIN)))
1998 BD_ENDOBJS := $(addsuffix .o,$(BD_ENDFILES))
1999 BD_LINKLIBOBJS:= $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_LINKLIBFILES)) \
2002 := $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_RELLINKLIBFILES)) \
2005 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
2006 # This breaks con-handler build. Here we work around this
2007 ifeq (%(modname),con)
2008 BD_ERR := $(notdir $(BD_MODULE)).err
2010 BD_ERR := %(modname).err
2013 ifeq (%(build_library),M)
2014 # The module is linked from all the compiled .o files
2015 %rule_linkmodule module=$(BD_MODULE) objs="$(BD_STARTOBJS) $(BD_OBJS) $(USER_OBJS)" \
2016 endobj=$(BD_ENDOBJS) err=$(BD_ERR) objdir="%(objdir)" \
2017 cmd=$(BD_LINK) ldflags="$(LDFLAGS) $(%(modname)_LDFLAGS)" \
2018 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
2021 ifeq (%(build_abi),M)
2023 BD_LINKLIBNAME := $(shell echo %(linklibname) | tr A-Z a-z)
2024 BD_MODNAME := $(shell echo %(modname) | tr A-Z a-z)
2025 ifneq ($(BD_LINKLIB),)
2026 %rule_link_linklib libname="%(linklibname)$(BD_LIBSUFFIX)" objs=$(BD_LINKLIBOBJS) libdir="$(BD_LIBDIR)"
2027 ifneq ($(BD_MODNAME),$(BD_LINKLIBNAME))
2028 %rule_link_linklib libname="%(modname)$(BD_LIBSUFFIX)" objs=$(BD_LINKLIBOBJS) libdir="$(BD_LIBDIR)"
2031 $(BD_LINKLIB) : | $(BD_LIBDIR)
2032 GLOB_MKDIRS += $(BD_LIBDIR)
2035 ifneq ($(BD_RELLINKLIB),)
2036 %rule_link_linklib libname="%(linklibname)_rel$(BD_LIBSUFFIX)" objs=$(BD_RELLINKLIBOBJS) libdir="$(BD_LIBDIR)"
2037 ifneq ($(BD_MODNAME),$(BD_LINKLIBNAME))
2038 %rule_link_linklib libname="%(modname)_rel$(BD_LIBSUFFIX)" objs=$(BD_RELLINKLIBOBJS) libdir="$(BD_LIBDIR)"
2041 $(BD_RELLINKLIB) : | $(BD_LIBDIR)
2042 GLOB_MKDIRS += $(BD_LIBDIR)
2046 ifeq (%(build_library),M)
2047 # Link kernel object file
2048 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
2050 # Make these symbols local
2051 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
2052 UtilityBase ExpansionBase KeymapBase KernelBase
2054 BD_SYMBOLS := $(BD_KBASE)
2056 BD_KLIB := hiddstubs amiga arossupport autoinit libinit
2057 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
2058 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS) $(%(modname)_LIBS)
2059 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
2060 $(BD_KOBJ) : USER_LDFLAGS:=$(USER_LDFLAGS)
2061 $(BD_KOBJ) : $(BD_OBJS) $(USER_OBJS) $(BD_ENDOBJS)
2062 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
2063 @$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
2064 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
2067 ## Dependency fine-tuning
2069 BD_DEPS := $(addprefix %(objdir)/,$(notdir $(BD_CCFILES:=.d) $(BD_TARGETCCFILES:=.d) $(BD_CXXFILES:=.d)))
2071 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick" deps=$(BD_DEPS)
2073 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
2074 $(BD_MODULE) : | %(prefix)/%(moduledir)
2075 $(BD_KOBJ) : | $(KOBJSDIR)
2076 GLOB_MKDIRS += %(objdir) %(prefix)/%(moduledir) $(KOBJSDIR)
2078 # Some include files need to be generated before the .c can be parsed.
2079 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick),) # Only for this target these deps are wanted
2081 BD_DFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
2082 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES))
2083 $(BD_DEPS) : $(BD_DFILE_DEPS)
2086 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) \
2087 $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
2088 %(objdir)/Makefile.%(modname)%(modtype) \
2089 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
2090 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
2091 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
2092 %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
2093 $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
2094 $(BD_DEFLIBDEFSINC) $(addsuffix .c,$(BD_STARTFILES) $(BD_ENDFILES)) \
2096 %(mmake)-clean : FILES := $(BD_TOCLEAN)
2098 @$(ECHO) "Cleaning up for module %(modname)"
2101 endif # $(TARGET) in $(BD_ALLTARGETS)
2103 #------------------------------------------------------------------------------
2105 #------------------------------------------------------------------------------
2106 # Build a module - ABI and library
2107 # Explanation of this macro is done in the developer's manual
2108 %define build_module mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2109 files="$(basename $(call WILDCARD, *.c))" \
2110 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2111 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_DEFDXXFLAGS) \
2112 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
2113 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
2114 compiler=target nostartup=yes archspecific=no \
2117 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2118 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2119 files="%(files)" cxxfiles="%(cxxfiles)" \
2120 linklibname="%(linklibname)" \
2121 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2122 cflags="%(cflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2123 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2124 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" \
2125 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2126 includedir="%(includedir)" libdir="%(libdir)" \
2127 build_abi=M build_library=M
2130 #------------------------------------------------------------------------------
2133 #------------------------------------------------------------------------------
2134 # Build a module skeleton ABI
2135 # This is a stripped-down version of build_module, it only creates include
2136 # files and the linklibs.
2137 # This is used when for plugins or classes with the same API, but no actual
2138 # implementation here.
2139 %define build_module_abi mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2140 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_DEFDXXFLAGS) \
2141 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
2142 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
2143 compiler=target nostartup=yes archspecific=no \
2146 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2147 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2148 linklibname="%(linklibname)" \
2149 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2150 cflags="%(cflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2151 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2152 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" \
2153 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2154 includedir="%(includedir)" libdir="%(libdir)" \
2155 build_abi=M build_library=
2158 #------------------------------------------------------------------------------
2160 #------------------------------------------------------------------------------
2161 # Build a module library - no includes nor linklibs
2162 # Explanation of this macro is done in the developer's manual
2163 %define build_module_library mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2164 files="$(basename $(call WILDCARD, *.c))" \
2165 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2166 cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) cxxflags="$(CXXFLAGS)" dxxflags="$(BD_DEFDXXFLAGS)" \
2167 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
2168 uselibs= usehostlibs= \
2169 compiler=target nostartup=yes archspecific=no \
2172 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2173 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2174 files="%(files)" cxxfiles="%(cxxfiles)" \
2175 cflags="%(cflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2176 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2177 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" \
2178 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2179 includedir="%(includedir)" libdir="%(libdir)" \
2180 build_abi= build_library=M
2183 #------------------------------------------------------------------------------
2187 #------------------------------------------------------------------------------
2189 # - mmake is the mmaketarget
2190 # - libname is the baselibname e.g. lib%(libname).a will be created
2191 # - files are the C source files to include in the lib. The list of files
2192 # has to be given without the .c suffix
2193 # - cxxfiles are C++ source files without suffix.
2194 # NB: files will be matched in the order .cpp > .cxx > .cc
2195 # - asmfiles are the asm files to include in the lib. The list of files has to
2196 # be given without the .s suffix
2197 # - objs additional object to link into the linklib. The objects have to be
2198 # given with full absolute path and the .o suffix.
2199 # - objdir is where the .o are generated. Defaults to $(GENDIR)/$(CURDIR)
2200 # - libdir is the directory where the linklib will be placed (default $(AROS_LIB))
2201 # - cflags are the flags to compile the source (default $(CFLAGS))
2202 # - dflags are the flags used during makedepend (default equal to cflags)
2203 # - aflags are the flags used during assembling (default $(AFLAGS))
2204 # - libdir is the directory where the linklib will be placed (default $(AROS_LIB))
2205 %define build_linklib mmake=/A libname=/A files= cxxfiles= \
2206 asmfiles= objs= objdir=$(GENDIR)/$(CURDIR) libdir=$(AROS_LIB) \
2208 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_CXXFLAGS) \
2209 aflags=$(AFLAGS) compiler=target
2211 # assign and generate the local variables used in this macro
2212 BD_LIBNAME := %(libname)
2213 BD_LINKLIB := %(libdir)/lib%(libname).a
2215 BD_FILES := %(files)
2216 BD_ASMFILES := %(asmfiles)
2217 BD_CXXFILES := %(cxxfiles)
2219 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
2220 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
2221 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
2223 BD_OBJS := $(BD_ARCHOBJS) \
2224 $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES:=.o) $(BD_CXXFILES:=.o) $(BD_ASMFILES:=.o))) \
2226 BD_DEPS := $(patsubst %.o,%.d,$(BD_OBJS))
2228 BD_CFLAGS := %(cflags)
2229 BD_CXXFLAGS := %(cxxflags)
2230 ifneq (%(includedir),)
2231 BD_CFLAGS += -I%(includedir)
2232 BD_CXXFLAGS += -I%(includedir)
2234 BD_AFLAGS := %(aflags)
2235 BD_DFLAGS := %(dflags)
2236 BD_DXXFLAGS := %(dxxflags)
2238 .PHONY : %(mmake) %(mmake)-clean %(mmake)-quick
2241 %(mmake)-quick : %(mmake)
2243 #MM %(mmake) : includes-generate-deps
2244 %(mmake) : $(BD_LINKLIB)
2246 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
2248 %rule_compile_cxx_multi basenames=$(BD_CXXFILES) targetdir="%(objdir)" \
2249 compiler="%(compiler)" cxxflags=$(BD_CXXFLAGS) dxxflags=$(BD_DXXFLAGS)
2250 %rule_compile_multi basenames=$(BD_FILES) targetdir="%(objdir)" \
2251 compiler="%(compiler)" cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
2252 %rule_assemble basename=% targetdir="%(objdir)" \
2255 %rule_link_linklib libname="%(libname)" objs=$(BD_OBJS) libdir="%(libdir)" linker="%(compiler)"
2258 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
2260 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
2261 $(BD_LINKLIB) : | %(libdir)
2262 GLOB_MKDIRS += %(objdir) %(libdir)
2264 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_LINKLIB) $(BD_DEPS)
2267 @$(ECHO) "Cleaning up for metatarget %(mmake)"
2271 #------------------------------------------------------------------------------
2274 #------------------------------------------------------------------------------
2276 # - mmake is the mmaketarget
2277 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
2278 # - description is the catalog description file (.cd), without the .cd suffix (default *.cd)
2279 # - subdir is the destination subdirectory of the catalogs
2280 # - name is the name of the destination catalog, without the .catalog suffix
2281 # - source is the path to the generated source code file
2282 # - dir is the base destination directory (default $(AROS_CATALOGS))
2283 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
2284 # - srcdir is the directory in which the *.cd and *.ct files are searched
2286 %define build_catalogs mmake=/A name=/A subdir=/A \
2287 catalogs= source="../strings.h" description= dir=$(AROS_CATALOGS) \
2288 sourcedescription=$(TOOLDIR)/C_h_aros srcdir=$(SRCDIR)/$(CURDIR)
2290 ifeq (%(description),)
2291 BD_DESC := $(basename $(wildcard %(srcdir)/*.cd))
2293 BD_DESC := %(description)
2296 BD_SRC := $(shell echo %(sourcedescription) | sed 's/^\(.\):\//\/\1\//')
2299 BD_LNGS := $(basename $(notdir $(call WILDCARD, %(srcdir)/*.ct)))
2301 BD_LNGS := %(catalogs)
2304 BD_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, $(BD_LNGS)))
2305 BD_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, $(BD_LNGS))) $(dir %(source))
2308 %(mmake) : $(BD_OBJS) %(source)
2310 $(BD_OBJS) : | $(BD_DIRS)
2311 GLOB_MKDIRS += $(BD_DIRS)
2313 %(dir)/%/%(subdir)/%(name).catalog : %(srcdir)/%.ct $(BD_DESC).cd
2314 @$(ECHO) "Creating %(name) catalog for language $*."
2315 @$(FLEXCAT) $(BD_DESC).cd $< CATALOG="%(dir)/$*/%(subdir)/%(name).catalog" || [ $$? -lt 10 ]
2318 %(source) : BD_DESC := $(BD_DESC)
2319 %(source) : BD_SRC := $(BD_SRC)
2320 %(source) : $(BD_DESC).cd $(BD_SRC).sd | $(dir %(source))
2321 @$(ECHO) "Creating %(name) catalog source file $@"
2322 @$(FLEXCAT) $(BD_DESC).cd $@=$(BD_SRC).sd
2325 %(mmake)-clean : FILES := $(BD_OBJS) %(source)
2328 @$(ECHO) "Cleaning up for metatarget %(mmake)"
2331 .PHONY: %(mmake) %(mmake)-clean
2334 #-----------------------------------------------------------------------------
2337 #-----------------------------------------------------------------------------
2339 # - mmake is the mmaketarget
2340 # - icons is a list of icon base names (ie. without the .info suffix)
2341 # - dir is the destination directory
2342 # - srcdir is where *.png and *.info.src are searched
2343 #-----------------------------------------------------------------------------
2345 %define build_icons mmake=/A icons=/A dir=/A srcdir=$(SRCDIR)/$(CURDIR) image=
2347 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
2350 %(mmake) : $(BD_OBJS)
2354 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%.png
2355 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2356 @$(ILBMTOICON) $+ $@
2360 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%(image)
2361 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2362 @$(ILBMTOICON) $+ $@
2366 $(BD_OBJS) : | %(dir)
2367 GLOB_MKDIRS += %(dir)
2369 %(mmake)-clean : FILES := $(BD_OBJS)
2374 .PHONY: %(mmake) %(mmake)-clean
2377 #-----------------------------------------------------------------------------
2380 #------------------------------------------------------------------------------
2381 # Compile files for an arch-specific replacement of code for a module
2382 # - files: the basenames of the C files to compile.
2383 # - asmfiles: the basenames of the asm files to assemble.
2384 # - mainmmake: the mmake of the module in the main directory to compile these
2385 # arch specific files for.
2386 # - maindir: the object directory for the main module
2387 # - arch: the arch for which to compile these files. It can have the form
2388 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
2389 # - cflags (default $(CFLAGS)): the C flags to use for compilation
2390 # - dflags: the flags used during creation of dependency file. If not specified
2391 # the same value as cflags will be used
2392 # - aflags: the flags used during assembling
2393 # - compiler: (host, kernel or target) specifies which compiler to use. By default
2394 # the target compiler is used
2395 %define build_archspecific files= asmfiles= mainmmake=/A maindir=/A arch=/A \
2396 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
2398 ifeq (%(files) %(asmfiles),)
2399 $(error no files or asmfiles given)
2402 %buildid targets="%(mainmmake)-%(arch)"
2404 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2405 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2406 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2407 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2408 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2409 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2410 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2411 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2412 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2413 #MM- %(mainmmake)-kobj-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2414 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2415 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2416 #MM- %(mainmmake)-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2417 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2418 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2420 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
2422 BD_OBJDIR$(BDID) := $(GENDIR)/%(maindir)/arch
2423 BD_COBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
2424 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
2425 BD_OBJS$(BDID) := $(BD_COBJS$(BDID)) $(BD_ASMOBJS$(BDID))
2426 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
2428 ifneq (%(modulename),)
2429 BD_DEFLIBDEFSINC$(BDID) := -include $(GENDIR)/%(maindir)/include/%(modulename)_deflibdefs.h
2432 ifeq ($(TARGET),%(mainmmake)-%(arch)-quick)
2433 BD_TARGET := %(mainmmake)-%(arch)-quick
2435 BD_TARGET := %(mainmmake)-%(arch)
2439 ifeq ($(TARGET),$(BD_TARGET))
2440 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
2441 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(files)))
2442 vpath %.s $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2443 vpath %.S $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2446 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID))
2447 GLOB_MKDIRS += $(BD_OBJDIR$(BDID))
2450 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
2453 %(mainmmake)-%(arch)-quick :: $(BD_OBJS$(BDID))
2455 ifeq ($(findstring %(compiler),host kernel target),)
2456 $(error unknown compiler %(compiler))
2458 ifeq (%(compiler),target)
2459 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_CFLAGS)
2460 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
2461 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
2463 ifeq (%(compiler),host)
2464 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(HOST_CC)
2465 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
2466 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
2468 ifeq (%(compiler),kernel)
2469 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_CFLAGS)
2470 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
2471 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
2473 ifneq (%(modulename),)
2474 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) $(BD_DEFLIBDEFSINC$(BDID))
2476 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
2478 ifeq ($(TARGET),$(BD_TARGET))
2479 $(BD_OBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2480 %compile_q cmd=$(TMP_CMD) opt=$(TMP_CFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2484 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags) $(BD_DEFLIBDEFSINC$(BDID))
2486 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
2488 ifeq ($(TARGET),$(BD_TARGET))
2489 $(BD_OBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2490 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
2493 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
2495 ifeq ($(TARGET),$(BD_TARGET))
2496 $(BD_OBJDIR$(BDID))/%.o : %.s
2498 $(BD_OBJDIR$(BDID))/%.o : %.S
2502 %include_deps depstargets=$(BD_TARGET) deps=$(BD_DEPS$(BDID))
2504 #------------------------------------------------------------------------------
2507 #------------------------------------------------------------------------------
2508 # generate asm files from c files (for debugging purposes)
2511 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
2512 @$(TARGET_CC) $(TARGET_SYSROOT) -S $(CFLAGS) $(TARGET_CFLAGS) $< -c -o $@
2514 #------------------------------------------------------------------------------
2517 #------------------------------------------------------------------------------
2518 # Copy files from one directory to another.
2520 %define copy_files_q mmake=/A files=$(FILES) src=. dst=/A
2522 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
2524 GLOB_MKDIRS += %(dst)
2530 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC))/, $(file)) $(addprefix %(dst)/, $(file))))
2533 #------------------------------------------------------------------------------
2536 #------------------------------------------------------------------------------
2537 # Copy a directory recursively to another place, preserving the original
2538 # hierarchical structure
2540 # src: the source directory whose content will be copied.
2541 # dst: the directories where to copy src's content. If not existing, they will be made.
2542 # excludefiles: files which must not be copied. Path must be relative to src.
2544 %define copy_dir_recursive mmake=/A src=. dst=/A excludefiles=
2550 @cd $(SRCDIR)/$(CURDIR) && $(CPYDIRREC) -s %(src) -d %(dst) -e %(excludefiles)
2553 #------------------------------------------------------------------------------
2556 #------------------------------------------------------------------------------
2557 # Copy include files into the includes directories. There are currently
2558 # two include directories. One for building AROS $(AROS_INCLUDES) and one
2559 # for building tools that need to run on the host system $(GENINCDIR). The
2560 # $(GENINCDIR) path must not contain any references to the C runtime
2561 # library header files.
2563 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
2564 dir= compiler=target includedir=$(AROS_INCLUDES)
2566 ifeq ($(findstring %(compiler),host kernel target),)
2567 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
2572 $(eval TMP_DIRREMAIN := $$$(TMP_DIR))
2573 TMP_DIRFIRST := $(subst $(TMP_DIRREMAIN),,$(TMP_DIR))
2574 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),$(dir %(includes)))
2575 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,$(notdir %(includes)))
2576 ifeq ($(TMP_DIRFIRST),/)
2577 BD_INC_PATH := %(dir)/
2579 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
2582 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
2583 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
2586 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
2590 ifeq (%(compiler),target)
2593 BD_INCL_FILES2 := $(subst %(dir),%(includedir)/%(path),$(dir %(includes)))
2594 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,$(notdir %(includes)))
2596 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,%(includes))
2599 BD_INCL_FILES += $(BD_INCL_FILES2)
2601 $(BD_INCL_FILES2) : %(includedir)/%(path)/% : $(BD_INC_PATH)%
2606 %(mmake) : $(BD_INCL_FILES)
2610 $(BD_INCL_FILES) : | $(dir $(BD_INCL_FILES))
2611 GLOB_MKDIRS += $(dir $(BD_INCL_FILES))
2613 #------------------------------------------------------------------------------
2616 #------------------------------------------------------------------------------
2617 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
2618 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
2619 STUBS_MEM := $(addsuffix .o,$(STUBS))
2620 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
2621 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
2622 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
2624 #MM- linklibs : hidd-%(hidd)-stubs
2625 #MM- %(parenttarget): hidd-%(hidd)-stubs
2626 #MM hidd-%(hidd)-stubs : includes includes-copy
2627 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
2629 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
2632 $(STUBS_OBJ) : $(STUBS_SRC)
2633 %compile_q cmd="$(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_CFLAGS)" opt="%(cflags)" iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
2635 $(STUBS_DEP) : $(STUBS_SRC)
2636 %mkdepend_q flags="%(dflags)"
2639 %mkdirs_q $(OBJDIR) $(AROS_LIB)
2643 -@$(RM) $(HIDD_LIB) $(OBJDIR)
2645 DEPS := $(DEPS) $(STUBS_DEP)
2648 #------------------------------------------------------------------------------
2651 #------------------------------------------------------------------------------
2652 # Build an imported source tree which uses the configure script from the
2653 # autoconf package. This rule will try to "integrate" the produced files as
2654 # much as possible in the AROS build, for example by putting libraries in the
2655 # standard library directory, includes in the standard include directory, and
2656 # so on. You can however override this behaviour.
2658 # As a special "bonus" for you, the PROGDIR environment variable is defined to
2659 # be %(bindir) (or its deduced value) when running "make install", and
2660 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
2661 # configure script some more parameters whose value depends upon the PROGDIR
2662 # env var, so that the program gets all its stuff installed in the proper place
2663 # when building it, but when running it from inside AROS it can also find that
2664 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
2665 # the configuration parameters set when running ./configure
2667 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
2668 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
2669 # to the name which has to follow it.
2673 # - mmake = the meta make target.
2674 # - package = name of the package to be built.
2675 # - srcdir = the location of the unpacked source code. Defaults
2676 # to $(SRCDIR)/$(CURDIR).
2677 # - prefix = the target directory. Must be an absolute path of the
2678 # host system. Defaults to $(AROS_CONTRIB).
2679 # - aros_prefix = set a path which is valid within the AROS filesystem.
2680 # Defaults to the value of the prefix option.
2681 # - extraoptions = additional options for the configure script.
2682 # - extracflags = additional flags to use with the C compiler.
2683 # - extracxxflags = additional flags to use with the C++ compiler.
2684 # - nix_dir_layout = if yes the binary will be stored in a bin subdirectory.
2685 # Defaults to the value of the nix argument.
2686 # - nix = enable u*nix path handling, i.e. a path like
2687 # /progdir//./file will be translated to
2688 # progdir:file during run-time. Defaults to no.
2689 # - compiler = target, host or kernel. Defaults to target.
2690 # - install_target = the command used for installing. Defaults to install. Leave
2691 # it empty if you want to suppress installing.
2692 # - preconfigure = a metatarget which is executed before configure is called.
2693 # - postconfigure = a metatarget which is executed after configure is called.
2694 # - postinstall = a metatarget which is executed after installing.
2695 # - install_env = set additional options for installing.
2696 # - use_build_env = if yes the configuration environment is used for
2697 # installing, too. Defaults to no.
2699 # The arguments aros_prefix, nix and nix_dir_layout are related. The logic is
2703 # --prefix = $(aros_prefix)
2704 # progdir = $(aros_prefix)/bin
2707 # --prefix = /PROGDIR
2708 # --bindir = /PROGDIR
2709 # --sbindir = /PROGDIR
2711 # --includedir = /INCLUDE
2712 # --oldincludedir = /INCLUDE
2714 # --prefix = $(aros_prefix)
2717 # progdir = $(aros_prefix)
2720 # bindir = $(prefix)
2721 # sbindir = $(prefix)
2722 # libdir = $(AROS_LIB)
2723 # includedir = $(AROS_INCLUDES)
2724 # oldincludedir = $(AROS_INCLUDES)
2728 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) gendir= prefix= \
2729 aros_prefix= extraoptions= extracflags= extracxxflags= nix_dir_layout= nix=no compiler=target \
2730 install_target=install preconfigure= postconfigure= postinstall= \
2731 config_env_extra= install_env= use_build_env=no gnuflags=yes
2734 %(mmake)-prefix := %(prefix)
2736 %(mmake)-prefix := $(AROS_CONTRIB)
2739 ifneq (%(aros_prefix),)
2740 %(mmake)-aros_prefix := %(aros_prefix)
2742 %(mmake)-aros_prefix := $(%(mmake)-prefix)
2748 %(mmake)-nix := $(BD_NIXFLAG)
2749 %(mmake)-volpfx := /
2750 %(mmake)-volsfx := /
2752 ifeq (%(nix_dir_layout),)
2753 %(mmake)-nix_dir_layout := yes
2756 %(mmake)-volsfx := :
2758 ifeq (%(nix_dir_layout),)
2759 %(mmake)-nix_dir_layout := no
2763 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
2765 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
2766 exec_prefix=$(%(mmake)-prefix) %(install_env)
2768 # Check if chosen compiler is valid
2769 ifeq ($(findstring %(compiler),host target kernel),)
2770 $(error unknown compiler %(compiler))
2773 # Set legacy 'host' variable based on chosen compiler
2774 ifeq (%(compiler),host)
2777 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
2779 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
2784 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
2786 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
2791 %(mmake)-pkgdir := %(gendir)/$(CURDIR)
2793 %(mmake)-pkgdir := %(gendir)/$(CURDIR)/%(package)
2797 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
2798 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
2800 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
2801 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
2802 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2805 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
2806 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
2808 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2811 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
2813 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
2814 sbindir=$(%(mmake)-prefix) \
2815 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
2816 oldincludedir=$(AROS_INCLUDES) %(install_env)
2819 ifneq ($(DEBUG),yes)
2820 %(mmake)-s_flag = -s
2823 # Set up build environment, and options for configure script
2824 ifeq (%(compiler),host)
2825 # NB: We need to pass in our crosstoolsdir, but cannot set CFLAGS since it
2826 # confused configure scripts. We also cannot pass it via _FOR_BUILD
2827 # since that won't get picked up during configure.
2828 # We also cannot pass in the compiler including std flags so we need to use
2829 # the "plain" host compiler.
2830 CONFIG_ENV := %(config_env_extra) \
2832 CXXCPP="$(HOST_CPP)" \
2833 CC="$(HOST_DEF_CC) $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include" \
2834 CXX="$(HOST_CXX) $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include" \
2835 LDFLAGS="-L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS)" \
2836 TARGET_CC="$(KERNEL_CC) $(KERNEL_SYSROOT)" \
2837 TARGET_CFLAGS="$(KERNEL_CFLAGS) $(%(mmake)-s_flag)" \
2838 TARGET_CXX="$(KERNEL_CXX) $(KERNEL_SYSROOT)" \
2839 TARGET_CXXFLAGS="$(KERNEL_CXXFLAGS) $(%(mmake)-s_flag)" \
2840 TARGET_AS="$(TARGET_AS)" \
2841 OBJCOPY="$(OBJCOPY)" \
2842 TARGET_RANLIB="$(RANLIB)" \
2843 TARGET_STRIP="$(STRIP_PLAIN)" \
2844 TARGET_NM="$(NM_PLAIN)" \
2845 TARGET_OBJCOPY="$(TARGET_OBJCOPY)"
2847 ifeq (%(compiler),target)
2848 CONFIG_ENV := %(config_env_extra) \
2849 PKG_CONFIG_LIBDIR="$(AROS_DEVELOPMENT)/lib/pkgconfig" \
2850 PKG_CONFIG_SYSROOT_DIR="$(AROSDIR)" \
2851 CPP="$(TARGET_CPP) $(TARGET_SYSROOT)" \
2852 CXXCPP="$(TARGET_CPP) $(TARGET_SYSROOT)" \
2853 CC="$(TARGET_CC) $(TARGET_SYSROOT)" \
2854 CFLAGS=" $(TARGET_CFLAGS) $(DEBUG_CFLAGS) $(OPTIMIZATION_CFLAGS) %(extracflags) $(ISA_FLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2855 CXX="$(TARGET_CXX) $(TARGET_SYSROOT)" \
2856 CXXFLAGS=" $(TARGET_CXXFLAGS) $(DEBUG_CFLAGS) $(OPTIMIZATION_CFLAGS) %(extracxxflags) $(ISA_FLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2857 LDFLAGS="-L$(AROS_DEVELOPMENT)/lib $(USER_LDFLAGS)" \
2859 CC_FOR_BUILD="$(HOST_DEF_CC)" \
2860 CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
2861 CXX_FOR_BUILD="$(HOST_CXX)" \
2862 CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
2863 RANLIB="$(RANLIB)" \
2865 STRIP="$(STRIP_PLAIN)" \
2866 TARGET_CC="$(KERNEL_CC) $(KERNEL_SYSROOT)" \
2867 TARGET_CFLAGS="$(KERNEL_CFLAGS) $(%(mmake)-s_flag)" \
2868 TARGET_CXX="$(KERNEL_CXX) $(KERNEL_SYSROOT)" \
2869 TARGET_CXXFLAGS="$(KERNEL_CXXFLAGS) $(%(mmake)-s_flag)" \
2870 TARGET_AS="$(TARGET_AS)" \
2871 OBJCOPY="$(OBJCOPY)" \
2872 TARGET_RANLIB="$(RANLIB)" \
2873 TARGET_STRIP="$(STRIP_PLAIN)" \
2874 TARGET_NM="$(NM_PLAIN)" \
2875 CC_FOR_TARGET="$(TARGET_CC) $(TARGET_SYSROOT)" \
2876 CFLAGS_FOR_TARGET="$(TARGET_CFLAGS) -L$(AROS_DEVELOPMENT)/lib %(extracflags) $(ISA_FLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2877 CXX_FOR_TARGET="$(TARGET_CXX) $(TARGET_SYSROOT)" \
2878 CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS) -L$(AROS_DEVELOPMENT)/lib %(extracxxflags) $(ISA_FLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)"
2879 ifeq (%(gnuflags),yes)
2880 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)\
2881 --host=$(AROS_TARGET_CPU)-aros\
2882 --target=$(AROS_TARGET_CPU)-aros\
2884 --without-x --without-pic --disable-shared
2887 ifeq (%(compiler),kernel)
2888 CONFIG_ENV := %(config_env_extra) \
2889 CPP="$(KERNEL_CPP)" \
2890 CXXCPP="$(KERNEL_CPP)" \
2891 CC="$(KERNEL_CC) $(KERNEL_SYSROOT)" \
2892 CFLAGS="$(KERNEL_CFLAGS) %(extracflags) $(%(mmake)-s_flag)" \
2893 CXX="$(KERNEL_CXX) $(KERNEL_SYSROOT)" \
2894 CXXFLAGS="$(KERNEL_CXXFLAGS) %(extracxxflags) $(%(mmake)-s_flag)" \
2896 CC_FOR_BUILD="$(HOST_DEF_CC)" \
2897 CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
2898 CXX_FOR_BUILD="$(HOST_CXX)" \
2899 CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
2900 RANLIB="$(RANLIB)" \
2901 TARGET_RANLIB="$(RANLIB)" \
2902 TARGET_STRIP="$(STRIP_PLAIN)" \
2903 TARGET_NM="$(NM_PLAIN)"
2904 ifeq (%(gnuflags),yes)
2905 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)\
2906 --host=$(AROS_TARGET_CPU)-aros\
2907 --target=$(AROS_TARGET_CPU)-aros --disable-nls\
2908 --without-x --without-pic --disable-shared
2912 ifeq (%(use_build_env),yes)
2913 BUILD_ENV := $(CONFIG_ENV)
2916 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
2918 # When building for the host, we don't need to build the
2919 # linklibs - this is especially true when building the
2920 # crosstool toolchain on 'foreign' architectures (such as
2921 # building PPC on x86)
2923 #MM- %(mmake)-host : setup includes %(mmake)-quick
2924 #MM- %(mmake)-target : setup includes core-linklibs %(mmake)-quick
2925 #MM- %(mmake): %(mmake)-%(compiler)
2927 # Using -j1 in install_command may result in a warning but finally
2928 # it does its job. make install for gcc does not work reliably for -jN
2930 ifneq (%(install_target),)
2931 %(mmake)-install_command = \
2932 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2933 -C $(%(mmake)-pkgdir) %(install_target) -j1
2935 %(mmake)-uninstall_command = \
2936 $(RM) $(%(mmake)-installflag) && \
2937 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" \
2938 $(%(mmake)-install_opts) -C $(%(mmake)-pkgdir) uninstall
2940 %(mmake)-install_command := true
2941 %(mmake)-uninstall_command := true
2944 #MM- %(mmake)-quick : %(preconfigure) %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
2947 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
2949 $(%(mmake)-installflag) : $(%(mmake)-configflag)
2950 if ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q -C $(%(mmake)-pkgdir); then \
2951 $(RM) $(%(mmake)-installflag) && \
2952 $(BUILD_ENV) $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)"\
2953 -C $(%(mmake)-pkgdir) && \
2954 $(%(mmake)-install_command) && \
2955 $(TOUCH) $@ -r $^; \
2958 $(%(mmake)-pkgdir)/.files-touched:
2959 %mkdirs_q $(%(mmake)-pkgdir)
2960 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/configure '{}' \; && \
2964 %(mmake)-uninstall :
2965 $(%(mmake)-uninstall_command)
2968 %(mmake)-configure : $(%(mmake)-configflag)
2970 $(%(mmake)-configflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
2971 $(%(mmake)-configflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2973 %mkdirs_q $(%(mmake)-pkgdir)
2974 cd $(%(mmake)-pkgdir) && \
2975 find . -name config.cache -exec $(RM) '{}' \; && \
2976 $(CONFIG_ENV) $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) \
2977 %(extraoptions) && \
2981 %(mmake)-clean : %(mmake)-uninstall
2982 @$(RM) $(%(mmake)-pkgdir)
2984 #------------------------------------------------------------------------------
2987 #------------------------------------------------------------------------------
2988 # Build an imported source tree which uses cmake
2992 # - mmake = the meta make target.
2993 # - package = name of the package to be built.
2994 # - srcdir = the location of the unpacked source code. Defaults
2995 # to $(SRCDIR)/$(CURDIR).
2996 # - prefix = the target directory. Must be an absolute path of the
2997 # host system. Defaults to $(AROS_CONTRIB).
2998 # - aros_prefix = set a path which is valid within the AROS filesystem.
2999 # Defaults to the value of the prefix option.
3000 # - extraoptions = additional options for the cmake script.
3001 # - installoptions = additional options for the install step.
3004 %define build_with_cmake mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) gendir= prefix= \
3005 aros_prefix= extraoptions= installoptions= maketarget= compiler=target \
3006 cflags=$(CFLAGS) cxxflags=$(CXXFLAGS) ldflags=$(LDFLAGS)
3009 %(mmake)-prefix := %(prefix)
3011 %(mmake)-prefix := $(AROS_CONTRIB)
3014 ifneq (%(aros_prefix),)
3015 %(mmake)-aros_prefix := %(aros_prefix)
3017 %(mmake)-aros_prefix := $(%(mmake)-prefix)
3020 ifeq (%(compiler),host)
3021 BD_LDFLAGS := -L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS)
3022 BD_CFLAGS := $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include
3023 BD_CXXFLAGS := $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include
3024 %(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)"
3026 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
3028 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
3031 BD_LDFLAGS := %(ldflags)
3032 BD_CFLAGS := %(cflags)
3033 BD_CXXFLAGS := %(cxxflags)
3034 %(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)"
3036 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
3038 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
3043 %(mmake)-pkgdir := %(gendir)/$(CURDIR)
3045 %(mmake)-pkgdir := %(gendir)/$(CURDIR)/%(package)
3049 %(mmake)-cmakeflag := $(%(mmake)-pkgdir)/.cmake
3050 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
3052 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3054 #MM- %(mmake): setup includes core-linklibs %(mmake)-quick
3056 #MM- %(mmake)-quick : %(mmake)-cmake %(mmake)-build_and_install-quick
3059 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3061 $(%(mmake)-installflag) : $(%(mmake)-cmakeflag)
3062 if ! $(MAKE) -q -C $(%(mmake)-pkgdir); then \
3063 $(RM) $(%(mmake)-installflag) && \
3064 $(MAKE) -C $(%(mmake)-pkgdir) %(maketarget) && \
3065 cd $(%(mmake)-pkgdir) && \
3066 cmake %(installoptions) -P cmake_install.cmake && \
3067 $(TOUCH) $@ -r $^; \
3070 $(%(mmake)-pkgdir)/.files-touched:
3071 %mkdirs_q $(%(mmake)-pkgdir)
3072 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/CMakeLists.txt '{}' \; && \
3076 %(mmake)-cmake : $(%(mmake)-cmakeflag)
3078 $(%(mmake)-cmakeflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
3079 $(%(mmake)-cmakeflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
3081 %mkdirs_q $(%(mmake)-pkgdir)
3082 cd $(%(mmake)-pkgdir) && \
3083 $(RM) -Rf CMakeCache.txt CMakeFiles \; && \
3084 cmake $(%(mmake)-cmake_opts) %(extraoptions) $(TMP_SRCDIR) && \
3088 %(mmake)-clean : %(mmake)-uninstall
3089 @$(RM) $(%(mmake)-pkgdir)
3091 #------------------------------------------------------------------------------
3094 #------------------------------------------------------------------------------
3095 # Given an archive name, patches names and locations where to find them, fetch
3096 # the archive and the patches from any of those locations, unpack the archive
3097 # and then apply the patches.
3099 # Locations currently supported are http and ftp sites, plus local filesystem
3100 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
3101 # the fetch.sh script needs to be modified, since this macro relies on that script.
3105 # - mmake = mmaketarget
3106 # - archive_origins = list of locations where to find the archive. They are tried
3107 # in sequence, until the archive is found and fetching it
3108 # succeeded. If not specified, the current directory is assumed.
3109 # - archive = the archive name. Mandatory.
3110 # - suffixes = a list of suffixes to append to the the package name plus the
3111 # version. Each one of them is tried until a matching archive is
3112 # found. They are appended to patches and these are tried the
3113 # same way as packages are.
3114 # - location = the local directory where to put the fetched archive and patches.
3115 # If not specified, the directory specified by destination is used.
3116 # - destination = the directory to unpack the archive to.
3117 # If not specified, the current directory is assumed.
3118 # - patches_origins = list of locations where to find the patches. They are tried
3119 # in sequence, until a patch is found and fetching it
3120 # succeeded. If not specified, the current directory is assumed.
3121 # - patches_specs = list of "patch specs". A patch spec is of the form
3122 # patch_name[:[patch_subdir][:patch_opt]].
3124 # - patch_name = the name of the patch file
3125 # - patch_subdir = the directory within \destination\ where to
3127 # - patch_opt = any options to pass to the `patch' command
3128 # when applying the patch.
3130 # The patch_subdir and patch_opt fields are optional.
3132 %define fetch mmake=/A archive_origins=. archive=/A suffixes= location= destination=. \
3133 patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
3137 ifneq (%(location),)
3138 %(mmake)-location := %(location)
3140 %(mmake)-location := %(destination)
3145 $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
3146 -d %(destination) -po "%(patches_origins)" -p "%(patches_specs)"
3148 #------------------------------------------------------------------------------
3151 #------------------------------------------------------------------------------
3152 # This macro can aid in patch creation for fetched ports. It temporarily creates another
3153 # unpatched source tree and runs diff against this and a previously fetched and possibly
3154 # patched tree. Depending on what happens after patching during a normal build it might
3155 # give best results if the new patch is created directly after fetch.
3159 # - mmake = mmaketarget
3160 # - archive = archive base name
3161 # - srcdir = the top level directory the package is unpacked to, useful if
3162 # an archive unpacks to a directory other than its name suggests.
3163 # this should not be deeper than a single path element.
3164 # - suffixes = a list of suffixes to append to the the package name plus the
3165 # version. Each one of them is tried until a matching archive is
3167 # - destination = the directory to unpack the archive to.
3168 # - excludes = diff patterns to exclude files or directories from the patch
3170 %define create_patch mmake=/A archive=/A srcdir= suffixes="tar.bz2 tar.gz" destination=/A excludes=
3174 ifneq (%(excludes),)
3175 %(mmake)-exclude := -X ./exclude.patterns
3179 %(mmake)-srcdir := %(srcdir)
3181 %(mmake)-srcdir := %(archive)
3184 #MM- %(mmake) : %(mmake)-diff
3185 #MM- %(mmake)-quick : %(mmake)-diff
3189 @$(FETCH) -a %(archive) -s "%(suffixes)" -l $(PORTSSOURCEDIR) -d %(destination)/tmp ; \
3190 $(MV) %(destination)/$(%(mmake)-srcdir) %(destination)/tmp/$(%(mmake)-srcdir).aros ; \
3191 cd %(destination)/tmp ; \
3192 $(FOR) f in %(excludes) ; do \
3193 $(ECHO) $$f >> ./exclude.patterns ; \
3195 diff -ruN $(%(mmake)-exclude) \
3196 $(%(mmake)-srcdir) \
3197 $(%(mmake)-srcdir).aros \
3198 >$(SRCDIR)/$(CURDIR)/%(archive)-aros-new.diff ; \
3199 $(MV) %(destination)/tmp/$(%(mmake)-srcdir).aros %(destination)/$(%(mmake)-srcdir) ; \
3200 $(RM) %(destination)/tmp
3202 #------------------------------------------------------------------------------
3205 #------------------------------------------------------------------------------
3206 # Joins the features of %fetch and %build_with_configure.
3208 # If a patch is provided, it *must* be named the following way:
3210 # <package name>-<version number>-aros.diff
3212 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3213 # CD'ing into the archive's extracted directory.
3215 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3216 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3217 # to make that patch fully comprehensive.
3221 # - mmake = the meta make target.
3222 # - package = the GNU package name, sans version and archive format suffixes.
3223 # - subpackage = ???
3224 # - compiler = same meaning as the one for the %build_with_configure macro.
3225 # - install_target = same meaning as the one for the %build_with_configure macro.
3226 # - version = the package's version number, or otherwise any other version string.
3227 # It gets appended to the package name to form the basename of the archive.
3228 # - suffixes = a list of suffixes to apped to the the package name plus the
3229 # version. Each one of them is tried until a matching archive is found.
3230 # Defaults to "tar.bz2 tar.gz".
3231 # - srcdir = the top level directory the package is unpacked to (see create_patch).
3232 # - builddir = override the location we expect to run configure/make in.
3233 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
3234 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
3235 # fetched or not. Default to no.
3236 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
3237 # - prefix = same meaning as the one for the %build_with_configure macro.
3238 # - aros_prefix = same meaning as the one for the %build_with_configure macro.
3239 # - extraoptions = same meaning as the one for the %build_with_configure macro.
3240 # - extracflags = same meaning as the one for the %build_with_configure macro.
3241 # - extracxxflags = same meaning as the one for the %build_with_configure macro.
3242 # - preconfigure = same meaning as the one for the %build_with_configure macro.
3243 # - postconfigure = same meaning as the one for the %build_with_configure macro.
3244 # - postinstall = same meaning as the one for the %build_with_configure macro.
3245 # - install_env = same meaning as the one for the %build_with_configure macro.
3246 # - use_build_env = same meaning as the one for the %build_with_configure macro.
3247 # - nix = same meaning as the one for the %build_with_configure macro.
3248 # - nix_dir_layout = same meaning as the one for the %build_with_configure macro.
3249 # - create_pkg = create a distributable package of the compiled sources, defaults to no
3251 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target install_target=install \
3252 version=/A suffixes="tar.bz2 tar.gz" srcdir= builddir= gendir= package_repo= patch=no patch_repo= \
3253 prefix= aros_prefix= extraoptions= extracflags= extracxxflags= preconfigure= postconfigure= postinstall= \
3254 config_env_extra= install_env= use_build_env=no nix=no nix_dir_layout= create_pkg=no gnuflags=yes
3256 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
3257 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
3258 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
3259 #MM- %(mmake)-create-patch : %(mmake)-%(subpackage)-create-patch
3261 %(mmake)-archbase := %(package)-%(version)
3263 ifeq (%(compiler),host)
3264 %(mmake)-portdir := $(HOSTDIR)/Ports/host/%(package)
3266 %(mmake)-portdir := $(PORTSDIR)/%(package)
3270 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
3272 %(mmake)-prefix := %(prefix)
3275 ifneq (%(subpackage),)
3276 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
3278 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
3282 %(mmake)-%(subpackage)-srcdir := %(srcdir)
3284 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
3287 ifneq (%(builddir),)
3288 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)/%(builddir)
3290 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)
3294 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-f,-p1
3296 %(mmake)-%(subpackage)-patches_specs := ::
3299 %fetch mmake="%(mmake)-%(subpackage)-fetch" archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
3300 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
3301 archive_origins=". %(package_repo)" \
3302 patches_specs=$(%(mmake)-%(subpackage)-patches_specs) patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
3304 %create_patch mmake="%(mmake)-%(subpackage)-create-patch" \
3305 archive=$(%(mmake)-%(subpackage)-archbase) \
3306 srcdir=$(%(mmake)-%(subpackage)-srcdir) \
3307 suffixes="%(suffixes)" \
3308 destination=$(%(mmake)-portdir)
3310 #MM- %(mmake) : %(mmake)-%(subpackage)
3312 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
3314 %(mmake)-%(subpackage)-package-basename := \
3315 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
3317 ifneq (%(create_pkg),no)
3318 %(mmake)-%(subpackage)-package := $(%(mmake)-%(subpackage)-package-basename).tar.bz2
3321 %build_with_configure mmake="%(mmake)-%(subpackage)" package="%(package)" compiler="%(compiler)" install_target="%(install_target)" \
3322 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-builddir) gendir="%(gendir)" \
3323 config_env_extra="%(config_env_extra)" install_env="%(install_env)" use_build_env="%(use_build_env)" \
3324 nix="%(nix)" nix_dir_layout="%(nix_dir_layout)" prefix=$(%(mmake)-prefix) \
3325 aros_prefix="%(aros_prefix)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
3326 %(mmake)-%(subpackage)-make-package" extraoptions="%(extraoptions)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)" gnuflags=%(gnuflags)
3328 .PHONY : %(mmake)-%(subpackage)-make-package %(mmake)-%(subpackage)-create-patch
3329 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
3332 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package)
3334 #There seems to be a bug, either with my clock or with make, 'cause it may happen
3335 #that $^ and $@ have exactly the same mtime, and in that case make tries
3336 #to rebuild $@ again, which would fail because the directory where
3337 #the package got installed would not exist anymore.
3338 #We work this around by using an if statement to manually check the mtimes.
3339 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
3340 @$(IF) test $(%(mmake)-installflag) -nt $@ || ! test -f $@; then \
3342 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
3343 mkdir -p "$(DISTDIR)/Packages" ; \
3344 mkdir -p "$(%(mmake)-prefix)" ; \
3345 cd $(%(mmake)-%(subpackage)-package-dir) ; \
3346 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
3347 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
3350 #------------------------------------------------------------------------------
3353 #------------------------------------------------------------------------------
3354 # Joins the features of %fetch and %build_with_configure, taking advantage of
3355 # the naming scheme of GNU packages. GNU packages names are in the form
3357 # <package name>-<version number>.<archive format suffix>
3359 # If a patch is provided, it *must* be named the following way:
3361 # <package name>-<version number>-aros.diff
3363 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3364 # CD'ing into the archive's extracted directory.
3366 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3367 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3368 # to make that patch fully comprehensive.
3370 # NOTE: GNU packages are always compiled with *nix semantics turned on.
3374 # Arguments have the same meaning as the one for the %fetch_and_build macro, except:
3376 # - prefix = defaults to $(GNUDIR).
3377 # - aros_prefix = defaults to /GNU.
3379 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
3380 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
3381 aros_prefix=/GNU extraoptions= extracflags= extracxxflags= config_env_extra= preconfigure= postconfigure= postinstall=
3383 GNU_REPOSITORY := gnu://
3385 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
3386 suffixes="%(suffixes)" srcdir="%(srcdir)" \
3387 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
3388 patch="%(patch)" patch_repo="%(patch_repo)" \
3389 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)" \
3390 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=yes
3393 #------------------------------------------------------------------------------
3396 #------------------------------------------------------------------------------
3397 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
3398 # that the package is a "Development" package, and as such it needs to be placed
3399 # under the $(AROS_DEVELOPMENT) directory, as a default.
3401 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
3402 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
3403 # "mmake" argument, because the metatarget is implicitely defined as
3405 # #MM- development-%(package)
3407 %define fetch_and_build_gnu_development package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
3408 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPMENT) \
3409 aros_prefix=/Development config_env_extra= preconfigure= postconfigure= postinstall= extraoptions= extracflags= extracxxflags=
3411 #MM- development : development-%(package)
3414 %fetch_and_build_gnu mmake="development-%(package)" package="%(package)" subpackage="%(subpackage)" \
3415 version="%(version)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
3416 package_repo="%(package_repo)" patch="%(patch)" patch_repo="%(patch_repo)" prefix="%(prefix)" \
3417 aros_prefix="%(aros_prefix)" config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="postinstall-%(package)-delete-la-files %(postinstall)" \
3418 extraoptions="%(extraoptions)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)"
3421 postinstall-%(package)-delete-la-files:
3422 $(RM) $(AROS_DEVELOPMENT)/lib/*.la
3425 #------------------------------------------------------------------------------
3427 # Builds a kickstart package in PKG format
3431 # - mmake = target name
3432 # - file = destination file name with path
3434 # Other arguments are self-explanatory
3436 %define make_package mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
3437 arch_classes= arch_devs= arch_handlers= arch_hidds= arch_libs= arch_res=
3439 PKG_CLASSES := $(addprefix $(AROS_CLASSES)/,$(addsuffix .class, %(classes)))
3440 PKG_DEVICES := $(addprefix $(AROS_DEVS)/,$(addsuffix .device, %(devs)))
3441 PKG_HANDLERS := $(addprefix $(AROS_FS)/,$(addsuffix -handler, %(handlers)))
3442 PKG_HIDD := $(addprefix $(AROS_DEVS)/Drivers/,$(addsuffix .hidd, %(hidds)))
3443 PKG_LIBS := $(addprefix $(AROS_LIBRARIES)/,$(addsuffix .library, %(libs)))
3444 PKG_RESOURCES := $(addprefix $(AROS_DEVS)/,$(addsuffix .resource, %(res)))
3446 PKG_CLASSES_ARCH := $(addprefix $(AROS_CLASSES_ARCH)/,$(addsuffix .class, %(arch_classes)))
3447 PKG_DEVICES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .device, %(arch_devs)))
3448 PKG_HANDLERS_ARCH := $(addprefix $(AROS_FS_ARCH)/,$(addsuffix -handler, %(arch_handlers)))
3449 PKG_HIDD_ARCH := $(addprefix $(AROS_DEVS_ARCH)/Drivers/,$(addsuffix .hidd, %(arch_hidds)))
3450 PKG_LIBRARIES_ARCH := $(addprefix $(AROS_LIBRARIES_ARCH)/,$(addsuffix .library, %(arch_libs)))
3451 PKG_RESOURCES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .resource, %(arch_res)))
3453 PKG_FILES := $(PKG_CLASSES) $(PKG_DEVICES) $(PKG_HANDLERS) $(PKG_HIDD) $(PKG_LIBS) $(PKG_RESOURCES) \
3454 $(PKG_CLASSES_ARCH) $(PKG_DEVICES_ARCH) $(PKG_HANDLERS_ARCH) $(PKG_HIDD_ARCH) $(PKG_LIBRARIES_ARCH) $(PKG_RESOURCES_ARCH)
3455 PKG_DIR := $(dir %(file))
3461 %(mmake)-quick : %(file)
3463 %(file): $(PKG_FILES) | $(PKG_DIR)
3464 @$(ECHO) Packaging $@...
3465 @$(SRCDIR)/tools/package/pkg c $@ $^
3467 %compress_file mmake="%(mmake)" file="%(file)"
3469 GLOB_MKDIRS += $(PKG_DIR)
3473 #------------------------------------------------------------------------------
3474 # Compresses %(file) with a gzip.
3475 # Good in conjunction with for example %build_prog
3477 %define compress_file mmake=/A file=/A
3479 #MM- %(mmake)-gz : %(mmake) %(mmake)-gz-quick
3482 %(mmake)-gz-quick : %(file).gz
3485 @$(ECHO) Compressing $(subst $(TARGETDIR)/,,$^)...
3490 #------------------------------------------------------------------------------
3491 # Links a kickstart module in ELF format
3492 # Arguments are similar to make_package
3494 %define link_kickstart mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
3495 startup= uselibs= ldflags=$(LDFLAGS) map= deps=
3497 KOBJ_CLASSES := $(addprefix $(KOBJSDIR)/, $(addsuffix _class.o, %(classes)))
3498 KOBJ_DEVICES := $(addprefix $(KOBJSDIR)/, $(addsuffix _device.o, %(devs)))
3499 KOBJ_HANDLERS := $(addprefix $(KOBJSDIR)/, $(addsuffix _handler.o, %(handlers)))
3500 KOBJ_HIDD := $(addprefix $(KOBJSDIR)/, $(addsuffix _hidd.o, %(hidds)))
3501 KOBJ_LIBS := $(addprefix $(KOBJSDIR)/, $(addsuffix _library.o, %(libs)))
3502 KOBJ_RES := $(addprefix $(KOBJSDIR)/, $(addsuffix _resource.o, %(res)))
3505 KOBJ_STARTUP := $(GENDIR)/$(RESIDENT_BEGIN).o
3507 KOBJ_STARTUP := %(startup)
3510 KOBJS := $(KOBJ_STARTUP) $(KOBJ_CLASSES) $(KOBJ_HANDLERS) $(KOBJ_LIBS) $(KOBJ_DEVICES) $(KOBJ_HIDD) $(KOBJ_RES)
3512 TMP_LDFLAGS := %(ldflags)
3514 # Make a list of the lib files this program depends on.
3515 # In LDFLAGS remove white space between -L and directory
3516 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
3517 # Filter out only the libdirs and remove -L
3518 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
3520 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
3521 # Add normal linklib path
3522 TMP_DIRS += $(AROS_LIB)/
3523 # add lib and .a to static linklib names
3524 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
3525 # search for the linklibs in the given path, ignore ones not found
3526 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
3527 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
3530 TMP_DIRS += $(dir %(file))
3532 TMP_LDFLAGS += $(GENMAP) %(map)
3533 TMP_DIRS += $(dir %(map))
3536 #MM %(mmake) : %(deps)
3542 %(mmake)-quick : %(file)
3544 %(file): KOBJS := $(KOBJS)
3545 %(file): LDFLAGS := $(TMP_LDFLAGS) $(NOSTARTUP_LDFLAGS) \
3546 -static -nosysbase -Wl,-Ur
3547 %(file): LDLIBS := $(addprefix -l, %(uselibs))
3548 %(file): $(KOBJS) $(DEPLIBS) | $(TMP_DIRS)
3549 @$(ECHO) "Kickstart $(subst $(TARGETDIR)/,,$@)..."
3550 @$(TARGET_CC) $(TARGET_SYSROOT) -o $@ $(KOBJS) $(LDFLAGS) $(LDLIBS)
3553 %compress_file mmake="%(mmake)" file="%(file)"
3555 GLOB_MKDIRS += $(TMP_DIRS)