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 # Explanation of this macro is done in the developer's manual
1050 %define build_module mmake=/A modname=/A modtype=/A modsuffix= \
1051 conffile= files="$(basename $(wildcard *.c))" \
1052 linklibfiles= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1053 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
1054 reffile=$(BD_DEFREFFILE) noref= \
1055 linklibname=$(BD_DEFLINKLIBNAME) uselibs= compiler=target genincludes=
1057 # Define metamake targets and their dependencies
1058 #MM- includes-all : %(mmake)-includes
1059 #MM %(mmake) : %(mmake)-includes
1060 #MM %(mmake)-kobj : %(mmake)-includes
1061 #MM %(mmake)-quick : %(mmake)-includes-quick
1062 #MM %(mmake)-includes : %(mmake)-makefile includes-generate-deps
1063 #MM %(mmake)-includes-quick
1064 #MM %(mmake)-makefile
1065 #MM %(mmake)-funclist
1068 # All MetaMake targets defined by this macro
1069 BD_ALLTARGETS := %(mmake) %(mmake)-includes %(mmake)-clean %(mmake)-quick \
1070 %(mmake)-kobj %(mmake)-funclist
1072 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile %(mmake)-objdir
1075 $(error using %build_module: modname may not be empty)
1078 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1081 # Default values for variables and arguments
1082 BD_DEFLINKLIBNAME := %(modname)
1083 BD_DEFREFFILE := %(objdir)/%(modname)_ALL.ref
1084 BD_DEFDFLAGS := %(cflags)
1085 OBJDIR ?= $(GENDIR)/$(CURDIR)
1087 ## Create genmodule include Makefile for the module
1089 %(mmake)-makefile : %(objdir)/Makefile.%(modname)
1091 %rule_genmodule_makefile \
1092 modname=%(modname) modtype=%(modtype) \
1093 modsuffix=%(modsuffix) targetdir=%(objdir) \
1094 conffile=%(conffile)
1096 %(objdir)/Makefile.%(modname) : | %(objdir)
1098 GLOB_MKDIRS += %(objdir)
1100 # Do not parse these statements if metatarget is not appropriate
1101 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1103 include %(objdir)/Makefile.%(modname)
1105 BD_DEFMODDIR := $(%(modname)_MODDIR)
1108 ## include files generation
1110 BD_INCDIR := %(prefix)/$(AROS_DIR_INCLUDE)
1111 ifeq (%(genincludes),yes)
1112 %(modname)_INCLUDES := proto/%(modname).h clib/%(modname)_protos.h defines/%(modname).h
1114 ifeq (%(genincludes),no)
1115 %(modname)_INCLUDES :=
1117 BD_LIBDEFSINC := %(objdir)/%(modname)_libdefs.h
1118 BD_DEFLIBDEFSINC := %(objdir)/%(modname)_deflibdefs.h
1120 %(mmake)-includes-quick : %(mmake)-includes
1121 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1122 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1123 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1125 ifneq ($(%(modname)_INCLUDES),)
1126 %rule_genmodule_includes modname=%(modname) modtype=%(modtype) \
1127 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1128 conffile=%(conffile) reffile=%(reffile)
1130 %rule_copy_diff_multi \
1131 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(GENINCDIR) \
1132 stampfile=%(objdir)/%(modname)_geninc
1134 %rule_copy_diff_multi \
1135 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(BD_INCDIR) \
1136 stampfile=%(objdir)/%(modname)_incs
1138 %rule_genmodule_dummy modname=%(modname) modtype=%(modtype) \
1139 modsuffix=%(modsuffix) \
1140 targetdir=%(objdir)/dummyinc conffile=%(conffile)
1142 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1143 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) : | %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS))
1144 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) : | $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS))
1145 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) : | $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1146 $(addprefix %(objdir)/dummyinc/,$(%(modname)_INCLUDES)) : | %(objdir)/dummyinc $(addprefix %(objdir)/dummyinc/,$(BD_INCDIRS))
1147 GLOB_MKDIRS += %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1148 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1149 $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS)) \
1150 %(objdir)/dummyinc $(addprefix %(objdir)/dummyinc/,$(BD_INCDIRS))
1154 %rule_genmodule_genlibdefs modname=%(modname) modtype=%(modtype) \
1155 modsuffix=%(modsuffix) targetdir=%(objdir) \
1156 conffile=%(conffile)
1158 BD_LIBDEFSINC := %(objdir)/%(modname)_libdefs.h
1160 %(objdir)/%(modname)_deflibdefs.h : FILENAME := $(BD_LIBDEFSINC)
1161 %(objdir)/%(modname)_deflibdefs.h :
1162 @$(ECHO) "generating $@"
1163 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1166 ## Generation of the funclist file
1168 %(mmake)-funclist : %(modname).funclist
1170 %rule_genmodule_funclist \
1171 modname=%(modname) modtype=%(modtype) modsuffix=%(modsuffix) \
1172 conffile=%(conffile) reffile=%(reffile)
1175 ## Extra genmodule src files generation
1177 %rule_genmodule_files modname=%(modname) modtype=%(modtype) \
1178 modsuffix=%(modsuffix) targetdir=%(objdir) \
1179 conffile=%(conffile) reffile=%(reffile)
1183 BD_FILES := %(files)
1184 BD_STARTFILES := $(addprefix %(objdir)/,$(%(modname)_STARTFILES))
1185 BD_ENDFILES := $(addprefix %(objdir)/,$(%(modname)_ENDFILES))
1187 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1188 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1189 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1191 BD_CFLAGS := %(cflags) -I%(objdir) -idirafter $(TOP)/$(CURDIR) -include %(objdir)/%(modname)_deflibdefs.h
1192 BD_DFLAGS := %(dflags) -I%(objdir) -idirafter $(TOP)/$(CURDIR) -include %(objdir)/%(modname)_deflibdefs.h
1194 BD_LINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBFILES))
1195 BD_LINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBAFILES))
1196 ifeq ($(strip $(%(modname)_LINKLIBFILES) %(linklibfiles)),)
1199 BD_LINKLIB := %(prefix)/$(AROS_DIR_LIB)/lib%(linklibname).a
1201 BD_LINKLIBFILES := $(BD_LINKLIBCFILES) $(BD_LINKLIBAFILES)
1203 BD_CCFILES := $(BD_NARCHFILES) $(BD_STARTFILES) \
1204 $(BD_ENDFILES) $(BD_LINKLIBCFILES) %(linklibfiles)
1206 %rule_compile_multi \
1207 basenames=$(BD_CCFILES) targetdir=%(objdir) \
1208 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) \
1209 compiler=%(compiler)
1211 ifneq ($(BD_LINKLIBAFILES),)
1212 %rule_assemble_multi \
1213 basenames=$(BD_LINKLIBAFILES) targetdir=%(objdir) suffix=.S
1216 ## function reference files generation
1219 basenames=$(BD_FILES) targetdir=%(objdir) \
1220 cflags="-I$(dir $(GENMODULE))/genmod_inc -I%(objdir)/dummyinc $(strip $(BD_CFLAGS))" \
1221 compiler=%(compiler)
1224 BD_REFS := $(addprefix %(objdir)/,$(addsuffix .ref, $(notdir $(BD_FILES))))
1226 BD_REFS := $(addprefix %(objdir)/,$(addsuffix .ref, $(notdir $(filter-out %(noref),$(BD_FILES)))))
1229 %rule_join from=$(BD_REFS) to=%(reffile) \
1230 text="Collecting function references for module %(modname)"
1235 ifeq (%(modsuffix),)
1236 BD_MODULE := %(prefix)/%(moduledir)/%(modname).%(modtype)
1237 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1239 BD_MODULE := %(prefix)/%(moduledir)/%(modname).%(modsuffix)
1240 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modsuffix).o
1243 %(mmake)-quick : %(mmake)
1244 %(mmake) : $(BD_MODULE) $(BD_LINKLIB)
1245 %(mmake)-kobj : $(BD_KOBJ)
1247 BD_OBJS := $(addsuffix .o,$(BD_STARTFILES)) $(BD_ARCHOBJS) \
1248 $(addsuffix .o, $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES))))
1249 BD_ENDOBJS := $(addsuffix .o,$(BD_ENDFILES))
1250 BD_LINKLIBOBJS:= $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_LINKLIBFILES))
1252 # The module is linked from all the compiled .o files
1253 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1254 endobj=$(BD_ENDOBJS) err=$(BD_MODNAME).err uselibs="%(uselibs)"
1257 ifneq ($(BD_LINKLIB),)
1258 %rule_link_linklib libname=%(linklibname) objs=$(BD_LINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1260 $(BD_LINKLIB) : | %(prefix)/$(AROS_DIR_LIB)
1261 GLOB_MKDIRS += %(prefix)/$(AROS_DIR_LIB)
1264 # Link kernel object file
1265 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1266 @$(ECHO) "Linking $@"
1267 @$(AROS_LD) -Ur -o $@ $^
1268 @$(OBJCOPY) $@ `$(NM_PLAIN) $@ | $(AWK) '$$3 ~ /^__.*_(LIST|END)__$$/ {print "-L " $$3;}'`
1271 ## Dependency fine-tuning
1273 BD_DEPS := $(addsuffix .d,$(addprefix %(objdir)/,$(notdir $(BD_CCFILES))))
1274 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1276 $(BD_OBJS) $(BD_DEPS) $(BD_REFS) : | %(objdir)
1277 $(BD_MODULE) : | %(prefix)/%(moduledir)
1278 $(BD_KOBJ) : | $(KOBJSDIR)
1279 GLOB_MKDIRS += %(objdir) %(prefix)/%(moduledir) $(KOBJSDIR)
1281 # Some include files need to be generated before the .c can be parsed.
1282 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj),) # Only for this target these deps are wanted
1283 BD_REFFILE_DEPS := $(BD_LIBDEFSINC) %(objdir)/%(modname)_deflibdefs.h \
1284 $(addprefix %(objdir)/dummyinc/,$(%(modname)_INCLUDES))
1285 $(BD_REFS) : $(BD_REFFILE_DEPS) $(dir $(GENMODULE))/genmod_inc/aros/libcall.h
1287 BD_DFILE_DEPS := $(BD_LIBDEFSINC) %(objdir)/%(modname)_deflibdefs.h \
1288 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES))
1289 $(BD_DEPS) : $(BD_DFILE_DEPS)
1292 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) %(reffile) \
1293 $(BD_REFS) $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
1294 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1295 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1296 $(addprefix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
1297 %(objdir)/%(modname)_deflibdefs.h \
1298 $(addsuffix .c,$(BD_STARTFILES) $(BD_ENDFILES)) \
1300 %(mmake)-clean : FILES := $(BD_TOCLEAN)
1302 @$(ECHO) "Cleaning up for module %(modname)"
1305 endif # $(TARGET) in $(BD_ALLTARGETS)
1307 #------------------------------------------------------------------------------
1310 #------------------------------------------------------------------------------
1311 # Build a module using the deprecated macro's to define the functions in the
1312 # library. Explanation of this macro is done in the developer's manual
1313 %define build_module_macro mmake=/A modname=/A modtype=/A dir= \
1314 conffile=$(BD_MODNAME$(BDID)).conf initfile=$(BD_MODNAME$(BDID))_init \
1315 funcs= files= linklibfiles= cflags=$(CFLAGS) dflags= \
1316 objdir=$(OBJDIR) uselibs= usehostlibs= \
1317 genfunctable= genincludes= compiler=target
1319 %buildid targets="%(mmake) %(mmake)-setup %(mmake)-clean %(mmake)-includes %(mmake)-linklib %(mmake)-quick %(mmake)-kobj"
1321 .PHONY : setup-module$(BDID)
1324 $(error using %build_module: modname may not be empty)
1327 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1330 # assign and generate the local variables used in this macro
1331 BD_MODNAME$(BDID) := %(modname)
1332 BD_MODTYPE$(BDID) := %(modtype)
1333 BD_MODDIR$(BDID) := %(dir)
1334 BD_CONFFILE$(BDID) := %(conffile)
1335 OBJDIR ?= $(GENDIR)/$(CURDIR)
1336 BD_OBJDIR$(BDID) := %(objdir)
1338 BD_ARCHOBJS$(BDID) := $(wildcard $(BD_OBJDIR$(BDID))/arch/*.o)
1339 BD_ARCHFILES$(BDID) := $(basename $(notdir $(BD_ARCHOBJS$(BDID))))
1341 BD_INITFILE$(BDID) := %(initfile)
1342 BD_FUNCS$(BDID) := $(filter-out $(BD_ARCHFILES$(BDID)),%(funcs))
1343 BD_FILES$(BDID) := $(filter-out $(BD_ARCHFILES$(BDID)),%(files))
1344 BD_LIBFILES$(BDID) := %(linklibfiles)
1345 ifneq ($(wildcard $(BD_CONFFILE$(BDID))),)
1346 BD_ENDFILE$(BDID) := $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_end
1348 BD_ENDFILE$(BDID) :=
1351 BD_FUNCSRCS$(BDID) := $(addsuffix .c,%(funcs))
1352 BD_SRCS$(BDID) := $(addsuffix .c,$(BD_FILES$(BDID)))
1353 ifeq ($(filter $(BD_INITFILE$(BDID)), $(BD_ARCHFILES$(BDID))),)
1354 BD_INITOBJ$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir $(BD_INITFILE$(BDID)))))
1356 TMP_INITREPLACE := $(filter $(notdir $(BD_INITFILE$(BDID))), $(BD_ARCHFILES$(BDID)))
1357 TMP_INITKEEP := $(filter-out $(TMP_INITREPLACE),$(notdir $(BD_INITFILE$(BDID))))
1358 BD_INITOBJ$(BDID) := $(addsuffix .o, \
1359 $(addprefix $(BD_OBJDIR$(BDID))/arch/,$(TMP_INITREPLACE)) \
1360 $(addprefix $(BD_OBJDIR$(BDID))/,$(TMP_INITKEEP)) \
1362 BD_ARCHOBJS$(BDID) := $(filter-out $(BD_INITOBJ$(BDID)),$(BD_ARCHOBJS$(BDID)))
1365 TMP_FILES := $(notdir $(BD_FILES$(BDID)))
1366 ifeq (%(genfunctable),yes)
1367 TMP_FILES := $(BD_MODNAME$(BDID))_functable $(TMP_FILES)
1369 ifneq ($(BD_FUNCS$(BDID)),)
1370 ifeq (%(genfunctable),)
1371 ifneq ($(BD_MODTYPE$(BDID)),resource)
1372 TMP_FILES := $(BD_MODNAME$(BDID))_functable $(TMP_FILES)
1375 ifneq (%(genfunctable),no)
1376 TMP_FILES := $(BD_MODNAME$(BDID))_functable $(TMP_FILES)
1379 TMP_FILES += $(BD_FUNCS$(BDID))
1382 BD_OBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(TMP_FILES))) $(BD_ARCHOBJS$(BDID))
1383 BD_ENDOBJ$(BDID) := $(addsuffix .o,$(BD_ENDFILE$(BDID)))
1385 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(BD_INITFILE$(BDID)) $(TMP_FILES)))
1387 BD_GENINCS$(BDID) :=
1388 ifneq (%(genincludes),)
1389 ifeq (%(genincludes),yes)
1390 BD_GENINCS$(BDID):= clib/$(BD_MODNAME$(BDID))_protos.h defines/$(BD_MODNAME$(BDID)).h proto/$(BD_MODNAME$(BDID)).h
1393 ifneq ($(BD_FUNCS$(BDID)),)
1394 ifneq ($(findstring $(BD_MODTYPE$(BDID)),library gadget device),)
1395 BD_GENINCS$(BDID):= clib/$(BD_MODNAME$(BDID))_protos.h defines/$(BD_MODNAME$(BDID)).h proto/$(BD_MODNAME$(BDID)).h
1399 # Only generate libdefs.h if the config file exists
1400 ifneq ($(wildcard $(BD_CONFFILE$(BDID))),)
1401 BD_LIBDEFSINC$(BDID):= $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_libdefs.h
1403 BD_LIBDEFSINC$(BDID):=
1406 BD_CFLAGS$(BDID) := %(cflags) -I$(BD_OBJDIR$(BDID)) -I. -I$(TOP)/workbench/libs -include $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h
1408 BD_DFLAGS$(BDID) := $(BD_CFLAGS$(BDID))
1410 BD_DFLAGS$(BDID) := %(dflags) -I$(BD_OBJDIR$(BDID)) -I. -I$(TOP)/workbench/libs -include $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h
1413 # Add additional files depending the module type
1414 ifeq ($(findstring $(BD_MODTYPE$(BDID)),library gadget datatype handler device resource mui mcc mcp hidd),)
1415 $(error unhandled MODTYPE %(modtype))
1417 ifeq ($(BD_MODDIR$(BDID)),)
1418 ifeq ($(BD_MODTYPE$(BDID)),library)
1419 BD_MODDIR$(BDID) := $(AROS_LIBS)
1421 ifeq ($(BD_MODTYPE$(BDID)),gadget)
1422 BD_MODDIR$(BDID) := $(AROS_GADGETS)
1424 ifeq ($(BD_MODTYPE$(BDID)),datatype)
1425 BD_MODDIR$(BDID) := $(AROS_DATATYPES)
1427 ifeq ($(BD_MODTYPE$(BDID)),handler)
1428 BD_MODDIR$(BDID) := $(AROS_FS)
1430 ifeq ($(BD_MODTYPE$(BDID)),device)
1431 BD_MODDIR$(BDID) := $(AROS_DEVS)
1433 ifeq ($(BD_MODTYPE$(BDID)),resource)
1434 BD_MODDIR$(BDID) := $(AROS_RESOURCES)
1436 ifeq ($(BD_MODTYPE$(BDID)),mui)
1437 BD_MODDIR$(BDID) := $(AROS_CLASSES)/Zune
1439 ifeq ($(BD_MODTYPE$(BDID)),mcc)
1440 BD_MODDIR$(BDID) := $(AROS_CLASSES)/Zune
1442 ifeq ($(BD_MODTYPE$(BDID)),mcp)
1443 BD_MODDIR$(BDID) := $(AROS_CLASSES)/Zune
1445 ifeq ($(BD_MODTYPE$(BDID)),hidd)
1446 BD_MODDIR$(BDID) := $(AROS_DRIVERS)
1450 BD_MODULE$(BDID) := $(BD_MODDIR$(BDID))/$(BD_MODNAME$(BDID)).$(BD_MODTYPE$(BDID))
1451 BD_GENFILES$(BDID) := $(BD_MODULE$(BDID))
1452 BD_DEPS$(BDID) += $(BD_LINKLIBDEPS$(BDID))
1454 #MM- includes-all : %(mmake)-includes
1455 #MM %(mmake) : %(mmake)-includes %(mmake)-setup
1456 #MM %(mmake)-includes : %(mmake)-setup
1459 %(mmake)-quick : %(mmake)
1461 %(mmake) : $(BD_GENFILES$(BDID))
1465 @$(ECHO) "Cleaning up for module $(BD_MODNAME$(BDID))"
1466 @$(RM) $(BD_OBJS$(BDID)) $(BD_DEPS$(BDID)) \
1467 $(addprefix $(BD_OBJDIR$(BDID))/,$(addsuffix .c,$(BD_GENFILES$(BDID)))) \
1468 $(addprefix $(GENINCDIR)/,$(BD_GENINCS$(BDID))) \
1469 $(addprefix $(AROS_INCLUDES)/,$(BD_GENINCS$(BDID))) \
1470 $(BD_LIBDEFSINC$(BDID)) \
1471 $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h \
1472 $(BD_ENDFILE$(BDID)).c $(BD_ENDOBJ$(BDID))
1475 %(mmake)-setup : setup-module$(BDID)
1477 #MM %(mmake)-includes : setup-clib
1479 TMP_DEPS := $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h
1480 ifneq ($(BD_GENINCS$(BDID)),)
1481 TMP_DEPS += $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_includes.stamp \
1482 $(addprefix $(AROS_INCLUDES)/,$(BD_GENINCS$(BDID)))
1485 %(mmake)-includes : $(TMP_DEPS)
1487 $(TMP_DEPS) : $(BD_LIBDEFSINC$(BDID))
1489 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-linklib %(mmake)-quick %(mmake)-kobj),) # Avoid conflicts
1490 ifneq ($(dir $(BD_FILES$(BDID))),./)
1491 vpath %.c $(filter-out ./,$(dir $(BD_FUNCS$(BDID)) $(BD_FILES$(BDID))))
1494 %rule_compile basename=% targetdir=$(BD_OBJDIR$(BDID)) \
1495 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID)) \
1496 compiler=%(compiler)
1497 %rule_compile basename=$(BD_ENDFILE$(BDID)) targetdir=$(BD_OBJDIR$(BDID)) \
1498 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID)) \
1499 compiler=%(compiler)
1500 %rule_compile basename=$(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_functable targetdir=$(BD_OBJDIR$(BDID)) \
1501 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID)) \
1502 compiler=%(compiler)
1505 BD_DFILE_DEPS$(BDID) := $(BD_LIBDEFSINC$(BDID)) $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h
1507 # Some include files need to be generated before the .c can be parsed.
1508 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick %(mmake)-linklib) %(mmake)-kobj,) # Only for this target these deps are wanted
1509 $(BD_DEPS$(BDID)) : $(BD_DFILE_DEPS$(BDID))
1512 # Generation of the autogenerated .c and .h files.
1513 $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h :
1514 @$(ECHO) "generating $@"
1515 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(notdir $(BD_LIBDEFSINC$(BDID)))\"" >$@
1517 %libdefs_rule conffile=$(BD_CONFFILE$(BDID)) dest=$(BD_LIBDEFSINC$(BDID))
1519 ifneq ($(BD_ENDFILE$(BDID)),)
1520 $(BD_ENDFILE$(BDID)).c :
1521 @$(ECHO) "generating $@"
1522 @$(ECHO) "#include <libcore/libtail.c>" >$@
1525 %rule_genfunctable name=$(BD_MODNAME$(BDID))_functable files=$(BD_FUNCS$(BDID)) dir=$(BD_OBJDIR$(BDID)) \
1526 libdefs=$(BD_LIBDEFSINC$(BDID))
1528 # The module is linked from all the compiled .o files
1529 %rule_linkmodule module=$(BD_MODULE$(BDID)) objs="$(BD_INITOBJ$(BDID)) $(BD_OBJS$(BDID))" \
1530 endobj=$(BD_ENDOBJ$(BDID)) err=$(BD_MODNAME).err uselibs="%(uselibs)" \
1531 usehostlibs="%(usehostlibs)"
1533 BD_HEADER_DEPS$(BDID) := $(wildcard headers.tmpl) $(BD_LIBDEFSINC$(BDID)) \
1534 $(BD_FUNCSRCS$(BDID)) \
1535 $(SCRIPTDIR)/genshared \
1536 $(SCRIPTDIR)/genclib.awk $(SCRIPTDIR)/genpclib.awk \
1537 $(SCRIPTDIR)/gendefines.awk $(SCRIPTDIR)/genpdefines.awk
1539 # Regenerate the includes when some of the dependencies are changed
1540 $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_includes.stamp : $(BD_HEADER_DEPS$(BDID))
1541 @$(SCRIPTDIR)/genshared -clib -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1542 @$(SCRIPTDIR)/genshared -defines -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1543 @$(SCRIPTDIR)/genshared -proto -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1544 @$(SCRIPTDIR)/genshared -pclib -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1545 @$(SCRIPTDIR)/genshared -pdefines -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1546 @$(SCRIPTDIR)/genshared -pproto -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1549 # Generate includes the first time they are needed
1550 $(GENINCDIR)/clib/$(BD_MODNAME$(BDID))_private_protos.h \
1551 $(GENINCDIR)/clib/$(BD_MODNAME$(BDID))_protos.h \
1552 $(GENINCDIR)/defines/$(BD_MODNAME$(BDID)).h \
1553 $(GENINCDIR)/proto/$(BD_MODNAME$(BDID)).h :
1554 @$(SCRIPTDIR)/genshared -clib -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1555 @$(SCRIPTDIR)/genshared -proto -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1556 @$(SCRIPTDIR)/genshared -pclib -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1557 @$(SCRIPTDIR)/genshared -pdefines -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1558 @$(SCRIPTDIR)/genshared -pproto -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1559 @$(TOUCH) $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_includes.stamp
1561 # The include files generated in $(GENINCDIR) have to be mirrored in the AROS include directory
1562 %rule_copy from=$(GENINCDIR)/clib/$(BD_MODNAME$(BDID))_protos.h to=$(AROS_INCLUDES)/clib/$(BD_MODNAME$(BDID))_protos.h
1563 %rule_copy from=$(GENINCDIR)/defines/$(BD_MODNAME$(BDID)).h to=$(AROS_INCLUDES)/defines/$(BD_MODNAME$(BDID)).h
1564 #%rule_copy from=$(GENINCDIR)/pragmas/$(BD_MODNAME$(BDID)).h to=$(AROS_INCLUDES)/pragmas/$(BD_MODNAME$(BDID)).h
1565 %rule_copy from=$(GENINCDIR)/proto/$(BD_MODNAME$(BDID)).h to=$(AROS_INCLUDES)/proto/$(BD_MODNAME$(BDID)).h
1567 MYDIRS$(BDID) := $(BD_OBJDIR$(BDID)) $(GENINCDIR) $(GENINCDIR)/clib \
1568 $(GENINCDIR)/proto $(GENINCDIR)/defines \
1569 $(GENINCDIR)/pragmas $(AROS_INCLUDES) $(AROS_INCLUDES)/clib $(AROS_INCLUDES)/proto \
1570 $(AROS_INCLUDES)/defines $(AROS_INCLUDES)/pragmas \
1571 $(BD_MODDIR$(BDID)) $(KOBJSDIR)
1573 %rule_makedirs dirs=$(MYDIRS$(BDID)) setuptarget=setup-module$(BDID)
1575 #MM %(mmake)-linklib : %(mmake)-setup setup-clib
1576 #MM %(mmake)-kobj : %(mmake)-setup setup-clib
1578 TMP_DEPS := $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h \
1579 $(BD_LIBDEFSINC$(BDID))
1580 ifneq ($(BD_GENINCS$(BDID)),)
1581 TMP_DEPS += $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_includes.stamp \
1582 $(addprefix $(AROS_INCLUDES)/,$(BD_GENINCS$(BDID)))
1585 %(mmake)-linklib : $(TMP_DEPS)
1586 %(mmake)-kobj : $(TMP_DEPS)
1588 # Link only when target %(mmake)-linklib otherwise for example jpeg.datatype
1589 # that depend on the jpeg library can cause to get this rule executed unwanted
1590 ifneq ($(filter $(TARGET),%(mmake)-linklib %(mmake)-kobj),)
1591 %(mmake)-linklib : $(LIBDIR)/lib$(BD_MODNAME$(BDID)).a
1592 %(mmake)-kobj : $(KOBJSDIR)/$(BD_MODNAME$(BDID))_$(BD_MODTYPE$(BDID)).o
1594 %rule_link_linklib libname=$(BD_MODNAME$(BDID)) libdir=$(LIBDIR) \
1595 objs="$(BD_INITOBJ$(BDID)) $(BD_OBJS$(BDID)) $(BD_ENDOBJ$(BDID))"
1597 $(KOBJSDIR)/$(BD_MODNAME$(BDID))_$(BD_MODTYPE$(BDID)).o : \
1598 $(BD_INITOBJ$(BDID)) $(BD_OBJS$(BDID)) $(BD_ENDOBJ$(BDID))
1599 @$(ECHO) "Linking $@"
1600 $(AROS_LD) -Ur -o $@ $^
1601 $(OBJCOPY) $@ `$(NM_PLAIN) $@ | $(AWK) '$$3 ~ /^__.*_(LIST|END)__$$/ {print "-L " $$3;}'`
1604 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-linklib %(mmake)-kobj" deps=$(BD_DEPS$(BDID))
1606 #------------------------------------------------------------------------------
1609 #------------------------------------------------------------------------------
1611 # - mmake is the mmaketarget
1612 # - libname is the baselibname e.g. lib%(libname).a will be created
1613 # - files are the C source files to include in the lib. The list of files
1614 # has to be given without the .c suffix
1615 # - asmfiles are the asm files to include in the lib. The list of files has to
1616 # be given with the .s suffix
1617 # - cflags are the flags to compile the source (default $(CFLAGS))
1618 # - dflags are the flags use during makedepend (default equal to cflags)
1619 # - aflags are the flags use during assembling (default $(AFLAGS))
1620 # - objdir is where the .o are generated
1621 # - libdir is the directory where the linklib will be placed (default $(LIBDIR))
1622 %define build_linklib mmake=/A libname=/A files="$(basename $(wildcard *.c))" \
1623 asmfiles= cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) objdir=$(OBJDIR) libdir=$(LIBDIR)
1625 %buildid targets="%(mmake) %(mmake)-clean"
1627 # assign and generate the local variables used in this macro
1628 BD_LIBNAME$(BDID) := %(libname)
1629 OBJDIR ?= $(GENDIR)/$(CURDIR)
1630 BD_OBJDIR$(BDID) := %(objdir)
1631 BD_LIBDIR$(BDID) := %(libdir)
1633 BD_FILES$(BDID) := %(files)
1634 BD_ASMFILES$(BDID) := %(asmfiles)
1635 BD_SRCS$(BDID) := $(addsuffix .c,$(BD_FILES$(BDID)))
1636 BD_OBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir $(BD_FILES$(BDID)) $(BD_ASMFILES$(BDID)))))
1637 BD_DEPS$(BDID) := $(patsubst %.o,%.d,$(BD_OBJS$(BDID)))
1639 BD_CFLAGS$(BDID) := %(cflags)
1641 BD_DFLAGS$(BDID) := $(BD_CFLAGS$(BDID))
1643 BD_DFLAGS$(BDID) := %(dflags)
1645 BD_AFLAGS$(BDID) := %(aflags)
1647 BD_LINKLIB$(BDID) := $(BD_LIBDIR$(BDID))/lib$(BD_LIBNAME$(BDID)).a
1649 .PHONY : %(mmake) %(mmake)-clean
1652 %(mmake) : $(BD_LINKLIB$(BDID))
1656 @$(RM) $(BD_OBJS$(BDID)) $(BD_DEPS$(BDID))
1658 ifeq ($(TARGET),%(mmake))
1659 ifneq ($(dir $(BD_FILES$(BDID))),./)
1660 vpath %.c $(filter-out ./,$(dir $(BD_FILES$(BDID))))
1663 %rule_compile basename=% targetdir=$(BD_OBJDIR$(BDID)) \
1664 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID))
1665 %rule_assemble basename=% targetdir=$(BD_OBJDIR$(BDID)) \
1666 flags=$(BD_AFLAGS$(BDID))
1669 %rule_link_linklib libname=%(libname) objs=$(BD_OBJS$(BDID)) libdir=$(BD_LIBDIR$(BDID))
1671 %include_deps depstargets=%(mmake) deps=$(BD_DEPS$(BDID))
1673 $(BD_OBJS$(BDID)) $(BD_DEPS$(BDID)) : | $(BD_OBJDIR$(BDID))
1674 $(BD_LINKLIB$(BDID)) : | $(BD_LIBDIR$(BDID))
1675 GLOB_MKDIRS += $(BD_OBJDIR$(BDID)) $(BD_LIBDIR$(BDID))
1678 #------------------------------------------------------------------------------
1681 #------------------------------------------------------------------------------
1683 # - mmake is the mmaketarget
1684 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
1685 # - description is the catalog description file (.cd) (default *.cd)
1686 # - subdir is the destination subdir of the catalogs
1687 # - name is the name of the destination catalog, without the .catalog suffix
1688 # - source is the path to the generated source code file
1689 # - dir is the base destination directory (default $(AROS_CATALOGS))
1690 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
1692 %define build_catalogs mmake=/A name=/A subdir=/A \
1693 catalogs="$(basename $(wildcard *.ct))" source="../strings.h" \
1694 description="$(basename $(wildcard *.cd))" dir=$(AROS_CATALOGS) \
1695 sourcedescription="$(TOOLDIR)/C_h_orig"
1697 %buildid targets="%(mmake) %(mmake)-clean"
1699 BD_SRCS$(BDID) := $(foreach name, %(catalogs), $(name).ct)
1700 BD_OBJS$(BDID) := $(foreach name, %(catalogs), %(dir)/$(name)/%(subdir)/%(name).catalog)
1701 BD_DIRS$(BDID) := $(foreach name, %(catalogs), %(dir)/$(name)/%(subdir))
1704 %(mmake) : $(BD_OBJS$(BDID)) %(source)
1706 $(BD_OBJS$(BDID)) : | $(BD_DIRS$(BDID))
1707 GLOB_MKDIRS += $(BD_DIRS$(BDID))
1709 %(dir)/%/%(subdir)/%(name).catalog : %.ct %(description).cd
1710 @$(ECHO) "Creating %(name) catalog for language $*."
1711 @$(FLEXCAT) %(description).cd $*.ct CATALOG=%(dir)/$*/%(subdir)/%(name).catalog || [ $$? -lt 10 ]
1714 %(source) : %(description).cd
1715 @$(ECHO) "Creating %(name) catalog source file %(source)"
1716 @$(FLEXCAT) %(description).cd %(source)=%(sourcedescription).sd
1721 $(RM) $(BD_OBJS$(BDID)) %(source)
1723 .PHONY: %(mmake) %(mmake-clean)
1727 #-----------------------------------------------------------------------------
1729 #-----------------------------------------------------------------------------
1731 # - mmake is the mmaketarget
1732 # - icons is a list of icon base names (ie. without the .info suffix)
1733 # - dir is the destination directory
1734 #-----------------------------------------------------------------------------
1736 %define build_icons mmake=/A icons=/A dir=/A
1738 %buildid targets="%(mmake) %(mmake)-clean"
1740 BD_OBJS$(BDID) := $(foreach icon, %(icons), %(dir)/$(icon).info)
1743 %(mmake) : $(BD_OBJS$(BDID))
1745 %(dir)/%.info : %.info.src %.png
1746 @$(ECHO) Creating $(notdir $@)...
1747 @$(ILBMTOICON) $+ $@
1749 $(BD_OBJS$(BDID)) : | %(dir)
1750 GLOB_MKDIRS += %(dir)
1754 @$(RM) $(BD_OBJS$(BDID))
1760 #-----------------------------------------------------------------------------
1762 #------------------------------------------------------------------------------
1763 # Compile files for a arch specific replacement of code for a module
1764 # - files: the basename of the C files to compile.
1765 # - asmfiles: the basename of the asm file to assemble.
1766 # - mainmmake: the mmake of the module in the main directory to compile these
1767 # arch specific files for.
1768 # - maindir: the object directory for the main module
1769 # - arch: the arch for which to compile these files. It can has to have the form
1770 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
1771 # - cflags (default $(CFLAGS)): the C flags to use for compilation
1772 # - dflags: the flags used during creation of dependency file. If not specified
1773 # the same value as cflags will be used
1774 # - aflags: the flags used during assembling
1775 # - compiler: (host or target) specifies which compiler to use. By default
1776 # the target compiler is used
1777 %define build_archspecific files= asmfiles= mainmmake=/A maindir=/A arch=/A \
1778 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
1780 ifeq (%(files) %(asmfiles),)
1781 $(error no files or asmfiles given)
1784 %buildid targets="%(mainmmake)-%(arch)"
1786 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1787 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1788 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1790 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
1793 $(error argument arch has to be non empty for the rule_compile_archspecific macro)
1796 BD_OBJDIR$(BDID) := $(GENDIR)/%(maindir)/arch
1797 BD_COBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1798 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
1799 BD_OBJS$(BDID) := $(BD_COBJS$(BDID)) $(BD_ASMOBJS$(BDID))
1800 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1802 ifeq ($(TARGET),%(mainmmake)-%(arch))
1803 vpath %.c $(filter-out ./,$(dir %(files)))
1804 vpath %.s $(filter-out ./,$(dir %(asmfiles)))
1805 vpath %.S $(filter-out ./,$(dir %(asmfiles)))
1808 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID))
1809 GLOB_MKDIRS += $(BD_OBJDIR$(BDID))
1812 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
1814 ifeq ($(findstring %(compiler),host target),)
1815 $(error unknown compiler %(compiler))
1817 ifeq (%(compiler),target)
1818 $(BD_COBJS$(BDID)) : TMP_CMD:=$(TARGET_CC)
1820 ifeq (%(compiler),host)
1821 $(BD_COBJS$(BDID)) : TMP_CMD:=$(HOST_CC)
1823 ifneq (%(modulename),)
1824 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) \
1825 --include $(GENDIR)/%(maindir)/%(modulename)_deflibdefs.h
1827 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
1829 ifeq ($(TARGET),%(mainmmake)-%(arch))
1830 $(BD_OBJDIR$(BDID))/%.o : %.c
1831 %compile_q opt=$(TMP_CFLAGS) cmd=$(TMP_CMD)
1835 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags)
1837 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
1839 ifeq ($(TARGET),%(mainmmake)-%(arch))
1840 $(BD_OBJDIR$(BDID))/%.d : %.c
1841 %mkdepend_q flags=$(TMP_DFLAGS)
1844 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
1846 ifeq ($(TARGET),%(mainmmake)-%(arch))
1847 $(BD_OBJDIR$(BDID))/%.o : %.s
1848 %assemble_q opt=$(AFLAGS)
1849 $(BD_OBJDIR$(BDID))/%.o : %.S
1850 %assemble_q opt=$(AFLAGS)
1853 %include_deps depstargets=%(mainmmake)-%(arch) deps=$(BD_DEPS$(BDID))
1855 #------------------------------------------------------------------------------
1863 # ======================
1864 # Old stuff, will probably be removed in the future
1869 # GNU Make automatic variables
1871 # $< First dependency
1872 # $? All newer dependencies
1873 # $^ All dependencies
1874 # $* The stem (ie. target is dir/a.foo.b and the pattern is
1875 # a.%.b, then the stem is dir/foo)
1877 #------------------------------------------------------------------------------
1878 # rule to generate libdefs.h with archtool (options may go away!)
1879 %define libdefs_rule conffile=lib.conf genlibdefstool=$(ARCHTOOL) dest=libdefs.h
1880 %(dest) : %(conffile) %(genlibdefstool)
1881 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
1882 @%(genlibdefstool) -c -o $@ %(conffile)
1886 #------------------------------------------------------------------------------
1887 # generate asm files from c files (for debugging purposes)
1890 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
1891 @$(TARGET_CC) -S $(CFLAGS) $< -c -o $@
1894 #------------------------------------------------------------------------------
1895 # Convert two png images to an Amiga icon file based on the description
1896 # file %(from), with outputfile going to %(to).
1897 %define makeicon2 from=$< to=$@ img1="$(basename $(basename $<))_N.png" img2="$(basename $(basename $<))_S.png"
1898 @$(ECHO) "Creating icon %(to)..."
1899 @$(PNGTOPNM) %(img1) | $(PPMTOILBM) -maxplanes 8 >$(GENDIR)/genicon1.iff
1900 @$(PNGTOPNM) %(img2) | $(PPMTOILBM) -maxplanes 8 >$(GENDIR)/genicon2.iff
1901 @$(ILBMTOICON) %(from) $(GENDIR)/genicon1.iff $(GENDIR)/genicon2.iff %(to)
1904 #------------------------------------------------------------------------------
1905 # NOTE: The following are all part of Iain's build changes, please don't use
1906 # or change anything below this line until you know what you are doing. This
1907 # is so that I don't conflict with the semantics of any of the above macros.
1908 #------------------------------------------------------------------------------
1910 #------------------------------------------------------------------------------
1911 # Copy files from one directory to another.
1913 %define copy_files_q files=$(FILES) src=. dst=/A maketarget=files-copy
1915 SRC_FILES := $(foreach f, %(files), %(src)/$(f))
1916 DST_FILES := $(foreach f, %(files), %(dst)/$(f))
1918 %(maketarget) : setup $(DST_FILES)
1920 $(DST_FILES) : %(dst)/% : %(src)/%
1928 #----------------------------------------------------------------------------------
1929 # Copy a diretory recursively to another place, preserving the original
1930 # hierarchical structure
1932 # src: the source directory whose content will be copied
1933 # dst: the directory where to copy src's content. If not existing, it will be made.
1935 %define copy_dir_recursive mmake=/A src=$(TOP)/$(CURDIR) dst=/A
1937 %(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)
1938 %(mmake)_DIRS := $(sort $(foreach f,$(%(mmake)_FILES),$(dir $(f))))
1940 define %(mmake)_mkdir
1945 define %(mmake)_copy
1946 $(3)/$(1): $(2)/$(1) | $(dir $(3)/$(1))
1953 %(mmake): | $(GENDIR)/$(CURDIR)
1954 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1955 $(ECHO) "all: $(addprefix \$$(DST)/,$(%(mmake)_FILES))" > $$m
1956 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1957 for d in $(%(mmake)_DIRS); do \
1958 $(ECHO) "\$$(DST)/$$d: ; $(MKDIR) \$$@" >> $$m; \
1960 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1961 for f in $(%(mmake)_FILES); do \
1962 $(ECHO) "\$$(DST)/$$f: \$$(SRC)/$$f | \$$\$$(@D); $(CP) \$$< \$$@" >> $$m; \
1964 for dst in %(dst); do \
1965 $(MAKE) -f $$m DST=$$dst SRC=%(src) all; \
1968 $(GENDIR)/$(CURDIR):
1973 #------------------------------------------------------------------------------
1974 # Copy include files into the includes directories. There are currently
1975 # two include directories. One for building AROS $(AROS_INCLUDES) and one
1976 # for building tools that need to run on the host system $(GENINCDIR). The
1977 # $(GENINCDIR) path must not contain any references to the C runtime
1978 # library header files.
1980 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. dir=include
1983 INCL_FILES_1 := $(subst %(dir),$(AROS_INCLUDES)/%(path),%(includes))
1984 INCL_FILES_2 := $(subst %(dir),$(GENINCDIR)/%(path),%(includes))
1985 _INC_PATH := %(dir)/
1987 INCL_FILES_1 := $(foreach f,%(includes),$(AROS_INCLUDES)/%(path)/$(f))
1988 INCL_FILES_2 := $(foreach f,%(includes),$(GENINCDIR)/%(path)/$(f))
1994 ifneq (%(mmake),includes-copy)
1996 includes-copy : %(mmake)
1999 %(mmake) : $(INCL_FILES_1) $(INCL_FILES_2)
2003 $(AROS_INCLUDES)/%(path)/%.h : $(_INC_PATH)%.h
2006 $(GENINCDIR)/%(path)/%.h : $(_INC_PATH)%.h
2009 $(INCL_FILES_1) : | $(AROS_INCLUDES)/%(path)
2010 $(INCL_FILES_2) : | $(GENINCDIR)/%(path)
2011 GLOB_MKDIRS += $(AROS_INCLUDES)/%(path) $(GENINCDIR)/%(path)
2015 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
2016 STUBS_SRC := $(foreach f,$(STUBS),$(f).c)
2017 STUBS_OBJ := $(foreach f,$(STUBS),$(OBJDIR)/$(f).o)
2018 STUBS_MEM := $(foreach f,$(STUBS),$(f).o)
2019 STUBS_DEP := $(foreach f,$(STUBS),$(OBJDIR)/$(f).d)
2020 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
2022 #MM- linklibs : hidd-%(hidd)-stubs
2023 #MM- %(parenttarget): hidd-%(hidd)-stubs
2024 #MM hidd-%(hidd)-stubs : includes includes-copy
2025 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
2027 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
2030 $(STUBS_OBJ) : $(STUBS_SRC)
2031 %compile_q cmd=$(TARGET_CC) opt=%(cflags)
2033 $(STUBS_DEP) : $(STUBS_SRC)
2034 %mkdepend_q flags=%(dflags)
2037 %mkdirs_q $(OBJDIR) $(LIBDIR)
2041 -@$(RM) $(HIDD_LIB) $(OBJDIR)
2043 DEPS := $(DEPS) $(STUBS_DEP)
2047 #------------------------------------------------------------------------------
2048 # Build an imported source tree which uses the configure script from the
2049 # autoconf package. This rule will try to "integrate" the produced files as
2050 # much as possible in the AROS build, for exampley by putting libraries in the
2051 # standard library directory, includes in the standard include directory, and
2052 # so on. You can however override this behaviour.
2054 # As a special "bonus" for you, the PROGDIR environment variable is defined to
2055 # be %(bindir) (or its deduced value) when running "make install", and
2056 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
2057 # configure script some more parameters whose value depends upon the PROGDIR
2058 # env var, so that the program gets all its stuff installed in the proper place
2059 # when building it, but when running it from inside AROS it can also find that
2060 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
2061 # the configuration parameters set when running ./configure
2063 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
2064 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
2065 # to the name which has to follow it.
2068 %define build_with_configure mmake=/A srcdir=$(TOP)/$(CURDIR) prefix= aros_prefix= \
2069 extraoptions= nix_dir_layout= nix=no host=no \
2070 install_target=install postconfigure= postinstall=
2073 %(mmake)-prefix := %(prefix)
2075 %(mmake)-prefix := $(AROS_CONTRIB)
2078 ifneq (%(aros_prefix),)
2079 %(mmake)-aros_prefix := %(aros_prefix)
2081 %(mmake)-aros_prefix := $(%(mmake)-prefix)
2085 %(mmake)-nix := -nix
2086 %(mmake)-volpfx := /
2087 %(mmake)-volsfx := /
2089 ifeq (%(nix_dir_layout),)
2090 %(mmake)-nix_dir_layout := yes
2093 %(mmake)-volsfx := :
2095 ifeq (%(nix_dir_layout),)
2096 %(mmake)-nix_dir_layout := no
2100 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
2102 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) exec_prefix=$(%(mmake)-prefix)
2104 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) %(host)),yes)
2105 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
2106 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2109 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
2110 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
2112 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2115 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
2117 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) sbindir=$(%(mmake)-prefix) \
2118 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) oldincludedir=$(AROS_INCLUDES)
2122 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
2124 #MM- %(mmake) : setup includes linklibs-core %(mmake)-quick
2126 ifneq (%(install_target),)
2127 %(mmake)-install_command = \
2128 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2129 -C $(GENDIR)/$(CURDIR) %(install_target) && \
2130 $(TOUCH) $(GENDIR)/$(CURDIR)/.installed
2132 %(mmake)-uninstall_command = \
2133 $(RM) $(GENDIR)/$(CURDIR)/.installed && \
2134 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2135 -C $(GENDIR)/$(CURDIR) uninstall
2137 %(mmake)-install_command := true
2138 %(mmake)-uninstall_command := true
2141 #MM- %(mmake)-quick : %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
2144 %(mmake)-build_and_install-quick : $(GENDIR)/$(CURDIR)/.configured
2145 if ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q -C $(GENDIR)/$(CURDIR); then \
2146 $(RM) $(GENDIR)/$(CURDIR)/.installed && \
2147 $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -C $(GENDIR)/$(CURDIR) && \
2148 $(%(mmake)-install_command); \
2151 %(srcdir)/.files-touched:
2152 find %(srcdir) -exec $(TOUCH) -r %(srcdir)/configure '{}' \; && \
2156 %(mmake)-uninstall :
2157 $(%(mmake)-uninstall_command)
2159 ifneq ($(DEBUG),yes)
2160 %(mmake)-s_flag = -s
2164 %(mmake)-configure : $(GENDIR)/$(CURDIR)/.configured
2167 $(GENDIR)/$(CURDIR)/.configured : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2169 %mkdirs_q $(GENDIR)/$(CURDIR)
2170 cd $(GENDIR)/$(CURDIR) && \
2171 find . -name config.cache -exec $(RM) '{}' \; && \
2173 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) && \
2176 $(GENDIR)/$(CURDIR)/.configured : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2178 %mkdirs_q $(GENDIR)/$(CURDIR)
2179 cd $(GENDIR)/$(CURDIR) && \
2180 find . -name config.cache -exec $(RM) '{}' \; && \
2181 CC="$(TARGET_CC) $(%(mmake)-nix) $(%(mmake)-s_flag)" CC_FOR_BUILD="$(HOST_CC)" \
2182 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) --host=$(AROS_TARGET_CPU)-aros \
2183 --target=$(AROS_TARGET_CPU)-aros --build=local --disable-nls --without-x \
2184 --without-pic --disable-shared && \
2189 %(mmake)-clean : %(mmake)-uninstall
2190 @$(RM) $(GENDIR)/$(CURDIR)
2193 #############################################################################
2194 #############################################################################
2196 ## Misciellanous macros. Everying that doesn't fin above should be put ##
2199 #############################################################################
2200 #############################################################################
2202 #----------------------------------------------------------------------------------
2203 # Given an archive name, patches names and locations where to find them, fetch
2204 # the archive and the patches from any of those locations, unpack the archive
2205 # and then apply the patches.
2207 # Locations currently supported are http and ftp sites, plus local filesystem
2208 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
2209 # the fetch.sh script needs to be modified, since this macro relies on that script.
2213 # - archive_origins = list of locations where to find the archive. They are tried
2214 # in sequence, until the archive is found and fetching it
2215 # succeeded. If not specified, the current directory is assumed.
2216 # - archive = the archive name. Mandatory.
2217 # - destination = the local directory where to put the archive and patches.
2218 # If not specified, the current directory is assumed.
2219 # - patches_origins = list of locations where to find the patches. They are tried
2220 # in sequence, until a patch is found and fetching it
2221 # succeeded. If not specified, the current directory is assumed.
2222 # - patches_specs = list of "patch specs". A patch spec is of the form
2223 # patch_name[:[patch_subdir][:patch_opt]].
2225 # - patch_name = the name of the patch file
2226 # - patch_subdir = the directory within \destination\ where to
2228 # - patch_opt = any options to pass to the `patch' command
2229 # when applying the patch.
2231 # The patch_subdir and patch_opt fields are optional.
2233 %define fetch archive_origins=. archive=/A suffixes= destination=. patches_origins=. patches_specs=::
2234 $(FETCH) -ao "%(archive_origins)" -a %(archive) -as "%(suffixes)" -d %(destination) \
2235 -po "%(patches_origins)" -p %(patches_specs)
2238 #-----------------------------------------------------------------------------------------
2239 # Joins the features of %fetch and %build_with_configure, taking advantage of
2240 # the naming scheme of GNU packages. GNU packages names are in the form
2242 # <package name>-<version number>.<archive format suffix>
2244 # If a patch is provided, it *must* be named the following way:
2246 # <package name>-<version number>-aros.diff
2248 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
2249 # CD'ing into the archive's extracted directory.
2251 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
2252 # the %fetch_and_build macro only accept *one* patch for each package. It's up to you
2253 # to make that patch fully comprehensive.
2255 # NOTE: GNU packages are always compiled with *nix semantics turned on.
2259 # - mmake = the meta make target, as would be supplied to the %build_with_configure
2261 # - package = the GNU package name, sans version and archive format suffixes.
2262 # - version = the package's version number, or otherwise any other version string.
2263 # It gets appended to the package name to form the basename of the archive.
2264 # - suffixes = a list of suffixes to apped to the the package name plus the
2265 # version. Each one of them is tried until a matching archive is found.
2266 # Defaults to "tat.bz2 tar.gz".
2267 # - destination = same meaning as the one for the %fetch macro
2268 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
2269 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
2271 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
2272 # - prefix = same meaning as the one for the %build_with_configure macro. Defaults to
2274 # - aros_prefix = same meaning as the one for the %build_with_configure macro. Defaults to
2276 # - extraoptions = same meaning as the one for the %build_with_configure macro.
2277 # - postinstall = same meaning as the one for the %build_with_configure macro.
2279 %define fetch_and_build mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2280 srcdir= package_repo= patch=no patch_repo= prefix= \
2281 aros_prefix= extraoptions= postconfigure= postinstall= nix=no nix_dir_layout=
2283 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
2284 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
2286 %(mmake)-archbase := %(package)-%(version)
2289 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
2291 %(mmake)-prefix := %(prefix)
2294 ifneq (%(subpackage),)
2295 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
2297 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
2301 %(mmake)-%(subpackage)-srcdir := %(srcdir)
2303 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
2307 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-p1
2309 %(mmake)-%(subpackage)-patches_specs := ::
2312 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
2314 .PHONY : %(mmake)-%(subpackage)-fetch
2316 %(mmake)-%(subpackage)-fetch :
2317 %fetch archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
2318 destination=$(PORTSDIR)/%(package) \
2319 archive_origins=". %(package_repo)" \
2320 patches_specs="$(%(mmake)-%(subpackage)-patches_specs)" patches_origins=". %(patch_repo)"
2322 #MM- %(mmake) : %(mmake)-%(subpackage)
2324 PACKAGES_DIR := $(AROSDIR)/../Packages
2326 %(mmake)-%(subpackage)-package-dir := $(PACKAGES_DIR)/$(%(mmake)-%(subpackage)-archbase)
2328 %(mmake)-%(subpackage)-package-basename := \
2329 $(PACKAGES_DIR)/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
2331 %build_with_configure mmake=%(mmake)-%(subpackage) \
2332 srcdir=$(PORTSDIR)/%(package)/$(%(mmake)-%(subpackage)-srcdir) \
2333 nix=%(nix) nix_dir_layout=%(nix_dir_layout) prefix="$(%(mmake)-%(subpackage)-package-dir)" \
2334 aros_prefix="%(aros_prefix)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
2335 %(mmake)-%(subpackage)-make-package" extraoptions="%(extraoptions)"
2337 .PHONY : %(mmake)-%(subpackage)-make-package
2338 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
2341 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package-basename).tar.bz2
2343 #There seems to be a bug, either with my clock or with make, 'cause it may happen
2344 #that $^ and $@ have exactly the same mtime, and in that case make tries
2345 #to rebuild $@ again, which would fail because the directory where
2346 #the package got installed would not exist anymore.
2347 #We work this around by using an if statement to manually check the mtimes.
2348 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
2349 @if test $(GENDIR)/$(CURDIR)/.installed -nt $@ || ! test -f $@; then \
2351 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" && \
2352 cd $(%(mmake)-%(subpackage)-package-dir) && \
2353 tar --remove-files -cvf $(%(mmake)-%(subpackage)-package-basename).tar * && \
2354 mkdir -p "$(%(mmake)-prefix)" && \
2355 tar -xf $(%(mmake)-%(subpackage)-package-basename).tar -C "%(prefix)"/ && \
2356 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar && \
2357 cd .. && $(RM) $(%(mmake)-%(subpackage)-archbase); \
2361 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2362 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
2363 aros_prefix=/GNU extraoptions= postconfigure= postinstall=
2365 GNU_REPOSITORY := http://ftp.gnu.org/pub/gnu
2367 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
2368 suffixes="%(suffixes)" srcdir="%(srcdir)" \
2369 package_repo="%(package_repo) $(GNU_REPOSITORY)/%(package)" \
2370 patch="%(patch)" patch_repo="%(patch_repo)" \
2371 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" \
2372 postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=yes
2376 #-----------------------------------------------------------------------------------------
2377 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
2378 # that the package is a "Development" package, and as such it needs to be placed
2379 # under the $(AROS_DEVELOPMENT) directory, as a default.
2381 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
2382 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
2383 # "mmake" argument, because the metatarget is implicitely defined as
2385 # #MM- development-%(package)
2387 %define fetch_and_build_gnu_development package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2388 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPMENT) \
2389 aros_prefix=/Development postconfigure= postinstall= extraoptions=
2391 #MM- development : development-%(package)
2394 %fetch_and_build_gnu mmake=development-%(package) package=%(package) subpackage="%(subpackage)" \
2395 version=%(version) suffixes="%(suffixes)" srcdir="%(srcdir)" \
2396 package_repo="%(package_repo)" patch="%(patch)" patch_repo="%(patch_repo)" prefix=%(prefix) \
2397 aros_prefix="%(aros_prefix)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" \
2398 extraoptions="%(extraoptions)"