1 ############################################################################
2 #############################################################################
4 ## Here are the mmakefile macro's that are used as commands in the body ##
6 ## They are used to help the portability of mmakefile 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 $(notdir %(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=$(AS) opt=$(AFLAGS) from=$< to=$@
36 @$(ECHO) "Assembling $(notdir %(from))..."
37 @$(IF) %(cmd) %(opt) -c %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
38 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
39 $(ECHO) "$(notdir %(from)): %(cmd) %(opt) -c %(from) -o %(to)" >> $(GENDIR)/errors ; \
40 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
45 $(ECHO) "Assemble failed: %(cmd) %(opt) -c %(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) : SRCDIR := %(srcdir)
201 %(stampfile) : TGTDIR := %(targetdir)
202 %(stampfile) : FILES := %(files)
203 %(stampfile) : $(addprefix %(srcdir)/,%(files))
204 @for f in $(FILES); do \
205 $(IF) ! $(CMP) -s $(SRCDIR)/$$f $(TGTDIR)/$$f ; then \
206 $(CP) $(SRCDIR)/$$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 # Rule to generate a functable
266 %define rule_genfunctable name=functable files=/A dir=. libdefs=libdefs.h
268 %(dir)/%(name).c : $(addsuffix .c,%(files)) $(SCRIPTDIR)/genfunctable.awk %(libdefs)
269 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
271 $(AWK) -v file=%(libdefs) -f $(SCRIPTDIR)/genfunctable.awk $(addsuffix .c,%(files)) > $@
277 #------------------------------------------------------------------------------
280 #------------------------------------------------------------------------------
281 # Generate a rule to compile a C source file to an object file and generate
282 # the dependency file. Basename may contain a directory part, then the source
283 # file has to be in that directory. The generated file will be put in the
284 # object directory without the directory.
286 # - basename: the basename of the file to compile. Use % for a wildcard rule
287 # - cflags (default $(CFLAGS)): the C flags to use for compilation
288 # - dflags: the flags used during creation of dependency file. If not specified
289 # the same value as cflags will be used
290 # - targetdir: the directory to put the .o file and the .d file. By default
291 # it is put in the same directory as the .c file
292 %define rule_compile basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target
295 TMP_TARGETBASE := %(basename)
297 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
300 ifeq ($(findstring %(compiler),host target),)
301 $(error unknown compiler %(compiler))
303 ifeq (%(compiler),target)
304 $(TMP_TARGETBASE).o : TMP_CMD:=$(TARGET_CC)
305 $(TMP_TARGETBASE).d : TMP_CMD:=$(TARGET_CC)
307 ifeq (%(compiler),host)
308 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
309 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
312 $(TMP_TARGETBASE).o : %(basename).c
313 %compile_q opt="%(cflags)" cmd=$(TMP_CMD)
316 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(cflags)
318 $(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 stripped from the file names so that all files are in
339 # that dir and not in subdirectories.
340 %define rule_compile_multi basenames=/A cflags=$(CFLAGS) dflags= targetdir= \
344 TMP_TARGETS := $(addsuffix .o,%(basenames))
345 TMP_DTARGETS := $(addsuffix .d,%(basenames))
348 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
349 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
350 TMP_WILDCARD := %(targetdir)/%
352 # Be sure that all .c files are generated
353 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .c,%(basenames))
355 # Be sure that all .c files are found
356 TMP_DIRS := $(filter-out ./,$(sort $(dir %(basenames))))
358 vpath %.c $(TMP_DIRS)
363 ifeq ($(findstring %(compiler),host target),)
364 $(error unknown compiler %(compiler))
366 ifeq (%(compiler),target)
367 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TARGET_CC)
369 ifeq (%(compiler),host)
370 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_CC)
373 $(TMP_TARGETS) : CFLAGS := %(cflags)
374 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.c
375 %compile_q cmd=$(CMD)
378 $(TMP_DTARGETS) : DFLAGS:=%(cflags)
380 $(TMP_DTARGETS) : DFLAGS:=%(dflags)
382 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.c
383 %mkdepend_q cc=$(CMD) flags=$(DFLAGS)
385 #------------------------------------------------------------------------------
388 #------------------------------------------------------------------------------
389 # Make an alias from one arch specific build to another arch.
391 # - mainmmake: the mmake of the module in the main tree
392 # - arch: the current arch
393 # - alias: the alias to which this should point
394 %define rule_archalias mainmmake=\A arch=\A alias=\A
396 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
398 #------------------------------------------------------------------------------
401 #------------------------------------------------------------------------------
402 # Generate a rule to compile a C source file to an shared object file with a
403 # .so suffix. Basename may contain a directory part, then the source
404 # file has to be in that directory. The generated file will be put in the
405 # object directory without the directory.
407 # - basename: the basename of the file to compile. Use % for a wildcard rule
408 # - cflags (default $(CFLAGS)): the C flags to use for compilation
409 # - targetdir: the directory to put the .o file and the .d file. By default
410 # it is put in the same directory as the .c file
411 %define rule_compile_shared basename=/A cflags=$(CFLAGS) targetdir= compiler=target
414 TMP_TARGETBASE := %(basename)
416 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
419 ifeq ($(findstring %(compiler),host target),)
420 $(error unknown compiler %(compiler))
422 ifeq (%(compiler),target)
423 $(TMP_TARGETBASE).so : TMP_CMD:=$(TARGET_CC)
425 ifeq (%(compiler),host)
426 $(TMP_TARGETBASE).so : TMP_CMD:=$(HOST_CC)
429 $(TMP_TARGETBASE).so : %(basename).c
430 %compile_q opt="$(SHARED_CFLAGS) %(cflags)" cmd=$(TMP_CMD)
432 #------------------------------------------------------------------------------
435 #------------------------------------------------------------------------------
436 # Generate a rule to assemble a source file to an object file. Basename may
437 # contain a directory part, then the source file has to be in that directory.
438 # The generated file will be put in the object directory without the directory.
440 # - basename: the basename of the file to compile. Use % for a wildcard rule
441 # - flags (default $(AFLAGS)): the asm flags to use for assembling
442 # - targetdir: the directory to put the .o file. By default it is put in the
443 # same directory as the .s file
444 %define rule_assemble basename=/A flags=$(AFLAGS) targetdir=
447 %(basename).o : %(basename).s
448 %assemble_q opt=%(flags)
451 %(targetdir)/$(notdir %(basename)).o : %(basename).s
452 %assemble_q opt=%(flags)
456 #------------------------------------------------------------------------------
459 #------------------------------------------------------------------------------
460 # Generate a rule to assemble multiple source files to an object file. The
461 # generated file will be put in the object directory with the directory part
462 # of the source file stripped of.
464 # - basenames: the basenames of the files to compile. The names may include
465 # relative or absolute path names. No wildcard is allowed
466 # - aflags (default $(AFLAGS)): the C flags to use for compilation
467 # - targetdir: the directory to put the .o file and the .d file. By default
468 # it is put in the same directory as the .c file. When targetdir is not
469 # empty, path names will stripped from the file names so that all files are in
470 # that dir and not in subdirectories.
471 %define rule_assemble_multi basenames=/A aflags=$(AFLAGS) targetdir= suffix=.s
474 TMP_TARGETS := $(addsuffix .o,%(basenames))
477 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
478 TMP_WILDCARD := %(targetdir)/%
480 # Be sure that all .s files are generated
481 $(TMP_TARGETS) : | $(addsuffix %(suffix),%(basenames))
483 # Be sure that all .c files are found
484 TMP_DIRS := $(filter-out ./,$(sort $(dir %(basenames))))
486 vpath %%(suffix) $(TMP_DIRS)
491 $(TMP_TARGETS) : AFLAGS := %(aflags)
492 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %%(suffix)
493 %assemble_q opt=$(AFLAGS)
495 #------------------------------------------------------------------------------
498 #------------------------------------------------------------------------------
499 # Link %(objs) to %(prog) using the libraries in %(uselibs)
500 %define rule_link_prog prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
501 usehostlibs= usestartup=yes detach=no nix=no
505 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
507 ifeq (%(usestartup),no)
508 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
511 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
513 %(prog) : EXTRA_LDFLAGS:=$(TMP_EXTRA_LDFLAGS)
515 %(prog) : %(objs) $(addprefix $(LIBDIR)/lib,$(addsuffix .a,%(uselibs) libinit autoinit))
516 %link_q from="%(objs)" opt="%(ldflags) $(EXTRA_LDFLAGS)" \
517 libs="$(addprefix -l,%(uselibs)) $(addprefix -l,%(usehostlibs))"
519 #------------------------------------------------------------------------------
522 #------------------------------------------------------------------------------
523 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
524 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
525 %define rule_link_progs progs=/A targetdir=$(AROSDIR)/$(CURDIR) \
526 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
527 usestartup=yes detach=no
531 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
533 ifeq (%(usestartup),no)
534 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
537 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
539 $(addprefix %(targetdir)/,%(progs)) : EXTRA_LDFLAGS:=$(TMP_EXTRA_LDFLAGS)
541 $(addprefix %(targetdir)/,%(progs)) : %(targetdir)/% : %(objdir)/%.o \
542 $(addprefix $(LIBDIR)/lib,$(addsuffix .a,%(uselibs) libinit autoinit))
543 %link_q from=$< opt="%(ldflags) $(EXTRA_LDFLAGS)" \
544 libs="$(addprefix -l,%(uselibs)) $(addprefix -l,%(usehostlibs))"
546 #------------------------------------------------------------------------------
549 #------------------------------------------------------------------------------
550 # Link the %(objs) to the library %(libdir)/lib%(libname).a in
551 %define rule_link_linklib libname=/A objs=/A libdir=$(LIBDIR)
553 %(libdir)/lib%(libname).a : %(objs)
556 #------------------------------------------------------------------------------
559 #------------------------------------------------------------------------------
560 # Link the %(objs) to the library %(libdir)/lib%(libname).so in
561 %define rule_link_shlib libname=/A objs=/A libdir=$(LIBDIR)
563 %(libdir)/lib%(libname).so : %(objs)
564 @$(SHARED_LD) $(SHARED_LDFLAGS) -o $@ $^
566 #------------------------------------------------------------------------------
569 #------------------------------------------------------------------------------
570 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
571 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
572 %define rule_linkmodule module=/A objs=/A endobj=/A err=/A uselibs= usehostlibs=
574 %(module) : OBJS := %(objs)
575 %(module) : ENDTAG := %(endobj)
576 %(module) : ERR := %(err)
577 %(module) : LIBS := $(addprefix -l,%(uselibs)) -lautoinit -llibinit -L/usr/lib $(addprefix -l,%(usehostlibs))
578 %(module) : %(objs) %(endobj) $(addprefix $(LIBDIR)/lib,$(addsuffix .a,%(uselibs) libinit autoinit))
579 %link_module_q err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS)
582 #------------------------------------------------------------------------------
585 #------------------------------------------------------------------------------
586 # Generate a rule to generate a function reference file from a C source file.
587 # Basename may contain a directory part, then the source file has to be in that
588 # directory. The generated file will be put in the object directory without the
591 # - basename: the basename of the file to compile. Use % for a wildcard rule
592 # - cflags (default $(CFLAGS)): the C flags to use for compilation
593 # - targetdir: the directory to put the generated .ref file. By default the
594 # .ref file will be put in the same directory as the .c file.
595 # - includefile: This file will be included at the head of the source file
596 %define rule_ref basename=/A cflags=$(CFLAGS) targetdir= includefile= compiler=target
599 GENFILE_TMP := %(basename).ref
601 GENFILE_TMP := %(targetdir)/$(notdir %(basename)).ref
604 ifeq ($(filter %(compiler),target host),)
605 $(error use of %rule_ref: compiler has to be 'host' or 'target')
608 ifeq (%(compiler),target)
609 $(GENFILE_TMP) : CC:=$(TARGET_CC)
611 $(GENFILE_TMP) : CC:=$(HOST_CC)
614 $(GENFILE_TMP) : %(basename).c $(CXREF) %(includefile)
615 ifeq (%(includefile),)
616 %mkref_q cc=$(CC) cflags="%(cflags)"
618 %mkref_q cc=$(CC) cflags="%(cflags) -include %(includefile)"
622 #------------------------------------------------------------------------------
625 #------------------------------------------------------------------------------
626 # Generate a rule to generate a function reference file from a C source file.
627 # Basename may contain a directory part, then the source file has to be in that
628 # directory. The generated file will be put in the object directory without the
631 # - basenames: the basenames of the files to compile. No wildcard is allowed
632 # - cflags (default $(CFLAGS)): the C flags to use for compilation
633 # - targetdir: the directory to put the generated .ref file. By default the
634 # .ref file will be put in the same directory as the .c file. When targetdir
635 # is not empty all files will be put there and path parts in the basenames
636 # will be stripped off.
637 # - includefile: This file will be included at the head of the source file
638 %define rule_ref_multi basenames=/A cflags=$(CFLAGS) targetdir= includefile= \
642 TMP_TARGETS := $(addsuffix .ref,%(basenames))
643 TMP_WILDCARD := %.ref
645 TMP_TARGETS := $(addprefix %(targetdir)/,$(addsuffix .ref,$(notdir %(basenames))))
646 TMP_WILDCARD := %(targetdir)/%.ref
648 # Be sure that all .c files are generated
649 $(TMP_TARGETS) : | $(addsuffix .c,%(basenames))
651 # Be sure that all .c files are found
652 TMP_DIRS := $(filter-out ./,$(sort $(dir %(basenames))))
654 vpath %.c $(TMP_DIRS)
659 ifeq ($(filter %(compiler),target host),)
660 $(error use of %rule_ref: compiler has to be 'host' or 'target')
663 ifeq (%(compiler),target)
664 $(TMP_TARGETS) : CC:=$(TARGET_CC)
666 $(TMP_TARGETS) : CC:=$(HOST_CC)
668 ifeq (%(includefile),)
669 $(TMP_TARGETS) : CFLAGS:=%(cflags)
671 $(TMP_TARGETS) : CFLAGS:="%(cflags) -include %(includefile)"
672 $(TMP_TARGETS) : %(includefile)
674 $(TMP_TARGETS) : $(CXREF)
675 $(TMP_TARGETS) : $(TMP_WILDCARD) : %.c
678 #------------------------------------------------------------------------------
681 #------------------------------------------------------------------------------
682 # Generate the libdefs.h include file for a module.
683 %define rule_genmodule_genlibdefs modname=/A modtype=/A modsuffix= conffile= targetdir=
685 TMP_TARGET := %(modname)_libdefs.h
686 TMP_DEPS := $(GENMODULE)
689 TMP_OPTS += -c %(conffile)
690 TMP_DEPS += %(conffile)
692 TMP_DEPS += %(modname).conf
694 ifneq (%(modsuffix),)
695 TMP_OPTS += -s %(modsuffix)
697 ifneq (%(targetdir),)
698 TMP_OPTS += -d %(targetdir)
699 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
702 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
703 $(TMP_TARGET) : MODNAME := %(modname)
704 $(TMP_TARGET) : MODTYPE := %(modtype)
705 $(TMP_TARGET) : $(TMP_DEPS)
706 @$(ECHO) "Generating $(notdir $@)"
707 @$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
709 #------------------------------------------------------------------------------
712 #------------------------------------------------------------------------------
713 # Generate the libdefs.h include file for a module.
714 %define rule_genmodule_funclist \
715 modname=/A modtype=/A modsuffix= conffile= targetdir= reffile=
717 TMP_TARGET := %(modname).funclist
718 TMP_DEPS := $(GENMODULE)
721 $(error reffile needed in rule_genmodule_funclist but none specified)
723 TMP_OPTS := -r %(reffile)
724 TMP_DEPS += %(reffile)
726 TMP_OPTS += -c %(conffile)
727 TMP_DEPS += %(conffile)
729 TMP_DEPS += %(modname).conf
731 ifneq (%(modsuffix),)
732 TMP_OPTS += -s %(modsuffix)
734 ifneq (%(targetdir),)
735 TMP_OPTS += -d %(targetdir)
736 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
739 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
740 $(TMP_TARGET) : MODNAME := %(modname)
741 $(TMP_TARGET) : MODTYPE := %(modtype)
742 $(TMP_TARGET) : $(TMP_DEPS)
743 @$(ECHO) "Generating $(notdir $@)"
744 @$(GENMODULE) $(OPTS) writefunclist $(MODNAME) $(MODTYPE)
746 #------------------------------------------------------------------------------
749 #------------------------------------------------------------------------------
750 # Generate a Makefile.%(modname) with the genmodule program and include this
751 # generated file in this Makefile
752 %define rule_genmodule_makefile modname=/A modtype=/A modsuffix= conffile= \
755 TMP_TARGET := Makefile.%(modname)
756 TMP_DEPS := $(GENMODULE)
759 TMP_OPTS += -c %(conffile)
760 TMP_DEPS += %(conffile)
762 TMP_DEPS += %(modname).conf
764 ifneq (%(modsuffix),)
765 TMP_OPTS += -s %(modsuffix)
767 ifneq (%(targetdir),)
768 TMP_OPTS += -d %(targetdir)
769 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
772 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
773 $(TMP_TARGET) : MODNAME := %(modname)
774 $(TMP_TARGET) : MODTYPE := %(modtype)
775 $(TMP_TARGET) : $(TMP_DEPS)
776 @$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
778 #------------------------------------------------------------------------------
780 #------------------------------------------------------------------------------
781 # Generate dummy support files so cxref when used on the a module source file
782 # will find something to include. This rule has to be preceeded by
783 # %rule_genmodule_makefile
784 %define rule_genmodule_dummy modname=/A modtype=/A modsuffix= conffile= targetdir=
786 ifneq ($(%(modname)_INCLUDES),)
787 TMP_TARGETS := $(%(modname)_INCLUDES)
789 TMP_DEPS := $(GENMODULE)
792 TMP_OPTS += -c %(conffile)
793 TMP_DEPS += %(conffile)
795 TMP_DEPS += %(modname).conf
797 ifneq (%(modsuffix),)
798 TMP_OPTS += -s %(modsuffix)
800 ifneq (%(targetdir),)
801 TMP_OPTS += -d %(targetdir)
802 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
805 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
806 $(TMP_TARGETS) : MODNAME := %(modname)
807 $(TMP_TARGETS) : MODTYPE := %(modtype)
808 $(TMP_TARGETS) : $(TMP_DEPS)
809 @$(ECHO) "Generating dummy include files"
810 @$(GENMODULE) $(OPTS) writedummy $(MODNAME) $(MODTYPE)
813 #------------------------------------------------------------------------------
816 #------------------------------------------------------------------------------
817 # Generate the support files for compiling a module. This includes include
818 # files and source files. This rule has to be preceeded by
819 # %rule_genmodule_makefile
820 %define rule_genmodule_files modname=/A modtype=/A modsuffix= targetdir= \
823 TMP_TARGETS := $(%(modname)_STARTFILES) $(%(modname)_ENDFILES) \
824 $(%(modname)_LINKLIBFILES)
825 TMP_TARGETS := $(addsuffix .c,$(TMP_TARGETS)) $(addsuffix .S, $(%(modname)_LINKLIBAFILES))
827 TMP_DEPS := $(GENMODULE)
828 ifeq ($(%(modname)_NEEDREF), yes)
830 $(error reffile needed in rule_genmodule_files but none specified)
832 TMP_OPTS := -r %(reffile)
833 TMP_DEPS += %(reffile)
838 TMP_OPTS += -c %(conffile)
839 TMP_DEPS += %(conffile)
841 TMP_DEPS += %(modname).conf
843 ifneq (%(modsuffix),)
844 TMP_OPTS += -s %(modsuffix)
846 ifneq (%(targetdir),)
847 TMP_OPTS += -d %(targetdir)
848 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
851 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
852 $(TMP_TARGETS) : MODNAME := %(modname)
853 $(TMP_TARGETS) : MODTYPE := %(modtype)
854 $(TMP_TARGETS) : $(TMP_DEPS)
855 @$(ECHO) "Generating functable and support files for module $(BD_MODNAME$(BDID))"
856 ifneq (%(conffile),lib.conf)
857 @$(IF) $(TEST) -f lib.conf; then \
858 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
861 @$(IF) $(TEST) -f libdefs.h; then \
862 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
864 @$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
866 #------------------------------------------------------------------------------
868 #------------------------------------------------------------------------------
869 # Generate the support files for compiling a module. This includes include
870 # files and source files.
871 %define rule_genmodule_includes modname=/A modtype=/A modsuffix= \
872 targetdir= conffile= reffile=
875 ifneq ($(%(modname)_INCLUDES),)
876 TMP_TARGETS := $(%(modname)_INCLUDES)
878 TMP_DEPS := $(GENMODULE)
879 ifeq ($(%(modname)_NEEDREF), yes)
881 $(error reffile needed in rule_genmodule_files but none specified)
883 TMP_OPTS := -r %(reffile)
884 TMP_DEPS += %(reffile)
889 TMP_OPTS += -c %(conffile)
890 TMP_DEPS += %(conffile)
892 TMP_DEPS += %(modname).conf
894 ifneq (%(modsuffix),)
895 TMP_OPTS += -s %(modsuffix)
897 ifneq (%(targetdir),)
898 TMP_OPTS += -d %(targetdir)
899 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
902 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
903 $(TMP_TARGETS) : MODNAME := %(modname)
904 $(TMP_TARGETS) : MODTYPE := %(modtype)
905 $(TMP_TARGETS) : $(TMP_DEPS)
906 @$(ECHO) "Generating include files"
907 @$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
910 #------------------------------------------------------------------------------
912 #------------------------------------------------------------------------------
913 # Common rules for all makefiles
915 # Delete generated makefiles
918 @$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
920 include $(TOP)/config/make.tail
922 BDID := $(BDTARGETID)
924 #------------------------------------------------------------------------------
927 #############################################################################
928 #############################################################################
930 ## Here are the mmakefile build macro's. These are macro's that takes care ##
931 ## of everything to go from the sources to the generated target. Also all ##
932 ## intermediate files and directories that are needed are created by these ##
935 #############################################################################
936 #############################################################################
938 #------------------------------------------------------------------------------
940 %define build_prog mmake=/A progname=/A files=$(BD_PROGNAME$(BDID)) asmfiles= \
941 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
942 cflags=$(CFLAGS) dflags=$(BD_CFLAGS$(BDID)) ldflags=$(LDFLAGS) \
943 aflags=$(AFLAFS) uselibs= usehostlibs= usestartup=yes detach=no nix=no
947 %buildid targets="%(mmake) %(mmake)-clean %(mmake)-quick"
949 BD_PROGNAME$(BDID) := %(progname)
950 BD_OBJDIR$(BDID) := %(objdir)
951 BD_TARGETDIR$(BDID) := %(targetdir)
953 BD_FILES$(BDID) := %(files)
954 BD_ASMFILES$(BDID) := %(asmfiles)
955 BD_OBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(BD_FILES$(BDID)) $(BD_ASMFILES$(BDID))))
956 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(BD_FILES$(BDID))))
958 BD_CFLAGS$(BDID) := %(cflags)
959 BD_AFLAGS$(BDID) := %(aflags)
960 BD_DFLAGS$(BDID) := %(dflags)
961 BD_LDFLAGS$(BDID) := %(ldflags)
964 %(mmake)-quick : %(mmake)
967 %(mmake) : $(BD_TARGETDIR$(BDID))/$(BD_PROGNAME$(BDID))
969 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
970 %rule_compile basename=% targetdir=$(BD_OBJDIR$(BDID)) \
971 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID))
972 %rule_assemble basename=% targetdir=$(BD_OBJDIR$(BDID)) \
973 flags=$(BD_AFLAGS$(BDID))
975 %rule_link_prog prog=$(BD_TARGETDIR$(BDID))/$(BD_PROGNAME$(BDID)) \
976 objs=$(BD_OBJS$(BDID)) ldflags=$(BD_LDFLAGS$(BDID)) \
977 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
978 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)"
982 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS$(BDID))
984 $(BD_OBJS$(BDID)) $(BD_DEPS$(BDID)) : | $(BD_OBJDIR$(BDID))
985 $(BD_TARGETDIR$(BDID))/$(BD_PROGNAME$(BDID)) : | $(BD_TARGETDIR$(BDID))
986 GLOB_MKDIRS += $(BD_OBJDIR$(BDID)) $(BD_TARGETDIR$(BDID))
989 #------------------------------------------------------------------------------
992 #------------------------------------------------------------------------------
993 # Build programs, for every C file an executable will be built with the same
995 %define build_progs mmake=/A files=/A \
996 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
997 cflags=$(CFLAGS) dflags=$(BD_CFLAGS$(BDID)) ldflags=$(LDFLAGS) \
998 uselibs= usehostlibs= usestartup=yes detach=no
1002 %buildid targets="%(mmake) %(mmake)-clean %(mmake)-quick"
1004 BD_OBJDIR$(BDID) := %(objdir)
1005 BD_TARGETDIR$(BDID) := %(targetdir)
1007 BD_FILES$(BDID) := %(files)
1008 BD_OBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(BD_FILES$(BDID))))
1009 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(BD_FILES$(BDID))))
1010 BD_EXES$(BDID) := $(addprefix $(BD_TARGETDIR$(BDID))/,$(BD_FILES$(BDID)))
1012 BD_CFLAGS$(BDID) := %(cflags)
1013 ifneq ($(strip $(filter arosc_shared,%(uselibs))),)
1014 BD_CFLAGS$(BDID) += -D_CLIB_LIBRARY_ -I$(TOP)/rom/exec
1016 BD_DFLAGS$(BDID) := %(dflags)
1017 BD_LDFLAGS$(BDID) := %(ldflags)
1020 %(mmake)-quick : %(mmake)
1023 %(mmake) : $(BD_EXES$(BDID))
1025 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1026 %rule_compile basename=% targetdir=$(BD_OBJDIR$(BDID)) \
1027 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID))
1029 %rule_link_progs progs=$(BD_FILES$(BDID)) \
1030 targetdir=$(BD_TARGETDIR$(BDID)) objdir=$(BD_OBJDIR$(BDID)) \
1031 ldflags=$(BD_LDFLAGS$(BDID)) \
1032 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1033 usestartup="%(usestartup)" detach="%(detach)"
1037 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS$(BDID))
1039 $(addprefix $(BD_TARGETDIR$(BDID))/,$(BD_FILES$(BDID))) : | $(BD_TARGETDIR$(BDID))
1040 $(BD_DEPS$(BDID)) $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID))
1041 GLOB_MKDIRS += $(BD_TARGETDIR$(BDID)) $(BD_OBJDIR$(BDID))
1044 #------------------------------------------------------------------------------
1047 #------------------------------------------------------------------------------
1049 # This is a bare version: It just compiles and links the given files. It is
1050 # assumed that all needed boiler plate code is in the files. This should only
1051 # be used for compiling external code. For AROS code use %build_module
1052 %define build_module_simple mmake=/A modname=/A modtype=/A \
1053 files="$(basename $(wildcard *.c))" \
1054 cflags=$(CFLAGS) dflags=$(BD_DEFDFLASGS) \
1055 objdir=$(OBJDIR) moduledir= \
1056 uselibs= usehostlibs= compiler=target
1058 # Define metamake targets and their dependencies
1059 #MM %(mmake) : core-linklibs includes-generate-deps
1060 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1064 BD_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj
1066 .PHONY : $(BD_ALLTARGETS)
1069 $(error using %build_module_simple: modname may not be empty)
1072 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1075 # Default values for variables and arguments
1076 BD_DEFLINKLIBNAME := %(modname)
1077 BD_DEFREFFILE := %(objdir)/%(modname)_ALL.ref
1078 BD_DEFDFLAGS := %(cflags)
1079 OBJDIR ?= $(GENDIR)/$(CURDIR)
1080 BD_MODDIR := %(moduledir)
1081 ifeq ($(BD_MODDIR),)
1082 ifeq (%(modtype),library)
1083 BD_MODDIR := $(AROS_LIBS)
1085 ifeq (%(modtype),gadget)
1086 BD_MODDIR := $(AROS_GADGETS)
1088 ifeq (%(modtype),datatype)
1089 BD_MODDIR := $(AROS_DATATYPES)
1091 ifeq (%(modtype),handler)
1092 BD_MODDIR := $(AROS_FS)
1094 ifeq (%(modtype),device)
1095 BD_MODDIR := $(AROS_DEVS)
1097 ifeq (%(modtype),resource)
1098 BD_MODDIR := $(AROS_RESOURCES)
1100 ifeq (%(modtype),mui)
1101 BD_MODDIR := $(AROS_CLASSES)/Zune
1103 ifeq (%(modtype),mcc)
1104 BD_MODDIR := $(AROS_CLASSES)/Zune
1106 ifeq (%(modtype),mcp)
1107 BD_MODDIR := $(AROS_CLASSES)/Zune
1109 ifeq (%(modtype),hidd)
1110 BD_MODDIR := $(AROS_DRIVERS)
1113 ifeq ($(BD_MODDIR),)
1114 $(error Don't where to put the file for modtype %(modtype). Specify moduledir=)
1117 %rule_compile_multi \
1118 basenames="%(files)" targetdir="%(objdir)" \
1119 cflags="%(cflags)" dflags="%(dflags)" \
1120 compiler=%(compiler)
1122 BD_MODULE := $(BD_MODDIR)/%(modname).%(modtype)
1123 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1125 %(mmake)-quick : %(mmake)
1126 %(mmake) : $(BD_MODULE)
1127 %(mmake)-kobj : $(BD_KOBJ)
1129 # The module is linked from all the compiled .o files
1130 BD_OBJS := $(addprefix %(objdir)/, $(addsuffix .o,%(files)))
1131 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1132 endobj= err=%(modname).err \
1133 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1135 # Link kernel object file
1136 BD_KAUTOLIB := workbench dos cybergraphics intuition layers graphics oop utility \
1138 BD_KBASE := WorkbenchBase DOSBase CyberGfxBase IntuitionBase LayersBase \
1139 GfxBase OOPBase UtilityBase ExpansionBase KeymapBase
1140 BD_KLIB := hiddgraphicsstubs hiddstubs amiga arossupport rom arosm autoinit libinit
1141 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1142 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1143 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_KBASE))
1144 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1145 @$(ECHO) "Linking $@"
1146 @$(AROS_LD) -Ur -o $@ $^ -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1147 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__$$/) || ($$3 ~ /^libraryset_.*$$/) {print "-L " $$3;}'`
1150 ## Dependency fine-tuning
1152 BD_DEPS := $(addprefix %(objdir), $(addsuffix .o,%(files)))
1153 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1155 $(BD_OBJS) $(BD_DEPS) $(BD_REFS) : | %(objdir)
1156 $(BD_MODULE) : | $(BD_MODDIR)
1157 $(BD_KOBJ) : | $(KOBJSDIR)
1158 GLOB_MKDIRS += %(objdir) $(BD_MODDIR) $(KOBJSDIR)
1160 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_MODULE) $(BD_KOBJ) $(BD_DEPS)
1162 @$(ECHO) "Cleaning up for module %(modname)"
1163 @$(RM) $(BD_OBJS) $(BD_KOBJ)
1167 #------------------------------------------------------------------------------
1169 # Explanation of this macro is done in the developer's manual
1170 %define build_module mmake=/A modname=/A modtype=/A modsuffix= \
1171 conffile= files="$(basename $(wildcard *.c))" \
1172 linklibfiles= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1173 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
1174 reffile=$(BD_DEFREFFILE) noref= \
1175 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
1176 compiler=target genincludes=
1178 # Define metamake targets and their dependencies
1179 #MM- includes-all : %(mmake)-includes
1180 #MM %(mmake) : %(mmake)-includes core-linklibs
1181 #MM %(mmake)-kobj : %(mmake)-includes core-linklibs
1182 #MM %(mmake)-linklib : %(mmake)-includes
1183 #MM %(mmake)-quick : %(mmake)-includes-quick
1184 #MM %(mmake)-includes : %(mmake)-makefile includes-generate-deps
1185 #MM %(mmake)-includes-quick
1186 #MM %(mmake)-makefile
1187 #MM %(mmake)-funclist
1190 # All MetaMake targets defined by this macro
1191 BD_ALLTARGETS := %(mmake) %(mmake)-includes %(mmake)-clean %(mmake)-quick \
1192 %(mmake)-kobj %(mmake)-funclist %(mmake)-linklib
1194 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1197 $(error using %build_module: modname may not be empty)
1200 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1203 # Default values for variables and arguments
1204 BD_DEFLINKLIBNAME := %(modname)
1205 BD_DEFREFFILE := %(objdir)/%(modname)_ALL.ref
1206 BD_DEFDFLAGS := %(cflags)
1207 OBJDIR ?= $(GENDIR)/$(CURDIR)
1209 ## Create genmodule include Makefile for the module
1211 %(mmake)-makefile : %(objdir)/Makefile.%(modname)
1213 %rule_genmodule_makefile \
1214 modname=%(modname) modtype=%(modtype) \
1215 modsuffix=%(modsuffix) targetdir=%(objdir) \
1216 conffile=%(conffile)
1218 %(objdir)/Makefile.%(modname) : | %(objdir)
1220 GLOB_MKDIRS += %(objdir)
1222 # Do not parse these statements if metatarget is not appropriate
1223 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1225 include %(objdir)/Makefile.%(modname)
1227 BD_DEFMODDIR := $(%(modname)_MODDIR)
1230 ## include files generation
1232 BD_INCDIR := %(prefix)/$(AROS_DIR_INCLUDE)
1233 ifeq (%(genincludes),yes)
1234 %(modname)_INCLUDES := proto/%(modname).h clib/%(modname)_protos.h defines/%(modname).h
1236 ifeq (%(genincludes),no)
1237 %(modname)_INCLUDES :=
1239 BD_LIBDEFSINC := %(objdir)/%(modname)_libdefs.h
1240 BD_DEFLIBDEFSINC := %(objdir)/%(modname)_deflibdefs.h
1242 %(mmake)-includes-quick : %(mmake)-includes
1243 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1244 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1245 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1247 ifneq ($(%(modname)_INCLUDES),)
1248 %rule_genmodule_includes modname=%(modname) modtype=%(modtype) \
1249 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1250 conffile=%(conffile) reffile=%(reffile)
1252 %rule_copy_diff_multi \
1253 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(GENINCDIR) \
1254 stampfile=%(objdir)/%(modname)_geninc
1256 %rule_copy_diff_multi \
1257 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(BD_INCDIR) \
1258 stampfile=%(objdir)/%(modname)_incs
1260 %rule_genmodule_dummy modname=%(modname) modtype=%(modtype) \
1261 modsuffix=%(modsuffix) \
1262 targetdir=%(objdir)/dummyinc conffile=%(conffile)
1264 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1265 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) : | %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS))
1266 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) : | $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS))
1267 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) : | $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1268 $(addprefix %(objdir)/dummyinc/,$(%(modname)_INCLUDES)) : | %(objdir)/dummyinc $(addprefix %(objdir)/dummyinc/,$(BD_INCDIRS))
1269 GLOB_MKDIRS += %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1270 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1271 $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS)) \
1272 %(objdir)/dummyinc $(addprefix %(objdir)/dummyinc/,$(BD_INCDIRS))
1276 %rule_genmodule_genlibdefs modname=%(modname) modtype=%(modtype) \
1277 modsuffix=%(modsuffix) targetdir=%(objdir) \
1278 conffile=%(conffile)
1280 BD_LIBDEFSINC := %(objdir)/%(modname)_libdefs.h
1282 %(objdir)/%(modname)_deflibdefs.h : FILENAME := $(BD_LIBDEFSINC)
1283 %(objdir)/%(modname)_deflibdefs.h :
1284 @$(ECHO) "generating $@"
1285 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1288 ## Generation of the funclist file
1290 %(mmake)-funclist : %(modname).funclist
1292 %rule_genmodule_funclist \
1293 modname=%(modname) modtype=%(modtype) modsuffix=%(modsuffix) \
1294 conffile=%(conffile) reffile=%(reffile)
1297 ## Extra genmodule src files generation
1299 %rule_genmodule_files modname=%(modname) modtype=%(modtype) \
1300 modsuffix=%(modsuffix) targetdir=%(objdir) \
1301 conffile=%(conffile) reffile=%(reffile)
1305 BD_FILES := %(files)
1306 BD_STARTFILES := $(addprefix %(objdir)/,$(%(modname)_STARTFILES))
1307 BD_ENDFILES := $(addprefix %(objdir)/,$(%(modname)_ENDFILES))
1309 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1310 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1311 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1313 BD_CFLAGS := %(cflags) -I%(objdir) -idirafter $(TOP)/$(CURDIR) -include %(objdir)/%(modname)_deflibdefs.h
1314 BD_DFLAGS := %(dflags) -I%(objdir) -idirafter $(TOP)/$(CURDIR) -include %(objdir)/%(modname)_deflibdefs.h
1316 BD_LINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBFILES))
1317 BD_LINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBAFILES))
1318 ifeq ($(strip $(%(modname)_LINKLIBFILES) %(linklibfiles)),)
1321 BD_LINKLIB := %(prefix)/$(AROS_DIR_LIB)/lib%(linklibname).a
1323 BD_LINKLIBFILES := $(BD_LINKLIBCFILES) $(BD_LINKLIBAFILES)
1325 BD_CCFILES := $(BD_NARCHFILES) $(BD_STARTFILES) \
1326 $(BD_ENDFILES) $(BD_LINKLIBCFILES) %(linklibfiles)
1328 %rule_compile_multi \
1329 basenames=$(BD_CCFILES) targetdir=%(objdir) \
1330 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) \
1331 compiler=%(compiler)
1333 ifneq ($(BD_LINKLIBAFILES),)
1334 %rule_assemble_multi \
1335 basenames=$(BD_LINKLIBAFILES) targetdir=%(objdir) suffix=.S
1338 ## function reference files generation
1341 basenames=$(BD_FILES) targetdir=%(objdir) \
1342 cflags="-I$(dir $(GENMODULE))/genmod_inc -I%(objdir)/dummyinc $(strip $(BD_CFLAGS))" \
1343 compiler=%(compiler)
1346 BD_REFS := $(addprefix %(objdir)/,$(addsuffix .ref, $(notdir $(BD_FILES))))
1348 BD_REFS := $(addprefix %(objdir)/,$(addsuffix .ref, $(notdir $(filter-out %(noref),$(BD_FILES)))))
1351 %rule_join from=$(BD_REFS) to=%(reffile) \
1352 text="Collecting function references for module %(modname)"
1357 ifeq (%(modsuffix),)
1358 BD_MODULE := %(prefix)/%(moduledir)/%(modname).%(modtype)
1359 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1361 BD_MODULE := %(prefix)/%(moduledir)/%(modname).%(modsuffix)
1362 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modsuffix).o
1365 %(mmake)-quick : %(mmake)
1366 %(mmake) : $(BD_MODULE) $(BD_LINKLIB)
1367 %(mmake)-kobj : $(BD_KOBJ) $(BD_LINKLIB)
1368 %(mmake)-linklib : $(BD_LINKLIB)
1370 BD_OBJS := $(addsuffix .o,$(BD_STARTFILES)) $(BD_ARCHOBJS) \
1371 $(addsuffix .o, $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES))))
1372 BD_ENDOBJS := $(addsuffix .o,$(BD_ENDFILES))
1373 BD_LINKLIBOBJS:= $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_LINKLIBFILES))
1375 # The module is linked from all the compiled .o files
1376 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1377 endobj=$(BD_ENDOBJS) err=$(BD_MODNAME).err \
1378 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1381 ifneq ($(BD_LINKLIB),)
1382 %rule_link_linklib libname=%(linklibname) objs=$(BD_LINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1384 $(BD_LINKLIB) : | %(prefix)/$(AROS_DIR_LIB)
1385 GLOB_MKDIRS += %(prefix)/$(AROS_DIR_LIB)
1388 # Link kernel object file
1389 BD_KAUTOLIB := workbench dos cybergraphics intuition layers graphics oop utility \
1391 BD_KBASE := WorkbenchBase DOSBase CyberGfxBase IntuitionBase LayersBase \
1392 GfxBase OOPBase UtilityBase ExpansionBase KeymapBase
1393 BD_KLIB := hiddgraphicsstubs hiddstubs amiga arossupport rom arosm autoinit libinit
1394 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1395 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1396 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_KBASE))
1397 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1398 @$(ECHO) "Linking $@"
1399 @$(AROS_LD) -Ur -o $@ $^ -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1400 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__$$/) || ($$3 ~ /^libraryset_.*$$/) {print "-L " $$3;}'`
1402 ## Dependency fine-tuning
1404 BD_DEPS := $(addsuffix .d,$(addprefix %(objdir)/,$(notdir $(BD_CCFILES))))
1405 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1407 $(BD_OBJS) $(BD_DEPS) $(BD_REFS) : | %(objdir)
1408 $(BD_MODULE) : | %(prefix)/%(moduledir)
1409 $(BD_KOBJ) : | $(KOBJSDIR)
1410 GLOB_MKDIRS += %(objdir) %(prefix)/%(moduledir) $(KOBJSDIR)
1412 # Some include files need to be generated before the .c can be parsed.
1413 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj),) # Only for this target these deps are wanted
1414 BD_REFFILE_DEPS := $(BD_LIBDEFSINC) %(objdir)/%(modname)_deflibdefs.h \
1415 $(addprefix %(objdir)/dummyinc/,$(%(modname)_INCLUDES))
1416 $(BD_REFS) : $(BD_REFFILE_DEPS) $(dir $(GENMODULE))/genmod_inc/aros/libcall.h
1418 BD_DFILE_DEPS := $(BD_LIBDEFSINC) %(objdir)/%(modname)_deflibdefs.h \
1419 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES))
1420 $(BD_DEPS) : $(BD_DFILE_DEPS)
1423 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) %(reffile) \
1424 $(BD_REFS) $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
1425 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1426 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1427 $(addprefix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
1428 %(objdir)/%(modname)_deflibdefs.h \
1429 $(addsuffix .c,$(BD_STARTFILES) $(BD_ENDFILES)) \
1431 %(mmake)-clean : FILES := $(BD_TOCLEAN)
1433 @$(ECHO) "Cleaning up for module %(modname)"
1436 endif # $(TARGET) in $(BD_ALLTARGETS)
1438 #------------------------------------------------------------------------------
1441 #------------------------------------------------------------------------------
1442 # Build a module using the deprecated macro's to define the functions in the
1443 # library. Explanation of this macro is done in the developer's manual
1444 %define build_module_macro mmake=/A modname=/A modtype=/A dir= \
1445 conffile=$(BD_MODNAME$(BDID)).conf initfile=$(BD_MODNAME$(BDID))_init \
1446 funcs= files= linklibfiles= cflags=$(CFLAGS) dflags= \
1447 objdir=$(OBJDIR) uselibs= usehostlibs= \
1448 genfunctable= genincludes= compiler=target
1450 %buildid targets="%(mmake) %(mmake)-setup %(mmake)-clean %(mmake)-includes %(mmake)-linklib %(mmake)-quick %(mmake)-kobj"
1452 .PHONY : setup-module$(BDID)
1455 $(error using %build_module: modname may not be empty)
1458 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1461 # assign and generate the local variables used in this macro
1462 BD_MODNAME$(BDID) := %(modname)
1463 BD_MODTYPE$(BDID) := %(modtype)
1464 BD_MODDIR$(BDID) := %(dir)
1465 BD_CONFFILE$(BDID) := %(conffile)
1466 OBJDIR ?= $(GENDIR)/$(CURDIR)
1467 BD_OBJDIR$(BDID) := %(objdir)
1469 BD_ARCHOBJS$(BDID) := $(wildcard $(BD_OBJDIR$(BDID))/arch/*.o)
1470 BD_ARCHFILES$(BDID) := $(basename $(notdir $(BD_ARCHOBJS$(BDID))))
1472 BD_INITFILE$(BDID) := %(initfile)
1473 BD_FUNCS$(BDID) := $(filter-out $(BD_ARCHFILES$(BDID)),%(funcs))
1474 BD_FILES$(BDID) := $(filter-out $(BD_ARCHFILES$(BDID)),%(files))
1475 BD_LIBFILES$(BDID) := %(linklibfiles)
1476 ifneq ($(wildcard $(BD_CONFFILE$(BDID))),)
1477 BD_ENDFILE$(BDID) := $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_end
1479 BD_ENDFILE$(BDID) :=
1482 BD_FUNCSRCS$(BDID) := $(addsuffix .c,%(funcs))
1483 BD_SRCS$(BDID) := $(addsuffix .c,$(BD_FILES$(BDID)))
1484 ifeq ($(filter $(BD_INITFILE$(BDID)), $(BD_ARCHFILES$(BDID))),)
1485 BD_INITOBJ$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir $(BD_INITFILE$(BDID)))))
1487 TMP_INITREPLACE := $(filter $(notdir $(BD_INITFILE$(BDID))), $(BD_ARCHFILES$(BDID)))
1488 TMP_INITKEEP := $(filter-out $(TMP_INITREPLACE),$(notdir $(BD_INITFILE$(BDID))))
1489 BD_INITOBJ$(BDID) := $(addsuffix .o, \
1490 $(addprefix $(BD_OBJDIR$(BDID))/arch/,$(TMP_INITREPLACE)) \
1491 $(addprefix $(BD_OBJDIR$(BDID))/,$(TMP_INITKEEP)) \
1493 BD_ARCHOBJS$(BDID) := $(filter-out $(BD_INITOBJ$(BDID)),$(BD_ARCHOBJS$(BDID)))
1496 TMP_FILES := $(notdir $(BD_FILES$(BDID)))
1497 ifeq (%(genfunctable),yes)
1498 TMP_FILES := $(BD_MODNAME$(BDID))_functable $(TMP_FILES)
1500 ifneq ($(BD_FUNCS$(BDID)),)
1501 ifeq (%(genfunctable),)
1502 ifneq ($(BD_MODTYPE$(BDID)),resource)
1503 TMP_FILES := $(BD_MODNAME$(BDID))_functable $(TMP_FILES)
1506 ifneq (%(genfunctable),no)
1507 TMP_FILES := $(BD_MODNAME$(BDID))_functable $(TMP_FILES)
1510 TMP_FILES += $(BD_FUNCS$(BDID))
1513 BD_OBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(TMP_FILES))) $(BD_ARCHOBJS$(BDID))
1514 BD_ENDOBJ$(BDID) := $(addsuffix .o,$(BD_ENDFILE$(BDID)))
1516 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(BD_INITFILE$(BDID)) $(TMP_FILES)))
1518 BD_GENINCS$(BDID) :=
1519 ifneq (%(genincludes),)
1520 ifeq (%(genincludes),yes)
1521 BD_GENINCS$(BDID):= clib/$(BD_MODNAME$(BDID))_protos.h defines/$(BD_MODNAME$(BDID)).h proto/$(BD_MODNAME$(BDID)).h
1524 ifneq ($(BD_FUNCS$(BDID)),)
1525 ifneq ($(findstring $(BD_MODTYPE$(BDID)),library gadget device),)
1526 BD_GENINCS$(BDID):= clib/$(BD_MODNAME$(BDID))_protos.h defines/$(BD_MODNAME$(BDID)).h proto/$(BD_MODNAME$(BDID)).h
1530 # Only generate libdefs.h if the config file exists
1531 ifneq ($(wildcard $(BD_CONFFILE$(BDID))),)
1532 BD_LIBDEFSINC$(BDID):= $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_libdefs.h
1534 BD_LIBDEFSINC$(BDID):=
1537 BD_CFLAGS$(BDID) := %(cflags) -I$(BD_OBJDIR$(BDID)) -I. -I$(TOP)/workbench/libs -include $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h
1539 BD_DFLAGS$(BDID) := $(BD_CFLAGS$(BDID))
1541 BD_DFLAGS$(BDID) := %(dflags) -I$(BD_OBJDIR$(BDID)) -I. -I$(TOP)/workbench/libs -include $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h
1544 # Add additional files depending the module type
1545 ifeq ($(findstring $(BD_MODTYPE$(BDID)),library gadget datatype handler device resource mui mcc mcp hidd),)
1546 $(error unhandled MODTYPE %(modtype))
1548 ifeq ($(BD_MODDIR$(BDID)),)
1549 ifeq ($(BD_MODTYPE$(BDID)),library)
1550 BD_MODDIR$(BDID) := $(AROS_LIBS)
1552 ifeq ($(BD_MODTYPE$(BDID)),gadget)
1553 BD_MODDIR$(BDID) := $(AROS_GADGETS)
1555 ifeq ($(BD_MODTYPE$(BDID)),datatype)
1556 BD_MODDIR$(BDID) := $(AROS_DATATYPES)
1558 ifeq ($(BD_MODTYPE$(BDID)),handler)
1559 BD_MODDIR$(BDID) := $(AROS_FS)
1561 ifeq ($(BD_MODTYPE$(BDID)),device)
1562 BD_MODDIR$(BDID) := $(AROS_DEVS)
1564 ifeq ($(BD_MODTYPE$(BDID)),resource)
1565 BD_MODDIR$(BDID) := $(AROS_RESOURCES)
1567 ifeq ($(BD_MODTYPE$(BDID)),mui)
1568 BD_MODDIR$(BDID) := $(AROS_CLASSES)/Zune
1570 ifeq ($(BD_MODTYPE$(BDID)),mcc)
1571 BD_MODDIR$(BDID) := $(AROS_CLASSES)/Zune
1573 ifeq ($(BD_MODTYPE$(BDID)),mcp)
1574 BD_MODDIR$(BDID) := $(AROS_CLASSES)/Zune
1576 ifeq ($(BD_MODTYPE$(BDID)),hidd)
1577 BD_MODDIR$(BDID) := $(AROS_DRIVERS)
1581 BD_MODULE$(BDID) := $(BD_MODDIR$(BDID))/$(BD_MODNAME$(BDID)).$(BD_MODTYPE$(BDID))
1582 BD_GENFILES$(BDID) := $(BD_MODULE$(BDID))
1583 BD_DEPS$(BDID) += $(BD_LINKLIBDEPS$(BDID))
1585 #MM- includes-all : %(mmake)-includes
1586 #MM %(mmake) : %(mmake)-includes %(mmake)-setup
1587 #MM %(mmake)-includes : %(mmake)-setup
1590 %(mmake)-quick : %(mmake)
1592 %(mmake) : $(BD_GENFILES$(BDID))
1596 @$(ECHO) "Cleaning up for module $(BD_MODNAME$(BDID))"
1597 @$(RM) $(BD_OBJS$(BDID)) $(BD_DEPS$(BDID)) \
1598 $(addprefix $(BD_OBJDIR$(BDID))/,$(addsuffix .c,$(BD_GENFILES$(BDID)))) \
1599 $(addprefix $(GENINCDIR)/,$(BD_GENINCS$(BDID))) \
1600 $(addprefix $(AROS_INCLUDES)/,$(BD_GENINCS$(BDID))) \
1601 $(BD_LIBDEFSINC$(BDID)) \
1602 $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h \
1603 $(BD_ENDFILE$(BDID)).c $(BD_ENDOBJ$(BDID))
1606 %(mmake)-setup : setup-module$(BDID)
1608 #MM %(mmake)-includes : setup-clib
1610 TMP_DEPS := $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h
1611 ifneq ($(BD_GENINCS$(BDID)),)
1612 TMP_DEPS += $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_includes.stamp \
1613 $(addprefix $(AROS_INCLUDES)/,$(BD_GENINCS$(BDID)))
1616 %(mmake)-includes : $(TMP_DEPS)
1618 $(TMP_DEPS) : $(BD_LIBDEFSINC$(BDID))
1620 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-linklib %(mmake)-quick %(mmake)-kobj),) # Avoid conflicts
1621 ifneq ($(dir $(BD_FILES$(BDID))),./)
1622 vpath %.c $(filter-out ./,$(dir $(BD_FUNCS$(BDID)) $(BD_FILES$(BDID))))
1625 %rule_compile basename=% targetdir=$(BD_OBJDIR$(BDID)) \
1626 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID)) \
1627 compiler=%(compiler)
1628 %rule_compile basename=$(BD_ENDFILE$(BDID)) targetdir=$(BD_OBJDIR$(BDID)) \
1629 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID)) \
1630 compiler=%(compiler)
1631 %rule_compile basename=$(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_functable targetdir=$(BD_OBJDIR$(BDID)) \
1632 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID)) \
1633 compiler=%(compiler)
1636 BD_DFILE_DEPS$(BDID) := $(BD_LIBDEFSINC$(BDID)) $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h
1638 # Some include files need to be generated before the .c can be parsed.
1639 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick %(mmake)-linklib) %(mmake)-kobj,) # Only for this target these deps are wanted
1640 $(BD_DEPS$(BDID)) : $(BD_DFILE_DEPS$(BDID))
1643 # Generation of the autogenerated .c and .h files.
1644 $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h :
1645 @$(ECHO) "generating $@"
1646 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(notdir $(BD_LIBDEFSINC$(BDID)))\"" >$@
1648 %libdefs_rule conffile=$(BD_CONFFILE$(BDID)) dest=$(BD_LIBDEFSINC$(BDID))
1650 ifneq ($(BD_ENDFILE$(BDID)),)
1651 $(BD_ENDFILE$(BDID)).c :
1652 @$(ECHO) "generating $@"
1653 @$(ECHO) "#include <libcore/libtail.c>" >$@
1656 %rule_genfunctable name=$(BD_MODNAME$(BDID))_functable files=$(BD_FUNCS$(BDID)) dir=$(BD_OBJDIR$(BDID)) \
1657 libdefs=$(BD_LIBDEFSINC$(BDID))
1659 # The module is linked from all the compiled .o files
1660 %rule_linkmodule module=$(BD_MODULE$(BDID)) objs="$(BD_INITOBJ$(BDID)) $(BD_OBJS$(BDID))" \
1661 endobj=$(BD_ENDOBJ$(BDID)) err=$(BD_MODNAME).err uselibs="%(uselibs)" \
1662 usehostlibs="%(usehostlibs)"
1664 BD_HEADER_DEPS$(BDID) := $(wildcard headers.tmpl) $(BD_LIBDEFSINC$(BDID)) \
1665 $(BD_FUNCSRCS$(BDID)) \
1666 $(SCRIPTDIR)/genshared \
1667 $(SCRIPTDIR)/genclib.awk $(SCRIPTDIR)/genpclib.awk \
1668 $(SCRIPTDIR)/gendefines.awk $(SCRIPTDIR)/genpdefines.awk
1670 # Regenerate the includes when some of the dependencies are changed
1671 $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_includes.stamp : $(BD_HEADER_DEPS$(BDID))
1672 @$(SCRIPTDIR)/genshared -clib -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1673 @$(SCRIPTDIR)/genshared -defines -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1674 @$(SCRIPTDIR)/genshared -proto -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1675 @$(SCRIPTDIR)/genshared -pclib -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1676 @$(SCRIPTDIR)/genshared -pdefines -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1677 @$(SCRIPTDIR)/genshared -pproto -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1680 # Generate includes the first time they are needed
1681 $(GENINCDIR)/clib/$(BD_MODNAME$(BDID))_private_protos.h \
1682 $(GENINCDIR)/clib/$(BD_MODNAME$(BDID))_protos.h \
1683 $(GENINCDIR)/defines/$(BD_MODNAME$(BDID)).h \
1684 $(GENINCDIR)/proto/$(BD_MODNAME$(BDID)).h :
1685 @$(SCRIPTDIR)/genshared -clib -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1686 @$(SCRIPTDIR)/genshared -proto -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1687 @$(SCRIPTDIR)/genshared -pclib -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1688 @$(SCRIPTDIR)/genshared -pdefines -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1689 @$(SCRIPTDIR)/genshared -pproto -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1690 @$(TOUCH) $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_includes.stamp
1692 # The include files generated in $(GENINCDIR) have to be mirrored in the AROS include directory
1693 %rule_copy from=$(GENINCDIR)/clib/$(BD_MODNAME$(BDID))_protos.h to=$(AROS_INCLUDES)/clib/$(BD_MODNAME$(BDID))_protos.h
1694 %rule_copy from=$(GENINCDIR)/defines/$(BD_MODNAME$(BDID)).h to=$(AROS_INCLUDES)/defines/$(BD_MODNAME$(BDID)).h
1695 #%rule_copy from=$(GENINCDIR)/pragmas/$(BD_MODNAME$(BDID)).h to=$(AROS_INCLUDES)/pragmas/$(BD_MODNAME$(BDID)).h
1696 %rule_copy from=$(GENINCDIR)/proto/$(BD_MODNAME$(BDID)).h to=$(AROS_INCLUDES)/proto/$(BD_MODNAME$(BDID)).h
1698 MYDIRS$(BDID) := $(BD_OBJDIR$(BDID)) $(GENINCDIR) $(GENINCDIR)/clib \
1699 $(GENINCDIR)/proto $(GENINCDIR)/defines \
1700 $(GENINCDIR)/pragmas $(AROS_INCLUDES) $(AROS_INCLUDES)/clib $(AROS_INCLUDES)/proto \
1701 $(AROS_INCLUDES)/defines $(AROS_INCLUDES)/pragmas \
1702 $(BD_MODDIR$(BDID)) $(KOBJSDIR)
1704 %rule_makedirs dirs=$(MYDIRS$(BDID)) setuptarget=setup-module$(BDID)
1706 #MM %(mmake)-linklib : %(mmake)-setup setup-clib
1707 #MM %(mmake)-kobj : %(mmake)-setup setup-clib
1709 TMP_DEPS := $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h \
1710 $(BD_LIBDEFSINC$(BDID))
1711 ifneq ($(BD_GENINCS$(BDID)),)
1712 TMP_DEPS += $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_includes.stamp \
1713 $(addprefix $(AROS_INCLUDES)/,$(BD_GENINCS$(BDID)))
1716 %(mmake)-linklib : $(TMP_DEPS)
1717 %(mmake)-kobj : $(TMP_DEPS)
1719 # Link only when target %(mmake)-linklib otherwise for example jpeg.datatype
1720 # that depend on the jpeg library can cause to get this rule executed unwanted
1721 ifneq ($(filter $(TARGET),%(mmake)-linklib %(mmake)-kobj),)
1722 %(mmake)-linklib : $(LIBDIR)/lib$(BD_MODNAME$(BDID)).a
1723 %(mmake)-kobj : $(KOBJSDIR)/$(BD_MODNAME$(BDID))_$(BD_MODTYPE$(BDID)).o
1725 %rule_link_linklib libname=$(BD_MODNAME$(BDID)) libdir=$(LIBDIR) \
1726 objs="$(BD_INITOBJ$(BDID)) $(BD_OBJS$(BDID)) $(BD_ENDOBJ$(BDID))"
1728 $(KOBJSDIR)/$(BD_MODNAME$(BDID))_$(BD_MODTYPE$(BDID)).o : \
1729 $(BD_INITOBJ$(BDID)) $(BD_OBJS$(BDID)) $(BD_ENDOBJ$(BDID))
1730 @$(ECHO) "Linking $@"
1731 $(AROS_LD) -Ur -o $@ $^
1732 $(OBJCOPY) $@ `$(NM_PLAIN) $@ | $(AWK) '$$3 ~ /^__.*_(LIST|END)__$$/ {print "-L " $$3;}'`
1735 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-linklib %(mmake)-kobj" deps=$(BD_DEPS$(BDID))
1737 #------------------------------------------------------------------------------
1740 #------------------------------------------------------------------------------
1742 # - mmake is the mmaketarget
1743 # - libname is the baselibname e.g. lib%(libname).a will be created
1744 # - files are the C source files to include in the lib. The list of files
1745 # has to be given without the .c suffix
1746 # - asmfiles are the asm files to include in the lib. The list of files has to
1747 # be given with the .s suffix
1748 # - cflags are the flags to compile the source (default $(CFLAGS))
1749 # - dflags are the flags use during makedepend (default equal to cflags)
1750 # - aflags are the flags use during assembling (default $(AFLAGS))
1751 # - objdir is where the .o are generated
1752 # - libdir is the directory where the linklib will be placed (default $(LIBDIR))
1753 %define build_linklib mmake=/A libname=/A files="$(basename $(wildcard *.c))" \
1754 asmfiles= cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) objdir=$(OBJDIR) libdir=$(LIBDIR)
1756 %buildid targets="%(mmake) %(mmake)-clean"
1758 # assign and generate the local variables used in this macro
1759 BD_LIBNAME$(BDID) := %(libname)
1760 OBJDIR ?= $(GENDIR)/$(CURDIR)
1761 BD_OBJDIR$(BDID) := %(objdir)
1762 BD_LIBDIR$(BDID) := %(libdir)
1764 BD_FILES$(BDID) := %(files)
1765 BD_ASMFILES$(BDID) := %(asmfiles)
1766 BD_SRCS$(BDID) := $(addsuffix .c,$(BD_FILES$(BDID)))
1767 BD_OBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir $(BD_FILES$(BDID)) $(BD_ASMFILES$(BDID)))))
1768 BD_DEPS$(BDID) := $(patsubst %.o,%.d,$(BD_OBJS$(BDID)))
1770 BD_CFLAGS$(BDID) := %(cflags)
1772 BD_DFLAGS$(BDID) := $(BD_CFLAGS$(BDID))
1774 BD_DFLAGS$(BDID) := %(dflags)
1776 BD_AFLAGS$(BDID) := %(aflags)
1778 BD_LINKLIB$(BDID) := $(BD_LIBDIR$(BDID))/lib$(BD_LIBNAME$(BDID)).a
1780 .PHONY : %(mmake) %(mmake)-clean
1783 %(mmake) : $(BD_LINKLIB$(BDID))
1787 @$(RM) $(BD_OBJS$(BDID)) $(BD_DEPS$(BDID))
1789 ifeq ($(TARGET),%(mmake))
1790 ifneq ($(dir $(BD_FILES$(BDID))),./)
1791 vpath %.c $(filter-out ./,$(dir $(BD_FILES$(BDID))))
1794 %rule_compile basename=% targetdir=$(BD_OBJDIR$(BDID)) \
1795 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID))
1796 %rule_assemble basename=% targetdir=$(BD_OBJDIR$(BDID)) \
1797 flags=$(BD_AFLAGS$(BDID))
1800 %rule_link_linklib libname=%(libname) objs=$(BD_OBJS$(BDID)) libdir=$(BD_LIBDIR$(BDID))
1802 %include_deps depstargets=%(mmake) deps=$(BD_DEPS$(BDID))
1804 $(BD_OBJS$(BDID)) $(BD_DEPS$(BDID)) : | $(BD_OBJDIR$(BDID))
1805 $(BD_LINKLIB$(BDID)) : | $(BD_LIBDIR$(BDID))
1806 GLOB_MKDIRS += $(BD_OBJDIR$(BDID)) $(BD_LIBDIR$(BDID))
1809 #------------------------------------------------------------------------------
1812 #------------------------------------------------------------------------------
1814 # - mmake is the mmaketarget
1815 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
1816 # - description is the catalog description file (.cd) (default *.cd)
1817 # - subdir is the destination subdir of the catalogs
1818 # - name is the name of the destination catalog, without the .catalog suffix
1819 # - source is the path to the generated source code file
1820 # - dir is the base destination directory (default $(AROS_CATALOGS))
1821 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
1823 %define build_catalogs mmake=/A name=/A subdir=/A \
1824 catalogs="$(basename $(wildcard *.ct))" source="../strings.h" \
1825 description="$(basename $(wildcard *.cd))" dir=$(AROS_CATALOGS) \
1826 sourcedescription="$(TOOLDIR)/C_h_orig"
1828 %buildid targets="%(mmake) %(mmake)-clean"
1830 BD_SRCS$(BDID) := $(foreach name, %(catalogs), $(name).ct)
1831 BD_OBJS$(BDID) := $(foreach name, %(catalogs), %(dir)/$(name)/%(subdir)/%(name).catalog)
1832 BD_DIRS$(BDID) := $(foreach name, %(catalogs), %(dir)/$(name)/%(subdir))
1835 %(mmake) : $(BD_OBJS$(BDID)) %(source)
1837 $(BD_OBJS$(BDID)) : | $(BD_DIRS$(BDID))
1838 GLOB_MKDIRS += $(BD_DIRS$(BDID))
1840 %(dir)/%/%(subdir)/%(name).catalog : %.ct %(description).cd
1841 @$(ECHO) "Creating %(name) catalog for language $*."
1842 @$(FLEXCAT) %(description).cd $*.ct CATALOG=%(dir)/$*/%(subdir)/%(name).catalog || [ $$? -lt 10 ]
1845 %(source) : %(description).cd
1846 @$(ECHO) "Creating %(name) catalog source file %(source)"
1847 @$(FLEXCAT) %(description).cd %(source)=%(sourcedescription).sd
1852 $(RM) $(BD_OBJS$(BDID)) %(source)
1854 .PHONY: %(mmake) %(mmake-clean)
1858 #-----------------------------------------------------------------------------
1860 #-----------------------------------------------------------------------------
1862 # - mmake is the mmaketarget
1863 # - icons is a list of icon base names (ie. without the .info suffix)
1864 # - dir is the destination directory
1865 #-----------------------------------------------------------------------------
1867 %define build_icons mmake=/A icons=/A dir=/A
1869 %buildid targets="%(mmake) %(mmake)-clean"
1871 BD_OBJS$(BDID) := $(foreach icon, %(icons), %(dir)/$(icon).info)
1874 %(mmake) : $(BD_OBJS$(BDID))
1876 %(dir)/%.info : %.info.src %.png
1877 @$(ECHO) Creating $(notdir $@)...
1878 @$(ILBMTOICON) $+ $@
1880 $(BD_OBJS$(BDID)) : | %(dir)
1881 GLOB_MKDIRS += %(dir)
1885 @$(RM) $(BD_OBJS$(BDID))
1891 #-----------------------------------------------------------------------------
1893 #------------------------------------------------------------------------------
1894 # Compile files for a arch specific replacement of code for a module
1895 # - files: the basename of the C files to compile.
1896 # - asmfiles: the basename of the asm file to assemble.
1897 # - mainmmake: the mmake of the module in the main directory to compile these
1898 # arch specific files for.
1899 # - maindir: the object directory for the main module
1900 # - arch: the arch for which to compile these files. It can has to have the form
1901 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
1902 # - cflags (default $(CFLAGS)): the C flags to use for compilation
1903 # - dflags: the flags used during creation of dependency file. If not specified
1904 # the same value as cflags will be used
1905 # - aflags: the flags used during assembling
1906 # - compiler: (host or target) specifies which compiler to use. By default
1907 # the target compiler is used
1908 %define build_archspecific files= asmfiles= mainmmake=/A maindir=/A arch=/A \
1909 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
1911 ifeq (%(files) %(asmfiles),)
1912 $(error no files or asmfiles given)
1915 %buildid targets="%(mainmmake)-%(arch)"
1917 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1918 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1919 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1921 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
1924 $(error argument arch has to be non empty for the rule_compile_archspecific macro)
1927 BD_OBJDIR$(BDID) := $(GENDIR)/%(maindir)/arch
1928 BD_COBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1929 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
1930 BD_OBJS$(BDID) := $(BD_COBJS$(BDID)) $(BD_ASMOBJS$(BDID))
1931 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1933 ifeq ($(TARGET),%(mainmmake)-%(arch))
1934 vpath %.c $(filter-out ./,$(dir %(files)))
1935 vpath %.s $(filter-out ./,$(dir %(asmfiles)))
1936 vpath %.S $(filter-out ./,$(dir %(asmfiles)))
1939 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID))
1940 GLOB_MKDIRS += $(BD_OBJDIR$(BDID))
1943 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
1945 ifeq ($(findstring %(compiler),host target),)
1946 $(error unknown compiler %(compiler))
1948 ifeq (%(compiler),target)
1949 $(BD_COBJS$(BDID)) : TMP_CMD:=$(TARGET_CC)
1951 ifeq (%(compiler),host)
1952 $(BD_COBJS$(BDID)) : TMP_CMD:=$(HOST_CC)
1954 ifneq (%(modulename),)
1955 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) \
1956 --include $(GENDIR)/%(maindir)/%(modulename)_deflibdefs.h
1958 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
1960 ifeq ($(TARGET),%(mainmmake)-%(arch))
1961 $(BD_OBJDIR$(BDID))/%.o : %.c
1962 %compile_q opt=$(TMP_CFLAGS) cmd=$(TMP_CMD)
1966 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags)
1968 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
1970 ifeq ($(TARGET),%(mainmmake)-%(arch))
1971 $(BD_OBJDIR$(BDID))/%.d : %.c
1972 %mkdepend_q flags=$(TMP_DFLAGS)
1975 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
1977 ifeq ($(TARGET),%(mainmmake)-%(arch))
1978 $(BD_OBJDIR$(BDID))/%.o : %.s
1979 %assemble_q opt=$(AFLAGS)
1980 $(BD_OBJDIR$(BDID))/%.o : %.S
1981 %assemble_q opt=$(AFLAGS)
1984 %include_deps depstargets=%(mainmmake)-%(arch) deps=$(BD_DEPS$(BDID))
1986 #------------------------------------------------------------------------------
1994 # ======================
1995 # Old stuff, will probably be removed in the future
2000 # GNU Make automatic variables
2002 # $< First dependency
2003 # $? All newer dependencies
2004 # $^ All dependencies
2005 # $* The stem (ie. target is dir/a.foo.b and the pattern is
2006 # a.%.b, then the stem is dir/foo)
2008 #------------------------------------------------------------------------------
2009 # rule to generate libdefs.h with archtool (options may go away!)
2010 %define libdefs_rule conffile=lib.conf genlibdefstool=$(ARCHTOOL) dest=libdefs.h
2011 %(dest) : %(conffile) %(genlibdefstool)
2012 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
2013 @%(genlibdefstool) -c -o $@ %(conffile)
2017 #------------------------------------------------------------------------------
2018 # generate asm files from c files (for debugging purposes)
2021 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
2022 @$(TARGET_CC) -S $(CFLAGS) $< -c -o $@
2025 #------------------------------------------------------------------------------
2026 # Convert two png images to an Amiga icon file based on the description
2027 # file %(from), with outputfile going to %(to).
2028 %define makeicon2 from=$< to=$@ img1="$(basename $(basename $<))_N.png" img2="$(basename $(basename $<))_S.png"
2029 @$(ECHO) "Creating icon %(to)..."
2030 @$(PNGTOPNM) %(img1) | $(PPMTOILBM) -maxplanes 8 >$(GENDIR)/genicon1.iff
2031 @$(PNGTOPNM) %(img2) | $(PPMTOILBM) -maxplanes 8 >$(GENDIR)/genicon2.iff
2032 @$(ILBMTOICON) %(from) $(GENDIR)/genicon1.iff $(GENDIR)/genicon2.iff %(to)
2035 #------------------------------------------------------------------------------
2036 # NOTE: The following are all part of Iain's build changes, please don't use
2037 # or change anything below this line until you know what you are doing. This
2038 # is so that I don't conflict with the semantics of any of the above macros.
2039 #------------------------------------------------------------------------------
2041 #------------------------------------------------------------------------------
2042 # Copy files from one directory to another.
2044 %define copy_files_q files=$(FILES) src=. dst=/A maketarget=files-copy
2046 SRC_FILES := $(foreach f, %(files), %(src)/$(f))
2047 DST_FILES := $(foreach f, %(files), %(dst)/$(f))
2049 %(maketarget) : setup $(DST_FILES)
2051 $(DST_FILES) : %(dst)/% : %(src)/%
2059 #----------------------------------------------------------------------------------
2060 # Copy a diretory recursively to another place, preserving the original
2061 # hierarchical structure
2063 # src: the source directory whose content will be copied
2064 # dst: the directory where to copy src's content. If not existing, it will be made.
2066 %define copy_dir_recursive mmake=/A src=$(TOP)/$(CURDIR) dst=/A
2068 %(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)
2069 %(mmake)_DIRS := $(sort $(foreach f,$(%(mmake)_FILES),$(dir $(f))))
2071 define %(mmake)_mkdir
2076 define %(mmake)_copy
2077 $(3)/$(1): $(2)/$(1) | $(dir $(3)/$(1))
2084 %(mmake): | $(GENDIR)/$(CURDIR)
2085 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
2086 $(ECHO) "all: $(addprefix \$$(DST)/,$(%(mmake)_FILES))" > $$m
2087 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
2088 for d in $(%(mmake)_DIRS); do \
2089 $(ECHO) "\$$(DST)/$$d: ; $(MKDIR) \$$@" >> $$m; \
2091 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
2092 for f in $(%(mmake)_FILES); do \
2093 $(ECHO) "\$$(DST)/$$f: \$$(SRC)/$$f | \$$\$$(@D); $(CP) \$$< \$$@" >> $$m; \
2095 for dst in %(dst); do \
2096 $(MAKE) -f $$m DST=$$dst SRC=%(src) all; \
2099 $(GENDIR)/$(CURDIR):
2104 #------------------------------------------------------------------------------
2105 # Copy include files into the includes directories. There are currently
2106 # two include directories. One for building AROS $(AROS_INCLUDES) and one
2107 # for building tools that need to run on the host system $(GENINCDIR). The
2108 # $(GENINCDIR) path must not contain any references to the C runtime
2109 # library header files.
2111 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. dir=include
2114 INCL_FILES_1 := $(subst %(dir),$(AROS_INCLUDES)/%(path),%(includes))
2115 INCL_FILES_2 := $(subst %(dir),$(GENINCDIR)/%(path),%(includes))
2116 _INC_PATH := %(dir)/
2118 INCL_FILES_1 := $(foreach f,%(includes),$(AROS_INCLUDES)/%(path)/$(f))
2119 INCL_FILES_2 := $(foreach f,%(includes),$(GENINCDIR)/%(path)/$(f))
2125 ifneq (%(mmake),includes-copy)
2127 includes-copy : %(mmake)
2130 %(mmake) : $(INCL_FILES_1) $(INCL_FILES_2)
2134 $(AROS_INCLUDES)/%(path)/%.h : $(_INC_PATH)%.h
2137 $(GENINCDIR)/%(path)/%.h : $(_INC_PATH)%.h
2140 $(INCL_FILES_1) : | $(AROS_INCLUDES)/%(path)
2141 $(INCL_FILES_2) : | $(GENINCDIR)/%(path)
2142 GLOB_MKDIRS += $(AROS_INCLUDES)/%(path) $(GENINCDIR)/%(path)
2146 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
2147 STUBS_SRC := $(foreach f,$(STUBS),$(f).c)
2148 STUBS_OBJ := $(foreach f,$(STUBS),$(OBJDIR)/$(f).o)
2149 STUBS_MEM := $(foreach f,$(STUBS),$(f).o)
2150 STUBS_DEP := $(foreach f,$(STUBS),$(OBJDIR)/$(f).d)
2151 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
2153 #MM- linklibs : hidd-%(hidd)-stubs
2154 #MM- %(parenttarget): hidd-%(hidd)-stubs
2155 #MM hidd-%(hidd)-stubs : includes includes-copy
2156 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
2158 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
2161 $(STUBS_OBJ) : $(STUBS_SRC)
2162 %compile_q cmd=$(TARGET_CC) opt=%(cflags)
2164 $(STUBS_DEP) : $(STUBS_SRC)
2165 %mkdepend_q flags=%(dflags)
2168 %mkdirs_q $(OBJDIR) $(LIBDIR)
2172 -@$(RM) $(HIDD_LIB) $(OBJDIR)
2174 DEPS := $(DEPS) $(STUBS_DEP)
2178 #------------------------------------------------------------------------------
2179 # Build an imported source tree which uses the configure script from the
2180 # autoconf package. This rule will try to "integrate" the produced files as
2181 # much as possible in the AROS build, for exampley by putting libraries in the
2182 # standard library directory, includes in the standard include directory, and
2183 # so on. You can however override this behaviour.
2185 # As a special "bonus" for you, the PROGDIR environment variable is defined to
2186 # be %(bindir) (or its deduced value) when running "make install", and
2187 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
2188 # configure script some more parameters whose value depends upon the PROGDIR
2189 # env var, so that the program gets all its stuff installed in the proper place
2190 # when building it, but when running it from inside AROS it can also find that
2191 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
2192 # the configuration parameters set when running ./configure
2194 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
2195 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
2196 # to the name which has to follow it.
2199 %define build_with_configure mmake=/A srcdir=$(TOP)/$(CURDIR) prefix= aros_prefix= \
2200 extraoptions= nix_dir_layout= nix=no host=no \
2201 install_target=install postconfigure= postinstall=
2204 %(mmake)-prefix := %(prefix)
2206 %(mmake)-prefix := $(AROS_CONTRIB)
2209 ifneq (%(aros_prefix),)
2210 %(mmake)-aros_prefix := %(aros_prefix)
2212 %(mmake)-aros_prefix := $(%(mmake)-prefix)
2216 %(mmake)-nix := -nix
2217 %(mmake)-volpfx := /
2218 %(mmake)-volsfx := /
2220 ifeq (%(nix_dir_layout),)
2221 %(mmake)-nix_dir_layout := yes
2224 %(mmake)-volsfx := :
2226 ifeq (%(nix_dir_layout),)
2227 %(mmake)-nix_dir_layout := no
2231 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
2233 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) exec_prefix=$(%(mmake)-prefix)
2235 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) %(host)),yes)
2236 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
2237 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2240 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
2241 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
2243 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2246 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
2248 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) sbindir=$(%(mmake)-prefix) \
2249 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) oldincludedir=$(AROS_INCLUDES)
2253 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
2255 #MM- %(mmake) : setup includes linklibs-core %(mmake)-quick
2257 ifneq (%(install_target),)
2258 %(mmake)-install_command = \
2259 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2260 -C $(GENDIR)/$(CURDIR) %(install_target) && \
2261 $(TOUCH) $(GENDIR)/$(CURDIR)/.installed
2263 %(mmake)-uninstall_command = \
2264 $(RM) $(GENDIR)/$(CURDIR)/.installed && \
2265 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2266 -C $(GENDIR)/$(CURDIR) uninstall
2268 %(mmake)-install_command := true
2269 %(mmake)-uninstall_command := true
2272 #MM- %(mmake)-quick : %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
2275 %(mmake)-build_and_install-quick : $(GENDIR)/$(CURDIR)/.configured
2276 if ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q -C $(GENDIR)/$(CURDIR); then \
2277 $(RM) $(GENDIR)/$(CURDIR)/.installed && \
2278 $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -C $(GENDIR)/$(CURDIR) && \
2279 $(%(mmake)-install_command); \
2282 %(srcdir)/.files-touched:
2283 find %(srcdir) -exec $(TOUCH) -r %(srcdir)/configure '{}' \; && \
2287 %(mmake)-uninstall :
2288 $(%(mmake)-uninstall_command)
2290 ifneq ($(DEBUG),yes)
2291 %(mmake)-s_flag = -s
2295 %(mmake)-configure : $(GENDIR)/$(CURDIR)/.configured
2298 $(GENDIR)/$(CURDIR)/.configured : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2300 %mkdirs_q $(GENDIR)/$(CURDIR)
2301 cd $(GENDIR)/$(CURDIR) && \
2302 find . -name config.cache -exec $(RM) '{}' \; && \
2304 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) && \
2307 $(GENDIR)/$(CURDIR)/.configured : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2309 %mkdirs_q $(GENDIR)/$(CURDIR)
2310 cd $(GENDIR)/$(CURDIR) && \
2311 find . -name config.cache -exec $(RM) '{}' \; && \
2312 CC="$(TARGET_CC) $(%(mmake)-nix) $(%(mmake)-s_flag)" CC_FOR_BUILD="$(HOST_CC)" \
2313 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) --host=$(AROS_TARGET_CPU)-aros \
2314 --target=$(AROS_TARGET_CPU)-aros --build=local --disable-nls --without-x \
2315 --without-pic --disable-shared && \
2320 %(mmake)-clean : %(mmake)-uninstall
2321 @$(RM) $(GENDIR)/$(CURDIR)
2324 #############################################################################
2325 #############################################################################
2327 ## Misciellanous macros. Everying that doesn't fin above should be put ##
2330 #############################################################################
2331 #############################################################################
2333 #----------------------------------------------------------------------------------
2334 # Given an archive name, patches names and locations where to find them, fetch
2335 # the archive and the patches from any of those locations, unpack the archive
2336 # and then apply the patches.
2338 # Locations currently supported are http and ftp sites, plus local filesystem
2339 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
2340 # the fetch.sh script needs to be modified, since this macro relies on that script.
2344 # - archive_origins = list of locations where to find the archive. They are tried
2345 # in sequence, until the archive is found and fetching it
2346 # succeeded. If not specified, the current directory is assumed.
2347 # - archive = the archive name. Mandatory.
2348 # - destination = the local directory where to put the archive and patches.
2349 # If not specified, the current directory is assumed.
2350 # - patches_origins = list of locations where to find the patches. They are tried
2351 # in sequence, until a patch is found and fetching it
2352 # succeeded. If not specified, the current directory is assumed.
2353 # - patches_specs = list of "patch specs". A patch spec is of the form
2354 # patch_name[:[patch_subdir][:patch_opt]].
2356 # - patch_name = the name of the patch file
2357 # - patch_subdir = the directory within \destination\ where to
2359 # - patch_opt = any options to pass to the `patch' command
2360 # when applying the patch.
2362 # The patch_subdir and patch_opt fields are optional.
2364 %define fetch archive_origins=. archive=/A suffixes= destination=. patches_origins=. patches_specs=::
2365 $(FETCH) -ao "%(archive_origins)" -a %(archive) -as "%(suffixes)" -d %(destination) \
2366 -po "%(patches_origins)" -p %(patches_specs)
2369 #-----------------------------------------------------------------------------------------
2370 # Joins the features of %fetch and %build_with_configure, taking advantage of
2371 # the naming scheme of GNU packages. GNU packages names are in the form
2373 # <package name>-<version number>.<archive format suffix>
2375 # If a patch is provided, it *must* be named the following way:
2377 # <package name>-<version number>-aros.diff
2379 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
2380 # CD'ing into the archive's extracted directory.
2382 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
2383 # the %fetch_and_build macro only accept *one* patch for each package. It's up to you
2384 # to make that patch fully comprehensive.
2386 # NOTE: GNU packages are always compiled with *nix semantics turned on.
2390 # - mmake = the meta make target, as would be supplied to the %build_with_configure
2392 # - package = the GNU package name, sans version and archive format suffixes.
2393 # - version = the package's version number, or otherwise any other version string.
2394 # It gets appended to the package name to form the basename of the archive.
2395 # - suffixes = a list of suffixes to apped to the the package name plus the
2396 # version. Each one of them is tried until a matching archive is found.
2397 # Defaults to "tat.bz2 tar.gz".
2398 # - destination = same meaning as the one for the %fetch macro
2399 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
2400 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
2402 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
2403 # - prefix = same meaning as the one for the %build_with_configure macro. Defaults to
2405 # - aros_prefix = same meaning as the one for the %build_with_configure macro. Defaults to
2407 # - extraoptions = same meaning as the one for the %build_with_configure macro.
2408 # - postinstall = same meaning as the one for the %build_with_configure macro.
2410 %define fetch_and_build mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2411 srcdir= package_repo= patch=no patch_repo= prefix= \
2412 aros_prefix= extraoptions= postconfigure= postinstall= nix=no nix_dir_layout=
2414 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
2415 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
2417 %(mmake)-archbase := %(package)-%(version)
2420 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
2422 %(mmake)-prefix := %(prefix)
2425 ifneq (%(subpackage),)
2426 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
2428 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
2432 %(mmake)-%(subpackage)-srcdir := %(srcdir)
2434 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
2438 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-p1
2440 %(mmake)-%(subpackage)-patches_specs := ::
2443 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
2445 .PHONY : %(mmake)-%(subpackage)-fetch
2447 %(mmake)-%(subpackage)-fetch :
2448 %fetch archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
2449 destination=$(PORTSDIR)/%(package) \
2450 archive_origins=". %(package_repo)" \
2451 patches_specs="$(%(mmake)-%(subpackage)-patches_specs)" patches_origins=". %(patch_repo)"
2453 #MM- %(mmake) : %(mmake)-%(subpackage)
2455 PACKAGES_DIR := $(AROSDIR)/../Packages
2457 %(mmake)-%(subpackage)-package-dir := $(PACKAGES_DIR)/$(%(mmake)-%(subpackage)-archbase)
2459 %(mmake)-%(subpackage)-package-basename := \
2460 $(PACKAGES_DIR)/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
2462 %build_with_configure mmake=%(mmake)-%(subpackage) \
2463 srcdir=$(PORTSDIR)/%(package)/$(%(mmake)-%(subpackage)-srcdir) \
2464 nix=%(nix) nix_dir_layout=%(nix_dir_layout) prefix="$(%(mmake)-%(subpackage)-package-dir)" \
2465 aros_prefix="%(aros_prefix)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
2466 %(mmake)-%(subpackage)-make-package" extraoptions="%(extraoptions)"
2468 .PHONY : %(mmake)-%(subpackage)-make-package
2469 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
2472 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package-basename).tar.bz2
2474 #There seems to be a bug, either with my clock or with make, 'cause it may happen
2475 #that $^ and $@ have exactly the same mtime, and in that case make tries
2476 #to rebuild $@ again, which would fail because the directory where
2477 #the package got installed would not exist anymore.
2478 #We work this around by using an if statement to manually check the mtimes.
2479 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
2480 @if test $(GENDIR)/$(CURDIR)/.installed -nt $@ || ! test -f $@; then \
2482 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" && \
2483 cd $(%(mmake)-%(subpackage)-package-dir) && \
2484 tar --remove-files -cvf $(%(mmake)-%(subpackage)-package-basename).tar * && \
2485 mkdir -p "$(%(mmake)-prefix)" && \
2486 tar -xf $(%(mmake)-%(subpackage)-package-basename).tar -C "%(prefix)"/ && \
2487 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar && \
2488 cd .. && $(RM) $(%(mmake)-%(subpackage)-archbase); \
2492 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2493 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
2494 aros_prefix=/GNU extraoptions= postconfigure= postinstall=
2496 GNU_REPOSITORY := http://ftp.gnu.org/pub/gnu
2498 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
2499 suffixes="%(suffixes)" srcdir="%(srcdir)" \
2500 package_repo="%(package_repo) $(GNU_REPOSITORY)/%(package)" \
2501 patch="%(patch)" patch_repo="%(patch_repo)" \
2502 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" \
2503 postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=yes
2507 #-----------------------------------------------------------------------------------------
2508 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
2509 # that the package is a "Development" package, and as such it needs to be placed
2510 # under the $(AROS_DEVELOPMENT) directory, as a default.
2512 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
2513 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
2514 # "mmake" argument, because the metatarget is implicitely defined as
2516 # #MM- development-%(package)
2518 %define fetch_and_build_gnu_development package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2519 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPMENT) \
2520 aros_prefix=/Development postconfigure= postinstall= extraoptions=
2522 #MM- development : development-%(package)
2525 %fetch_and_build_gnu mmake=development-%(package) package=%(package) subpackage="%(subpackage)" \
2526 version=%(version) suffixes="%(suffixes)" srcdir="%(srcdir)" \
2527 package_repo="%(package_repo)" patch="%(patch)" patch_repo="%(patch_repo)" prefix=%(prefix) \
2528 aros_prefix="%(aros_prefix)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" \
2529 extraoptions="%(extraoptions)"