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_CFLAGS)" opt=$(CFLAGS) from=$< to=$@ iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
26 @$(ECHO) "Compiling $(CURDIR)/$(notdir %(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) 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) opt=$(LDFLAGS) from=$< to=$@ libs=$(LIBS) strip=$(STRIP)
66 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,%(to))..."
67 @$(IF) %(cmd) %(opt) %(from) -o %(to) %(libs) 2>&1 > $(GENDIR)/cerrors 2>&1 ; then \
68 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
69 $(ECHO) "%(to): %(cmd) %(opt) %(from) -o %(to) %(libs)" >> $(GENDIR)/errors ; \
70 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
75 $(ECHO) "Link failed: %(cmd) %(opt) %(from) -o %(to) %(libs)" 1>&2 ; \
76 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
81 #------------------------------------------------------------------------------
84 #-------------------------------------------------------------------------
85 # Link a module based upon a number of arguments and the standard $(LIBS)
86 # and $(DEPLIBS) make variables.
88 %define link_module_q err="$(notdir $@).err" objs=/A endtag= module=$(MODULE) ldflags=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
89 @$(ECHO) "Building $(subst $(TARGETDIR)/,,$@) ..."
90 @if $(AROS_CC) $(NOSTARTUP_LDFLAGS) %(ldflags) \
91 $(GENMAP) %(objdir)/%(module).map \
92 %(objs) %(libs) %(endtag) \
93 -o $@ 2>&1 > %(objdir)/%(err); \
95 cat %(objdir)/%(err); \
97 echo "$(AROS_CC) $(NOSTARTUP_LDFLAGS) %(ldflags) $(GENMAP) %(objdir)/%(module).map %(objs) %(libs) %(endtag) -o $@"; \
98 cat %(objdir)/%(err); \
102 @if $(TEST) ! -s %(objdir)/%(err) ; then $(RM) %(objdir)/%(err) ; fi
105 #------------------------------------------------------------------------------
108 #------------------------------------------------------------------------------
110 %define mklib_q ar=$(AR) ranlib=$(RANLIB) to=$@ from=$(OBJS)
111 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,%(to))..."
115 #------------------------------------------------------------------------------
118 #------------------------------------------------------------------------------
119 # Create the dependency file %(to) for %(from)
120 %define mkdepend_q flags=$(CFLAGS) from=$< to=$@ cc=$(AROS_CC)
121 %mkdir_q dir="$(dir %(to))"
122 @$(ECHO) "Makedepend $(CURDIR)/$(notdir %(from))..."
123 @AROS_CC="%(cc)" $(MKDEPEND) %(flags) -I$(TOP)/$(CURDIR) -I$(SRCDIR)/$(CURDIR) %(from) -o %(to)
125 #------------------------------------------------------------------------------
128 #------------------------------------------------------------------------------
129 # Create one directory without any output
130 %define mkdir_q dir=.
131 @$(IF) $(TEST) ! -d %(dir) ; then $(MKDIR) %(dir) ; else $(NOP) ; fi
133 #------------------------------------------------------------------------------
136 #------------------------------------------------------------------------------
137 # Create several directories without any output
138 %define mkdirs_q dirs=/M
139 @$(FOR) dir in %(dirs) ; do \
140 $(IF) $(TEST) ! -d $$dir ; then $(MKDIR) $$dir ; else $(NOP) ; fi ; \
143 #------------------------------------------------------------------------------
146 #############################################################################
147 #############################################################################
149 ## Here are the mmakefile macros that are used to do certain tasks in a ##
150 ## mmakefile. They consist of one or more full makefile rules. ##
151 ## In general the files generated in these macros are also defined as ##
152 ## make targets so that they can be used as a dependency in other rules ##
154 #############################################################################
155 #############################################################################
157 #------------------------------------------------------------------------------
158 # Generate a unique id for each of the %build... rules
159 %define buildid targets=/A
161 ifneq ($(filter $(TARGET),%(targets)),)
162 BDTARGETID := $(BDID)
165 #------------------------------------------------------------------------------
168 #------------------------------------------------------------------------------
169 # Copy file %(from) to %(to) in a makefile rule
170 %define rule_copy from=/A to=/A
174 #------------------------------------------------------------------------------
177 #------------------------------------------------------------------------------
178 # Copy the files %(files) to %(targetdir). For each file in %(files),
179 # %(srcdir)/file is copied to %(targetdir)/file. The targetdir and the
180 # appropriate subdirs are not generated by this rule so they have to be
182 %define rule_copy_multi files=/A targetdir=/A srcdir=.
184 $(addprefix %(targetdir)/,%(files)) : %(targetdir)/% : %(srcdir)/%
187 #------------------------------------------------------------------------------
190 #------------------------------------------------------------------------------
191 # Copy the files %(files) to %(targetdir). For each file in %(files),
192 # %(srcdir)/file is copied to %(targetdir)/file if these files are different.
193 # %(stampfile) is used to keep track of when the last time the comparison has
194 # been done. The targetdir and the appropriate subdirs are not generated by
195 # this rule so they have to be present.
196 %define rule_copy_diff_multi files=/A targetdir=/A srcdir=. \
197 stampfile=$(TMP_SRCDIR)/.copy_stamp
199 TMP_SRCDIR := %(srcdir)
201 $(addprefix %(targetdir)/,%(files)) : | %(stampfile)
203 %(stampfile) : COPYSRCDIR := %(srcdir)
204 %(stampfile) : TGTDIR := %(targetdir)
205 %(stampfile) : FILES := %(files)
206 %(stampfile) : $(addprefix %(srcdir)/,%(files))
207 @for f in $(FILES); do \
208 $(IF) ! $(CMP) -s $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; then \
209 $(CP) $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; \
214 #------------------------------------------------------------------------------
217 #------------------------------------------------------------------------------
218 # Will join all the files in %(from) to %(to). When text is specified it will
220 # Restriction: at the moment when using a non-empty target dir %(from) may
222 %define rule_join to=/A from=/A text=
230 #------------------------------------------------------------------------------
233 #------------------------------------------------------------------------------
234 # Include the dependency files and add some internal rules
235 # When depstargets is provided the depencies will only be included when one of
236 # these targets is the $(TARGET). Otherwise the dependencies will only be
237 # included when the $(TARGET) is not for setup or clean
238 %define include_deps deps=$(DEPS)/M depstargets=
240 ifneq (%(depstargets),)
241 ifneq ($(findstring $(TARGET),%(depstargets)),)
245 ifeq (,$(filter clean% %clean %clean% setup% includes% %setup,$(TARGET)))
251 #------------------------------------------------------------------------------
254 #------------------------------------------------------------------------------
255 # Create the directories %(dirs). The creation will be done by adding rules to
256 # the %(setuptarget) make target with setup as the default.
257 %define rule_makedirs dirs=/A setuptarget=setup
259 %(setuptarget) :: %(dirs)
261 GLOB_MKDIRS += %(dirs)
264 #------------------------------------------------------------------------------
267 #------------------------------------------------------------------------------
268 # Generate a rule to compile a C source file to an object file and generate
269 # the dependency file. Basename may contain a directory part, then the source
270 # file has to be in that directory. The generated file will be put in the
271 # object directory without the directory.
273 # - basename: the basename of the file to compile. Use % for a wildcard rule
274 # - cflags (default $(CFLAGS)): the C flags to use for compilation
275 # - dflags: the flags used during creation of dependency file. If not specified
276 # the same value as cflags will be used
277 # - targetdir: the directory to put the .o file and the .d file. By default
278 # it is put in the same directory as the .c file
279 %define rule_compile basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target nix=no
282 TMP_TARGETBASE := %(basename)
284 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
287 ifeq ($(findstring %(compiler),host kernel target),)
288 $(error unknown compiler %(compiler))
290 ifeq (%(compiler),target)
291 $(TMP_TARGETBASE).o : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
292 $(TMP_TARGETBASE).d : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
293 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
294 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
295 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
296 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
298 ifeq (%(compiler),host)
299 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
300 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
301 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
302 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
303 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
304 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
306 ifeq (%(compiler),kernel)
307 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
308 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
309 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
310 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
311 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
312 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
316 $(TMP_TARGETBASE).o : CFLAGS := -nix %(cflags)
318 $(TMP_TARGETBASE).o : CFLAGS := %(cflags)
320 $(TMP_TARGETBASE).o : %(basename).c
321 %compile_q cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
325 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(cflags)
327 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(cflags)
331 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(dflags)
333 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(dflags)
336 $(TMP_TARGETBASE).d : %(basename).c
337 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
339 #------------------------------------------------------------------------------
342 #------------------------------------------------------------------------------
343 # Generate a rule to compile a C++ source file to an object file and generate
344 # the dependency file. Basename may contain a directory part, then the source
345 # file has to be in that directory. The generated file will be put in the
346 # object directory without the directory.
348 # - basename: the basename of the file to compile. Use % for a wildcard rule
349 # - cflags (default $(CFLAGS)): the C flags to use for compilation
350 # - dflags: the flags used during creation of dependency file. If not specified
351 # the same value as cflags will be used
352 # - targetdir: the directory to put the .o file and the .d file. By default
353 # it is put in the same directory as the .c file
354 %define rule_compile_cxx basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target nix=no
357 TMP_TARGETBASE := %(basename)
359 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
362 # Adjust compiler flags to suit C++
363 TMP_CXXFLAGS := %(cflags)
364 TMP_CXXFLAGS := $(TMP_CXXFLAGS) -fno-rtti -fno-exceptions -fno-check-new -isystem $(AROS_DEVELOPMENT)/include
365 TMP_CXXFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(TMP_CXXFLAGS)))
367 ifeq ($(findstring %(compiler),host kernel target),)
368 $(error unknown compiler %(compiler))
370 ifeq (%(compiler),target)
371 $(TMP_TARGETBASE).o : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
372 $(TMP_TARGETBASE).d : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
373 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
374 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
375 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
376 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
378 ifeq (%(compiler),host)
379 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
380 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
381 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
382 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
383 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
384 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
386 ifeq (%(compiler),kernel)
387 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
388 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
389 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
390 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
391 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
392 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
396 $(TMP_TARGETBASE).o : CFLAGS := -nix $(TMP_CXXFLAGS)
398 $(TMP_TARGETBASE).o : CFLAGS := $(TMP_CXXFLAGS)
400 $(TMP_TARGETBASE).o : %(basename).cpp
401 %compile_q cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
405 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix $(TMP_CXXFLAGS)
407 $(TMP_TARGETBASE).d : TMP_DFLAGS:=$(TMP_CXXFLAGS)
411 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(dflags)
413 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(dflags)
416 $(TMP_TARGETBASE).d : %(basename).cpp
417 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
419 #------------------------------------------------------------------------------
422 #------------------------------------------------------------------------------
423 # Generate a rule to compile multiple C source files to an object file and
424 # generate the corresponding dependency files. The generated file will be put
425 # in the object directory without the directory part of the source file.
427 # - basenames: the basenames of the files to compile. The names may include
428 # relative or absolute path names. No wildcard is allowed
429 # - cflags (default $(CFLAGS)): the C flags to use for compilation
430 # - dflags: the flags used during creation of dependency file. If not specified
431 # the same value as cflags will be used
432 # - targetdir: the directory to put the .o file and the .d file. By default
433 # it is put in the same directory as the .c file. When targetdir is not
434 # empty, path names will be stripped from the file names so that all files
435 # are in that dir and not in subdirectories.
436 # - compiler (default target): compiler to use, target, kernel or host
437 %define rule_compile_multi basenames=/A cflags=$(CFLAGS) dflags= targetdir= \
441 TMP_TARGETS := $(addsuffix .o,%(basenames))
442 TMP_DTARGETS := $(addsuffix .d,%(basenames))
445 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
446 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
447 TMP_WILDCARD := %(targetdir)/%
449 # Be sure that all .c files are generated
450 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .c,%(basenames))
452 # Be sure that all .c files are found
453 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
454 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
455 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
457 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
458 vpath %.c $(TMP_DIRS)
463 ifeq ($(findstring %(compiler),host kernel target),)
464 $(error unknown compiler %(compiler))
466 ifeq (%(compiler),target)
467 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
468 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
469 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
471 ifeq (%(compiler),host)
472 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_CC)
473 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
474 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
476 ifeq (%(compiler),kernel)
477 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
478 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
479 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
482 $(TMP_TARGETS) : CFLAGS := %(cflags)
483 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.c
484 %compile_q cmd=$(CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
487 $(TMP_DTARGETS) : DFLAGS:=%(cflags)
489 $(TMP_DTARGETS) : DFLAGS:=%(dflags)
491 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.c
492 %mkdepend_q cc=$(CMD) flags=$(DFLAGS)
494 #------------------------------------------------------------------------------
497 #------------------------------------------------------------------------------
498 # Generate a rule to compile multiple C++ source files to an object file and
499 # generate the corresponding dependency files. The generated file will be put
500 # in the object directory without the directory part of the source file.
502 # - basenames: the basenames of the files to compile. The names may include
503 # relative or absolute path names. No wildcard is allowed
504 # - cflags (default $(CFLAGS)): the C flags to use for compilation
505 # - dflags: the flags used during creation of dependency file. If not specified
506 # the same value as cflags will be used
507 # - targetdir: the directory to put the .o file and the .d file. By default
508 # it is put in the same directory as the .c file. When targetdir is not
509 # empty, path names will be stripped from the file names so that all files
510 # are in that dir and not in subdirectories.
511 # - compiler (default target): compiler to use, target, kernel or host
512 # - suffix (default .cpp): suffix for source files to compile
513 %define rule_compile_cxx_multi basenames=/A cflags=$(CFLAGS) dflags= \
514 targetdir= compiler=target suffix=.cpp
516 # Adjust compiler flags to suit C++
517 TMP_CXXFLAGS := %(cflags)
518 TMP_CXXFLAGS := $(TMP_CXXFLAGS) -fno-rtti -fno-exceptions -fno-check-new -isystem $(AROS_DEVELOPMENT)/include
519 TMP_CXXFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(TMP_CXXFLAGS)))
522 TMP_TARGETS := $(addsuffix .o,%(basenames))
523 TMP_DTARGETS := $(addsuffix .d,%(basenames))
526 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
527 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
528 TMP_WILDCARD := %(targetdir)/%
530 # Be sure that all source files are generated
531 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix %(suffix),%(basenames))
533 # Be sure that all source files are found
534 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
535 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
536 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
538 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
539 vpath %%(suffix) $(TMP_DIRS)
543 # Define the use of cross compiler
544 ifeq ($(TARGET_CXX),)
545 TMP_CC := $(CROSSTOOLSDIR)/$(AROS_TARGET_CPU)-aros-g++
547 TMP_CC := $(TARGET_CXX)
550 ifeq ($(findstring %(compiler),host kernel target),)
551 $(error unknown compiler %(compiler))
553 ifeq (%(compiler),target)
554 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TMP_CC) $(TARGET_CFLAGS)
555 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
556 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
558 ifeq (%(compiler),host)
559 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_CXX)
560 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
561 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
563 ifeq (%(compiler),kernel)
564 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_CXX) $(KERNEL_CFLAGS)
565 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
566 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
569 $(TMP_TARGETS) : CFLAGS := $(TMP_CXXFLAGS)
570 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %%(suffix)
571 %compile_q cmd=$(CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
574 $(TMP_DTARGETS) : DFLAGS:=$(TMP_CXXFLAGS)
576 ifeq (%(dflags),%(cflags))
577 $(TMP_DTARGETS) : DFLAGS:=$(TMP_CXXFLAGS)
579 $(TMP_DTARGETS) : DFLAGS:=%(dflags)
582 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %%(suffix)
583 %mkdepend_q cc=$(CMD) flags=$(DFLAGS)
585 #------------------------------------------------------------------------------
588 #------------------------------------------------------------------------------
589 # Generate a rule to compile an ObjC source file to an object file and generate
590 # the dependency file. Basename may contain a directory part, then the source
591 # file has to be in that directory. The generated file will be put in the
592 # object directory without the directory.
594 # - basename: the basename of the file to compile. Use % for a wildcard rule
595 # - cflags (default $(CFLAGS)): the C flags to use for compilation
596 # - dflags: the flags used during creation of dependency file. If not specified
597 # the same value as cflags will be used
598 # - targetdir: the directory to put the .o file and the .d file. By default
599 # it is put in the same directory as the .m file
600 %define rule_compile_objc basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target nix=no
603 TMP_TARGETBASE := %(basename)
605 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
608 # Adjust compiler flags to suit ObjC
609 TMP_OBJCFLAGS := %(cflags)
610 TMP_OBJCFLAGS := $(TMP_OBJCFLAGS) -isystem $(AROS_DEVELOPMENT)/include
611 TMP_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(TMP_OBJCFLAGS)))
613 ifeq ($(findstring %(compiler),host kernel target),)
614 $(error unknown compiler %(compiler))
616 ifeq (%(compiler),target)
617 $(TMP_TARGETBASE).o : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
618 $(TMP_TARGETBASE).d : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
619 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
620 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
621 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
622 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
624 ifeq (%(compiler),host)
625 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
626 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
627 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
628 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
629 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
630 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
632 ifeq (%(compiler),kernel)
633 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
634 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
635 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
636 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
637 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
638 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
642 $(TMP_TARGETBASE).o : CFLAGS := -nix $(TMP_OBJCFLAGS)
644 $(TMP_TARGETBASE).o : CFLAGS := $(TMP_OBJCFLAGS)
646 $(TMP_TARGETBASE).o : %(basename).m
647 %compile_q cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
651 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix $(TMP_OBJCFLAGS)
653 $(TMP_TARGETBASE).d : TMP_DFLAGS:=$(TMP_OBJCFLAGS)
657 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(dflags)
659 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(dflags)
662 $(TMP_TARGETBASE).d : %(basename).m
663 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
665 #------------------------------------------------------------------------------
667 #------------------------------------------------------------------------------
668 # Generate a rule to compile multiple ObjC source files to an object file and
669 # generate the corresponding dependency files. The generated file will be put
670 # in the object directory without the directory part of the source file.
672 # - basenames: the basenames of the files to compile. The names may include
673 # relative or absolute path names. No wildcard is allowed
674 # - cflags (default $(CFLAGS)): the C flags to use for compilation
675 # - dflags: the flags used during creation of dependency file. If not specified
676 # the same value as cflags will be used
677 # - targetdir: the directory to put the .o file and the .d file. By default
678 # it is put in the same directory as the .m file. When targetdir is not
679 # empty, path names will be stripped from the file names so that all files
680 # are in that dir and not in subdirectories.
681 # - compiler (default target): compiler to use, target, kernel or host
682 %define rule_compile_objc_multi basenames=/A cflags=$(CFLAGS) dflags= \
683 targetdir= compiler=target
685 # Adjust compiler flags to suit ObjC
686 TMP_OBJCFLAGS := %(cflags)
687 TMP_OBJCFLAGS := $(TMP_OBJCFLAGS) -isystem $(AROS_DEVELOPMENT)/include
688 TMP_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(TMP_OBJCFLAGS)))
691 TMP_TARGETS := $(addsuffix .o,%(basenames))
692 TMP_DTARGETS := $(addsuffix .d,%(basenames))
695 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,%(basenames)))
696 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,%(basenames)))
697 TMP_WILDCARD := %(targetdir)/%
699 # Be sure that all .m files are generated
700 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .m,%(basenames))
702 # Be sure that all .m files are found
703 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
704 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
705 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
707 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
708 vpath %.m $(TMP_DIRS)
712 # Define the use of cross compiler
713 ifeq ($(TARGET_OBJC),)
714 TMP_CC := $(TARGET_CC)
716 TMP_CC := $(TARGET_OBJC)
719 ifeq ($(findstring %(compiler),host kernel target),)
720 $(error unknown compiler %(compiler))
722 ifeq (%(compiler),target)
723 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TMP_CC) $(TARGET_CFLAGS)
724 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
725 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
727 ifeq (%(compiler),host)
728 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_OBJC)
729 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
730 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
732 ifeq (%(compiler),kernel)
733 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_OBJC) $(KERNEL_CFLAGS)
734 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
735 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
738 $(TMP_TARGETS) : CFLAGS := $(TMP_OBJCFLAGS)
739 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.m
740 %compile_q cmd=$(CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
743 $(TMP_DTARGETS) : DFLAGS:=$(TMP_OBJCFLAGS)
745 ifeq (%(dflags),%(cflags))
746 $(TMP_DTARGETS) : DFLAGS:=$(TMP_OBJCFLAGS)
748 $(TMP_DTARGETS) : DFLAGS:=%(dflags)
751 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.m
752 %mkdepend_q cc=$(CMD) flags=$(DFLAGS)
754 #------------------------------------------------------------------------------
757 #------------------------------------------------------------------------------
758 # Make an alias from one arch specific build to another arch.
760 # - mainmmake: the mmake of the module in the main tree
761 # - arch: the current arch
762 # - alias: the alias to which this should point
763 %define rule_archalias mainmmake=\A arch=\A alias=\A
765 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
767 #------------------------------------------------------------------------------
770 #------------------------------------------------------------------------------
771 # Generate a rule to assemble a source file to an object file. Basename may
772 # contain a directory part, then the source file has to be in that directory.
773 # The generated file will be put in the object directory without the directory.
775 # - basename: the basename of the file to compile. Use % for a wildcard rule
776 # - flags (default $(AFLAGS)): the asm flags to use for assembling
777 # - targetdir: the directory to put the .o file in. By default it is put in the
778 # same directory as the .s file
779 %define rule_assemble basename=/A aflags=$(AFLAGS) targetdir=
782 %(basename).o : AFLAGS := %(aflags)
783 %(basename).o : %(basename).s
785 %(basename).o : %(basename).S
789 %(targetdir)/$(notdir %(basename)).o : AFLAGS := %(aflags)
790 %(targetdir)/$(notdir %(basename)).o : %(basename).s
792 %(targetdir)/$(notdir %(basename)).o : %(basename).S
797 #------------------------------------------------------------------------------
800 #------------------------------------------------------------------------------
801 # Generate a rule to assemble multiple source files to an object file. The
802 # generated file will be put in the object directory with the directory part
803 # of the source file stripped off.
805 # - basenames: the basenames of the files to compile. The names may include
806 # relative or absolute path names. No wildcard is allowed
807 # - aflags (default $(AFLAGS)): the flags to use for assembly
808 # - targetdir: the directory to put the .o file and the .d file. By default
809 # it is put in the same directory as the .c file. When targetdir is not
810 # empty, path names will be stripped from the file names so that all files
811 # are in that dir and not in subdirectories.
812 %define rule_assemble_multi basenames=/A aflags=$(AFLAGS) targetdir= suffix=.s compiler=target
815 TMP_TARGETS := $(addsuffix .o,%(basenames))
818 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
819 TMP_WILDCARD := %(targetdir)/%
821 # Be sure that all .s files are generated
822 $(TMP_TARGETS) : | $(addsuffix %(suffix),%(basenames))
824 # Be sure that all .c files are found
825 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
826 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
827 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
829 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
830 vpath %%(suffix) $(TMP_DIRS)
835 ifeq ($(findstring %(compiler),host kernel target),)
836 $(error unknown compiler %(compiler))
838 ifeq (%(compiler),target)
839 $(TMP_TARGETS) : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
841 ifeq (%(compiler),host)
842 $(TMP_TARGETS) : TMP_CMD:=$(HOST_CC)
844 ifeq (%(compiler),kernel)
845 $(TMP_TARGETS) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
848 $(TMP_TARGETS) : AFLAGS := %(aflags)
849 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %%(suffix)
850 %assemble_q cmd=$(TMP_CMD) opt=$(AFLAGS)
852 #------------------------------------------------------------------------------
855 #------------------------------------------------------------------------------
856 # Link %(objs) to %(prog) using the libraries in %(uselibs)
857 %define rule_link_prog prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
858 usehostlibs= usestartup=yes detach=no nix=no linker=target
863 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
865 ifeq (%(usestartup),no)
866 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
867 TMP_EXTRA_LIBS += arosc.static
868 ifeq (%(linker),target)
869 TMP_EXTRA_LIBS += libinit autoinit
873 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
876 # Make a list of the lib files this program depends on.
877 # In LDFLAGS remove white space between -L and directory
878 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
879 # Filter out only the libdirs and remove -L
880 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
882 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
883 # Add normal linklib path
884 TMP_DIRS += $(LIBDIR)/
885 # add lib and .a to static linklib names
886 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(TMP_EXTRA_LIBS)))
887 ifeq (%(usestartup),yes)
888 TMP_LIBS += startup.o
893 # search for the linklibs in the given path, ignore ones not found
894 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
895 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
898 ifeq (%(linker),target)
899 %(prog) : CMD:=$(TARGET_CC)
900 %(prog) : STRIPCMD:=$(TARGET_STRIP)
902 ifeq (%(linker),host)
903 %(prog) : CMD:=$(HOST_CC)
904 %(prog) : STRIPCMD:=$(HOST_STRIP)
906 ifeq (%(linker),kernel)
907 %(prog) : CMD:=$(KERNEL_CC) $(KERNEL_LDFLAGS)
908 %(prog) : STRIPCMD:=$(ECHO) >/dev/null
911 %(prog) : OBJS := %(objs)
912 %(prog) : LDFLAGS := %(ldflags) $(TMP_EXTRA_LDFLAGS)
913 %(prog) : LIBS := $(addprefix -l,%(uselibs) $(TMP_EXTRA_LIBS) %(usehostlibs))
914 %(prog) : %(objs) $(TMP_DEPLIBS)
915 %link_q from=$(OBJS) opt=$(LDFLAGS) libs=$(LIBS) cmd=$(CMD) strip=$(STRIPCMD)
917 #------------------------------------------------------------------------------
920 #------------------------------------------------------------------------------
921 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
922 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
923 %define rule_link_progs progs=/A targetdir=$(AROSDIR)/$(CURDIR) nix=%(nix) \
924 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
925 usestartup=yes detach=no
930 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
932 ifeq (%(usestartup),no)
933 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
934 TMP_EXTRA_LIBS += arosc.static libinit autoinit
937 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
940 # Make a list of the lib files the programs depend on.
941 # In LDFLAGS remove white space between -L and directory
942 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
943 # Filter out only the libdirs and remove -L
944 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
946 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
947 # Add normal linklib path
948 TMP_DIRS += $(LIBDIR)/
949 # add lib and .a to static linklib names
950 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(TMP_EXTRA_LIBS)))
951 # search for the linklibs in the given path, ignore ones not found
952 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
953 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
956 $(addprefix %(targetdir)/,%(progs)) : LDFLAGS:= %(ldflags) $(TMP_EXTRA_LDFLAGS)
957 $(addprefix %(targetdir)/,%(progs)) : LIBS:= $(addprefix -l,%(uselibs) $(TMP_EXTRA_LIBS) %(usehostlibs))
958 $(addprefix %(targetdir)/,%(progs)) : %(targetdir)/% : %(objdir)/%.o $(TMP_DEPLIBS)
959 %link_q from=$< opt=$(LDFLAGS) libs=$(LIBS)
961 #------------------------------------------------------------------------------
964 #------------------------------------------------------------------------------
965 # Link the %(objs) to the library %(libdir)/lib%(libname).a
966 %define rule_link_linklib libname=/A objs=/A libdir=$(LIBDIR) linker=target
968 ifeq (%(linker),target)
969 %(libdir)/lib%(libname).a : TMP_AR:=$(AR)
970 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(RANLIB)
972 ifeq (%(linker),host)
973 %(libdir)/lib%(libname).a : TMP_AR:=$(HOST_AR)
974 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(HOST_RANLIB)
976 ifeq (%(linker),kernel)
977 %(libdir)/lib%(libname).a : TMP_AR:=$(KERNEL_AR)
978 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(KERNEL_RANLIB)
981 %(libdir)/lib%(libname).a : %(objs)
982 %mklib_q from=$^ ar=$(TMP_AR) ranlib=$(TMP_RANLIB)
984 #------------------------------------------------------------------------------
986 #------------------------------------------------------------------------------
987 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
988 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
989 # The -noarosc flag is added so that modules are not linked with arosc.library
990 # (see /config/specs.in file)
991 %define rule_linkmodule module=/A objs=/A endobj=/A err=/A objdir=$(OBJDIR) \
992 ldflags=$(LDFLAGS) uselibs= usehostlibs=
994 TMP_LDFLAGS := %(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 $(TMP_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 += $(LIBDIR)/
1004 # add lib and .a to static linklib names
1005 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) libinit autoinit))
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)))) \
1011 %(module) : LIB_NAMES := %(uselibs)
1012 %(module) : OBJS := %(objs)
1013 %(module) : ENDTAG := %(endobj)
1014 %(module) : ERR := %(err)
1015 %(module) : OBJDIR := %(objdir)
1016 %(module) : LDFLAGS := $(TMP_LDFLAGS)
1017 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES)) \
1018 -L/usr/lib $(addprefix -l,%(usehostlibs))
1019 %(module) : %(objs) %(endobj) $(TMP_DEPLIBS) $(USER_DEPLIBS)
1020 %link_module_q err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS) objdir=$(OBJDIR) ldflags="$(LDFLAGS) -noarosc"
1023 #------------------------------------------------------------------------------
1026 #------------------------------------------------------------------------------
1027 # Generate the libdefs.h include file for a module.
1028 %define rule_genmodule_genlibdefs modname=/A modtype=/A modsuffix= conffile= targetdir= version=
1030 TMP_TARGET := %(modname)_libdefs.h
1031 TMP_DEPS := $(GENMODULE)
1033 ifneq (%(conffile),)
1034 ifeq ($(dir %(conffile)),./)
1035 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1036 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1038 TMP_OPTS += -c %(conffile)
1039 TMP_DEPS += %(conffile)
1042 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1043 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1045 ifneq (%(modsuffix),)
1046 TMP_OPTS += -s %(modsuffix)
1048 ifneq (%(targetdir),)
1049 TMP_OPTS += -d %(targetdir)
1050 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1053 TMP_OPTS += -v %(version)
1056 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1057 $(TMP_TARGET) : MODNAME := %(modname)
1058 $(TMP_TARGET) : MODTYPE := %(modtype)
1059 $(TMP_TARGET) : $(TMP_DEPS)
1060 @$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1061 @$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
1063 #------------------------------------------------------------------------------
1065 #------------------------------------------------------------------------------
1066 # Generate the _lib.fd file for a module.
1067 %define rule_genmodule_fd modname=/A modtype=/A modsuffix= conffile= targetdir=
1069 TMP_TARGET := %(modname)_lib.fd
1070 TMP_DEPS := $(GENMODULE)
1072 ifneq (%(conffile),)
1073 ifeq ($(dir %(conffile)),./)
1074 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1075 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1077 TMP_OPTS += -c %(conffile)
1078 TMP_DEPS += %(conffile)
1081 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1082 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1084 ifneq (%(modsuffix),)
1085 TMP_OPTS += -s %(modsuffix)
1087 ifneq (%(targetdir),)
1088 TMP_OPTS += -d %(targetdir)
1089 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1092 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1093 $(TMP_TARGET) : MODNAME := %(modname)
1094 $(TMP_TARGET) : MODTYPE := %(modtype)
1095 $(TMP_TARGET) : $(TMP_DEPS)
1096 @$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1097 @$(GENMODULE) $(OPTS) writefd $(MODNAME) $(MODTYPE)
1099 #------------------------------------------------------------------------------
1101 #------------------------------------------------------------------------------
1102 # Generate a Makefile.%(modname)%(modtype) with the genmodule program and include this
1103 # generated file in this Makefile
1104 %define rule_genmodule_makefile modname=/A modtype=/A modsuffix= conffile= \
1107 TMP_TARGET := Makefile.%(modname)%(modtype)
1108 TMP_DEPS := $(GENMODULE)
1110 ifneq (%(conffile),)
1111 ifeq ($(dir %(conffile)),./)
1112 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1113 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1115 TMP_OPTS += -c %(conffile)
1116 TMP_DEPS += %(conffile)
1119 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1120 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1122 ifneq (%(modsuffix),)
1123 TMP_OPTS += -s %(modsuffix)
1125 ifneq (%(targetdir),)
1126 TMP_OPTS += -d %(targetdir)
1127 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1130 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1131 $(TMP_TARGET) : MODNAME := %(modname)
1132 $(TMP_TARGET) : MODTYPE := %(modtype)
1133 $(TMP_TARGET) : $(TMP_DEPS)
1134 @$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
1136 #------------------------------------------------------------------------------
1139 #------------------------------------------------------------------------------
1140 # Generate the support files for compiling a module. This includes include
1141 # files and source files. This rule has to be preceeded by
1142 # %rule_genmodule_makefile
1143 %define rule_genmodule_files modname=/A modtype=/A modsuffix= targetdir= \
1146 TMP_TARGETS := $(%(modname)_STARTFILES) $(%(modname)_ENDFILES) \
1147 $(%(modname)_LINKLIBFILES) $(%(modname)_RELLINKLIBFILES)
1148 TMP_TARGETS := $(addsuffix .c,$(TMP_TARGETS)) \
1149 $(addsuffix .S, $(%(modname)_LINKLIBAFILES) $(%(modname)_RELLINKLIBAFILES))
1151 TMP_DEPS := $(GENMODULE)
1154 ifneq (%(conffile),)
1155 ifeq ($(dir %(conffile)),./)
1156 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1157 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1159 TMP_OPTS += -c %(conffile)
1160 TMP_DEPS += %(conffile)
1163 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1164 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1166 ifneq (%(modsuffix),)
1167 TMP_OPTS += -s %(modsuffix)
1169 ifneq (%(targetdir),)
1170 TMP_OPTS += -d %(targetdir)
1171 TMP_TARGETDIR := $(shell echo %(targetdir) | sed 's/^\(.\):\//\/\1\//')
1172 TMP_TARGETS := $(addprefix $(TMP_TARGETDIR)/,$(TMP_TARGETS))
1175 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
1176 $(TMP_TARGETS) : MODNAME := %(modname)
1177 $(TMP_TARGETS) : MODTYPE := %(modtype)
1178 $(TMP_TARGETS) : $(TMP_DEPS)
1179 @$(ECHO) "Generating support files for module $(MODNAME$(BDID))"
1180 ifneq (%(conffile),lib.conf)
1181 @$(IF) $(TEST) -f lib.conf; then \
1182 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
1185 @$(IF) $(TEST) -f libdefs.h; then \
1186 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
1188 @$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
1190 #------------------------------------------------------------------------------
1193 #------------------------------------------------------------------------------
1194 # Generate the support files for compiling a module. This includes include
1195 # files and source files.
1196 %define rule_genmodule_includes modname=/A modtype=/A modsuffix= \
1197 targetdir= conffile=
1199 ifneq ($(%(modname)_INCLUDES),)
1200 TMP_TARGETS := $(%(modname)_INCLUDES)
1202 TMP_DEPS := $(GENMODULE)
1205 ifneq (%(conffile),)
1206 ifeq ($(dir %(conffile)),./)
1207 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1208 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1210 TMP_OPTS += -c %(conffile)
1211 TMP_DEPS += %(conffile)
1214 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1215 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1217 ifneq (%(modsuffix),)
1218 TMP_OPTS += -s %(modsuffix)
1220 ifneq (%(targetdir),)
1221 TMP_OPTS += -d %(targetdir)
1222 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
1225 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
1226 $(TMP_TARGETS) : MODNAME := %(modname)
1227 $(TMP_TARGETS) : MODTYPE := %(modtype)
1228 $(TMP_TARGETS) : $(TMP_DEPS)
1229 @$(ECHO) "Generating $(MODNAME).$(MODTYPE) includes"
1230 @$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
1233 #------------------------------------------------------------------------------
1235 #------------------------------------------------------------------------------
1236 # Link %(objs) to binary blob in %(file) using %(name) as name of embedded binary object
1237 # 'start' is an optional starting address
1238 # 'ldflags' is optional additional flags for the linker
1239 %define rule_link_binary file=/A name=/A objs= files= start=0 ldflags=
1241 BD_OUTDIR := $(dir %(file))
1242 # This trick removes the trailing '/', otherwise findstring below fails, causing a warning
1243 BD_OUTDIR := $(subst /*,,$(addsuffix *,$(BD_OUTDIR)))
1244 BD_TMPDIR := $(GENDIR)/$(CURDIR)
1245 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(notdir %(files))))
1246 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(notdir %(files))))
1249 %rule_compile_multi basenames=%(files) targetdir=$(BD_OBJDIR)
1251 %(file) : $(BD_OBJS) $(BD_DEPS) $(BD_OUTDIR)
1252 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)..."
1253 @$(KERNEL_LD) %(ldflags) --entry=%(start) --oformat=binary -Ttext=%(start) -o $(BD_TMPDIR)/%(name) $(BD_OBJS)
1254 @cd $(BD_TMPDIR) && $(AROS_LD) %(ldflags) -r --format binary %(name) -o $@
1256 ifeq ($(findstring $(BD_OUTDIR),$(GLOB_MKDIRS)),)
1257 GLOB_MKDIRS += $(BD_OUTDIR)
1262 #------------------------------------------------------------------------------
1263 # Common rules for all makefiles
1265 # Delete generated makefiles
1268 @$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
1270 include $(SRCDIR)/config/make.tail
1272 BDID := $(BDTARGETID)
1274 #------------------------------------------------------------------------------
1277 #############################################################################
1278 #############################################################################
1280 ## Here are the mmakefile build macros. These are macros that takes care ##
1281 ## of everything to go from the sources to the generated target. Also all ##
1282 ## intermediate files and directories that are needed are created by these ##
1285 #############################################################################
1286 #############################################################################
1288 #------------------------------------------------------------------------------
1290 %define build_prog mmake=/A progname=/A files=$(BD_PROGNAME) cxxfiles= \
1292 asmfiles= objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1293 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
1294 aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
1295 compiler=target linker=
1299 BD_PROGNAME := %(progname)
1300 BD_OBJDIR := %(objdir)
1301 BD_TARGETDIR := %(targetdir)
1302 BD_LINKER := %(linker)
1304 # If not supplied, linker is equal to compiler
1305 ifeq ($(BD_LINKER),)
1306 BD_LINKER := %(compiler)
1309 BD_FILES := %(files)
1310 BD_CXXFILES := %(cxxfiles)
1311 BD_OBJCFILES := %(objcfiles)
1312 BD_ASMFILES := %(asmfiles)
1314 BD_ARCHOBJS := $(wildcard $(BD_OBJDIR)/arch/*.o)
1315 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1316 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1318 TMP_FILES := $(BD_NARCHFILES) $(BD_CXXFILES) $(BD_ASMFILES) $(BD_OBJCFILES)
1319 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(notdir $(TMP_FILES))))
1320 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(notdir $(TMP_FILES))))
1322 BD_CFLAGS := %(cflags)
1323 BD_AFLAGS := %(aflags)
1324 BD_DFLAGS := %(dflags)
1325 BD_LDFLAGS := %(ldflags)
1328 %(mmake)-quick : %(mmake)
1330 #MM %(mmake) : includes-generate-deps core-linklibs linklibs-%(uselibs)
1331 %(mmake) : $(BD_TARGETDIR)/$(BD_PROGNAME)
1333 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick %(mmake)-gz-quick),)
1334 %rule_compile_multi basenames=$(BD_NARCHFILES) targetdir=$(BD_OBJDIR) \
1335 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler=%(compiler)
1336 %rule_compile_cxx_multi basenames=$(BD_CXXFILES) targetdir=$(BD_OBJDIR) \
1337 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler=%(compiler)
1338 %rule_compile_objc_multi basenames=$(BD_OBJCFILES) targetdir=$(BD_OBJDIR) \
1339 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler=%(compiler)
1340 %rule_assemble_multi basenames=$(BD_ASMFILES) targetdir=$(BD_OBJDIR) \
1341 aflags=$(BD_AFLAGS) compiler=%(compiler)
1343 %rule_link_prog prog=$(BD_TARGETDIR)/$(BD_PROGNAME) \
1344 objs="$(BD_OBJS) $(BD_ARCHOBJS) $(USER_OBJS)" ldflags=$(BD_LDFLAGS) \
1345 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1346 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)" \
1351 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1353 $(BD_OBJS) $(BD_DEPS) : | $(BD_OBJDIR)
1354 $(BD_TARGETDIR)/$(BD_PROGNAME) : | $(BD_TARGETDIR)
1355 GLOB_MKDIRS += $(BD_OBJDIR) $(BD_TARGETDIR)
1357 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_TARGETDIR)/$(BD_PROGNAME) $(BD_DEPS)
1360 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1364 #------------------------------------------------------------------------------
1367 #------------------------------------------------------------------------------
1368 # Build programs, for every C file an executable will be built with the same
1369 # name as the C file
1370 %define build_progs mmake=/A files=/A nix=no \
1371 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1372 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
1373 uselibs= usehostlibs= usestartup=yes detach=no
1377 BD_OBJDIR := %(objdir)
1378 BD_TARGETDIR := %(targetdir)
1380 BD_FILES := %(files)
1381 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1382 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1383 BD_EXES := $(addprefix $(BD_TARGETDIR)/,$(BD_FILES))
1385 BD_CFLAGS := %(cflags)
1386 BD_DFLAGS := %(dflags)
1387 BD_LDFLAGS := %(ldflags)
1390 %(mmake)-quick : %(mmake)
1392 #MM %(mmake) : includes-generate-deps core-linklibs linklibs-%(uselibs)
1393 %(mmake) : $(BD_EXES)
1395 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1396 %rule_compile basename=% targetdir=$(BD_OBJDIR) nix=%(nix) \
1397 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1399 %rule_link_progs progs=$(BD_FILES) nix=%(nix) \
1400 targetdir=$(BD_TARGETDIR) objdir=$(BD_OBJDIR) \
1401 ldflags=$(BD_LDFLAGS) \
1402 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1403 usestartup="%(usestartup)" detach="%(detach)"
1407 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1409 $(addprefix $(BD_TARGETDIR)/,$(BD_FILES)) : | $(BD_TARGETDIR)
1410 $(BD_DEPS) $(BD_OBJS) : | $(BD_OBJDIR)
1411 GLOB_MKDIRS += $(BD_TARGETDIR) $(BD_OBJDIR)
1413 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_EXES) $(BD_DEPS)
1416 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1420 #------------------------------------------------------------------------------
1423 #------------------------------------------------------------------------------
1425 # This is a bare version: It just compiles and links the given files. It is
1426 # assumed that all needed boiler plate code is in the files. This should only
1427 # be used for compiling external code. For AROS code use %build_module
1428 %define build_module_simple mmake=/A modname=/A modtype=/A \
1429 files="$(basename $(call WILDCARD, *.c))" \
1430 cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1431 objdir=$(OBJDIR) moduledir= \
1432 uselibs= usehostlibs= compiler=target
1434 # Define metamake targets and their dependencies
1435 #MM %(mmake) : core-linklibs includes-generate-deps
1436 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1437 #MM %(mmake)-pkg : core-linklibs includes-generate-deps
1438 #MM %(mmake)-kobj-quick
1439 #MM %(mmake)-pkg-quick
1443 BD_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj %(mmake)-pkg
1445 .PHONY : $(BD_ALLTARGETS)
1448 $(error using %build_module_simple: modname may not be empty)
1451 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1454 # Default values for variables and arguments
1455 BD_DEFLINKLIBNAME := %(modname)
1456 BD_DEFDFLAGS := %(cflags)
1457 OBJDIR ?= $(GENDIR)/$(CURDIR)
1458 BD_MODDIR := %(moduledir)
1459 ifeq ($(BD_MODDIR),)
1460 ifeq (%(modtype),library)
1461 BD_MODDIR := $(AROS_LIBS)
1463 ifeq (%(modtype),gadget)
1464 BD_MODDIR := $(AROS_GADGETS)
1466 ifeq (%(modtype),datatype)
1467 BD_MODDIR := $(AROS_DATATYPES)
1469 ifeq (%(modtype),handler)
1470 BD_MODDIR := $(AROS_FS)
1472 ifeq (%(modtype),device)
1473 BD_MODDIR := $(AROS_DEVS)
1475 ifeq (%(modtype),resource)
1476 BD_MODDIR := $(AROS_RESOURCES)
1478 ifeq (%(modtype),hook)
1479 BD_MODDIR := $(AROS_RESOURCES)
1481 ifeq (%(modtype),mui)
1482 BD_MODDIR := $(AROS_CLASSES)/Zune
1484 ifeq (%(modtype),mcc)
1485 BD_MODDIR := $(AROS_CLASSES)/Zune
1487 ifeq (%(modtype),mcp)
1488 BD_MODDIR := $(AROS_CLASSES)/Zune
1490 ifeq (%(modtype),usbclass)
1491 BD_MODDIR := $(AROS_CLASSES)/USB
1493 ifeq (%(modtype),hidd)
1494 BD_MODDIR := $(AROS_DRIVERS)
1496 ifeq (%(modtype),printer)
1497 BD_MODDIR := $(AROS_PRINTERS)
1500 ifeq ($(BD_MODDIR),)
1501 $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1504 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1505 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1506 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),%(files))
1508 %rule_compile_multi \
1509 basenames="$(BD_NARCHFILES)" targetdir="%(objdir)" \
1510 cflags="%(cflags)" dflags="%(dflags)" \
1511 compiler=%(compiler)
1513 # Handlers use dash instead of dot in their names
1514 ifeq (%(modtype),handler)
1515 BD_MODULE := $(BD_MODDIR)/%(modname)-%(modtype)
1516 BD_PKGMOD := $(PKGDIR)/%(modname)-%(modtype)
1518 ifeq (%(modtype),printer)
1519 BD_MODULE := $(BD_MODDIR)/%(modname)
1520 BD_PKGMOD := $(PKGDIR)/%(modname)
1522 BD_MODULE := $(BD_MODDIR)/%(modname).%(modtype)
1523 BD_PKGMOD := $(PKGDIR)/%(modname).%(modtype)
1526 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1528 %(mmake)-quick : %(mmake)
1529 %(mmake)-pkg-quick : $(BD_PKGMOD)
1530 %(mmake)-kobj-quick : $(BD_KOBJ)
1531 %(mmake) : $(BD_MODULE)
1532 %(mmake)-pkg : $(BD_PKGMOD)
1533 %(mmake)-kobj : $(BD_KOBJ)
1535 # The module is linked from all the compiled .o files
1536 BD_OBJS := $(BD_ARCHOBJS) $(addprefix %(objdir)/, $(addsuffix .o,$(notdir $(BD_NARCHFILES))))
1538 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
1539 # This breaks con-handler build. Here we work around this
1540 ifeq (%(modname),con)
1541 BD_ERR := $(notdir $(BD_MODULE)).err
1543 BD_ERR := %(modname).err
1546 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1547 endobj= err=$(BD_ERR) objdir=%(objdir) \
1548 ldflags="$(LDFLAGS) $(%(modname)_LDFLAGS)" \
1549 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
1551 %rule_linkmodule module=$(BD_PKGMOD) objs=$(BD_OBJS) \
1552 endobj= err=$(BD_ERR) objdir=%(objdir) \
1553 ldflags="$(LDFLAGS) $(%(modname)_LDFLAGS)" \
1554 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
1556 # Link kernel object file
1557 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1559 # Make these symbols local
1560 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1561 UtilityBase ExpansionBase KeymapBase KernelBase
1563 BD_SYMBOLS := $(BD_KBASE)
1565 BD_KLIB := hiddstubs amiga arossupport arosc.static arosm autoinit libinit
1566 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1567 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1568 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
1569 $(BD_KOBJ) : USER_LDFLAGS := $(USER_LDFLAGS)
1570 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1571 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
1572 @$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1573 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
1576 ## Dependency fine-tuning
1578 BD_DEPS := $(addprefix %(objdir)/, $(addsuffix .d,%(files)))
1579 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj %(mmake)-pkg" deps=$(BD_DEPS)
1581 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1582 $(BD_MODULE) : | $(BD_MODDIR)
1583 $(BD_KOBJ) : | $(KOBJSDIR)
1584 GLOB_MKDIRS += %(objdir) $(BD_MODDIR) $(KOBJSDIR)
1586 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_MODULE) $(BD_KOBJ) $(BD_DEPS)
1588 @$(ECHO) "Cleaning up for module %(modname)"
1591 #------------------------------------------------------------------------------
1594 #------------------------------------------------------------------------------
1596 # Explanation of this macro is done in the developer's manual
1597 %define build_module mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
1598 files="$(basename $(call WILDCARD, *.c))" \
1599 cxxfiles="$(basename $(call WILDCARD, *.cpp))" \
1600 cxxccfiles="$(basename $(call WILDCARD, *.cc))" \
1601 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1602 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
1603 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
1604 compiler=target nostartup=yes
1606 # Define metamake targets and their dependencies
1607 #MM- includes-all : %(mmake)-includes
1608 #MM- linklibs-%(modname): %(mmake)-linklib
1609 #MM- linklibs-%(modname)_rel : %(mmake)-linklib
1610 #MM- includes-%(modname): %(mmake)-includes
1611 #MM- includes-%(modname)_rel : %(mmake)-includes
1612 #MM %(mmake) : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1613 #MM %(mmake)-kobj : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1614 #MM %(mmake)-kobj-quick : %(mmake)-includes-quick
1615 #MM %(mmake)-pkg : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1616 #MM %(mmake)-pkg-quick : %(mmake)-includes-quick
1617 #MM %(mmake)-linklib : %(mmake)-includes includes-%(uselibs)
1618 #MM %(mmake)-quick : %(mmake)-includes-quick
1619 #MM %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1620 #MM includes-generate-deps %(mmake)-fd
1621 #MM %(mmake)-includes-quick
1622 #MM %(mmake)-includes-dirs
1624 #MM %(mmake)-makefile
1627 # All MetaMake targets defined by this macro
1628 BD_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-includes \
1629 %(mmake)-includes-quick %(mmake)-includes-dirs %(mmake)-clean \
1630 %(mmake)-kobj %(mmake)-kobj-quick %(mmake)-pkg %(mmake)-pkg-quick \
1631 %(mmake)-linklib %(mmake)-fd
1633 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1636 $(error using %build_module: modname may not be empty)
1639 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1642 # Default values for variables and arguments
1643 BD_DEFLINKLIBNAME := %(modname)
1644 BD_DEFDFLAGS := %(cflags)
1645 OBJDIR ?= $(GENDIR)/$(CURDIR)
1647 ## Create genmodule include Makefile for the module
1649 %(mmake)-makefile : %(objdir)/Makefile.%(modname)%(modtype)
1651 %rule_genmodule_makefile \
1652 modname=%(modname) modtype=%(modtype) \
1653 modsuffix=%(modsuffix) targetdir=%(objdir) \
1654 conffile=%(conffile)
1656 %(objdir)/Makefile.%(modname)%(modtype) : | %(objdir)
1658 GLOB_MKDIRS += %(objdir)
1660 # Do not parse these statements if metatarget is not appropriate
1661 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1663 include %(objdir)/Makefile.%(modname)%(modtype)
1665 BD_DEFMODDIR := $(%(modname)_MODDIR)
1668 ## include files generation
1670 BD_INCDIR := %(prefix)/$(AROS_DIR_INCLUDE)
1671 BD_LIBDEFSINC := %(objdir)/include/%(modname)_libdefs.h
1672 BD_DEFLIBDEFSINC := %(objdir)/include/%(modname)_deflibdefs.h
1674 %(mmake)-includes-quick : %(mmake)-includes
1675 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1676 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1677 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1679 ifneq ($(%(modname)_INCLUDES),)
1680 %rule_genmodule_includes modname=%(modname) modtype=%(modtype) \
1681 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1682 conffile=%(conffile)
1684 %rule_copy_diff_multi \
1685 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(GENINCDIR) \
1686 stampfile=%(objdir)/%(modname)_geninc
1688 %rule_copy_diff_multi \
1689 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(BD_INCDIR) \
1690 stampfile=%(objdir)/%(modname)_incs
1692 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1694 TMP%(modname)_INCDIRS := \
1695 %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1696 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1697 $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1698 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget=%(mmake)-includes-dirs
1702 %rule_genmodule_genlibdefs modname=%(modname) modtype=%(modtype) \
1703 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1704 conffile=%(conffile) version=%(version)
1706 $(BD_DEFLIBDEFSINC) : FILENAME := $(BD_LIBDEFSINC)
1707 $(BD_DEFLIBDEFSINC) :
1708 @$(ECHO) "Generating $@"
1709 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1711 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) : | %(objdir)/include
1712 GLOB_MKDIRS += %(objdir)/include
1714 ## Extra genmodule src files generation
1716 %rule_genmodule_files modname=%(modname) modtype=%(modtype) \
1717 modsuffix=%(modsuffix) targetdir=%(objdir) \
1718 conffile=%(conffile)
1722 BD_FDDIR := $(AROS_DEVELOPMENT)/fd
1723 %(mmake)-fd : $(BD_FDDIR)/%(modname)_lib.fd
1725 %rule_genmodule_fd modname=%(modname) modtype=%(modtype) \
1726 modsuffix=%(modsuffix) targetdir=$(BD_FDDIR) conffile=%(conffile)
1728 $(BD_FDDIR)/%(modname)_lib.fd : | $(BD_FDDIR)
1730 GLOB_MKDIRS += $(BD_FDDIR)
1735 BD_FILES := %(files)
1736 BD_CXXFILES := %(cxxfiles)
1737 BD_CXXCCFILES := %(cxxccfiles)
1739 BD_FDIRS := $(sort $(dir $(BD_FILES)))
1741 BD_STARTFILES := $(addprefix %(objdir)/,$(%(modname)_STARTFILES))
1742 BD_ENDFILES := $(addprefix %(objdir)/,$(%(modname)_ENDFILES))
1744 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1745 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1746 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1748 BD_CFLAGS := %(cflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC) $(%(modname)_CFLAGS)
1749 BD_DFLAGS := %(dflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC) $(%(modname)_DFLAGS)
1751 ifeq (%(modtype),library)
1754 BD_LIBSUFFIX := .%(modtype)
1757 BD_LINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBFILES))
1758 BD_LINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBAFILES))
1759 ifeq ($(strip $(%(modname)_LINKLIBFILES) $(%(modname)_LINKLIBAFILES) %(linklibfiles)),)
1762 BD_LINKLIB := %(prefix)/$(AROS_DIR_LIB)/lib%(modname)$(BD_LIBSUFFIX).a
1763 ifneq (%(modname),%(linklibname))
1764 BD_LINKLIB += %(prefix)/$(AROS_DIR_LIB)/lib%(linklibname)$(BD_LIBSUFFIX).a
1767 BD_LINKLIBFILES := $(BD_LINKLIBCFILES) $(BD_LINKLIBAFILES)
1769 BD_RELLINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_RELLINKLIBFILES))
1770 BD_RELLINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_RELLINKLIBAFILES))
1771 ifeq ($(strip $(%(modname)_RELLINKLIBFILES) $(%(modname)_RELLINKLIBAFILES) %(linklibfiles)),)
1774 BD_RELLINKLIB := %(prefix)/$(AROS_DIR_LIB)/lib%(modname)_rel$(BD_LIBSUFFIX).a
1775 ifneq (%(modname),%(linklibname))
1776 BD_RELLINKLIB += %(prefix)/$(AROS_DIR_LIB)/lib%(linklibname)_rel$(BD_LIBSUFFIX).a
1779 BD_RELLINKLIBFILES := $(BD_RELLINKLIBCFILES) $(BD_RELLINKLIBAFILES)
1781 BD_CCFILES := $(BD_NARCHFILES) %(linklibfiles)
1782 BD_TARGETCCFILES := $(BD_STARTFILES) $(BD_ENDFILES) $(BD_LINKLIBCFILES) \
1783 $(BD_RELLINKLIBCFILES)
1785 %rule_compile_multi \
1786 basenames=$(BD_CCFILES) targetdir=%(objdir) \
1787 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) \
1788 compiler=%(compiler)
1789 %rule_compile_multi \
1790 basenames=$(BD_TARGETCCFILES) targetdir=%(objdir) \
1791 cflags="$(BD_CFLAGS) -D__AROS__" dflags=$(BD_DFLAGS) \
1792 compiler=%(compiler)
1793 %rule_compile_cxx_multi basenames=$(BD_CXXFILES) targetdir=%(objdir) \
1794 compiler=%(compiler) cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1795 %rule_compile_cxx_multi basenames=$(BD_CXXCCFILES) targetdir=%(objdir) \
1796 compiler=%(compiler) cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) suffix=.cc
1798 ifneq ($(BD_LINKLIBAFILES),)
1799 %rule_assemble_multi \
1800 basenames="$(BD_LINKLIBAFILES) $(BD_RELLINKLIBAFILES)" targetdir=%(objdir) suffix=.S
1805 ifeq (%(modsuffix),)
1806 BD_SUFFIX := %(modtype)
1808 BD_SUFFIX := %(modsuffix)
1811 # Handlers use dash instead of dot in their names
1812 ifeq ($(BD_SUFFIX),handler)
1813 BD_MODULE := %(prefix)/%(moduledir)/%(modname)-$(BD_SUFFIX)
1814 BD_PKGMOD := $(PKGDIR)/%(modname)-$(BD_SUFFIX)
1816 BD_MODULE := %(prefix)/%(moduledir)/%(modname).$(BD_SUFFIX)
1817 BD_PKGMOD := $(PKGDIR)/%(modname).$(BD_SUFFIX)
1819 BD_KOBJ := $(KOBJSDIR)/%(modname)_$(BD_SUFFIX).o
1821 %(mmake)-quick : %(mmake)
1822 %(mmake) : $(BD_MODULE) $(BD_LINKLIB) $(BD_RELLINKLIB)
1823 %(mmake)-pkg : $(BD_PKGMOD) $(BD_LINKLIB) $(BD_RELLINKLIB)
1824 %(mmake)-pkg-quick : $(BD_PKGMOD) $(BD_LINKLIB) $(BD_RELLINKLIB)
1825 %(mmake)-kobj : $(BD_KOBJ) $(BD_LINKLIB) $(BD_RELLINKLIB)
1826 %(mmake)-kobj-quick : $(BD_KOBJ) $(BD_LINKLIB) $(BD_RELLINKLIB)
1827 %(mmake)-linklib : $(BD_LINKLIB) $(BD_RELLINKLIB)
1829 BD_OBJS := $(addsuffix .o,$(BD_STARTFILES)) $(BD_ARCHOBJS) \
1830 $(addsuffix .o, $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES)))) \
1831 $(addsuffix .o, $(addprefix %(objdir)/,$(notdir $(BD_CXXFILES) $(BD_CXXCCFILES))))
1833 ifeq (%(nostartup),yes)
1834 # Handlers always have entry point
1835 ifneq (%(modtype),handler)
1836 BD_STARTOBJS := $(addsuffix .o,$(addprefix $(GENDIR)/,$(RESIDENT_BEGIN)))
1840 BD_ENDOBJS := $(addsuffix .o,$(BD_ENDFILES))
1841 BD_LINKLIBOBJS:= $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_LINKLIBFILES)) \
1844 := $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_RELLINKLIBFILES)) \
1847 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
1848 # This breaks con-handler build. Here we work around this
1849 ifeq (%(modname),con)
1850 BD_ERR := $(notdir $(BD_MODULE)).err
1852 BD_ERR := %(modname).err
1855 # The module is linked from all the compiled .o files
1856 %rule_linkmodule module=$(BD_MODULE) objs="$(BD_STARTOBJS) $(BD_OBJS) $(USER_OBJS)" \
1857 endobj=$(BD_ENDOBJS) err=$(BD_ERR) objdir=%(objdir) \
1858 ldflags="$(LDFLAGS) $(%(modname)_LDFLAGS)" \
1859 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
1861 %rule_linkmodule module=$(BD_PKGMOD) objs="$(BD_STARTOBJS) $(BD_OBJS) $(USER_OBJS)" \
1862 endobj=$(BD_ENDOBJS) err=$(BD_ERR) objdir=%(objdir) \
1863 ldflags="$(LDFLAGS) $(%(modname)_LDFLAGS)" \
1864 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
1867 ifneq ($(BD_LINKLIB),)
1868 %rule_link_linklib libname=%(modname)$(BD_LIBSUFFIX) objs=$(BD_LINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1870 ifneq (%(modname),%(linklibname))
1871 %rule_link_linklib libname=%(linklibname)$(BD_LIBSUFFIX) objs=$(BD_LINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1874 $(BD_LINKLIB) : | %(prefix)/$(AROS_DIR_LIB)
1875 GLOB_MKDIRS += %(prefix)/$(AROS_DIR_LIB)
1878 ifneq ($(BD_RELLINKLIB),)
1879 %rule_link_linklib libname=%(modname)_rel$(BD_LIBSUFFIX) objs=$(BD_RELLINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1880 ifneq (%(modname),%(linklibname))
1881 %rule_link_linklib libname=%(linklibname)_rel$(BD_LIBSUFFIX) objs=$(BD_RELLINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1884 $(BD_RELLINKLIB) : | %(prefix)/$(AROS_DIR_LIB)
1885 GLOB_MKDIRS += %(prefix)/$(AROS_DIR_LIB)
1888 # Link kernel object file
1889 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1891 # Make these symbols local
1892 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1893 UtilityBase ExpansionBase KeymapBase KernelBase
1895 BD_SYMBOLS := $(BD_KBASE)
1897 BD_KLIB := hiddstubs amiga arossupport arosc.static arosm autoinit libinit
1898 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1899 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS) $(%(modname)_LIBS)
1900 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
1901 $(BD_KOBJ) : USER_LDFLAGS:=$(USER_LDFLAGS)
1902 $(BD_KOBJ) : $(BD_OBJS) $(USER_OBJS) $(BD_ENDOBJS)
1903 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
1904 @$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1905 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
1907 ## Dependency fine-tuning
1909 BD_DEPS := $(addsuffix .d,$(addprefix %(objdir)/,$(notdir $(BD_CCFILES) $(BD_TARGETCCFILES)))) \
1910 $(addsuffix .d,$(addprefix %(objdir)/,$(notdir $(BD_CXXFILES) $(BD_CXXCCFILES))))
1911 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick %(mmake)-pkg %(mmake)-pkg-quick" deps=$(BD_DEPS)
1913 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1914 $(BD_MODULE) : | %(prefix)/%(moduledir)
1915 $(BD_PKGMOD) : | $(PKGDIR)
1916 $(BD_KOBJ) : | $(KOBJSDIR)
1917 GLOB_MKDIRS += %(objdir) %(prefix)/%(moduledir) $(KOBJSDIR) $(PKGDIR)
1919 # Some include files need to be generated before the .c can be parsed.
1920 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick %(mmake)-pkg %(mmake)-pkg-quick),) # Only for this target these deps are wanted
1922 BD_DFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
1923 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES))
1924 $(BD_DEPS) : $(BD_DFILE_DEPS)
1927 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) \
1928 $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
1929 %(objdir)/Makefile.%(modname)%(modtype) \
1930 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
1931 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1932 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1933 %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
1934 $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
1935 $(BD_DEFLIBDEFSINC) $(addsuffix .c,$(BD_STARTFILES) $(BD_ENDFILES)) \
1937 %(mmake)-clean : FILES := $(BD_TOCLEAN)
1939 @$(ECHO) "Cleaning up for module %(modname)"
1942 endif # $(TARGET) in $(BD_ALLTARGETS)
1944 #------------------------------------------------------------------------------
1947 #------------------------------------------------------------------------------
1948 # Build a module skeleton
1949 # This is a stripped-down version of build_module, it only creates include files,
1950 # but no actual object. This is used when for plugins or classes with the same
1951 # API, but no actual implementation here.
1952 %define build_module_skeleton mmake=/A modname=/A modtype=/A modsuffix= \
1954 objdir=$(OBJDIR) prefix=$(AROSDIR)
1956 # Define metamake targets and their dependencies
1957 #MM- includes-all : %(mmake)-includes
1958 #MM %(mmake) : %(mmake)-includes core-linklibs
1959 #MM %(mmake)-kobj : %(mmake)-includes core-linklibs
1960 #MM %(mmake)-pkg : %(mmake)-includes core-linklibs
1961 #MM %(mmake)-linklib : %(mmake)-includes
1962 #MM %(mmake)-quick : %(mmake)-includes-quick
1963 #MM %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1964 #MM includes-generate-deps
1965 #MM %(mmake)-includes-quick
1966 #MM %(mmake)-includes-dirs
1967 #MM %(mmake)-makefile
1970 # All MetaMake targets defined by this macro
1971 BD_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-includes \
1972 %(mmake)-includes-quick %(mmake)-includes-dirs %(mmake)-clean \
1973 %(mmake)-kobj %(mmake)-pkg
1975 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1978 $(error using %build_module_skeleton: modname may not be empty)
1981 $(error using %build_module_skeleton: $(MODTYPE) has to be defined with the type of the module)
1984 # Default values for variables and arguments
1985 BD_DEFLINKLIBNAME := %(modname)
1986 BD_DEFDFLAGS := %(cflags)
1987 OBJDIR ?= $(GENDIR)/$(CURDIR)
1989 ## Create genmodule include Makefile for the module
1991 %(mmake)-makefile : %(objdir)/Makefile.%(modname)%(modtype)
1993 %rule_genmodule_makefile \
1994 modname=%(modname) modtype=%(modtype) \
1995 modsuffix=%(modsuffix) targetdir=%(objdir) \
1996 conffile=%(conffile)
1998 %(objdir)/Makefile.%(modname)%(modtype) : | %(objdir)
2000 GLOB_MKDIRS += %(objdir)
2002 # Do not parse these statements if metatarget is not appropriate
2003 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
2005 include %(objdir)/Makefile.%(modname)%(modtype)
2007 BD_DEFMODDIR := $(%(modname)_MODDIR)
2010 ## include files generation
2012 BD_INCDIR := %(prefix)/$(AROS_DIR_INCLUDE)
2013 BD_LIBDEFSINC := %(objdir)/include/%(modname)_libdefs.h
2014 BD_DEFLIBDEFSINC := %(objdir)/include/%(modname)_deflibdefs.h
2016 %(mmake)-includes-quick : %(mmake)-includes
2017 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
2018 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
2019 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
2021 ifneq ($(%(modname)_INCLUDES),)
2022 %rule_genmodule_includes modname=%(modname) modtype=%(modtype) \
2023 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
2024 conffile=%(conffile)
2026 %rule_copy_diff_multi \
2027 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(GENINCDIR) \
2028 stampfile=%(objdir)/%(modname)_geninc
2030 %rule_copy_diff_multi \
2031 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(BD_INCDIR) \
2032 stampfile=%(objdir)/%(modname)_incs
2034 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
2036 TMP%(modname)_INCDIRS := \
2037 %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
2038 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
2039 $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
2040 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget=%(mmake)-includes-dirs
2044 %rule_genmodule_genlibdefs modname=%(modname) modtype=%(modtype) \
2045 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
2046 conffile=%(conffile)
2048 $(BD_DEFLIBDEFSINC) : FILENAME := $(BD_LIBDEFSINC)
2049 $(BD_DEFLIBDEFSINC) :
2050 @$(ECHO) "generating $@"
2051 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
2053 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) : | %(objdir)/include
2054 GLOB_MKDIRS += %(objdir)/include
2056 ## Extra genmodule src files generation
2058 %rule_genmodule_files modname=%(modname) modtype=%(modtype) \
2059 modsuffix=%(modsuffix) targetdir=%(objdir) \
2060 conffile=%(conffile)
2062 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) \
2063 $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
2064 %(objdir)/Makefile.%(modname)%(modtype) \
2065 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
2066 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
2067 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
2068 %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
2069 $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
2071 %(mmake)-clean : FILES := $(BD_TOCLEAN)
2073 @$(ECHO) "Cleaning up for module %(modname)"
2076 endif # $(TARGET) in $(BD_ALLTARGETS)
2078 #------------------------------------------------------------------------------
2081 #------------------------------------------------------------------------------
2083 # - mmake is the mmaketarget
2084 # - libname is the baselibname e.g. lib%(libname).a will be created
2085 # - files are the C source files to include in the lib. The list of files
2086 # has to be given without the .c suffix
2087 # - asmfiles are the asm files to include in the lib. The list of files has to
2088 # be given without the .s suffix
2089 # - objs additional object to link into the linklib. The objects have to be
2090 # given with full absolute path and the .o suffix.
2091 # - cflags are the flags to compile the source (default $(CFLAGS))
2092 # - dflags are the flags use during makedepend (default equal to cflags)
2093 # - aflags are the flags use during assembling (default $(AFLAGS))
2094 # - objdir is where the .o are generated
2095 # - libdir is the directory where the linklib will be placed (default $(LIBDIR))
2096 %define build_linklib mmake=/A libname=/A \
2097 files="$(basename $(call WILDCARD, *.c))" \
2098 cxxfiles="$(basename $(call WILDCARD, *.cpp))" \
2099 asmfiles= objs= compiler=target \
2100 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) objdir=$(OBJDIR) libdir=$(LIBDIR)
2102 # assign and generate the local variables used in this macro
2103 OBJDIR ?= $(GENDIR)/$(CURDIR)
2105 BD_FILES := %(files)
2106 BD_CXXFILES := %(cxxfiles)
2107 BD_ASMFILES := %(asmfiles)
2109 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
2110 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
2111 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
2113 BD_OBJS := $(BD_ARCHOBJS) \
2114 $(addsuffix .o,$(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES) $(BD_CXXFILES) $(BD_ASMFILES)))) \
2116 BD_DEPS := $(patsubst %.o,%.d,$(BD_OBJS))
2118 BD_CFLAGS := %(cflags)
2120 BD_DFLAGS := $(BD_CFLAGS)
2122 BD_DFLAGS := %(dflags)
2124 BD_AFLAGS := %(aflags)
2126 BD_LINKLIB := %(libdir)/lib%(libname).a
2128 .PHONY : %(mmake) %(mmake)-clean
2130 #MM %(mmake) : includes-generate-deps
2131 %(mmake) : $(BD_LINKLIB)
2135 @$(RM) $(BD_OBJS) $(BD_DEPS)
2137 ifeq ($(TARGET),%(mmake))
2138 ifneq ($(dir $(BD_FILES)),./)
2139 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
2140 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir $(BD_FILES)))
2143 %rule_compile basename=% targetdir=%(objdir) \
2144 compiler=%(compiler) cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
2145 %rule_compile_cxx_multi basenames=$(BD_CXXFILES) targetdir=%(objdir) \
2146 compiler=%(compiler) cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
2147 %rule_assemble basename=% targetdir=%(objdir) \
2150 %rule_link_linklib libname=%(libname) objs=$(BD_OBJS) libdir=%(libdir) linker=%(compiler)
2153 %include_deps depstargets=%(mmake) deps=$(BD_DEPS)
2155 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
2156 $(BD_LINKLIB) : | %(libdir)
2157 GLOB_MKDIRS += %(objdir) %(libdir)
2160 #------------------------------------------------------------------------------
2163 #------------------------------------------------------------------------------
2165 # - mmake is the mmaketarget
2166 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
2167 # - description is the catalog description file (.cd), without the .ct suffix (default *.cd)
2168 # - subdir is the destination subdirectory of the catalogs
2169 # - name is the name of the destination catalog, without the .catalog suffix
2170 # - source is the path to the generated source code file
2171 # - dir is the base destination directory (default $(AROS_CATALOGS))
2172 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
2173 # - srcdir is the directory in which the *.cd and *.ct files are searched
2175 %define build_catalogs mmake=/A name=/A subdir=/A \
2176 catalogs= source="../strings.h" description= dir=$(AROS_CATALOGS) \
2177 sourcedescription="$(TOOLDIR)/C_h_aros" srcdir="$(SRCDIR)/$(CURDIR)"
2179 ifeq (%(description),)
2180 BD_DESC := $(basename $(wildcard %(srcdir)/*.cd))
2182 BD_DESC := %(description)
2185 BD_SRC := $(shell echo %(sourcedescription) | sed 's/^\(.\):\//\/\1\//')
2188 BD_LNGS := $(basename $(notdir $(call WILDCARD, %(srcdir)/*.ct)))
2190 BD_LNGS := %(catalogs)
2193 BD_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, $(BD_LNGS)))
2194 BD_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, $(BD_LNGS))) $(dir %(source))
2197 %(mmake) : $(BD_OBJS) %(source)
2199 $(BD_OBJS) : | $(BD_DIRS)
2200 GLOB_MKDIRS += $(BD_DIRS)
2202 %(dir)/%/%(subdir)/%(name).catalog : %(srcdir)/%.ct $(BD_DESC).cd
2203 @$(ECHO) "Creating %(name) catalog for language $*."
2204 @$(FLEXCAT) $(BD_DESC).cd $< CATALOG=%(dir)/$*/%(subdir)/%(name).catalog || [ $$? -lt 10 ]
2207 %(source) : BD_DESC := $(BD_DESC)
2208 %(source) : BD_SRC := $(BD_SRC)
2209 %(source) : $(BD_DESC).cd $(BD_SRC).sd | $(dir %(source))
2210 @$(ECHO) "Creating %(name) catalog source file $@"
2211 @$(FLEXCAT) $(BD_DESC).cd $@=$(BD_SRC).sd
2216 $(RM) $(BD_OBJS) %(source)
2218 .PHONY: %(mmake) %(mmake)-clean
2221 #-----------------------------------------------------------------------------
2224 #-----------------------------------------------------------------------------
2226 # - mmake is the mmaketarget
2227 # - icons is a list of icon base names (ie. without the .info suffix)
2228 # - dir is the destination directory
2229 # - srcdir is where *.png and *.info.src are searched
2230 #-----------------------------------------------------------------------------
2232 %define build_icons mmake=/A icons=/A dir=/A srcdir="$(SRCDIR)/$(CURDIR)" image=
2234 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
2237 %(mmake) : $(BD_OBJS)
2241 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%.png
2242 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2243 @$(ILBMTOICON) $+ $@
2247 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%(image)
2248 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2249 @$(ILBMTOICON) $+ $@
2253 $(BD_OBJS) : | %(dir)
2254 GLOB_MKDIRS += %(dir)
2256 %(mmake)-clean : FILES := $(BD_OBJS)
2261 .PHONY: %(mmake) %(mmake)-clean
2264 #-----------------------------------------------------------------------------
2267 #------------------------------------------------------------------------------
2268 # Compile files for an arch-specific replacement of code for a module
2269 # - files: the basenames of the C files to compile.
2270 # - asmfiles: the basenames of the asm files to assemble.
2271 # - mainmmake: the mmake of the module in the main directory to compile these
2272 # arch specific files for.
2273 # - maindir: the object directory for the main module
2274 # - arch: the arch for which to compile these files. It can have the form
2275 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
2276 # - cflags (default $(CFLAGS)): the C flags to use for compilation
2277 # - dflags: the flags used during creation of dependency file. If not specified
2278 # the same value as cflags will be used
2279 # - aflags: the flags used during assembling
2280 # - compiler: (host, kernel or target) specifies which compiler to use. By default
2281 # the target compiler is used
2282 %define build_archspecific files= asmfiles= mainmmake=/A maindir=/A arch=/A \
2283 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
2285 ifeq (%(files) %(asmfiles),)
2286 $(error no files or asmfiles given)
2289 %buildid targets="%(mainmmake)-%(arch)"
2291 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2292 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2293 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2294 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2295 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2296 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2297 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2298 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2299 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2300 #MM- %(mainmmake)-kobj-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2301 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2302 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2303 #MM- %(mainmmake)-pkg : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2304 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2305 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2306 #MM- %(mainmmake)-pkg-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2307 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2308 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2309 #MM- %(mainmmake)-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2310 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2311 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2313 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
2315 BD_OBJDIR$(BDID) := $(GENDIR)/%(maindir)/arch
2316 BD_COBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
2317 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
2318 BD_OBJS$(BDID) := $(BD_COBJS$(BDID)) $(BD_ASMOBJS$(BDID))
2319 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
2321 ifneq (%(modulename),)
2322 BD_DEFLIBDEFSINC$(BDID) := -include $(GENDIR)/%(maindir)/include/%(modulename)_deflibdefs.h
2325 ifeq ($(TARGET),%(mainmmake)-%(arch)-quick)
2326 BD_TARGET := %(mainmmake)-%(arch)-quick
2328 BD_TARGET := %(mainmmake)-%(arch)
2332 ifeq ($(TARGET),$(BD_TARGET))
2333 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
2334 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(files)))
2335 vpath %.s $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2336 vpath %.S $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2339 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID))
2340 GLOB_MKDIRS += $(BD_OBJDIR$(BDID))
2343 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
2346 %(mainmmake)-%(arch)-quick :: $(BD_OBJS$(BDID))
2348 ifeq ($(findstring %(compiler),host kernel target),)
2349 $(error unknown compiler %(compiler))
2351 ifeq (%(compiler),target)
2352 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
2353 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
2354 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
2356 ifeq (%(compiler),host)
2357 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(HOST_CC)
2358 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
2359 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
2361 ifeq (%(compiler),kernel)
2362 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
2363 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
2364 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
2366 ifneq (%(modulename),)
2367 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) $(BD_DEFLIBDEFSINC$(BDID))
2369 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
2371 ifeq ($(TARGET),$(BD_TARGET))
2372 $(BD_OBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2373 %compile_q opt=$(TMP_CFLAGS) cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2377 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags) $(BD_DEFLIBDEFSINC$(BDID))
2379 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
2381 ifeq ($(TARGET),$(BD_TARGET))
2382 $(BD_OBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2383 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
2386 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
2388 ifeq ($(TARGET),$(BD_TARGET))
2389 $(BD_OBJDIR$(BDID))/%.o : %.s
2390 %assemble_q opt=$(AFLAGS)
2391 $(BD_OBJDIR$(BDID))/%.o : %.S
2392 %assemble_q opt=$(AFLAGS)
2395 %include_deps depstargets=$(BD_TARGET) deps=$(BD_DEPS$(BDID))
2397 #------------------------------------------------------------------------------
2400 #------------------------------------------------------------------------------
2401 # generate asm files from c files (for debugging purposes)
2404 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
2405 @$(TARGET_CC) -S $(CFLAGS) $(TARGET_CFLAGS) $< -c -o $@
2407 #------------------------------------------------------------------------------
2410 #------------------------------------------------------------------------------
2411 # Copy files from one directory to another.
2413 %define copy_files_q mmake=/A files=$(FILES) src=. dst=/A
2415 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
2417 GLOB_MKDIRS += %(dst)
2423 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC))/, $(file)) $(addprefix %(dst)/, $(file))))
2426 #------------------------------------------------------------------------------
2429 #------------------------------------------------------------------------------
2430 # Copy a directory recursively to another place, preserving the original
2431 # hierarchical structure
2433 # src: the source directory whose content will be copied
2434 # dst: the directory where to copy src's content. If not existing, it will be made.
2436 %define copy_dir_recursive mmake=/A src=. dst=/A excludefiles=
2438 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
2439 %(mmake)_FILES := $(shell cd $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC)); find . -path '*/CVS' -prune -o -path '*/.svn' -prune -o -name .cvsignore -prune -o -name mmakefile -prune -o -name mmakefile.src -prune $(%(mmake)_FILTER) -o -type f -print)
2440 %(mmake)_DIRS := $(sort $(dir $(%(mmake)_FILES)))
2442 %(mmake)_EXCLUDEFILES := $(addprefix ./,%(excludefiles))
2443 %(mmake)_FILES := $(filter-out $(%(mmake)_EXCLUDEFILES),$(%(mmake)_FILES))
2445 GLOB_MKDIRS += $(GENDIR)/$(CURDIR)
2450 %(mmake): | $(GENDIR)/$(CURDIR)
2451 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
2452 $(ECHO) "all: $(addprefix \$$(DST)/,$(%(mmake)_FILES))" > $$m
2453 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
2454 for d in $(%(mmake)_DIRS); do \
2455 $(ECHO) "\$$(DST)/$$d: ; $(MKDIR) \$$@" >> $$m; \
2457 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
2458 for f in $(%(mmake)_FILES); do \
2459 $(ECHO) "\$$(DST)/$$f: \$$(SRC)/$$f | \$$(dir \$$(DST)/$$f); $(CP) \$$< \$$@" >> $$m; \
2461 for dst in %(dst); do \
2462 $(MAKE) -f $$m DST=$$dst SRC=$(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC)) all; \
2466 #------------------------------------------------------------------------------
2469 #------------------------------------------------------------------------------
2470 # Copy include files into the includes directories. There are currently
2471 # two include directories. One for building AROS $(AROS_INCLUDES) and one
2472 # for building tools that need to run on the host system $(GENINCDIR). The
2473 # $(GENINCDIR) path must not contain any references to the C runtime
2474 # library header files.
2476 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
2477 dir= compiler=target
2479 ifeq ($(findstring %(compiler),host kernel target),)
2480 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
2484 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),$(dir %(includes)))
2485 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,$(notdir %(includes)))
2486 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
2488 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
2489 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
2492 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
2496 ifeq (%(compiler),target)
2499 BD_INCL_FILES2 := $(subst %(dir),$(AROS_INCLUDES)/%(path),$(dir %(includes)))
2500 BD_INCL_FILES2 := $(addprefix $(AROS_INCLUDES)/%(path)/,$(notdir %(includes)))
2502 BD_INCL_FILES2 := $(addprefix $(AROS_INCLUDES)/%(path)/,%(includes))
2505 BD_INCL_FILES += $(BD_INCL_FILES2)
2507 $(BD_INCL_FILES2) : $(AROS_INCLUDES)/%(path)/% : $(BD_INC_PATH)%
2512 %(mmake) : $(BD_INCL_FILES)
2516 $(BD_INCL_FILES) : | $(dir $(BD_INCL_FILES))
2517 GLOB_MKDIRS += $(dir $(BD_INCL_FILES))
2519 #------------------------------------------------------------------------------
2522 #------------------------------------------------------------------------------
2523 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
2524 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
2525 STUBS_MEM := $(addsuffix .o,$(STUBS))
2526 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
2527 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
2528 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
2530 #MM- linklibs : hidd-%(hidd)-stubs
2531 #MM- %(parenttarget): hidd-%(hidd)-stubs
2532 #MM hidd-%(hidd)-stubs : includes includes-copy
2533 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
2535 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
2538 $(STUBS_OBJ) : $(STUBS_SRC)
2539 %compile_q cmd="$(TARGET_CC) $(TARGET_CFLAGS)" opt=%(cflags) iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
2541 $(STUBS_DEP) : $(STUBS_SRC)
2542 %mkdepend_q flags=%(dflags)
2545 %mkdirs_q $(OBJDIR) $(LIBDIR)
2549 -@$(RM) $(HIDD_LIB) $(OBJDIR)
2551 DEPS := $(DEPS) $(STUBS_DEP)
2554 #------------------------------------------------------------------------------
2557 #------------------------------------------------------------------------------
2558 # Build an imported source tree which uses the configure script from the
2559 # autoconf package. This rule will try to "integrate" the produced files as
2560 # much as possible in the AROS build, for example by putting libraries in the
2561 # standard library directory, includes in the standard include directory, and
2562 # so on. You can however override this behaviour.
2564 # As a special "bonus" for you, the PROGDIR environment variable is defined to
2565 # be %(bindir) (or its deduced value) when running "make install", and
2566 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
2567 # configure script some more parameters whose value depends upon the PROGDIR
2568 # env var, so that the program gets all its stuff installed in the proper place
2569 # when building it, but when running it from inside AROS it can also find that
2570 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
2571 # the configuration parameters set when running ./configure
2573 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
2574 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
2575 # to the name which has to follow it.
2579 # - mmake = the meta make target.
2580 # - package = name of the package to be built.
2581 # - srcdir = the location of the unpacked source code. Defaults
2582 # to $(SRCDIR)/$(CURDIR).
2583 # - prefix = the target directory. Must be an absolute path of the
2584 # host system. Defaults to $(AROS_CONTRIB).
2585 # - aros_prefix = set a path which is valid within the AROS filesystem.
2586 # Defaults to the value of the prefix option.
2587 # - extraoptions = additional options for the configure script.
2588 # - extracflags = additional flags which are used for both C and C++.
2589 # - nix_dir_layout = if yes the binary will be stored in a bin subdirectory.
2590 # Defaults to the value of the nix argument.
2591 # - nix = enable u*nix path handling, i.e. a path like
2592 # /progdir//./file will be translated to
2593 # progdir:file during run-time. Defaults to no.
2594 # - compiler = target, host or kernel. Defaults to target.
2595 # - install_target = the command used for installing. Defaults to install. Leave
2596 # it empty if you want to suppress installing.
2597 # - preconfigure = a metatarget which is executed before configure is called.
2598 # - postconfigure = a metatarget which is executed after configure is called.
2599 # - postinstall = a metatarget which is executed after installing.
2600 # - install_env = set additional options for installing.
2601 # - use_build_env = if yes the configuration environment is used for
2602 # installing, too. Defaults to no.
2604 # The arguments aros_prefix, nix and nix_dir_layout are related. The logic is
2608 # --prefix = $(aros_prefix)
2609 # progdir = $(aros_prefix)/bin
2612 # --prefix = /PROGDIR
2613 # --bindir = /PROGDIR
2614 # --sbindir = /PROGDIR
2616 # --includedir = /INCLUDE
2617 # --oldincludedir = /INCLUDE
2619 # --prefix = $(aros_prefix)
2622 # progdir = $(aros_prefix)
2625 # bindir = $(prefix)
2626 # sbindir = $(prefix)
2627 # libdir = $(AROS_LIB)
2628 # includedir = $(AROS_INCLUDES)
2629 # oldincludedir = $(AROS_INCLUDES)
2633 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) prefix= \
2634 aros_prefix= extraoptions= extracflags= nix_dir_layout= nix=no compiler=target \
2635 install_target=install preconfigure= postconfigure= postinstall= \
2636 install_env= use_build_env=no
2639 %(mmake)-prefix := %(prefix)
2641 %(mmake)-prefix := $(AROS_CONTRIB)
2644 ifneq (%(aros_prefix),)
2645 %(mmake)-aros_prefix := %(aros_prefix)
2647 %(mmake)-aros_prefix := $(%(mmake)-prefix)
2651 %(mmake)-nix := -nix
2652 %(mmake)-volpfx := /
2653 %(mmake)-volsfx := /
2655 ifeq (%(nix_dir_layout),)
2656 %(mmake)-nix_dir_layout := yes
2659 %(mmake)-volsfx := :
2661 ifeq (%(nix_dir_layout),)
2662 %(mmake)-nix_dir_layout := no
2666 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
2668 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
2669 exec_prefix=$(%(mmake)-prefix) %(install_env)
2671 # Check if chosen compiler is valid
2672 ifeq ($(findstring %(compiler),host target kernel),)
2673 $(error unknown compiler %(compiler))
2676 # Set legacy 'host' variable based on chosen compiler
2677 ifeq (%(compiler),host)
2680 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
2682 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
2687 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
2689 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
2693 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
2694 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
2696 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
2697 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
2698 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2701 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
2702 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
2704 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2707 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
2709 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
2710 sbindir=$(%(mmake)-prefix) \
2711 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
2712 oldincludedir=$(AROS_INCLUDES) %(install_env)
2715 ifneq ($(DEBUG),yes)
2716 %(mmake)-s_flag = -s
2719 # Set up build environment, and options for configure script
2720 ifeq (%(compiler),host)
2723 CXXCPP="$(HOST_CPP)" \
2724 CC="$(HOST_CC) $(HOST_CFLAGS) -L$(CROSSTOOLSDIR)/lib -I$(CROSSTOOLSDIR)/include" \
2725 CXX="$(HOST_CXX) $(HOST_CXXFLAGS) -L$(CROSSTOOLSDIR)/lib -I$(CROSSTOOLSDIR)/include" \
2726 TARGET_CC="$(KERNEL_CC) $(KERNEL_CFLAGS) $(%(mmake)-s_flag)" \
2727 TARGET_AS="$(TARGET_AS)" OBJCOPY="$(OBJCOPY)" \
2728 TARGET_RANLIB="$(RANLIB)" TARGET_STRIP="$(STRIP_PLAIN)" \
2729 TARGET_NM="$(NM_PLAIN)"
2731 ifeq (%(compiler),target)
2733 PKG_CONFIG_LIBDIR="$(AROS_DEVELOPMENT)/lib/pkgconfig" \
2734 PKG_CONFIG_SYSROOT_DIR="$(AROSDIR)" \
2735 CPP="$(TARGET_CPP)" \
2736 CXXCPP="$(TARGET_CPP)" \
2737 CC="$(TARGET_CC) $(TARGET_CFLAGS) -L$(AROS_DEVELOPMENT)/lib -I$(AROS_DEVELOPMENT)/include %(extracflags) $(LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)"\
2738 CXX="$(TARGET_CXX) $(TARGET_CFLAGS) -L$(AROS_DEVELOPMENT)/lib -I$(AROS_DEVELOPMENT)/include %(extracflags) $(LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)"\
2739 AS="$(TARGET_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)" AR="$(AR_PLAIN)" STRIP="$(STRIP_PLAIN)"\
2740 TARGET_CC="$(KERNEL_CC) $(KERNEL_CFLAGS) $(%(mmake)-s_flag)"\
2741 TARGET_AS="$(TARGET_AS)" OBJCOPY="$(OBJCOPY)"\
2742 TARGET_RANLIB="$(RANLIB)" TARGET_STRIP="$(STRIP_PLAIN)"\
2743 TARGET_NM="$(NM_PLAIN)" \
2744 CC_FOR_TARGET="$(TARGET_CC) $(TARGET_CFLAGS) -L$(AROS_DEVELOPMENT)/lib -I$(AROS_DEVELOPMENT)/include %(extracflags) $(LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)"\
2745 CXX_FOR_TARGET="$(TARGET_CXX) $(TARGET_CFLAGS) -L$(AROS_DEVELOPMENT)/lib -I$(AROS_DEVELOPMENT)/include %(extracflags) $(LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)"
2746 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)\
2747 --host=$(AROS_TARGET_CPU)-aros\
2748 --target=$(AROS_TARGET_CPU)-aros\
2750 --without-x --without-pic --disable-shared
2752 ifeq (%(compiler),kernel)
2754 CPP="$(KERNEL_CPP)" \
2755 CXXCPP="$(KERNEL_CPP)" \
2756 CC="$(KERNEL_CC) $(KERNEL_CFLAGS) %(extracflags) $(%(mmake)-s_flag)"\
2757 CXX="$(KERNEL_CXX) $(KERNEL_CFLAGS) %(extracflags) $(%(mmake)-s_flag)"\
2758 AS="$(KERNEL_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)"\
2759 TARGET_RANLIB="$(RANLIB)" TARGET_STRIP="$(STRIP_PLAIN)" \
2760 TARGET_NM="$(NM_PLAIN)"
2761 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)\
2762 --host=$(AROS_TARGET_CPU)-aros\
2763 --target=$(AROS_TARGET_CPU)-aros --disable-nls\
2764 --without-x --without-pic --disable-shared
2767 ifeq (%(use_build_env),yes)
2768 BUILD_ENV := $(CONFIG_ENV)
2772 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
2774 # When building for the host, we don't need to build the
2775 # linklibs - this is especially true when building the
2776 # crosstool toolchain on 'foreign' architectures (such as
2777 # building PPC on x86)
2779 #MM- %(mmake)-host : setup includes %(mmake)-quick
2780 #MM- %(mmake)-target : setup includes core-linklibs %(mmake)-quick
2781 #MM- %(mmake): %(mmake)-%(compiler)
2783 # Using -j1 in install_command may result in a warning but finally
2784 # it does its job. make install for gcc does not work reliably for -jN
2786 ifneq (%(install_target),)
2787 %(mmake)-install_command = \
2788 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2789 -C $(%(mmake)-pkgdir) %(install_target) -j1
2791 %(mmake)-uninstall_command = \
2792 $(RM) $(%(mmake)-installflag) && \
2793 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" \
2794 $(%(mmake)-install_opts) -C $(%(mmake)-pkgdir) uninstall
2796 %(mmake)-install_command := true
2797 %(mmake)-uninstall_command := true
2800 #MM- %(mmake)-quick : %(preconfigure) %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
2803 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
2805 $(%(mmake)-installflag) : $(%(mmake)-configflag)
2806 if ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q -C $(%(mmake)-pkgdir); then \
2807 $(RM) $(%(mmake)-installflag) && \
2808 $(BUILD_ENV) $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)"\
2809 -C $(%(mmake)-pkgdir) && \
2810 $(%(mmake)-install_command) && \
2811 $(TOUCH) $@ -r $^; \
2814 $(%(mmake)-pkgdir)/.files-touched:
2815 %mkdirs_q $(%(mmake)-pkgdir)
2816 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/configure '{}' \; && \
2820 %(mmake)-uninstall :
2821 $(%(mmake)-uninstall_command)
2824 %(mmake)-configure : $(%(mmake)-configflag)
2826 $(%(mmake)-configflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
2827 $(%(mmake)-configflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2829 %mkdirs_q $(%(mmake)-pkgdir)
2830 cd $(%(mmake)-pkgdir) && \
2831 find . -name config.cache -exec $(RM) '{}' \; && \
2832 $(CONFIG_ENV) $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) \
2833 %(extraoptions) && \
2837 %(mmake)-clean : %(mmake)-uninstall
2838 @$(RM) $(%(mmake)-pkgdir)
2840 #------------------------------------------------------------------------------
2843 #------------------------------------------------------------------------------
2844 # Given an archive name, patches names and locations where to find them, fetch
2845 # the archive and the patches from any of those locations, unpack the archive
2846 # and then apply the patches.
2848 # Locations currently supported are http and ftp sites, plus local filesystem
2849 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
2850 # the fetch.sh script needs to be modified, since this macro relies on that script.
2854 # - mmake = mmaketarget
2855 # - archive_origins = list of locations where to find the archive. They are tried
2856 # in sequence, until the archive is found and fetching it
2857 # succeeded. If not specified, the current directory is assumed.
2858 # - archive = the archive name. Mandatory.
2859 # - suffixes = a list of suffixes to append to the the package name plus the
2860 # version. Each one of them is tried until a matching archive is
2861 # found. They are appended to patches and these are tried the
2862 # same way as packages are.
2863 # - location = the local directory where to put the fetched archive and patches.
2864 # If not specified, the directory specified by destination is used.
2865 # - destination = the directory to unpack the archive to.
2866 # If not specified, the current directory is assumed.
2867 # - patches_origins = list of locations where to find the patches. They are tried
2868 # in sequence, until a patch is found and fetching it
2869 # succeeded. If not specified, the current directory is assumed.
2870 # - patches_specs = list of "patch specs". A patch spec is of the form
2871 # patch_name[:[patch_subdir][:patch_opt]].
2873 # - patch_name = the name of the patch file
2874 # - patch_subdir = the directory within \destination\ where to
2876 # - patch_opt = any options to pass to the `patch' command
2877 # when applying the patch.
2879 # The patch_subdir and patch_opt fields are optional.
2881 %define fetch mmake=/A archive_origins=. archive=/A suffixes= location= destination=. \
2882 patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
2886 ifneq (%(location),)
2887 %(mmake)-location := %(location)
2889 %(mmake)-location := %(destination)
2894 $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
2895 -d %(destination) -po "%(patches_origins)" -p "%(patches_specs)"
2897 #------------------------------------------------------------------------------
2900 #------------------------------------------------------------------------------
2901 # This macro can aid in patch creation for fetched ports. It temporarily creates another
2902 # unpatched source tree and runs diff against this and a previously fetched and possibly
2903 # patched tree. Depending on what happens after patching during a normal build it might
2904 # give best results if the new patch is created directly after fetch.
2908 # - mmake = mmaketarget
2909 # - archive = archive base name
2910 # - srcdir = the top level directory the package is unpacked to, useful if
2911 # an archive unpacks to a directory other than its name suggests.
2912 # this should not be deeper than a single path element.
2913 # - suffixes = a list of suffixes to append to the the package name plus the
2914 # version. Each one of them is tried until a matching archive is
2916 # - destination = the directory to unpack the archive to.
2917 # - excludes = diff patterns to exclude files or directories from the patch
2919 %define create_patch mmake=/A archive=/A srcdir= suffixes="tar.bz2 tar.gz" destination=/A excludes=
2923 ifneq (%(excludes),)
2924 %(mmake)-exclude := -X ./exclude.patterns
2928 %(mmake)-srcdir := %(srcdir)
2930 %(mmake)-srcdir := %(archive)
2935 @$(FETCH) -a %(archive) -s "%(suffixes)" -l $(PORTSSOURCEDIR) -d %(destination)/tmp ; \
2936 $(MV) %(destination)/$(%(mmake)-srcdir) %(destination)/tmp/$(%(mmake)-srcdir).aros ; \
2937 cd %(destination)/tmp ; \
2938 $(FOR) f in %(excludes) ; do \
2939 $(ECHO) $$f >> ./exclude.patterns ; \
2941 diff -ruN $(%(mmake)-exclude) \
2942 $(%(mmake)-srcdir) \
2943 $(%(mmake)-srcdir).aros \
2944 >$(SRCDIR)/$(CURDIR)/%(archive)-aros-new.diff ; \
2945 $(MV) %(destination)/tmp/$(%(mmake)-srcdir).aros %(destination)/$(%(mmake)-srcdir) ; \
2946 $(RM) %(destination)/tmp
2948 #------------------------------------------------------------------------------
2951 #------------------------------------------------------------------------------
2952 # Joins the features of %fetch and %build_with_configure.
2954 # If a patch is provided, it *must* be named the following way:
2956 # <package name>-<version number>-aros.diff
2958 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
2959 # CD'ing into the archive's extracted directory.
2961 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
2962 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
2963 # to make that patch fully comprehensive.
2967 # - mmake = the meta make target.
2968 # - package = the GNU package name, sans version and archive format suffixes.
2969 # - subpackage = ???
2970 # - compiler = same meaning as the one for the %build_with_configure macro.
2971 # - install_target = same meaning as the one for the %build_with_configure macro.
2972 # - version = the package's version number, or otherwise any other version string.
2973 # It gets appended to the package name to form the basename of the archive.
2974 # - suffixes = a list of suffixes to apped to the the package name plus the
2975 # version. Each one of them is tried until a matching archive is found.
2976 # Defaults to "tar.bz2 tar.gz".
2977 # - srcdir = the top level directory the package is unpacked to (see create_patch).
2978 # - builddir = override the location we expect to run configure/make in.
2979 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
2980 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
2981 # fetched or not. Default to no.
2982 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
2983 # - prefix = same meaning as the one for the %build_with_configure macro.
2984 # - aros_prefix = same meaning as the one for the %build_with_configure macro.
2985 # - extraoptions = same meaning as the one for the %build_with_configure macro.
2986 # - extracflags = same meaning as the one for the %build_with_configure macro.
2987 # - preconfigure = same meaning as the one for the %build_with_configure macro.
2988 # - postconfigure = same meaning as the one for the %build_with_configure macro.
2989 # - postinstall = same meaning as the one for the %build_with_configure macro.
2990 # - install_env = same meaning as the one for the %build_with_configure macro.
2991 # - use_build_env = same meaning as the one for the %build_with_configure macro.
2992 # - nix = same meaning as the one for the %build_with_configure macro.
2993 # - nix_dir_layout = same meaning as the one for the %build_with_configure macro.
2994 # - create_pkg = create a distributable package of the compiled sources, defaults to no
2996 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target install_target=install \
2997 version=/A suffixes="tar.bz2 tar.gz" srcdir= builddir= package_repo= patch=no patch_repo= \
2998 prefix= aros_prefix= extraoptions= extracflags= preconfigure= postconfigure= postinstall= \
2999 install_env= use_build_env=no nix=no nix_dir_layout= create_pkg=no
3001 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
3002 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
3003 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
3004 #MM- %(mmake)-create-patch : %(mmake)-%(subpackage)-create-patch
3006 %(mmake)-archbase := %(package)-%(version)
3008 ifeq (%(compiler),host)
3009 %(mmake)-portdir := $(HOSTDIR)/Ports/%(package)
3011 %(mmake)-portdir := $(PORTSDIR)/%(package)
3015 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
3017 %(mmake)-prefix := %(prefix)
3020 ifneq (%(subpackage),)
3021 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
3023 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
3027 %(mmake)-%(subpackage)-srcdir := %(srcdir)
3029 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
3032 ifneq (%(builddir),)
3033 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)/%(builddir)
3035 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)
3039 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-f,-p1
3041 %(mmake)-%(subpackage)-patches_specs := ::
3044 %fetch mmake=%(mmake)-%(subpackage)-fetch archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
3045 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
3046 archive_origins=". %(package_repo)" \
3047 patches_specs="$(%(mmake)-%(subpackage)-patches_specs)" patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
3049 %create_patch mmake=%(mmake)-%(subpackage)-create-patch \
3050 archive=$(%(mmake)-%(subpackage)-archbase) \
3051 srcdir=$(%(mmake)-%(subpackage)-srcdir) \
3052 suffixes="%(suffixes)" \
3053 destination=$(%(mmake)-portdir)
3055 #MM- %(mmake) : %(mmake)-%(subpackage)
3057 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
3059 %(mmake)-%(subpackage)-package-basename := \
3060 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
3062 ifneq (%(create_pkg),no)
3063 %(mmake)-%(subpackage)-package := $(%(mmake)-%(subpackage)-package-basename).tar.bz2
3066 %build_with_configure mmake=%(mmake)-%(subpackage) package=%(package) compiler=%(compiler) install_target=%(install_target) \
3067 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-builddir) install_env=%(install_env) use_build_env=%(use_build_env) \
3068 nix=%(nix) nix_dir_layout=%(nix_dir_layout) prefix="$(%(mmake)-prefix)" \
3069 aros_prefix="%(aros_prefix)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
3070 %(mmake)-%(subpackage)-make-package" extraoptions="%(extraoptions)" extracflags="%(extracflags)"
3072 .PHONY : %(mmake)-%(subpackage)-make-package %(mmake)-%(subpackage)-create-patch
3073 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
3076 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package)
3078 #There seems to be a bug, either with my clock or with make, 'cause it may happen
3079 #that $^ and $@ have exactly the same mtime, and in that case make tries
3080 #to rebuild $@ again, which would fail because the directory where
3081 #the package got installed would not exist anymore.
3082 #We work this around by using an if statement to manually check the mtimes.
3083 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
3084 @$(IF) test $(%(mmake)-installflag) -nt $@ || ! test -f $@; then \
3086 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
3087 mkdir -p "$(DISTDIR)/Packages" ; \
3088 mkdir -p "$(%(mmake)-prefix)" ; \
3089 cd $(%(mmake)-%(subpackage)-package-dir) ; \
3090 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
3091 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
3094 #------------------------------------------------------------------------------
3097 #------------------------------------------------------------------------------
3098 # Joins the features of %fetch and %build_with_configure, taking advantage of
3099 # the naming scheme of GNU packages. GNU packages names are in the form
3101 # <package name>-<version number>.<archive format suffix>
3103 # If a patch is provided, it *must* be named the following way:
3105 # <package name>-<version number>-aros.diff
3107 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3108 # CD'ing into the archive's extracted directory.
3110 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3111 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3112 # to make that patch fully comprehensive.
3114 # NOTE: GNU packages are always compiled with *nix semantics turned on.
3118 # Arguments have the same meaning as the one for the %fetch_and_build macro, except:
3120 # - prefix = defaults to $(GNUDIR).
3121 # - aros_prefix = defaults to /GNU.
3123 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
3124 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
3125 aros_prefix=/GNU extraoptions= extracflags= preconfigure= postconfigure= postinstall=
3127 GNU_REPOSITORY := gnu://
3129 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
3130 suffixes="%(suffixes)" srcdir="%(srcdir)" \
3131 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
3132 patch="%(patch)" patch_repo="%(patch_repo)" \
3133 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" extracflags="%(extracflags)" \
3134 preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=yes
3137 #------------------------------------------------------------------------------
3140 #------------------------------------------------------------------------------
3141 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
3142 # that the package is a "Development" package, and as such it needs to be placed
3143 # under the $(AROS_DEVELOPMENT) directory, as a default.
3145 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
3146 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
3147 # "mmake" argument, because the metatarget is implicitely defined as
3149 # #MM- development-%(package)
3151 %define fetch_and_build_gnu_development package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
3152 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPMENT) \
3153 aros_prefix=/Development preconfigure= postconfigure= postinstall= extraoptions= extracflags=
3155 #MM- development : development-%(package)
3158 %fetch_and_build_gnu mmake=development-%(package) package=%(package) subpackage="%(subpackage)" \
3159 version=%(version) suffixes="%(suffixes)" srcdir="%(srcdir)" \
3160 package_repo="%(package_repo)" patch="%(patch)" patch_repo="%(patch_repo)" prefix=%(prefix) \
3161 aros_prefix="%(aros_prefix)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="postinstall-%(package)-delete-la-files %(postinstall)" \
3162 extraoptions="%(extraoptions)" extracflags="%(extracflags)"
3165 postinstall-%(package)-delete-la-files:
3166 $(RM) $(AROS_DEVELOPMENT)/lib/*.la
3169 #------------------------------------------------------------------------------
3171 # Builds a kickstart package in PKG format
3175 # - mmake = target name
3176 # - file = destination file name with path
3177 # - startup = the file which will be put first
3179 # Other arguments are self-explanatory
3181 %define make_package mmake=/A file=/A classes= devs= handlers= hidds= libs= res= startup=
3183 PKG_CLASSES := $(addsuffix .class, %(classes))
3184 PKG_DEVICES := $(addsuffix .device, %(devs))
3185 PKG_HANDLERS := $(addsuffix -handler, %(handlers))
3186 PKG_HIDD := $(addsuffix .hidd, %(hidds))
3187 PKG_LIBS := $(addsuffix .library, %(libs))
3188 PKG_RESOURCES := $(addsuffix .resource, %(res))
3190 PKG_FILES := %(startup) $(PKG_CLASSES) $(PKG_DEVICES) $(PKG_HANDLERS) $(PKG_HIDD) $(PKG_LIBS) $(PKG_RESOURCES)
3191 PKG_DIR := $(dir %(file))
3192 PKG_DEPS := $(addprefix $(PKGDIR)/, $(PKG_FILES))
3198 %(mmake)-quick : %(file)
3200 %(file): PKG_FILES := $(PKG_FILES)
3201 %(file): $(PKG_DEPS) | $(PKG_DIR)
3202 @$(ECHO) Packaging $@...
3203 @$(SRCDIR)/tools/package/pkg c $@ $(PKGDIR) $(PKG_FILES)
3205 %compress_file mmake=%(mmake) file=%(file)
3207 GLOB_MKDIRS += $(PKG_DIR)
3211 #------------------------------------------------------------------------------
3212 # Compresses %(file) with a gzip.
3213 # Good in conjunction with for example %build_prog
3215 %define compress_file mmake=/A file=/A
3217 #MM- %(mmake)-gz : %(mmake) %(mmake)-gz-quick
3220 %(mmake)-gz-quick : %(file).gz
3223 @$(ECHO) Compressing $(subst $(TARGETDIR)/,,$^)...
3228 #------------------------------------------------------------------------------
3229 # Links a kickstart module in ELF format
3230 # Arguments are similar to make_package
3232 %define link_kickstart mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
3233 startup= uselibs= ldflags=$(LDFLAGS) map= deps=
3235 KOBJ_CLASSES := $(addprefix $(KOBJSDIR)/, $(addsuffix _class.o, %(classes)))
3236 KOBJ_DEVICES := $(addprefix $(KOBJSDIR)/, $(addsuffix _device.o, %(devs)))
3237 KOBJ_HANDLERS := $(addprefix $(KOBJSDIR)/, $(addsuffix _handler.o, %(handlers)))
3238 KOBJ_HIDD := $(addprefix $(KOBJSDIR)/, $(addsuffix _hidd.o, %(hidds)))
3239 KOBJ_LIBS := $(addprefix $(KOBJSDIR)/, $(addsuffix _library.o, %(libs)))
3240 KOBJ_RES := $(addprefix $(KOBJSDIR)/, $(addsuffix _resource.o, %(res)))
3243 KOBJ_STARTUP := $(GENDIR)/$(RESIDENT_BEGIN).o
3245 KOBJ_STARTUP := %(startup)
3248 KOBJS := $(KOBJ_STARTUP) $(KOBJ_CLASSES) $(KOBJ_HANDLERS) $(KOBJ_LIBS) $(KOBJ_DEVICES) $(KOBJ_HIDD) $(KOBJ_RES)
3250 TMP_LDFLAGS := %(ldflags)
3252 # Make a list of the lib files this program depends on.
3253 # In LDFLAGS remove white space between -L and directory
3254 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
3255 # Filter out only the libdirs and remove -L
3256 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
3258 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
3259 # Add normal linklib path
3260 TMP_DIRS += $(LIBDIR)/
3261 # add lib and .a to static linklib names
3262 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) libinit autoinit))
3263 # search for the linklibs in the given path, ignore ones not found
3264 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
3265 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
3268 TMP_DIRS += $(dir %(file))
3270 TMP_LDFLAGS += $(GENMAP) %(map)
3271 TMP_DIRS += $(dir %(map))
3274 #MM %(mmake) : %(deps)
3280 %(mmake)-quick : %(file)
3282 %(file): KOBJS := $(KOBJS)
3283 %(file): LDFLAGS := $(TMP_LDFLAGS) $(NOSTARTUP_LDFLAGS) \
3284 -noarosc -nosysbase -Wl,-Ur
3285 %(file): LDLIBS := $(addprefix -l, %(uselibs))
3286 %(file): $(KOBJS) $(DEPLIBS) | $(TMP_DIRS)
3287 @$(ECHO) "Kickstart $(subst $(TARGETDIR)/,,$@)..."
3288 @$(TARGET_CC) -o $@ $(KOBJS) $(LDFLAGS) $(LDLIBS)
3291 %compress_file mmake=%(mmake) file=%(file)
3293 GLOB_MKDIRS += $(TMP_DIRS)