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 # Compile the file %(from) to %(to) with %(cmd). Write any errors to %(err)
14 # and use the options in %(opt). Use %(iquote) and %(iquote_end) for supplying -iquote or -I- flags
15 %define compile_q cmd="$(TARGET_CC) $(TARGET_CFLAGS)" opt=$(CFLAGS) from=$< to=$@ iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
16 @$(ECHO) "Compiling %(from)"
17 @$(IF) %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -c %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
18 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
19 $(ECHO) "%(from): %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -c %(from) -o %(to)" >> $(GENDIR)/errors ; \
20 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors ; \
25 $(ECHO) "Compile failed: %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -c %(from) -o %(to)" 1>&2 ; \
26 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
30 #------------------------------------------------------------------------------
33 #------------------------------------------------------------------------------
34 # Assemble the file %(from) to %(to) with %(cmd) with the options in %(opt).
35 %define assemble_q cmd=$(CC) opt=$(AFLAGS) from=$< to=$@
36 @$(ECHO) "Assembling $(notdir %(from))..."
37 @$(IF) %(cmd) %(opt) %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
38 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
39 $(ECHO) "$(notdir %(from)): %(cmd) %(opt) %(from) -o %(to)" >> $(GENDIR)/errors ; \
40 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
45 $(ECHO) "Assemble failed: %(cmd) %(opt) %(from) -o %(to)" 1>&2 ; \
46 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
50 #-------------------------------------------------------------------------
53 #------------------------------------------------------------------------------
54 # Link a specified number of objects to an executable
55 %define link_q cmd=$(AROS_CC) opt=$(LDFLAGS) from=$< to=$@ libs=$(LIBS) strip=$(STRIP)
56 @$(ECHO) "Linking %(to)..."
57 @$(IF) %(cmd) %(opt) %(from) -o %(to) %(libs) 2>&1 > $(GENDIR)/cerrors 2>&1 ; then \
58 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
59 $(ECHO) "%(to): %(cmd) %(opt) %(from) -o %(to) %(libs)" >> $(GENDIR)/errors ; \
60 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
65 $(ECHO) "Link failed: %(cmd) %(opt) %(from) -o %(to) %(libs)" 1>&2 ; \
66 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
71 #------------------------------------------------------------------------------
74 #-------------------------------------------------------------------------
75 # Link a module based upon a number of arguments and the standard $(LIBS)
76 # and $(DEPLIBS) make variables.
78 %define link_module_q err="$(notdir $@).err" objs=/A endtag= module=$(MODULE) ldflags=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
79 @$(ECHO) "Building $(notdir $@) ..."
80 @if $(AROS_CC) $(NOSTARTUP_LDFLAGS) %(ldflags) \
81 $(GENMAP) %(objdir)/%(module).map \
82 %(objs) %(libs) %(endtag) \
83 -o $@ 2>&1 > %(objdir)/%(err); \
85 cat %(objdir)/%(err); \
87 cat %(objdir)/%(err); \
91 @if $(TEST) ! -s %(objdir)/%(err) ; then $(RM) %(objdir)/%(err) ; fi
94 #------------------------------------------------------------------------------
97 #------------------------------------------------------------------------------
99 %define mklib_q ar=$(AR) ranlib=$(RANLIB) to=$@ from=$(OBJS)
100 @$(ECHO) "Creating library %(to)..."
104 #------------------------------------------------------------------------------
107 #------------------------------------------------------------------------------
108 # Create the dependency file %(to) for %(from)
109 %define mkdepend_q flags=$(CFLAGS) from=$< to=$@ cc=$(AROS_CC)
110 %mkdir_q dir="$(dir %(to))"
111 @$(ECHO) "Makedepend $(CURDIR)/$(notdir %(from))..."
112 @AROS_CC="%(cc)" $(MKDEPEND) %(flags) -I$(SRCDIR)/$(CURDIR) %(from) -o %(to)
114 #------------------------------------------------------------------------------
117 #------------------------------------------------------------------------------
118 # Create one directory without any output
119 %define mkdir_q dir=.
120 @$(IF) $(TEST) ! -d %(dir) ; then $(MKDIR) %(dir) ; else $(NOP) ; fi
122 #------------------------------------------------------------------------------
125 #------------------------------------------------------------------------------
126 # Create several directories without any output
127 %define mkdirs_q dirs=/M
128 @$(FOR) dir in %(dirs) ; do \
129 $(IF) $(TEST) ! -d $$dir ; then $(MKDIR) $$dir ; else $(NOP) ; fi ; \
132 #------------------------------------------------------------------------------
135 #############################################################################
136 #############################################################################
138 ## Here are the mmakefile macros that are used to do certain tasks in a ##
139 ## mmakefile. They consist of one or more full makefile rules. ##
140 ## In general the files generated in these macros are also defined as ##
141 ## make targets so that they can be used as a dependency in other rules ##
143 #############################################################################
144 #############################################################################
146 #------------------------------------------------------------------------------
147 # Generate a unique id for each of the %build... rules
148 %define buildid targets=/A
150 ifneq ($(filter $(TARGET),%(targets)),)
151 BDTARGETID := $(BDID)
154 #------------------------------------------------------------------------------
157 #------------------------------------------------------------------------------
158 # Copy file %(from) to %(to) in a makefile rule
159 %define rule_copy from=/A to=/A
163 #------------------------------------------------------------------------------
166 #------------------------------------------------------------------------------
167 # Copy the files %(files) to %(targetdir). For each file in %(files),
168 # %(srcdir)/file is copied to %(targetdir)/file. The targetdir and the
169 # appropriate subdirs are not generated by this rule so they have to be
171 %define rule_copy_multi files=/A targetdir=/A srcdir=.
173 $(addprefix %(targetdir)/,%(files)) : %(targetdir)/% : %(srcdir)/%
176 #------------------------------------------------------------------------------
179 #------------------------------------------------------------------------------
180 # Copy the files %(files) to %(targetdir). For each file in %(files),
181 # %(srcdir)/file is copied to %(targetdir)/file if these files are different.
182 # %(stampfile) is used to keep track of when the last time the comparison has
183 # been done. The targetdir and the appropriate subdirs are not generated by
184 # this rule so they have to be present.
185 %define rule_copy_diff_multi files=/A targetdir=/A srcdir=. \
186 stampfile=$(TMP_SRCDIR)/.copy_stamp
188 TMP_SRCDIR := %(srcdir)
190 $(addprefix %(targetdir)/,%(files)) : | %(stampfile)
192 %(stampfile) : COPYSRCDIR := %(srcdir)
193 %(stampfile) : TGTDIR := %(targetdir)
194 %(stampfile) : FILES := %(files)
195 %(stampfile) : $(addprefix %(srcdir)/,%(files))
196 @for f in $(FILES); do \
197 $(IF) ! $(CMP) -s $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; then \
198 $(CP) $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; \
203 #------------------------------------------------------------------------------
206 #------------------------------------------------------------------------------
207 # Will join all the files in %(from) to %(to). When text is specified it will
209 # Restriction: at the moment when using a non-empty target dir %(from) may
211 %define rule_join to=/A from=/A text=
219 #------------------------------------------------------------------------------
222 #------------------------------------------------------------------------------
223 # Include the dependency files and add some internal rules
224 # When depstargets is provided the depencies will only be included when one of
225 # these targets is the $(TARGET). Otherwise the dependencies will only be
226 # included when the $(TARGET) is not for setup or clean
227 %define include_deps deps=$(DEPS)/M depstargets=
229 ifneq (%(depstargets),)
230 ifneq ($(findstring $(TARGET),%(depstargets)),)
234 ifeq (,$(filter clean% %clean %clean% setup% includes% %setup,$(TARGET)))
240 #------------------------------------------------------------------------------
243 #------------------------------------------------------------------------------
244 # Create the directories %(dirs). The creation will be done by adding rules to
245 # the %(setuptarget) make target with setup as the default.
246 %define rule_makedirs dirs=/A setuptarget=setup
248 %(setuptarget) :: %(dirs)
250 GLOB_MKDIRS += %(dirs)
253 #------------------------------------------------------------------------------
256 #------------------------------------------------------------------------------
257 # Generate a rule to compile a C source file to an object file and generate
258 # the dependency file. Basename may contain a directory part, then the source
259 # file has to be in that directory. The generated file will be put in the
260 # object directory without the directory.
262 # - basename: the basename of the file to compile. Use % for a wildcard rule
263 # - cflags (default $(CFLAGS)): the C flags to use for compilation
264 # - dflags: the flags used during creation of dependency file. If not specified
265 # the same value as cflags will be used
266 # - targetdir: the directory to put the .o file and the .d file. By default
267 # it is put in the same directory as the .c file
268 %define rule_compile basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target nix=no
271 TMP_TARGETBASE := %(basename)
273 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
276 ifeq ($(findstring %(compiler),host kernel target),)
277 $(error unknown compiler %(compiler))
279 ifeq (%(compiler),target)
280 $(TMP_TARGETBASE).o : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
281 $(TMP_TARGETBASE).d : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
282 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
283 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
284 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
285 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
287 ifeq (%(compiler),host)
288 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
289 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
290 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
291 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
292 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
293 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
295 ifeq (%(compiler),kernel)
296 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
297 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
298 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
299 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
300 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
301 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
305 $(TMP_TARGETBASE).o : CFLAGS := -nix %(cflags)
307 $(TMP_TARGETBASE).o : CFLAGS := %(cflags)
309 $(TMP_TARGETBASE).o : %(basename).c
310 %compile_q cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
314 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(cflags)
316 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(cflags)
320 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(dflags)
322 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(dflags)
325 $(TMP_TARGETBASE).d : %(basename).c
326 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
328 #------------------------------------------------------------------------------
331 #------------------------------------------------------------------------------
332 # Generate a rule to compile multiple C source files to an object file and
333 # generate the corresponding dependency files. The generated file will be put
334 # in the object directory without the directory part of the source file.
336 # - basenames: the basenames of the files to compile. The names may include
337 # relative or absolute path names. No wildcard is allowed
338 # - cflags (default $(CFLAGS)): the C flags to use for compilation
339 # - dflags: the flags used during creation of dependency file. If not specified
340 # the same value as cflags will be used
341 # - targetdir: the directory to put the .o file and the .d file. By default
342 # it is put in the same directory as the .c file. When targetdir is not
343 # empty, path names will be stripped from the file names so that all files
344 # are in that dir and not in subdirectories.
345 # - compiler (default target): compiler to use, target, kernel or host
346 %define rule_compile_multi basenames=/A cflags=$(CFLAGS) dflags= targetdir= \
350 TMP_TARGETS := $(addsuffix .o,%(basenames))
351 TMP_DTARGETS := $(addsuffix .d,%(basenames))
354 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
355 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
356 TMP_WILDCARD := %(targetdir)/%
358 # Be sure that all .c files are generated
359 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .c,%(basenames))
361 # Be sure that all .c files are found
362 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
363 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
364 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
366 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
367 vpath %.c $(TMP_DIRS)
372 ifeq ($(findstring %(compiler),host kernel target),)
373 $(error unknown compiler %(compiler))
375 ifeq (%(compiler),target)
376 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
377 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
378 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
380 ifeq (%(compiler),host)
381 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_CC)
382 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
383 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
385 ifeq (%(compiler),kernel)
386 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
387 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
388 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
391 $(TMP_TARGETS) : CFLAGS := %(cflags)
392 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.c
393 %compile_q cmd=$(CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
396 $(TMP_DTARGETS) : DFLAGS:=%(cflags)
398 $(TMP_DTARGETS) : DFLAGS:=%(dflags)
400 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.c
401 %mkdepend_q cc=$(CMD) flags=$(DFLAGS)
403 #------------------------------------------------------------------------------
406 #------------------------------------------------------------------------------
407 # Make an alias from one arch specific build to another arch.
409 # - mainmmake: the mmake of the module in the main tree
410 # - arch: the current arch
411 # - alias: the alias to which this should point
412 %define rule_archalias mainmmake=\A arch=\A alias=\A
414 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
416 #------------------------------------------------------------------------------
419 #------------------------------------------------------------------------------
420 # Generate a rule to compile a C source file to a shared object file with a
421 # .so suffix. Basename may contain a directory part, then the source
422 # file has to be in that directory. The generated file will be put in the
423 # object directory without the directory.
425 # - basename: the basename of the file to compile. Use % for a wildcard rule
426 # - cflags (default $(CFLAGS)): the C flags to use for compilation
427 # - targetdir: the directory to put the .o file and the .d file. By default
428 # it is put in the same directory as the .c file
429 %define rule_compile_shared basename=/A cflags=$(CFLAGS) targetdir= compiler=target
432 TMP_TARGETBASE := %(basename)
434 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
437 ifeq ($(findstring %(compiler),host kernel target),)
438 $(error unknown compiler %(compiler))
440 ifeq (%(compiler),target)
441 $(TMP_TARGETBASE).so : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
442 $(TMP_TARGETBASE).so : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
443 $(TMP_TARGETBASE).so : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
445 ifeq (%(compiler),host)
446 $(TMP_TARGETBASE).so : TMP_CMD:=$(HOST_CC)
447 $(TMP_TARGETBASE).so : TMP_IQUOTE:=$(HOST_IQUOTE)
448 $(TMP_TARGETBASE).so : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
450 ifeq (%(compiler),kernel)
451 $(TMP_TARGETBASE).so : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
452 $(TMP_TARGETBASE).so : TMP_IQUOTE:=$(KERNEL_IQUOTE)
453 $(TMP_TARGETBASE).so : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
456 $(TMP_TARGETBASE).so : %(basename).c
457 %compile_q opt="$(SHARED_CFLAGS) %(cflags)" cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
459 #------------------------------------------------------------------------------
462 #------------------------------------------------------------------------------
463 # Generate a rule to assemble a source file to an object file. Basename may
464 # contain a directory part, then the source file has to be in that directory.
465 # The generated file will be put in the object directory without the directory.
467 # - basename: the basename of the file to compile. Use % for a wildcard rule
468 # - flags (default $(AFLAGS)): the asm flags to use for assembling
469 # - targetdir: the directory to put the .o file in. By default it is put in the
470 # same directory as the .s file
471 %define rule_assemble basename=/A aflags=$(AFLAGS) targetdir=
474 %(basename).o : AFLAGS := %(aflags)
475 %(basename).o : %(basename).s
477 %(basename).o : %(basename).S
481 %(targetdir)/$(notdir %(basename)).o : AFLAGS := %(aflags)
482 %(targetdir)/$(notdir %(basename)).o : %(basename).s
484 %(targetdir)/$(notdir %(basename)).o : %(basename).S
489 #------------------------------------------------------------------------------
492 #------------------------------------------------------------------------------
493 # Generate a rule to assemble multiple source files to an object file. The
494 # generated file will be put in the object directory with the directory part
495 # of the source file stripped off.
497 # - basenames: the basenames of the files to compile. The names may include
498 # relative or absolute path names. No wildcard is allowed
499 # - aflags (default $(AFLAGS)): the flags to use for assembly
500 # - targetdir: the directory to put the .o file and the .d file. By default
501 # it is put in the same directory as the .c file. When targetdir is not
502 # empty, path names will be stripped from the file names so that all files
503 # are in that dir and not in subdirectories.
504 %define rule_assemble_multi basenames=/A aflags=$(AFLAGS) targetdir= suffix=.s compiler=target
507 TMP_TARGETS := $(addsuffix .o,%(basenames))
510 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
511 TMP_WILDCARD := %(targetdir)/%
513 # Be sure that all .s files are generated
514 $(TMP_TARGETS) : | $(addsuffix %(suffix),%(basenames))
516 # Be sure that all .c files are found
517 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
518 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
519 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
521 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
522 vpath %%(suffix) $(TMP_DIRS)
527 ifeq ($(findstring %(compiler),host kernel target),)
528 $(error unknown compiler %(compiler))
530 ifeq (%(compiler),target)
531 $(TMP_TARGETS) : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
533 ifeq (%(compiler),host)
534 $(TMP_TARGETS) : TMP_CMD:=$(HOST_CC)
536 ifeq (%(compiler),kernel)
537 $(TMP_TARGETS) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
540 $(TMP_TARGETS) : AFLAGS := %(aflags)
541 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %%(suffix)
542 %assemble_q cmd=$(TMP_CMD) opt=$(AFLAGS)
544 #------------------------------------------------------------------------------
547 #------------------------------------------------------------------------------
548 # Link %(objs) to %(prog) using the libraries in %(uselibs)
549 %define rule_link_prog prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
550 usehostlibs= usestartup=yes detach=no nix=no linker=target
554 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
556 ifeq (%(usestartup),no)
557 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
560 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
563 # Make a list of the lib files this program depends on.
565 # In LDFLAGS remove white space between -L and directory
566 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
567 # Filter out only the libdirs and remove -L
568 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
570 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
571 # Add normal linklib path
572 TMP_DIRS += $(LIBDIR)/
573 # add lib and .a to static linklib names
574 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) libinit autoinit))
575 # search for the linklibs in the given path, ignore ones not found
576 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
577 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
583 ifeq (%(linker),target)
584 %(prog) : CMD:=$(TARGET_CC)
585 %(prog) : STRIPCMD:=$(TARGET_STRIP)
587 ifeq (%(linker),host)
588 %(prog) : CMD:=$(HOST_CC)
589 %(prog) : STRIPCMD:=$(HOST_STRIP)
591 ifeq (%(linker),kernel)
592 %(prog) : CMD:=$(KERNEL_CC) $(KERNEL_LDFLAGS)
593 %(prog) : STRIPCMD:=$(ECHO) >/dev/null
596 %(prog) : OBJS := %(objs)
597 %(prog) : LDFLAGS := %(ldflags) $(TMP_EXTRA_LDFLAGS)
598 %(prog) : LIBS := $(addprefix -l,%(uselibs)) $(addprefix -l,%(usehostlibs))
599 %(prog) : %(objs) $(TMP_DEPLIBS)
600 %link_q from=$(OBJS) opt=$(LDFLAGS) libs=$(LIBS) cmd=$(CMD) strip=$(STRIPCMD)
602 #------------------------------------------------------------------------------
605 #------------------------------------------------------------------------------
606 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
607 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
608 %define rule_link_progs progs=/A targetdir=$(AROSDIR)/$(CURDIR) nix=%(nix) \
609 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
610 usestartup=yes detach=no
614 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
616 ifeq (%(usestartup),no)
617 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
620 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
623 # Make a list of the lib files the programs depend on.
625 # In LDFLAGS remove white space between -L and directory
626 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
627 # Filter out only the libdirs and remove -L
628 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
630 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
631 # Add normal linklib path
632 TMP_DIRS += $(LIBDIR)/lib/
633 # add lib and .a to static linklib names
634 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) libinit autoinit))
635 # search for the linklibs in the given path, ignore ones not found
636 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
637 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
643 $(addprefix %(targetdir)/,%(progs)) : LDFLAGS:= %(ldflags) $(TMP_EXTRA_LDFLAGS)
644 $(addprefix %(targetdir)/,%(progs)) : LIBS:= $(addprefix -l,%(uselibs)) $(addprefix -l,%(usehostlibs))
645 $(addprefix %(targetdir)/,%(progs)) : %(targetdir)/% : %(objdir)/%.o $(TMP_DEPLIBS)
646 %link_q from=$< opt=$(LDFLAGS) libs=$(LIBS)
648 #------------------------------------------------------------------------------
651 #------------------------------------------------------------------------------
652 # Link the %(objs) to the library %(libdir)/lib%(libname).a
653 %define rule_link_linklib libname=/A objs=/A libdir=$(LIBDIR)
655 %(libdir)/lib%(libname).a : %(objs)
658 #------------------------------------------------------------------------------
661 #------------------------------------------------------------------------------
662 # Link the %(objs) to the library %(libdir)/lib%(libname).so
663 %define rule_link_shlib libname=/A objs=/A libdir=$(LIBDIR)
665 %(libdir)/lib%(libname).so : %(objs)
666 @$(SHARED_LD) $(SHARED_LDFLAGS) -o $@ $^
668 #------------------------------------------------------------------------------
671 #------------------------------------------------------------------------------
672 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
673 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
674 # The -noarosc flag is added so that modules are not linked with arosc.library
675 # (see /config/specs.in file)
676 %define rule_linkmodule module=/A objs=/A endobj=/A err=/A objdir=$(OBJDIR) \
677 uselibs= usehostlibs=
679 %(module) : OBJS := %(objs)
680 %(module) : ENDTAG := %(endobj)
681 %(module) : ERR := %(err)
682 %(module) : OBJDIR := %(objdir)
683 %(module) : LIBS := $(addprefix -l,%(uselibs)) -lautoinit -llibinit -L/usr/lib $(addprefix -l,%(usehostlibs))
684 %(module) : %(objs) %(endobj) $(addprefix $(LIBDIR)/lib,$(addsuffix .a,%(uselibs) libinit autoinit))
685 %link_module_q err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS) objdir=$(OBJDIR) ldflags="$(LDFLAGS) -noarosc"
688 #------------------------------------------------------------------------------
691 #------------------------------------------------------------------------------
692 # Generate the libdefs.h include file for a module.
693 %define rule_genmodule_genlibdefs modname=/A modtype=/A modsuffix= conffile= targetdir=
695 TMP_TARGET := %(modname)_libdefs.h
696 TMP_DEPS := $(GENMODULE)
699 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
700 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
702 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
703 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
705 ifneq (%(modsuffix),)
706 TMP_OPTS += -s %(modsuffix)
708 ifneq (%(targetdir),)
709 TMP_OPTS += -d %(targetdir)
710 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
713 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
714 $(TMP_TARGET) : MODNAME := %(modname)
715 $(TMP_TARGET) : MODTYPE := %(modtype)
716 $(TMP_TARGET) : $(TMP_DEPS)
717 @$(ECHO) "Generating $(notdir $@)"
718 @$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
720 #------------------------------------------------------------------------------
723 #------------------------------------------------------------------------------
724 # Generate a Makefile.%(modname) with the genmodule program and include this
725 # generated file in this Makefile
726 %define rule_genmodule_makefile modname=/A modtype=/A modsuffix= conffile= \
729 TMP_TARGET := Makefile.%(modname)
730 TMP_DEPS := $(GENMODULE)
733 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
734 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
736 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
737 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
739 ifneq (%(modsuffix),)
740 TMP_OPTS += -s %(modsuffix)
742 ifneq (%(targetdir),)
743 TMP_OPTS += -d %(targetdir)
744 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
747 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
748 $(TMP_TARGET) : MODNAME := %(modname)
749 $(TMP_TARGET) : MODTYPE := %(modtype)
750 $(TMP_TARGET) : $(TMP_DEPS)
751 @$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
753 #------------------------------------------------------------------------------
756 #------------------------------------------------------------------------------
757 # Generate the support files for compiling a module. This includes include
758 # files and source files. This rule has to be preceeded by
759 # %rule_genmodule_makefile
760 %define rule_genmodule_files modname=/A modtype=/A modsuffix= targetdir= \
763 TMP_TARGETS := $(%(modname)_STARTFILES) $(%(modname)_ENDFILES) \
764 $(%(modname)_LINKLIBFILES)
765 TMP_TARGETS := $(addsuffix .c,$(TMP_TARGETS)) $(addsuffix .S, $(%(modname)_LINKLIBAFILES))
767 TMP_DEPS := $(GENMODULE)
771 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
772 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
774 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
775 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
777 ifneq (%(modsuffix),)
778 TMP_OPTS += -s %(modsuffix)
780 ifneq (%(targetdir),)
781 TMP_OPTS += -d %(targetdir)
782 TMP_TARGETDIR := $(shell echo %(targetdir) | sed 's/^\(.\):\//\/\1\//')
783 TMP_TARGETS := $(addprefix $(TMP_TARGETDIR)/,$(TMP_TARGETS))
786 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
787 $(TMP_TARGETS) : MODNAME := %(modname)
788 $(TMP_TARGETS) : MODTYPE := %(modtype)
789 $(TMP_TARGETS) : $(TMP_DEPS)
790 @$(ECHO) "Generating support files for module $(MODNAME$(BDID))"
791 ifneq (%(conffile),lib.conf)
792 @$(IF) $(TEST) -f lib.conf; then \
793 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
796 @$(IF) $(TEST) -f libdefs.h; then \
797 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
799 @$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
801 #------------------------------------------------------------------------------
804 #------------------------------------------------------------------------------
805 # Generate the support files for compiling a module. This includes include
806 # files and source files.
807 %define rule_genmodule_includes modname=/A modtype=/A modsuffix= \
810 ifneq ($(%(modname)_INCLUDES),)
811 TMP_TARGETS := $(%(modname)_INCLUDES)
813 TMP_DEPS := $(GENMODULE)
817 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
818 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
820 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
821 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
823 ifneq (%(modsuffix),)
824 TMP_OPTS += -s %(modsuffix)
826 ifneq (%(targetdir),)
827 TMP_OPTS += -d %(targetdir)
828 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
831 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
832 $(TMP_TARGETS) : MODNAME := %(modname)
833 $(TMP_TARGETS) : MODTYPE := %(modtype)
834 $(TMP_TARGETS) : $(TMP_DEPS)
835 @$(ECHO) "Generating include files"
836 @$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
839 #------------------------------------------------------------------------------
842 #------------------------------------------------------------------------------
843 # Common rules for all makefiles
845 # Delete generated makefiles
848 @$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
850 include $(SRCDIR)/config/make.tail
852 BDID := $(BDTARGETID)
854 #------------------------------------------------------------------------------
857 #############################################################################
858 #############################################################################
860 ## Here are the mmakefile build macros. These are macros that takes care ##
861 ## of everything to go from the sources to the generated target. Also all ##
862 ## intermediate files and directories that are needed are created by these ##
865 #############################################################################
866 #############################################################################
868 #------------------------------------------------------------------------------
870 %define build_prog mmake=/A progname=/A files=$(BD_PROGNAME) asmfiles= \
871 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
872 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
873 aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
874 compiler=target srcdir=
878 BD_PROGNAME := %(progname)
879 BD_OBJDIR := %(objdir)
880 BD_TARGETDIR := %(targetdir)
883 BD_ASMFILES := %(asmfiles)
885 BD_ARCHOBJS := $(wildcard $(BD_OBJDIR)/arch/*.o)
886 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
887 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
889 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_NARCHFILES) $(BD_ASMFILES)))
890 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_NARCHFILES)))
892 BD_CFLAGS := %(cflags)
893 BD_AFLAGS := %(aflags)
894 BD_DFLAGS := %(dflags)
895 BD_LDFLAGS := %(ldflags)
898 %(mmake)-quick : %(mmake)
900 #MM %(mmake) : includes-generate-deps linklibs-core
901 %(mmake) : $(BD_TARGETDIR)/$(BD_PROGNAME)
903 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
904 %rule_compile basename=%(srcdir)% targetdir=$(BD_OBJDIR) \
905 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler=%(compiler)
906 %rule_assemble_multi basenames=$(BD_ASMFILES) targetdir=$(BD_OBJDIR) \
907 aflags=$(BD_AFLAGS) compiler=%(compiler)
909 %rule_link_prog prog=$(BD_TARGETDIR)/$(BD_PROGNAME) \
910 objs="$(BD_OBJS) $(BD_ARCHOBJS) $(USER_OBJS)" ldflags=$(BD_LDFLAGS) \
911 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
912 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)" \
917 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
919 $(BD_OBJS) $(BD_DEPS) : | $(BD_OBJDIR)
920 $(BD_TARGETDIR)/$(BD_PROGNAME) : | $(BD_TARGETDIR)
921 GLOB_MKDIRS += $(BD_OBJDIR) $(BD_TARGETDIR)
923 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_TARGETDIR)/$(BD_PROGNAME) $(BD_DEPS)
926 @$(ECHO) "Cleaning up for metatarget %(mmake)"
930 #------------------------------------------------------------------------------
933 #------------------------------------------------------------------------------
934 # Build programs, for every C file an executable will be built with the same
936 %define build_progs mmake=/A files=/A nix=no \
937 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
938 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
939 uselibs= usehostlibs= usestartup=yes detach=no
943 BD_OBJDIR := %(objdir)
944 BD_TARGETDIR := %(targetdir)
947 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
948 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
949 BD_EXES := $(addprefix $(BD_TARGETDIR)/,$(BD_FILES))
951 BD_CFLAGS := %(cflags)
952 BD_DFLAGS := %(dflags)
953 BD_LDFLAGS := %(ldflags)
956 %(mmake)-quick : %(mmake)
958 #MM %(mmake) : includes-generate-deps
959 %(mmake) : $(BD_EXES)
961 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
962 %rule_compile basename=% targetdir=$(BD_OBJDIR) nix=%(nix) \
963 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
965 %rule_link_progs progs=$(BD_FILES) nix=%(nix) \
966 targetdir=$(BD_TARGETDIR) objdir=$(BD_OBJDIR) \
967 ldflags=$(BD_LDFLAGS) \
968 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
969 usestartup="%(usestartup)" detach="%(detach)"
973 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
975 $(addprefix $(BD_TARGETDIR)/,$(BD_FILES)) : | $(BD_TARGETDIR)
976 $(BD_DEPS) $(BD_OBJS) : | $(BD_OBJDIR)
977 GLOB_MKDIRS += $(BD_TARGETDIR) $(BD_OBJDIR)
979 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_EXES) $(BD_DEPS)
982 @$(ECHO) "Cleaning up for metatarget %(mmake)"
986 #------------------------------------------------------------------------------
989 #------------------------------------------------------------------------------
991 # This is a bare version: It just compiles and links the given files. It is
992 # assumed that all needed boiler plate code is in the files. This should only
993 # be used for compiling external code. For AROS code use %build_module
994 %define build_module_simple mmake=/A modname=/A modtype=/A \
995 files="$(basename $(call WILDCARD, *.c))" \
996 cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
997 objdir=$(OBJDIR) moduledir= \
998 uselibs= usehostlibs= compiler=target
1000 # Define metamake targets and their dependencies
1001 #MM %(mmake) : core-linklibs includes-generate-deps
1002 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1006 BD_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj
1008 .PHONY : $(BD_ALLTARGETS)
1011 $(error using %build_module_simple: modname may not be empty)
1014 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1017 # Default values for variables and arguments
1018 BD_DEFLINKLIBNAME := %(modname)
1019 BD_DEFDFLAGS := %(cflags)
1020 OBJDIR ?= $(GENDIR)/$(CURDIR)
1021 BD_MODDIR := %(moduledir)
1022 ifeq ($(BD_MODDIR),)
1023 ifeq (%(modtype),library)
1024 BD_MODDIR := $(AROS_LIBS)
1026 ifeq (%(modtype),gadget)
1027 BD_MODDIR := $(AROS_GADGETS)
1029 ifeq (%(modtype),datatype)
1030 BD_MODDIR := $(AROS_DATATYPES)
1032 ifeq (%(modtype),handler)
1033 BD_MODDIR := $(AROS_FS)
1035 ifeq (%(modtype),device)
1036 BD_MODDIR := $(AROS_DEVS)
1038 ifeq (%(modtype),resource)
1039 BD_MODDIR := $(AROS_RESOURCES)
1041 ifeq (%(modtype),mui)
1042 BD_MODDIR := $(AROS_CLASSES)/Zune
1044 ifeq (%(modtype),mcc)
1045 BD_MODDIR := $(AROS_CLASSES)/Zune
1047 ifeq (%(modtype),mcp)
1048 BD_MODDIR := $(AROS_CLASSES)/Zune
1050 ifeq (%(modtype),usbclass)
1051 BD_MODDIR := $(AROS_CLASSES)/USB
1053 ifeq (%(modtype),hidd)
1054 BD_MODDIR := $(AROS_DRIVERS)
1057 ifeq ($(BD_MODDIR),)
1058 $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1061 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1062 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1063 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),%(files))
1065 %rule_compile_multi \
1066 basenames="$(BD_NARCHFILES)" targetdir="%(objdir)" \
1067 cflags="%(cflags)" dflags="%(dflags)" \
1068 compiler=%(compiler)
1070 BD_MODULE := $(BD_MODDIR)/%(modname).%(modtype)
1071 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1073 %(mmake)-quick : %(mmake)
1074 %(mmake) : $(BD_MODULE)
1075 %(mmake)-kobj : $(BD_KOBJ)
1077 # The module is linked from all the compiled .o files
1078 BD_OBJS := $(BD_ARCHOBJS) $(addprefix %(objdir)/, $(addsuffix .o,$(notdir $(BD_NARCHFILES))))
1079 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1080 endobj= err=%(modname).err objdir=%(objdir) \
1081 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1083 # Link kernel object file
1084 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1086 # Make these symbols local
1087 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1088 UtilityBase ExpansionBase KeymapBase KernelBase
1090 BD_SYMBOLS := $(BD_KBASE)
1092 BD_KLIB := hiddgraphicsstubs hiddstubs amiga arossupport rom arosm autoinit libinit
1093 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1094 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1095 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
1096 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1097 @$(ECHO) "Linking $@"
1098 @$(AROS_LD) -Ur -o $@ $^ -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1099 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^libraryset_.*$$/) {print "-L " $$3;}'`
1102 ## Dependency fine-tuning
1104 BD_DEPS := $(addprefix %(objdir)/, $(addsuffix .d,%(files)))
1105 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1107 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1108 $(BD_MODULE) : | $(BD_MODDIR)
1109 $(BD_KOBJ) : | $(KOBJSDIR)
1110 GLOB_MKDIRS += %(objdir) $(BD_MODDIR) $(KOBJSDIR)
1112 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_MODULE) $(BD_KOBJ) $(BD_DEPS)
1114 @$(ECHO) "Cleaning up for module %(modname)"
1117 #------------------------------------------------------------------------------
1120 #------------------------------------------------------------------------------
1122 # Explanation of this macro is done in the developer's manual
1123 %define build_module mmake=/A modname=/A modtype=/A modsuffix= \
1124 conffile= files="$(basename $(call WILDCARD, *.c))" \
1125 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1126 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
1127 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
1130 # Define metamake targets and their dependencies
1131 #MM- includes-all : %(mmake)-includes
1132 #MM %(mmake) : %(mmake)-includes core-linklibs
1133 #MM %(mmake)-kobj : %(mmake)-includes core-linklibs
1134 #MM %(mmake)-kobj-quick : %(mmake)-includes-quick
1135 #MM %(mmake)-linklib : %(mmake)-includes
1136 #MM %(mmake)-quick : %(mmake)-includes-quick
1137 #MM %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1138 #MM includes-generate-deps
1139 #MM %(mmake)-includes-quick
1140 #MM %(mmake)-includes-dirs
1141 #MM %(mmake)-makefile
1144 # All MetaMake targets defined by this macro
1145 BD_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-includes \
1146 %(mmake)-includes-quick %(mmake)-includes-dirs %(mmake)-clean \
1147 %(mmake)-kobj %(mmake)-kobj-quick %(mmake)-linklib
1149 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1152 $(error using %build_module: modname may not be empty)
1155 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1158 # Default values for variables and arguments
1159 BD_DEFLINKLIBNAME := %(modname)
1160 BD_DEFDFLAGS := %(cflags)
1161 OBJDIR ?= $(GENDIR)/$(CURDIR)
1163 ## Create genmodule include Makefile for the module
1165 %(mmake)-makefile : %(objdir)/Makefile.%(modname)
1167 %rule_genmodule_makefile \
1168 modname=%(modname) modtype=%(modtype) \
1169 modsuffix=%(modsuffix) targetdir=%(objdir) \
1170 conffile=%(conffile)
1172 %(objdir)/Makefile.%(modname) : | %(objdir)
1174 GLOB_MKDIRS += %(objdir)
1176 # Do not parse these statements if metatarget is not appropriate
1177 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1179 include %(objdir)/Makefile.%(modname)
1181 BD_DEFMODDIR := $(%(modname)_MODDIR)
1184 ## include files generation
1186 BD_INCDIR := %(prefix)/$(AROS_DIR_INCLUDE)
1187 BD_LIBDEFSINC := %(objdir)/include/%(modname)_libdefs.h
1188 BD_DEFLIBDEFSINC := %(objdir)/include/%(modname)_deflibdefs.h
1190 %(mmake)-includes-quick : %(mmake)-includes
1191 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1192 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1193 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1195 ifneq ($(%(modname)_INCLUDES),)
1196 %rule_genmodule_includes modname=%(modname) modtype=%(modtype) \
1197 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1198 conffile=%(conffile)
1200 %rule_copy_diff_multi \
1201 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(GENINCDIR) \
1202 stampfile=%(objdir)/%(modname)_geninc
1204 %rule_copy_diff_multi \
1205 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(BD_INCDIR) \
1206 stampfile=%(objdir)/%(modname)_incs
1208 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1210 TMP%(modname)_INCDIRS := \
1211 %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1212 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1213 $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1214 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget=%(mmake)-includes-dirs
1218 %rule_genmodule_genlibdefs modname=%(modname) modtype=%(modtype) \
1219 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1220 conffile=%(conffile)
1222 $(BD_DEFLIBDEFSINC) : FILENAME := $(BD_LIBDEFSINC)
1223 $(BD_DEFLIBDEFSINC) :
1224 @$(ECHO) "generating $@"
1225 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1227 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) : | %(objdir)/include
1228 GLOB_MKDIRS += %(objdir)/include
1230 ## Extra genmodule src files generation
1232 %rule_genmodule_files modname=%(modname) modtype=%(modtype) \
1233 modsuffix=%(modsuffix) targetdir=%(objdir) \
1234 conffile=%(conffile)
1238 BD_FILES := %(files)
1239 BD_FDIRS := $(sort $(dir $(BD_FILES)))
1240 BD_STARTFILES := $(addprefix %(objdir)/,$(%(modname)_STARTFILES))
1241 BD_ENDFILES := $(addprefix %(objdir)/,$(%(modname)_ENDFILES))
1243 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1244 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1245 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1247 BD_CFLAGS := %(cflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1248 BD_DFLAGS := %(dflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1250 BD_LINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBFILES))
1251 BD_LINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBAFILES))
1252 ifeq ($(strip $(%(modname)_LINKLIBFILES) %(linklibfiles)),)
1255 BD_LINKLIB := %(prefix)/$(AROS_DIR_LIB)/lib%(linklibname).a
1257 BD_LINKLIBFILES := $(BD_LINKLIBCFILES) $(BD_LINKLIBAFILES)
1259 BD_CCFILES := $(BD_NARCHFILES) %(linklibfiles)
1260 BD_TARGETCCFILES := $(BD_STARTFILES) $(BD_ENDFILES) $(BD_LINKLIBCFILES)
1262 %rule_compile_multi \
1263 basenames=$(BD_CCFILES) targetdir=%(objdir) \
1264 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) \
1265 compiler=%(compiler)
1266 %rule_compile_multi \
1267 basenames=$(BD_TARGETCCFILES) targetdir=%(objdir) \
1268 cflags="$(BD_CFLAGS) -D__AROS__" dflags=$(BD_DFLAGS) \
1269 compiler=%(compiler)
1271 ifneq ($(BD_LINKLIBAFILES),)
1272 %rule_assemble_multi \
1273 basenames=$(BD_LINKLIBAFILES) targetdir=%(objdir) suffix=.S
1278 ifeq (%(modsuffix),)
1279 BD_MODULE := %(prefix)/%(moduledir)/%(modname).%(modtype)
1280 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1282 BD_MODULE := %(prefix)/%(moduledir)/%(modname).%(modsuffix)
1283 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modsuffix).o
1286 %(mmake)-quick : %(mmake)
1287 %(mmake) : $(BD_MODULE) $(BD_LINKLIB)
1288 %(mmake)-kobj : $(BD_KOBJ) $(BD_LINKLIB)
1289 %(mmake)-kobj-quick : $(BD_KOBJ) $(BD_LINKLIB)
1290 %(mmake)-linklib : $(BD_LINKLIB)
1292 BD_OBJS := $(addsuffix .o,$(BD_STARTFILES)) $(BD_ARCHOBJS) \
1293 $(addsuffix .o, $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES))))
1294 BD_STARTOBJS := $(addsuffix .o,$(addprefix $(GENDIR)/,$(RESIDENT_BEGIN)))
1295 BD_ENDOBJS := $(addsuffix .o,$(BD_ENDFILES))
1296 BD_LINKLIBOBJS:= $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_LINKLIBFILES)) \
1299 # The module is linked from all the compiled .o files
1300 %rule_linkmodule module=$(BD_MODULE) objs="$(BD_STARTOBJS) $(BD_OBJS)" \
1301 endobj=$(BD_ENDOBJS) err=%(modname).err objdir=%(objdir) \
1302 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1305 ifneq ($(BD_LINKLIB),)
1306 %rule_link_linklib libname=%(linklibname) objs=$(BD_LINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1308 $(BD_LINKLIB) : | %(prefix)/$(AROS_DIR_LIB)
1309 GLOB_MKDIRS += %(prefix)/$(AROS_DIR_LIB)
1312 # Link kernel object file
1313 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1315 # Make these symbols local
1316 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1317 UtilityBase ExpansionBase KeymapBase KernelBase
1319 BD_SYMBOLS := $(BD_KBASE)
1321 BD_KLIB := hiddgraphicsstubs hiddstubs amiga arossupport rom arosm autoinit libinit
1322 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1323 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1324 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
1325 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1326 @$(ECHO) "Linking $@"
1327 @$(AROS_LD) -Ur -o $@ $^ -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1328 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^libraryset_.*$$/) {print "-L " $$3;}'`
1330 ## Dependency fine-tuning
1332 BD_DEPS := $(addsuffix .d,$(addprefix %(objdir)/,$(notdir $(BD_CCFILES) $(BD_TARGETCCFILES))))
1333 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick" deps=$(BD_DEPS)
1335 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1336 $(BD_MODULE) : | %(prefix)/%(moduledir)
1337 $(BD_KOBJ) : | $(KOBJSDIR)
1338 GLOB_MKDIRS += %(objdir) %(prefix)/%(moduledir) $(KOBJSDIR)
1340 # Some include files need to be generated before the .c can be parsed.
1341 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick),) # Only for this target these deps are wanted
1343 BD_DFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
1344 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES))
1345 $(BD_DEPS) : $(BD_DFILE_DEPS)
1348 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) \
1349 $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
1350 %(objdir)/Makefile.%(modname) \
1351 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
1352 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1353 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1354 %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
1355 $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
1356 $(BD_DEFLIBDEFSINC) $(addsuffix .c,$(BD_STARTFILES) $(BD_ENDFILES)) \
1358 %(mmake)-clean : FILES := $(BD_TOCLEAN)
1360 @$(ECHO) "Cleaning up for module %(modname)"
1363 endif # $(TARGET) in $(BD_ALLTARGETS)
1365 #------------------------------------------------------------------------------
1368 #------------------------------------------------------------------------------
1369 # Build a module skeleton
1370 # This is a stripped-down version of build_module, it only creates include files,
1371 # but no actual object. This is used when for plugins or classes with the same
1372 # API, but no actual implementation here.
1373 %define build_module_skeleton mmake=/A modname=/A modtype=/A modsuffix= \
1375 objdir=$(OBJDIR) prefix=$(AROSDIR)
1377 # Define metamake targets and their dependencies
1378 #MM- includes-all : %(mmake)-includes
1379 #MM %(mmake) : %(mmake)-includes core-linklibs
1380 #MM %(mmake)-kobj : %(mmake)-includes core-linklibs
1381 #MM %(mmake)-linklib : %(mmake)-includes
1382 #MM %(mmake)-quick : %(mmake)-includes-quick
1383 #MM %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1384 #MM includes-generate-deps
1385 #MM %(mmake)-includes-quick
1386 #MM %(mmake)-includes-dirs
1387 #MM %(mmake)-makefile
1390 # All MetaMake targets defined by this macro
1391 BD_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-includes \
1392 %(mmake)-includes-quick %(mmake)-includes-dirs %(mmake)-clean \
1395 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1398 $(error using %build_module_skeleton: modname may not be empty)
1401 $(error using %build_module_skeleton: $(MODTYPE) has to be defined with the type of the module)
1404 # Default values for variables and arguments
1405 BD_DEFLINKLIBNAME := %(modname)
1406 BD_DEFDFLAGS := %(cflags)
1407 OBJDIR ?= $(GENDIR)/$(CURDIR)
1409 ## Create genmodule include Makefile for the module
1411 %(mmake)-makefile : %(objdir)/Makefile.%(modname)
1413 %rule_genmodule_makefile \
1414 modname=%(modname) modtype=%(modtype) \
1415 modsuffix=%(modsuffix) targetdir=%(objdir) \
1416 conffile=%(conffile)
1418 %(objdir)/Makefile.%(modname) : | %(objdir)
1420 GLOB_MKDIRS += %(objdir)
1422 # Do not parse these statements if metatarget is not appropriate
1423 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1425 include %(objdir)/Makefile.%(modname)
1427 BD_DEFMODDIR := $(%(modname)_MODDIR)
1430 ## include files generation
1432 BD_INCDIR := %(prefix)/$(AROS_DIR_INCLUDE)
1433 BD_LIBDEFSINC := %(objdir)/include/%(modname)_libdefs.h
1434 BD_DEFLIBDEFSINC := %(objdir)/include/%(modname)_deflibdefs.h
1436 %(mmake)-includes-quick : %(mmake)-includes
1437 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1438 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1439 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1441 ifneq ($(%(modname)_INCLUDES),)
1442 %rule_genmodule_includes modname=%(modname) modtype=%(modtype) \
1443 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1444 conffile=%(conffile)
1446 %rule_copy_diff_multi \
1447 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(GENINCDIR) \
1448 stampfile=%(objdir)/%(modname)_geninc
1450 %rule_copy_diff_multi \
1451 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(BD_INCDIR) \
1452 stampfile=%(objdir)/%(modname)_incs
1454 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1456 TMP%(modname)_INCDIRS := \
1457 %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1458 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1459 $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1460 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget=%(mmake)-includes-dirs
1464 %rule_genmodule_genlibdefs modname=%(modname) modtype=%(modtype) \
1465 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1466 conffile=%(conffile)
1468 $(BD_DEFLIBDEFSINC) : FILENAME := $(BD_LIBDEFSINC)
1469 $(BD_DEFLIBDEFSINC) :
1470 @$(ECHO) "generating $@"
1471 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1473 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) : | %(objdir)/include
1474 GLOB_MKDIRS += %(objdir)/include
1476 ## Extra genmodule src files generation
1478 %rule_genmodule_files modname=%(modname) modtype=%(modtype) \
1479 modsuffix=%(modsuffix) targetdir=%(objdir) \
1480 conffile=%(conffile)
1482 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) \
1483 $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
1484 %(objdir)/Makefile.%(modname) \
1485 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
1486 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1487 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1488 %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
1489 $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
1491 %(mmake)-clean : FILES := $(BD_TOCLEAN)
1493 @$(ECHO) "Cleaning up for module %(modname)"
1496 endif # $(TARGET) in $(BD_ALLTARGETS)
1498 #------------------------------------------------------------------------------
1501 #------------------------------------------------------------------------------
1503 # - mmake is the mmaketarget
1504 # - libname is the baselibname e.g. lib%(libname).a will be created
1505 # - files are the C source files to include in the lib. The list of files
1506 # has to be given without the .c suffix
1507 # - asmfiles are the asm files to include in the lib. The list of files has to
1508 # be given without the .s suffix
1509 # - objs additional object to link into the linklib. The objects have to be
1510 # given with full absolute path and the .o suffix.
1511 # - cflags are the flags to compile the source (default $(CFLAGS))
1512 # - dflags are the flags use during makedepend (default equal to cflags)
1513 # - aflags are the flags use during assembling (default $(AFLAGS))
1514 # - objdir is where the .o are generated
1515 # - libdir is the directory where the linklib will be placed (default $(LIBDIR))
1516 %define build_linklib mmake=/A libname=/A \
1517 files="$(basename $(call WILDCARD, *.c))" asmfiles= objs= \
1518 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) objdir=$(OBJDIR) libdir=$(LIBDIR)
1520 # assign and generate the local variables used in this macro
1521 OBJDIR ?= $(GENDIR)/$(CURDIR)
1523 BD_FILES := %(files)
1524 BD_ASMFILES := %(asmfiles)
1526 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1527 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1528 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1530 BD_OBJS := $(BD_ARCHOBJS) \
1531 $(addsuffix .o,$(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES) $(BD_ASMFILES)))) \
1533 BD_DEPS := $(patsubst %.o,%.d,$(BD_OBJS))
1535 BD_CFLAGS := %(cflags)
1537 BD_DFLAGS := $(BD_CFLAGS)
1539 BD_DFLAGS := %(dflags)
1541 BD_AFLAGS := %(aflags)
1543 BD_LINKLIB := %(libdir)/lib%(libname).a
1545 .PHONY : %(mmake) %(mmake)-clean
1547 #MM %(mmake) : includes-generate-deps
1548 %(mmake) : $(BD_LINKLIB)
1552 @$(RM) $(BD_OBJS) $(BD_DEPS)
1554 ifeq ($(TARGET),%(mmake))
1555 ifneq ($(dir $(BD_FILES)),./)
1556 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
1557 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir $(BD_FILES)))
1560 %rule_compile basename=% targetdir=%(objdir) \
1561 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1562 %rule_assemble basename=% targetdir=%(objdir) \
1566 %rule_link_linklib libname=%(libname) objs=$(BD_OBJS) libdir=%(libdir)
1568 %include_deps depstargets=%(mmake) deps=$(BD_DEPS)
1570 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1571 $(BD_LINKLIB) : | %(libdir)
1572 GLOB_MKDIRS += %(objdir) %(libdir)
1575 #------------------------------------------------------------------------------
1578 #------------------------------------------------------------------------------
1580 # - mmake is the mmaketarget
1581 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
1582 # - description is the catalog description file (.cd), without the .ct suffix (default *.cd)
1583 # - subdir is the destination subdirectory of the catalogs
1584 # - name is the name of the destination catalog, without the .catalog suffix
1585 # - source is the path to the generated source code file
1586 # - dir is the base destination directory (default $(AROS_CATALOGS))
1587 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
1588 # - srcdir is the directory in which the *.cd and *.ct files are searched
1590 %define build_catalogs mmake=/A name=/A subdir=/A \
1591 catalogs= source="../strings.h" description= dir=$(AROS_CATALOGS) \
1592 sourcedescription="$(TOOLDIR)/C_h_orig" srcdir="$(SRCDIR)/$(CURDIR)"
1594 ifeq (%(description),)
1595 BD_DESC := $(basename $(wildcard %(srcdir)/*.cd))
1597 BD_DESC := %(description)
1601 BD_LNGS := $(basename $(notdir $(call WILDCARD, %(srcdir)/*.ct)))
1603 BD_LNGS := %(catalogs)
1606 BD_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, $(BD_LNGS)))
1607 BD_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, $(BD_LNGS))) $(dir %(source))
1610 %(mmake) : $(BD_OBJS) %(source)
1612 $(BD_OBJS) : | $(BD_DIRS)
1613 GLOB_MKDIRS += $(BD_DIRS)
1615 %(dir)/%/%(subdir)/%(name).catalog : %(srcdir)/%.ct $(BD_DESC).cd
1616 @$(ECHO) "Creating %(name) catalog for language $*."
1617 @$(FLEXCAT) $(BD_DESC).cd $< CATALOG=%(dir)/$*/%(subdir)/%(name).catalog || [ $$? -lt 10 ]
1620 %(source) : TMP_SOURCEDESCRIPTION := $(shell echo %(sourcedescription) | sed 's/^\(.\):\//\/\1\//')
1621 %(source) : $(BD_DESC).cd | $(dir %(source))
1622 @$(ECHO) "Creating %(name) catalog source file %(source)"
1623 @$(FLEXCAT) $(BD_DESC).cd %(source)=$(TMP_SOURCEDESCRIPTION).sd
1628 $(RM) $(BD_OBJS) %(source)
1630 .PHONY: %(mmake) %(mmake)-clean
1633 #-----------------------------------------------------------------------------
1636 #-----------------------------------------------------------------------------
1638 # - mmake is the mmaketarget
1639 # - icons is a list of icon base names (ie. without the .info suffix)
1640 # - dir is the destination directory
1641 # - srcdir is where *.png and *.info.src are searched
1642 #-----------------------------------------------------------------------------
1644 %define build_icons mmake=/A icons=/A dir=/A srcdir="$(SRCDIR)/$(CURDIR)" image=
1646 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
1649 %(mmake) : $(BD_OBJS)
1653 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%.png
1654 @$(ECHO) Creating $(notdir $@)...
1655 @$(ILBMTOICON) $+ $@
1659 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%(image)
1660 @$(ECHO) Creating $(notdir $@)...
1661 @$(ILBMTOICON) $+ $@
1665 $(BD_OBJS) : | %(dir)
1666 GLOB_MKDIRS += %(dir)
1668 %(mmake)-clean : FILES := $(BD_OBJS)
1673 .PHONY: %(mmake) %(mmake)-clean
1676 #-----------------------------------------------------------------------------
1679 #------------------------------------------------------------------------------
1680 # Compile files for an arch-specific replacement of code for a module
1681 # - files: the basenames of the C files to compile.
1682 # - asmfiles: the basenames of the asm files to assemble.
1683 # - mainmmake: the mmake of the module in the main directory to compile these
1684 # arch specific files for.
1685 # - maindir: the object directory for the main module
1686 # - arch: the arch for which to compile these files. It can have the form
1687 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
1688 # - cflags (default $(CFLAGS)): the C flags to use for compilation
1689 # - dflags: the flags used during creation of dependency file. If not specified
1690 # the same value as cflags will be used
1691 # - aflags: the flags used during assembling
1692 # - compiler: (host, kernel or target) specifies which compiler to use. By default
1693 # the target compiler is used
1694 %define build_archspecific files= asmfiles= mainmmake=/A maindir=/A arch=/A \
1695 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
1697 ifeq (%(files) %(asmfiles),)
1698 $(error no files or asmfiles given)
1701 %buildid targets="%(mainmmake)-%(arch)"
1703 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1704 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1705 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1706 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1707 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1708 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1709 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1710 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1711 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1712 #MM- %(mainmmake)-kobj-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1713 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1714 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1715 #MM- %(mainmmake)-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1716 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1717 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1719 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
1722 $(error argument arch has to be non empty for the rule_compile_archspecific macro)
1725 BD_OBJDIR$(BDID) := $(GENDIR)/%(maindir)/arch
1726 BD_COBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1727 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
1728 BD_OBJS$(BDID) := $(BD_COBJS$(BDID)) $(BD_ASMOBJS$(BDID))
1729 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1731 ifeq ($(TARGET),%(mainmmake)-%(arch))
1732 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
1733 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(files)))
1734 vpath %.s $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
1735 vpath %.S $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
1738 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID))
1739 GLOB_MKDIRS += $(BD_OBJDIR$(BDID))
1742 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
1744 ifeq ($(findstring %(compiler),host kernel target),)
1745 $(error unknown compiler %(compiler))
1747 ifeq (%(compiler),target)
1748 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
1749 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
1750 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
1752 ifeq (%(compiler),host)
1753 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(HOST_CC)
1754 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
1755 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
1757 ifeq (%(compiler),kernel)
1758 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
1759 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
1760 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
1762 ifneq (%(modulename),)
1763 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) \
1764 -include $(GENDIR)/%(maindir)/include/%(modulename)_deflibdefs.h
1766 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
1768 ifeq ($(TARGET),%(mainmmake)-%(arch))
1769 $(BD_OBJDIR$(BDID))/%.o : %.c
1770 %compile_q opt=$(TMP_CFLAGS) cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
1774 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags)
1776 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
1778 ifeq ($(TARGET),%(mainmmake)-%(arch))
1779 $(BD_OBJDIR$(BDID))/%.d : %.c
1780 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
1783 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
1785 ifeq ($(TARGET),%(mainmmake)-%(arch))
1786 $(BD_OBJDIR$(BDID))/%.o : %.s
1787 %assemble_q opt=$(AFLAGS)
1788 $(BD_OBJDIR$(BDID))/%.o : %.S
1789 %assemble_q opt=$(AFLAGS)
1792 %include_deps depstargets=%(mainmmake)-%(arch) deps=$(BD_DEPS$(BDID))
1794 #------------------------------------------------------------------------------
1797 #------------------------------------------------------------------------------
1798 # generate asm files from c files (for debugging purposes)
1801 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
1802 @$(TARGET_CC) -S $(CFLAGS) $(TARGET_CFLAGS) $< -c -o $@
1804 #------------------------------------------------------------------------------
1807 #------------------------------------------------------------------------------
1808 # Copy files from one directory to another.
1810 %define copy_files_q mmake=/A files=$(FILES) src=. dst=/A
1812 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
1814 GLOB_MKDIRS += %(dst)
1820 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC))/, $(file)) $(addprefix %(dst)/, $(file))))
1823 #------------------------------------------------------------------------------
1826 #------------------------------------------------------------------------------
1827 # Copy a directory recursively to another place, preserving the original
1828 # hierarchical structure
1830 # src: the source directory whose content will be copied
1831 # dst: the directory where to copy src's content. If not existing, it will be made.
1833 %define copy_dir_recursive mmake=/A src=. dst=/A excludefiles=
1835 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
1836 %(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)
1837 %(mmake)_DIRS := $(sort $(dir $(%(mmake)_FILES)))
1839 %(mmake)_EXCLUDEFILES := $(addprefix ./,%(excludefiles))
1840 %(mmake)_FILES := $(filter-out $(%(mmake)_EXCLUDEFILES),$(%(mmake)_FILES))
1842 GLOB_MKDIRS += $(GENDIR)/$(CURDIR)
1847 %(mmake): | $(GENDIR)/$(CURDIR)
1848 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1849 $(ECHO) "all: $(addprefix \$$(DST)/,$(%(mmake)_FILES))" > $$m
1850 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1851 for d in $(%(mmake)_DIRS); do \
1852 $(ECHO) "\$$(DST)/$$d: ; $(MKDIR) \$$@" >> $$m; \
1854 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1855 for f in $(%(mmake)_FILES); do \
1856 $(ECHO) "\$$(DST)/$$f: \$$(SRC)/$$f | \$$(dir \$$(DST)/$$f); $(CP) \$$< \$$@" >> $$m; \
1858 for dst in %(dst); do \
1859 $(MAKE) -f $$m DST=$$dst SRC=$(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC)) all; \
1863 #------------------------------------------------------------------------------
1866 #------------------------------------------------------------------------------
1867 # Copy include files into the includes directories. There are currently
1868 # two include directories. One for building AROS $(AROS_INCLUDES) and one
1869 # for building tools that need to run on the host system $(GENINCDIR). The
1870 # $(GENINCDIR) path must not contain any references to the C runtime
1871 # library header files.
1873 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
1874 dir= compiler=target
1876 ifeq ($(findstring %(compiler),host kernel target),)
1877 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
1881 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),$(dir %(includes)))
1882 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,$(notdir %(includes)))
1883 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
1885 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
1886 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
1889 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
1893 ifeq (%(compiler),target)
1896 BD_INCL_FILES2 := $(subst %(dir),$(AROS_INCLUDES)/%(path),$(dir %(includes)))
1897 BD_INCL_FILES2 := $(addprefix $(AROS_INCLUDES)/%(path)/,$(notdir %(includes)))
1899 BD_INCL_FILES2 := $(addprefix $(AROS_INCLUDES)/%(path)/,%(includes))
1902 BD_INCL_FILES += $(BD_INCL_FILES2)
1904 $(BD_INCL_FILES2) : $(AROS_INCLUDES)/%(path)/% : $(BD_INC_PATH)%
1909 %(mmake) : $(BD_INCL_FILES)
1913 $(BD_INCL_FILES) : | $(dir $(BD_INCL_FILES))
1914 GLOB_MKDIRS += $(dir $(BD_INCL_FILES))
1916 #------------------------------------------------------------------------------
1919 #------------------------------------------------------------------------------
1920 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
1921 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
1922 STUBS_MEM := $(addsuffix .o,$(STUBS))
1923 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
1924 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
1925 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
1927 #MM- linklibs : hidd-%(hidd)-stubs
1928 #MM- %(parenttarget): hidd-%(hidd)-stubs
1929 #MM hidd-%(hidd)-stubs : includes includes-copy
1930 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
1932 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
1935 $(STUBS_OBJ) : $(STUBS_SRC)
1936 %compile_q cmd="$(TARGET_CC) $(TARGET_CFLAGS)" opt=%(cflags) iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
1938 $(STUBS_DEP) : $(STUBS_SRC)
1939 %mkdepend_q flags=%(dflags)
1942 %mkdirs_q $(OBJDIR) $(LIBDIR)
1946 -@$(RM) $(HIDD_LIB) $(OBJDIR)
1948 DEPS := $(DEPS) $(STUBS_DEP)
1951 #------------------------------------------------------------------------------
1954 #------------------------------------------------------------------------------
1955 # Build an imported source tree which uses the configure script from the
1956 # autoconf package. This rule will try to "integrate" the produced files as
1957 # much as possible in the AROS build, for example by putting libraries in the
1958 # standard library directory, includes in the standard include directory, and
1959 # so on. You can however override this behaviour.
1961 # As a special "bonus" for you, the PROGDIR environment variable is defined to
1962 # be %(bindir) (or its deduced value) when running "make install", and
1963 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
1964 # configure script some more parameters whose value depends upon the PROGDIR
1965 # env var, so that the program gets all its stuff installed in the proper place
1966 # when building it, but when running it from inside AROS it can also find that
1967 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
1968 # the configuration parameters set when running ./configure
1970 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
1971 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
1972 # to the name which has to follow it.
1975 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) prefix= \
1976 aros_prefix= extraoptions= nix_dir_layout= nix=no compiler=target \
1977 install_target=install preconfigure= postconfigure= postinstall= \
1981 %(mmake)-prefix := %(prefix)
1983 %(mmake)-prefix := $(AROS_CONTRIB)
1986 ifneq (%(aros_prefix),)
1987 %(mmake)-aros_prefix := %(aros_prefix)
1989 %(mmake)-aros_prefix := $(%(mmake)-prefix)
1993 %(mmake)-nix := -nix
1994 %(mmake)-volpfx := /
1995 %(mmake)-volsfx := /
1997 ifeq (%(nix_dir_layout),)
1998 %(mmake)-nix_dir_layout := yes
2001 %(mmake)-volsfx := :
2003 ifeq (%(nix_dir_layout),)
2004 %(mmake)-nix_dir_layout := no
2008 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
2010 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
2011 exec_prefix=$(%(mmake)-prefix) %(install_env)
2013 # Check if chosen compiler is valid
2014 ifeq ($(findstring %(compiler),host target kernel),)
2015 $(error unknown compiler %(compiler))
2018 # Set legacy 'host' variable based on chosen compiler
2019 ifeq (%(compiler),host)
2022 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
2024 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
2029 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
2031 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
2035 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
2036 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
2038 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
2039 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
2040 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2043 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
2044 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
2046 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2049 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
2051 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
2052 sbindir=$(%(mmake)-prefix) \
2053 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
2054 oldincludedir=$(AROS_INCLUDES) %(install_env)
2058 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
2060 #MM- %(mmake) : setup includes linklibs-core %(mmake)-quick
2062 # Using -j1 in install_command may result in a warning but finally
2063 # it does its job. make install for gcc does not work reliable for -jN
2065 ifneq (%(install_target),)
2066 %(mmake)-install_command = \
2067 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2068 -C $(%(mmake)-pkgdir) %(install_target) -j1
2070 %(mmake)-uninstall_command = \
2071 $(RM) $(%(mmake)-installflag) && \
2072 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2073 -C $(%(mmake)-pkgdir) uninstall
2075 %(mmake)-install_command := true
2076 %(mmake)-uninstall_command := true
2079 #MM- %(mmake)-quick : %(preconfigure) %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
2082 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
2084 $(%(mmake)-installflag) : $(%(mmake)-configflag)
2085 if ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q -C $(%(mmake)-pkgdir); then \
2086 $(RM) $(%(mmake)-installflag) && \
2087 $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -C $(%(mmake)-pkgdir) && \
2088 $(%(mmake)-install_command) && \
2089 $(TOUCH) $@ -r $^; \
2092 $(%(mmake)-pkgdir)/.files-touched:
2093 %mkdirs_q $(%(mmake)-pkgdir)
2094 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/configure '{}' \; && \
2098 %(mmake)-uninstall :
2099 $(%(mmake)-uninstall_command)
2101 ifneq ($(DEBUG),yes)
2102 %(mmake)-s_flag = -s
2106 %(mmake)-configure : $(%(mmake)-configflag)
2108 $(%(mmake)-configflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
2109 ifeq (%(compiler),host)
2110 $(%(mmake)-configflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2112 %mkdirs_q $(%(mmake)-pkgdir)
2113 cd $(%(mmake)-pkgdir) && \
2114 find . -name config.cache -exec $(RM) '{}' \; && \
2115 CC="$(HOST_CC) $(HOST_CFLAGS)" \
2116 TARGET_CC="$(KERNEL_CC) $(KERNEL_CFLAGS) $(%(mmake)-s_flag)" \
2117 TARGET_AS="$(TARGET_AS)" OBJCOPY="$(OBJCOPY)" \
2118 $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) %(extraoptions) \
2119 --target=$(AROS_TARGET_CPU)-aros && \
2122 ifeq (%(compiler),target)
2123 $(%(mmake)-configflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2125 %mkdirs_q $(%(mmake)-pkgdir)
2126 cd $(%(mmake)-pkgdir) && \
2127 find . -name config.cache -exec $(RM) '{}' \; && \
2128 CC="$(TARGET_CC) $(TARGET_CFLAGS) $(LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2129 AS="$(TARGET_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)" \
2130 $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) %(extraoptions) \
2131 --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH) \
2132 --host=$(AROS_TARGET_CPU)-aros \
2133 --target=$(AROS_TARGET_CPU)-aros \
2135 --without-x --without-pic --disable-shared && \
2138 ifeq (%(compiler),kernel)
2139 $(%(mmake)-configflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2141 %mkdirs_q $(%(mmake)-pkgdir)
2142 cd $(%(mmake)-pkgdir) && \
2143 find . -name config.cache -exec $(RM) '{}' \; && \
2144 CC="$(KERNEL_CC) $(KERNEL_CFLAGS) $(%(mmake)-s_flag)" \
2145 AS="$(TARGET_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)" \
2146 $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) %(extraoptions) \
2147 --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH) \
2148 --host=$(AROS_TARGET_CPU)-aros \
2149 --target=$(AROS_TARGET_CPU)-aros --disable-nls \
2150 --without-x --without-pic --disable-shared && \
2155 %(mmake)-clean : %(mmake)-uninstall
2156 @$(RM) $(%(mmake)-pkgdir)
2158 #------------------------------------------------------------------------------
2161 #------------------------------------------------------------------------------
2162 # Given an archive name, patches names and locations where to find them, fetch
2163 # the archive and the patches from any of those locations, unpack the archive
2164 # and then apply the patches.
2166 # Locations currently supported are http and ftp sites, plus local filesystem
2167 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
2168 # the fetch.sh script needs to be modified, since this macro relies on that script.
2172 # - mmake = mmaketarget
2173 # - archive_origins = list of locations where to find the archive. They are tried
2174 # in sequence, until the archive is found and fetching it
2175 # succeeded. If not specified, the current directory is assumed.
2176 # - archive = the archive name. Mandatory.
2177 # - suffixes = a list of suffixes to append to the the package name plus the
2178 # version. Each one of them is tried until a matching archive is
2179 # found. They are appended to patches and these are tried the
2180 # same way as packages are.
2181 # - location = the local directory where to put the fetched archive and patches.
2182 # If not specified, the directory specified by destination is used.
2183 # - destination = the directory to unpack the archive to.
2184 # If not specified, the current directory is assumed.
2185 # - patches_origins = list of locations where to find the patches. They are tried
2186 # in sequence, until a patch is found and fetching it
2187 # succeeded. If not specified, the current directory is assumed.
2188 # - patches_specs = list of "patch specs". A patch spec is of the form
2189 # patch_name[:[patch_subdir][:patch_opt]].
2191 # - patch_name = the name of the patch file
2192 # - patch_subdir = the directory within \destination\ where to
2194 # - patch_opt = any options to pass to the `patch' command
2195 # when applying the patch.
2197 # The patch_subdir and patch_opt fields are optional.
2199 %define fetch mmake=/A archive_origins=. archive=/A suffixes= location= destination=. \
2200 patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
2204 ifneq (%(location),)
2205 %(mmake)-location := %(location)
2207 %(mmake)-location := %(destination)
2212 $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
2213 -d %(destination) -po "%(patches_origins)" -p %(patches_specs)
2215 #------------------------------------------------------------------------------
2218 #------------------------------------------------------------------------------
2219 # This macro can aid in patch creation for fetched ports. It temporarily creates another
2220 # unpatched source tree and runs diff against this and a previously fetched and possibly
2221 # patched tree. Depending on what happens after patching during a normal build it might
2222 # give best results if the new patch is created directly after fetch.
2226 # - mmake = mmaketarget
2227 # - archive = archive base name
2228 # - suffixes = a list of suffixes to append to the the package name plus the
2229 # version. Each one of them is tried until a matching archive is
2231 # - destination = the directory to unpack the archive to.
2232 # - excludes = diff patterns to exclude files or directories from the patch
2234 %define create_patch mmake=/A archive=/A suffixes="tar.bz2 tar.gz" destination=/A excludes=
2238 ifneq (%(excludes),)
2239 %(mmake)-exclude := -X ./exclude.patterns
2244 @$(FETCH) -a %(archive) -s "%(suffixes)" -l $(PORTSSOURCEDIR) -d %(destination)/tmp ; \
2245 $(MV) %(destination)/%(archive) %(destination)/tmp/%(archive).aros ; \
2246 cd %(destination)/tmp ; \
2247 $(FOR) f in %(excludes) ; do \
2248 $(ECHO) $$f >> ./exclude.patterns ; \
2250 diff -ruN $(%(mmake)-exclude) \
2253 >$(SRCDIR)/$(CURDIR)/%(archive)-aros-new.diff ; \
2254 $(MV) %(destination)/tmp/%(archive).aros %(destination)/%(archive) ; \
2255 $(RM) %(destination)/tmp
2257 #------------------------------------------------------------------------------
2260 #------------------------------------------------------------------------------
2261 # Joins the features of %fetch and %build_with_configure, taking advantage of
2262 # the naming scheme of GNU packages. GNU packages names are in the form
2264 # <package name>-<version number>.<archive format suffix>
2266 # If a patch is provided, it *must* be named the following way:
2268 # <package name>-<version number>-aros.diff
2270 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
2271 # CD'ing into the archive's extracted directory.
2273 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
2274 # the %fetch_and_build macro only accept *one* patch for each package. It's up to you
2275 # to make that patch fully comprehensive.
2277 # NOTE: GNU packages are always compiled with *nix semantics turned on.
2281 # - mmake = the meta make target, as would be supplied to the %build_with_configure
2283 # - package = the GNU package name, sans version and archive format suffixes.
2284 # - version = the package's version number, or otherwise any other version string.
2285 # It gets appended to the package name to form the basename of the archive.
2286 # - suffixes = a list of suffixes to apped to the the package name plus the
2287 # version. Each one of them is tried until a matching archive is found.
2288 # Defaults to "tar.bz2 tar.gz".
2289 # - destination = same meaning as the one for the %fetch macro
2290 # - location = same meaning as the one for the %fetch macro
2291 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
2292 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
2294 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
2295 # - prefix = same meaning as the one for the %build_with_configure macro. Defaults to
2297 # - aros_prefix = same meaning as the one for the %build_with_configure macro. Defaults to
2299 # - extraoptions = same meaning as the one for the %build_with_configure macro.
2300 # - postinstall = same meaning as the one for the %build_with_configure macro.
2301 # - create_pkg = create a distributable package of the compiled sources, defaults to no
2303 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target version=/A suffixes="tar.bz2 tar.gz" \
2304 srcdir= package_repo= patch=no patch_repo= prefix= aros_prefix= extraoptions= \
2305 preconfigure= postconfigure= postinstall= nix=no nix_dir_layout= create_pkg=no
2307 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
2308 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
2309 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
2310 #MM- %(mmake)-create-patch : %(mmake)-%(subpackage)-create-patch
2312 %(mmake)-archbase := %(package)-%(version)
2314 ifeq (%(compiler),host)
2315 %(mmake)-portdir := $(HOSTDIR)/Ports/%(package)
2317 %(mmake)-portdir := $(PORTSDIR)/%(package)
2321 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
2323 %(mmake)-prefix := %(prefix)
2326 ifneq (%(subpackage),)
2327 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
2329 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
2333 %(mmake)-%(subpackage)-srcdir := %(srcdir)
2335 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
2339 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-p1
2341 %(mmake)-%(subpackage)-patches_specs := ::
2344 %fetch mmake=%(mmake)-%(subpackage)-fetch archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
2345 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
2346 archive_origins=". %(package_repo)" \
2347 patches_specs="$(%(mmake)-%(subpackage)-patches_specs)" patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
2349 %create_patch mmake=%(mmake)-%(subpackage)-create-patch \
2350 archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" destination=$(%(mmake)-portdir)
2352 #MM- %(mmake) : %(mmake)-%(subpackage)
2354 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
2356 %(mmake)-%(subpackage)-package-basename := \
2357 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
2359 ifneq (%(create_pkg),no)
2360 %(mmake)-%(subpackage)-package := $(%(mmake)-%(subpackage)-package-basename).tar.bz2
2363 %build_with_configure mmake=%(mmake)-%(subpackage) package=%(package) compiler=%(compiler) \
2364 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-srcdir) \
2365 nix=%(nix) nix_dir_layout=%(nix_dir_layout) prefix="$(%(mmake)-prefix)" \
2366 aros_prefix="%(aros_prefix)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
2367 %(mmake)-%(subpackage)-make-package" extraoptions="%(extraoptions)"
2369 .PHONY : %(mmake)-%(subpackage)-make-package %(mmake)-%(subpackage)-create-patch
2370 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
2373 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package)
2375 #There seems to be a bug, either with my clock or with make, 'cause it may happen
2376 #that $^ and $@ have exactly the same mtime, and in that case make tries
2377 #to rebuild $@ again, which would fail because the directory where
2378 #the package got installed would not exist anymore.
2379 #We work this around by using an if statement to manually check the mtimes.
2380 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
2381 @$(IF) test $(%(mmake)-installflag) -nt $@ || ! test -f $@; then \
2383 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
2384 mkdir -p "$(DISTDIR)/Packages" ; \
2385 mkdir -p "$(%(mmake)-prefix)" ; \
2386 cd $(%(mmake)-%(subpackage)-package-dir) ; \
2387 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
2388 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
2391 #------------------------------------------------------------------------------
2394 #------------------------------------------------------------------------------
2395 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2396 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
2397 aros_prefix=/GNU extraoptions= preconfigure= postconfigure= postinstall=
2399 GNU_REPOSITORY := gnu://
2401 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
2402 suffixes="%(suffixes)" srcdir="%(srcdir)" \
2403 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
2404 patch="%(patch)" patch_repo="%(patch_repo)" \
2405 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" \
2406 preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=yes
2409 #------------------------------------------------------------------------------
2412 #------------------------------------------------------------------------------
2413 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
2414 # that the package is a "Development" package, and as such it needs to be placed
2415 # under the $(AROS_DEVELOPMENT) directory, as a default.
2417 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
2418 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
2419 # "mmake" argument, because the metatarget is implicitely defined as
2421 # #MM- development-%(package)
2423 %define fetch_and_build_gnu_development package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2424 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPMENT) \
2425 aros_prefix=/Development preconfigure= postconfigure= postinstall= extraoptions=
2427 #MM- development : development-%(package)
2430 %fetch_and_build_gnu mmake=development-%(package) package=%(package) subpackage="%(subpackage)" \
2431 version=%(version) suffixes="%(suffixes)" srcdir="%(srcdir)" \
2432 package_repo="%(package_repo)" patch="%(patch)" patch_repo="%(patch_repo)" prefix=%(prefix) \
2433 aros_prefix="%(aros_prefix)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" \
2434 extraoptions="%(extraoptions)"
2437 #------------------------------------------------------------------------------