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).
15 %define compile_q cmd=$(TARGET_CC) opt=$(CFLAGS) from=$< to=$@
16 @$(ECHO) "Compiling %(from)"
17 @$(IF) %(cmd) $(CFLAGS_IQUOTE) $(SRCDIR)/$(CURDIR) $(CFLAGS_IQUOTE) . $(CFLAGS_IQUOTE_END) %(opt) -c %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
18 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
19 $(ECHO) "%(from): %(cmd) $(CFLAGS_IQUOTE) $(SRCDIR)/$(CURDIR) $(CFLAGS_IQUOTE) . $(CFLAGS_IQUOTE_END) %(opt) -c %(from) -o %(to)" >> $(GENDIR)/errors ; \
20 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors ; \
25 $(ECHO) "Compile failed: %(cmd) $(CFLAGS_IQUOTE) $(SRCDIR)/$(CURDIR) $(CFLAGS_IQUOTE) . $(CFLAGS_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)
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 ; \
72 #-------------------------------------------------------------------------
73 # Link a module based upon a number of arguments and the standard $(LIBS)
74 # and $(DEPLIBS) make variables.
76 %define link_module_q err="$(notdir $@).err" objs=/A endtag= module=$(MODULE) ldflags=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
77 @$(ECHO) "Building $(notdir $@) ..."
78 @if $(AROS_CC) $(NOSTARTUP_LDFLAGS) %(ldflags) \
79 $(GENMAP) %(objdir)/%(module).map \
80 %(objs) %(libs) %(endtag) \
81 -o $@ 2>&1 > %(objdir)/%(err); \
83 cat %(objdir)/%(err); \
85 cat %(objdir)/%(err); \
89 @if $(TEST) ! -s %(objdir)/%(err) ; then $(RM) %(objdir)/%(err) ; fi
92 #------------------------------------------------------------------------------
94 #------------------------------------------------------------------------------
96 %define mklib_q ar=$(AR) ranlib=$(RANLIB) to=$@ from=$(OBJS)
97 @$(ECHO) "Creating library %(to)..."
102 #------------------------------------------------------------------------------
103 # Create the dependency file %(to) for %(from)
104 %define mkdepend_q flags=$(CFLAGS) from=$< to=$@ cc=$(AROS_CC)
105 %mkdir_q dir="$(dir %(to))"
106 @$(ECHO) "Makedepend $(CURDIR)/$(notdir %(from))..."
107 @AROS_CC="%(cc)" $(MKDEPEND) %(flags) -I$(SRCDIR)/$(CURDIR) %(from) -o %(to)
109 #------------------------------------------------------------------------------
111 #------------------------------------------------------------------------------
112 # Create the function reference file %(to) to %(from)
113 %define mkref_q cc=$(AROS_CC) cppflags="-E -C -dD -D__CXREF__" cflags=$(CFLAGS) from=$< to=$@
114 @$(ECHO) "Generating ref for $(notdir %(from))..."
115 @$(CXREF) -raw -CPP '%(cc) %(cppflags) %(cflags)' %(from) >%(to) 2>$(GENDIR)/cerrors
116 @$(IF) $(TEST) -s %(to) ; \
118 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
119 $(ECHO) "%(from): $(CXREF) -raw -CPP '%(cc) %(cppflags) %(cflags)' %(from) >%(to)" >> $(GENDIR)/errors ; \
120 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors ; \
123 $(ECHO) "Reference generation failed: $(CXREF) -raw -CPP '%(cc) %(cppflags) %(cflags)' %(from) >%(to)" 1>&2 ; \
124 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
130 #------------------------------------------------------------------------------
131 # Create one directory without any output
132 %define mkdir_q dir=.
133 @$(IF) $(TEST) ! -d %(dir) ; then $(MKDIR) %(dir) ; else $(NOP) ; fi
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 ; \
144 #############################################################################
145 #############################################################################
147 ## Here are the mmakefile macro's that are used to do certain tasks in a ##
148 ## mmakefile. They consist of one or more full makefile rules. ##
149 ## In general the files generated in these macro's are also defined as ##
150 ## make targets so that they can be used as a dependency in other rules ##
152 #############################################################################
153 #############################################################################
155 #------------------------------------------------------------------------------
156 # Generate a unique id for each of the %build... rules
157 %define buildid targets=/A
159 ifneq ($(filter $(TARGET),%(targets)),)
160 BDTARGETID := $(BDID)
163 #------------------------------------------------------------------------------
166 #------------------------------------------------------------------------------
167 # Copy file %(from) to %(to) in a makefile rule
168 %define rule_copy from=/A to=/A
172 #------------------------------------------------------------------------------
175 #------------------------------------------------------------------------------
176 # Copy the files %(files) to %(targetdir). For each file in %(files),
177 # %(srcdir)/file is copied to %(targetdir)/file. The targetdir and the
178 # appropriate subdirs are not generated by this rule so they have to be
180 %define rule_copy_multi files=/A targetdir=/A srcdir=.
182 $(addprefix %(targetdir)/,%(files)) : %(targetdir)/% : %(srcdir)/%
185 #------------------------------------------------------------------------------
187 #------------------------------------------------------------------------------
188 # Copy the files %(files) to %(targetdir). For each file in %(files),
189 # %(srcdir)/file is copied to %(targetdir)/file if these files are different.
190 # %(stampfile) is used to keep track of when the last time the comparison has
191 # been done. The targetdir and the appropriate subdirs are not generated by
192 # this rule so they have to be present.
193 %define rule_copy_diff_multi files=/A targetdir=/A srcdir=. \
194 stampfile=$(TMP_SRCDIR)/.copy_stamp
196 TMP_SRCDIR := %(srcdir)
198 $(addprefix %(targetdir)/,%(files)) : | %(stampfile)
200 %(stampfile) : COPYSRCDIR := %(srcdir)
201 %(stampfile) : TGTDIR := %(targetdir)
202 %(stampfile) : FILES := %(files)
203 %(stampfile) : $(addprefix %(srcdir)/,%(files))
204 @for f in $(FILES); do \
205 $(IF) ! $(CMP) -s $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; then \
206 $(CP) $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; \
211 #------------------------------------------------------------------------------
213 #------------------------------------------------------------------------------
214 # Will join all the files in %(from) to %(to). When text is specified it will
216 # Restriction: at the moment when using a non-empty target dir %(from) may
218 %define rule_join to=/A from=/A text=
226 #------------------------------------------------------------------------------
229 #------------------------------------------------------------------------------
230 # Include the dependency files and add some internal rules
231 # When depstargets is provided the depencies will only be included when one of
232 # these targets is the $(TARGET). Otherwise the dependencies will only be
233 # include when the $(TARGET) is not for setup or clean
234 %define include_deps deps=$(DEPS)/M depstargets=
236 ifneq (%(depstargets),)
237 ifneq ($(findstring $(TARGET),%(depstargets)),)
241 ifeq (,$(filter clean% %clean %clean% setup% includes% %setup,$(TARGET)))
247 #------------------------------------------------------------------------------
250 #------------------------------------------------------------------------------
251 # Create the directories %(dirs). The creation will be done by adding rules to
252 # the %(setuptarget) make target with setup as the default.
253 %define rule_makedirs dirs=/A setuptarget=setup
255 %(setuptarget) :: %(dirs)
257 GLOB_MKDIRS += %(dirs)
260 #------------------------------------------------------------------------------
263 #------------------------------------------------------------------------------
264 # Generate a rule to compile a C source file to an object file and generate
265 # the dependency file. Basename may contain a directory part, then the source
266 # file has to be in that directory. The generated file will be put in the
267 # object directory without the directory.
269 # - basename: the basename of the file to compile. Use % for a wildcard rule
270 # - cflags (default $(CFLAGS)): the C flags to use for compilation
271 # - dflags: the flags used during creation of dependency file. If not specified
272 # the same value as cflags will be used
273 # - targetdir: the directory to put the .o file and the .d file. By default
274 # it is put in the same directory as the .c file
275 %define rule_compile basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target nix=no
278 TMP_TARGETBASE := %(basename)
280 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
283 ifeq ($(findstring %(compiler),host kernel target),)
284 $(error unknown compiler %(compiler))
286 ifeq (%(compiler),target)
287 $(TMP_TARGETBASE).o : TMP_CMD:=$(TARGET_CC)
288 $(TMP_TARGETBASE).d : TMP_CMD:=$(TARGET_CC)
290 ifeq (%(compiler),host)
291 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
292 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
294 ifeq (%(compiler),kernel)
295 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
296 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
300 $(TMP_TARGETBASE).o : CFLAGS := -nix %(cflags)
302 $(TMP_TARGETBASE).o : CFLAGS := %(cflags)
304 $(TMP_TARGETBASE).o : %(basename).c
305 %compile_q cmd=$(TMP_CMD)
309 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(cflags)
311 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(cflags)
315 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(dflags)
317 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(dflags)
320 $(TMP_TARGETBASE).d : %(basename).c
321 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
323 #------------------------------------------------------------------------------
326 #------------------------------------------------------------------------------
327 # Generate a rule to compile multiple C source files to an object file and
328 # generate the corresponding dependency files. The generated file will be put
329 # in the object directory without the directory part of the source file.
331 # - basenames: the basenames of the files to compile. The names may include
332 # relative or absolute path names. No wildcard is allowed
333 # - cflags (default $(CFLAGS)): the C flags to use for compilation
334 # - dflags: the flags used during creation of dependency file. If not specified
335 # the same value as cflags will be used
336 # - targetdir: the directory to put the .o file and the .d file. By default
337 # it is put in the same directory as the .c file. When targetdir is not
338 # empty, path names will be stripped from the file names so that all files
339 # are in that dir and not in subdirectories.
340 # - compiler (default target): compiler to use, target, kernel or host
341 %define rule_compile_multi basenames=/A cflags=$(CFLAGS) dflags= targetdir= \
345 TMP_TARGETS := $(addsuffix .o,%(basenames))
346 TMP_DTARGETS := $(addsuffix .d,%(basenames))
349 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
350 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
351 TMP_WILDCARD := %(targetdir)/%
353 # Be sure that all .c files are generated
354 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .c,%(basenames))
356 # Be sure that all .c files are found
357 TMP_DIRS := $(filter-out ./,$(sort $(dir %(basenames)) $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir %(basenames)))))
359 vpath %.c $(TMP_DIRS)
364 ifeq ($(findstring %(compiler),host kernel target),)
365 $(error unknown compiler %(compiler))
367 ifeq (%(compiler),target)
368 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TARGET_CC)
370 ifeq (%(compiler),host)
371 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_CC)
373 ifeq (%(compiler),kernel)
374 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
377 $(TMP_TARGETS) : CFLAGS := %(cflags)
378 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.c
379 %compile_q cmd=$(CMD)
382 $(TMP_DTARGETS) : DFLAGS:=%(cflags)
384 $(TMP_DTARGETS) : DFLAGS:=%(dflags)
386 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.c
387 %mkdepend_q cc=$(CMD) flags=$(DFLAGS)
389 #------------------------------------------------------------------------------
392 #------------------------------------------------------------------------------
393 # Make an alias from one arch specific build to another arch.
395 # - mainmmake: the mmake of the module in the main tree
396 # - arch: the current arch
397 # - alias: the alias to which this should point
398 %define rule_archalias mainmmake=\A arch=\A alias=\A
400 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
402 #------------------------------------------------------------------------------
405 #------------------------------------------------------------------------------
406 # Generate a rule to compile a C source file to a shared object file with a
407 # .so suffix. Basename may contain a directory part, then the source
408 # file has to be in that directory. The generated file will be put in the
409 # object directory without the directory.
411 # - basename: the basename of the file to compile. Use % for a wildcard rule
412 # - cflags (default $(CFLAGS)): the C flags to use for compilation
413 # - targetdir: the directory to put the .o file and the .d file. By default
414 # it is put in the same directory as the .c file
415 %define rule_compile_shared basename=/A cflags=$(CFLAGS) targetdir= compiler=target
418 TMP_TARGETBASE := %(basename)
420 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
423 ifeq ($(findstring %(compiler),host kernel target),)
424 $(error unknown compiler %(compiler))
426 ifeq (%(compiler),target)
427 $(TMP_TARGETBASE).so : TMP_CMD:=$(TARGET_CC)
429 ifeq (%(compiler),host)
430 $(TMP_TARGETBASE).so : TMP_CMD:=$(HOST_CC)
432 ifeq (%(compiler),kernel)
433 $(TMP_TARGETBASE).so : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
436 $(TMP_TARGETBASE).so : %(basename).c
437 %compile_q opt="$(SHARED_CFLAGS) %(cflags)" cmd=$(TMP_CMD)
439 #------------------------------------------------------------------------------
442 #------------------------------------------------------------------------------
443 # Generate a rule to assemble a source file to an object file. Basename may
444 # contain a directory part, then the source file has to be in that directory.
445 # The generated file will be put in the object directory without the directory.
447 # - basename: the basename of the file to compile. Use % for a wildcard rule
448 # - flags (default $(AFLAGS)): the asm flags to use for assembling
449 # - targetdir: the directory to put the .o file in. By default it is put in the
450 # same directory as the .s file
451 %define rule_assemble basename=/A aflags=$(AFLAGS) targetdir=
454 %(basename).o : AFLAGS := %(aflags)
455 %(basename).o : %(basename).s
459 %(targetdir)/$(notdir %(basename)).o : AFLAGS := %(aflags)
460 %(targetdir)/$(notdir %(basename)).o : %(basename).s
465 #------------------------------------------------------------------------------
468 #------------------------------------------------------------------------------
469 # Generate a rule to assemble multiple source files to an object file. The
470 # generated file will be put in the object directory with the directory part
471 # of the source file stripped off.
473 # - basenames: the basenames of the files to compile. The names may include
474 # relative or absolute path names. No wildcard is allowed
475 # - aflags (default $(AFLAGS)): the flags to use for assembly
476 # - targetdir: the directory to put the .o file and the .d file. By default
477 # it is put in the same directory as the .c file. When targetdir is not
478 # empty, path names will be stripped from the file names so that all files
479 # are in that dir and not in subdirectories.
480 %define rule_assemble_multi basenames=/A aflags=$(AFLAGS) targetdir= suffix=.s
483 TMP_TARGETS := $(addsuffix .o,%(basenames))
486 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
487 TMP_WILDCARD := %(targetdir)/%
489 # Be sure that all .s files are generated
490 $(TMP_TARGETS) : | $(addsuffix %(suffix),%(basenames))
492 # Be sure that all .c files are found
493 TMP_DIRS := $(filter-out ./,$(sort $(dir %(basenames)) $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir %(basenames)))))
495 vpath %%(suffix) $(TMP_DIRS)
500 $(TMP_TARGETS) : AFLAGS := %(aflags)
501 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %%(suffix)
502 %assemble_q opt=$(AFLAGS)
504 #------------------------------------------------------------------------------
507 #------------------------------------------------------------------------------
508 # Link %(objs) to %(prog) using the libraries in %(uselibs)
509 %define rule_link_prog prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
510 usehostlibs= usestartup=yes detach=no nix=no
514 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
516 ifeq (%(usestartup),no)
517 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
520 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
523 # Make a list of the lib files this program depends on.
525 # In LDFLAGS remove white space between -L and directory
526 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
527 # Filter out only the libdirs and remove -L
528 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
530 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
531 # Add normal linklib path
532 TMP_DIRS += $(LIBDIR)/
533 # add lib and .a to static linklib names
534 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) libinit autoinit))
535 # search for the linklibs in the given path, ignore ones not found
536 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
537 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
543 %(prog) : OBJS := %(objs)
544 %(prog) : LDFLAGS := %(ldflags) $(TMP_EXTRA_LDFLAGS)
545 %(prog) : LIBS := $(addprefix -l,%(uselibs)) $(addprefix -l,%(usehostlibs))
546 %(prog) : %(objs) $(TMP_DEPLIBS)
547 %link_q from=$(OBJS) opt=$(LDFLAGS) libs=$(LIBS)
549 #------------------------------------------------------------------------------
552 #------------------------------------------------------------------------------
553 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
554 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
555 %define rule_link_progs progs=/A targetdir=$(AROSDIR)/$(CURDIR) nix=%(nix) \
556 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
557 usestartup=yes detach=no
561 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
563 ifeq (%(usestartup),no)
564 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
567 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
570 # Make a list of the lib files the programs depend on.
572 # In LDFLAGS remove white space between -L and directory
573 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
574 # Filter out only the libdirs and remove -L
575 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
577 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
578 # Add normal linklib path
579 TMP_DIRS += $(LIBDIR)/lib/
580 # add lib and .a to static linklib names
581 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) libinit autoinit))
582 # search for the linklibs in the given path, ignore ones not found
583 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
584 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
590 $(addprefix %(targetdir)/,%(progs)) : LDFLAGS:= %(ldflags) $(TMP_EXTRA_LDFLAGS)
591 $(addprefix %(targetdir)/,%(progs)) : LIBS:= $(addprefix -l,%(uselibs)) $(addprefix -l,%(usehostlibs))
592 $(addprefix %(targetdir)/,%(progs)) : %(targetdir)/% : %(objdir)/%.o $(TMP_DEPLIBS)
593 %link_q from=$< opt=$(LDFLAGS) libs=$(LIBS)
595 #------------------------------------------------------------------------------
598 #------------------------------------------------------------------------------
599 # Link the %(objs) to the library %(libdir)/lib%(libname).a in
600 %define rule_link_linklib libname=/A objs=/A libdir=$(LIBDIR)
602 %(libdir)/lib%(libname).a : %(objs)
605 #------------------------------------------------------------------------------
608 #------------------------------------------------------------------------------
609 # Link the %(objs) to the library %(libdir)/lib%(libname).so in
610 %define rule_link_shlib libname=/A objs=/A libdir=$(LIBDIR)
612 %(libdir)/lib%(libname).so : %(objs)
613 @$(SHARED_LD) $(SHARED_LDFLAGS) -o $@ $^
615 #------------------------------------------------------------------------------
618 #------------------------------------------------------------------------------
619 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
620 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
621 %define rule_linkmodule module=/A objs=/A endobj=/A err=/A objdir=$(OBJDIR) \
622 uselibs= usehostlibs=
624 %(module) : OBJS := %(objs)
625 %(module) : ENDTAG := %(endobj)
626 %(module) : ERR := %(err)
627 %(module) : OBJDIR := %(objdir)
628 %(module) : LIBS := $(addprefix -l,%(uselibs)) -lautoinit -llibinit -L/usr/lib $(addprefix -l,%(usehostlibs))
629 %(module) : %(objs) %(endobj) $(addprefix $(LIBDIR)/lib,$(addsuffix .a,%(uselibs) libinit autoinit))
630 %link_module_q err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS) objdir=$(OBJDIR)
633 #------------------------------------------------------------------------------
636 #------------------------------------------------------------------------------
637 # Generate a rule to generate a function reference file from a C source file.
638 # Basename may contain a directory part, then the source file has to be in that
639 # directory. The generated file will be put in the object directory without the
642 # - basename: the basename of the file to compile. Use % for a wildcard rule
643 # - cflags (default $(CFLAGS)): the C flags to use for compilation
644 # - targetdir: the directory to put the generated .ref file. By default the
645 # .ref file will be put in the same directory as the .c file.
646 # - includefile: This file will be included at the head of the source file
647 %define rule_ref basename=/A cflags=$(CFLAGS) targetdir= includefile= compiler=target
650 GENFILE_TMP := %(basename).ref
652 GENFILE_TMP := %(targetdir)/$(notdir %(basename)).ref
655 ifeq ($(filter %(compiler),target kernel host),)
656 $(error use of %rule_ref: compiler has to be 'host', 'kernel' or 'target')
659 ifeq (%(compiler),target)
660 $(GENFILE_TMP) : CC:=$(TARGET_CC)
662 ifeq (%(compiler),host)
663 $(GENFILE_TMP) : CC:=$(HOST_CC)
665 ifeq(%(compiler),kernel)
666 $(GENFILE_TMP) : CC:=$(KERNEL_CC) $(KERNEL_CFLAGS)
669 $(GENFILE_TMP) : %(basename).c $(CXREF) %(includefile)
670 ifeq (%(includefile),)
671 %mkref_q cc=$(CC) cflags="%(cflags)"
673 %mkref_q cc=$(CC) cflags="%(cflags) -include %(includefile)"
677 #------------------------------------------------------------------------------
680 #------------------------------------------------------------------------------
681 # Generate a rule to generate a function reference file from a C source file.
682 # Basename may contain a directory part, then the source file has to be in that
683 # directory. The generated file will be put in the object directory without the
686 # - basenames: the basenames of the files to compile. No wildcard is allowed
687 # - cflags (default $(CFLAGS)): the C flags to use for compilation
688 # - targetdir: the directory to put the generated .ref file. By default the
689 # .ref file will be put in the same directory as the .c file. When targetdir
690 # is not empty all files will be put there and path parts in the basenames
691 # will be stripped off.
692 # - includefile: This file will be included at the head of the source file
693 %define rule_ref_multi basenames=/A cflags=$(CFLAGS) targetdir= includefile= \
697 TMP_TARGETS := $(addsuffix .ref,%(basenames))
698 TMP_WILDCARD := %.ref
700 TMP_TARGETS := $(addprefix %(targetdir)/,$(addsuffix .ref,$(notdir %(basenames))))
701 TMP_WILDCARD := %(targetdir)/%.ref
703 # Be sure that all .c files are generated
704 $(TMP_TARGETS) : | $(addsuffix .c,%(basenames))
706 # Be sure that all .c files are found
707 TMP_DIRS := $(filter-out ./,$(sort $(dir %(basenames)) $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir %(basenames)))))
709 vpath %.c $(TMP_DIRS)
714 ifeq ($(filter %(compiler),target kernel host),)
715 $(error use of %rule_ref: compiler has to be 'host', 'kernel' or 'target')
718 ifeq (%(compiler),target)
719 $(TMP_TARGETS) : CC:=$(TARGET_CC)
721 ifeq (%(compiler),host)
722 $(TMP_TARGETS) : CC:=$(HOST_CC)
724 ifeq (%(compiler),kernel)
725 $(TMP_TARGETS) : CC:=$(KERNEL_CC) $(KERNEL_CFLAGS)
727 ifeq (%(includefile),)
728 $(TMP_TARGETS) : CFLAGS:=%(cflags)
730 $(TMP_TARGETS) : CFLAGS:="%(cflags) -include %(includefile)"
731 $(TMP_TARGETS) : %(includefile)
733 $(TMP_TARGETS) : $(CXREF)
734 $(TMP_TARGETS) : $(TMP_WILDCARD) : %.c
737 #------------------------------------------------------------------------------
740 #------------------------------------------------------------------------------
741 # Generate the libdefs.h include file for a module.
742 %define rule_genmodule_genlibdefs modname=/A modtype=/A modsuffix= conffile= targetdir=
744 TMP_TARGET := %(modname)_libdefs.h
745 TMP_DEPS := $(GENMODULE)
748 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
749 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
751 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
752 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
754 ifneq (%(modsuffix),)
755 TMP_OPTS += -s %(modsuffix)
757 ifneq (%(targetdir),)
758 TMP_OPTS += -d %(targetdir)
759 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
762 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
763 $(TMP_TARGET) : MODNAME := %(modname)
764 $(TMP_TARGET) : MODTYPE := %(modtype)
765 $(TMP_TARGET) : $(TMP_DEPS)
766 @$(ECHO) "Generating $(notdir $@)"
767 @$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
769 #------------------------------------------------------------------------------
772 #------------------------------------------------------------------------------
773 # Generate the libdefs.h include file for a module.
774 %define rule_genmodule_funclist \
775 modname=/A modtype=/A modsuffix= conffile= targetdir= reffile=
777 TMP_TARGET := %(modname).funclist
778 TMP_DEPS := $(GENMODULE)
781 $(error reffile needed in rule_genmodule_funclist but none specified)
783 TMP_OPTS := -r %(reffile)
784 TMP_DEPS += %(reffile)
786 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
787 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
789 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
790 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
792 ifneq (%(modsuffix),)
793 TMP_OPTS += -s %(modsuffix)
795 ifneq (%(targetdir),)
796 TMP_OPTS += -d %(targetdir)
797 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
800 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
801 $(TMP_TARGET) : MODNAME := %(modname)
802 $(TMP_TARGET) : MODTYPE := %(modtype)
803 $(TMP_TARGET) : $(TMP_DEPS)
804 @$(ECHO) "Generating $(notdir $@)"
805 @$(GENMODULE) $(OPTS) writefunclist $(MODNAME) $(MODTYPE)
807 #------------------------------------------------------------------------------
810 #------------------------------------------------------------------------------
811 # Generate a Makefile.%(modname) with the genmodule program and include this
812 # generated file in this Makefile
813 %define rule_genmodule_makefile modname=/A modtype=/A modsuffix= conffile= \
816 TMP_TARGET := Makefile.%(modname)
817 TMP_DEPS := $(GENMODULE)
820 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
821 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
823 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
824 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
826 ifneq (%(modsuffix),)
827 TMP_OPTS += -s %(modsuffix)
829 ifneq (%(targetdir),)
830 TMP_OPTS += -d %(targetdir)
831 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
834 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
835 $(TMP_TARGET) : MODNAME := %(modname)
836 $(TMP_TARGET) : MODTYPE := %(modtype)
837 $(TMP_TARGET) : $(TMP_DEPS)
838 @$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
840 #------------------------------------------------------------------------------
842 #------------------------------------------------------------------------------
843 # Generate dummy support files so cxref when used on the a module source file
844 # will find something to include. This rule has to be preceeded by
845 # %rule_genmodule_makefile
846 %define rule_genmodule_dummy modname=/A modtype=/A modsuffix= conffile= targetdir=
848 ifneq ($(%(modname)_INCLUDES),)
849 TMP_TARGETS := $(%(modname)_INCLUDES)
851 TMP_DEPS := $(GENMODULE)
854 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
855 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
857 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
858 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
860 ifneq (%(modsuffix),)
861 TMP_OPTS += -s %(modsuffix)
863 ifneq (%(targetdir),)
864 TMP_OPTS += -d %(targetdir)
865 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
868 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
869 $(TMP_TARGETS) : MODNAME := %(modname)
870 $(TMP_TARGETS) : MODTYPE := %(modtype)
871 $(TMP_TARGETS) : $(TMP_DEPS)
872 @$(ECHO) "Generating dummy include files"
873 @$(GENMODULE) $(OPTS) writedummy $(MODNAME) $(MODTYPE)
876 #------------------------------------------------------------------------------
879 #------------------------------------------------------------------------------
880 # Generate the support files for compiling a module. This includes include
881 # files and source files. This rule has to be preceeded by
882 # %rule_genmodule_makefile
883 %define rule_genmodule_files modname=/A modtype=/A modsuffix= targetdir= \
886 TMP_TARGETS := $(%(modname)_STARTFILES) $(%(modname)_ENDFILES) \
887 $(%(modname)_LINKLIBFILES)
888 TMP_TARGETS := $(addsuffix .c,$(TMP_TARGETS)) $(addsuffix .S, $(%(modname)_LINKLIBAFILES))
890 TMP_DEPS := $(GENMODULE)
891 ifeq ($(%(modname)_NEEDREF), yes)
893 $(error reffile needed in rule_genmodule_files but none specified)
895 TMP_OPTS := -r %(reffile)
896 TMP_DEPS += %(reffile)
901 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
902 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
904 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
905 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
907 ifneq (%(modsuffix),)
908 TMP_OPTS += -s %(modsuffix)
910 ifneq (%(targetdir),)
911 TMP_OPTS += -d %(targetdir)
912 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
915 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
916 $(TMP_TARGETS) : MODNAME := %(modname)
917 $(TMP_TARGETS) : MODTYPE := %(modtype)
918 $(TMP_TARGETS) : $(TMP_DEPS)
919 @$(ECHO) "Generating functable and support files for module $(MODNAME$(BDID))"
920 ifneq (%(conffile),lib.conf)
921 @$(IF) $(TEST) -f lib.conf; then \
922 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
925 @$(IF) $(TEST) -f libdefs.h; then \
926 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
928 @$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
930 #------------------------------------------------------------------------------
932 #------------------------------------------------------------------------------
933 # Generate the support files for compiling a module. This includes include
934 # files and source files.
935 %define rule_genmodule_includes modname=/A modtype=/A modsuffix= \
936 targetdir= conffile= reffile=
939 ifneq ($(%(modname)_INCLUDES),)
940 TMP_TARGETS := $(%(modname)_INCLUDES)
942 TMP_DEPS := $(GENMODULE)
943 ifeq ($(%(modname)_NEEDREF), yes)
945 $(error reffile needed in rule_genmodule_files but none specified)
947 TMP_OPTS := -r %(reffile)
948 TMP_DEPS += %(reffile)
953 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
954 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
956 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
957 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
959 ifneq (%(modsuffix),)
960 TMP_OPTS += -s %(modsuffix)
962 ifneq (%(targetdir),)
963 TMP_OPTS += -d %(targetdir)
964 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
967 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
968 $(TMP_TARGETS) : MODNAME := %(modname)
969 $(TMP_TARGETS) : MODTYPE := %(modtype)
970 $(TMP_TARGETS) : $(TMP_DEPS)
971 @$(ECHO) "Generating include files"
972 @$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
975 #------------------------------------------------------------------------------
977 #------------------------------------------------------------------------------
978 # Common rules for all makefiles
980 # Delete generated makefiles
983 @$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
985 include $(SRCDIR)/config/make.tail
987 BDID := $(BDTARGETID)
989 #------------------------------------------------------------------------------
992 #############################################################################
993 #############################################################################
995 ## Here are the mmakefile build macro's. These are macro's that takes care ##
996 ## of everything to go from the sources to the generated target. Also all ##
997 ## intermediate files and directories that are needed are created by these ##
1000 #############################################################################
1001 #############################################################################
1003 #------------------------------------------------------------------------------
1005 %define build_prog mmake=/A progname=/A files=$(BD_PROGNAME) asmfiles= \
1006 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1007 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
1008 aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
1013 BD_PROGNAME := %(progname)
1014 BD_OBJDIR := %(objdir)
1015 BD_TARGETDIR := %(targetdir)
1017 BD_FILES := %(files)
1018 BD_ASMFILES := %(asmfiles)
1019 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_FILES) $(BD_ASMFILES)))
1020 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1022 BD_CFLAGS := %(cflags)
1023 BD_AFLAGS := %(aflags)
1024 BD_DFLAGS := %(dflags)
1025 BD_LDFLAGS := %(ldflags)
1028 %(mmake)-quick : %(mmake)
1030 #MM %(mmake) : includes-generate-deps
1031 %(mmake) : $(BD_TARGETDIR)/$(BD_PROGNAME)
1033 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1034 %rule_compile basename=%(srcdir)% targetdir=$(BD_OBJDIR) \
1035 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1036 %rule_assemble_multi basenames=$(BD_ASMFILES) targetdir=$(BD_OBJDIR) \
1039 %rule_link_prog prog=$(BD_TARGETDIR)/$(BD_PROGNAME) \
1040 objs=$(BD_OBJS) ldflags=$(BD_LDFLAGS) \
1041 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1042 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)"
1046 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1048 $(BD_OBJS) $(BD_DEPS) : | $(BD_OBJDIR)
1049 $(BD_TARGETDIR)/$(BD_PROGNAME) : | $(BD_TARGETDIR)
1050 GLOB_MKDIRS += $(BD_OBJDIR) $(BD_TARGETDIR)
1052 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_TARGETDIR)/$(BD_PROGNAME) $(BD_DEPS)
1055 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1059 #------------------------------------------------------------------------------
1062 #------------------------------------------------------------------------------
1063 # Build programs, for every C file an executable will be built with the same
1065 %define build_progs mmake=/A files=/A nix=no \
1066 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1067 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
1068 uselibs= usehostlibs= usestartup=yes detach=no
1072 BD_OBJDIR := %(objdir)
1073 BD_TARGETDIR := %(targetdir)
1075 BD_FILES := %(files)
1076 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1077 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1078 BD_EXES := $(addprefix $(BD_TARGETDIR)/,$(BD_FILES))
1080 BD_CFLAGS := %(cflags)
1081 BD_DFLAGS := %(dflags)
1082 BD_LDFLAGS := %(ldflags)
1085 %(mmake)-quick : %(mmake)
1087 #MM %(mmake) : includes-generate-deps
1088 %(mmake) : $(BD_EXES)
1090 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1091 %rule_compile basename=% targetdir=$(BD_OBJDIR) nix=%(nix) \
1092 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1094 %rule_link_progs progs=$(BD_FILES) nix=%(nix) \
1095 targetdir=$(BD_TARGETDIR) objdir=$(BD_OBJDIR) \
1096 ldflags=$(BD_LDFLAGS) \
1097 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1098 usestartup="%(usestartup)" detach="%(detach)"
1102 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1104 $(addprefix $(BD_TARGETDIR)/,$(BD_FILES)) : | $(BD_TARGETDIR)
1105 $(BD_DEPS) $(BD_OBJS) : | $(BD_OBJDIR)
1106 GLOB_MKDIRS += $(BD_TARGETDIR) $(BD_OBJDIR)
1108 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_EXES) $(BD_DEPS)
1111 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1115 #------------------------------------------------------------------------------
1118 #------------------------------------------------------------------------------
1120 # This is a bare version: It just compiles and links the given files. It is
1121 # assumed that all needed boiler plate code is in the files. This should only
1122 # be used for compiling external code. For AROS code use %build_module
1123 %define build_module_simple mmake=/A modname=/A modtype=/A \
1124 files="$(basename $(call WILDCARD, *.c))" \
1125 cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1126 objdir=$(OBJDIR) moduledir= \
1127 uselibs= usehostlibs= compiler=target
1129 # Define metamake targets and their dependencies
1130 #MM %(mmake) : core-linklibs includes-generate-deps
1131 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1135 BD_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj
1137 .PHONY : $(BD_ALLTARGETS)
1140 $(error using %build_module_simple: modname may not be empty)
1143 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1146 # Default values for variables and arguments
1147 BD_DEFLINKLIBNAME := %(modname)
1148 BD_DEFREFFILE := %(objdir)/%(modname)_ALL.ref
1149 BD_DEFDFLAGS := %(cflags)
1150 OBJDIR ?= $(GENDIR)/$(CURDIR)
1151 BD_MODDIR := %(moduledir)
1152 ifeq ($(BD_MODDIR),)
1153 ifeq (%(modtype),library)
1154 BD_MODDIR := $(AROS_LIBS)
1156 ifeq (%(modtype),gadget)
1157 BD_MODDIR := $(AROS_GADGETS)
1159 ifeq (%(modtype),datatype)
1160 BD_MODDIR := $(AROS_DATATYPES)
1162 ifeq (%(modtype),handler)
1163 BD_MODDIR := $(AROS_FS)
1165 ifeq (%(modtype),device)
1166 BD_MODDIR := $(AROS_DEVS)
1168 ifeq (%(modtype),resource)
1169 BD_MODDIR := $(AROS_RESOURCES)
1171 ifeq (%(modtype),mui)
1172 BD_MODDIR := $(AROS_CLASSES)/Zune
1174 ifeq (%(modtype),mcc)
1175 BD_MODDIR := $(AROS_CLASSES)/Zune
1177 ifeq (%(modtype),mcp)
1178 BD_MODDIR := $(AROS_CLASSES)/Zune
1180 ifeq (%(modtype),hidd)
1181 BD_MODDIR := $(AROS_DRIVERS)
1184 ifeq ($(BD_MODDIR),)
1185 $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1188 %rule_compile_multi \
1189 basenames="%(files)" targetdir="%(objdir)" \
1190 cflags="%(cflags)" dflags="%(dflags)" \
1191 compiler=%(compiler)
1193 BD_MODULE := $(BD_MODDIR)/%(modname).%(modtype)
1194 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1196 %(mmake)-quick : %(mmake)
1197 %(mmake) : $(BD_MODULE)
1198 %(mmake)-kobj : $(BD_KOBJ)
1200 # The module is linked from all the compiled .o files
1201 BD_OBJS := $(addprefix %(objdir)/, $(addsuffix .o,%(files)))
1202 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1203 endobj= err=%(modname).err objdir=%(objdir) \
1204 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1206 # Link kernel object file
1207 BD_KAUTOLIB := workbench dos cybergraphics intuition layers graphics oop utility \
1209 BD_KBASE := WorkbenchBase DOSBase CyberGfxBase IntuitionBase LayersBase \
1210 GfxBase OOPBase UtilityBase ExpansionBase KeymapBase
1211 BD_KLIB := hiddgraphicsstubs hiddstubs amiga arossupport rom arosm autoinit libinit
1212 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1213 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1214 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_KBASE))
1215 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1216 @$(ECHO) "Linking $@"
1217 @$(AROS_LD) -Ur -o $@ $^ -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1218 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__$$/) || ($$3 ~ /^libraryset_.*$$/) {print "-L " $$3;}'`
1221 ## Dependency fine-tuning
1223 BD_DEPS := $(addprefix %(objdir), $(addsuffix .o,%(files)))
1224 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1226 $(BD_OBJS) $(BD_DEPS) $(BD_REFS) : | %(objdir)
1227 $(BD_MODULE) : | $(BD_MODDIR)
1228 $(BD_KOBJ) : | $(KOBJSDIR)
1229 GLOB_MKDIRS += %(objdir) $(BD_MODDIR) $(KOBJSDIR)
1231 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_MODULE) $(BD_KOBJ) $(BD_DEPS)
1233 @$(ECHO) "Cleaning up for module %(modname)"
1238 #------------------------------------------------------------------------------
1240 # Explanation of this macro is done in the developer's manual
1241 %define build_module mmake=/A modname=/A modtype=/A modsuffix= \
1242 conffile= files="$(basename $(call WILDCARD, *.c))" \
1243 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1244 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
1245 reffile=$(BD_DEFREFFILE) noref= \
1246 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
1249 # Define metamake targets and their dependencies
1250 #MM- includes-all : %(mmake)-includes
1251 #MM %(mmake) : %(mmake)-includes core-linklibs
1252 #MM %(mmake)-kobj : %(mmake)-includes core-linklibs
1253 #MM %(mmake)-linklib : %(mmake)-includes
1254 #MM %(mmake)-quick : %(mmake)-includes-quick
1255 #MM %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1256 #MM includes-generate-deps
1257 #MM %(mmake)-includes-quick
1258 #MM %(mmake)-includes-dirs
1259 #MM %(mmake)-makefile
1260 #MM %(mmake)-funclist
1263 # All MetaMake targets defined by this macro
1264 BD_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-includes \
1265 %(mmake)-includes-quick %(mmake)-includes-dirs %(mmake)-clean \
1266 %(mmake)-kobj %(mmake)-funclist %(mmake)-linklib
1268 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1271 $(error using %build_module: modname may not be empty)
1274 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1277 # Default values for variables and arguments
1278 BD_DEFLINKLIBNAME := %(modname)
1279 BD_DEFREFFILE := %(objdir)/%(modname)_ALL.ref
1280 BD_DEFDFLAGS := %(cflags)
1281 OBJDIR ?= $(GENDIR)/$(CURDIR)
1283 ## Create genmodule include Makefile for the module
1285 %(mmake)-makefile : %(objdir)/Makefile.%(modname)
1287 %rule_genmodule_makefile \
1288 modname=%(modname) modtype=%(modtype) \
1289 modsuffix=%(modsuffix) targetdir=%(objdir) \
1290 conffile=%(conffile)
1292 %(objdir)/Makefile.%(modname) : | %(objdir)
1294 GLOB_MKDIRS += %(objdir)
1296 # Do not parse these statements if metatarget is not appropriate
1297 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1299 include %(objdir)/Makefile.%(modname)
1301 BD_DEFMODDIR := $(%(modname)_MODDIR)
1304 ## include files generation
1306 BD_INCDIR := %(prefix)/$(AROS_DIR_INCLUDE)
1307 BD_LIBDEFSINC := %(objdir)/include/%(modname)_libdefs.h
1308 BD_DEFLIBDEFSINC := %(objdir)/include/%(modname)_deflibdefs.h
1310 %(mmake)-includes-quick : %(mmake)-includes
1311 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1312 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1313 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1315 ifneq ($(%(modname)_INCLUDES),)
1316 %rule_genmodule_includes modname=%(modname) modtype=%(modtype) \
1317 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1318 conffile=%(conffile) reffile=%(reffile)
1320 %rule_copy_diff_multi \
1321 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(GENINCDIR) \
1322 stampfile=%(objdir)/%(modname)_geninc
1324 %rule_copy_diff_multi \
1325 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(BD_INCDIR) \
1326 stampfile=%(objdir)/%(modname)_incs
1328 %rule_genmodule_dummy modname=%(modname) modtype=%(modtype) \
1329 modsuffix=%(modsuffix) \
1330 targetdir=%(objdir)/dummyinc conffile=%(conffile)
1332 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1334 TMP%(modname)_INCDIRS := \
1335 %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1336 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1337 $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1338 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget=%(mmake)-includes-dirs
1340 $(addprefix %(objdir)/dummyinc/,$(%(modname)_INCLUDES)) : | %(objdir)/dummyinc $(addprefix %(objdir)/dummyinc/,$(BD_INCDIRS))
1341 GLOB_MKDIRS += %(objdir)/dummyinc $(addprefix %(objdir)/dummyinc/,$(BD_INCDIRS))
1345 %rule_genmodule_genlibdefs modname=%(modname) modtype=%(modtype) \
1346 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1347 conffile=%(conffile)
1349 $(BD_DEFLIBDEFSINC) : FILENAME := $(BD_LIBDEFSINC)
1350 $(BD_DEFLIBDEFSINC) :
1351 @$(ECHO) "generating $@"
1352 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1354 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) : | %(objdir)/include
1355 GLOB_MKDIRS += %(objdir)/include
1357 ## Generation of the funclist file
1359 %(mmake)-funclist : %(modname).funclist
1361 %rule_genmodule_funclist \
1362 modname=%(modname) modtype=%(modtype) modsuffix=%(modsuffix) \
1363 conffile=%(conffile) reffile=%(reffile)
1366 ## Extra genmodule src files generation
1368 %rule_genmodule_files modname=%(modname) modtype=%(modtype) \
1369 modsuffix=%(modsuffix) targetdir=%(objdir) \
1370 conffile=%(conffile) reffile=%(reffile)
1374 BD_FILES := %(files)
1375 BD_FDIRS := $(sort $(dir $(BD_FILES)))
1376 BD_STARTFILES := $(addprefix %(objdir)/,$(%(modname)_STARTFILES))
1377 BD_ENDFILES := $(addprefix %(objdir)/,$(%(modname)_ENDFILES))
1379 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1380 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1381 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1383 TMP_QUOTE := $(CFLAGS_IQUOTE) $(TOP)/$(CURDIR) \
1384 $(addprefix $(CFLAGS_IQUOTE),$(BD_FDIRS)) \
1385 $(CFLAGS_IQUOTE_END)
1386 BD_CFLAGS := $(TMP_QUOTE) %(cflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1387 BD_DFLAGS := $(TMP_QUOTE) %(dflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1389 BD_LINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBFILES))
1390 BD_LINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBAFILES))
1391 ifeq ($(strip $(%(modname)_LINKLIBFILES) %(linklibfiles)),)
1394 BD_LINKLIB := %(prefix)/$(AROS_DIR_LIB)/lib%(linklibname).a
1396 BD_LINKLIBFILES := $(BD_LINKLIBCFILES) $(BD_LINKLIBAFILES)
1398 BD_CCFILES := $(BD_NARCHFILES) %(linklibfiles)
1399 BD_TARGETCCFILES := $(BD_STARTFILES) $(BD_ENDFILES) $(BD_LINKLIBCFILES)
1401 %rule_compile_multi \
1402 basenames=$(BD_CCFILES) targetdir=%(objdir) \
1403 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) \
1404 compiler=%(compiler)
1405 %rule_compile_multi \
1406 basenames=$(BD_TARGETCCFILES) targetdir=%(objdir) \
1407 cflags="$(BD_CFLAGS) -D__AROS__" dflags=$(BD_DFLAGS) \
1408 compiler=%(compiler)
1410 ifneq ($(BD_LINKLIBAFILES),)
1411 %rule_assemble_multi \
1412 basenames=$(BD_LINKLIBAFILES) targetdir=%(objdir) suffix=.S
1415 ## function reference files generation
1417 BD_CFLAGS_REF := -I$(dir $(GENMODULE))/genmod_inc -I%(objdir)/dummyinc $(strip %(cflags)) -I$(TOP)/$(CURDIR) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1419 basenames=$(BD_FILES) targetdir=%(objdir) \
1420 cflags=$(BD_CFLAGS_REF) \
1421 compiler=%(compiler)
1424 BD_REFS := $(addprefix %(objdir)/,$(addsuffix .ref, $(notdir $(BD_FILES))))
1426 BD_REFS := $(addprefix %(objdir)/,$(addsuffix .ref, $(notdir $(filter-out %(noref),$(BD_FILES)))))
1429 %rule_join from=$(BD_REFS) to=%(reffile) \
1430 text="Collecting function references for module %(modname)"
1435 ifeq (%(modsuffix),)
1436 BD_MODULE := %(prefix)/%(moduledir)/%(modname).%(modtype)
1437 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1439 BD_MODULE := %(prefix)/%(moduledir)/%(modname).%(modsuffix)
1440 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modsuffix).o
1443 %(mmake)-quick : %(mmake)
1444 %(mmake) : $(BD_MODULE) $(BD_LINKLIB)
1445 %(mmake)-kobj : $(BD_KOBJ) $(BD_LINKLIB)
1446 %(mmake)-linklib : $(BD_LINKLIB)
1448 BD_OBJS := $(addsuffix .o,$(BD_STARTFILES)) $(BD_ARCHOBJS) \
1449 $(addsuffix .o, $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES))))
1450 BD_ENDOBJS := $(addsuffix .o,$(BD_ENDFILES))
1451 BD_LINKLIBOBJS:= $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_LINKLIBFILES)) \
1454 # The module is linked from all the compiled .o files
1455 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1456 endobj=$(BD_ENDOBJS) err=%(modname).err objdir=%(objdir) \
1457 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1460 ifneq ($(BD_LINKLIB),)
1461 %rule_link_linklib libname=%(linklibname) objs=$(BD_LINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1463 $(BD_LINKLIB) : | %(prefix)/$(AROS_DIR_LIB)
1464 GLOB_MKDIRS += %(prefix)/$(AROS_DIR_LIB)
1467 # Link kernel object file
1468 BD_KAUTOLIB := workbench dos cybergraphics intuition layers graphics oop utility \
1470 BD_KBASE := WorkbenchBase DOSBase CyberGfxBase IntuitionBase LayersBase \
1471 GfxBase OOPBase UtilityBase ExpansionBase KeymapBase
1472 BD_KLIB := hiddgraphicsstubs hiddstubs amiga arossupport rom arosm autoinit libinit
1473 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1474 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1475 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_KBASE))
1476 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1477 @$(ECHO) "Linking $@"
1478 @$(AROS_LD) -Ur -o $@ $^ -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1479 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__$$/) || ($$3 ~ /^libraryset_.*$$/) {print "-L " $$3;}'`
1481 ## Dependency fine-tuning
1483 BD_DEPS := $(addsuffix .d,$(addprefix %(objdir)/,$(notdir $(BD_CCFILES) $(BD_TARGETCCFILES))))
1484 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1486 $(BD_OBJS) $(BD_DEPS) $(BD_REFS) : | %(objdir)
1487 $(BD_MODULE) : | %(prefix)/%(moduledir)
1488 $(BD_KOBJ) : | $(KOBJSDIR)
1489 GLOB_MKDIRS += %(objdir) %(prefix)/%(moduledir) $(KOBJSDIR)
1491 # Some include files need to be generated before the .c can be parsed.
1492 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj),) # Only for this target these deps are wanted
1493 BD_REFFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
1494 $(addprefix %(objdir)/dummyinc/,$(%(modname)_INCLUDES))
1495 $(BD_REFS) : $(BD_REFFILE_DEPS) $(dir $(GENMODULE))/genmod_inc/aros/libcall.h
1497 BD_DFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
1498 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES))
1499 $(BD_DEPS) : $(BD_DFILE_DEPS)
1502 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) %(reffile) \
1503 $(BD_REFS) $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
1504 %(objdir)/Makefile.%(modname) \
1505 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
1506 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1507 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1508 %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
1509 $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
1510 $(BD_DEFLIBDEFSINC) $(addsuffix .c,$(BD_STARTFILES) $(BD_ENDFILES)) \
1512 %(mmake)-clean : FILES := $(BD_TOCLEAN)
1514 @$(ECHO) "Cleaning up for module %(modname)"
1517 endif # $(TARGET) in $(BD_ALLTARGETS)
1519 #------------------------------------------------------------------------------
1522 #------------------------------------------------------------------------------
1524 # - mmake is the mmaketarget
1525 # - libname is the baselibname e.g. lib%(libname).a will be created
1526 # - files are the C source files to include in the lib. The list of files
1527 # has to be given without the .c suffix
1528 # - asmfiles are the asm files to include in the lib. The list of files has to
1529 # be given without the .s suffix
1530 # - objs additional object to link into the linklib. The objects have to be
1531 # given with full absolute path and the .o suffix.
1532 # - cflags are the flags to compile the source (default $(CFLAGS))
1533 # - dflags are the flags use during makedepend (default equal to cflags)
1534 # - aflags are the flags use during assembling (default $(AFLAGS))
1535 # - objdir is where the .o are generated
1536 # - libdir is the directory where the linklib will be placed (default $(LIBDIR))
1537 %define build_linklib mmake=/A libname=/A \
1538 files="$(basename $(call WILDCARD, *.c))" asmfiles= objs= \
1539 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) objdir=$(OBJDIR) libdir=$(LIBDIR)
1541 # assign and generate the local variables used in this macro
1542 OBJDIR ?= $(GENDIR)/$(CURDIR)
1544 BD_FILES := %(files)
1545 BD_ASMFILES := %(asmfiles)
1547 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1548 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1549 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1551 BD_OBJS := $(BD_ARCHOBJS) \
1552 $(addsuffix .o,$(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES) $(BD_ASMFILES)))) \
1554 BD_DEPS := $(patsubst %.o,%.d,$(BD_OBJS))
1556 BD_CFLAGS := %(cflags)
1558 BD_DFLAGS := $(BD_CFLAGS)
1560 BD_DFLAGS := %(dflags)
1562 BD_AFLAGS := %(aflags)
1564 BD_LINKLIB := %(libdir)/lib%(libname).a
1566 .PHONY : %(mmake) %(mmake)-clean
1568 #MM %(mmake) : includes-generate-deps
1569 %(mmake) : $(BD_LINKLIB)
1573 @$(RM) $(BD_OBJS) $(BD_DEPS)
1575 ifeq ($(TARGET),%(mmake))
1576 ifneq ($(dir $(BD_FILES)),./)
1577 vpath %.c $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir $(BD_FILES)))
1580 %rule_compile basename=% targetdir=%(objdir) \
1581 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1582 %rule_assemble basename=% targetdir=%(objdir) \
1586 %rule_link_linklib libname=%(libname) objs=$(BD_OBJS) libdir=%(libdir)
1588 %include_deps depstargets=%(mmake) deps=$(BD_DEPS)
1590 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1591 $(BD_LINKLIB) : | %(libdir)
1592 GLOB_MKDIRS += %(objdir) %(libdir)
1595 #------------------------------------------------------------------------------
1598 #------------------------------------------------------------------------------
1600 # - mmake is the mmaketarget
1601 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
1602 # - description is the catalog description file (.cd) (default *.cd)
1603 # - subdir is the destination subdir of the catalogs
1604 # - name is the name of the destination catalog, without the .catalog suffix
1605 # - source is the path to the generated source code file
1606 # - dir is the base destination directory (default $(AROS_CATALOGS))
1607 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
1609 %define build_catalogs mmake=/A name=/A subdir=/A \
1610 catalogs="$(basename $(call WILDCARD, *.ct))" source="../strings.h" \
1611 description="$(basename $(call WILDCARD, *.cd))" dir=$(AROS_CATALOGS) \
1612 sourcedescription="$(TOOLDIR)/C_h_orig"
1614 BD_SRCS := $(addsuffix .ct, %(catalogs))
1615 BD_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, %(catalogs)))
1616 BD_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, %(catalogs)))
1619 %(mmake) : $(BD_OBJS) %(source)
1621 $(BD_OBJS) : | $(BD_DIRS)
1622 GLOB_MKDIRS += $(BD_DIRS)
1624 %(dir)/%/%(subdir)/%(name).catalog : %.ct %(description).cd
1625 @$(ECHO) "Creating %(name) catalog for language $*."
1626 @$(FLEXCAT) $(SRCDIR)/$(CURDIR)/%(description).cd $< CATALOG=%(dir)/$*/%(subdir)/%(name).catalog || [ $$? -lt 10 ]
1629 %(source) : %(description).cd
1630 @$(ECHO) "Creating %(name) catalog source file %(source)"
1631 @$(FLEXCAT) $(SRCDIR)/$(CURDIR)/%(description).cd %(source)=%(sourcedescription).sd
1634 %(mmake)-clean : FILES := $(BD_OJS) %(source)
1639 .PHONY: %(mmake) %(mmake)-clean
1643 #-----------------------------------------------------------------------------
1645 #-----------------------------------------------------------------------------
1647 # - mmake is the mmaketarget
1648 # - icons is a list of icon base names (ie. without the .info suffix)
1649 # - dir is the destination directory
1650 #-----------------------------------------------------------------------------
1652 %define build_icons mmake=/A icons=/A dir=/A
1654 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
1657 %(mmake) : $(BD_OBJS)
1659 %(dir)/%.info : %.info.src %.png
1660 @$(ECHO) Creating $(notdir $@)...
1661 @$(ILBMTOICON) $+ $@
1663 $(BD_OBJS) : | %(dir)
1664 GLOB_MKDIRS += %(dir)
1666 %(mmake)-clean : FILES := $(BD_OBJS)
1671 .PHONY: %(mmake) %(mmake)-clean
1675 #-----------------------------------------------------------------------------
1677 #------------------------------------------------------------------------------
1678 # Compile files for an arch-specific replacement of code for a module
1679 # - files: the basenames of the C files to compile.
1680 # - asmfiles: the basenames of the asm files to assemble.
1681 # - mainmmake: the mmake of the module in the main directory to compile these
1682 # arch specific files for.
1683 # - maindir: the object directory for the main module
1684 # - arch: the arch for which to compile these files. It can have the form
1685 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
1686 # - cflags (default $(CFLAGS)): the C flags to use for compilation
1687 # - dflags: the flags used during creation of dependency file. If not specified
1688 # the same value as cflags will be used
1689 # - aflags: the flags used during assembling
1690 # - compiler: (host, kernel or target) specifies which compiler to use. By default
1691 # the target compiler is used
1692 %define build_archspecific files= asmfiles= mainmmake=/A maindir=/A arch=/A \
1693 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
1695 ifeq (%(files) %(asmfiles),)
1696 $(error no files or asmfiles given)
1699 %buildid targets="%(mainmmake)-%(arch)"
1701 ifeq ($(AROS_TARGET_VARIANT),)
1702 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1703 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1704 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1706 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1707 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1708 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1711 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
1714 $(error argument arch has to be non empty for the rule_compile_archspecific macro)
1717 BD_OBJDIR$(BDID) := $(GENDIR)/%(maindir)/arch
1718 BD_COBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1719 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
1720 BD_OBJS$(BDID) := $(BD_COBJS$(BDID)) $(BD_ASMOBJS$(BDID))
1721 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1723 ifeq ($(TARGET),%(mainmmake)-%(arch))
1724 vpath %.c $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir %(files)))
1725 vpath %.s $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
1726 vpath %.S $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
1729 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID))
1730 GLOB_MKDIRS += $(BD_OBJDIR$(BDID))
1733 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
1735 ifeq ($(findstring %(compiler),host kernel target),)
1736 $(error unknown compiler %(compiler))
1738 ifeq (%(compiler),target)
1739 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(TARGET_CC)
1741 ifeq (%(compiler),host)
1742 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(HOST_CC)
1744 ifeq (%(compiler),kernel)
1745 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
1747 ifneq (%(modulename),)
1748 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) \
1749 -include $(GENDIR)/%(maindir)/include/%(modulename)_deflibdefs.h
1751 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
1753 ifeq ($(TARGET),%(mainmmake)-%(arch))
1754 $(BD_OBJDIR$(BDID))/%.o : %.c
1755 %compile_q opt=$(TMP_CFLAGS) cmd=$(TMP_CMD)
1759 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags)
1761 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
1763 ifeq ($(TARGET),%(mainmmake)-%(arch))
1764 $(BD_OBJDIR$(BDID))/%.d : %.c
1765 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
1768 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
1770 ifeq ($(TARGET),%(mainmmake)-%(arch))
1771 $(BD_OBJDIR$(BDID))/%.o : %.s
1772 %assemble_q opt=$(AFLAGS)
1773 $(BD_OBJDIR$(BDID))/%.o : %.S
1774 %assemble_q opt=$(AFLAGS)
1777 %include_deps depstargets=%(mainmmake)-%(arch) deps=$(BD_DEPS$(BDID))
1779 #------------------------------------------------------------------------------
1787 # ======================
1788 # Old stuff, will probably be removed in the future
1793 # GNU Make automatic variables
1795 # $< First dependency
1796 # $? All newer dependencies
1797 # $^ All dependencies
1798 # $* The stem (ie. target is dir/a.foo.b and the pattern is
1799 # a.%.b, then the stem is dir/foo)
1801 #------------------------------------------------------------------------------
1802 # rule to generate libdefs.h with archtool (options may go away!)
1803 %define libdefs_rule conffile=lib.conf genlibdefstool=$(ARCHTOOL) dest=libdefs.h
1804 %(dest) : %(conffile) %(genlibdefstool)
1805 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
1806 @%(genlibdefstool) -c -o $@ %(conffile)
1810 #------------------------------------------------------------------------------
1811 # generate asm files from c files (for debugging purposes)
1814 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
1815 @$(TARGET_CC) -S $(CFLAGS) $< -c -o $@
1818 #------------------------------------------------------------------------------
1819 # Convert two png images to an Amiga icon file based on the description
1820 # file %(from), with outputfile going to %(to).
1821 %define makeicon2 from=$< to=$@ img1="$(basename $(basename $<))_N.png" img2="$(basename $(basename $<))_S.png"
1822 @$(ECHO) "Creating icon %(to)..."
1823 @$(PNGTOPNM) %(img1) | $(PPMTOILBM) -maxplanes 8 >$(GENDIR)/genicon1.iff
1824 @$(PNGTOPNM) %(img2) | $(PPMTOILBM) -maxplanes 8 >$(GENDIR)/genicon2.iff
1825 @$(ILBMTOICON) %(from) $(GENDIR)/genicon1.iff $(GENDIR)/genicon2.iff %(to)
1828 #------------------------------------------------------------------------------
1829 # NOTE: The following are all part of Iain's build changes, please don't use
1830 # or change anything below this line until you know what you are doing. This
1831 # is so that I don't conflict with the semantics of any of the above macros.
1832 #------------------------------------------------------------------------------
1834 #------------------------------------------------------------------------------
1835 # Copy files from one directory to another.
1837 %define copy_files_q files=$(FILES) src=. dst=/A maketarget=files-copy
1839 %(maketarget) : setup
1840 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,%(src)),%(src),$(SRCDIR)/$(CURDIR)/%(src))/, $(file)) $(addprefix %(dst)/, $(file))))
1847 #----------------------------------------------------------------------------------
1848 # Copy a diretory recursively to another place, preserving the original
1849 # hierarchical structure
1851 # src: the source directory whose content will be copied
1852 # dst: the directory where to copy src's content. If not existing, it will be made.
1854 %define copy_dir_recursive mmake=/A src=. dst=/A
1856 %(mmake)_FILES := $(shell cd $(if $(filter /%,%(src)),%(src),$(SRCDIR)/$(CURDIR)/%(src)); find . -path '*/CVS' -prune -o -path '*/.svn' -prune -o -name .cvsignore -prune -o -name mmakefile -prune -o -name mmakefile.src -prune -o -type f -print)
1857 %(mmake)_DIRS := $(sort $(dir $(%(mmake)_FILES)))
1859 define %(mmake)_mkdir
1864 define %(mmake)_copy
1865 $(3)/$(1): $(2)/$(1) | $(dir $(3)/$(1))
1872 %(mmake): | $(GENDIR)/$(CURDIR)
1873 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1874 $(ECHO) "all: $(addprefix \$$(DST)/,$(%(mmake)_FILES))" > $$m
1875 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1876 for d in $(%(mmake)_DIRS); do \
1877 $(ECHO) "\$$(DST)/$$d: ; $(MKDIR) \$$@" >> $$m; \
1879 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1880 for f in $(%(mmake)_FILES); do \
1881 $(ECHO) "\$$(DST)/$$f: \$$(SRC)/$$f | \$$(dir \$$(DST)/$$f); $(CP) \$$< \$$@" >> $$m; \
1883 for dst in %(dst); do \
1884 $(MAKE) -f $$m DST=$$dst SRC=$(if $(filter /%,%(src)),%(src),$(SRCDIR)/$(CURDIR)/%(src)) all; \
1887 $(GENDIR)/$(CURDIR):
1892 #------------------------------------------------------------------------------
1893 # Copy include files into the includes directories. There are currently
1894 # two include directories. One for building AROS $(AROS_INCLUDES) and one
1895 # for building tools that need to run on the host system $(GENINCDIR). The
1896 # $(GENINCDIR) path must not contain any references to the C runtime
1897 # library header files.
1899 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
1900 dir= compiler=target
1902 ifeq ($(findstring %(compiler),host kernel target),)
1903 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
1907 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),%(includes))
1908 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
1910 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
1911 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
1914 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
1918 ifeq (%(compiler),target)
1921 BD_INCL_FILES2 := $(subst %(dir),$(AROS_INCLUDES)/%(path),%(includes))
1923 BD_INCL_FILES2 := $(addprefix $(AROS_INCLUDES)/%(path)/,%(includes))
1926 BD_INCL_FILES += $(BD_INCL_FILES2)
1928 $(BD_INCL_FILES2) : $(AROS_INCLUDES)/%(path)/% : $(BD_INC_PATH)%
1933 %(mmake) : $(BD_INCL_FILES)
1937 $(BD_INCL_FILES) : | $(dir $(BD_INCL_FILES))
1938 GLOB_MKDIRS += $(dir $(BD_INCL_FILES))
1942 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
1943 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
1944 STUBS_MEM := $(addsuffix .o,$(STUBS))
1945 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
1946 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
1947 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
1949 #MM- linklibs : hidd-%(hidd)-stubs
1950 #MM- %(parenttarget): hidd-%(hidd)-stubs
1951 #MM hidd-%(hidd)-stubs : includes includes-copy
1952 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
1954 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
1957 $(STUBS_OBJ) : $(STUBS_SRC)
1958 %compile_q cmd=$(TARGET_CC) opt=%(cflags)
1960 $(STUBS_DEP) : $(STUBS_SRC)
1961 %mkdepend_q flags=%(dflags)
1964 %mkdirs_q $(OBJDIR) $(LIBDIR)
1968 -@$(RM) $(HIDD_LIB) $(OBJDIR)
1970 DEPS := $(DEPS) $(STUBS_DEP)
1974 #------------------------------------------------------------------------------
1975 # Build an imported source tree which uses the configure script from the
1976 # autoconf package. This rule will try to "integrate" the produced files as
1977 # much as possible in the AROS build, for example by putting libraries in the
1978 # standard library directory, includes in the standard include directory, and
1979 # so on. You can however override this behaviour.
1981 # As a special "bonus" for you, the PROGDIR environment variable is defined to
1982 # be %(bindir) (or its deduced value) when running "make install", and
1983 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
1984 # configure script some more parameters whose value depends upon the PROGDIR
1985 # env var, so that the program gets all its stuff installed in the proper place
1986 # when building it, but when running it from inside AROS it can also find that
1987 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
1988 # the configuration parameters set when running ./configure
1990 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
1991 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
1992 # to the name which has to follow it.
1995 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) prefix= \
1996 aros_prefix= extraoptions= nix_dir_layout= nix=no compiler=target \
1997 install_target=install postconfigure= postinstall= \
2001 %(mmake)-prefix := %(prefix)
2003 %(mmake)-prefix := $(AROS_CONTRIB)
2006 ifneq (%(aros_prefix),)
2007 %(mmake)-aros_prefix := %(aros_prefix)
2009 %(mmake)-aros_prefix := $(%(mmake)-prefix)
2013 %(mmake)-nix := -nix
2014 %(mmake)-volpfx := /
2015 %(mmake)-volsfx := /
2017 ifeq (%(nix_dir_layout),)
2018 %(mmake)-nix_dir_layout := yes
2021 %(mmake)-volsfx := :
2023 ifeq (%(nix_dir_layout),)
2024 %(mmake)-nix_dir_layout := no
2028 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
2030 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
2031 exec_prefix=$(%(mmake)-prefix) %(install_env)
2033 # Check if chosen compiler is valid
2034 ifeq ($(findstring %(compiler),host target kernel),)
2035 $(error unknown compiler %(compiler))
2038 # Set legacy 'host' variable based on chosen compiler
2039 ifeq (%(compiler),host)
2042 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
2044 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
2049 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
2051 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
2055 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
2056 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
2058 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
2059 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
2060 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2063 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
2064 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
2066 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2069 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
2071 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
2072 sbindir=$(%(mmake)-prefix) \
2073 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
2074 oldincludedir=$(AROS_INCLUDES) %(install_env)
2078 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
2080 #MM- %(mmake) : setup includes linklibs-core %(mmake)-quick
2082 # Using -j1 in install_command may result in a warning but finally
2083 # it does its job. make install for gcc does not work reliable for -jN
2085 ifneq (%(install_target),)
2086 %(mmake)-install_command = \
2087 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2088 -C $(%(mmake)-pkgdir) %(install_target) -j1 && \
2089 $(TOUCH) $(%(mmake)-installflag)
2091 %(mmake)-uninstall_command = \
2092 $(RM) $(%(mmake)-installflag) && \
2093 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2094 -C $(%(mmake)-pkgdir) uninstall
2096 %(mmake)-install_command := true
2097 %(mmake)-uninstall_command := true
2100 #MM- %(mmake)-quick : %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
2103 %(mmake)-build_and_install-quick : $(%(mmake)-configflag)
2104 if ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q -C $(%(mmake)-pkgdir); then \
2105 $(RM) $(%(mmake)-installflag) && \
2106 $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -C $(%(mmake)-pkgdir) && \
2107 $(%(mmake)-install_command); \
2110 %(srcdir)/.files-touched:
2111 find %(srcdir) -exec $(TOUCH) -r %(srcdir)/configure '{}' \; && \
2115 %(mmake)-uninstall :
2116 $(%(mmake)-uninstall_command)
2118 ifneq ($(DEBUG),yes)
2119 %(mmake)-s_flag = -s
2123 %(mmake)-configure : $(%(mmake)-configflag)
2125 ifeq (%(compiler),host)
2126 $(%(mmake)-configflag) : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2128 %mkdirs_q $(%(mmake)-pkgdir)
2129 cd $(%(mmake)-pkgdir) && \
2130 find . -name config.cache -exec $(RM) '{}' \; && \
2132 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) && \
2135 ifeq (%(compiler),target)
2136 $(%(mmake)-configflag) : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2138 %mkdirs_q $(%(mmake)-pkgdir)
2139 cd $(%(mmake)-pkgdir) && \
2140 find . -name config.cache -exec $(RM) '{}' \; && \
2141 CC="$(TARGET_CC) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2142 AS="$(TARGET_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)" \
2143 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) \
2144 --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH) \
2145 --host=$(AROS_TARGET_CPU)-aros \
2146 --target=$(AROS_TARGET_CPU)-aros \
2148 --without-x --without-pic --disable-shared && \
2151 ifeq (%(compiler),kernel)
2152 $(%(mmake)-configflag) : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2154 %mkdirs_q $(%(mmake)-pkgdir)
2155 cd $(%(mmake)-pkgdir) && \
2156 find . -name config.cache -exec $(RM) '{}' \; && \
2157 CC="$(KERNEL_CC) $(KERNEL_CFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2158 AS="$(TARGET_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)" \
2159 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) \
2160 --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH) \
2161 --host=$(AROS_TARGET_CPU)-aros \
2162 --target=$(AROS_TARGET_CPU)-aros --disable-nls \
2163 --without-x --without-pic --disable-shared && \
2168 %(mmake)-clean : %(mmake)-uninstall
2169 @$(RM) $(%(mmake)-pkgdir)
2172 #############################################################################
2173 #############################################################################
2175 ## Miscellaneous macros. Everything that doesn't fit above should be put ##
2178 #############################################################################
2179 #############################################################################
2181 #----------------------------------------------------------------------------------
2182 # Given an archive name, patches names and locations where to find them, fetch
2183 # the archive and the patches from any of those locations, unpack the archive
2184 # and then apply the patches.
2186 # Locations currently supported are http and ftp sites, plus local filesystem
2187 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
2188 # the fetch.sh script needs to be modified, since this macro relies on that script.
2192 # - archive_origins = list of locations where to find the archive. They are tried
2193 # in sequence, until the archive is found and fetching it
2194 # succeeded. If not specified, the current directory is assumed.
2195 # - archive = the archive name. Mandatory.
2196 # - suffixes = a list of suffixes to append to the the package name plus the
2197 # version. Each one of them is tried until a matching archive is
2198 # found. They are appended to patches and these are tried the
2199 # same way as packages are.
2200 # - destination = the local directory where to put the archive and patches.
2201 # If not specified, the current directory is assumed.
2202 # - patches_origins = list of locations where to find the patches. They are tried
2203 # in sequence, until a patch is found and fetching it
2204 # succeeded. If not specified, the current directory is assumed.
2205 # - patches_specs = list of "patch specs". A patch spec is of the form
2206 # patch_name[:[patch_subdir][:patch_opt]].
2208 # - patch_name = the name of the patch file
2209 # - patch_subdir = the directory within \destination\ where to
2211 # - patch_opt = any options to pass to the `patch' command
2212 # when applying the patch.
2214 # The patch_subdir and patch_opt fields are optional.
2216 %define fetch archive_origins=. archive=/A suffixes= location=%destination destination=. patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
2217 $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l %(location) -d %(destination) \
2218 -po "%(patches_origins)" -p %(patches_specs)
2221 #-----------------------------------------------------------------------------------------
2222 # Joins the features of %fetch and %build_with_configure, taking advantage of
2223 # the naming scheme of GNU packages. GNU packages names are in the form
2225 # <package name>-<version number>.<archive format suffix>
2227 # If a patch is provided, it *must* be named the following way:
2229 # <package name>-<version number>-aros.diff
2231 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
2232 # CD'ing into the archive's extracted directory.
2234 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
2235 # the %fetch_and_build macro only accept *one* patch for each package. It's up to you
2236 # to make that patch fully comprehensive.
2238 # NOTE: GNU packages are always compiled with *nix semantics turned on.
2242 # - mmake = the meta make target, as would be supplied to the %build_with_configure
2244 # - package = the GNU package name, sans version and archive format suffixes.
2245 # - version = the package's version number, or otherwise any other version string.
2246 # It gets appended to the package name to form the basename of the archive.
2247 # - suffixes = a list of suffixes to apped to the the package name plus the
2248 # version. Each one of them is tried until a matching archive is found.
2249 # Defaults to "tar.bz2 tar.gz".
2250 # - destination = same meaning as the one for the %fetch macro
2251 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
2252 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
2254 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
2255 # - prefix = same meaning as the one for the %build_with_configure macro. Defaults to
2257 # - aros_prefix = same meaning as the one for the %build_with_configure macro. Defaults to
2259 # - extraoptions = same meaning as the one for the %build_with_configure macro.
2260 # - postinstall = same meaning as the one for the %build_with_configure macro.
2262 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target version=/A suffixes="tar.bz2 tar.gz" \
2263 srcdir= package_repo= patch=no patch_repo= prefix= \
2264 aros_prefix= extraoptions= postconfigure= postinstall= nix=no nix_dir_layout=
2266 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
2267 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
2268 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
2270 %(mmake)-archbase := %(package)-%(version)
2272 ifeq (%(compiler),host)
2273 %(mmake)-portdir := $(HOSTDIR)/Ports/%(package)
2275 %(mmake)-portdir := $(PORTSDIR)/%(package)
2279 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
2281 %(mmake)-prefix := %(prefix)
2284 ifneq (%(subpackage),)
2285 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
2287 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
2291 %(mmake)-%(subpackage)-srcdir := %(srcdir)
2293 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
2297 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-p1
2299 %(mmake)-%(subpackage)-patches_specs := ::
2302 .PHONY : %(mmake)-%(subpackage)-fetch
2304 %(mmake)-%(subpackage)-fetch :
2305 %fetch archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
2306 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
2307 archive_origins=". %(package_repo)" \
2308 patches_specs="$(%(mmake)-%(subpackage)-patches_specs)" patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
2310 #MM- %(mmake) : %(mmake)-%(subpackage)
2312 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
2314 %(mmake)-%(subpackage)-package-basename := \
2315 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
2317 %build_with_configure mmake=%(mmake)-%(subpackage) package=%(package) compiler=%(compiler) \
2318 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-srcdir) \
2319 nix=%(nix) nix_dir_layout=%(nix_dir_layout) prefix="$(%(mmake)-prefix)" \
2320 aros_prefix="%(aros_prefix)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
2321 %(mmake)-%(subpackage)-make-package" extraoptions="%(extraoptions)"
2323 .PHONY : %(mmake)-%(subpackage)-make-package
2324 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
2327 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package-basename).tar.bz2
2329 #There seems to be a bug, either with my clock or with make, 'cause it may happen
2330 #that $^ and $@ have exactly the same mtime, and in that case make tries
2331 #to rebuild $@ again, which would fail because the directory where
2332 #the package got installed would not exist anymore.
2333 #We work this around by using an if statement to manually check the mtimes.
2334 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
2335 @$(IF) test $(%(mmake)-installflag) -nt $@ || ! test -f $@; then \
2337 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
2338 mkdir -p "$(DISTDIR)/Packages" ; \
2339 mkdir -p "$(%(mmake)-prefix)" ; \
2340 cd $(%(mmake)-%(subpackage)-package-dir) ; \
2341 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
2342 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
2346 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2347 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
2348 aros_prefix=/GNU extraoptions= postconfigure= postinstall=
2350 GNU_REPOSITORY := gnu://
2352 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
2353 suffixes="%(suffixes)" srcdir="%(srcdir)" \
2354 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
2355 patch="%(patch)" patch_repo="%(patch_repo)" \
2356 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" \
2357 postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=yes
2361 #-----------------------------------------------------------------------------------------
2362 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
2363 # that the package is a "Development" package, and as such it needs to be placed
2364 # under the $(AROS_DEVELOPMENT) directory, as a default.
2366 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
2367 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
2368 # "mmake" argument, because the metatarget is implicitely defined as
2370 # #MM- development-%(package)
2372 %define fetch_and_build_gnu_development package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2373 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPMENT) \
2374 aros_prefix=/Development postconfigure= postinstall= extraoptions=
2376 #MM- development : development-%(package)
2379 %fetch_and_build_gnu mmake=development-%(package) package=%(package) subpackage="%(subpackage)" \
2380 version=%(version) suffixes="%(suffixes)" srcdir="%(srcdir)" \
2381 package_repo="%(package_repo)" patch="%(patch)" patch_repo="%(patch_repo)" prefix=%(prefix) \
2382 aros_prefix="%(aros_prefix)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" \
2383 extraoptions="%(extraoptions)"