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) %(opt) -c %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
18 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
19 $(ECHO) "%(from): %(cmd) %(opt) -c %(from) -o %(to)" >> $(GENDIR)/errors ; \
20 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors ; \
25 $(ECHO) "Compile failed: %(cmd) %(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) %(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))))
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))))
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))))
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 %(conffile)
749 TMP_DEPS += %(conffile)
751 TMP_DEPS += %(modname).conf
753 ifneq (%(modsuffix),)
754 TMP_OPTS += -s %(modsuffix)
756 ifneq (%(targetdir),)
757 TMP_OPTS += -d %(targetdir)
758 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
761 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
762 $(TMP_TARGET) : MODNAME := %(modname)
763 $(TMP_TARGET) : MODTYPE := %(modtype)
764 $(TMP_TARGET) : $(TMP_DEPS)
765 @$(ECHO) "Generating $(notdir $@)"
766 @$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
768 #------------------------------------------------------------------------------
771 #------------------------------------------------------------------------------
772 # Generate the libdefs.h include file for a module.
773 %define rule_genmodule_funclist \
774 modname=/A modtype=/A modsuffix= conffile= targetdir= reffile=
776 TMP_TARGET := %(modname).funclist
777 TMP_DEPS := $(GENMODULE)
780 $(error reffile needed in rule_genmodule_funclist but none specified)
782 TMP_OPTS := -r %(reffile)
783 TMP_DEPS += %(reffile)
785 TMP_OPTS += -c %(conffile)
786 TMP_DEPS += %(conffile)
788 TMP_DEPS += %(modname).conf
790 ifneq (%(modsuffix),)
791 TMP_OPTS += -s %(modsuffix)
793 ifneq (%(targetdir),)
794 TMP_OPTS += -d %(targetdir)
795 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
798 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
799 $(TMP_TARGET) : MODNAME := %(modname)
800 $(TMP_TARGET) : MODTYPE := %(modtype)
801 $(TMP_TARGET) : $(TMP_DEPS)
802 @$(ECHO) "Generating $(notdir $@)"
803 @$(GENMODULE) $(OPTS) writefunclist $(MODNAME) $(MODTYPE)
805 #------------------------------------------------------------------------------
808 #------------------------------------------------------------------------------
809 # Generate a Makefile.%(modname) with the genmodule program and include this
810 # generated file in this Makefile
811 %define rule_genmodule_makefile modname=/A modtype=/A modsuffix= conffile= \
814 TMP_TARGET := Makefile.%(modname)
815 TMP_DEPS := $(GENMODULE)
818 TMP_OPTS += -c %(conffile)
819 TMP_DEPS += %(conffile)
821 TMP_DEPS += %(modname).conf
823 ifneq (%(modsuffix),)
824 TMP_OPTS += -s %(modsuffix)
826 ifneq (%(targetdir),)
827 TMP_OPTS += -d %(targetdir)
828 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
831 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
832 $(TMP_TARGET) : MODNAME := %(modname)
833 $(TMP_TARGET) : MODTYPE := %(modtype)
834 $(TMP_TARGET) : $(TMP_DEPS)
835 @$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
837 #------------------------------------------------------------------------------
839 #------------------------------------------------------------------------------
840 # Generate dummy support files so cxref when used on the a module source file
841 # will find something to include. This rule has to be preceeded by
842 # %rule_genmodule_makefile
843 %define rule_genmodule_dummy modname=/A modtype=/A modsuffix= conffile= targetdir=
845 ifneq ($(%(modname)_INCLUDES),)
846 TMP_TARGETS := $(%(modname)_INCLUDES)
848 TMP_DEPS := $(GENMODULE)
851 TMP_OPTS += -c %(conffile)
852 TMP_DEPS += %(conffile)
854 TMP_DEPS += %(modname).conf
856 ifneq (%(modsuffix),)
857 TMP_OPTS += -s %(modsuffix)
859 ifneq (%(targetdir),)
860 TMP_OPTS += -d %(targetdir)
861 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
864 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
865 $(TMP_TARGETS) : MODNAME := %(modname)
866 $(TMP_TARGETS) : MODTYPE := %(modtype)
867 $(TMP_TARGETS) : $(TMP_DEPS)
868 @$(ECHO) "Generating dummy include files"
869 @$(GENMODULE) $(OPTS) writedummy $(MODNAME) $(MODTYPE)
872 #------------------------------------------------------------------------------
875 #------------------------------------------------------------------------------
876 # Generate the support files for compiling a module. This includes include
877 # files and source files. This rule has to be preceeded by
878 # %rule_genmodule_makefile
879 %define rule_genmodule_files modname=/A modtype=/A modsuffix= targetdir= \
882 TMP_TARGETS := $(%(modname)_STARTFILES) $(%(modname)_ENDFILES) \
883 $(%(modname)_LINKLIBFILES)
884 TMP_TARGETS := $(addsuffix .c,$(TMP_TARGETS)) $(addsuffix .S, $(%(modname)_LINKLIBAFILES))
886 TMP_DEPS := $(GENMODULE)
887 ifeq ($(%(modname)_NEEDREF), yes)
889 $(error reffile needed in rule_genmodule_files but none specified)
891 TMP_OPTS := -r %(reffile)
892 TMP_DEPS += %(reffile)
897 TMP_OPTS += -c %(conffile)
898 TMP_DEPS += %(conffile)
900 TMP_DEPS += %(modname).conf
902 ifneq (%(modsuffix),)
903 TMP_OPTS += -s %(modsuffix)
905 ifneq (%(targetdir),)
906 TMP_OPTS += -d %(targetdir)
907 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
910 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
911 $(TMP_TARGETS) : MODNAME := %(modname)
912 $(TMP_TARGETS) : MODTYPE := %(modtype)
913 $(TMP_TARGETS) : $(TMP_DEPS)
914 @$(ECHO) "Generating functable and support files for module $(MODNAME$(BDID))"
915 ifneq (%(conffile),lib.conf)
916 @$(IF) $(TEST) -f lib.conf; then \
917 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
920 @$(IF) $(TEST) -f libdefs.h; then \
921 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
923 @$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
925 #------------------------------------------------------------------------------
927 #------------------------------------------------------------------------------
928 # Generate the support files for compiling a module. This includes include
929 # files and source files.
930 %define rule_genmodule_includes modname=/A modtype=/A modsuffix= \
931 targetdir= conffile= reffile=
934 ifneq ($(%(modname)_INCLUDES),)
935 TMP_TARGETS := $(%(modname)_INCLUDES)
937 TMP_DEPS := $(GENMODULE)
938 ifeq ($(%(modname)_NEEDREF), yes)
940 $(error reffile needed in rule_genmodule_files but none specified)
942 TMP_OPTS := -r %(reffile)
943 TMP_DEPS += %(reffile)
948 TMP_OPTS += -c %(conffile)
949 TMP_DEPS += %(conffile)
951 TMP_DEPS += %(modname).conf
953 ifneq (%(modsuffix),)
954 TMP_OPTS += -s %(modsuffix)
956 ifneq (%(targetdir),)
957 TMP_OPTS += -d %(targetdir)
958 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
961 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
962 $(TMP_TARGETS) : MODNAME := %(modname)
963 $(TMP_TARGETS) : MODTYPE := %(modtype)
964 $(TMP_TARGETS) : $(TMP_DEPS)
965 @$(ECHO) "Generating include files"
966 @$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
969 #------------------------------------------------------------------------------
971 #------------------------------------------------------------------------------
972 # Common rules for all makefiles
974 # Delete generated makefiles
977 @$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
979 include $(SRCDIR)/config/make.tail
981 BDID := $(BDTARGETID)
983 #------------------------------------------------------------------------------
986 #############################################################################
987 #############################################################################
989 ## Here are the mmakefile build macro's. These are macro's that takes care ##
990 ## of everything to go from the sources to the generated target. Also all ##
991 ## intermediate files and directories that are needed are created by these ##
994 #############################################################################
995 #############################################################################
997 #------------------------------------------------------------------------------
999 %define build_prog mmake=/A progname=/A files=$(BD_PROGNAME) asmfiles= \
1000 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1001 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
1002 aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
1007 BD_PROGNAME := %(progname)
1008 BD_OBJDIR := %(objdir)
1009 BD_TARGETDIR := %(targetdir)
1011 BD_FILES := %(files)
1012 BD_ASMFILES := %(asmfiles)
1013 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_FILES) $(BD_ASMFILES)))
1014 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1016 BD_CFLAGS := %(cflags)
1017 BD_AFLAGS := %(aflags)
1018 BD_DFLAGS := %(dflags)
1019 BD_LDFLAGS := %(ldflags)
1022 %(mmake)-quick : %(mmake)
1024 #MM %(mmake) : includes-generate-deps
1025 %(mmake) : $(BD_TARGETDIR)/$(BD_PROGNAME)
1027 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1028 %rule_compile basename=%(srcdir)% targetdir=$(BD_OBJDIR) \
1029 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1030 %rule_assemble_multi basenames=$(BD_ASMFILES) targetdir=$(BD_OBJDIR) \
1033 %rule_link_prog prog=$(BD_TARGETDIR)/$(BD_PROGNAME) \
1034 objs=$(BD_OBJS) ldflags=$(BD_LDFLAGS) \
1035 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1036 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)"
1040 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1042 $(BD_OBJS) $(BD_DEPS) : | $(BD_OBJDIR)
1043 $(BD_TARGETDIR)/$(BD_PROGNAME) : | $(BD_TARGETDIR)
1044 GLOB_MKDIRS += $(BD_OBJDIR) $(BD_TARGETDIR)
1046 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_TARGETDIR)/$(BD_PROGNAME) $(BD_DEPS)
1049 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1053 #------------------------------------------------------------------------------
1056 #------------------------------------------------------------------------------
1057 # Build programs, for every C file an executable will be built with the same
1059 %define build_progs mmake=/A files=/A nix=no \
1060 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1061 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
1062 uselibs= usehostlibs= usestartup=yes detach=no
1066 BD_OBJDIR := %(objdir)
1067 BD_TARGETDIR := %(targetdir)
1069 BD_FILES := %(files)
1070 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1071 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1072 BD_EXES := $(addprefix $(BD_TARGETDIR)/,$(BD_FILES))
1074 BD_CFLAGS := %(cflags)
1075 BD_DFLAGS := %(dflags)
1076 BD_LDFLAGS := %(ldflags)
1079 %(mmake)-quick : %(mmake)
1081 #MM %(mmake) : includes-generate-deps
1082 %(mmake) : $(BD_EXES)
1084 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1085 %rule_compile basename=% targetdir=$(BD_OBJDIR) nix=%(nix) \
1086 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1088 %rule_link_progs progs=$(BD_FILES) nix=%(nix) \
1089 targetdir=$(BD_TARGETDIR) objdir=$(BD_OBJDIR) \
1090 ldflags=$(BD_LDFLAGS) \
1091 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1092 usestartup="%(usestartup)" detach="%(detach)"
1096 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1098 $(addprefix $(BD_TARGETDIR)/,$(BD_FILES)) : | $(BD_TARGETDIR)
1099 $(BD_DEPS) $(BD_OBJS) : | $(BD_OBJDIR)
1100 GLOB_MKDIRS += $(BD_TARGETDIR) $(BD_OBJDIR)
1102 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_EXES) $(BD_DEPS)
1105 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1109 #------------------------------------------------------------------------------
1112 #------------------------------------------------------------------------------
1114 # This is a bare version: It just compiles and links the given files. It is
1115 # assumed that all needed boiler plate code is in the files. This should only
1116 # be used for compiling external code. For AROS code use %build_module
1117 %define build_module_simple mmake=/A modname=/A modtype=/A \
1118 files="$(basename $(wildcard *.c))" \
1119 cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1120 objdir=$(OBJDIR) moduledir= \
1121 uselibs= usehostlibs= compiler=target
1123 # Define metamake targets and their dependencies
1124 #MM %(mmake) : core-linklibs includes-generate-deps
1125 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1129 BD_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj
1131 .PHONY : $(BD_ALLTARGETS)
1134 $(error using %build_module_simple: modname may not be empty)
1137 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1140 # Default values for variables and arguments
1141 BD_DEFLINKLIBNAME := %(modname)
1142 BD_DEFREFFILE := %(objdir)/%(modname)_ALL.ref
1143 BD_DEFDFLAGS := %(cflags)
1144 OBJDIR ?= $(GENDIR)/$(CURDIR)
1145 BD_MODDIR := %(moduledir)
1146 ifeq ($(BD_MODDIR),)
1147 ifeq (%(modtype),library)
1148 BD_MODDIR := $(AROS_LIBS)
1150 ifeq (%(modtype),gadget)
1151 BD_MODDIR := $(AROS_GADGETS)
1153 ifeq (%(modtype),datatype)
1154 BD_MODDIR := $(AROS_DATATYPES)
1156 ifeq (%(modtype),handler)
1157 BD_MODDIR := $(AROS_FS)
1159 ifeq (%(modtype),device)
1160 BD_MODDIR := $(AROS_DEVS)
1162 ifeq (%(modtype),resource)
1163 BD_MODDIR := $(AROS_RESOURCES)
1165 ifeq (%(modtype),mui)
1166 BD_MODDIR := $(AROS_CLASSES)/Zune
1168 ifeq (%(modtype),mcc)
1169 BD_MODDIR := $(AROS_CLASSES)/Zune
1171 ifeq (%(modtype),mcp)
1172 BD_MODDIR := $(AROS_CLASSES)/Zune
1174 ifeq (%(modtype),hidd)
1175 BD_MODDIR := $(AROS_DRIVERS)
1178 ifeq ($(BD_MODDIR),)
1179 $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1182 %rule_compile_multi \
1183 basenames="%(files)" targetdir="%(objdir)" \
1184 cflags="%(cflags)" dflags="%(dflags)" \
1185 compiler=%(compiler)
1187 BD_MODULE := $(BD_MODDIR)/%(modname).%(modtype)
1188 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1190 %(mmake)-quick : %(mmake)
1191 %(mmake) : $(BD_MODULE)
1192 %(mmake)-kobj : $(BD_KOBJ)
1194 # The module is linked from all the compiled .o files
1195 BD_OBJS := $(addprefix %(objdir)/, $(addsuffix .o,%(files)))
1196 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1197 endobj= err=%(modname).err objdir=%(objdir) \
1198 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1200 # Link kernel object file
1201 BD_KAUTOLIB := workbench dos cybergraphics intuition layers graphics oop utility \
1203 BD_KBASE := WorkbenchBase DOSBase CyberGfxBase IntuitionBase LayersBase \
1204 GfxBase OOPBase UtilityBase ExpansionBase KeymapBase
1205 BD_KLIB := hiddgraphicsstubs hiddstubs amiga arossupport rom arosm autoinit libinit
1206 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1207 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1208 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_KBASE))
1209 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1210 @$(ECHO) "Linking $@"
1211 @$(AROS_LD) -Ur -o $@ $^ -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1212 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__$$/) || ($$3 ~ /^libraryset_.*$$/) {print "-L " $$3;}'`
1215 ## Dependency fine-tuning
1217 BD_DEPS := $(addprefix %(objdir), $(addsuffix .o,%(files)))
1218 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1220 $(BD_OBJS) $(BD_DEPS) $(BD_REFS) : | %(objdir)
1221 $(BD_MODULE) : | $(BD_MODDIR)
1222 $(BD_KOBJ) : | $(KOBJSDIR)
1223 GLOB_MKDIRS += %(objdir) $(BD_MODDIR) $(KOBJSDIR)
1225 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_MODULE) $(BD_KOBJ) $(BD_DEPS)
1227 @$(ECHO) "Cleaning up for module %(modname)"
1232 #------------------------------------------------------------------------------
1234 # Explanation of this macro is done in the developer's manual
1235 %define build_module mmake=/A modname=/A modtype=/A modsuffix= \
1236 conffile= files="$(basename $(wildcard *.c))" \
1237 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1238 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
1239 reffile=$(BD_DEFREFFILE) noref= \
1240 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
1243 # Define metamake targets and their dependencies
1244 #MM- includes-all : %(mmake)-includes
1245 #MM %(mmake) : %(mmake)-includes core-linklibs
1246 #MM %(mmake)-kobj : %(mmake)-includes core-linklibs
1247 #MM %(mmake)-linklib : %(mmake)-includes
1248 #MM %(mmake)-quick : %(mmake)-includes-quick
1249 #MM %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1250 #MM includes-generate-deps
1251 #MM %(mmake)-includes-quick
1252 #MM %(mmake)-includes-dirs
1253 #MM %(mmake)-makefile
1254 #MM %(mmake)-funclist
1257 # All MetaMake targets defined by this macro
1258 BD_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-includes \
1259 %(mmake)-includes-quick %(mmake)-includes-dirs %(mmake)-clean \
1260 %(mmake)-kobj %(mmake)-funclist %(mmake)-linklib
1262 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1265 $(error using %build_module: modname may not be empty)
1268 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1271 # Default values for variables and arguments
1272 BD_DEFLINKLIBNAME := %(modname)
1273 BD_DEFREFFILE := %(objdir)/%(modname)_ALL.ref
1274 BD_DEFDFLAGS := %(cflags)
1275 OBJDIR ?= $(GENDIR)/$(CURDIR)
1277 ## Create genmodule include Makefile for the module
1279 %(mmake)-makefile : %(objdir)/Makefile.%(modname)
1281 %rule_genmodule_makefile \
1282 modname=%(modname) modtype=%(modtype) \
1283 modsuffix=%(modsuffix) targetdir=%(objdir) \
1284 conffile=%(conffile)
1286 %(objdir)/Makefile.%(modname) : | %(objdir)
1288 GLOB_MKDIRS += %(objdir)
1290 # Do not parse these statements if metatarget is not appropriate
1291 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1293 include %(objdir)/Makefile.%(modname)
1295 BD_DEFMODDIR := $(%(modname)_MODDIR)
1298 ## include files generation
1300 BD_INCDIR := %(prefix)/$(AROS_DIR_INCLUDE)
1301 BD_LIBDEFSINC := %(objdir)/include/%(modname)_libdefs.h
1302 BD_DEFLIBDEFSINC := %(objdir)/include/%(modname)_deflibdefs.h
1304 %(mmake)-includes-quick : %(mmake)-includes
1305 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1306 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1307 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1309 ifneq ($(%(modname)_INCLUDES),)
1310 %rule_genmodule_includes modname=%(modname) modtype=%(modtype) \
1311 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1312 conffile=%(conffile) reffile=%(reffile)
1314 %rule_copy_diff_multi \
1315 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(GENINCDIR) \
1316 stampfile=%(objdir)/%(modname)_geninc
1318 %rule_copy_diff_multi \
1319 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(BD_INCDIR) \
1320 stampfile=%(objdir)/%(modname)_incs
1322 %rule_genmodule_dummy modname=%(modname) modtype=%(modtype) \
1323 modsuffix=%(modsuffix) \
1324 targetdir=%(objdir)/dummyinc conffile=%(conffile)
1326 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1328 TMP%(modname)_INCDIRS := \
1329 %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1330 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1331 $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1332 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget=%(mmake)-includes-dirs
1334 $(addprefix %(objdir)/dummyinc/,$(%(modname)_INCLUDES)) : | %(objdir)/dummyinc $(addprefix %(objdir)/dummyinc/,$(BD_INCDIRS))
1335 GLOB_MKDIRS += %(objdir)/dummyinc $(addprefix %(objdir)/dummyinc/,$(BD_INCDIRS))
1339 %rule_genmodule_genlibdefs modname=%(modname) modtype=%(modtype) \
1340 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1341 conffile=%(conffile)
1343 $(BD_DEFLIBDEFSINC) : FILENAME := $(BD_LIBDEFSINC)
1344 $(BD_DEFLIBDEFSINC) :
1345 @$(ECHO) "generating $@"
1346 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1348 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) : | %(objdir)/include
1349 GLOB_MKDIRS += %(objdir)/include
1351 ## Generation of the funclist file
1353 %(mmake)-funclist : %(modname).funclist
1355 %rule_genmodule_funclist \
1356 modname=%(modname) modtype=%(modtype) modsuffix=%(modsuffix) \
1357 conffile=%(conffile) reffile=%(reffile)
1360 ## Extra genmodule src files generation
1362 %rule_genmodule_files modname=%(modname) modtype=%(modtype) \
1363 modsuffix=%(modsuffix) targetdir=%(objdir) \
1364 conffile=%(conffile) reffile=%(reffile)
1368 BD_FILES := %(files)
1369 BD_FDIRS := $(sort $(dir $(BD_FILES)))
1370 BD_STARTFILES := $(addprefix %(objdir)/,$(%(modname)_STARTFILES))
1371 BD_ENDFILES := $(addprefix %(objdir)/,$(%(modname)_ENDFILES))
1373 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1374 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1375 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1377 TMP_QUOTE := $(CFLAGS_IQUOTE) $(TOP)/$(CURDIR) \
1378 $(addprefix $(CFLAGS_IQUOTE),$(BD_FDIRS)) \
1379 $(CFLAGS_IQUOTE_END)
1380 BD_CFLAGS := $(TMP_QUOTE) %(cflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1381 BD_DFLAGS := $(TMP_QUOTE) %(dflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1383 BD_LINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBFILES))
1384 BD_LINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBAFILES))
1385 ifeq ($(strip $(%(modname)_LINKLIBFILES) %(linklibfiles)),)
1388 BD_LINKLIB := %(prefix)/$(AROS_DIR_LIB)/lib%(linklibname).a
1390 BD_LINKLIBFILES := $(BD_LINKLIBCFILES) $(BD_LINKLIBAFILES)
1392 BD_CCFILES := $(BD_NARCHFILES) %(linklibfiles)
1393 BD_TARGETCCFILES := $(BD_STARTFILES) $(BD_ENDFILES) $(BD_LINKLIBCFILES)
1395 %rule_compile_multi \
1396 basenames=$(BD_CCFILES) targetdir=%(objdir) \
1397 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) \
1398 compiler=%(compiler)
1399 %rule_compile_multi \
1400 basenames=$(BD_TARGETCCFILES) targetdir=%(objdir) \
1401 cflags="$(BD_CFLAGS) -D__AROS__" dflags=$(BD_DFLAGS) \
1402 compiler=%(compiler)
1404 ifneq ($(BD_LINKLIBAFILES),)
1405 %rule_assemble_multi \
1406 basenames=$(BD_LINKLIBAFILES) targetdir=%(objdir) suffix=.S
1409 ## function reference files generation
1411 BD_CFLAGS_REF := -I$(dir $(GENMODULE))/genmod_inc -I%(objdir)/dummyinc $(strip %(cflags)) -I$(TOP)/$(CURDIR) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1413 basenames=$(BD_FILES) targetdir=%(objdir) \
1414 cflags=$(BD_CFLAGS_REF) \
1415 compiler=%(compiler)
1418 BD_REFS := $(addprefix %(objdir)/,$(addsuffix .ref, $(notdir $(BD_FILES))))
1420 BD_REFS := $(addprefix %(objdir)/,$(addsuffix .ref, $(notdir $(filter-out %(noref),$(BD_FILES)))))
1423 %rule_join from=$(BD_REFS) to=%(reffile) \
1424 text="Collecting function references for module %(modname)"
1429 ifeq (%(modsuffix),)
1430 BD_MODULE := %(prefix)/%(moduledir)/%(modname).%(modtype)
1431 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1433 BD_MODULE := %(prefix)/%(moduledir)/%(modname).%(modsuffix)
1434 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modsuffix).o
1437 %(mmake)-quick : %(mmake)
1438 %(mmake) : $(BD_MODULE) $(BD_LINKLIB)
1439 %(mmake)-kobj : $(BD_KOBJ) $(BD_LINKLIB)
1440 %(mmake)-linklib : $(BD_LINKLIB)
1442 BD_OBJS := $(addsuffix .o,$(BD_STARTFILES)) $(BD_ARCHOBJS) \
1443 $(addsuffix .o, $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES))))
1444 BD_ENDOBJS := $(addsuffix .o,$(BD_ENDFILES))
1445 BD_LINKLIBOBJS:= $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_LINKLIBFILES)) \
1448 # The module is linked from all the compiled .o files
1449 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1450 endobj=$(BD_ENDOBJS) err=%(modname).err objdir=%(objdir) \
1451 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1454 ifneq ($(BD_LINKLIB),)
1455 %rule_link_linklib libname=%(linklibname) objs=$(BD_LINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1457 $(BD_LINKLIB) : | %(prefix)/$(AROS_DIR_LIB)
1458 GLOB_MKDIRS += %(prefix)/$(AROS_DIR_LIB)
1461 # Link kernel object file
1462 BD_KAUTOLIB := workbench dos cybergraphics intuition layers graphics oop utility \
1464 BD_KBASE := WorkbenchBase DOSBase CyberGfxBase IntuitionBase LayersBase \
1465 GfxBase OOPBase UtilityBase ExpansionBase KeymapBase
1466 BD_KLIB := hiddgraphicsstubs hiddstubs amiga arossupport rom arosm autoinit libinit
1467 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1468 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1469 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_KBASE))
1470 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1471 @$(ECHO) "Linking $@"
1472 @$(AROS_LD) -Ur -o $@ $^ -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1473 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__$$/) || ($$3 ~ /^libraryset_.*$$/) {print "-L " $$3;}'`
1475 ## Dependency fine-tuning
1477 BD_DEPS := $(addsuffix .d,$(addprefix %(objdir)/,$(notdir $(BD_CCFILES) $(BD_TARGETCCFILES))))
1478 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1480 $(BD_OBJS) $(BD_DEPS) $(BD_REFS) : | %(objdir)
1481 $(BD_MODULE) : | %(prefix)/%(moduledir)
1482 $(BD_KOBJ) : | $(KOBJSDIR)
1483 GLOB_MKDIRS += %(objdir) %(prefix)/%(moduledir) $(KOBJSDIR)
1485 # Some include files need to be generated before the .c can be parsed.
1486 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj),) # Only for this target these deps are wanted
1487 BD_REFFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
1488 $(addprefix %(objdir)/dummyinc/,$(%(modname)_INCLUDES))
1489 $(BD_REFS) : $(BD_REFFILE_DEPS) $(dir $(GENMODULE))/genmod_inc/aros/libcall.h
1491 BD_DFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
1492 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES))
1493 $(BD_DEPS) : $(BD_DFILE_DEPS)
1496 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) %(reffile) \
1497 $(BD_REFS) $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
1498 %(objdir)/Makefile.%(modname) \
1499 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
1500 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1501 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1502 %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
1503 $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
1504 $(BD_DEFLIBDEFSINC) $(addsuffix .c,$(BD_STARTFILES) $(BD_ENDFILES)) \
1506 %(mmake)-clean : FILES := $(BD_TOCLEAN)
1508 @$(ECHO) "Cleaning up for module %(modname)"
1511 endif # $(TARGET) in $(BD_ALLTARGETS)
1513 #------------------------------------------------------------------------------
1516 #------------------------------------------------------------------------------
1518 # - mmake is the mmaketarget
1519 # - libname is the baselibname e.g. lib%(libname).a will be created
1520 # - files are the C source files to include in the lib. The list of files
1521 # has to be given without the .c suffix
1522 # - asmfiles are the asm files to include in the lib. The list of files has to
1523 # be given without the .s suffix
1524 # - objs additional object to link into the linklib. The objects have to be
1525 # given with full absolute path and the .o suffix.
1526 # - cflags are the flags to compile the source (default $(CFLAGS))
1527 # - dflags are the flags use during makedepend (default equal to cflags)
1528 # - aflags are the flags use during assembling (default $(AFLAGS))
1529 # - objdir is where the .o are generated
1530 # - libdir is the directory where the linklib will be placed (default $(LIBDIR))
1531 %define build_linklib mmake=/A libname=/A \
1532 files="$(basename $(wildcard *.c))" asmfiles= objs= \
1533 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) objdir=$(OBJDIR) libdir=$(LIBDIR)
1535 # assign and generate the local variables used in this macro
1536 OBJDIR ?= $(GENDIR)/$(CURDIR)
1538 BD_FILES := %(files)
1539 BD_ASMFILES := %(asmfiles)
1541 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1542 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1543 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1545 BD_OBJS := $(BD_ARCHOBJS) \
1546 $(addsuffix .o,$(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES) $(BD_ASMFILES)))) \
1548 BD_DEPS := $(patsubst %.o,%.d,$(BD_OBJS))
1550 BD_CFLAGS := %(cflags)
1552 BD_DFLAGS := $(BD_CFLAGS)
1554 BD_DFLAGS := %(dflags)
1556 BD_AFLAGS := %(aflags)
1558 BD_LINKLIB := %(libdir)/lib%(libname).a
1560 .PHONY : %(mmake) %(mmake)-clean
1562 #MM %(mmake) : includes-generate-deps
1563 %(mmake) : $(BD_LINKLIB)
1567 @$(RM) $(BD_OBJS) $(BD_DEPS)
1569 ifeq ($(TARGET),%(mmake))
1570 ifneq ($(dir $(BD_FILES)),./)
1571 vpath %.c $(filter-out ./,$(dir $(BD_FILES)))
1574 %rule_compile basename=% targetdir=%(objdir) \
1575 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1576 %rule_assemble basename=% targetdir=%(objdir) \
1580 %rule_link_linklib libname=%(libname) objs=$(BD_OBJS) libdir=%(libdir)
1582 %include_deps depstargets=%(mmake) deps=$(BD_DEPS)
1584 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1585 $(BD_LINKLIB) : | %(libdir)
1586 GLOB_MKDIRS += %(objdir) %(libdir)
1589 #------------------------------------------------------------------------------
1592 #------------------------------------------------------------------------------
1594 # - mmake is the mmaketarget
1595 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
1596 # - description is the catalog description file (.cd) (default *.cd)
1597 # - subdir is the destination subdir of the catalogs
1598 # - name is the name of the destination catalog, without the .catalog suffix
1599 # - source is the path to the generated source code file
1600 # - dir is the base destination directory (default $(AROS_CATALOGS))
1601 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
1603 %define build_catalogs mmake=/A name=/A subdir=/A \
1604 catalogs="$(basename $(wildcard *.ct))" source="../strings.h" \
1605 description="$(basename $(wildcard *.cd))" dir=$(AROS_CATALOGS) \
1606 sourcedescription="$(TOOLDIR)/C_h_orig"
1608 BD_SRCS := $(addsuffix .ct, %(catalogs))
1609 BD_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, %(catalogs)))
1610 BD_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, %(catalogs)))
1613 %(mmake) : $(BD_OBJS) %(source)
1615 $(BD_OBJS) : | $(BD_DIRS)
1616 GLOB_MKDIRS += $(BD_DIRS)
1618 %(dir)/%/%(subdir)/%(name).catalog : %.ct %(description).cd
1619 @$(ECHO) "Creating %(name) catalog for language $*."
1620 @$(FLEXCAT) %(description).cd $*.ct CATALOG=%(dir)/$*/%(subdir)/%(name).catalog || [ $$? -lt 10 ]
1623 %(source) : %(description).cd
1624 @$(ECHO) "Creating %(name) catalog source file %(source)"
1625 @$(FLEXCAT) %(description).cd %(source)=%(sourcedescription).sd
1628 %(mmake)-clean : FILES := $(BD_OJS) %(source)
1633 .PHONY: %(mmake) %(mmake)-clean
1637 #-----------------------------------------------------------------------------
1639 #-----------------------------------------------------------------------------
1641 # - mmake is the mmaketarget
1642 # - icons is a list of icon base names (ie. without the .info suffix)
1643 # - dir is the destination directory
1644 #-----------------------------------------------------------------------------
1646 %define build_icons mmake=/A icons=/A dir=/A
1648 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
1651 %(mmake) : $(BD_OBJS)
1653 %(dir)/%.info : %.info.src %.png
1654 @$(ECHO) Creating $(notdir $@)...
1655 @$(ILBMTOICON) $+ $@
1657 $(BD_OBJS) : | %(dir)
1658 GLOB_MKDIRS += %(dir)
1660 %(mmake)-clean : FILES := $(BD_OBJS)
1665 .PHONY: %(mmake) %(mmake)-clean
1669 #-----------------------------------------------------------------------------
1671 #------------------------------------------------------------------------------
1672 # Compile files for an arch-specific replacement of code for a module
1673 # - files: the basenames of the C files to compile.
1674 # - asmfiles: the basenames of the asm files to assemble.
1675 # - mainmmake: the mmake of the module in the main directory to compile these
1676 # arch specific files for.
1677 # - maindir: the object directory for the main module
1678 # - arch: the arch for which to compile these files. It can have the form
1679 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
1680 # - cflags (default $(CFLAGS)): the C flags to use for compilation
1681 # - dflags: the flags used during creation of dependency file. If not specified
1682 # the same value as cflags will be used
1683 # - aflags: the flags used during assembling
1684 # - compiler: (host, kernel or target) specifies which compiler to use. By default
1685 # the target compiler is used
1686 %define build_archspecific files= asmfiles= mainmmake=/A maindir=/A arch=/A \
1687 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
1689 ifeq (%(files) %(asmfiles),)
1690 $(error no files or asmfiles given)
1693 %buildid targets="%(mainmmake)-%(arch)"
1695 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1696 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1697 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1699 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
1702 $(error argument arch has to be non empty for the rule_compile_archspecific macro)
1705 BD_OBJDIR$(BDID) := $(GENDIR)/%(maindir)/arch
1706 BD_COBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1707 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
1708 BD_OBJS$(BDID) := $(BD_COBJS$(BDID)) $(BD_ASMOBJS$(BDID))
1709 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1711 ifeq ($(TARGET),%(mainmmake)-%(arch))
1712 vpath %.c $(filter-out ./,$(dir %(files)))
1713 vpath %.s $(filter-out ./,$(dir %(asmfiles)))
1714 vpath %.S $(filter-out ./,$(dir %(asmfiles)))
1717 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID))
1718 GLOB_MKDIRS += $(BD_OBJDIR$(BDID))
1721 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
1723 ifeq ($(findstring %(compiler),host kernel target),)
1724 $(error unknown compiler %(compiler))
1726 ifeq (%(compiler),target)
1727 $(BD_COBJS$(BDID)) : TMP_CMD:=$(TARGET_CC)
1729 ifeq (%(compiler),host)
1730 $(BD_COBJS$(BDID)) : TMP_CMD:=$(HOST_CC)
1732 ifeq (%(compiler),kernel)
1733 $(BD_COBJS$(BDID)) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
1735 ifneq (%(modulename),)
1736 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) \
1737 -include $(GENDIR)/%(maindir)/include/%(modulename)_deflibdefs.h
1739 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
1741 ifeq ($(TARGET),%(mainmmake)-%(arch))
1742 $(BD_OBJDIR$(BDID))/%.o : %.c
1743 %compile_q opt=$(TMP_CFLAGS) cmd=$(TMP_CMD)
1747 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags)
1749 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
1751 ifeq ($(TARGET),%(mainmmake)-%(arch))
1752 $(BD_OBJDIR$(BDID))/%.d : %.c
1753 %mkdepend_q flags=$(TMP_DFLAGS)
1756 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
1758 ifeq ($(TARGET),%(mainmmake)-%(arch))
1759 $(BD_OBJDIR$(BDID))/%.o : %.s
1760 %assemble_q opt=$(AFLAGS)
1761 $(BD_OBJDIR$(BDID))/%.o : %.S
1762 %assemble_q opt=$(AFLAGS)
1765 %include_deps depstargets=%(mainmmake)-%(arch) deps=$(BD_DEPS$(BDID))
1767 #------------------------------------------------------------------------------
1775 # ======================
1776 # Old stuff, will probably be removed in the future
1781 # GNU Make automatic variables
1783 # $< First dependency
1784 # $? All newer dependencies
1785 # $^ All dependencies
1786 # $* The stem (ie. target is dir/a.foo.b and the pattern is
1787 # a.%.b, then the stem is dir/foo)
1789 #------------------------------------------------------------------------------
1790 # rule to generate libdefs.h with archtool (options may go away!)
1791 %define libdefs_rule conffile=lib.conf genlibdefstool=$(ARCHTOOL) dest=libdefs.h
1792 %(dest) : %(conffile) %(genlibdefstool)
1793 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
1794 @%(genlibdefstool) -c -o $@ %(conffile)
1798 #------------------------------------------------------------------------------
1799 # generate asm files from c files (for debugging purposes)
1802 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
1803 @$(TARGET_CC) -S $(CFLAGS) $< -c -o $@
1806 #------------------------------------------------------------------------------
1807 # Convert two png images to an Amiga icon file based on the description
1808 # file %(from), with outputfile going to %(to).
1809 %define makeicon2 from=$< to=$@ img1="$(basename $(basename $<))_N.png" img2="$(basename $(basename $<))_S.png"
1810 @$(ECHO) "Creating icon %(to)..."
1811 @$(PNGTOPNM) %(img1) | $(PPMTOILBM) -maxplanes 8 >$(GENDIR)/genicon1.iff
1812 @$(PNGTOPNM) %(img2) | $(PPMTOILBM) -maxplanes 8 >$(GENDIR)/genicon2.iff
1813 @$(ILBMTOICON) %(from) $(GENDIR)/genicon1.iff $(GENDIR)/genicon2.iff %(to)
1816 #------------------------------------------------------------------------------
1817 # NOTE: The following are all part of Iain's build changes, please don't use
1818 # or change anything below this line until you know what you are doing. This
1819 # is so that I don't conflict with the semantics of any of the above macros.
1820 #------------------------------------------------------------------------------
1822 #------------------------------------------------------------------------------
1823 # Copy files from one directory to another.
1825 %define copy_files_q files=$(FILES) src=. dst=/A maketarget=files-copy
1827 %(maketarget) : setup
1828 $(foreach file, %(files), $(shell $(CP) $(addprefix %(src)/, $(file)) $(addprefix %(dst)/, $(file))))
1835 #----------------------------------------------------------------------------------
1836 # Copy a diretory recursively to another place, preserving the original
1837 # hierarchical structure
1839 # src: the source directory whose content will be copied
1840 # dst: the directory where to copy src's content. If not existing, it will be made.
1842 %define copy_dir_recursive mmake=/A src=$(TOP)/$(CURDIR) dst=/A
1844 %(mmake)_FILES := $(shell cd %(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)
1845 %(mmake)_DIRS := $(sort $(dir $(%(mmake)_FILES)))
1847 define %(mmake)_mkdir
1852 define %(mmake)_copy
1853 $(3)/$(1): $(2)/$(1) | $(dir $(3)/$(1))
1860 %(mmake): | $(GENDIR)/$(CURDIR)
1861 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1862 $(ECHO) "all: $(addprefix \$$(DST)/,$(%(mmake)_FILES))" > $$m
1863 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1864 for d in $(%(mmake)_DIRS); do \
1865 $(ECHO) "\$$(DST)/$$d: ; $(MKDIR) \$$@" >> $$m; \
1867 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1868 for f in $(%(mmake)_FILES); do \
1869 $(ECHO) "\$$(DST)/$$f: \$$(SRC)/$$f | \$$(dir \$$(DST)/$$f); $(CP) \$$< \$$@" >> $$m; \
1871 for dst in %(dst); do \
1872 $(MAKE) -f $$m DST=$$dst SRC=%(src) all; \
1875 $(GENDIR)/$(CURDIR):
1880 #------------------------------------------------------------------------------
1881 # Copy include files into the includes directories. There are currently
1882 # two include directories. One for building AROS $(AROS_INCLUDES) and one
1883 # for building tools that need to run on the host system $(GENINCDIR). The
1884 # $(GENINCDIR) path must not contain any references to the C runtime
1885 # library header files.
1887 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
1888 dir= compiler=target
1890 ifeq ($(findstring %(compiler),host kernel target),)
1891 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
1895 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),%(includes))
1896 BD_INC_PATH := %(dir)/
1898 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
1902 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
1906 ifeq (%(compiler),target)
1909 BD_INCL_FILES2 := $(subst %(dir),$(AROS_INCLUDES)/%(path),%(includes))
1911 BD_INCL_FILES2 := $(addprefix $(AROS_INCLUDES)/%(path)/,%(includes))
1914 BD_INCL_FILES += $(BD_INCL_FILES2)
1916 $(BD_INCL_FILES2) : $(AROS_INCLUDES)/%(path)/% : $(BD_INC_PATH)%
1921 %(mmake) : $(BD_INCL_FILES)
1925 $(BD_INCL_FILES) : | $(dir $(BD_INCL_FILES))
1926 GLOB_MKDIRS += $(dir $(BD_INCL_FILES))
1930 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
1931 STUBS_SRC := $(addsuffix .c,$(STUBS))
1932 STUBS_MEM := $(addsuffix .o,$(STUBS))
1933 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
1934 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
1935 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
1937 #MM- linklibs : hidd-%(hidd)-stubs
1938 #MM- %(parenttarget): hidd-%(hidd)-stubs
1939 #MM hidd-%(hidd)-stubs : includes includes-copy
1940 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
1942 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
1945 $(STUBS_OBJ) : $(STUBS_SRC)
1946 %compile_q cmd=$(TARGET_CC) opt=%(cflags)
1948 $(STUBS_DEP) : $(STUBS_SRC)
1949 %mkdepend_q flags=%(dflags)
1952 %mkdirs_q $(OBJDIR) $(LIBDIR)
1956 -@$(RM) $(HIDD_LIB) $(OBJDIR)
1958 DEPS := $(DEPS) $(STUBS_DEP)
1962 #------------------------------------------------------------------------------
1963 # Build an imported source tree which uses the configure script from the
1964 # autoconf package. This rule will try to "integrate" the produced files as
1965 # much as possible in the AROS build, for example by putting libraries in the
1966 # standard library directory, includes in the standard include directory, and
1967 # so on. You can however override this behaviour.
1969 # As a special "bonus" for you, the PROGDIR environment variable is defined to
1970 # be %(bindir) (or its deduced value) when running "make install", and
1971 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
1972 # configure script some more parameters whose value depends upon the PROGDIR
1973 # env var, so that the program gets all its stuff installed in the proper place
1974 # when building it, but when running it from inside AROS it can also find that
1975 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
1976 # the configuration parameters set when running ./configure
1978 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
1979 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
1980 # to the name which has to follow it.
1983 %define build_with_configure mmake=/A package= srcdir=$(TOP)/$(CURDIR) prefix= \
1984 aros_prefix= extraoptions= nix_dir_layout= nix=no compiler=target \
1985 install_target=install postconfigure= postinstall= \
1989 %(mmake)-prefix := %(prefix)
1991 %(mmake)-prefix := $(AROS_CONTRIB)
1994 ifneq (%(aros_prefix),)
1995 %(mmake)-aros_prefix := %(aros_prefix)
1997 %(mmake)-aros_prefix := $(%(mmake)-prefix)
2001 %(mmake)-nix := -nix
2002 %(mmake)-volpfx := /
2003 %(mmake)-volsfx := /
2005 ifeq (%(nix_dir_layout),)
2006 %(mmake)-nix_dir_layout := yes
2009 %(mmake)-volsfx := :
2011 ifeq (%(nix_dir_layout),)
2012 %(mmake)-nix_dir_layout := no
2016 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
2018 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
2019 exec_prefix=$(%(mmake)-prefix) %(install_env)
2021 # Check if chosen compiler is valid
2022 ifeq ($(findstring %(compiler),host target kernel),)
2023 $(error unknown compiler %(compiler))
2026 # Set legacy 'host' variable based on chosen compiler
2027 ifeq (%(compiler),host)
2030 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
2032 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
2037 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
2039 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
2043 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
2044 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
2046 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
2047 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
2048 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2051 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
2052 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
2054 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2057 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
2059 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
2060 sbindir=$(%(mmake)-prefix) \
2061 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
2062 oldincludedir=$(AROS_INCLUDES) %(install_env)
2066 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
2068 #MM- %(mmake) : setup includes linklibs-core %(mmake)-quick
2070 # Using -j1 in install_command may result in a warning but finally
2071 # it does its job. make install for gcc does not work reliable for -jN
2073 ifneq (%(install_target),)
2074 %(mmake)-install_command = \
2075 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2076 -C $(%(mmake)-pkgdir) %(install_target) -j1 && \
2077 $(TOUCH) $(%(mmake)-installflag)
2079 %(mmake)-uninstall_command = \
2080 $(RM) $(%(mmake)-installflag) && \
2081 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2082 -C $(%(mmake)-pkgdir) uninstall
2084 %(mmake)-install_command := true
2085 %(mmake)-uninstall_command := true
2088 #MM- %(mmake)-quick : %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
2091 %(mmake)-build_and_install-quick : $(%(mmake)-configflag)
2092 if ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q -C $(%(mmake)-pkgdir); then \
2093 $(RM) $(%(mmake)-installflag) && \
2094 $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -C $(%(mmake)-pkgdir) && \
2095 $(%(mmake)-install_command); \
2098 %(srcdir)/.files-touched:
2099 find %(srcdir) -exec $(TOUCH) -r %(srcdir)/configure '{}' \; && \
2103 %(mmake)-uninstall :
2104 $(%(mmake)-uninstall_command)
2106 ifneq ($(DEBUG),yes)
2107 %(mmake)-s_flag = -s
2111 %(mmake)-configure : $(%(mmake)-configflag)
2113 ifeq (%(compiler),host)
2114 $(%(mmake)-configflag) : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2116 %mkdirs_q $(%(mmake)-pkgdir)
2117 cd $(%(mmake)-pkgdir) && \
2118 find . -name config.cache -exec $(RM) '{}' \; && \
2120 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) && \
2123 ifeq (%(compiler),target)
2124 $(%(mmake)-configflag) : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2126 %mkdirs_q $(%(mmake)-pkgdir)
2127 cd $(%(mmake)-pkgdir) && \
2128 find . -name config.cache -exec $(RM) '{}' \; && \
2129 CC="$(TARGET_CC) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2130 AS="$(TARGET_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)" \
2131 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) \
2132 --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH) \
2133 --host=$(AROS_TARGET_CPU)-aros \
2134 --target=$(AROS_TARGET_CPU)-aros \
2136 --without-x --without-pic --disable-shared && \
2139 ifeq (%(compiler),kernel)
2140 $(%(mmake)-configflag) : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2142 %mkdirs_q $(%(mmake)-pkgdir)
2143 cd $(%(mmake)-pkgdir) && \
2144 find . -name config.cache -exec $(RM) '{}' \; && \
2145 CC="$(KERNEL_CC) $(KERNEL_CFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2146 AS="$(TARGET_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)" \
2147 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) \
2148 --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH) \
2149 --host=$(AROS_TARGET_CPU)-aros \
2150 --target=$(AROS_TARGET_CPU)-aros --disable-nls \
2151 --without-x --without-pic --disable-shared && \
2156 %(mmake)-clean : %(mmake)-uninstall
2157 @$(RM) $(%(mmake)-pkgdir)
2160 #############################################################################
2161 #############################################################################
2163 ## Miscellaneous macros. Everything that doesn't fit above should be put ##
2166 #############################################################################
2167 #############################################################################
2169 #----------------------------------------------------------------------------------
2170 # Given an archive name, patches names and locations where to find them, fetch
2171 # the archive and the patches from any of those locations, unpack the archive
2172 # and then apply the patches.
2174 # Locations currently supported are http and ftp sites, plus local filesystem
2175 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
2176 # the fetch.sh script needs to be modified, since this macro relies on that script.
2180 # - archive_origins = list of locations where to find the archive. They are tried
2181 # in sequence, until the archive is found and fetching it
2182 # succeeded. If not specified, the current directory is assumed.
2183 # - archive = the archive name. Mandatory.
2184 # - suffixes = a list of suffixes to append to the the package name plus the
2185 # version. Each one of them is tried until a matching archive is
2186 # found. They are appended to patches and these are tried the
2187 # same way as packages are.
2188 # - destination = the local directory where to put the archive and patches.
2189 # If not specified, the current directory is assumed.
2190 # - patches_origins = list of locations where to find the patches. They are tried
2191 # in sequence, until a patch is found and fetching it
2192 # succeeded. If not specified, the current directory is assumed.
2193 # - patches_specs = list of "patch specs". A patch spec is of the form
2194 # patch_name[:[patch_subdir][:patch_opt]].
2196 # - patch_name = the name of the patch file
2197 # - patch_subdir = the directory within \destination\ where to
2199 # - patch_opt = any options to pass to the `patch' command
2200 # when applying the patch.
2202 # The patch_subdir and patch_opt fields are optional.
2204 %define fetch archive_origins=. archive=/A suffixes= location=%destination destination=. patches_origins=. patches_specs=::
2205 $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l %(location) -d %(destination) \
2206 -po "%(patches_origins)" -p %(patches_specs)
2209 #-----------------------------------------------------------------------------------------
2210 # Joins the features of %fetch and %build_with_configure, taking advantage of
2211 # the naming scheme of GNU packages. GNU packages names are in the form
2213 # <package name>-<version number>.<archive format suffix>
2215 # If a patch is provided, it *must* be named the following way:
2217 # <package name>-<version number>-aros.diff
2219 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
2220 # CD'ing into the archive's extracted directory.
2222 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
2223 # the %fetch_and_build macro only accept *one* patch for each package. It's up to you
2224 # to make that patch fully comprehensive.
2226 # NOTE: GNU packages are always compiled with *nix semantics turned on.
2230 # - mmake = the meta make target, as would be supplied to the %build_with_configure
2232 # - package = the GNU package name, sans version and archive format suffixes.
2233 # - version = the package's version number, or otherwise any other version string.
2234 # It gets appended to the package name to form the basename of the archive.
2235 # - suffixes = a list of suffixes to apped to the the package name plus the
2236 # version. Each one of them is tried until a matching archive is found.
2237 # Defaults to "tar.bz2 tar.gz".
2238 # - destination = same meaning as the one for the %fetch macro
2239 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
2240 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
2242 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
2243 # - prefix = same meaning as the one for the %build_with_configure macro. Defaults to
2245 # - aros_prefix = same meaning as the one for the %build_with_configure macro. Defaults to
2247 # - extraoptions = same meaning as the one for the %build_with_configure macro.
2248 # - postinstall = same meaning as the one for the %build_with_configure macro.
2250 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target version=/A suffixes="tar.bz2 tar.gz" \
2251 srcdir= package_repo= patch=no patch_repo= prefix= \
2252 aros_prefix= extraoptions= postconfigure= postinstall= nix=no nix_dir_layout=
2254 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
2255 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
2256 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
2258 %(mmake)-archbase := %(package)-%(version)
2260 ifeq (%(compiler),host)
2261 %(mmake)-portdir := $(HOSTDIR)/Ports/%(package)
2263 %(mmake)-portdir := $(PORTSDIR)/%(package)
2267 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
2269 %(mmake)-prefix := %(prefix)
2272 ifneq (%(subpackage),)
2273 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
2275 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
2279 %(mmake)-%(subpackage)-srcdir := %(srcdir)
2281 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
2285 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-p1
2287 %(mmake)-%(subpackage)-patches_specs := ::
2290 .PHONY : %(mmake)-%(subpackage)-fetch
2292 %(mmake)-%(subpackage)-fetch :
2293 %fetch archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
2294 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
2295 archive_origins=". %(package_repo)" \
2296 patches_specs="$(%(mmake)-%(subpackage)-patches_specs)" patches_origins=". %(patch_repo)"
2298 #MM- %(mmake) : %(mmake)-%(subpackage)
2300 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
2302 %(mmake)-%(subpackage)-package-basename := \
2303 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
2305 %build_with_configure mmake=%(mmake)-%(subpackage) package=%(package) compiler=%(compiler) \
2306 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-srcdir) \
2307 nix=%(nix) nix_dir_layout=%(nix_dir_layout) prefix="$(%(mmake)-prefix)" \
2308 aros_prefix="%(aros_prefix)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
2309 %(mmake)-%(subpackage)-make-package" extraoptions="%(extraoptions)"
2311 .PHONY : %(mmake)-%(subpackage)-make-package
2312 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
2315 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package-basename).tar.bz2
2317 #There seems to be a bug, either with my clock or with make, 'cause it may happen
2318 #that $^ and $@ have exactly the same mtime, and in that case make tries
2319 #to rebuild $@ again, which would fail because the directory where
2320 #the package got installed would not exist anymore.
2321 #We work this around by using an if statement to manually check the mtimes.
2322 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
2323 @$(IF) test $(%(mmake)-installflag) -nt $@ || ! test -f $@; then \
2325 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
2326 mkdir -p "$(DISTDIR)/Packages" ; \
2327 mkdir -p "$(%(mmake)-prefix)" ; \
2328 cd $(%(mmake)-%(subpackage)-package-dir) ; \
2329 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
2330 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
2334 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2335 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
2336 aros_prefix=/GNU extraoptions= postconfigure= postinstall=
2338 GNU_REPOSITORY := gnu://
2340 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
2341 suffixes="%(suffixes)" srcdir="%(srcdir)" \
2342 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
2343 patch="%(patch)" patch_repo="%(patch_repo)" \
2344 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" \
2345 postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=yes
2349 #-----------------------------------------------------------------------------------------
2350 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
2351 # that the package is a "Development" package, and as such it needs to be placed
2352 # under the $(AROS_DEVELOPMENT) directory, as a default.
2354 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
2355 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
2356 # "mmake" argument, because the metatarget is implicitely defined as
2358 # #MM- development-%(package)
2360 %define fetch_and_build_gnu_development package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2361 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPMENT) \
2362 aros_prefix=/Development postconfigure= postinstall= extraoptions=
2364 #MM- development : development-%(package)
2367 %fetch_and_build_gnu mmake=development-%(package) package=%(package) subpackage="%(subpackage)" \
2368 version=%(version) suffixes="%(suffixes)" srcdir="%(srcdir)" \
2369 package_repo="%(package_repo)" patch="%(patch)" patch_repo="%(patch_repo)" prefix=%(prefix) \
2370 aros_prefix="%(aros_prefix)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" \
2371 extraoptions="%(extraoptions)"