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 # Will join all the files in %(from) to %(to). When text is specified it will
178 # Restriction: at the moment when using a non-empty target dir %(from) may
180 %define rule_join to=/A from=/A text=
186 @$(CAT) $(BD_REFFILES$(BDID)) >$@
188 #------------------------------------------------------------------------------
191 #------------------------------------------------------------------------------
192 # Include the dependency files and add some internal rules
193 # When depstargets is provided the depencies will only be included when one of
194 # these targets is the $(TARGET). Otherwise the dependencies will only be
195 # include when the $(TARGET) is not for setup or clean
196 %define include_deps deps=$(DEPS)/M depstargets=
198 ifneq (%(depstargets),)
199 ifneq ($(findstring $(TARGET),%(depstargets)),)
203 ifeq (,$(filter clean% %clean %clean% setup% includes% %setup,$(TARGET)))
209 #------------------------------------------------------------------------------
212 #------------------------------------------------------------------------------
213 # Create the directories %(dirs). The creation will be done by adding rules to
214 # the %(setuptarget) make target with setup as the default.
215 %define rule_makedirs dirs=/A setuptarget=setup
217 %(setuptarget) :: %(dirs)
219 # Only add a rule for a directory for which there is no rule yet.
221 TOCREATE_TMP := $(filter-out $(CREATED_DIRS_GLOB),%(dirs))
225 @$(ECHO) "Creating directory $@"
228 ifdef CREATED_DIRS_GLOB
229 CREATED_DIRS_GLOB += $(TOCREATE_TMP)
231 CREATED_DIRS_GLOB := $(TOCREATE_TMP)
235 #------------------------------------------------------------------------------
238 #------------------------------------------------------------------------------
239 # Rule to generate a functable
241 %define rule_genfunctable name=functable files=/A dir=. libdefs=libdefs.h
243 %(dir)/%(name).c : $(addsuffix .c,%(files)) $(SCRIPTDIR)/genfunctable.awk %(libdefs)
244 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
246 $(AWK) -v file=%(libdefs) -f $(SCRIPTDIR)/genfunctable.awk $(addsuffix .c,%(files)) > $@
252 #------------------------------------------------------------------------------
255 #------------------------------------------------------------------------------
256 # Generate a rule to compile a C source file to an object file and generate
257 # the dependency file. Basename may contain a directory part, then the source
258 # file has to be in that directory. The generated file will be put in the
259 # object directory without the directory.
261 # - basename: the basename of the file to compile. Use % for a wildcard rule
262 # - cflags (default $(CFLAGS)): the C flags to use for compilation
263 # - dflags: the flags used during creation of dependency file. If not specified
264 # the same value as cflags will be used
265 # - targetdir: the directory to put the .o file and the .d file. By default
266 # it is put in the same directory as the .c file
267 %define rule_compile basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target
270 TMP_TARGETBASE := %(basename)
272 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
275 ifeq ($(findstring %(compiler),host target),)
276 $(error unknown compiler %(compiler))
278 ifeq (%(compiler),target)
279 $(TMP_TARGETBASE).o : TMP_CMD:=$(TARGET_CC)
280 $(TMP_TARGETBASE).d : TMP_CMD:=$(TARGET_CC)
282 ifeq (%(compiler),host)
283 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
284 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
287 $(TMP_TARGETBASE).o : %(basename).c
288 %compile_q opt="%(cflags)" cmd=$(TMP_CMD)
291 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(cflags)
293 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(dflags)
295 $(TMP_TARGETBASE).d : %(basename).c
296 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
298 #------------------------------------------------------------------------------
301 #------------------------------------------------------------------------------
302 # Make an alias from one arch specific build to another arch.
304 # - mainmmake: the mmake of the module in the main tree
305 # - arch: the current arch
306 # - alias: the alias to which this should point
307 %define rule_archalias mainmmake=\A arch=\A alias=\A
309 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
311 #------------------------------------------------------------------------------
314 #------------------------------------------------------------------------------
315 # Generate a rule to compile a C source file to an shared object file with a
316 # .so suffix. Basename may contain a directory part, then the source
317 # file has to be in that directory. The generated file will be put in the
318 # object directory without the directory.
320 # - basename: the basename of the file to compile. Use % for a wildcard rule
321 # - cflags (default $(CFLAGS)): the C flags to use for compilation
322 # - targetdir: the directory to put the .o file and the .d file. By default
323 # it is put in the same directory as the .c file
324 %define rule_compile_shared basename=/A cflags=$(CFLAGS) targetdir= compiler=target
327 TMP_TARGETBASE := %(basename)
329 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
332 ifeq ($(findstring %(compiler),host target),)
333 $(error unknown compiler %(compiler))
335 ifeq (%(compiler),target)
336 $(TMP_TARGETBASE).so : TMP_CMD:=$(TARGET_CC)
338 ifeq (%(compiler),host)
339 $(TMP_TARGETBASE).so : TMP_CMD:=$(HOST_CC)
342 $(TMP_TARGETBASE).so : %(basename).c
343 %compile_q opt="$(SHARED_CFLAGS) %(cflags)" cmd=$(TMP_CMD)
345 #------------------------------------------------------------------------------
348 #------------------------------------------------------------------------------
349 # Generate a rule to assemble a source file to an object file. Basename may
350 # contain a directory part, then the source file has to be in that directory.
351 # The generated file will be put in the object directory without the directory.
353 # - basename: the basename of the file to compile. Use % for a wildcard rule
354 # - flags (default $(AFLAGS)): the asm flags to use for assembling
355 # - targetdir: the directory to put the .o file. By default it is put in the
356 # same directory as the .s file
357 %define rule_assemble basename=/A flags=$(AFLAGS) targetdir=
360 %(basename).o : %(basename).s
361 %assemble_q opt=%(flags)
364 %(targetdir)/$(notdir %(basename)).o : %(basename).s
365 %assemble_q opt=%(flags)
369 #------------------------------------------------------------------------------
372 #------------------------------------------------------------------------------
373 # Link %(objs) to %(prog) using the libraries in %(uselibs)
374 %define rule_link_prog prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
375 usehostlibs= usestartup=yes detach=no nix=no
379 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
381 ifeq (%(usestartup),no)
382 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
385 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
387 %(prog) : EXTRA_LDFLAGS:=$(TMP_EXTRA_LDFLAGS)
389 %(prog) : %(objs) $(addprefix $(LIBDIR)/lib,$(addsuffix .a,%(uselibs) libinit autoinit))
390 %link_q from="%(objs)" opt="%(ldflags) $(EXTRA_LDFLAGS)" \
391 libs="$(addprefix -l,%(uselibs)) $(addprefix -l,%(usehostlibs))"
393 #------------------------------------------------------------------------------
396 #------------------------------------------------------------------------------
397 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
398 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
399 %define rule_link_progs progs=/A targetdir=$(AROSDIR)/$(CURDIR) \
400 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
401 usestartup=yes detach=no
405 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
407 ifeq (%(usestartup),no)
408 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
411 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
413 $(addprefix %(targetdir)/,%(progs)) : EXTRA_LDFLAGS:=$(TMP_EXTRA_LDFLAGS)
415 $(addprefix %(targetdir)/,%(progs)) : %(targetdir)/% : %(objdir)/%.o \
416 $(addprefix $(LIBDIR)/lib,$(addsuffix .a,%(uselibs) libinit autoinit))
417 %link_q from=$< opt="%(ldflags) $(EXTRA_LDFLAGS)" \
418 libs="$(addprefix -l,%(uselibs)) $(addprefix -l,%(usehostlibs))"
420 #------------------------------------------------------------------------------
423 #------------------------------------------------------------------------------
424 # Link the %(objs) to the library %(libdir)/lib%(libname).a in
425 %define rule_link_linklib libname=/A objs=/A libdir=$(LIBDIR)
427 %(libdir)/lib%(libname).a : %(objs)
430 #------------------------------------------------------------------------------
433 #------------------------------------------------------------------------------
434 # Link the %(objs) to the library %(libdir)/lib%(libname).so in
435 %define rule_link_shlib libname=/A objs=/A libdir=$(LIBDIR)
437 %(libdir)/lib%(libname).so : %(objs)
438 @$(SHARED_LD) $(SHARED_LDFLAGS) -o $@ $^
440 #------------------------------------------------------------------------------
443 #------------------------------------------------------------------------------
444 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
445 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
446 %define rule_linkmodule module=/A objs=/A endobj=/A err=/A uselibs= usehostlibs=
448 %(module) : %(objs) %(endobj) $(addprefix $(LIBDIR)/lib,$(addsuffix .a,%(uselibs) libinit autoinit))
449 %link_module_q err="%(err)" endtag="%(endobj)" objs="%(objs)" \
450 libs="$(addprefix -l,%(uselibs)) -lautoinit -llibinit -L/usr/lib $(addprefix -l,%(usehostlibs))"
453 #------------------------------------------------------------------------------
456 #------------------------------------------------------------------------------
457 # Generate a rule to generate a function reference file from a C source file.
458 # Basename may contain a directory part, then the source file has to be in that
459 # directory. The generated file will be put in the object directory without the
462 # - basename: the basename of the file to compile. Use % for a wildcard rule
463 # - cflags (default $(CFLAGS)): the C flags to use for compilation
464 # - targetdir: the directory to put the generated .ref file. By default the
465 # .ref file will be put in the same directory as the .c file.
466 # - includefile: This file will be included at the head of the source file
467 %define rule_ref basename=/A cflags=$(CFLAGS) targetdir= includefile= compiler=target
470 GENFILE_TMP := %(basename).ref
472 GENFILE_TMP := %(targetdir)/$(notdir %(basename)).ref
475 ifeq ($(filter %(compiler),target host),)
476 $(error use of %rule_ref: compiler has to be 'host' or 'target')
479 ifeq (%(compiler),target)
480 $(GENFILE_TMP) : CC:=$(TARGET_CC)
482 $(GENFILE_TMP) : CC:=$(HOST_CC)
485 $(GENFILE_TMP) : %(basename).c $(CXREF) %(includefile)
486 ifeq (%(includefile),)
487 %mkref_q cc=$(CC) cflags="%(cflags)"
489 %mkref_q cc=$(CC) cflags="%(cflags) -include %(includefile)"
493 #------------------------------------------------------------------------------
496 #------------------------------------------------------------------------------
497 # Generate the libdefs.h include file for a module.
498 %define rule_genlibdefs modname=/A modtype=/A modsuffix= conffile=/A targetdir=/A
500 %(targetdir)/%(modname)_libdefs.h : %(conffile) $(GENLIBDEFS)
501 @$(ECHO) "Generating $(notdir $@)"
502 @$(GENLIBDEFS) %(modname) %(modtype) %(modsuffix) %(conffile) %(targetdir)
504 #------------------------------------------------------------------------------
507 #------------------------------------------------------------------------------
508 # Generate dummy support files so cxref when used on the a module source file
509 # will find something to include.
510 %define rule_genmodule_dummy modname=/A modtype=/A modsuffix= conffile=/A targetdir=/A
512 %(targetdir)/clib/%(modname)_protos.h %(targetdir)/defines/%(modname).h \
513 %(targetdir)/proto/%(modname).h : %(conffile) $(GENMODULEDUMMY)
514 @$(ECHO) "Generating $(notdir $@)"
515 %mkdirs_q dirs="%(targetdir) %(targetdir)/clib %(targetdir)/defines %(targetdir)/proto"
516 $(GENMODULEDUMMY) %(modname) %(modtype) %(modsuffix) %(conffile) %(targetdir)
518 #------------------------------------------------------------------------------
521 #------------------------------------------------------------------------------
522 # Generate the support files for compiling a module. This includes include
523 # files and source files.
524 %define rule_genmodule modname=/A modtype=/A modsuffix= objdir=/A conffile=/A reffile=/A
526 GENFILES_TMP := %(objdir)/%(modname)_start.c %(objdir)/%(modname)_end.c
528 # Some of the generated files are dependent on the module type.
529 ifneq ($(findstring %(modtype),library device resource gadget datatype),)
530 GENFILES_TMP += %(objdir)/%(modname)_autoinit.c %(objdir)/%(modname)_stubs.c \
531 $(GENINCDIR)/clib/%(modname)_protos.h \
532 $(GENINCDIR)/defines/%(modname).h \
533 $(GENINCDIR)/proto/%(modname).h
536 ifneq ($(findstring %(modtype),mcc mui mcp),)
537 GENFILES_TMP += %(objdir)/%(modname)_stubs.c
540 $(GENFILES_TMP) : %(conffile) $(GENMODULE) %(reffile)
541 @$(ECHO) "Generating functable and includes for module $(BD_MODNAME$(BDID))"
542 ifneq (%(conffile),lib.conf)
543 @$(IF) $(TEST) -f lib.conf; then \
544 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
547 @$(IF) $(TEST) -f libdefs.h; then \
548 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
550 @$(GENMODULE) %(modname) %(modtype) %(modsuffix) %(conffile) %(objdir) $(GENINCDIR) %(reffile)
552 #------------------------------------------------------------------------------
554 #------------------------------------------------------------------------------
555 # Common rules for all makefiles
557 # Delete generated makefiles
560 @$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
562 include $(TOP)/config/make.tail
564 BDID := $(BDTARGETID)
566 #------------------------------------------------------------------------------
569 #############################################################################
570 #############################################################################
572 ## Here are the mmakefile build macro's. These are macro's that takes care ##
573 ## of everything to go from the sources to the generated target. Also all ##
574 ## intermediate files and directories that are needed are created by these ##
577 #############################################################################
578 #############################################################################
580 #------------------------------------------------------------------------------
582 %define build_prog mmake=/A progname=/A files=$(BD_PROGNAME$(BDID)) asmfiles= \
583 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
584 cflags=$(CFLAGS) dflags=$(BD_CFLAGS$(BDID)) ldflags=$(LDFLAGS) \
585 aflags=$(AFLAFS) uselibs= usehostlibs= usestartup=yes detach=no nix=no
587 .PHONY : %(mmake) %(mmake)-setup
589 %buildid targets="%(mmake) %(mmake)-setup %(mmake)-clean %(mmake)-quick"
591 BD_PROGNAME$(BDID) := %(progname)
592 BD_OBJDIR$(BDID) := %(objdir)
593 BD_TARGETDIR$(BDID) := %(targetdir)
595 BD_FILES$(BDID) := %(files)
596 BD_ASMFILES$(BDID) := %(asmfiles)
597 BD_OBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(BD_FILES$(BDID)) $(BD_ASMFILES$(BDID))))
598 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(BD_FILES$(BDID))))
600 BD_CFLAGS$(BDID) := %(cflags)
601 BD_AFLAGS$(BDID) := %(aflags)
602 BD_DFLAGS$(BDID) := %(dflags)
603 BD_LDFLAGS$(BDID) := %(ldflags)
605 #MM %(mmake) : %(mmake)-setup
608 %(mmake)-quick : %(mmake)
610 %(mmake) : $(BD_TARGETDIR$(BDID))/$(BD_PROGNAME$(BDID))
613 %rule_makedirs dirs="$(BD_OBJDIR$(BDID)) $(BD_TARGETDIR$(BDID))" \
614 setuptarget=%(mmake)-setup
616 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
617 %rule_compile basename=% targetdir=$(BD_OBJDIR$(BDID)) \
618 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID))
619 %rule_assemble basename=% targetdir=$(BD_OBJDIR$(BDID)) \
620 flags=$(BD_AFLAGS$(BDID))
622 %rule_link_prog prog=$(BD_TARGETDIR$(BDID))/$(BD_PROGNAME$(BDID)) \
623 objs=$(BD_OBJS$(BDID)) ldflags=$(BD_LDFLAGS$(BDID)) \
624 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
625 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)"
629 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS$(BDID))
631 #------------------------------------------------------------------------------
634 #------------------------------------------------------------------------------
635 # Build programs, for every C file an executable will be built with the same
637 %define build_progs mmake=/A files=/A \
638 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
639 cflags=$(CFLAGS) dflags=$(BD_CFLAGS$(BDID)) ldflags=$(LDFLAGS) \
640 uselibs= usehostlibs= usestartup=yes detach=no
642 .PHONY : %(mmake) %(mmake)-setup
644 %buildid targets="%(mmake) %(mmake)-setup %(mmake)-clean %(mmake)-quick"
646 BD_OBJDIR$(BDID) := %(objdir)
647 BD_TARGETDIR$(BDID) := %(targetdir)
649 BD_FILES$(BDID) := %(files)
650 BD_OBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(BD_FILES$(BDID))))
651 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(BD_FILES$(BDID))))
652 BD_EXES$(BDID) := $(addprefix $(BD_TARGETDIR$(BDID))/,$(BD_FILES$(BDID)))
654 BD_CFLAGS$(BDID) := %(cflags)
655 ifneq ($(strip $(filter arosc_shared,%(uselibs))),)
656 BD_CFLAGS$(BDID) += -D_CLIB_LIBRARY_ -I$(TOP)/rom/exec
658 BD_DFLAGS$(BDID) := %(dflags)
659 BD_LDFLAGS$(BDID) := %(ldflags)
661 #MM %(mmake) : %(mmake)-setup
664 %(mmake)-quick : %(mmake)
666 %(mmake) : $(BD_EXES$(BDID))
669 %rule_makedirs dirs="$(BD_OBJDIR$(BDID)) $(BD_TARGETDIR$(BDID))" \
670 setuptarget=%(mmake)-setup
672 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
673 %rule_compile basename=% targetdir=$(BD_OBJDIR$(BDID)) \
674 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID))
676 %rule_link_progs progs=$(BD_FILES$(BDID)) \
677 targetdir=$(BD_TARGETDIR$(BDID)) objdir=$(BD_OBJDIR$(BDID)) \
678 ldflags=$(BD_LDFLAGS$(BDID)) \
679 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
680 usestartup="%(usestartup)" detach="%(detach)"
684 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS$(BDID))
686 #------------------------------------------------------------------------------
689 #------------------------------------------------------------------------------
691 # Explanation of this macro is done in the developer's manual
692 %define build_module mmake=/A modname=/A modtype=/A modsuffix= \
693 conffile=$(BD_MODNAME$(BDID)).conf files="$(basename $(wildcard *.c))" \
694 linklibfiles= cflags=$(CFLAGS) dflags= \
695 objdir=$(OBJDIR) moduledir= prefix=$(AROSDIR)\
696 reffile=$(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_ALL.ref noref= \
697 linklibname=$(BD_MODNAME$(BDID)) uselibs= \
700 %buildid targets="%(mmake) %(mmake)-includes %(mmake)-setup %(mmake)-clean %(mmake)-quick %(mmake)-kobj"
702 .PHONY : setup-module$(BDID) %(mmake) %(mmake)-includes %(mmake)-setup %(mmake)-clean %(mmake)-quick %(mmake)-kobj
705 $(error using %build_module: modname may not be empty)
708 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
711 # assign and generate the local variables used in this macro
712 BD_MODNAME$(BDID) := %(modname)
713 BD_MODTYPE$(BDID) := %(modtype)
715 BD_MODSUFFIX$(BDID) := %(modtype)
717 BD_MODSUFFIX$(BDID) := %(modsuffix)
719 BD_CONFFILE$(BDID) := %(conffile)
720 OBJDIR ?= $(GENDIR)/$(CURDIR)
721 BD_OBJDIR$(BDID) := %(objdir)
722 BD_PREFIX$(BDID) := %(prefix)
723 BD_INCLUDE$(BDID) := $(BD_PREFIX$(BDID))/$(AROS_DIR_INCLUDE)
725 BD_FILES$(BDID) := %(files)
726 BD_LIBFILES$(BDID) := %(linklibfiles)
727 BD_STARTFILE$(BDID) := $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_start
728 BD_ENDFILE$(BDID) := $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_end
730 BD_ARCHOBJS$(BDID) := $(wildcard $(BD_OBJDIR$(BDID))/arch/*.o)
731 BD_ARCHFILES$(BDID) := $(basename $(notdir $(BD_ARCHOBJS$(BDID))))
732 BD_NARCHFILES$(BDID) := $(filter-out $(BD_ARCHFILES$(BDID)),$(BD_FILES$(BDID)))
733 BD_NEWARCHFILES$(BDID):= $(filter-out $(BD_FILES$(BDID)),$(BD_ARCHFILES$(BDID)))
734 BD_ARCHOBJS$(BDID) := $(addsuffix .o, $(addprefix $(BD_OBJDIR$(BDID))/arch/,$(BD_ARCHFILES$(BDID))))
735 BD_NARCHOBJS$(BDID) := $(addsuffix .o, $(addprefix $(BD_OBJDIR$(BDID))/,$(BD_NARCHFILES$(BDID))))
736 BD_OBJS$(BDID) := $(BD_ARCHOBJS$(BDID)) $(BD_NARCHOBJS$(BDID))
737 BD_STARTOBJ$(BDID) := $(addsuffix .o,$(BD_STARTFILE$(BDID)))
738 BD_ENDOBJ$(BDID) := $(addsuffix .o,$(BD_ENDFILE$(BDID)))
740 BD_DEPS$(BDID) := $(patsubst %.o,%.d,$(BD_NARCHOBJS$(BDID)))
743 BD_REFFILES$(BDID) := $(addprefix $(BD_OBJDIR$(BDID))/,$(addsuffix .ref, $(notdir $(BD_FILES$(BDID)))))
745 BD_REFFILES$(BDID) := $(addprefix $(BD_OBJDIR$(BDID))/,$(addsuffix .ref, $(notdir $(filter-out %(noref),$(BD_FILES$(BDID))))))
747 BD_REFFILE$(BDID) := %(reffile)
749 ifneq ($(findstring $(BD_MODTYPE$(BDID)),library device resource),)
750 BD_GENINCS$(BDID) := clib/$(BD_MODNAME$(BDID))_protos.h defines/$(BD_MODNAME$(BDID)).h proto/$(BD_MODNAME$(BDID)).h
752 BD_LIBDEFSINC$(BDID) := $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_libdefs.h
754 BD_CFLAGS$(BDID) := %(cflags) -I$(BD_INCLUDE$(BDID)) -I$(BD_OBJDIR$(BDID)) -idirafter $(TOP)/$(CURDIR) -include $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h
756 BD_DFLAGS$(BDID) := $(BD_CFLAGS$(BDID))
758 BD_DFLAGS$(BDID) := %(dflags) -I$(BD_INCLUDE$(BDID)) -I$(BD_OBJDIR$(BDID)) -include $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h
761 # Add additional files depending the module type
762 ifeq ($(findstring $(BD_MODTYPE$(BDID)),library device mcc mui mcp resource gadget datatype),)
763 $(error unhandled MODTYPE %(modtype))
765 ifeq ($(BD_MODTYPE$(BDID)),library)
766 BD_MODDIR$(BDID) := $(BD_PREFIX$(BDID))/$(AROS_DIR_LIBS)
767 BD_LINKLIBFILES$(BDID) := $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_autoinit.c
768 BD_LINKLIBOBJS$(BDID) := $(addprefix $(BD_OBJDIR$(BDID))/,$(addsuffix .o,$(BD_LIBFILES$(BDID)))) \
769 $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_autoinit.o
770 BD_LINKLIBGENFILES$(BDID):= $(BD_PREFIX$(BDID))/$(AROS_DIR_LIB)/lib%(linklibname).a
771 %rule_compile basename=$(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_autoinit \
772 targetdir=$(BD_OBJDIR$(BDID)) \
773 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID)) \
777 ifeq ($(BD_MODTYPE$(BDID)),device)
778 BD_MODDIR$(BDID) := $(BD_PREFIX$(BDID))/$(AROS_DIR_DEVS)
779 BD_LINKLIBFILES$(BDID) :=
780 BD_LINKLIBOBJS$(BDID) := $(addprefix $(BD_LIBOBJDIR$(BDID))/,$(addsuffix .o,$(BD_LIBFILES$(BDID)))) \
781 $(BD_LIBARCHOBJS$(BDID))
782 BD_LINKLIBGENFILES$(BDID):= $(BD_PREFIX$(BDID))/$(AROS_DIR_LIB)/lib%(linklibname).a
785 ifeq ($(BD_MODTYPE$(BDID)),resource)
786 BD_MODDIR$(BDID) := $(BD_PREFIX$(BDID))/$(AROS_DIR_DEVS)
787 BD_LINKLIBFILES$(BDID) :=
788 BD_LINKLIBOBJS$(BDID) := $(addprefix $(BD_LIBOBJDIR$(BDID))/,$(addsuffix .o,$(BD_LIBFILES$(BDID)))) \
789 $(BD_LIBARCHOBJS$(BDID))
790 BD_LINKLIBGENFILES$(BDID):= $(BD_PREFIX$(BDID))/$(AROS_DIR_LIB)/lib%(linklibname).a
793 ifneq ($(findstring $(BD_MODTYPE$(BDID)),mcc mui mcp),)
794 BD_MODDIR$(BDID) := $(BD_PREFIX$(BDID))/$(AROS_DIR_CLASSES)/Zune
795 BD_LINKLIBGENFILES$(BDID):=
798 ifeq ($(BD_MODTYPE$(BDID)),gadget)
799 BD_MODDIR$(BDID) := $(BD_PREFIX$(BDID))/$(AROS_DIR_CLASSES)/Gadgets
800 BD_LINKLIBGENFILES$(BDID):=
803 ifeq ($(BD_MODTYPE$(BDID)),datatype)
804 BD_MODDIR$(BDID) := $(BD_PREFIX$(BDID))/$(AROS_DIR_CLASSES)/DataTypes
805 BD_LINKLIBGENFILES$(BDID):=
808 ifneq ($(findstring $(BD_MODTYPE$(BDID)),library device resource mcc mcp),)
809 BD_LINKLIBFILES$(BDID) += $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_stubs.c
810 BD_LINKLIBOBJS$(BDID) += $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_stubs.o
811 BD_LINKLIBDEPS$(BDID) := $(patsubst %.o,%.d,$(BD_LINKLIBOBJS$(BDID)))
812 %rule_compile basename=$(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_stubs \
813 targetdir=$(BD_OBJDIR$(BDID)) \
814 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID)) \
818 ifneq (%(moduledir),)
819 BD_MODDIR$(BDID) := $(BD_PREFIX$(BDID))/%(moduledir)
822 BD_MODULE$(BDID) := $(BD_MODDIR$(BDID))/$(BD_MODNAME$(BDID)).$(BD_MODSUFFIX$(BDID))
823 BD_GENFILES$(BDID) := $(BD_MODULE$(BDID)) $(BD_LINKLIBGENFILES$(BDID))
824 BD_DEPS$(BDID) += $(BD_LINKLIBDEPS$(BDID))
826 # What are the files that need to be generated before the .d and .ref files
828 BD_REFFILE_DEPS$(BDID) := $(BD_LIBDEFSINC$(BDID)) $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h
829 ifneq ($(findstring $(BD_MODTYPE$(BDID)),library device resource gadget datatype),)
830 BD_REFFILE_DEPS$(BDID) += $(addprefix $(BD_OBJDIR$(BDID))/dummyinc/,$(BD_GENINCS$(BDID)))
832 BD_DFILE_DEPS$(BDID) := $(BD_LIBDEFSINC$(BDID)) $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h
833 ifneq ($(findstring $(BD_MODTYPE$(BDID)),library device resource gadget datatype),)
834 BD_DFILE_DEPS$(BDID) += $(addprefix $(BD_INCLUDE$(BDID))/,$(BD_GENINCS$(BDID)))
837 #MM- includes-all : %(mmake)-includes
838 #MM %(mmake) : %(mmake)-includes
839 #MM %(mmake)-kobj : %(mmake)-includes
840 #MM %(mmake)-includes : %(mmake)-setup includes-generate-deps
843 %(mmake)-quick : %(mmake)
846 %(mmake) : $(BD_GENFILES$(BDID))
849 %(mmake)-includes : $(addprefix $(BD_INCLUDE$(BDID))/,$(BD_GENINCS$(BDID)))
853 @$(ECHO) "Cleaning up for module $(BD_MODNAME$(BDID))"
854 @$(RM) $(BD_OBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_REFFILE$(BDID)) \
855 $(BD_REFFILES$(BDID))\
856 $(addprefix $(BD_OBJDIR$(BDID))/,$(addsuffix .c,$(BD_GENFILES$(BDID)))) \
857 $(addprefix $(GENINCDIR)/,$(BD_GENINCS$(BDID))) \
858 $(addprefix $(BD_INCLUDE$(BDID))/,$(BD_GENINCS$(BDID))) \
859 $(BD_LINKLIBFILES$(BDID)) $(BD_LINKLIBOBJS$(BDID)) $(BD_LIBDEFSINC$(BDID)) \
860 $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h \
861 $(addsuffix .c,$(BD_STARTFILE$(BDID)) $(BD_ENDFILE$(BDID))) \
862 $(BD_STARTOBJ$(BDID)) $(BD_ENDOBJ$(BDID))
865 %(mmake)-setup : setup-module$(BDID)
867 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj),) # Avoid conflicts
868 TMP_SRCDIR := $(filter-out ./,$(sort $(dir $(BD_FILES$(BDID)))))
869 ifneq ($(TMP_SRCDIR),)
870 vpath %.c $(TMP_SRCDIR)
871 %rule_makedirs dirs="$(addprefix $(BD_OBJDIR$(BDID))/,$(TMP_SRCDIR))" setuptarget=setup-module$(BDID)
874 %rule_compile basename=% targetdir=$(BD_OBJDIR$(BDID)) \
875 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID)) \
877 %rule_ref basename=% targetdir=$(BD_OBJDIR$(BDID)) \
878 cflags="-I$(dir $(GENMODULE))/genmod_inc -I$(BD_OBJDIR$(BDID))/dummyinc $(strip $(BD_CFLAGS$(BDID)))" \
880 %rule_compile basename=$(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_start targetdir=$(BD_OBJDIR$(BDID)) \
881 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID)) \
883 %rule_compile basename=$(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_end targetdir=$(BD_OBJDIR$(BDID)) \
884 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID)) \
888 # Some include files need to be generated before the .c can be parsed.
889 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj),) # Only for this target these deps are wanted
890 $(BD_REFFILES$(BDID)) : $(BD_REFFILE_DEPS$(BDID)) $(dir $(GENMODULE))/genmod_inc/aros/libcall.h
891 $(BD_DEPS$(BDID)) : $(BD_DFILE_DEPS$(BDID))
894 # Generation of the autogenerated .c and .h files.
895 %rule_genmodule modname=$(BD_MODNAME$(BDID)) modtype=$(BD_MODTYPE$(BDID)) \
896 modsuffix=$(BD_MODSUFFIX$(BDID)) objdir=$(BD_OBJDIR$(BDID)) \
897 conffile=$(BD_CONFFILE$(BDID)) reffile=$(BD_REFFILE$(BDID))
899 %rule_genmodule_dummy modname=$(BD_MODNAME$(BDID)) modtype=$(BD_MODTYPE$(BDID)) \
900 modsuffix=$(BD_MODSUFFIX$(BDID)) \
901 targetdir=$(BD_OBJDIR$(BDID))/dummyinc conffile=$(BD_CONFFILE$(BDID))
903 %rule_genlibdefs modname=$(BD_MODNAME$(BDID)) modtype=$(BD_MODTYPE$(BDID)) \
904 modsuffix=$(BD_MODSUFFIX$(BDID)) targetdir=$(BD_OBJDIR$(BDID)) \
905 conffile=$(BD_CONFFILE$(BDID))
907 $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h : $(BD_CONFFILE$(BDID))
908 @$(ECHO) "generating $@"
909 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(BD_LIBDEFSINC$(BDID))\"" >$@
911 # The module ref file is the joint of all individual .ref files
912 %rule_join from=$(BD_REFFILES$(BDID)) to=$(BD_REFFILE$(BDID)) \
913 text="Collecting function references for module $(BD_MODNAME$(BDID))"
915 # The module is linked from all the compiled .o files
916 %rule_linkmodule module=$(BD_MODULE$(BDID)) objs="$(BD_STARTOBJ$(BDID)) $(BD_OBJS$(BDID))" \
917 endobj=$(BD_ENDOBJ$(BDID)) err=$(BD_MODNAME).err uselibs="%(uselibs)"
919 # The include files generated in $(GENINCDIR) have to be mirrored in the AROS include directory
920 ifneq ($(findstring $(BD_MODTYPE$(BDID)),library device resource gadget datatype),)
921 %rule_makedirs dirs="$(addprefix $(BD_INCLUDE$(BDID))/, clib defines pragmas proto)" setuptarget=setup-module$(BDID)
922 %rule_copy from=$(GENINCDIR)/clib/$(BD_MODNAME$(BDID))_protos.h to=$(BD_INCLUDE$(BDID))/clib/$(BD_MODNAME$(BDID))_protos.h
923 %rule_copy from=$(GENINCDIR)/defines/$(BD_MODNAME$(BDID)).h to=$(BD_INCLUDE$(BDID))/defines/$(BD_MODNAME$(BDID)).h
924 %rule_copy from=$(GENINCDIR)/pragmas/$(BD_MODNAME$(BDID)).h to=$(BD_INCLUDE$(BDID))/pragmas/$(BD_MODNAME$(BDID)).h
925 %rule_copy from=$(GENINCDIR)/proto/$(BD_MODNAME$(BDID)).h to=$(BD_INCLUDE$(BDID))/proto/$(BD_MODNAME$(BDID)).h
928 # For a shared library and device also build a static link lib
929 ifneq ($(findstring $(BD_MODTYPE$(BDID)),library device resource),)
930 %rule_makedirs dirs=$(BD_PREFIX$(BDID))/$(AROS_DIR_LIB) setuptarget=setup-module$(BDID)
931 %rule_link_linklib libname=%(linklibname) objs=$(BD_LINKLIBOBJS$(BDID)) libdir=$(BD_PREFIX$(BDID))/$(AROS_DIR_LIB)
934 %rule_makedirs dirs="$(BD_OBJDIR$(BDID)) $(BD_OBJDIR$(BDID))/dummyinc/defines $(BD_OBJDIR$(BDID))/dummyinc/proto $(BD_OBJDIR$(BDID))/dummyinc/clib $(BD_MODDIR$(BDID)) $(KOBJSDIR)" \
935 setuptarget=setup-module$(BDID)
937 %(mmake)-kobj : $(KOBJSDIR)/$(BD_MODNAME$(BDID))_$(BD_MODSUFFIX$(BDID)).o
939 $(KOBJSDIR)/$(BD_MODNAME$(BDID))_$(BD_MODSUFFIX$(BDID)).o : \
940 $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_start.o \
942 $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_end.o
943 @$(ECHO) "Linking $@"
944 @$(AROS_LD) -Ur -o $@ $^
945 @$(OBJCOPY) $@ `$(NM_PLAIN) $@ | $(AWK) '$$3 ~ /^__.*_(LIST|END)__$$/ {print "-L " $$3;}'`
947 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS$(BDID))
949 #------------------------------------------------------------------------------
952 #------------------------------------------------------------------------------
953 # Build a module using the deprecated macro's to define the functions in the
954 # library. Explanation of this macro is done in the developer's manual
955 %define build_module_macro mmake=/A modname=/A modtype=/A dir= \
956 conffile=$(BD_MODNAME$(BDID)).conf initfile=$(BD_MODNAME$(BDID))_init \
957 funcs= files= linklibfiles= cflags=$(CFLAGS) dflags= \
958 objdir=$(OBJDIR) uselibs= usehostlibs= \
959 genfunctable= genincludes= compiler=target
961 %buildid targets="%(mmake) %(mmake)-setup %(mmake)-clean %(mmake)-includes %(mmake)-linklib %(mmake)-quick %(mmake)-kobj"
963 .PHONY : setup-module$(BDID)
966 $(error using %build_module: modname may not be empty)
969 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
972 # assign and generate the local variables used in this macro
973 BD_MODNAME$(BDID) := %(modname)
974 BD_MODTYPE$(BDID) := %(modtype)
975 BD_MODDIR$(BDID) := %(dir)
976 BD_CONFFILE$(BDID) := %(conffile)
977 OBJDIR ?= $(GENDIR)/$(CURDIR)
978 BD_OBJDIR$(BDID) := %(objdir)
980 BD_ARCHOBJS$(BDID) := $(wildcard $(BD_OBJDIR$(BDID))/arch/*.o)
981 BD_ARCHFILES$(BDID) := $(basename $(notdir $(BD_ARCHOBJS$(BDID))))
983 BD_INITFILE$(BDID) := %(initfile)
984 BD_FUNCS$(BDID) := $(filter-out $(BD_ARCHFILES$(BDID)),%(funcs))
985 BD_FILES$(BDID) := $(filter-out $(BD_ARCHFILES$(BDID)),%(files))
986 BD_LIBFILES$(BDID) := %(linklibfiles)
987 ifneq ($(wildcard $(BD_CONFFILE$(BDID))),)
988 BD_ENDFILE$(BDID) := $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_end
993 BD_FUNCSRCS$(BDID) := $(addsuffix .c,%(funcs))
994 BD_SRCS$(BDID) := $(addsuffix .c,$(BD_FILES$(BDID)))
995 ifeq ($(filter $(BD_INITFILE$(BDID)), $(BD_ARCHFILES$(BDID))),)
996 BD_INITOBJ$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir $(BD_INITFILE$(BDID)))))
998 TMP_INITREPLACE := $(filter $(notdir $(BD_INITFILE$(BDID))), $(BD_ARCHFILES$(BDID)))
999 TMP_INITKEEP := $(filter-out $(TMP_INITREPLACE),$(notdir $(BD_INITFILE$(BDID))))
1000 BD_INITOBJ$(BDID) := $(addsuffix .o, \
1001 $(addprefix $(BD_OBJDIR$(BDID))/arch/,$(TMP_INITREPLACE)) \
1002 $(addprefix $(BD_OBJDIR$(BDID))/,$(TMP_INITKEEP)) \
1004 BD_ARCHOBJS$(BDID) := $(filter-out $(BD_INITOBJ$(BDID)),$(BD_ARCHOBJS$(BDID)))
1007 TMP_FILES := $(notdir $(BD_FILES$(BDID)))
1008 ifeq (%(genfunctable),yes)
1009 TMP_FILES := $(BD_MODNAME$(BDID))_functable $(TMP_FILES)
1011 ifneq ($(BD_FUNCS$(BDID)),)
1012 ifeq (%(genfunctable),)
1013 ifneq ($(BD_MODTYPE$(BDID)),resource)
1014 TMP_FILES := $(BD_MODNAME$(BDID))_functable $(TMP_FILES)
1017 ifneq (%(genfunctable),no)
1018 TMP_FILES := $(BD_MODNAME$(BDID))_functable $(TMP_FILES)
1021 TMP_FILES += $(BD_FUNCS$(BDID))
1024 BD_OBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(TMP_FILES))) $(BD_ARCHOBJS$(BDID))
1025 BD_ENDOBJ$(BDID) := $(addsuffix .o,$(BD_ENDFILE$(BDID)))
1027 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(BD_INITFILE$(BDID)) $(TMP_FILES)))
1029 BD_GENINCS$(BDID) :=
1030 ifneq (%(genincludes),)
1031 ifeq (%(genincludes),yes)
1032 BD_GENINCS$(BDID):= clib/$(BD_MODNAME$(BDID))_protos.h defines/$(BD_MODNAME$(BDID)).h proto/$(BD_MODNAME$(BDID)).h
1035 ifneq ($(BD_FUNCS$(BDID)),)
1036 ifneq ($(findstring $(BD_MODTYPE$(BDID)),library gadget device),)
1037 BD_GENINCS$(BDID):= clib/$(BD_MODNAME$(BDID))_protos.h defines/$(BD_MODNAME$(BDID)).h proto/$(BD_MODNAME$(BDID)).h
1041 # Only generate libdefs.h if the config file exists
1042 ifneq ($(wildcard $(BD_CONFFILE$(BDID))),)
1043 BD_LIBDEFSINC$(BDID):= $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_libdefs.h
1045 BD_LIBDEFSINC$(BDID):=
1048 BD_CFLAGS$(BDID) := %(cflags) -I$(BD_OBJDIR$(BDID)) -I. -I$(TOP)/workbench/libs -include $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h
1050 BD_DFLAGS$(BDID) := $(BD_CFLAGS$(BDID))
1052 BD_DFLAGS$(BDID) := %(dflags) -I$(BD_OBJDIR$(BDID)) -I. -I$(TOP)/workbench/libs -include $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h
1055 # Add additional files depending the module type
1056 ifeq ($(findstring $(BD_MODTYPE$(BDID)),library gadget datatype handler device resource mui mcc mcp hidd),)
1057 $(error unhandled MODTYPE %(modtype))
1059 ifeq ($(BD_MODDIR$(BDID)),)
1060 ifeq ($(BD_MODTYPE$(BDID)),library)
1061 BD_MODDIR$(BDID) := $(AROS_LIBS)
1063 ifeq ($(BD_MODTYPE$(BDID)),gadget)
1064 BD_MODDIR$(BDID) := $(AROS_GADGETS)
1066 ifeq ($(BD_MODTYPE$(BDID)),datatype)
1067 BD_MODDIR$(BDID) := $(AROS_DATATYPES)
1069 ifeq ($(BD_MODTYPE$(BDID)),handler)
1070 BD_MODDIR$(BDID) := $(AROS_FS)
1072 ifeq ($(BD_MODTYPE$(BDID)),device)
1073 BD_MODDIR$(BDID) := $(AROS_DEVS)
1075 ifeq ($(BD_MODTYPE$(BDID)),resource)
1076 BD_MODDIR$(BDID) := $(AROS_RESOURCES)
1078 ifeq ($(BD_MODTYPE$(BDID)),mui)
1079 BD_MODDIR$(BDID) := $(AROS_CLASSES)/Zune
1081 ifeq ($(BD_MODTYPE$(BDID)),mcc)
1082 BD_MODDIR$(BDID) := $(AROS_CLASSES)/Zune
1084 ifeq ($(BD_MODTYPE$(BDID)),mcp)
1085 BD_MODDIR$(BDID) := $(AROS_CLASSES)/Zune
1087 ifeq ($(BD_MODTYPE$(BDID)),hidd)
1088 BD_MODDIR$(BDID) := $(AROS_DRIVERS)
1092 BD_MODULE$(BDID) := $(BD_MODDIR$(BDID))/$(BD_MODNAME$(BDID)).$(BD_MODTYPE$(BDID))
1093 BD_GENFILES$(BDID) := $(BD_MODULE$(BDID))
1094 BD_DEPS$(BDID) += $(BD_LINKLIBDEPS$(BDID))
1096 #MM- includes-all : %(mmake)-includes
1097 #MM %(mmake) : %(mmake)-includes %(mmake)-setup
1098 #MM %(mmake)-includes : %(mmake)-setup
1101 %(mmake)-quick : %(mmake)
1103 %(mmake) : $(BD_GENFILES$(BDID))
1107 @$(ECHO) "Cleaning up for module $(BD_MODNAME$(BDID))"
1108 @$(RM) $(BD_OBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_REFFILE$(BDID)) \
1109 $(BD_REFFILES$(BDID))\
1110 $(addprefix $(BD_OBJDIR$(BDID))/,$(addsuffix .c,$(BD_GENFILES$(BDID)))) \
1111 $(addprefix $(GENINCDIR)/,$(BD_GENINCS$(BDID))) \
1112 $(addprefix $(AROS_INCLUDES)/,$(BD_GENINCS$(BDID))) \
1113 $(BD_LINKLIBFILES$(BDID)) $(BD_LINKLIBOBJS$(BDID)) $(BD_LIBDEFSINC$(BDID)) \
1114 $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h \
1115 $(BD_ENDFILE$(BDID)).c $(BD_ENDOBJ$(BDID))
1118 %(mmake)-setup : setup-module$(BDID)
1120 #MM %(mmake)-includes : setup-clib
1122 TMP_DEPS := $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h
1123 ifneq ($(BD_GENINCS$(BDID)),)
1124 TMP_DEPS += $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_includes.stamp \
1125 $(addprefix $(AROS_INCLUDES)/,$(BD_GENINCS$(BDID)))
1128 %(mmake)-includes : $(TMP_DEPS)
1130 $(TMP_DEPS) : $(BD_LIBDEFSINC$(BDID))
1132 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-linklib %(mmake)-quick %(mmake)-kobj),) # Avoid conflicts
1133 ifneq ($(dir $(BD_FILES$(BDID))),./)
1134 vpath %.c $(filter-out ./,$(dir $(BD_FUNCS$(BDID)) $(BD_FILES$(BDID))))
1137 %rule_compile basename=% targetdir=$(BD_OBJDIR$(BDID)) \
1138 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID)) \
1139 compiler=%(compiler)
1140 %rule_compile basename=$(BD_ENDFILE$(BDID)) targetdir=$(BD_OBJDIR$(BDID)) \
1141 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID)) \
1142 compiler=%(compiler)
1143 %rule_compile basename=$(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_functable targetdir=$(BD_OBJDIR$(BDID)) \
1144 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID)) \
1145 compiler=%(compiler)
1148 BD_DFILE_DEPS$(BDID) := $(BD_LIBDEFSINC$(BDID)) $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h
1150 # Some include files need to be generated before the .c can be parsed.
1151 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick %(mmake)-linklib) %(mmake)-kobj,) # Only for this target these deps are wanted
1152 $(BD_DEPS$(BDID)) : $(BD_DFILE_DEPS$(BDID))
1155 # Generation of the autogenerated .c and .h files.
1156 $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h :
1157 @$(ECHO) "generating $@"
1158 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(notdir $(BD_LIBDEFSINC$(BDID)))\"" >$@
1160 %libdefs_rule conffile=$(BD_CONFFILE$(BDID)) dest=$(BD_LIBDEFSINC$(BDID))
1162 ifneq ($(BD_ENDFILE$(BDID)),)
1163 $(BD_ENDFILE$(BDID)).c :
1164 @$(ECHO) "generating $@"
1165 @$(ECHO) "#include <libcore/libtail.c>" >$@
1168 %rule_genfunctable name=$(BD_MODNAME$(BDID))_functable files=$(BD_FUNCS$(BDID)) dir=$(BD_OBJDIR$(BDID)) \
1169 libdefs=$(BD_LIBDEFSINC$(BDID))
1171 # The module is linked from all the compiled .o files
1172 %rule_linkmodule module=$(BD_MODULE$(BDID)) objs="$(BD_INITOBJ$(BDID)) $(BD_OBJS$(BDID))" \
1173 endobj=$(BD_ENDOBJ$(BDID)) err=$(BD_MODNAME).err uselibs="%(uselibs)" \
1174 usehostlibs="%(usehostlibs)"
1176 BD_HEADER_DEPS$(BDID) := $(wildcard headers.tmpl) $(BD_LIBDEFSINC$(BDID)) \
1177 $(BD_FUNCSRCS$(BDID)) \
1178 $(SCRIPTDIR)/genshared \
1179 $(SCRIPTDIR)/genclib.awk $(SCRIPTDIR)/genpclib.awk \
1180 $(SCRIPTDIR)/gendefines.awk $(SCRIPTDIR)/genpdefines.awk
1182 # Regenerate the includes when some of the dependencies are changed
1183 $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_includes.stamp : $(BD_HEADER_DEPS$(BDID))
1184 @$(SCRIPTDIR)/genshared -clib -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1185 @$(SCRIPTDIR)/genshared -defines -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1186 @$(SCRIPTDIR)/genshared -proto -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1187 @$(SCRIPTDIR)/genshared -pclib -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1188 @$(SCRIPTDIR)/genshared -pdefines -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1189 @$(SCRIPTDIR)/genshared -pproto -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1192 # Generate includes the first time they are needed
1193 $(GENINCDIR)/clib/$(BD_MODNAME$(BDID))_private_protos.h \
1194 $(GENINCDIR)/clib/$(BD_MODNAME$(BDID))_protos.h \
1195 $(GENINCDIR)/defines/$(BD_MODNAME$(BDID)).h \
1196 $(GENINCDIR)/proto/$(BD_MODNAME$(BDID)).h :
1197 @$(SCRIPTDIR)/genshared -clib -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1198 @$(SCRIPTDIR)/genshared -proto -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1199 @$(SCRIPTDIR)/genshared -pclib -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1200 @$(SCRIPTDIR)/genshared -pdefines -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1201 @$(SCRIPTDIR)/genshared -pproto -libdefsfile $(BD_LIBDEFSINC$(BDID)) -prefix $(GENINCDIR) $(BD_FUNCSRCS$(BDID))
1202 @$(TOUCH) $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_includes.stamp
1204 # The include files generated in $(GENINCDIR) have to be mirrored in the AROS include directory
1205 %rule_copy from=$(GENINCDIR)/clib/$(BD_MODNAME$(BDID))_protos.h to=$(AROS_INCLUDES)/clib/$(BD_MODNAME$(BDID))_protos.h
1206 %rule_copy from=$(GENINCDIR)/defines/$(BD_MODNAME$(BDID)).h to=$(AROS_INCLUDES)/defines/$(BD_MODNAME$(BDID)).h
1207 #%rule_copy from=$(GENINCDIR)/pragmas/$(BD_MODNAME$(BDID)).h to=$(AROS_INCLUDES)/pragmas/$(BD_MODNAME$(BDID)).h
1208 %rule_copy from=$(GENINCDIR)/proto/$(BD_MODNAME$(BDID)).h to=$(AROS_INCLUDES)/proto/$(BD_MODNAME$(BDID)).h
1210 MYDIRS$(BDID) := $(BD_OBJDIR$(BDID)) $(GENINCDIR) $(GENINCDIR)/clib \
1211 $(GENINCDIR)/proto $(GENINCDIR)/defines \
1212 $(GENINCDIR)/pragmas $(AROS_INCLUDES) $(AROS_INCLUDES)/clib $(AROS_INCLUDES)/proto \
1213 $(AROS_INCLUDES)/defines $(AROS_INCLUDES)/pragmas \
1214 $(BD_MODDIR$(BDID)) $(KOBJSDIR)
1216 %rule_makedirs dirs=$(MYDIRS$(BDID)) setuptarget=setup-module$(BDID)
1218 #MM %(mmake)-linklib : %(mmake)-setup setup-clib
1219 #MM %(mmake)-kobj : %(mmake)-setup setup-clib
1221 TMP_DEPS := $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_deflibdefs.h \
1222 $(BD_LIBDEFSINC$(BDID))
1223 ifneq ($(BD_GENINCS$(BDID)),)
1224 TMP_DEPS += $(BD_OBJDIR$(BDID))/$(BD_MODNAME$(BDID))_includes.stamp \
1225 $(addprefix $(AROS_INCLUDES)/,$(BD_GENINCS$(BDID)))
1228 %(mmake)-linklib : $(TMP_DEPS)
1229 %(mmake)-kobj : $(TMP_DEPS)
1231 # Link only when target %(mmake)-linklib otherwise for example jpeg.datatype
1232 # that depend on the jpeg library can cause to get this rule executed unwanted
1233 ifneq ($(filter $(TARGET),%(mmake)-linklib %(mmake)-kobj),)
1234 %(mmake)-linklib : $(LIBDIR)/lib$(BD_MODNAME$(BDID)).a
1235 %(mmake)-kobj : $(KOBJSDIR)/$(BD_MODNAME$(BDID))_$(BD_MODTYPE$(BDID)).o
1237 %rule_link_linklib libname=$(BD_MODNAME$(BDID)) libdir=$(LIBDIR) \
1238 objs="$(BD_INITOBJ$(BDID)) $(BD_OBJS$(BDID)) $(BD_ENDOBJ$(BDID))"
1240 $(KOBJSDIR)/$(BD_MODNAME$(BDID))_$(BD_MODTYPE$(BDID)).o : \
1241 $(BD_INITOBJ$(BDID)) $(BD_OBJS$(BDID)) $(BD_ENDOBJ$(BDID))
1242 @$(ECHO) "Linking $@"
1243 $(AROS_LD) -Ur -o $@ $^
1244 $(OBJCOPY) $@ `$(NM_PLAIN) $@ | $(AWK) '$$3 ~ /^__.*_(LIST|END)__$$/ {print "-L " $$3;}'`
1247 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-linklib %(mmake)-kobj" deps=$(BD_DEPS$(BDID))
1249 #------------------------------------------------------------------------------
1252 #------------------------------------------------------------------------------
1254 # - mmake is the mmaketarget
1255 # - libname is the baselibname e.g. lib%(libname).a will be created
1256 # - files are the C source files to include in the lib. The list of files
1257 # has to be given without the .c suffix
1258 # - asmfiles are the asm files to include in the lib. The list of files has to
1259 # be given with the .s suffix
1260 # - cflags are the flags to compile the source (default $(CFLAGS))
1261 # - dflags are the flags use during makedepend (default equal to cflags)
1262 # - aflags are the flags use during assembling (default $(AFLAGS))
1263 # - objdir is where the .o are generated
1264 # - libdir is the directory where the linklib will be placed (default $(LIBDIR))
1265 %define build_linklib mmake=/A libname=/A files="$(basename $(wildcard *.c))" \
1266 asmfiles= cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) objdir=$(OBJDIR) libdir=$(LIBDIR)
1268 %buildid targets="%(mmake) %(mmake)-setup %(mmake)-clean"
1270 # assign and generate the local variables used in this macro
1271 BD_LIBNAME$(BDID) := %(libname)
1272 OBJDIR ?= $(GENDIR)/$(CURDIR)
1273 BD_OBJDIR$(BDID) := %(objdir)
1274 BD_LIBDIR$(BDID) := %(libdir)
1276 BD_FILES$(BDID) := %(files)
1277 BD_ASMFILES$(BDID) := %(asmfiles)
1278 BD_SRCS$(BDID) := $(addsuffix .c,$(BD_FILES$(BDID)))
1279 BD_OBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir $(BD_FILES$(BDID)) $(BD_ASMFILES$(BDID)))))
1280 BD_DEPS$(BDID) := $(patsubst %.o,%.d,$(BD_OBJS$(BDID)))
1282 BD_CFLAGS$(BDID) := %(cflags)
1284 BD_DFLAGS$(BDID) := $(BD_CFLAGS$(BDID))
1286 BD_DFLAGS$(BDID) := %(dflags)
1288 BD_AFLAGS$(BDID) := %(aflags)
1290 BD_LINKLIB$(BDID) := $(BD_LIBDIR$(BDID))/lib$(BD_LIBNAME$(BDID)).a
1292 .PHONY : setup-linklib$(BDID)
1294 #MM %(mmake) : %(mmake)-setup
1296 %(mmake) : $(BD_LINKLIB$(BDID))
1299 %(mmake)-setup : setup-linklib$(BDID)
1303 @$(RM) $(BD_OBJS$(BDID)) $(BD_DEPS$(BDID))
1305 %rule_makedirs dirs="$(BD_OBJDIR$(BDID)) $(BD_LIBDIR$(BDID))" \
1306 setuptarget=setup-linklib$(BDID)
1308 ifeq ($(TARGET),%(mmake))
1309 ifneq ($(dir $(BD_FILES$(BDID))),./)
1310 vpath %.c $(filter-out ./,$(dir $(BD_FILES$(BDID))))
1313 %rule_compile basename=% targetdir=$(BD_OBJDIR$(BDID)) \
1314 cflags=$(BD_CFLAGS$(BDID)) dflags=$(BD_DFLAGS$(BDID))
1315 %rule_assemble basename=% targetdir=$(BD_OBJDIR$(BDID)) \
1316 flags=$(BD_AFLAGS$(BDID))
1319 %rule_link_linklib libname=%(libname) objs=$(BD_OBJS$(BDID)) libdir=$(BD_LIBDIR$(BDID))
1321 %include_deps depstargets=%(mmake) deps=$(BD_DEPS$(BDID))
1323 #------------------------------------------------------------------------------
1326 #------------------------------------------------------------------------------
1328 # - mmake is the mmaketarget
1329 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
1330 # - description is the catalog description file (.cd) (default *.cd)
1331 # - subdir is the destination subdir of the catalogs
1332 # - name is the name of the destination catalog, without the .catalog suffix
1333 # - source is the path to the generated source code file
1334 # - dir is the base destination directory (default $(AROS_CATALOGS))
1335 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
1337 %define build_catalogs mmake=/A name=/A subdir=/A \
1338 catalogs="$(basename $(wildcard *.ct))" source="../strings.h" \
1339 description="$(basename $(wildcard *.cd))" dir=$(AROS_CATALOGS) \
1340 sourcedescription="$(TOOLDIR)/C_h_orig"
1342 %buildid targets="%(mmake) %(mmake)-setup %(mmake)-clean"
1344 BD_SRCS$(BDID) := $(foreach name, %(catalogs), $(name).ct)
1345 BD_OBJS$(BDID) := $(foreach name, %(catalogs), %(dir)/$(name)/%(subdir)/%(name).catalog)
1346 BD_DIRS$(BDID) := $(foreach name, %(catalogs), %(dir)/$(name)/%(subdir))
1348 #MM %(mmake) : %(mmake)-setup
1350 %(mmake) : $(BD_OBJS$(BDID)) %(source)
1353 %rule_makedirs dirs=$(BD_DIRS$(BDID)) setuptarget=%(mmake)-setup
1355 %(dir)/%/%(subdir)/%(name).catalog : %.ct %(description).cd
1356 @$(ECHO) "Creating %(name) catalog for language $*."
1357 @$(FLEXCAT) %(description).cd $*.ct CATALOG=%(dir)/$*/%(subdir)/%(name).catalog || [ $$? -lt 10 ]
1360 %(source) : %(description).cd
1361 @$(ECHO) "Creating %(name) catalog source file %(source)"
1362 @$(FLEXCAT) %(description).cd %(source)=%(sourcedescription).sd
1367 $(RM) $(BD_OBJS$(BDID)) %(source)
1369 .PHONY: %(mmake) %(mmake-setup) %(mmake-clean)
1373 #-----------------------------------------------------------------------------
1375 #-----------------------------------------------------------------------------
1377 # - mmake is the mmaketarget
1378 # - icons is a list of icon base names (ie. without the .info suffix)
1379 # - dir is the destination directory
1380 #-----------------------------------------------------------------------------
1382 %define build_icons mmake=/A icons=/A dir=/A
1384 %buildid targets="%(mmake) %(mmake)-setup %(mmake)-clean"
1386 BD_OBJS$(BDID) := $(foreach icon, %(icons), %(dir)/$(icon).info)
1388 #MM %(mmake) : %(mmake)-setup
1390 %(mmake) : $(BD_OBJS$(BDID))
1392 %(dir)/%.info : %.info.src %.png
1393 @$(ECHO) Creating $(notdir $@)...
1394 @$(ILBMTOICON) $+ $@
1397 %rule_makedirs dirs=%(dir) setuptarget=%(mmake)-setup
1401 @$(RM) $(BD_OBJS$(BDID))
1407 #-----------------------------------------------------------------------------
1409 #------------------------------------------------------------------------------
1410 # Compile files for a arch specific replacement of code for a module
1411 # - files: the basename of the C files to compile.
1412 # - asmfiles: the basename of the asm file to assemble.
1413 # - mainmmake: the mmake of the module in the main directory to compile these
1414 # arch specific files for.
1415 # - maindir: the object directory for the main module
1416 # - arch: the arch for which to compile these files. It can has to have the form
1417 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
1418 # - cflags (default $(CFLAGS)): the C flags to use for compilation
1419 # - dflags: the flags used during creation of dependency file. If not specified
1420 # the same value as cflags will be used
1421 # - aflags: the flags used during assembling
1422 # - compiler: (host or target) specifies which compiler to use. By default
1423 # the target compiler is used
1424 %define build_archspecific files= asmfiles= mainmmake=/A maindir=/A arch=/A \
1425 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
1427 ifeq (%(files) %(asmfiles),)
1428 $(error no files or asmfiles given)
1431 %buildid targets="%(mainmmake)-%(arch) %(mainmmake)-%(arch)-setup"
1433 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1434 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1435 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1437 #MM %(mainmmake)-%(arch) : %(mainmmake)-%(arch)-setup %(mainmmake)-includes
1440 $(error argument arch has to be non empty for the rule_compile_archspecific macro)
1443 BD_OBJDIR$(BDID) := $(GENDIR)/%(maindir)/arch
1444 BD_COBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1445 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
1446 BD_OBJS$(BDID) := $(BD_COBJS$(BDID)) $(BD_ASMOBJS$(BDID))
1447 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1449 ifeq ($(TARGET),%(mainmmake)-%(arch))
1450 vpath %.c $(filter-out ./,$(dir %(files)))
1451 vpath %.s $(filter-out ./,$(dir %(asmfiles)))
1452 vpath %.S $(filter-out ./,$(dir %(asmfiles)))
1455 #MM %(mainmmake)-%(arch)-setup
1456 %rule_makedirs dirs=$(BD_OBJDIR$(BDID)) setuptarget=%(mainmmake)-%(arch)-setup
1459 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
1461 #MM %(mainmmake)-%(arch)-setup
1462 %rule_makedirs dirs=$(BD_OBJDIR$(BDID)) setuptarget=%(mainmmake)-%(arch)-setup
1464 ifeq ($(findstring %(compiler),host target),)
1465 $(error unknown compiler %(compiler))
1467 ifeq (%(compiler),target)
1468 $(BD_COBJS$(BDID)) : TMP_CMD:=$(TARGET_CC)
1470 ifeq (%(compiler),host)
1471 $(BD_COBJS$(BDID)) : TMP_CMD:=$(HOST_CC)
1473 ifneq (%(modulename),)
1474 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) \
1475 --include $(GENDIR)/%(maindir)/%(modulename)_deflibdefs.h
1477 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
1479 ifeq ($(TARGET),%(mainmmake)-%(arch))
1480 $(BD_OBJDIR$(BDID))/%.o : %.c
1481 %compile_q opt=$(TMP_CFLAGS) cmd=$(TMP_CMD)
1485 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags)
1487 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
1489 ifeq ($(TARGET),%(mainmmake)-%(arch))
1490 $(BD_OBJDIR$(BDID))/%.d : %.c
1491 %mkdepend_q flags=$(TMP_DFLAGS)
1494 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
1496 ifeq ($(TARGET),%(mainmmake)-%(arch))
1497 $(BD_OBJDIR$(BDID))/%.o : %.s
1498 %assemble_q opt=$(AFLAGS)
1499 $(BD_OBJDIR$(BDID))/%.o : %.S
1500 %assemble_q opt=$(AFLAGS)
1503 %include_deps depstargets=%(mainmmake)-%(arch) deps=$(BD_DEPS$(BDID))
1505 #------------------------------------------------------------------------------
1513 # ======================
1514 # Old stuff, will probably be removed in the future
1519 # GNU Make automatic variables
1521 # $< First dependency
1522 # $? All newer dependencies
1523 # $^ All dependencies
1524 # $* The stem (ie. target is dir/a.foo.b and the pattern is
1525 # a.%.b, then the stem is dir/foo)
1527 #------------------------------------------------------------------------------
1528 # rule to generate libdefs.h with archtool (options may go away!)
1529 %define libdefs_rule conffile=lib.conf genlibdefstool=$(ARCHTOOL) dest=libdefs.h
1530 %(dest) : %(conffile) %(genlibdefstool)
1531 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
1532 @%(genlibdefstool) -c -o $@ %(conffile)
1536 #------------------------------------------------------------------------------
1537 # generate asm files from c files (for debugging purposes)
1540 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
1541 @$(TARGET_CC) -S $(CFLAGS) $< -c -o $@
1544 #------------------------------------------------------------------------------
1545 # Convert two png images to an Amiga icon file based on the description
1546 # file %(from), with outputfile going to %(to).
1547 %define makeicon2 from=$< to=$@ img1="$(basename $(basename $<))_N.png" img2="$(basename $(basename $<))_S.png"
1548 @$(ECHO) "Creating icon %(to)..."
1549 @$(PNGTOPNM) %(img1) | $(PPMTOILBM) -maxplanes 8 >$(GENDIR)/genicon1.iff
1550 @$(PNGTOPNM) %(img2) | $(PPMTOILBM) -maxplanes 8 >$(GENDIR)/genicon2.iff
1551 @$(ILBMTOICON) %(from) $(GENDIR)/genicon1.iff $(GENDIR)/genicon2.iff %(to)
1554 #------------------------------------------------------------------------------
1555 # NOTE: The following are all part of Iain's build changes, please don't use
1556 # or change anything below this line until you know what you are doing. This
1557 # is so that I don't conflict with the semantics of any of the above macros.
1558 #------------------------------------------------------------------------------
1560 #------------------------------------------------------------------------------
1561 # Copy files from one directory to another.
1563 %define copy_files_q files=$(FILES) src=. dst=/A maketarget=files-copy
1565 SRC_FILES := $(foreach f, %(files), %(src)/$(f))
1566 DST_FILES := $(foreach f, %(files), %(dst)/$(f))
1568 %(maketarget) : setup $(DST_FILES)
1570 $(DST_FILES) : %(dst)/% : %(src)/%
1578 #----------------------------------------------------------------------------------
1579 # Copy a diretory recursively to another place, preserving the original
1580 # hierarchical structure
1582 # src: the source directory whose content will be copied
1583 # dst: the directory where to copy src's content. If not existing, it will be made.
1585 %define copy_dir_recursive mmake=/A src=$(TOP)/$(CURDIR) dst=/A
1587 %(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)
1588 %(mmake)_DIRS := $(sort $(foreach f,$(%(mmake)_FILES),$(dir $(f))))
1590 define %(mmake)_mkdir
1595 define %(mmake)_copy
1596 $(3)/$(1): $(2)/$(1) | $(dir $(3)/$(1))
1603 %(mmake): | $(GENDIR)/$(CURDIR)
1604 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1605 $(ECHO) "all: $(addprefix \$$(DST)/,$(%(mmake)_FILES))" > $$m
1606 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1607 for d in $(%(mmake)_DIRS); do \
1608 $(ECHO) "\$$(DST)/$$d: ; $(MKDIR) \$$@" >> $$m; \
1610 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1611 for f in $(%(mmake)_FILES); do \
1612 $(ECHO) "\$$(DST)/$$f: \$$(SRC)/$$f | \$$\$$(@D); $(CP) \$$< \$$@" >> $$m; \
1614 for dst in %(dst); do \
1615 $(MAKE) -f $$m DST=$$dst SRC=%(src) all; \
1618 $(GENDIR)/$(CURDIR):
1623 #------------------------------------------------------------------------------
1624 # Copy include files into the includes directories. There are currently
1625 # two include directories. One for building AROS $(AROS_INCLUDES) and one
1626 # for building tools that need to run on the host system $(GENINCDIR). The
1627 # $(GENINCDIR) path must not contain any references to the C runtime
1628 # library header files.
1630 %define copy_includes mmake= includes=$(INCLUDE_FILES) path=. dir=include
1633 INCL_FILES_1 := $(subst %(dir),$(AROS_INCLUDES)/%(path),%(includes))
1634 INCL_FILES_2 := $(subst %(dir),$(GENINCDIR)/%(path),%(includes))
1635 _INC_PATH := %(dir)/
1637 INCL_FILES_1 := $(foreach f,%(includes),$(AROS_INCLUDES)/%(path)/$(f))
1638 INCL_FILES_2 := $(foreach f,%(includes),$(GENINCDIR)/%(path)/$(f))
1644 includes-copy : %(mmake)
1647 %(mmake) : %(mmake)-includes-setup $(INCL_FILES_1) $(INCL_FILES_2)
1653 includes-copy : includes-setup $(INCL_FILES_1) $(INCL_FILES_2)
1657 $(AROS_INCLUDES)/%(path)/%.h : $(_INC_PATH)%.h
1660 $(GENINCDIR)/%(path)/%.h : $(_INC_PATH)%.h
1664 %(mmake)-includes-setup : $(AROS_INCLUDES)/%(path) $(GENINCDIR)/%(path)
1666 .PHONY: %(mmake)-includes-setup
1668 includes-setup : $(AROS_INCLUDES)/%(path) $(GENINCDIR)/%(path)
1671 $(AROS_INCLUDES)/%(path) $(GENINCDIR)/%(path) :
1674 ,PHONY: includes-copy includes-setup
1678 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
1679 STUBS_SRC := $(foreach f,$(STUBS),$(f).c)
1680 STUBS_OBJ := $(foreach f,$(STUBS),$(OBJDIR)/$(f).o)
1681 STUBS_MEM := $(foreach f,$(STUBS),$(f).o)
1682 STUBS_DEP := $(foreach f,$(STUBS),$(OBJDIR)/$(f).d)
1683 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
1685 #MM- linklibs : hidd-%(hidd)-stubs
1686 #MM- %(parenttarget): hidd-%(hidd)-stubs
1687 #MM hidd-%(hidd)-stubs : includes includes-copy
1688 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
1690 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
1693 $(STUBS_OBJ) : $(STUBS_SRC)
1694 %compile_q cmd=$(TARGET_CC) opt=%(cflags)
1696 $(STUBS_DEP) : $(STUBS_SRC)
1697 %mkdepend_q flags=%(dflags)
1700 %mkdirs_q $(OBJDIR) $(LIBDIR)
1704 -@$(RM) $(HIDD_LIB) $(OBJDIR)
1706 DEPS := $(DEPS) $(STUBS_DEP)
1710 #------------------------------------------------------------------------------
1711 # Build an imported source tree which uses the configure script from the
1712 # autoconf package. This rule will try to "integrate" the produced files as
1713 # much as possible in the AROS build, for exampley by putting libraries in the
1714 # standard library directory, includes in the standard include directory, and
1715 # so on. You can however override this behaviour.
1717 # As a special "bonus" for you, the PROGDIR environment variable is defined to
1718 # be %(bindir) (or its deduced value) when running "make install", and
1719 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
1720 # configure script some more parameters whose value depends upon the PROGDIR
1721 # env var, so that the program gets all its stuff installed in the proper place
1722 # when building it, but when running it from inside AROS it can also find that
1723 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
1724 # the configuration parameters set when running ./configure
1726 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
1727 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
1728 # to the name which has to follow it.
1731 %define build_with_configure mmake=/A srcdir=$(TOP)/$(CURDIR) prefix= aros_prefix= \
1732 extraoptions= nix_dir_layout= nix=no host=no \
1733 install_target=install postconfigure= postinstall=
1736 %(mmake)-prefix := %(prefix)
1738 %(mmake)-prefix := $(AROS_CONTRIB)
1741 ifneq (%(aros_prefix),)
1742 %(mmake)-aros_prefix := %(aros_prefix)
1744 %(mmake)-aros_prefix := $(%(mmake)-prefix)
1748 %(mmake)-nix := -nix
1749 %(mmake)-volpfx := /
1750 %(mmake)-volsfx := /
1752 ifeq (%(nix_dir_layout),)
1753 %(mmake)-nix_dir_layout := yes
1756 %(mmake)-volsfx := :
1758 ifeq (%(nix_dir_layout),)
1759 %(mmake)-nix_dir_layout := no
1763 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
1765 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) exec_prefix=$(%(mmake)-prefix)
1767 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) %(host)),yes)
1768 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
1769 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
1772 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
1773 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
1775 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
1778 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
1780 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) sbindir=$(%(mmake)-prefix) \
1781 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) oldincludedir=$(AROS_INCLUDES)
1785 .PHONY : %(mmake) %(mmake)-setup %(mmake)-clean %(mmake)-build_and_install-quick
1787 #MM- %(mmake) : setup includes linklibs-core %(mmake)-quick
1789 ifneq (%(install_target),)
1790 %(mmake)-install_command = \
1791 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
1792 -C $(GENDIR)/$(CURDIR) %(install_target) && \
1793 $(TOUCH) $(GENDIR)/$(CURDIR)/.installed
1795 %(mmake)-uninstall_command = \
1796 $(RM) $(GENDIR)/$(CURDIR)/.installed && \
1797 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
1798 -C $(GENDIR)/$(CURDIR) uninstall
1800 %(mmake)-install_command := true
1801 %(mmake)-uninstall_command := true
1804 #MM- %(mmake)-quick : %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
1807 %(mmake)-build_and_install-quick : $(GENDIR)/$(CURDIR)/.configured
1808 if ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q -C $(GENDIR)/$(CURDIR); then \
1809 $(RM) $(GENDIR)/$(CURDIR)/.installed && \
1810 $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -C $(GENDIR)/$(CURDIR) && \
1811 $(%(mmake)-install_command); \
1814 %(srcdir)/.files-touched:
1815 find %(srcdir) -exec $(TOUCH) -r %(srcdir)/configure '{}' \; && \
1819 %(mmake)-uninstall :
1820 $(%(mmake)-uninstall_command)
1822 ifneq ($(DEBUG),yes)
1823 %(mmake)-s_flag = -s
1827 %(mmake)-configure : $(GENDIR)/$(CURDIR)/.configured
1830 $(GENDIR)/$(CURDIR)/.configured : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
1832 %mkdirs_q $(GENDIR)/$(CURDIR)
1833 cd $(GENDIR)/$(CURDIR) && \
1834 find . -name config.cache -exec $(RM) '{}' \; && \
1836 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) && \
1839 $(GENDIR)/$(CURDIR)/.configured : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
1841 %mkdirs_q $(GENDIR)/$(CURDIR)
1842 cd $(GENDIR)/$(CURDIR) && \
1843 find . -name config.cache -exec $(RM) '{}' \; && \
1844 CC="$(TARGET_CC) $(%(mmake)-nix) $(%(mmake)-s_flag)" CC_FOR_BUILD="$(HOST_CC)" \
1845 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) --host=$(AROS_TARGET_CPU)-aros \
1846 --target=$(AROS_TARGET_CPU)-aros --build=local --disable-nls --without-x \
1847 --without-pic --disable-shared && \
1852 %(mmake)-clean : %(mmake)-uninstall
1853 @$(RM) $(GENDIR)/$(CURDIR)
1856 #############################################################################
1857 #############################################################################
1859 ## Misciellanous macros. Everying that doesn't fin above should be put ##
1862 #############################################################################
1863 #############################################################################
1865 #----------------------------------------------------------------------------------
1866 # Given an archive name, patches names and locations where to find them, fetch
1867 # the archive and the patches from any of those locations, unpack the archive
1868 # and then apply the patches.
1870 # Locations currently supported are http and ftp sites, plus local filesystem
1871 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
1872 # the fetch.sh script needs to be modified, since this macro relies on that script.
1876 # - archive_origins = list of locations where to find the archive. They are tried
1877 # in sequence, until the archive is found and fetching it
1878 # succeeded. If not specified, the current directory is assumed.
1879 # - archive = the archive name. Mandatory.
1880 # - destination = the local directory where to put the archive and patches.
1881 # If not specified, the current directory is assumed.
1882 # - patches_origins = list of locations where to find the patches. They are tried
1883 # in sequence, until a patch is found and fetching it
1884 # succeeded. If not specified, the current directory is assumed.
1885 # - patches_specs = list of "patch specs". A patch spec is of the form
1886 # patch_name[:[patch_subdir][:patch_opt]].
1888 # - patch_name = the name of the patch file
1889 # - patch_subdir = the directory within \destination\ where to
1891 # - patch_opt = any options to pass to the `patch' command
1892 # when applying the patch.
1894 # The patch_subdir and patch_opt fields are optional.
1896 %define fetch archive_origins=. archive=/A suffixes= destination=. patches_origins=. patches_specs=::
1897 $(FETCH) -ao "%(archive_origins)" -a %(archive) -as "%(suffixes)" -d %(destination) \
1898 -po "%(patches_origins)" -p %(patches_specs)
1901 #-----------------------------------------------------------------------------------------
1902 # Joins the features of %fetch and %build_with_configure, taking advantage of
1903 # the naming scheme of GNU packages. GNU packages names are in the form
1905 # <package name>-<version number>.<archive format suffix>
1907 # If a patch is provided, it *must* be named the following way:
1909 # <package name>-<version number>-aros.diff
1911 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
1912 # CD'ing into the archive's extracted directory.
1914 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
1915 # the %fetch_and_build macro only accept *one* patch for each package. It's up to you
1916 # to make that patch fully comprehensive.
1918 # NOTE: GNU packages are always compiled with *nix semantics turned on.
1922 # - mmake = the meta make target, as would be supplied to the %build_with_configure
1924 # - package = the GNU package name, sans version and archive format suffixes.
1925 # - version = the package's version number, or otherwise any other version string.
1926 # It gets appended to the package name to form the basename of the archive.
1927 # - suffixes = a list of suffixes to apped to the the package name plus the
1928 # version. Each one of them is tried until a matching archive is found.
1929 # Defaults to "tat.bz2 tar.gz".
1930 # - destination = same meaning as the one for the %fetch macro
1931 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
1932 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
1934 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
1935 # - prefix = same meaning as the one for the %build_with_configure macro. Defaults to
1937 # - aros_prefix = same meaning as the one for the %build_with_configure macro. Defaults to
1939 # - extraoptions = same meaning as the one for the %build_with_configure macro.
1940 # - postinstall = same meaning as the one for the %build_with_configure macro.
1942 %define fetch_and_build mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
1943 srcdir= package_repo= patch=no patch_repo= prefix= \
1944 aros_prefix= extraoptions= postconfigure= postinstall= nix=no nix_dir_layout=
1946 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
1947 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
1949 %(mmake)-archbase := %(package)-%(version)
1952 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
1954 %(mmake)-prefix := %(prefix)
1957 ifneq (%(subpackage),)
1958 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
1960 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
1964 %(mmake)-%(subpackage)-srcdir := %(srcdir)
1966 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
1970 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-p1
1972 %(mmake)-%(subpackage)-patches_specs := ::
1975 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
1977 .PHONY : %(mmake)-%(subpackage)-fetch
1979 %(mmake)-%(subpackage)-fetch :
1980 %fetch archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
1981 destination=$(PORTSDIR)/%(package) \
1982 archive_origins=". %(package_repo)" \
1983 patches_specs="$(%(mmake)-%(subpackage)-patches_specs)" patches_origins=". %(patch_repo)"
1985 #MM- %(mmake) : %(mmake)-%(subpackage)
1987 PACKAGES_DIR := $(AROSDIR)/../Packages
1989 %(mmake)-%(subpackage)-package-dir := $(PACKAGES_DIR)/$(%(mmake)-%(subpackage)-archbase)
1991 %(mmake)-%(subpackage)-package-basename := \
1992 $(PACKAGES_DIR)/$(%(mmake)-%(subpackage)-archbase)-aros-bin.$(AROS_TARGET_CPU)
1994 %build_with_configure mmake=%(mmake)-%(subpackage) \
1995 srcdir=$(PORTSDIR)/%(package)/$(%(mmake)-%(subpackage)-srcdir) \
1996 nix=%(nix) nix_dir_layout=%(nix_dir_layout) prefix="$(%(mmake)-%(subpackage)-package-dir)" \
1997 aros_prefix="%(aros_prefix)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
1998 %(mmake)-%(subpackage)-make-package" extraoptions="%(extraoptions)"
2000 .PHONY : %(mmake)-%(subpackage)-make-package
2001 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
2004 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package-basename).tar.bz2
2006 #There seems to be a bug, either with my clock or with make, 'cause it may happen
2007 #that $^ and $@ have exactly the same mtime, and in that case make tries
2008 #to rebuild $@ again, which would fail because the directory where
2009 #the package got installed would not exist anymore.
2010 #We work this around by using an if statement to manually check the mtimes.
2011 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
2012 @if test $(GENDIR)/$(CURDIR)/.installed -nt $@ || ! test -f $@; then \
2014 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" && \
2015 cd $(%(mmake)-%(subpackage)-package-dir) && \
2016 tar --remove-files -cvf $(%(mmake)-%(subpackage)-package-basename).tar * && \
2017 mkdir -p "$(%(mmake)-prefix)" && \
2018 tar -xf $(%(mmake)-%(subpackage)-package-basename).tar -C "%(prefix)"/ && \
2019 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar && \
2020 cd .. && $(RM) $(%(mmake)-%(subpackage)-archbase); \
2024 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2025 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
2026 aros_prefix=/GNU extraoptions= postconfigure= postinstall=
2028 GNU_REPOSITORY := http://ftp.gnu.org/pub/gnu
2030 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
2031 suffixes="%(suffixes)" srcdir="%(srcdir)" \
2032 package_repo="%(package_repo) $(GNU_REPOSITORY)/%(package)" \
2033 patch="%(patch)" patch_repo="%(patch_repo)" \
2034 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" \
2035 postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=yes
2039 #-----------------------------------------------------------------------------------------
2040 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
2041 # that the package is a "Development" package, and as such it needs to be placed
2042 # under the $(AROS_DEVELOPMENT) directory, as a default.
2044 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
2045 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
2046 # "mmake" argument, because the metatarget is implicitely defined as
2048 # #MM- development-%(package)
2050 %define fetch_and_build_gnu_development package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2051 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPMENT) \
2052 aros_prefix=/Development postconfigure= postinstall= extraoptions=
2054 #MM- development : development-%(package)
2057 %fetch_and_build_gnu mmake=development-%(package) package=%(package) subpackage="%(subpackage)" \
2058 version=%(version) suffixes="%(suffixes)" srcdir="%(srcdir)" \
2059 package_repo="%(package_repo)" patch="%(patch)" patch_repo="%(patch_repo)" prefix=%(prefix) \
2060 aros_prefix="%(aros_prefix)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" \
2061 extraoptions="%(extraoptions)"