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 .o,%(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 TMP_IQUOTE := $(CFLAGS_IQUOTE)
1408 TMP_IQUOTE_END := $(CFLAGS_IQUOTE_END)
1409 ifeq (%(compiler),host)
1410 TMP_IQUOTE := $(HOST_IQUOTE)
1411 TMP_IQUOTE_END := $(HOST_IQUOTE_END)
1413 ifeq (%(compiler),kernel)
1414 TMP_IQUOTE := $(KERNEL_IQUOTE)
1415 TMP_IQUOTE_END := $(KERNEL_IQUOTE_END)
1418 TMP_QUOTE := $(TMP_IQUOTE) $(TOP)/$(CURDIR) \
1419 $(addprefix $(TMP_IQUOTE),$(BD_FDIRS)) \
1421 BD_CFLAGS := $(TMP_QUOTE) %(cflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1422 BD_DFLAGS := $(TMP_QUOTE) %(dflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1424 BD_LINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBFILES))
1425 BD_LINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBAFILES))
1426 ifeq ($(strip $(%(modname)_LINKLIBFILES) %(linklibfiles)),)
1429 BD_LINKLIB := %(prefix)/$(AROS_DIR_LIB)/lib%(linklibname).a
1431 BD_LINKLIBFILES := $(BD_LINKLIBCFILES) $(BD_LINKLIBAFILES)
1433 BD_CCFILES := $(BD_NARCHFILES) %(linklibfiles)
1434 BD_TARGETCCFILES := $(BD_STARTFILES) $(BD_ENDFILES) $(BD_LINKLIBCFILES)
1436 %rule_compile_multi \
1437 basenames=$(BD_CCFILES) targetdir=%(objdir) \
1438 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) \
1439 compiler=%(compiler)
1440 %rule_compile_multi \
1441 basenames=$(BD_TARGETCCFILES) targetdir=%(objdir) \
1442 cflags="$(BD_CFLAGS) -D__AROS__" dflags=$(BD_DFLAGS) \
1443 compiler=%(compiler)
1445 ifneq ($(BD_LINKLIBAFILES),)
1446 %rule_assemble_multi \
1447 basenames=$(BD_LINKLIBAFILES) targetdir=%(objdir) suffix=.S
1450 ## function reference files generation
1452 BD_CFLAGS_REF := -I$(dir $(GENMODULE))/genmod_inc -I%(objdir)/dummyinc $(strip %(cflags)) -I$(TOP)/$(CURDIR) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1454 basenames=$(BD_FILES) targetdir=%(objdir) \
1455 cflags=$(BD_CFLAGS_REF) \
1456 compiler=%(compiler)
1459 BD_REFS := $(addprefix %(objdir)/,$(addsuffix .ref, $(notdir $(BD_FILES))))
1461 BD_REFS := $(addprefix %(objdir)/,$(addsuffix .ref, $(notdir $(filter-out %(noref),$(BD_FILES)))))
1464 %rule_join from=$(BD_REFS) to=%(reffile) \
1465 text="Collecting function references for module %(modname)"
1470 ifeq (%(modsuffix),)
1471 BD_MODULE := %(prefix)/%(moduledir)/%(modname).%(modtype)
1472 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1474 BD_MODULE := %(prefix)/%(moduledir)/%(modname).%(modsuffix)
1475 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modsuffix).o
1478 %(mmake)-quick : %(mmake)
1479 %(mmake) : $(BD_MODULE) $(BD_LINKLIB)
1480 %(mmake)-kobj : $(BD_KOBJ) $(BD_LINKLIB)
1481 %(mmake)-linklib : $(BD_LINKLIB)
1483 BD_OBJS := $(addsuffix .o,$(BD_STARTFILES)) $(BD_ARCHOBJS) \
1484 $(addsuffix .o, $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES))))
1485 BD_ENDOBJS := $(addsuffix .o,$(BD_ENDFILES))
1486 BD_LINKLIBOBJS:= $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_LINKLIBFILES)) \
1489 # The module is linked from all the compiled .o files
1490 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1491 endobj=$(BD_ENDOBJS) err=%(modname).err objdir=%(objdir) \
1492 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1495 ifneq ($(BD_LINKLIB),)
1496 %rule_link_linklib libname=%(linklibname) objs=$(BD_LINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1498 $(BD_LINKLIB) : | %(prefix)/$(AROS_DIR_LIB)
1499 GLOB_MKDIRS += %(prefix)/$(AROS_DIR_LIB)
1502 # Link kernel object file
1503 BD_KAUTOLIB := workbench dos cybergraphics intuition layers graphics oop utility \
1505 BD_KBASE := WorkbenchBase DOSBase CyberGfxBase IntuitionBase LayersBase \
1506 GfxBase OOPBase UtilityBase ExpansionBase KeymapBase
1507 BD_KLIB := hiddgraphicsstubs hiddstubs amiga arossupport rom arosm autoinit libinit
1508 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1509 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1510 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_KBASE))
1511 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1512 @$(ECHO) "Linking $@"
1513 @$(AROS_LD) -Ur -o $@ $^ -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1514 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__$$/) || ($$3 ~ /^libraryset_.*$$/) {print "-L " $$3;}'`
1516 ## Dependency fine-tuning
1518 BD_DEPS := $(addsuffix .d,$(addprefix %(objdir)/,$(notdir $(BD_CCFILES) $(BD_TARGETCCFILES))))
1519 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1521 $(BD_OBJS) $(BD_DEPS) $(BD_REFS) : | %(objdir)
1522 $(BD_MODULE) : | %(prefix)/%(moduledir)
1523 $(BD_KOBJ) : | $(KOBJSDIR)
1524 GLOB_MKDIRS += %(objdir) %(prefix)/%(moduledir) $(KOBJSDIR)
1526 # Some include files need to be generated before the .c can be parsed.
1527 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj),) # Only for this target these deps are wanted
1528 BD_REFFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
1529 $(addprefix %(objdir)/dummyinc/,$(%(modname)_INCLUDES))
1530 $(BD_REFS) : $(BD_REFFILE_DEPS) $(dir $(GENMODULE))/genmod_inc/aros/libcall.h
1532 BD_DFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
1533 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES))
1534 $(BD_DEPS) : $(BD_DFILE_DEPS)
1537 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) %(reffile) \
1538 $(BD_REFS) $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
1539 %(objdir)/Makefile.%(modname) \
1540 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
1541 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1542 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1543 %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
1544 $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
1545 $(BD_DEFLIBDEFSINC) $(addsuffix .c,$(BD_STARTFILES) $(BD_ENDFILES)) \
1547 %(mmake)-clean : FILES := $(BD_TOCLEAN)
1549 @$(ECHO) "Cleaning up for module %(modname)"
1552 endif # $(TARGET) in $(BD_ALLTARGETS)
1554 #------------------------------------------------------------------------------
1557 #------------------------------------------------------------------------------
1559 # - mmake is the mmaketarget
1560 # - libname is the baselibname e.g. lib%(libname).a will be created
1561 # - files are the C source files to include in the lib. The list of files
1562 # has to be given without the .c suffix
1563 # - asmfiles are the asm files to include in the lib. The list of files has to
1564 # be given without the .s suffix
1565 # - objs additional object to link into the linklib. The objects have to be
1566 # given with full absolute path and the .o suffix.
1567 # - cflags are the flags to compile the source (default $(CFLAGS))
1568 # - dflags are the flags use during makedepend (default equal to cflags)
1569 # - aflags are the flags use during assembling (default $(AFLAGS))
1570 # - objdir is where the .o are generated
1571 # - libdir is the directory where the linklib will be placed (default $(LIBDIR))
1572 %define build_linklib mmake=/A libname=/A \
1573 files="$(basename $(call WILDCARD, *.c))" asmfiles= objs= \
1574 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) objdir=$(OBJDIR) libdir=$(LIBDIR)
1576 # assign and generate the local variables used in this macro
1577 OBJDIR ?= $(GENDIR)/$(CURDIR)
1579 BD_FILES := %(files)
1580 BD_ASMFILES := %(asmfiles)
1582 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1583 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1584 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1586 BD_OBJS := $(BD_ARCHOBJS) \
1587 $(addsuffix .o,$(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES) $(BD_ASMFILES)))) \
1589 BD_DEPS := $(patsubst %.o,%.d,$(BD_OBJS))
1591 BD_CFLAGS := %(cflags)
1593 BD_DFLAGS := $(BD_CFLAGS)
1595 BD_DFLAGS := %(dflags)
1597 BD_AFLAGS := %(aflags)
1599 BD_LINKLIB := %(libdir)/lib%(libname).a
1601 .PHONY : %(mmake) %(mmake)-clean
1603 #MM %(mmake) : includes-generate-deps
1604 %(mmake) : $(BD_LINKLIB)
1608 @$(RM) $(BD_OBJS) $(BD_DEPS)
1610 ifeq ($(TARGET),%(mmake))
1611 ifneq ($(dir $(BD_FILES)),./)
1612 vpath %.c $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir $(BD_FILES)))
1615 %rule_compile basename=% targetdir=%(objdir) \
1616 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1617 %rule_assemble basename=% targetdir=%(objdir) \
1621 %rule_link_linklib libname=%(libname) objs=$(BD_OBJS) libdir=%(libdir)
1623 %include_deps depstargets=%(mmake) deps=$(BD_DEPS)
1625 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1626 $(BD_LINKLIB) : | %(libdir)
1627 GLOB_MKDIRS += %(objdir) %(libdir)
1630 #------------------------------------------------------------------------------
1633 #------------------------------------------------------------------------------
1635 # - mmake is the mmaketarget
1636 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
1637 # - description is the catalog description file (.cd) (default *.cd)
1638 # - subdir is the destination subdir of the catalogs
1639 # - name is the name of the destination catalog, without the .catalog suffix
1640 # - source is the path to the generated source code file
1641 # - dir is the base destination directory (default $(AROS_CATALOGS))
1642 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
1644 %define build_catalogs mmake=/A name=/A subdir=/A \
1645 catalogs="$(basename $(call WILDCARD, *.ct))" source="../strings.h" \
1646 description="$(basename $(call WILDCARD, *.cd))" dir=$(AROS_CATALOGS) \
1647 sourcedescription="$(TOOLDIR)/C_h_orig"
1649 BD_SRCS := $(addsuffix .ct, %(catalogs))
1650 BD_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, %(catalogs)))
1651 BD_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, %(catalogs)))
1654 %(mmake) : $(BD_OBJS) %(source)
1656 $(BD_OBJS) : | $(BD_DIRS)
1657 GLOB_MKDIRS += $(BD_DIRS)
1659 %(dir)/%/%(subdir)/%(name).catalog : %.ct %(description).cd
1660 @$(ECHO) "Creating %(name) catalog for language $*."
1661 @$(FLEXCAT) $(SRCDIR)/$(CURDIR)/%(description).cd $< CATALOG=%(dir)/$*/%(subdir)/%(name).catalog || [ $$? -lt 10 ]
1664 %(source) : %(description).cd
1665 @$(ECHO) "Creating %(name) catalog source file %(source)"
1666 @$(FLEXCAT) $(SRCDIR)/$(CURDIR)/%(description).cd %(source)=%(sourcedescription).sd
1669 %(mmake)-clean : FILES := $(BD_OJS) %(source)
1674 .PHONY: %(mmake) %(mmake)-clean
1678 #-----------------------------------------------------------------------------
1680 #-----------------------------------------------------------------------------
1682 # - mmake is the mmaketarget
1683 # - icons is a list of icon base names (ie. without the .info suffix)
1684 # - dir is the destination directory
1685 #-----------------------------------------------------------------------------
1687 %define build_icons mmake=/A icons=/A dir=/A
1689 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
1692 %(mmake) : $(BD_OBJS)
1694 %(dir)/%.info : %.info.src %.png
1695 @$(ECHO) Creating $(notdir $@)...
1696 @$(ILBMTOICON) $+ $@
1698 $(BD_OBJS) : | %(dir)
1699 GLOB_MKDIRS += %(dir)
1701 %(mmake)-clean : FILES := $(BD_OBJS)
1706 .PHONY: %(mmake) %(mmake)-clean
1710 #-----------------------------------------------------------------------------
1712 #------------------------------------------------------------------------------
1713 # Compile files for an arch-specific replacement of code for a module
1714 # - files: the basenames of the C files to compile.
1715 # - asmfiles: the basenames of the asm files to assemble.
1716 # - mainmmake: the mmake of the module in the main directory to compile these
1717 # arch specific files for.
1718 # - maindir: the object directory for the main module
1719 # - arch: the arch for which to compile these files. It can have the form
1720 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
1721 # - cflags (default $(CFLAGS)): the C flags to use for compilation
1722 # - dflags: the flags used during creation of dependency file. If not specified
1723 # the same value as cflags will be used
1724 # - aflags: the flags used during assembling
1725 # - compiler: (host, kernel or target) specifies which compiler to use. By default
1726 # the target compiler is used
1727 %define build_archspecific files= asmfiles= mainmmake=/A maindir=/A arch=/A \
1728 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
1730 ifeq (%(files) %(asmfiles),)
1731 $(error no files or asmfiles given)
1734 %buildid targets="%(mainmmake)-%(arch)"
1736 ifeq ($(AROS_TARGET_VARIANT),)
1737 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1738 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1739 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1741 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1742 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1743 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) %(mainmmake)-$(ARCH) %(mainmmake)-$(CPU)
1746 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
1749 $(error argument arch has to be non empty for the rule_compile_archspecific macro)
1752 BD_OBJDIR$(BDID) := $(GENDIR)/%(maindir)/arch
1753 BD_COBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1754 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
1755 BD_OBJS$(BDID) := $(BD_COBJS$(BDID)) $(BD_ASMOBJS$(BDID))
1756 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1758 ifeq ($(TARGET),%(mainmmake)-%(arch))
1759 vpath %.c $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir %(files)))
1760 vpath %.s $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
1761 vpath %.S $(addprefix $(SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
1764 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID))
1765 GLOB_MKDIRS += $(BD_OBJDIR$(BDID))
1768 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
1770 ifeq ($(findstring %(compiler),host kernel target),)
1771 $(error unknown compiler %(compiler))
1773 ifeq (%(compiler),target)
1774 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(TARGET_CC)
1775 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
1776 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
1778 ifeq (%(compiler),host)
1779 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(HOST_CC)
1780 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
1781 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
1783 ifeq (%(compiler),kernel)
1784 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
1785 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
1786 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
1788 ifneq (%(modulename),)
1789 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) \
1790 -include $(GENDIR)/%(maindir)/include/%(modulename)_deflibdefs.h
1792 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
1794 ifeq ($(TARGET),%(mainmmake)-%(arch))
1795 $(BD_OBJDIR$(BDID))/%.o : %.c
1796 %compile_q opt=$(TMP_CFLAGS) cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
1800 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags)
1802 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
1804 ifeq ($(TARGET),%(mainmmake)-%(arch))
1805 $(BD_OBJDIR$(BDID))/%.d : %.c
1806 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
1809 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
1811 ifeq ($(TARGET),%(mainmmake)-%(arch))
1812 $(BD_OBJDIR$(BDID))/%.o : %.s
1813 %assemble_q opt=$(AFLAGS)
1814 $(BD_OBJDIR$(BDID))/%.o : %.S
1815 %assemble_q opt=$(AFLAGS)
1818 %include_deps depstargets=%(mainmmake)-%(arch) deps=$(BD_DEPS$(BDID))
1820 #------------------------------------------------------------------------------
1828 # ======================
1829 # Old stuff, will probably be removed in the future
1834 # GNU Make automatic variables
1836 # $< First dependency
1837 # $? All newer dependencies
1838 # $^ All dependencies
1839 # $* The stem (ie. target is dir/a.foo.b and the pattern is
1840 # a.%.b, then the stem is dir/foo)
1842 #------------------------------------------------------------------------------
1843 # rule to generate libdefs.h with archtool (options may go away!)
1844 %define libdefs_rule conffile=lib.conf genlibdefstool=$(ARCHTOOL) dest=libdefs.h
1845 %(dest) : %(conffile) %(genlibdefstool)
1846 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
1847 @%(genlibdefstool) -c -o $@ %(conffile)
1851 #------------------------------------------------------------------------------
1852 # generate asm files from c files (for debugging purposes)
1855 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
1856 @$(TARGET_CC) -S $(CFLAGS) $< -c -o $@
1859 #------------------------------------------------------------------------------
1860 # Convert two png images to an Amiga icon file based on the description
1861 # file %(from), with outputfile going to %(to).
1862 %define makeicon2 from=$< to=$@ img1="$(basename $(basename $<))_N.png" img2="$(basename $(basename $<))_S.png"
1863 @$(ECHO) "Creating icon %(to)..."
1864 @$(PNGTOPNM) %(img1) | $(PPMTOILBM) -maxplanes 8 >$(GENDIR)/genicon1.iff
1865 @$(PNGTOPNM) %(img2) | $(PPMTOILBM) -maxplanes 8 >$(GENDIR)/genicon2.iff
1866 @$(ILBMTOICON) %(from) $(GENDIR)/genicon1.iff $(GENDIR)/genicon2.iff %(to)
1869 #------------------------------------------------------------------------------
1870 # NOTE: The following are all part of Iain's build changes, please don't use
1871 # or change anything below this line until you know what you are doing. This
1872 # is so that I don't conflict with the semantics of any of the above macros.
1873 #------------------------------------------------------------------------------
1875 #------------------------------------------------------------------------------
1876 # Copy files from one directory to another.
1878 %define copy_files_q files=$(FILES) src=. dst=/A maketarget=files-copy
1880 %(maketarget) : setup
1881 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,%(src)),%(src),$(SRCDIR)/$(CURDIR)/%(src))/, $(file)) $(addprefix %(dst)/, $(file))))
1888 #----------------------------------------------------------------------------------
1889 # Copy a diretory recursively to another place, preserving the original
1890 # hierarchical structure
1892 # src: the source directory whose content will be copied
1893 # dst: the directory where to copy src's content. If not existing, it will be made.
1895 %define copy_dir_recursive mmake=/A src=. dst=/A
1897 %(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)
1898 %(mmake)_DIRS := $(sort $(dir $(%(mmake)_FILES)))
1900 define %(mmake)_mkdir
1905 define %(mmake)_copy
1906 $(3)/$(1): $(2)/$(1) | $(dir $(3)/$(1))
1913 %(mmake): | $(GENDIR)/$(CURDIR)
1914 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1915 $(ECHO) "all: $(addprefix \$$(DST)/,$(%(mmake)_FILES))" > $$m
1916 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1917 for d in $(%(mmake)_DIRS); do \
1918 $(ECHO) "\$$(DST)/$$d: ; $(MKDIR) \$$@" >> $$m; \
1920 @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak"; \
1921 for f in $(%(mmake)_FILES); do \
1922 $(ECHO) "\$$(DST)/$$f: \$$(SRC)/$$f | \$$(dir \$$(DST)/$$f); $(CP) \$$< \$$@" >> $$m; \
1924 for dst in %(dst); do \
1925 $(MAKE) -f $$m DST=$$dst SRC=$(if $(filter /%,%(src)),%(src),$(SRCDIR)/$(CURDIR)/%(src)) all; \
1928 $(GENDIR)/$(CURDIR):
1933 #------------------------------------------------------------------------------
1934 # Copy include files into the includes directories. There are currently
1935 # two include directories. One for building AROS $(AROS_INCLUDES) and one
1936 # for building tools that need to run on the host system $(GENINCDIR). The
1937 # $(GENINCDIR) path must not contain any references to the C runtime
1938 # library header files.
1940 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
1941 dir= compiler=target
1943 ifeq ($(findstring %(compiler),host kernel target),)
1944 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
1948 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),%(includes))
1949 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
1951 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
1952 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
1955 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
1959 ifeq (%(compiler),target)
1962 BD_INCL_FILES2 := $(subst %(dir),$(AROS_INCLUDES)/%(path),%(includes))
1964 BD_INCL_FILES2 := $(addprefix $(AROS_INCLUDES)/%(path)/,%(includes))
1967 BD_INCL_FILES += $(BD_INCL_FILES2)
1969 $(BD_INCL_FILES2) : $(AROS_INCLUDES)/%(path)/% : $(BD_INC_PATH)%
1974 %(mmake) : $(BD_INCL_FILES)
1978 $(BD_INCL_FILES) : | $(dir $(BD_INCL_FILES))
1979 GLOB_MKDIRS += $(dir $(BD_INCL_FILES))
1983 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
1984 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
1985 STUBS_MEM := $(addsuffix .o,$(STUBS))
1986 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
1987 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
1988 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
1990 #MM- linklibs : hidd-%(hidd)-stubs
1991 #MM- %(parenttarget): hidd-%(hidd)-stubs
1992 #MM hidd-%(hidd)-stubs : includes includes-copy
1993 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
1995 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
1998 $(STUBS_OBJ) : $(STUBS_SRC)
1999 %compile_q cmd=$(TARGET_CC) opt=%(cflags) iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
2001 $(STUBS_DEP) : $(STUBS_SRC)
2002 %mkdepend_q flags=%(dflags)
2005 %mkdirs_q $(OBJDIR) $(LIBDIR)
2009 -@$(RM) $(HIDD_LIB) $(OBJDIR)
2011 DEPS := $(DEPS) $(STUBS_DEP)
2015 #------------------------------------------------------------------------------
2016 # Build an imported source tree which uses the configure script from the
2017 # autoconf package. This rule will try to "integrate" the produced files as
2018 # much as possible in the AROS build, for example by putting libraries in the
2019 # standard library directory, includes in the standard include directory, and
2020 # so on. You can however override this behaviour.
2022 # As a special "bonus" for you, the PROGDIR environment variable is defined to
2023 # be %(bindir) (or its deduced value) when running "make install", and
2024 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
2025 # configure script some more parameters whose value depends upon the PROGDIR
2026 # env var, so that the program gets all its stuff installed in the proper place
2027 # when building it, but when running it from inside AROS it can also find that
2028 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
2029 # the configuration parameters set when running ./configure
2031 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
2032 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
2033 # to the name which has to follow it.
2036 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) prefix= \
2037 aros_prefix= extraoptions= nix_dir_layout= nix=no compiler=target \
2038 install_target=install postconfigure= postinstall= \
2042 %(mmake)-prefix := %(prefix)
2044 %(mmake)-prefix := $(AROS_CONTRIB)
2047 ifneq (%(aros_prefix),)
2048 %(mmake)-aros_prefix := %(aros_prefix)
2050 %(mmake)-aros_prefix := $(%(mmake)-prefix)
2054 %(mmake)-nix := -nix
2055 %(mmake)-volpfx := /
2056 %(mmake)-volsfx := /
2058 ifeq (%(nix_dir_layout),)
2059 %(mmake)-nix_dir_layout := yes
2062 %(mmake)-volsfx := :
2064 ifeq (%(nix_dir_layout),)
2065 %(mmake)-nix_dir_layout := no
2069 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
2071 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
2072 exec_prefix=$(%(mmake)-prefix) %(install_env)
2074 # Check if chosen compiler is valid
2075 ifeq ($(findstring %(compiler),host target kernel),)
2076 $(error unknown compiler %(compiler))
2079 # Set legacy 'host' variable based on chosen compiler
2080 ifeq (%(compiler),host)
2083 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
2085 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
2090 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
2092 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
2096 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
2097 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
2099 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
2100 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
2101 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2104 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
2105 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
2107 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2110 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
2112 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
2113 sbindir=$(%(mmake)-prefix) \
2114 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
2115 oldincludedir=$(AROS_INCLUDES) %(install_env)
2119 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
2121 #MM- %(mmake) : setup includes linklibs-core %(mmake)-quick
2123 # Using -j1 in install_command may result in a warning but finally
2124 # it does its job. make install for gcc does not work reliable for -jN
2126 ifneq (%(install_target),)
2127 %(mmake)-install_command = \
2128 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2129 -C $(%(mmake)-pkgdir) %(install_target) -j1 && \
2130 $(TOUCH) $(%(mmake)-installflag)
2132 %(mmake)-uninstall_command = \
2133 $(RM) $(%(mmake)-installflag) && \
2134 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2135 -C $(%(mmake)-pkgdir) uninstall
2137 %(mmake)-install_command := true
2138 %(mmake)-uninstall_command := true
2141 #MM- %(mmake)-quick : %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
2144 %(mmake)-build_and_install-quick : $(%(mmake)-configflag)
2145 if ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q -C $(%(mmake)-pkgdir); then \
2146 $(RM) $(%(mmake)-installflag) && \
2147 $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -C $(%(mmake)-pkgdir) && \
2148 $(%(mmake)-install_command); \
2151 %(srcdir)/.files-touched:
2152 find %(srcdir) -exec $(TOUCH) -r %(srcdir)/configure '{}' \; && \
2156 %(mmake)-uninstall :
2157 $(%(mmake)-uninstall_command)
2159 ifneq ($(DEBUG),yes)
2160 %(mmake)-s_flag = -s
2164 %(mmake)-configure : $(%(mmake)-configflag)
2166 ifeq (%(compiler),host)
2167 $(%(mmake)-configflag) : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2169 %mkdirs_q $(%(mmake)-pkgdir)
2170 cd $(%(mmake)-pkgdir) && \
2171 find . -name config.cache -exec $(RM) '{}' \; && \
2173 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) && \
2176 ifeq (%(compiler),target)
2177 $(%(mmake)-configflag) : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2179 %mkdirs_q $(%(mmake)-pkgdir)
2180 cd $(%(mmake)-pkgdir) && \
2181 find . -name config.cache -exec $(RM) '{}' \; && \
2182 CC="$(TARGET_CC) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2183 AS="$(TARGET_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)" \
2184 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) \
2185 --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH) \
2186 --host=$(AROS_TARGET_CPU)-aros \
2187 --target=$(AROS_TARGET_CPU)-aros \
2189 --without-x --without-pic --disable-shared && \
2192 ifeq (%(compiler),kernel)
2193 $(%(mmake)-configflag) : %(srcdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2195 %mkdirs_q $(%(mmake)-pkgdir)
2196 cd $(%(mmake)-pkgdir) && \
2197 find . -name config.cache -exec $(RM) '{}' \; && \
2198 CC="$(KERNEL_CC) $(KERNEL_CFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2199 AS="$(TARGET_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)" \
2200 %(srcdir)/configure $(%(mmake)-config_opts) %(extraoptions) \
2201 --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH) \
2202 --host=$(AROS_TARGET_CPU)-aros \
2203 --target=$(AROS_TARGET_CPU)-aros --disable-nls \
2204 --without-x --without-pic --disable-shared && \
2209 %(mmake)-clean : %(mmake)-uninstall
2210 @$(RM) $(%(mmake)-pkgdir)
2213 #############################################################################
2214 #############################################################################
2216 ## Miscellaneous macros. Everything that doesn't fit above should be put ##
2219 #############################################################################
2220 #############################################################################
2222 #----------------------------------------------------------------------------------
2223 # Given an archive name, patches names and locations where to find them, fetch
2224 # the archive and the patches from any of those locations, unpack the archive
2225 # and then apply the patches.
2227 # Locations currently supported are http and ftp sites, plus local filesystem
2228 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
2229 # the fetch.sh script needs to be modified, since this macro relies on that script.
2233 # - archive_origins = list of locations where to find the archive. They are tried
2234 # in sequence, until the archive is found and fetching it
2235 # succeeded. If not specified, the current directory is assumed.
2236 # - archive = the archive name. Mandatory.
2237 # - suffixes = a list of suffixes to append to the the package name plus the
2238 # version. Each one of them is tried until a matching archive is
2239 # found. They are appended to patches and these are tried the
2240 # same way as packages are.
2241 # - destination = the local directory where to put the archive and patches.
2242 # If not specified, the current directory is assumed.
2243 # - patches_origins = list of locations where to find the patches. They are tried
2244 # in sequence, until a patch is found and fetching it
2245 # succeeded. If not specified, the current directory is assumed.
2246 # - patches_specs = list of "patch specs". A patch spec is of the form
2247 # patch_name[:[patch_subdir][:patch_opt]].
2249 # - patch_name = the name of the patch file
2250 # - patch_subdir = the directory within \destination\ where to
2252 # - patch_opt = any options to pass to the `patch' command
2253 # when applying the patch.
2255 # The patch_subdir and patch_opt fields are optional.
2257 %define fetch archive_origins=. archive=/A suffixes= location=%destination destination=. patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
2258 $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l %(location) -d %(destination) \
2259 -po "%(patches_origins)" -p %(patches_specs)
2262 #-----------------------------------------------------------------------------------------
2263 # Joins the features of %fetch and %build_with_configure, taking advantage of
2264 # the naming scheme of GNU packages. GNU packages names are in the form
2266 # <package name>-<version number>.<archive format suffix>
2268 # If a patch is provided, it *must* be named the following way:
2270 # <package name>-<version number>-aros.diff
2272 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
2273 # CD'ing into the archive's extracted directory.
2275 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
2276 # the %fetch_and_build macro only accept *one* patch for each package. It's up to you
2277 # to make that patch fully comprehensive.
2279 # NOTE: GNU packages are always compiled with *nix semantics turned on.
2283 # - mmake = the meta make target, as would be supplied to the %build_with_configure
2285 # - package = the GNU package name, sans version and archive format suffixes.
2286 # - version = the package's version number, or otherwise any other version string.
2287 # It gets appended to the package name to form the basename of the archive.
2288 # - suffixes = a list of suffixes to apped to the the package name plus the
2289 # version. Each one of them is tried until a matching archive is found.
2290 # Defaults to "tar.bz2 tar.gz".
2291 # - destination = same meaning as the one for the %fetch macro
2292 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
2293 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
2295 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
2296 # - prefix = same meaning as the one for the %build_with_configure macro. Defaults to
2298 # - aros_prefix = same meaning as the one for the %build_with_configure macro. Defaults to
2300 # - extraoptions = same meaning as the one for the %build_with_configure macro.
2301 # - postinstall = same meaning as the one for the %build_with_configure macro.
2303 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target version=/A suffixes="tar.bz2 tar.gz" \
2304 srcdir= package_repo= patch=no patch_repo= prefix= \
2305 aros_prefix= extraoptions= postconfigure= postinstall= nix=no nix_dir_layout=
2307 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
2308 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
2309 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
2311 %(mmake)-archbase := %(package)-%(version)
2313 ifeq (%(compiler),host)
2314 %(mmake)-portdir := $(HOSTDIR)/Ports/%(package)
2316 %(mmake)-portdir := $(PORTSDIR)/%(package)
2320 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
2322 %(mmake)-prefix := %(prefix)
2325 ifneq (%(subpackage),)
2326 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
2328 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
2332 %(mmake)-%(subpackage)-srcdir := %(srcdir)
2334 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
2338 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-p1
2340 %(mmake)-%(subpackage)-patches_specs := ::
2343 .PHONY : %(mmake)-%(subpackage)-fetch
2345 %(mmake)-%(subpackage)-fetch :
2346 %fetch archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
2347 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
2348 archive_origins=". %(package_repo)" \
2349 patches_specs="$(%(mmake)-%(subpackage)-patches_specs)" patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
2351 #MM- %(mmake) : %(mmake)-%(subpackage)
2353 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
2355 %(mmake)-%(subpackage)-package-basename := \
2356 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
2358 %build_with_configure mmake=%(mmake)-%(subpackage) package=%(package) compiler=%(compiler) \
2359 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-srcdir) \
2360 nix=%(nix) nix_dir_layout=%(nix_dir_layout) prefix="$(%(mmake)-prefix)" \
2361 aros_prefix="%(aros_prefix)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
2362 %(mmake)-%(subpackage)-make-package" extraoptions="%(extraoptions)"
2364 .PHONY : %(mmake)-%(subpackage)-make-package
2365 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
2368 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package-basename).tar.bz2
2370 #There seems to be a bug, either with my clock or with make, 'cause it may happen
2371 #that $^ and $@ have exactly the same mtime, and in that case make tries
2372 #to rebuild $@ again, which would fail because the directory where
2373 #the package got installed would not exist anymore.
2374 #We work this around by using an if statement to manually check the mtimes.
2375 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
2376 @$(IF) test $(%(mmake)-installflag) -nt $@ || ! test -f $@; then \
2378 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
2379 mkdir -p "$(DISTDIR)/Packages" ; \
2380 mkdir -p "$(%(mmake)-prefix)" ; \
2381 cd $(%(mmake)-%(subpackage)-package-dir) ; \
2382 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
2383 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
2387 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2388 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
2389 aros_prefix=/GNU extraoptions= postconfigure= postinstall=
2391 GNU_REPOSITORY := gnu://
2393 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
2394 suffixes="%(suffixes)" srcdir="%(srcdir)" \
2395 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
2396 patch="%(patch)" patch_repo="%(patch_repo)" \
2397 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" \
2398 postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=yes
2402 #-----------------------------------------------------------------------------------------
2403 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
2404 # that the package is a "Development" package, and as such it needs to be placed
2405 # under the $(AROS_DEVELOPMENT) directory, as a default.
2407 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
2408 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
2409 # "mmake" argument, because the metatarget is implicitely defined as
2411 # #MM- development-%(package)
2413 %define fetch_and_build_gnu_development package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2414 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPMENT) \
2415 aros_prefix=/Development postconfigure= postinstall= extraoptions=
2417 #MM- development : development-%(package)
2420 %fetch_and_build_gnu mmake=development-%(package) package=%(package) subpackage="%(subpackage)" \
2421 version=%(version) suffixes="%(suffixes)" srcdir="%(srcdir)" \
2422 package_repo="%(package_repo)" patch="%(patch)" patch_repo="%(patch_repo)" prefix=%(prefix) \
2423 aros_prefix="%(aros_prefix)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" \
2424 extraoptions="%(extraoptions)"