1 ############################################################################
2 #############################################################################
4 ## Here are the mmakefile macros that are used as commands in the body ##
6 ## They are used to help the portability of mmakefiles to different ##
7 ## platforms and also will handle the error handling in a standard way. ##
9 #############################################################################
10 #############################################################################
12 #------------------------------------------------------------------------------
13 # Compile the file %(from) to %(to) with %(cmd). Write any errors to %(err)
14 # and use the options in %(opt). Use %(iquote) and %(iquote_end) for supplying -iquote or -I- flags
15 %define compile_q cmd=$(TARGET_CC) opt=$(CFLAGS) from=$< to=$@ iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
16 @$(ECHO) "Compiling %(from)"
17 @$(IF) %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -c %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
18 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
19 $(ECHO) "%(from): %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -c %(from) -o %(to)" >> $(GENDIR)/errors ; \
20 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors ; \
25 $(ECHO) "Compile failed: %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -c %(from) -o %(to)" 1>&2 ; \
26 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
30 #------------------------------------------------------------------------------
33 #------------------------------------------------------------------------------
34 # Assemble the file %(from) to %(to) with %(cmd) with the options in %(opt).
35 %define assemble_q cmd=$(CC) opt=$(AFLAGS) from=$< to=$@
36 @$(ECHO) "Assembling $(notdir %(from))..."
37 @$(IF) %(cmd) %(opt) %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
38 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
39 $(ECHO) "$(notdir %(from)): %(cmd) %(opt) %(from) -o %(to)" >> $(GENDIR)/errors ; \
40 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
45 $(ECHO) "Assemble failed: %(cmd) %(opt) %(from) -o %(to)" 1>&2 ; \
46 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
50 #-------------------------------------------------------------------------
53 #------------------------------------------------------------------------------
54 # Link a specified number of objects to an executable
55 %define link_q cmd=$(AROS_CC) opt=$(LDFLAGS) from=$< to=$@ libs=$(LIBS)
56 @$(ECHO) "Linking %(to)..."
57 @$(IF) %(cmd) %(opt) %(from) -o %(to) %(libs) 2>&1 > $(GENDIR)/cerrors 2>&1 ; then \
58 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
59 $(ECHO) "%(to): %(cmd) %(opt) %(from) -o %(to) %(libs)" >> $(GENDIR)/errors ; \
60 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
65 $(ECHO) "Link failed: %(cmd) %(opt) %(from) -o %(to) %(libs)" 1>&2 ; \
66 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
72 #-------------------------------------------------------------------------
73 # Link a module based upon a number of arguments and the standard $(LIBS)
74 # and $(DEPLIBS) make variables.
76 %define link_module_q err="$(notdir $@).err" objs=/A endtag= module=$(MODULE) ldflags=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
77 @$(ECHO) "Building $(notdir $@) ..."
78 @if $(AROS_CC) $(NOSTARTUP_LDFLAGS) %(ldflags) \
79 $(GENMAP) %(objdir)/%(module).map \
80 %(objs) %(libs) %(endtag) \
81 -o $@ 2>&1 > %(objdir)/%(err); \
83 cat %(objdir)/%(err); \
85 cat %(objdir)/%(err); \
89 @if $(TEST) ! -s %(objdir)/%(err) ; then $(RM) %(objdir)/%(err) ; fi
92 #------------------------------------------------------------------------------
94 #------------------------------------------------------------------------------
96 %define mklib_q ar=$(AR) ranlib=$(RANLIB) to=$@ from=$(OBJS)
97 @$(ECHO) "Creating library %(to)..."
102 #------------------------------------------------------------------------------
103 # Create the dependency file %(to) for %(from)
104 %define mkdepend_q flags=$(CFLAGS) from=$< to=$@ cc=$(AROS_CC)
105 %mkdir_q dir="$(dir %(to))"
106 @$(ECHO) "Makedepend $(CURDIR)/$(notdir %(from))..."
107 @AROS_CC="%(cc)" $(MKDEPEND) %(flags) -I$(SRCDIR)/$(CURDIR) %(from) -o %(to)
109 #------------------------------------------------------------------------------
111 #------------------------------------------------------------------------------
112 # Create the function reference file %(to) to %(from)
113 %define mkref_q cc=$(AROS_CC) cppflags="-E -C -dD -D__CXREF__" cflags=$(CFLAGS) from=$< to=$@
114 @$(ECHO) "Generating ref for $(notdir %(from))..."
115 @$(CXREF) -raw -CPP '%(cc) %(cppflags) %(cflags)' %(from) >%(to) 2>$(GENDIR)/cerrors
116 @$(IF) $(TEST) -s %(to) ; \
118 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
119 $(ECHO) "%(from): $(CXREF) -raw -CPP '%(cc) %(cppflags) %(cflags)' %(from) >%(to)" >> $(GENDIR)/errors ; \
120 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors ; \
123 $(ECHO) "Reference generation failed: $(CXREF) -raw -CPP '%(cc) %(cppflags) %(cflags)' %(from) >%(to)" 1>&2 ; \
124 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
130 #------------------------------------------------------------------------------
131 # Create one directory without any output
132 %define mkdir_q dir=.
133 @$(IF) $(TEST) ! -d %(dir) ; then $(MKDIR) %(dir) ; else $(NOP) ; fi
136 #------------------------------------------------------------------------------
137 # Create several directories without any output
138 %define mkdirs_q dirs=/M
139 @$(FOR) dir in %(dirs) ; do \
140 $(IF) $(TEST) ! -d $$dir ; then $(MKDIR) $$dir ; else $(NOP) ; fi ; \
144 #############################################################################
145 #############################################################################
147 ## Here are the mmakefile macro's that are used to do certain tasks in a ##
148 ## mmakefile. They consist of one or more full makefile rules. ##
149 ## In general the files generated in these macro's are also defined as ##
150 ## make targets so that they can be used as a dependency in other rules ##
152 #############################################################################
153 #############################################################################
155 #------------------------------------------------------------------------------
156 # Generate a unique id for each of the %build... rules
157 %define buildid targets=/A
159 ifneq ($(filter $(TARGET),%(targets)),)
160 BDTARGETID := $(BDID)
163 #------------------------------------------------------------------------------
166 #------------------------------------------------------------------------------
167 # Copy file %(from) to %(to) in a makefile rule
168 %define rule_copy from=/A to=/A
172 #------------------------------------------------------------------------------
175 #------------------------------------------------------------------------------
176 # Copy the files %(files) to %(targetdir). For each file in %(files),
177 # %(srcdir)/file is copied to %(targetdir)/file. The targetdir and the
178 # appropriate subdirs are not generated by this rule so they have to be
180 %define rule_copy_multi files=/A targetdir=/A srcdir=.
182 $(addprefix %(targetdir)/,%(files)) : %(targetdir)/% : %(srcdir)/%
185 #------------------------------------------------------------------------------
187 #------------------------------------------------------------------------------
188 # Copy the files %(files) to %(targetdir). For each file in %(files),
189 # %(srcdir)/file is copied to %(targetdir)/file if these files are different.
190 # %(stampfile) is used to keep track of when the last time the comparison has
191 # been done. The targetdir and the appropriate subdirs are not generated by
192 # this rule so they have to be present.
193 %define rule_copy_diff_multi files=/A targetdir=/A srcdir=. \
194 stampfile=$(TMP_SRCDIR)/.copy_stamp
196 TMP_SRCDIR := %(srcdir)
198 $(addprefix %(targetdir)/,%(files)) : | %(stampfile)
200 %(stampfile) : COPYSRCDIR := %(srcdir)
201 %(stampfile) : TGTDIR := %(targetdir)
202 %(stampfile) : FILES := %(files)
203 %(stampfile) : $(addprefix %(srcdir)/,%(files))
204 @for f in $(FILES); do \
205 $(IF) ! $(CMP) -s $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; then \
206 $(CP) $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; \
211 #------------------------------------------------------------------------------
213 #------------------------------------------------------------------------------
214 # Will join all the files in %(from) to %(to). When text is specified it will
216 # Restriction: at the moment when using a non-empty target dir %(from) may
218 %define rule_join to=/A from=/A text=
226 #------------------------------------------------------------------------------
229 #------------------------------------------------------------------------------
230 # Include the dependency files and add some internal rules
231 # When depstargets is provided the depencies will only be included when one of
232 # these targets is the $(TARGET). Otherwise the dependencies will only be
233 # include when the $(TARGET) is not for setup or clean
234 %define include_deps deps=$(DEPS)/M depstargets=
236 ifneq (%(depstargets),)
237 ifneq ($(findstring $(TARGET),%(depstargets)),)
241 ifeq (,$(filter clean% %clean %clean% setup% includes% %setup,$(TARGET)))
247 #------------------------------------------------------------------------------
250 #------------------------------------------------------------------------------
251 # Create the directories %(dirs). The creation will be done by adding rules to
252 # the %(setuptarget) make target with setup as the default.
253 %define rule_makedirs dirs=/A setuptarget=setup
255 %(setuptarget) :: %(dirs)
257 GLOB_MKDIRS += %(dirs)
260 #------------------------------------------------------------------------------
263 #------------------------------------------------------------------------------
264 # Generate a rule to compile a C source file to an object file and generate
265 # the dependency file. Basename may contain a directory part, then the source
266 # file has to be in that directory. The generated file will be put in the
267 # object directory without the directory.
269 # - basename: the basename of the file to compile. Use % for a wildcard rule
270 # - cflags (default $(CFLAGS)): the C flags to use for compilation
271 # - dflags: the flags used during creation of dependency file. If not specified
272 # the same value as cflags will be used
273 # - targetdir: the directory to put the .o file and the .d file. By default
274 # it is put in the same directory as the .c file
275 %define rule_compile basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target nix=no
278 TMP_TARGETBASE := %(basename)
280 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
283 ifeq ($(findstring %(compiler),host kernel target),)
284 $(error unknown compiler %(compiler))
286 ifeq (%(compiler),target)
287 $(TMP_TARGETBASE).o : TMP_CMD:=$(TARGET_CC)
288 $(TMP_TARGETBASE).d : TMP_CMD:=$(TARGET_CC)
289 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
290 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
291 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
292 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
294 ifeq (%(compiler),host)
295 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
296 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
297 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
298 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
299 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
300 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
302 ifeq (%(compiler),kernel)
303 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
304 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
305 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
306 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
307 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
308 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
312 $(TMP_TARGETBASE).o : CFLAGS := -nix %(cflags)
314 $(TMP_TARGETBASE).o : CFLAGS := %(cflags)
316 $(TMP_TARGETBASE).o : %(basename).c
317 %compile_q cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
321 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(cflags)
323 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(cflags)
327 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(dflags)
329 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(dflags)
332 $(TMP_TARGETBASE).d : %(basename).c
333 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
335 #------------------------------------------------------------------------------
338 #------------------------------------------------------------------------------
339 # Generate a rule to compile multiple C source files to an object file and
340 # generate the corresponding dependency files. The generated file will be put
341 # in the object directory without the directory part of the source file.
343 # - basenames: the basenames of the files to compile. The names may include
344 # relative or absolute path names. No wildcard is allowed
345 # - cflags (default $(CFLAGS)): the C flags to use for compilation
346 # - dflags: the flags used during creation of dependency file. If not specified
347 # the same value as cflags will be used
348 # - targetdir: the directory to put the .o file and the .d file. By default
349 # it is put in the same directory as the .c file. When targetdir is not
350 # empty, path names will be stripped from the file names so that all files
351 # are in that dir and not in subdirectories.
352 # - compiler (default target): compiler to use, target, kernel or host
353 %define rule_compile_multi basenames=/A cflags=$(CFLAGS) dflags= targetdir= \
357 TMP_TARGETS := $(addsuffix .o,%(basenames))
358 TMP_DTARGETS := $(addsuffix .d,%(basenames))
361 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
362 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
363 TMP_WILDCARD := %(targetdir)/%
365 # Be sure that all .c files are generated
366 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .c,%(basenames))
368 # Be sure that all .c files are found
369 TMP_DIRS := $(filter-out ./,$(sort $(dir %(basenames)) $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir %(basenames)))))
371 vpath %.c $(TMP_DIRS)
376 ifeq ($(findstring %(compiler),host kernel target),)
377 $(error unknown compiler %(compiler))
379 ifeq (%(compiler),target)
380 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TARGET_CC)
381 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
382 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
384 ifeq (%(compiler),host)
385 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_CC)
386 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
387 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
389 ifeq (%(compiler),kernel)
390 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
391 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
392 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
395 $(TMP_TARGETS) : CFLAGS := %(cflags)
396 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.c
397 %compile_q cmd=$(CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
400 $(TMP_DTARGETS) : DFLAGS:=%(cflags)
402 $(TMP_DTARGETS) : DFLAGS:=%(dflags)
404 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.c
405 %mkdepend_q cc=$(CMD) flags=$(DFLAGS)
407 #------------------------------------------------------------------------------
410 #------------------------------------------------------------------------------
411 # Make an alias from one arch specific build to another arch.
413 # - mainmmake: the mmake of the module in the main tree
414 # - arch: the current arch
415 # - alias: the alias to which this should point
416 %define rule_archalias mainmmake=\A arch=\A alias=\A
418 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
420 #------------------------------------------------------------------------------
423 #------------------------------------------------------------------------------
424 # Generate a rule to compile a C source file to a shared object file with a
425 # .so suffix. Basename may contain a directory part, then the source
426 # file has to be in that directory. The generated file will be put in the
427 # object directory without the directory.
429 # - basename: the basename of the file to compile. Use % for a wildcard rule
430 # - cflags (default $(CFLAGS)): the C flags to use for compilation
431 # - targetdir: the directory to put the .o file and the .d file. By default
432 # it is put in the same directory as the .c file
433 %define rule_compile_shared basename=/A cflags=$(CFLAGS) targetdir= compiler=target
436 TMP_TARGETBASE := %(basename)
438 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
441 ifeq ($(findstring %(compiler),host kernel target),)
442 $(error unknown compiler %(compiler))
444 ifeq (%(compiler),target)
445 $(TMP_TARGETBASE).so : TMP_CMD:=$(TARGET_CC)
446 $(TMP_TARGETBASE).so : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
447 $(TMP_TARGETBASE).so : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
449 ifeq (%(compiler),host)
450 $(TMP_TARGETBASE).so : TMP_CMD:=$(HOST_CC)
451 $(TMP_TARGETBASE).so : TMP_IQUOTE:=$(HOST_IQUOTE)
452 $(TMP_TARGETBASE).so : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
454 ifeq (%(compiler),kernel)
455 $(TMP_TARGETBASE).so : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
456 $(TMP_TARGETBASE).so : TMP_IQUOTE:=$(KERNEL_IQUOTE)
457 $(TMP_TARGETBASE).so : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
460 $(TMP_TARGETBASE).so : %(basename).c
461 %compile_q opt="$(SHARED_CFLAGS) %(cflags)" cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
463 #------------------------------------------------------------------------------
466 #------------------------------------------------------------------------------
467 # Generate a rule to assemble a source file to an object file. Basename may
468 # contain a directory part, then the source file has to be in that directory.
469 # The generated file will be put in the object directory without the directory.
471 # - basename: the basename of the file to compile. Use % for a wildcard rule
472 # - flags (default $(AFLAGS)): the asm flags to use for assembling
473 # - targetdir: the directory to put the .o file in. By default it is put in the
474 # same directory as the .s file
475 %define rule_assemble basename=/A aflags=$(AFLAGS) targetdir=
478 %(basename).o : AFLAGS := %(aflags)
479 %(basename).o : %(basename).s
483 %(targetdir)/$(notdir %(basename)).o : AFLAGS := %(aflags)
484 %(targetdir)/$(notdir %(basename)).o : %(basename).s
489 #------------------------------------------------------------------------------
492 #------------------------------------------------------------------------------
493 # Generate a rule to assemble multiple source files to an object file. The
494 # generated file will be put in the object directory with the directory part
495 # of the source file stripped off.
497 # - basenames: the basenames of the files to compile. The names may include
498 # relative or absolute path names. No wildcard is allowed
499 # - aflags (default $(AFLAGS)): the flags to use for assembly
500 # - targetdir: the directory to put the .o file and the .d file. By default
501 # it is put in the same directory as the .c file. When targetdir is not
502 # empty, path names will be stripped from the file names so that all files
503 # are in that dir and not in subdirectories.
504 %define rule_assemble_multi basenames=/A aflags=$(AFLAGS) targetdir= suffix=.s
507 TMP_TARGETS := $(addsuffix .o,%(basenames))
510 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
511 TMP_WILDCARD := %(targetdir)/%
513 # Be sure that all .s files are generated
514 $(TMP_TARGETS) : | $(addsuffix %(suffix),%(basenames))
516 # Be sure that all .c files are found
517 TMP_DIRS := $(filter-out ./,$(sort $(dir %(basenames)) $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir %(basenames)))))
519 vpath %%(suffix) $(TMP_DIRS)
524 $(TMP_TARGETS) : AFLAGS := %(aflags)
525 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %%(suffix)
526 %assemble_q opt=$(AFLAGS)
528 #------------------------------------------------------------------------------
531 #------------------------------------------------------------------------------
532 # Link %(objs) to %(prog) using the libraries in %(uselibs)
533 %define rule_link_prog prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
534 usehostlibs= usestartup=yes detach=no nix=no
538 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
540 ifeq (%(usestartup),no)
541 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
544 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
547 # Make a list of the lib files this program depends on.
549 # In LDFLAGS remove white space between -L and directory
550 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
551 # Filter out only the libdirs and remove -L
552 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
554 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
555 # Add normal linklib path
556 TMP_DIRS += $(LIBDIR)/
557 # add lib and .a to static linklib names
558 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) libinit autoinit))
559 # search for the linklibs in the given path, ignore ones not found
560 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
561 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
567 %(prog) : OBJS := %(objs)
568 %(prog) : LDFLAGS := %(ldflags) $(TMP_EXTRA_LDFLAGS)
569 %(prog) : LIBS := $(addprefix -l,%(uselibs)) $(addprefix -l,%(usehostlibs))
570 %(prog) : %(objs) $(TMP_DEPLIBS)
571 %link_q from=$(OBJS) opt=$(LDFLAGS) libs=$(LIBS)
573 #------------------------------------------------------------------------------
576 #------------------------------------------------------------------------------
577 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
578 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
579 %define rule_link_progs progs=/A targetdir=$(AROSDIR)/$(CURDIR) nix=%(nix) \
580 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
581 usestartup=yes detach=no
585 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
587 ifeq (%(usestartup),no)
588 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
591 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
594 # Make a list of the lib files the programs depend on.
596 # In LDFLAGS remove white space between -L and directory
597 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
598 # Filter out only the libdirs and remove -L
599 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
601 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
602 # Add normal linklib path
603 TMP_DIRS += $(LIBDIR)/lib/
604 # add lib and .a to static linklib names
605 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) libinit autoinit))
606 # search for the linklibs in the given path, ignore ones not found
607 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
608 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
614 $(addprefix %(targetdir)/,%(progs)) : LDFLAGS:= %(ldflags) $(TMP_EXTRA_LDFLAGS)
615 $(addprefix %(targetdir)/,%(progs)) : LIBS:= $(addprefix -l,%(uselibs)) $(addprefix -l,%(usehostlibs))
616 $(addprefix %(targetdir)/,%(progs)) : %(targetdir)/% : %(objdir)/%.o $(TMP_DEPLIBS)
617 %link_q from=$< opt=$(LDFLAGS) libs=$(LIBS)
619 #------------------------------------------------------------------------------
622 #------------------------------------------------------------------------------
623 # Link the %(objs) to the library %(libdir)/lib%(libname).a in
624 %define rule_link_linklib libname=/A objs=/A libdir=$(LIBDIR)
626 %(libdir)/lib%(libname).a : %(objs)
629 #------------------------------------------------------------------------------
632 #------------------------------------------------------------------------------
633 # Link the %(objs) to the library %(libdir)/lib%(libname).so in
634 %define rule_link_shlib libname=/A objs=/A libdir=$(LIBDIR)
636 %(libdir)/lib%(libname).so : %(objs)
637 @$(SHARED_LD) $(SHARED_LDFLAGS) -o $@ $^
639 #------------------------------------------------------------------------------
642 #------------------------------------------------------------------------------
643 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
644 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
645 %define rule_linkmodule module=/A objs=/A endobj=/A err=/A objdir=$(OBJDIR) \
646 uselibs= usehostlibs=
648 %(module) : OBJS := %(objs)
649 %(module) : ENDTAG := %(endobj)
650 %(module) : ERR := %(err)
651 %(module) : OBJDIR := %(objdir)
652 %(module) : LIBS := $(addprefix -l,%(uselibs)) -lautoinit -llibinit -L/usr/lib $(addprefix -l,%(usehostlibs))
653 %(module) : %(objs) %(endobj) $(addprefix $(LIBDIR)/lib,$(addsuffix .a,%(uselibs) libinit autoinit))
654 %link_module_q err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS) objdir=$(OBJDIR)
657 #------------------------------------------------------------------------------
660 #------------------------------------------------------------------------------
661 # Generate a rule to generate a function reference file from a C source file.
662 # Basename may contain a directory part, then the source file has to be in that
663 # directory. The generated file will be put in the object directory without the
666 # - basename: the basename of the file to compile. Use % for a wildcard rule
667 # - cflags (default $(CFLAGS)): the C flags to use for compilation
668 # - targetdir: the directory to put the generated .ref file. By default the
669 # .ref file will be put in the same directory as the .c file.
670 # - includefile: This file will be included at the head of the source file
671 %define rule_ref basename=/A cflags=$(CFLAGS) targetdir= includefile= compiler=target
674 GENFILE_TMP := %(basename).ref
676 GENFILE_TMP := %(targetdir)/$(notdir %(basename)).ref
679 ifeq ($(filter %(compiler),target kernel host),)
680 $(error use of %rule_ref: compiler has to be 'host', 'kernel' or 'target')
683 ifeq (%(compiler),target)
684 $(GENFILE_TMP) : CC:=$(TARGET_CC)
686 ifeq (%(compiler),host)
687 $(GENFILE_TMP) : CC:=$(HOST_CC)
689 ifeq(%(compiler),kernel)
690 $(GENFILE_TMP) : CC:=$(KERNEL_CC) $(KERNEL_CFLAGS)
693 $(GENFILE_TMP) : %(basename).c $(CXREF) %(includefile)
694 ifeq (%(includefile),)
695 %mkref_q cc=$(CC) cflags="%(cflags)"
697 %mkref_q cc=$(CC) cflags="%(cflags) -include %(includefile)"
701 #------------------------------------------------------------------------------
704 #------------------------------------------------------------------------------
705 # Generate a rule to generate a function reference file from a C source file.
706 # Basename may contain a directory part, then the source file has to be in that
707 # directory. The generated file will be put in the object directory without the
710 # - basenames: the basenames of the files to compile. No wildcard is allowed
711 # - cflags (default $(CFLAGS)): the C flags to use for compilation
712 # - targetdir: the directory to put the generated .ref file. By default the
713 # .ref file will be put in the same directory as the .c file. When targetdir
714 # is not empty all files will be put there and path parts in the basenames
715 # will be stripped off.
716 # - includefile: This file will be included at the head of the source file
717 %define rule_ref_multi basenames=/A cflags=$(CFLAGS) targetdir= includefile= \
721 TMP_TARGETS := $(addsuffix .ref,%(basenames))
722 TMP_WILDCARD := %.ref
724 TMP_TARGETS := $(addprefix %(targetdir)/,$(addsuffix .ref,$(notdir %(basenames))))
725 TMP_WILDCARD := %(targetdir)/%.ref
727 # Be sure that all .c files are generated
728 $(TMP_TARGETS) : | $(addsuffix .c,%(basenames))
730 # Be sure that all .c files are found
731 TMP_DIRS := $(filter-out ./,$(sort $(dir %(basenames)) $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir %(basenames)))))
733 vpath %.c $(TMP_DIRS)
738 ifeq ($(filter %(compiler),target kernel host),)
739 $(error use of %rule_ref: compiler has to be 'host', 'kernel' or 'target')
742 ifeq (%(compiler),target)
743 $(TMP_TARGETS) : CC:=$(TARGET_CC)
745 ifeq (%(compiler),host)
746 $(TMP_TARGETS) : CC:=$(HOST_CC)
748 ifeq (%(compiler),kernel)
749 $(TMP_TARGETS) : CC:=$(KERNEL_CC) $(KERNEL_CFLAGS)
751 ifeq (%(includefile),)
752 $(TMP_TARGETS) : CFLAGS:=%(cflags)
754 $(TMP_TARGETS) : CFLAGS:="%(cflags) -include %(includefile)"
755 $(TMP_TARGETS) : %(includefile)
757 $(TMP_TARGETS) : $(CXREF)
758 $(TMP_TARGETS) : $(TMP_WILDCARD) : %.c
761 #------------------------------------------------------------------------------
764 #------------------------------------------------------------------------------
765 # Generate the libdefs.h include file for a module.
766 %define rule_genmodule_genlibdefs modname=/A modtype=/A modsuffix= conffile= targetdir=
768 TMP_TARGET := %(modname)_libdefs.h
769 TMP_DEPS := $(GENMODULE)
772 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
773 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
775 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
776 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
778 ifneq (%(modsuffix),)
779 TMP_OPTS += -s %(modsuffix)
781 ifneq (%(targetdir),)
782 TMP_OPTS += -d %(targetdir)
783 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
786 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
787 $(TMP_TARGET) : MODNAME := %(modname)
788 $(TMP_TARGET) : MODTYPE := %(modtype)
789 $(TMP_TARGET) : $(TMP_DEPS)
790 @$(ECHO) "Generating $(notdir $@)"
791 @$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
793 #------------------------------------------------------------------------------
796 #------------------------------------------------------------------------------
797 # Generate the libdefs.h include file for a module.
798 %define rule_genmodule_funclist \
799 modname=/A modtype=/A modsuffix= conffile= targetdir= reffile=
801 TMP_TARGET := %(modname).funclist
802 TMP_DEPS := $(GENMODULE)
805 $(error reffile needed in rule_genmodule_funclist but none specified)
807 TMP_OPTS := -r %(reffile)
808 TMP_DEPS += %(reffile)
810 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
811 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
813 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
814 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
816 ifneq (%(modsuffix),)
817 TMP_OPTS += -s %(modsuffix)
819 ifneq (%(targetdir),)
820 TMP_OPTS += -d %(targetdir)
821 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
824 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
825 $(TMP_TARGET) : MODNAME := %(modname)
826 $(TMP_TARGET) : MODTYPE := %(modtype)
827 $(TMP_TARGET) : $(TMP_DEPS)
828 @$(ECHO) "Generating $(notdir $@)"
829 @$(GENMODULE) $(OPTS) writefunclist $(MODNAME) $(MODTYPE)
831 #------------------------------------------------------------------------------
834 #------------------------------------------------------------------------------
835 # Generate a Makefile.%(modname) with the genmodule program and include this
836 # generated file in this Makefile
837 %define rule_genmodule_makefile modname=/A modtype=/A modsuffix= conffile= \
840 TMP_TARGET := Makefile.%(modname)
841 TMP_DEPS := $(GENMODULE)
844 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
845 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
847 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
848 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
850 ifneq (%(modsuffix),)
851 TMP_OPTS += -s %(modsuffix)
853 ifneq (%(targetdir),)
854 TMP_OPTS += -d %(targetdir)
855 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
858 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
859 $(TMP_TARGET) : MODNAME := %(modname)
860 $(TMP_TARGET) : MODTYPE := %(modtype)
861 $(TMP_TARGET) : $(TMP_DEPS)
862 @$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
864 #------------------------------------------------------------------------------
866 #------------------------------------------------------------------------------
867 # Generate dummy support files so cxref when used on the a module source file
868 # will find something to include. This rule has to be preceeded by
869 # %rule_genmodule_makefile
870 %define rule_genmodule_dummy modname=/A modtype=/A modsuffix= conffile= targetdir=
872 ifneq ($(%(modname)_INCLUDES),)
873 TMP_TARGETS := $(%(modname)_INCLUDES)
875 TMP_DEPS := $(GENMODULE)
878 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
879 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
881 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
882 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
884 ifneq (%(modsuffix),)
885 TMP_OPTS += -s %(modsuffix)
887 ifneq (%(targetdir),)
888 TMP_OPTS += -d %(targetdir)
889 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
892 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
893 $(TMP_TARGETS) : MODNAME := %(modname)
894 $(TMP_TARGETS) : MODTYPE := %(modtype)
895 $(TMP_TARGETS) : $(TMP_DEPS)
896 @$(ECHO) "Generating dummy include files"
897 @$(GENMODULE) $(OPTS) writedummy $(MODNAME) $(MODTYPE)
900 #------------------------------------------------------------------------------
903 #------------------------------------------------------------------------------
904 # Generate the support files for compiling a module. This includes include
905 # files and source files. This rule has to be preceeded by
906 # %rule_genmodule_makefile
907 %define rule_genmodule_files modname=/A modtype=/A modsuffix= targetdir= \
910 TMP_TARGETS := $(%(modname)_STARTFILES) $(%(modname)_ENDFILES) \
911 $(%(modname)_LINKLIBFILES)
912 TMP_TARGETS := $(addsuffix .c,$(TMP_TARGETS)) $(addsuffix .S, $(%(modname)_LINKLIBAFILES))
914 TMP_DEPS := $(GENMODULE)
915 ifeq ($(%(modname)_NEEDREF), yes)
917 $(error reffile needed in rule_genmodule_files but none specified)
919 TMP_OPTS := -r %(reffile)
920 TMP_DEPS += %(reffile)
925 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
926 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
928 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
929 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
931 ifneq (%(modsuffix),)
932 TMP_OPTS += -s %(modsuffix)
934 ifneq (%(targetdir),)
935 TMP_OPTS += -d %(targetdir)
936 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
939 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
940 $(TMP_TARGETS) : MODNAME := %(modname)
941 $(TMP_TARGETS) : MODTYPE := %(modtype)
942 $(TMP_TARGETS) : $(TMP_DEPS)
943 @$(ECHO) "Generating functable and support files for module $(MODNAME$(BDID))"
944 ifneq (%(conffile),lib.conf)
945 @$(IF) $(TEST) -f lib.conf; then \
946 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
949 @$(IF) $(TEST) -f libdefs.h; then \
950 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
952 @$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
954 #------------------------------------------------------------------------------
956 #------------------------------------------------------------------------------
957 # Generate the support files for compiling a module. This includes include
958 # files and source files.
959 %define rule_genmodule_includes modname=/A modtype=/A modsuffix= \
960 targetdir= conffile= reffile=
963 ifneq ($(%(modname)_INCLUDES),)
964 TMP_TARGETS := $(%(modname)_INCLUDES)
966 TMP_DEPS := $(GENMODULE)
967 ifeq ($(%(modname)_NEEDREF), yes)
969 $(error reffile needed in rule_genmodule_files but none specified)
971 TMP_OPTS := -r %(reffile)
972 TMP_DEPS += %(reffile)
977 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
978 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
980 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
981 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
983 ifneq (%(modsuffix),)
984 TMP_OPTS += -s %(modsuffix)
986 ifneq (%(targetdir),)
987 TMP_OPTS += -d %(targetdir)
988 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
991 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
992 $(TMP_TARGETS) : MODNAME := %(modname)
993 $(TMP_TARGETS) : MODTYPE := %(modtype)
994 $(TMP_TARGETS) : $(TMP_DEPS)
995 @$(ECHO) "Generating include files"
996 @$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
999 #------------------------------------------------------------------------------
1001 #------------------------------------------------------------------------------
1002 # Common rules for all makefiles
1004 # Delete generated makefiles
1007 @$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
1009 include $(SRCDIR)/config/make.tail
1011 BDID := $(BDTARGETID)
1013 #------------------------------------------------------------------------------
1016 #############################################################################
1017 #############################################################################
1019 ## Here are the mmakefile build macro's. These are macro's that takes care ##
1020 ## of everything to go from the sources to the generated target. Also all ##
1021 ## intermediate files and directories that are needed are created by these ##
1024 #############################################################################
1025 #############################################################################
1027 #------------------------------------------------------------------------------
1029 %define build_prog mmake=/A progname=/A files=$(BD_PROGNAME) asmfiles= \
1030 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1031 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
1032 aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
1037 BD_PROGNAME := %(progname)
1038 BD_OBJDIR := %(objdir)
1039 BD_TARGETDIR := %(targetdir)
1041 BD_FILES := %(files)
1042 BD_ASMFILES := %(asmfiles)
1043 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_FILES) $(BD_ASMFILES)))
1044 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1046 BD_CFLAGS := %(cflags)
1047 BD_AFLAGS := %(aflags)
1048 BD_DFLAGS := %(dflags)
1049 BD_LDFLAGS := %(ldflags)
1052 %(mmake)-quick : %(mmake)
1054 #MM %(mmake) : includes-generate-deps
1055 %(mmake) : $(BD_TARGETDIR)/$(BD_PROGNAME)
1057 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1058 %rule_compile basename=%(srcdir)% targetdir=$(BD_OBJDIR) \
1059 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1060 %rule_assemble_multi basenames=$(BD_ASMFILES) targetdir=$(BD_OBJDIR) \
1063 %rule_link_prog prog=$(BD_TARGETDIR)/$(BD_PROGNAME) \
1064 objs=$(BD_OBJS) ldflags=$(BD_LDFLAGS) \
1065 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1066 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)"
1070 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1072 $(BD_OBJS) $(BD_DEPS) : | $(BD_OBJDIR)
1073 $(BD_TARGETDIR)/$(BD_PROGNAME) : | $(BD_TARGETDIR)
1074 GLOB_MKDIRS += $(BD_OBJDIR) $(BD_TARGETDIR)
1076 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_TARGETDIR)/$(BD_PROGNAME) $(BD_DEPS)
1079 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1083 #------------------------------------------------------------------------------
1086 #------------------------------------------------------------------------------
1087 # Build programs, for every C file an executable will be built with the same
1089 %define build_progs mmake=/A files=/A nix=no \
1090 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1091 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
1092 uselibs= usehostlibs= usestartup=yes detach=no
1096 BD_OBJDIR := %(objdir)
1097 BD_TARGETDIR := %(targetdir)
1099 BD_FILES := %(files)
1100 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1101 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1102 BD_EXES := $(addprefix $(BD_TARGETDIR)/,$(BD_FILES))
1104 BD_CFLAGS := %(cflags)
1105 BD_DFLAGS := %(dflags)
1106 BD_LDFLAGS := %(ldflags)
1109 %(mmake)-quick : %(mmake)
1111 #MM %(mmake) : includes-generate-deps
1112 %(mmake) : $(BD_EXES)
1114 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1115 %rule_compile basename=% targetdir=$(BD_OBJDIR) nix=%(nix) \
1116 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1118 %rule_link_progs progs=$(BD_FILES) nix=%(nix) \
1119 targetdir=$(BD_TARGETDIR) objdir=$(BD_OBJDIR) \
1120 ldflags=$(BD_LDFLAGS) \
1121 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1122 usestartup="%(usestartup)" detach="%(detach)"
1126 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1128 $(addprefix $(BD_TARGETDIR)/,$(BD_FILES)) : | $(BD_TARGETDIR)
1129 $(BD_DEPS) $(BD_OBJS) : | $(BD_OBJDIR)
1130 GLOB_MKDIRS += $(BD_TARGETDIR) $(BD_OBJDIR)
1132 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_EXES) $(BD_DEPS)
1135 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1139 #------------------------------------------------------------------------------
1142 #------------------------------------------------------------------------------
1144 # This is a bare version: It just compiles and links the given files. It is
1145 # assumed that all needed boiler plate code is in the files. This should only
1146 # be used for compiling external code. For AROS code use %build_module
1147 %define build_module_simple mmake=/A modname=/A modtype=/A \
1148 files="$(basename $(call WILDCARD, *.c))" \
1149 cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1150 objdir=$(OBJDIR) moduledir= \
1151 uselibs= usehostlibs= compiler=target
1153 # Define metamake targets and their dependencies
1154 #MM %(mmake) : core-linklibs includes-generate-deps
1155 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1159 BD_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj
1161 .PHONY : $(BD_ALLTARGETS)
1164 $(error using %build_module_simple: modname may not be empty)
1167 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1170 # Default values for variables and arguments
1171 BD_DEFLINKLIBNAME := %(modname)
1172 BD_DEFREFFILE := %(objdir)/%(modname)_ALL.ref
1173 BD_DEFDFLAGS := %(cflags)
1174 OBJDIR ?= $(GENDIR)/$(CURDIR)
1175 BD_MODDIR := %(moduledir)
1176 ifeq ($(BD_MODDIR),)
1177 ifeq (%(modtype),library)
1178 BD_MODDIR := $(AROS_LIBS)
1180 ifeq (%(modtype),gadget)
1181 BD_MODDIR := $(AROS_GADGETS)
1183 ifeq (%(modtype),datatype)
1184 BD_MODDIR := $(AROS_DATATYPES)
1186 ifeq (%(modtype),handler)
1187 BD_MODDIR := $(AROS_FS)
1189 ifeq (%(modtype),device)
1190 BD_MODDIR := $(AROS_DEVS)
1192 ifeq (%(modtype),resource)
1193 BD_MODDIR := $(AROS_RESOURCES)
1195 ifeq (%(modtype),mui)
1196 BD_MODDIR := $(AROS_CLASSES)/Zune
1198 ifeq (%(modtype),mcc)
1199 BD_MODDIR := $(AROS_CLASSES)/Zune
1201 ifeq (%(modtype),mcp)
1202 BD_MODDIR := $(AROS_CLASSES)/Zune
1204 ifeq (%(modtype),hidd)
1205 BD_MODDIR := $(AROS_DRIVERS)
1208 ifeq ($(BD_MODDIR),)
1209 $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1212 %rule_compile_multi \
1213 basenames="%(files)" targetdir="%(objdir)" \
1214 cflags="%(cflags)" dflags="%(dflags)" \
1215 compiler=%(compiler)
1217 BD_MODULE := $(BD_MODDIR)/%(modname).%(modtype)
1218 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1220 %(mmake)-quick : %(mmake)
1221 %(mmake) : $(BD_MODULE)
1222 %(mmake)-kobj : $(BD_KOBJ)
1224 # The module is linked from all the compiled .o files
1225 BD_OBJS := $(addprefix %(objdir)/, $(addsuffix .o,%(files)))
1226 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1227 endobj= err=%(modname).err objdir=%(objdir) \
1228 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1230 # Link kernel object file
1231 BD_KAUTOLIB := workbench dos cybergraphics intuition layers graphics oop utility \
1233 BD_KBASE := WorkbenchBase DOSBase CyberGfxBase IntuitionBase LayersBase \
1234 GfxBase OOPBase UtilityBase ExpansionBase KeymapBase
1235 BD_KLIB := hiddgraphicsstubs hiddstubs amiga arossupport rom arosm autoinit libinit
1236 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1237 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1238 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_KBASE))
1239 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1240 @$(ECHO) "Linking $@"
1241 @$(AROS_LD) -Ur -o $@ $^ -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1242 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__$$/) || ($$3 ~ /^libraryset_.*$$/) {print "-L " $$3;}'`
1245 ## Dependency fine-tuning
1247 BD_DEPS := $(addprefix %(objdir)/, $(addsuffix .d,%(files)))
1248 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1250 $(BD_OBJS) $(BD_DEPS) $(BD_REFS) : | %(objdir)
1251 $(BD_MODULE) : | $(BD_MODDIR)
1252 $(BD_KOBJ) : | $(KOBJSDIR)
1253 GLOB_MKDIRS += %(objdir) $(BD_MODDIR) $(KOBJSDIR)
1255 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_MODULE) $(BD_KOBJ) $(BD_DEPS)
1257 @$(ECHO) "Cleaning up for module %(modname)"
1262 #------------------------------------------------------------------------------
1264 # Explanation of this macro is done in the developer's manual
1265 %define build_module mmake=/A modname=/A modtype=/A modsuffix= \
1266 conffile= files="$(basename $(call WILDCARD, *.c))" \
1267 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1268 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
1269 reffile=$(BD_DEFREFFILE) noref= \
1270 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
1273 # Define metamake targets and their dependencies
1274 #MM- includes-all : %(mmake)-includes
1275 #MM %(mmake) : %(mmake)-includes core-linklibs
1276 #MM %(mmake)-kobj : %(mmake)-includes core-linklibs
1277 #MM %(mmake)-linklib : %(mmake)-includes
1278 #MM %(mmake)-quick : %(mmake)-includes-quick
1279 #MM %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1280 #MM includes-generate-deps
1281 #MM %(mmake)-includes-quick
1282 #MM %(mmake)-includes-dirs
1283 #MM %(mmake)-makefile
1284 #MM %(mmake)-funclist
1287 # All MetaMake targets defined by this macro
1288 BD_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-includes \
1289 %(mmake)-includes-quick %(mmake)-includes-dirs %(mmake)-clean \
1290 %(mmake)-kobj %(mmake)-funclist %(mmake)-linklib
1292 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1295 $(error using %build_module: modname may not be empty)
1298 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1301 # Default values for variables and arguments
1302 BD_DEFLINKLIBNAME := %(modname)
1303 BD_DEFREFFILE := %(objdir)/%(modname)_ALL.ref
1304 BD_DEFDFLAGS := %(cflags)
1305 OBJDIR ?= $(GENDIR)/$(CURDIR)
1307 ## Create genmodule include Makefile for the module
1309 %(mmake)-makefile : %(objdir)/Makefile.%(modname)
1311 %rule_genmodule_makefile \
1312 modname=%(modname) modtype=%(modtype) \
1313 modsuffix=%(modsuffix) targetdir=%(objdir) \
1314 conffile=%(conffile)
1316 %(objdir)/Makefile.%(modname) : | %(objdir)
1318 GLOB_MKDIRS += %(objdir)
1320 # Do not parse these statements if metatarget is not appropriate
1321 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1323 include %(objdir)/Makefile.%(modname)
1325 BD_DEFMODDIR := $(%(modname)_MODDIR)
1328 ## include files generation
1330 BD_INCDIR := %(prefix)/$(AROS_DIR_INCLUDE)
1331 BD_LIBDEFSINC := %(objdir)/include/%(modname)_libdefs.h
1332 BD_DEFLIBDEFSINC := %(objdir)/include/%(modname)_deflibdefs.h
1334 %(mmake)-includes-quick : %(mmake)-includes
1335 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1336 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1337 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1339 ifneq ($(%(modname)_INCLUDES),)
1340 %rule_genmodule_includes modname=%(modname) modtype=%(modtype) \
1341 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1342 conffile=%(conffile) reffile=%(reffile)
1344 %rule_copy_diff_multi \
1345 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(GENINCDIR) \
1346 stampfile=%(objdir)/%(modname)_geninc
1348 %rule_copy_diff_multi \
1349 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(BD_INCDIR) \
1350 stampfile=%(objdir)/%(modname)_incs
1352 %rule_genmodule_dummy modname=%(modname) modtype=%(modtype) \
1353 modsuffix=%(modsuffix) \
1354 targetdir=%(objdir)/dummyinc conffile=%(conffile)
1356 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1358 TMP%(modname)_INCDIRS := \
1359 %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1360 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1361 $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1362 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget=%(mmake)-includes-dirs
1364 $(addprefix %(objdir)/dummyinc/,$(%(modname)_INCLUDES)) : | %(objdir)/dummyinc $(addprefix %(objdir)/dummyinc/,$(BD_INCDIRS))
1365 GLOB_MKDIRS += %(objdir)/dummyinc $(addprefix %(objdir)/dummyinc/,$(BD_INCDIRS))
1369 %rule_genmodule_genlibdefs modname=%(modname) modtype=%(modtype) \
1370 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1371 conffile=%(conffile)
1373 $(BD_DEFLIBDEFSINC) : FILENAME := $(BD_LIBDEFSINC)
1374 $(BD_DEFLIBDEFSINC) :
1375 @$(ECHO) "generating $@"
1376 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1378 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) : | %(objdir)/include
1379 GLOB_MKDIRS += %(objdir)/include
1381 ## Generation of the funclist file
1383 %(mmake)-funclist : %(modname).funclist
1385 %rule_genmodule_funclist \
1386 modname=%(modname) modtype=%(modtype) modsuffix=%(modsuffix) \
1387 conffile=%(conffile) reffile=%(reffile)
1390 ## Extra genmodule src files generation
1392 %rule_genmodule_files modname=%(modname) modtype=%(modtype) \
1393 modsuffix=%(modsuffix) targetdir=%(objdir) \
1394 conffile=%(conffile) reffile=%(reffile)
1398 BD_FILES := %(files)
1399 BD_FDIRS := $(sort $(dir $(BD_FILES)))
1400 BD_STARTFILES := $(addprefix %(objdir)/,$(%(modname)_STARTFILES))
1401 BD_ENDFILES := $(addprefix %(objdir)/,$(%(modname)_ENDFILES))
1403 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1404 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1405 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1407 BD_CFLAGS := %(cflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1408 BD_DFLAGS := %(dflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1410 BD_LINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBFILES))
1411 BD_LINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBAFILES))
1412 ifeq ($(strip $(%(modname)_LINKLIBFILES) %(linklibfiles)),)
1415 BD_LINKLIB := %(prefix)/$(AROS_DIR_LIB)/lib%(linklibname).a
1417 BD_LINKLIBFILES := $(BD_LINKLIBCFILES) $(BD_LINKLIBAFILES)
1419 BD_CCFILES := $(BD_NARCHFILES) %(linklibfiles)
1420 BD_TARGETCCFILES := $(BD_STARTFILES) $(BD_ENDFILES) $(BD_LINKLIBCFILES)
1422 %rule_compile_multi \
1423 basenames=$(BD_CCFILES) targetdir=%(objdir) \
1424 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) \
1425 compiler=%(compiler)
1426 %rule_compile_multi \
1427 basenames=$(BD_TARGETCCFILES) targetdir=%(objdir) \
1428 cflags="$(BD_CFLAGS) -D__AROS__" dflags=$(BD_DFLAGS) \
1429 compiler=%(compiler)
1431 ifneq ($(BD_LINKLIBAFILES),)
1432 %rule_assemble_multi \
1433 basenames=$(BD_LINKLIBAFILES) targetdir=%(objdir) suffix=.S
1436 ## function reference files generation
1438 BD_CFLAGS_REF := -I$(dir $(GENMODULE))/genmod_inc -I%(objdir)/dummyinc $(strip %(cflags)) -I$(TOP)/$(CURDIR) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1440 basenames=$(BD_FILES) targetdir=%(objdir) \
1441 cflags=$(BD_CFLAGS_REF) \
1442 compiler=%(compiler)
1445 BD_REFS := $(addprefix %(objdir)/,$(addsuffix .ref, $(notdir $(BD_FILES))))
1447 BD_REFS := $(addprefix %(objdir)/,$(addsuffix .ref, $(notdir $(filter-out %(noref),$(BD_FILES)))))
1450 %rule_join from=$(BD_REFS) to=%(reffile) \
1451 text="Collecting function references for module %(modname)"
1456 ifeq (%(modsuffix),)
1457 BD_MODULE := %(prefix)/%(moduledir)/%(modname).%(modtype)
1458 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1460 BD_MODULE := %(prefix)/%(moduledir)/%(modname).%(modsuffix)
1461 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modsuffix).o
1464 %(mmake)-quick : %(mmake)
1465 %(mmake) : $(BD_MODULE) $(BD_LINKLIB)
1466 %(mmake)-kobj : $(BD_KOBJ) $(BD_LINKLIB)
1467 %(mmake)-linklib : $(BD_LINKLIB)
1469 BD_OBJS := $(addsuffix .o,$(BD_STARTFILES)) $(BD_ARCHOBJS) \
1470 $(addsuffix .o, $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES))))
1471 BD_ENDOBJS := $(addsuffix .o,$(BD_ENDFILES))
1472 BD_LINKLIBOBJS:= $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_LINKLIBFILES)) \
1475 # The module is linked from all the compiled .o files
1476 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1477 endobj=$(BD_ENDOBJS) err=%(modname).err objdir=%(objdir) \
1478 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1481 ifneq ($(BD_LINKLIB),)
1482 %rule_link_linklib libname=%(linklibname) objs=$(BD_LINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1484 $(BD_LINKLIB) : | %(prefix)/$(AROS_DIR_LIB)
1485 GLOB_MKDIRS += %(prefix)/$(AROS_DIR_LIB)
1488 # Link kernel object file
1489 BD_KAUTOLIB := workbench dos cybergraphics intuition layers graphics oop utility \
1491 BD_KBASE := WorkbenchBase DOSBase CyberGfxBase IntuitionBase LayersBase \
1492 GfxBase OOPBase UtilityBase ExpansionBase KeymapBase
1493 BD_KLIB := hiddgraphicsstubs hiddstubs amiga arossupport rom arosm autoinit libinit
1494 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1495 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1496 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_KBASE))
1497 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1498 @$(ECHO) "Linking $@"
1499 @$(AROS_LD) -Ur -o $@ $^ -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1500 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__$$/) || ($$3 ~ /^libraryset_.*$$/) {print "-L " $$3;}'`
1502 ## Dependency fine-tuning
1504 BD_DEPS := $(addsuffix .d,$(addprefix %(objdir)/,$(notdir $(BD_CCFILES) $(BD_TARGETCCFILES))))
1505 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1507 $(BD_OBJS) $(BD_DEPS) $(BD_REFS) : | %(objdir)
1508 $(BD_MODULE) : | %(prefix)/%(moduledir)
1509 $(BD_KOBJ) : | $(KOBJSDIR)
1510 GLOB_MKDIRS += %(objdir) %(prefix)/%(moduledir) $(KOBJSDIR)
1512 # Some include files need to be generated before the .c can be parsed.
1513 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj),) # Only for this target these deps are wanted
1514 BD_REFFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
1515 $(addprefix %(objdir)/dummyinc/,$(%(modname)_INCLUDES))
1516 $(BD_REFS) : $(BD_REFFILE_DEPS) $(dir $(GENMODULE))/genmod_inc/aros/libcall.h
1518 BD_DFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
1519 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES))
1520 $(BD_DEPS) : $(BD_DFILE_DEPS)
1523 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) %(reffile) \
1524 $(BD_REFS) $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
1525 %(objdir)/Makefile.%(modname) \
1526 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
1527 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1528 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1529 %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
1530 $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
1531 $(BD_DEFLIBDEFSINC) $(addsuffix .c,$(BD_STARTFILES) $(BD_ENDFILES)) \
1533 %(mmake)-clean : FILES := $(BD_TOCLEAN)
1535 @$(ECHO) "Cleaning up for module %(modname)"
1538 endif # $(TARGET) in $(BD_ALLTARGETS)
1540 #------------------------------------------------------------------------------
1543 #------------------------------------------------------------------------------
1545 # - mmake is the mmaketarget
1546 # - libname is the baselibname e.g. lib%(libname).a will be created
1547 # - files are the C source files to include in the lib. The list of files
1548 # has to be given without the .c suffix
1549 # - asmfiles are the asm files to include in the lib. The list of files has to
1550 # be given without the .s suffix
1551 # - objs additional object to link into the linklib. The objects have to be
1552 # given with full absolute path and the .o suffix.
1553 # - cflags are the flags to compile the source (default $(CFLAGS))
1554 # - dflags are the flags use during makedepend (default equal to cflags)
1555 # - aflags are the flags use during assembling (default $(AFLAGS))
1556 # - objdir is where the .o are generated
1557 # - libdir is the directory where the linklib will be placed (default $(LIBDIR))
1558 %define build_linklib mmake=/A libname=/A \
1559 files="$(basename $(call WILDCARD, *.c))" asmfiles= objs= \
1560 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) objdir=$(OBJDIR) libdir=$(LIBDIR)
1562 # assign and generate the local variables used in this macro
1563 OBJDIR ?= $(GENDIR)/$(CURDIR)
1565 BD_FILES := %(files)
1566 BD_ASMFILES := %(asmfiles)
1568 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1569 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1570 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1572 BD_OBJS := $(BD_ARCHOBJS) \
1573 $(addsuffix .o,$(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES) $(BD_ASMFILES)))) \
1575 BD_DEPS := $(patsubst %.o,%.d,$(BD_OBJS))
1577 BD_CFLAGS := %(cflags)
1579 BD_DFLAGS := $(BD_CFLAGS)
1581 BD_DFLAGS := %(dflags)
1583 BD_AFLAGS := %(aflags)
1585 BD_LINKLIB := %(libdir)/lib%(libname).a
1587 .PHONY : %(mmake) %(mmake)-clean
1589 #MM %(mmake) : includes-generate-deps
1590 %(mmake) : $(BD_LINKLIB)
1594 @$(RM) $(BD_OBJS) $(BD_DEPS)
1596 ifeq ($(TARGET),%(mmake))
1597 ifneq ($(dir $(BD_FILES)),./)
1598 vpath %.c $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir $(BD_FILES)))
1601 %rule_compile basename=% targetdir=%(objdir) \
1602 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1603 %rule_assemble basename=% targetdir=%(objdir) \
1607 %rule_link_linklib libname=%(libname) objs=$(BD_OBJS) libdir=%(libdir)
1609 %include_deps depstargets=%(mmake) deps=$(BD_DEPS)
1611 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1612 $(BD_LINKLIB) : | %(libdir)
1613 GLOB_MKDIRS += %(objdir) %(libdir)
1616 #------------------------------------------------------------------------------
1619 #------------------------------------------------------------------------------
1621 # - mmake is the mmaketarget
1622 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
1623 # - description is the catalog description file (.cd) (default *.cd)
1624 # - subdir is the destination subdir of the catalogs
1625 # - name is the name of the destination catalog, without the .catalog suffix
1626 # - source is the path to the generated source code file
1627 # - dir is the base destination directory (default $(AROS_CATALOGS))
1628 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
1630 %define build_catalogs mmake=/A name=/A subdir=/A \
1631 catalogs="$(basename $(call WILDCARD, *.ct))" source="../strings.h" \
1632 description="$(basename $(call WILDCARD, *.cd))" dir=$(AROS_CATALOGS) \
1633 sourcedescription="$(TOOLDIR)/C_h_orig"
1635 BD_SRCS := $(addsuffix .ct, %(catalogs))
1636 BD_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, %(catalogs)))
1637 BD_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, %(catalogs)))
1640 %(mmake) : $(BD_OBJS) %(source)
1642 $(BD_OBJS) : | $(BD_DIRS)
1643 GLOB_MKDIRS += $(BD_DIRS)
1645 %(dir)/%/%(subdir)/%(name).catalog : %.ct %(description).cd
1646 @$(ECHO) "Creating %(name) catalog for language $*."
1647 @$(FLEXCAT) $(SRCDIR)/$(CURDIR)/%(description).cd $< CATALOG=%(dir)/$*/%(subdir)/%(name).catalog || [ $$? -lt 10 ]
1650 %(source) : %(description).cd
1651 @$(ECHO) "Creating %(name) catalog source file %(source)"
1652 @$(FLEXCAT) $(SRCDIR)/$(CURDIR)/%(description).cd %(source)=%(sourcedescription).sd
1655 %(mmake)-clean : FILES := $(BD_OJS) %(source)
1660 .PHONY: %(mmake) %(mmake)-clean
1664 #-----------------------------------------------------------------------------
1666 #-----------------------------------------------------------------------------
1668 # - mmake is the mmaketarget
1669 # - icons is a list of icon base names (ie. without the .info suffix)
1670 # - dir is the destination directory
1671 #-----------------------------------------------------------------------------
1673 %define build_icons mmake=/A icons=/A dir=/A
1675 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
1678 %(mmake) : $(BD_OBJS)
1680 %(dir)/%.info : %.info.src %.png
1681 @$(ECHO) Creating $(notdir $@)...
1682 @$(ILBMTOICON) $+ $@
1684 $(BD_OBJS) : | %(dir)
1685 GLOB_MKDIRS += %(dir)
1687 %(mmake)-clean : FILES := $(BD_OBJS)
1692 .PHONY: %(mmake) %(mmake)-clean
1696 #-----------------------------------------------------------------------------
1698 #------------------------------------------------------------------------------
1699 # Compile files for an arch-specific replacement of code for a module
1700 # - files: the basenames of the C files to compile.
1701 # - asmfiles: the basenames of the asm files to assemble.
1702 # - mainmmake: the mmake of the module in the main directory to compile these
1703 # arch specific files for.
1704 # - maindir: the object directory for the main module
1705 # - arch: the arch for which to compile these files. It can have the form
1706 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
1707 # - cflags (default $(CFLAGS)): the C flags to use for compilation
1708 # - dflags: the flags used during creation of dependency file. If not specified
1709 # the same value as cflags will be used
1710 # - aflags: the flags used during assembling
1711 # - compiler: (host, kernel or target) specifies which compiler to use. By default
1712 # the target compiler is used
1713 %define build_archspecific files= asmfiles= mainmmake=/A maindir=/A arch=/A \
1714 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
1716 ifeq (%(files) %(asmfiles),)
1717 $(error no files or asmfiles given)
1720 %buildid targets="%(mainmmake)-%(arch)"
1722 ifeq ($(AROS_TARGET_VARIANT),)
1723 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1724 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1725 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1727 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1728 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1729 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1732 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
1735 $(error argument arch has to be non empty for the rule_compile_archspecific macro)
1738 BD_OBJDIR$(BDID) := $(GENDIR)/%(maindir)/arch
1739 BD_COBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1740 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
1741 BD_OBJS$(BDID) := $(BD_COBJS$(BDID)) $(BD_ASMOBJS$(BDID))
1742 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1744 ifeq ($(TARGET),%(mainmmake)-%(arch))
1745 vpath %.c $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir %(files)))
1746 vpath %.s $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
1747 vpath %.S $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
1750 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID))
1751 GLOB_MKDIRS += $(BD_OBJDIR$(BDID))
1754 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
1756 ifeq ($(findstring %(compiler),host kernel target),)
1757 $(error unknown compiler %(compiler))
1759 ifeq (%(compiler),target)
1760 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(TARGET_CC)
1761 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
1762 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
1764 ifeq (%(compiler),host)
1765 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(HOST_CC)
1766 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
1767 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
1769 ifeq (%(compiler),kernel)
1770 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
1771 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
1772 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
1774 ifneq (%(modulename),)
1775 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) \
1776 -include $(GENDIR)/%(maindir)/include/%(modulename)_deflibdefs.h
1778 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
1780 ifeq ($(TARGET),%(mainmmake)-%(arch))
1781 $(BD_OBJDIR$(BDID))/%.o : %.c
1782 %compile_q opt=$(TMP_CFLAGS) cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
1786 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags)
1788 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
1790 ifeq ($(TARGET),%(mainmmake)-%(arch))
1791 $(BD_OBJDIR$(BDID))/%.d : %.c
1792 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
1795 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
1797 ifeq ($(TARGET),%(mainmmake)-%(arch))
1798 $(BD_OBJDIR$(BDID))/%.o : %.s
1799 %assemble_q opt=$(AFLAGS)
1800 $(BD_OBJDIR$(BDID))/%.o : %.S
1801 %assemble_q opt=$(AFLAGS)
1804 %include_deps depstargets=%(mainmmake)-%(arch) deps=$(BD_DEPS$(BDID))
1806 #------------------------------------------------------------------------------
1814 # ======================
1815 # Old stuff, will probably be removed in the future
1820 # GNU Make automatic variables
1822 # $< First dependency
1823 # $? All newer dependencies
1824 # $^ All dependencies
1825 # $* The stem (ie. target is dir/a.foo.b and the pattern is
1826 # a.%.b, then the stem is dir/foo)
1828 #------------------------------------------------------------------------------
1829 # rule to generate libdefs.h with archtool (options may go away!)
1830 %define libdefs_rule conffile=lib.conf genlibdefstool=$(ARCHTOOL) dest=libdefs.h
1831 %(dest) : %(conffile) %(genlibdefstool)
1832 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
1833 @%(genlibdefstool) -c -o $@ %(conffile)
1837 #------------------------------------------------------------------------------
1838 # generate asm files from c files (for debugging purposes)
1841 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
1842 @$(TARGET_CC) -S $(CFLAGS) $< -c -o $@
1845 #------------------------------------------------------------------------------
1846 # Convert two png images to an Amiga icon file based on the description
1847 # file %(from), with outputfile going to %(to).
1848 %define makeicon2 from=$< to=$@ img1="$(basename $(basename $<))_N.png" img2="$(basename $(basename $<))_S.png"
1849 @$(ECHO) "Creating icon %(to)..."
1850 @$(PNGTOPNM) %(img1) | $(PPMTOILBM) -maxplanes 8 >$(GENDIR)/genicon1.iff
1851 @$(PNGTOPNM) %(img2) | $(PPMTOILBM) -maxplanes 8 >$(GENDIR)/genicon2.iff
1852 @$(ILBMTOICON) %(from) $(GENDIR)/genicon1.iff $(GENDIR)/genicon2.iff %(to)
1855 #------------------------------------------------------------------------------
1856 # NOTE: The following are all part of Iain's build changes, please don't use
1857 # or change anything below this line until you know what you are doing. This
1858 # is so that I don't conflict with the semantics of any of the above macros.
1859 #------------------------------------------------------------------------------
1861 #------------------------------------------------------------------------------
1862 # Copy files from one directory to another.
1864 %define copy_files_q files=$(FILES) src=. dst=/A maketarget=files-copy
1866 %(maketarget) : setup
1867 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,%(src)),%(src),$(SRCDIR)/$(CURDIR)/%(src))/, $(file)) $(addprefix %(dst)/, $(file))))
1874 #----------------------------------------------------------------------------------
1875 # Copy a diretory recursively to another place, preserving the original
1876 # hierarchical structure
1878 # src: the source directory whose content will be copied
1879 # dst: the directory where to copy src's content. If not existing, it will be made.
1881 %define copy_dir_recursive mmake=/A src=. dst=/A
1883 %(mmake)_FILES := $(shell cd $(if $(filter /%,%(src)),%(src),$(SRCDIR)/$(CURDIR)/%(src)); find . -path '*/CVS' -prune -o -path '*/.svn' -prune -o -name .cvsignore -prune -o -name mmakefile -prune -o -name mmakefile.src -prune -o -type f -print)
1884 %(mmake)_DIRS := $(sort $(dir $(%(mmake)_FILES)))
1886 define %(mmake)_mkdir
1891 define %(mmake)_copy
1892 $(3)/$(1): $(2)/$(1) | $(dir $(3)/$(1))
1899 %(mmake): | $(GENDIR)/$(CURDIR)
1900 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1901 $(ECHO) "all: $(addprefix \$$(DST)/,$(%(mmake)_FILES))" > $$m
1902 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1903 for d in $(%(mmake)_DIRS); do \
1904 $(ECHO) "\$$(DST)/$$d: ; $(MKDIR) \$$@" >> $$m; \
1906 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1907 for f in $(%(mmake)_FILES); do \
1908 $(ECHO) "\$$(DST)/$$f: \$$(SRC)/$$f | \$$(dir \$$(DST)/$$f); $(CP) \$$< \$$@" >> $$m; \
1910 for dst in %(dst); do \
1911 $(MAKE) -f $$m DST=$$dst SRC=$(if $(filter /%,%(src)),%(src),$(SRCDIR)/$(CURDIR)/%(src)) all; \
1914 $(GENDIR)/$(CURDIR):
1919 #------------------------------------------------------------------------------
1920 # Copy include files into the includes directories. There are currently
1921 # two include directories. One for building AROS $(AROS_INCLUDES) and one
1922 # for building tools that need to run on the host system $(GENINCDIR). The
1923 # $(GENINCDIR) path must not contain any references to the C runtime
1924 # library header files.
1926 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
1927 dir= compiler=target
1929 ifeq ($(findstring %(compiler),host kernel target),)
1930 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
1934 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),%(includes))
1935 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
1937 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
1938 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
1941 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
1945 ifeq (%(compiler),target)
1948 BD_INCL_FILES2 := $(subst %(dir),$(AROS_INCLUDES)/%(path),%(includes))
1950 BD_INCL_FILES2 := $(addprefix $(AROS_INCLUDES)/%(path)/,%(includes))
1953 BD_INCL_FILES += $(BD_INCL_FILES2)
1955 $(BD_INCL_FILES2) : $(AROS_INCLUDES)/%(path)/% : $(BD_INC_PATH)%
1960 %(mmake) : $(BD_INCL_FILES)
1964 $(BD_INCL_FILES) : | $(dir $(BD_INCL_FILES))
1965 GLOB_MKDIRS += $(dir $(BD_INCL_FILES))
1969 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
1970 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
1971 STUBS_MEM := $(addsuffix .o,$(STUBS))
1972 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
1973 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
1974 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
1976 #MM- linklibs : hidd-%(hidd)-stubs
1977 #MM- %(parenttarget): hidd-%(hidd)-stubs
1978 #MM hidd-%(hidd)-stubs : includes includes-copy
1979 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
1981 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
1984 $(STUBS_OBJ) : $(STUBS_SRC)
1985 %compile_q cmd=$(TARGET_CC) opt=%(cflags) iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
1987 $(STUBS_DEP) : $(STUBS_SRC)
1988 %mkdepend_q flags=%(dflags)
1991 %mkdirs_q $(OBJDIR) $(LIBDIR)
1995 -@$(RM) $(HIDD_LIB) $(OBJDIR)
1997 DEPS := $(DEPS) $(STUBS_DEP)
2001 #------------------------------------------------------------------------------
2002 # Build an imported source tree which uses the configure script from the
2003 # autoconf package. This rule will try to "integrate" the produced files as
2004 # much as possible in the AROS build, for example by putting libraries in the
2005 # standard library directory, includes in the standard include directory, and
2006 # so on. You can however override this behaviour.
2008 # As a special "bonus" for you, the PROGDIR environment variable is defined to
2009 # be %(bindir) (or its deduced value) when running "make install", and
2010 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
2011 # configure script some more parameters whose value depends upon the PROGDIR
2012 # env var, so that the program gets all its stuff installed in the proper place
2013 # when building it, but when running it from inside AROS it can also find that
2014 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
2015 # the configuration parameters set when running ./configure
2017 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
2018 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
2019 # to the name which has to follow it.
2022 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) prefix= \
2023 aros_prefix= extraoptions= nix_dir_layout= nix=no compiler=target \
2024 install_target=install postconfigure= postinstall= \
2028 %(mmake)-prefix := %(prefix)
2030 %(mmake)-prefix := $(AROS_CONTRIB)
2033 ifneq (%(aros_prefix),)
2034 %(mmake)-aros_prefix := %(aros_prefix)
2036 %(mmake)-aros_prefix := $(%(mmake)-prefix)
2040 %(mmake)-nix := -nix
2041 %(mmake)-volpfx := /
2042 %(mmake)-volsfx := /
2044 ifeq (%(nix_dir_layout),)
2045 %(mmake)-nix_dir_layout := yes
2048 %(mmake)-volsfx := :
2050 ifeq (%(nix_dir_layout),)
2051 %(mmake)-nix_dir_layout := no
2055 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
2057 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
2058 exec_prefix=$(%(mmake)-prefix) %(install_env)
2060 # Check if chosen compiler is valid
2061 ifeq ($(findstring %(compiler),host target kernel),)
2062 $(error unknown compiler %(compiler))
2065 # Set legacy 'host' variable based on chosen compiler
2066 ifeq (%(compiler),host)
2069 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
2071 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
2076 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
2078 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
2082 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
2083 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
2085 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
2086 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
2087 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2090 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
2091 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
2093 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2096 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
2098 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
2099 sbindir=$(%(mmake)-prefix) \
2100 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
2101 oldincludedir=$(AROS_INCLUDES) %(install_env)
2105 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
2107 #MM- %(mmake) : setup includes linklibs-core %(mmake)-quick
2109 # Using -j1 in install_command may result in a warning but finally
2110 # it does its job. make install for gcc does not work reliable for -jN
2112 ifneq (%(install_target),)
2113 %(mmake)-install_command = \
2114 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2115 -C $(%(mmake)-pkgdir) %(install_target) -j1 && \
2116 $(TOUCH) $(%(mmake)-installflag)
2118 %(mmake)-uninstall_command = \
2119 $(RM) $(%(mmake)-installflag) && \
2120 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2121 -C $(%(mmake)-pkgdir) uninstall
2123 %(mmake)-install_command := true
2124 %(mmake)-uninstall_command := true
2127 #MM- %(mmake)-quick : %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
2130 %(mmake)-build_and_install-quick : $(%(mmake)-configflag)
2131 if ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q -C $(%(mmake)-pkgdir); then \
2132 $(RM) $(%(mmake)-installflag) && \
2133 $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -C $(%(mmake)-pkgdir) && \
2134 $(%(mmake)-install_command); \
2137 %(srcdir)/.files-touched:
2138 find %(srcdir) -exec $(TOUCH) -r %(srcdir)/configure '{}' \; && \
2142 %(mmake)-uninstall :
2143 $(%(mmake)-uninstall_command)
2145 ifneq ($(DEBUG),yes)
2146 %(mmake)-s_flag = -s
2150 %(mmake)-configure : $(%(mmake)-configflag)
2152 ifeq (%(compiler),host)
2153 $(%(mmake)-configflag) : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2155 %mkdirs_q $(%(mmake)-pkgdir)
2156 cd $(%(mmake)-pkgdir) && \
2157 find . -name config.cache -exec $(RM) '{}' \; && \
2159 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) && \
2162 ifeq (%(compiler),target)
2163 $(%(mmake)-configflag) : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2165 %mkdirs_q $(%(mmake)-pkgdir)
2166 cd $(%(mmake)-pkgdir) && \
2167 find . -name config.cache -exec $(RM) '{}' \; && \
2168 CC="$(TARGET_CC) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2169 AS="$(TARGET_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)" \
2170 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) \
2171 --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH) \
2172 --host=$(AROS_TARGET_CPU)-aros \
2173 --target=$(AROS_TARGET_CPU)-aros \
2175 --without-x --without-pic --disable-shared && \
2178 ifeq (%(compiler),kernel)
2179 $(%(mmake)-configflag) : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2181 %mkdirs_q $(%(mmake)-pkgdir)
2182 cd $(%(mmake)-pkgdir) && \
2183 find . -name config.cache -exec $(RM) '{}' \; && \
2184 CC="$(KERNEL_CC) $(KERNEL_CFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2185 AS="$(TARGET_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)" \
2186 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) \
2187 --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH) \
2188 --host=$(AROS_TARGET_CPU)-aros \
2189 --target=$(AROS_TARGET_CPU)-aros --disable-nls \
2190 --without-x --without-pic --disable-shared && \
2195 %(mmake)-clean : %(mmake)-uninstall
2196 @$(RM) $(%(mmake)-pkgdir)
2199 #############################################################################
2200 #############################################################################
2202 ## Miscellaneous macros. Everything that doesn't fit above should be put ##
2205 #############################################################################
2206 #############################################################################
2208 #----------------------------------------------------------------------------------
2209 # Given an archive name, patches names and locations where to find them, fetch
2210 # the archive and the patches from any of those locations, unpack the archive
2211 # and then apply the patches.
2213 # Locations currently supported are http and ftp sites, plus local filesystem
2214 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
2215 # the fetch.sh script needs to be modified, since this macro relies on that script.
2219 # - archive_origins = list of locations where to find the archive. They are tried
2220 # in sequence, until the archive is found and fetching it
2221 # succeeded. If not specified, the current directory is assumed.
2222 # - archive = the archive name. Mandatory.
2223 # - suffixes = a list of suffixes to append to the the package name plus the
2224 # version. Each one of them is tried until a matching archive is
2225 # found. They are appended to patches and these are tried the
2226 # same way as packages are.
2227 # - destination = the local directory where to put the archive and patches.
2228 # If not specified, the current directory is assumed.
2229 # - patches_origins = list of locations where to find the patches. They are tried
2230 # in sequence, until a patch is found and fetching it
2231 # succeeded. If not specified, the current directory is assumed.
2232 # - patches_specs = list of "patch specs". A patch spec is of the form
2233 # patch_name[:[patch_subdir][:patch_opt]].
2235 # - patch_name = the name of the patch file
2236 # - patch_subdir = the directory within \destination\ where to
2238 # - patch_opt = any options to pass to the `patch' command
2239 # when applying the patch.
2241 # The patch_subdir and patch_opt fields are optional.
2243 %define fetch archive_origins=. archive=/A suffixes= location=%destination destination=. patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
2244 $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l %(location) -d %(destination) \
2245 -po "%(patches_origins)" -p %(patches_specs)
2248 #-----------------------------------------------------------------------------------------
2249 # Joins the features of %fetch and %build_with_configure, taking advantage of
2250 # the naming scheme of GNU packages. GNU packages names are in the form
2252 # <package name>-<version number>.<archive format suffix>
2254 # If a patch is provided, it *must* be named the following way:
2256 # <package name>-<version number>-aros.diff
2258 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
2259 # CD'ing into the archive's extracted directory.
2261 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
2262 # the %fetch_and_build macro only accept *one* patch for each package. It's up to you
2263 # to make that patch fully comprehensive.
2265 # NOTE: GNU packages are always compiled with *nix semantics turned on.
2269 # - mmake = the meta make target, as would be supplied to the %build_with_configure
2271 # - package = the GNU package name, sans version and archive format suffixes.
2272 # - version = the package's version number, or otherwise any other version string.
2273 # It gets appended to the package name to form the basename of the archive.
2274 # - suffixes = a list of suffixes to apped to the the package name plus the
2275 # version. Each one of them is tried until a matching archive is found.
2276 # Defaults to "tar.bz2 tar.gz".
2277 # - destination = same meaning as the one for the %fetch macro
2278 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
2279 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
2281 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
2282 # - prefix = same meaning as the one for the %build_with_configure macro. Defaults to
2284 # - aros_prefix = same meaning as the one for the %build_with_configure macro. Defaults to
2286 # - extraoptions = same meaning as the one for the %build_with_configure macro.
2287 # - postinstall = same meaning as the one for the %build_with_configure macro.
2289 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target version=/A suffixes="tar.bz2 tar.gz" \
2290 srcdir= package_repo= patch=no patch_repo= prefix= \
2291 aros_prefix= extraoptions= postconfigure= postinstall= nix=no nix_dir_layout=
2293 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
2294 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
2295 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
2297 %(mmake)-archbase := %(package)-%(version)
2299 ifeq (%(compiler),host)
2300 %(mmake)-portdir := $(HOSTDIR)/Ports/%(package)
2302 %(mmake)-portdir := $(PORTSDIR)/%(package)
2306 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
2308 %(mmake)-prefix := %(prefix)
2311 ifneq (%(subpackage),)
2312 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
2314 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
2318 %(mmake)-%(subpackage)-srcdir := %(srcdir)
2320 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
2324 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-p1
2326 %(mmake)-%(subpackage)-patches_specs := ::
2329 .PHONY : %(mmake)-%(subpackage)-fetch
2331 %(mmake)-%(subpackage)-fetch :
2332 %fetch archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
2333 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
2334 archive_origins=". %(package_repo)" \
2335 patches_specs="$(%(mmake)-%(subpackage)-patches_specs)" patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
2337 #MM- %(mmake) : %(mmake)-%(subpackage)
2339 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
2341 %(mmake)-%(subpackage)-package-basename := \
2342 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
2344 %build_with_configure mmake=%(mmake)-%(subpackage) package=%(package) compiler=%(compiler) \
2345 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-srcdir) \
2346 nix=%(nix) nix_dir_layout=%(nix_dir_layout) prefix="$(%(mmake)-prefix)" \
2347 aros_prefix="%(aros_prefix)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
2348 %(mmake)-%(subpackage)-make-package" extraoptions="%(extraoptions)"
2350 .PHONY : %(mmake)-%(subpackage)-make-package
2351 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
2354 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package-basename).tar.bz2
2356 #There seems to be a bug, either with my clock or with make, 'cause it may happen
2357 #that $^ and $@ have exactly the same mtime, and in that case make tries
2358 #to rebuild $@ again, which would fail because the directory where
2359 #the package got installed would not exist anymore.
2360 #We work this around by using an if statement to manually check the mtimes.
2361 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
2362 @$(IF) test $(%(mmake)-installflag) -nt $@ || ! test -f $@; then \
2364 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
2365 mkdir -p "$(DISTDIR)/Packages" ; \
2366 mkdir -p "$(%(mmake)-prefix)" ; \
2367 cd $(%(mmake)-%(subpackage)-package-dir) ; \
2368 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
2369 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
2373 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2374 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
2375 aros_prefix=/GNU extraoptions= postconfigure= postinstall=
2377 GNU_REPOSITORY := gnu://
2379 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
2380 suffixes="%(suffixes)" srcdir="%(srcdir)" \
2381 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
2382 patch="%(patch)" patch_repo="%(patch_repo)" \
2383 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" \
2384 postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=yes
2388 #-----------------------------------------------------------------------------------------
2389 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
2390 # that the package is a "Development" package, and as such it needs to be placed
2391 # under the $(AROS_DEVELOPMENT) directory, as a default.
2393 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
2394 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
2395 # "mmake" argument, because the metatarget is implicitely defined as
2397 # #MM- development-%(package)
2399 %define fetch_and_build_gnu_development package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2400 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPMENT) \
2401 aros_prefix=/Development postconfigure= postinstall= extraoptions=
2403 #MM- development : development-%(package)
2406 %fetch_and_build_gnu mmake=development-%(package) package=%(package) subpackage="%(subpackage)" \
2407 version=%(version) suffixes="%(suffixes)" srcdir="%(srcdir)" \
2408 package_repo="%(package_repo)" patch="%(patch)" patch_repo="%(patch_repo)" prefix=%(prefix) \
2409 aros_prefix="%(aros_prefix)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" \
2410 extraoptions="%(extraoptions)"