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) $(TARGET_CFLAGS)" 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) strip=$(STRIP)
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 ; \
71 #------------------------------------------------------------------------------
74 #-------------------------------------------------------------------------
75 # Link a module based upon a number of arguments and the standard $(LIBS)
76 # and $(DEPLIBS) make variables.
78 %define link_module_q err="$(notdir $@).err" objs=/A endtag= module=$(MODULE) ldflags=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
79 @$(ECHO) "Building $(notdir $@) ..."
80 @if $(AROS_CC) $(NOSTARTUP_LDFLAGS) %(ldflags) \
81 $(GENMAP) %(objdir)/%(module).map \
82 %(objs) %(libs) %(endtag) \
83 -o $@ 2>&1 > %(objdir)/%(err); \
85 cat %(objdir)/%(err); \
87 cat %(objdir)/%(err); \
91 @if $(TEST) ! -s %(objdir)/%(err) ; then $(RM) %(objdir)/%(err) ; fi
94 #------------------------------------------------------------------------------
97 #------------------------------------------------------------------------------
99 %define mklib_q ar=$(AR) ranlib=$(RANLIB) to=$@ from=$(OBJS)
100 @$(ECHO) "Creating library %(to)..."
104 #------------------------------------------------------------------------------
107 #------------------------------------------------------------------------------
108 # Create the dependency file %(to) for %(from)
109 %define mkdepend_q flags=$(CFLAGS) from=$< to=$@ cc=$(AROS_CC)
110 %mkdir_q dir="$(dir %(to))"
111 @$(ECHO) "Makedepend $(CURDIR)/$(notdir %(from))..."
112 @AROS_CC="%(cc)" $(MKDEPEND) %(flags) -I$(SRCDIR)/$(CURDIR) %(from) -o %(to)
114 #------------------------------------------------------------------------------
117 #------------------------------------------------------------------------------
118 # Create one directory without any output
119 %define mkdir_q dir=.
120 @$(IF) $(TEST) ! -d %(dir) ; then $(MKDIR) %(dir) ; else $(NOP) ; fi
122 #------------------------------------------------------------------------------
125 #------------------------------------------------------------------------------
126 # Create several directories without any output
127 %define mkdirs_q dirs=/M
128 @$(FOR) dir in %(dirs) ; do \
129 $(IF) $(TEST) ! -d $$dir ; then $(MKDIR) $$dir ; else $(NOP) ; fi ; \
132 #------------------------------------------------------------------------------
135 #############################################################################
136 #############################################################################
138 ## Here are the mmakefile macros that are used to do certain tasks in a ##
139 ## mmakefile. They consist of one or more full makefile rules. ##
140 ## In general the files generated in these macros are also defined as ##
141 ## make targets so that they can be used as a dependency in other rules ##
143 #############################################################################
144 #############################################################################
146 #------------------------------------------------------------------------------
147 # Generate a unique id for each of the %build... rules
148 %define buildid targets=/A
150 ifneq ($(filter $(TARGET),%(targets)),)
151 BDTARGETID := $(BDID)
154 #------------------------------------------------------------------------------
157 #------------------------------------------------------------------------------
158 # Copy file %(from) to %(to) in a makefile rule
159 %define rule_copy from=/A to=/A
163 #------------------------------------------------------------------------------
166 #------------------------------------------------------------------------------
167 # Copy the files %(files) to %(targetdir). For each file in %(files),
168 # %(srcdir)/file is copied to %(targetdir)/file. The targetdir and the
169 # appropriate subdirs are not generated by this rule so they have to be
171 %define rule_copy_multi files=/A targetdir=/A srcdir=.
173 $(addprefix %(targetdir)/,%(files)) : %(targetdir)/% : %(srcdir)/%
176 #------------------------------------------------------------------------------
179 #------------------------------------------------------------------------------
180 # Copy the files %(files) to %(targetdir). For each file in %(files),
181 # %(srcdir)/file is copied to %(targetdir)/file if these files are different.
182 # %(stampfile) is used to keep track of when the last time the comparison has
183 # been done. The targetdir and the appropriate subdirs are not generated by
184 # this rule so they have to be present.
185 %define rule_copy_diff_multi files=/A targetdir=/A srcdir=. \
186 stampfile=$(TMP_SRCDIR)/.copy_stamp
188 TMP_SRCDIR := %(srcdir)
190 $(addprefix %(targetdir)/,%(files)) : | %(stampfile)
192 %(stampfile) : COPYSRCDIR := %(srcdir)
193 %(stampfile) : TGTDIR := %(targetdir)
194 %(stampfile) : FILES := %(files)
195 %(stampfile) : $(addprefix %(srcdir)/,%(files))
196 @for f in $(FILES); do \
197 $(IF) ! $(CMP) -s $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; then \
198 $(CP) $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; \
203 #------------------------------------------------------------------------------
206 #------------------------------------------------------------------------------
207 # Will join all the files in %(from) to %(to). When text is specified it will
209 # Restriction: at the moment when using a non-empty target dir %(from) may
211 %define rule_join to=/A from=/A text=
219 #------------------------------------------------------------------------------
222 #------------------------------------------------------------------------------
223 # Include the dependency files and add some internal rules
224 # When depstargets is provided the depencies will only be included when one of
225 # these targets is the $(TARGET). Otherwise the dependencies will only be
226 # included when the $(TARGET) is not for setup or clean
227 %define include_deps deps=$(DEPS)/M depstargets=
229 ifneq (%(depstargets),)
230 ifneq ($(findstring $(TARGET),%(depstargets)),)
234 ifeq (,$(filter clean% %clean %clean% setup% includes% %setup,$(TARGET)))
240 #------------------------------------------------------------------------------
243 #------------------------------------------------------------------------------
244 # Create the directories %(dirs). The creation will be done by adding rules to
245 # the %(setuptarget) make target with setup as the default.
246 %define rule_makedirs dirs=/A setuptarget=setup
248 %(setuptarget) :: %(dirs)
250 GLOB_MKDIRS += %(dirs)
253 #------------------------------------------------------------------------------
256 #------------------------------------------------------------------------------
257 # Generate a rule to compile a C source file to an object file and generate
258 # the dependency file. Basename may contain a directory part, then the source
259 # file has to be in that directory. The generated file will be put in the
260 # object directory without the directory.
262 # - basename: the basename of the file to compile. Use % for a wildcard rule
263 # - cflags (default $(CFLAGS)): the C flags to use for compilation
264 # - dflags: the flags used during creation of dependency file. If not specified
265 # the same value as cflags will be used
266 # - targetdir: the directory to put the .o file and the .d file. By default
267 # it is put in the same directory as the .c file
268 %define rule_compile basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target nix=no
271 TMP_TARGETBASE := %(basename)
273 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
276 ifeq ($(findstring %(compiler),host kernel target),)
277 $(error unknown compiler %(compiler))
279 ifeq (%(compiler),target)
280 $(TMP_TARGETBASE).o : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
281 $(TMP_TARGETBASE).d : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
282 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
283 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
284 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
285 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
287 ifeq (%(compiler),host)
288 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
289 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
290 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
291 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
292 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
293 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
295 ifeq (%(compiler),kernel)
296 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
297 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
298 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
299 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
300 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
301 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
305 $(TMP_TARGETBASE).o : CFLAGS := -nix %(cflags)
307 $(TMP_TARGETBASE).o : CFLAGS := %(cflags)
309 $(TMP_TARGETBASE).o : %(basename).c
310 %compile_q cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
314 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(cflags)
316 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(cflags)
320 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(dflags)
322 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(dflags)
325 $(TMP_TARGETBASE).d : %(basename).c
326 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
328 #------------------------------------------------------------------------------
331 #------------------------------------------------------------------------------
332 # Generate a rule to compile multiple C source files to an object file and
333 # generate the corresponding dependency files. The generated file will be put
334 # in the object directory without the directory part of the source file.
336 # - basenames: the basenames of the files to compile. The names may include
337 # relative or absolute path names. No wildcard is allowed
338 # - cflags (default $(CFLAGS)): the C flags to use for compilation
339 # - dflags: the flags used during creation of dependency file. If not specified
340 # the same value as cflags will be used
341 # - targetdir: the directory to put the .o file and the .d file. By default
342 # it is put in the same directory as the .c file. When targetdir is not
343 # empty, path names will be stripped from the file names so that all files
344 # are in that dir and not in subdirectories.
345 # - compiler (default target): compiler to use, target, kernel or host
346 %define rule_compile_multi basenames=/A cflags=$(CFLAGS) dflags= targetdir= \
350 TMP_TARGETS := $(addsuffix .o,%(basenames))
351 TMP_DTARGETS := $(addsuffix .d,%(basenames))
354 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
355 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
356 TMP_WILDCARD := %(targetdir)/%
358 # Be sure that all .c files are generated
359 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .c,%(basenames))
361 # Be sure that all .c files are found
362 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
363 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
364 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
366 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
367 vpath %.c $(TMP_DIRS)
372 ifeq ($(findstring %(compiler),host kernel target),)
373 $(error unknown compiler %(compiler))
375 ifeq (%(compiler),target)
376 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
377 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
378 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
380 ifeq (%(compiler),host)
381 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_CC)
382 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
383 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
385 ifeq (%(compiler),kernel)
386 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
387 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
388 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
391 $(TMP_TARGETS) : CFLAGS := %(cflags)
392 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.c
393 %compile_q cmd=$(CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
396 $(TMP_DTARGETS) : DFLAGS:=%(cflags)
398 $(TMP_DTARGETS) : DFLAGS:=%(dflags)
400 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.c
401 %mkdepend_q cc=$(CMD) flags=$(DFLAGS)
403 #------------------------------------------------------------------------------
406 #------------------------------------------------------------------------------
407 # Make an alias from one arch specific build to another arch.
409 # - mainmmake: the mmake of the module in the main tree
410 # - arch: the current arch
411 # - alias: the alias to which this should point
412 %define rule_archalias mainmmake=\A arch=\A alias=\A
414 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
416 #------------------------------------------------------------------------------
419 #------------------------------------------------------------------------------
420 # Generate a rule to compile a C source file to a shared object file with a
421 # .so suffix. Basename may contain a directory part, then the source
422 # file has to be in that directory. The generated file will be put in the
423 # object directory without the directory.
425 # - basename: the basename of the file to compile. Use % for a wildcard rule
426 # - cflags (default $(CFLAGS)): the C flags to use for compilation
427 # - targetdir: the directory to put the .o file and the .d file. By default
428 # it is put in the same directory as the .c file
429 %define rule_compile_shared basename=/A cflags=$(CFLAGS) targetdir= compiler=target
432 TMP_TARGETBASE := %(basename)
434 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
437 ifeq ($(findstring %(compiler),host kernel target),)
438 $(error unknown compiler %(compiler))
440 ifeq (%(compiler),target)
441 $(TMP_TARGETBASE).so : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
442 $(TMP_TARGETBASE).so : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
443 $(TMP_TARGETBASE).so : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
445 ifeq (%(compiler),host)
446 $(TMP_TARGETBASE).so : TMP_CMD:=$(HOST_CC)
447 $(TMP_TARGETBASE).so : TMP_IQUOTE:=$(HOST_IQUOTE)
448 $(TMP_TARGETBASE).so : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
450 ifeq (%(compiler),kernel)
451 $(TMP_TARGETBASE).so : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
452 $(TMP_TARGETBASE).so : TMP_IQUOTE:=$(KERNEL_IQUOTE)
453 $(TMP_TARGETBASE).so : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
456 $(TMP_TARGETBASE).so : %(basename).c
457 %compile_q opt="$(SHARED_CFLAGS) %(cflags)" cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
459 #------------------------------------------------------------------------------
462 #------------------------------------------------------------------------------
463 # Generate a rule to assemble a source file to an object file. Basename may
464 # contain a directory part, then the source file has to be in that directory.
465 # The generated file will be put in the object directory without the directory.
467 # - basename: the basename of the file to compile. Use % for a wildcard rule
468 # - flags (default $(AFLAGS)): the asm flags to use for assembling
469 # - targetdir: the directory to put the .o file in. By default it is put in the
470 # same directory as the .s file
471 %define rule_assemble basename=/A aflags=$(AFLAGS) targetdir=
474 %(basename).o : AFLAGS := %(aflags)
475 %(basename).o : %(basename).s
477 %(basename).o : %(basename).S
481 %(targetdir)/$(notdir %(basename)).o : AFLAGS := %(aflags)
482 %(targetdir)/$(notdir %(basename)).o : %(basename).s
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 compiler=target
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_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
518 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
519 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
521 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
522 vpath %%(suffix) $(TMP_DIRS)
527 ifeq ($(findstring %(compiler),host kernel target),)
528 $(error unknown compiler %(compiler))
530 ifeq (%(compiler),target)
531 $(TMP_TARGETS) : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
533 ifeq (%(compiler),host)
534 $(TMP_TARGETS) : TMP_CMD:=$(HOST_CC)
536 ifeq (%(compiler),kernel)
537 $(TMP_TARGETS) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
540 $(TMP_TARGETS) : AFLAGS := %(aflags)
541 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %%(suffix)
542 %assemble_q cmd=$(TMP_CMD) opt=$(AFLAGS)
544 #------------------------------------------------------------------------------
547 #------------------------------------------------------------------------------
548 # Link %(objs) to %(prog) using the libraries in %(uselibs)
549 %define rule_link_prog prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
550 usehostlibs= usestartup=yes detach=no nix=no linker=target
554 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
556 ifeq (%(usestartup),no)
557 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
560 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
563 # Make a list of the lib files this program depends on.
565 # In LDFLAGS remove white space between -L and directory
566 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
567 # Filter out only the libdirs and remove -L
568 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
570 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
571 # Add normal linklib path
572 TMP_DIRS += $(LIBDIR)/
573 # add lib and .a to static linklib names
574 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) libinit autoinit))
575 # search for the linklibs in the given path, ignore ones not found
576 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
577 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
583 ifeq (%(linker),target)
584 %(prog) : CMD:=$(TARGET_CC)
585 %(prog) : STRIPCMD:=$(TARGET_STRIP)
587 ifeq (%(linker),host)
588 %(prog) : CMD:=$(HOST_CC)
589 %(prog) : STRIPCMD:=$(HOST_STRIP)
591 ifeq (%(linker),kernel)
592 %(prog) : CMD:=$(KERNEL_CC) $(KERNEL_LDFLAGS)
593 %(prog) : STRIPCMD:=$(ECHO) >/dev/null
596 %(prog) : OBJS := %(objs)
597 %(prog) : LDFLAGS := %(ldflags) $(TMP_EXTRA_LDFLAGS)
598 %(prog) : LIBS := $(addprefix -l,%(uselibs)) $(addprefix -l,%(usehostlibs))
599 %(prog) : %(objs) $(TMP_DEPLIBS)
600 %link_q from=$(OBJS) opt=$(LDFLAGS) libs=$(LIBS) cmd=$(CMD) strip=$(STRIPCMD)
602 #------------------------------------------------------------------------------
605 #------------------------------------------------------------------------------
606 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
607 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
608 %define rule_link_progs progs=/A targetdir=$(AROSDIR)/$(CURDIR) nix=%(nix) \
609 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
610 usestartup=yes detach=no
614 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
616 ifeq (%(usestartup),no)
617 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
620 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
623 # Make a list of the lib files the programs depend on.
625 # In LDFLAGS remove white space between -L and directory
626 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
627 # Filter out only the libdirs and remove -L
628 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
630 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
631 # Add normal linklib path
632 TMP_DIRS += $(LIBDIR)/lib/
633 # add lib and .a to static linklib names
634 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) libinit autoinit))
635 # search for the linklibs in the given path, ignore ones not found
636 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
637 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
643 $(addprefix %(targetdir)/,%(progs)) : LDFLAGS:= %(ldflags) $(TMP_EXTRA_LDFLAGS)
644 $(addprefix %(targetdir)/,%(progs)) : LIBS:= $(addprefix -l,%(uselibs)) $(addprefix -l,%(usehostlibs))
645 $(addprefix %(targetdir)/,%(progs)) : %(targetdir)/% : %(objdir)/%.o $(TMP_DEPLIBS)
646 %link_q from=$< opt=$(LDFLAGS) libs=$(LIBS)
648 #------------------------------------------------------------------------------
651 #------------------------------------------------------------------------------
652 # Link the %(objs) to the library %(libdir)/lib%(libname).a
653 %define rule_link_linklib libname=/A objs=/A libdir=$(LIBDIR)
655 %(libdir)/lib%(libname).a : %(objs)
658 #------------------------------------------------------------------------------
661 #------------------------------------------------------------------------------
662 # Link the %(objs) to the library %(libdir)/lib%(libname).so
663 %define rule_link_shlib libname=/A objs=/A libdir=$(LIBDIR)
665 %(libdir)/lib%(libname).so : %(objs)
666 @$(SHARED_LD) $(SHARED_LDFLAGS) -o $@ $^
668 #------------------------------------------------------------------------------
671 #------------------------------------------------------------------------------
672 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
673 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
674 # The -noarosc flag is added so that modules are not linked with arosc.library
675 # (see /config/specs.in file)
676 %define rule_linkmodule module=/A objs=/A endobj=/A err=/A objdir=$(OBJDIR) \
677 uselibs= usehostlibs=
679 %(module) : OBJS := %(objs)
680 %(module) : ENDTAG := %(endobj)
681 %(module) : ERR := %(err)
682 %(module) : OBJDIR := %(objdir)
683 %(module) : LIBS := $(addprefix -l,%(uselibs)) -lautoinit -llibinit -L/usr/lib $(addprefix -l,%(usehostlibs))
685 TMP_DEPLIBS := $(addprefix lib,$(addsuffix .a, %(uselibs) autoinit libinit))
689 ifneq ($(USER_LIBDIR),)
690 ALL_USERLIBS := $(notdir $(wildcard $(USER_LIBDIR)/lib*.a))
691 USER_DEPLIBS := $(addprefix $(USER_LIBDIR)/, $(filter $(ALL_USERLIBS),$(TMP_DEPLIBS)))
692 TMP_DEPLIBS := $(filter-out $(ALL_USERLIBS),$(TMP_DEPLIBS))
693 TMP_LDFLAGS := -L$(USER_LIBDIR)
696 TMP_DEPLIBS := $(addprefix $(LIBDIR)/, $(TMP_DEPLIBS))
698 %(module) : %(objs) %(endobj) $(TMP_DEPLIBS) $(USER_DEPLIBS)
699 %link_module_q err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS) objdir=$(OBJDIR) ldflags="$(LDFLAGS) $(TMP_LDFLAGS) -noarosc"
702 #------------------------------------------------------------------------------
705 #------------------------------------------------------------------------------
706 # Generate the libdefs.h include file for a module.
707 %define rule_genmodule_genlibdefs modname=/A modtype=/A modsuffix= conffile= targetdir=
709 TMP_TARGET := %(modname)_libdefs.h
710 TMP_DEPS := $(GENMODULE)
713 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
714 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
716 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
717 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
719 ifneq (%(modsuffix),)
720 TMP_OPTS += -s %(modsuffix)
722 ifneq (%(targetdir),)
723 TMP_OPTS += -d %(targetdir)
724 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
727 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
728 $(TMP_TARGET) : MODNAME := %(modname)
729 $(TMP_TARGET) : MODTYPE := %(modtype)
730 $(TMP_TARGET) : $(TMP_DEPS)
731 @$(ECHO) "Generating $(notdir $@)"
732 @$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
734 #------------------------------------------------------------------------------
737 #------------------------------------------------------------------------------
738 # Generate a Makefile.%(modname) with the genmodule program and include this
739 # generated file in this Makefile
740 %define rule_genmodule_makefile modname=/A modtype=/A modsuffix= conffile= \
743 TMP_TARGET := Makefile.%(modname)
744 TMP_DEPS := $(GENMODULE)
747 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
748 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
750 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
751 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
753 ifneq (%(modsuffix),)
754 TMP_OPTS += -s %(modsuffix)
756 ifneq (%(targetdir),)
757 TMP_OPTS += -d %(targetdir)
758 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
761 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
762 $(TMP_TARGET) : MODNAME := %(modname)
763 $(TMP_TARGET) : MODTYPE := %(modtype)
764 $(TMP_TARGET) : $(TMP_DEPS)
765 @$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
767 #------------------------------------------------------------------------------
770 #------------------------------------------------------------------------------
771 # Generate the support files for compiling a module. This includes include
772 # files and source files. This rule has to be preceeded by
773 # %rule_genmodule_makefile
774 %define rule_genmodule_files modname=/A modtype=/A modsuffix= targetdir= \
777 TMP_TARGETS := $(%(modname)_STARTFILES) $(%(modname)_ENDFILES) \
778 $(%(modname)_LINKLIBFILES)
779 TMP_TARGETS := $(addsuffix .c,$(TMP_TARGETS)) $(addsuffix .S, $(%(modname)_LINKLIBAFILES))
781 TMP_DEPS := $(GENMODULE)
785 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
786 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
788 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
789 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
791 ifneq (%(modsuffix),)
792 TMP_OPTS += -s %(modsuffix)
794 ifneq (%(targetdir),)
795 TMP_OPTS += -d %(targetdir)
796 TMP_TARGETDIR := $(shell echo %(targetdir) | sed 's/^\(.\):\//\/\1\//')
797 TMP_TARGETS := $(addprefix $(TMP_TARGETDIR)/,$(TMP_TARGETS))
800 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
801 $(TMP_TARGETS) : MODNAME := %(modname)
802 $(TMP_TARGETS) : MODTYPE := %(modtype)
803 $(TMP_TARGETS) : $(TMP_DEPS)
804 @$(ECHO) "Generating support files for module $(MODNAME$(BDID))"
805 ifneq (%(conffile),lib.conf)
806 @$(IF) $(TEST) -f lib.conf; then \
807 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
810 @$(IF) $(TEST) -f libdefs.h; then \
811 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
813 @$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
815 #------------------------------------------------------------------------------
818 #------------------------------------------------------------------------------
819 # Generate the support files for compiling a module. This includes include
820 # files and source files.
821 %define rule_genmodule_includes modname=/A modtype=/A modsuffix= \
824 ifneq ($(%(modname)_INCLUDES),)
825 TMP_TARGETS := $(%(modname)_INCLUDES)
827 TMP_DEPS := $(GENMODULE)
831 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
832 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
834 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
835 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
837 ifneq (%(modsuffix),)
838 TMP_OPTS += -s %(modsuffix)
840 ifneq (%(targetdir),)
841 TMP_OPTS += -d %(targetdir)
842 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
845 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
846 $(TMP_TARGETS) : MODNAME := %(modname)
847 $(TMP_TARGETS) : MODTYPE := %(modtype)
848 $(TMP_TARGETS) : $(TMP_DEPS)
849 @$(ECHO) "Generating include files"
850 @$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
853 #------------------------------------------------------------------------------
856 #------------------------------------------------------------------------------
857 # Common rules for all makefiles
859 # Delete generated makefiles
862 @$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
864 include $(SRCDIR)/config/make.tail
866 BDID := $(BDTARGETID)
868 #------------------------------------------------------------------------------
871 #############################################################################
872 #############################################################################
874 ## Here are the mmakefile build macros. These are macros that takes care ##
875 ## of everything to go from the sources to the generated target. Also all ##
876 ## intermediate files and directories that are needed are created by these ##
879 #############################################################################
880 #############################################################################
882 #------------------------------------------------------------------------------
884 %define build_prog mmake=/A progname=/A files=$(BD_PROGNAME) asmfiles= \
885 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
886 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
887 aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
888 compiler=target srcdir=
892 BD_PROGNAME := %(progname)
893 BD_OBJDIR := %(objdir)
894 BD_TARGETDIR := %(targetdir)
897 BD_ASMFILES := %(asmfiles)
899 BD_ARCHOBJS := $(wildcard $(BD_OBJDIR)/arch/*.o)
900 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
901 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
903 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_NARCHFILES) $(BD_ASMFILES)))
904 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_NARCHFILES)))
906 BD_CFLAGS := %(cflags)
907 BD_AFLAGS := %(aflags)
908 BD_DFLAGS := %(dflags)
909 BD_LDFLAGS := %(ldflags)
912 %(mmake)-quick : %(mmake)
914 #MM %(mmake) : includes-generate-deps linklibs-core
915 %(mmake) : $(BD_TARGETDIR)/$(BD_PROGNAME)
917 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
918 %rule_compile basename=%(srcdir)% targetdir=$(BD_OBJDIR) \
919 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler=%(compiler)
920 %rule_assemble_multi basenames=$(BD_ASMFILES) targetdir=$(BD_OBJDIR) \
921 aflags=$(BD_AFLAGS) compiler=%(compiler)
923 %rule_link_prog prog=$(BD_TARGETDIR)/$(BD_PROGNAME) \
924 objs="$(BD_OBJS) $(BD_ARCHOBJS) $(USER_OBJS)" ldflags=$(BD_LDFLAGS) \
925 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
926 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)" \
931 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
933 $(BD_OBJS) $(BD_DEPS) : | $(BD_OBJDIR)
934 $(BD_TARGETDIR)/$(BD_PROGNAME) : | $(BD_TARGETDIR)
935 GLOB_MKDIRS += $(BD_OBJDIR) $(BD_TARGETDIR)
937 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_TARGETDIR)/$(BD_PROGNAME) $(BD_DEPS)
940 @$(ECHO) "Cleaning up for metatarget %(mmake)"
944 #------------------------------------------------------------------------------
947 #------------------------------------------------------------------------------
948 # Build programs, for every C file an executable will be built with the same
950 %define build_progs mmake=/A files=/A nix=no \
951 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
952 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
953 uselibs= usehostlibs= usestartup=yes detach=no
957 BD_OBJDIR := %(objdir)
958 BD_TARGETDIR := %(targetdir)
961 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
962 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
963 BD_EXES := $(addprefix $(BD_TARGETDIR)/,$(BD_FILES))
965 BD_CFLAGS := %(cflags)
966 BD_DFLAGS := %(dflags)
967 BD_LDFLAGS := %(ldflags)
970 %(mmake)-quick : %(mmake)
972 #MM %(mmake) : includes-generate-deps
973 %(mmake) : $(BD_EXES)
975 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
976 %rule_compile basename=% targetdir=$(BD_OBJDIR) nix=%(nix) \
977 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
979 %rule_link_progs progs=$(BD_FILES) nix=%(nix) \
980 targetdir=$(BD_TARGETDIR) objdir=$(BD_OBJDIR) \
981 ldflags=$(BD_LDFLAGS) \
982 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
983 usestartup="%(usestartup)" detach="%(detach)"
987 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
989 $(addprefix $(BD_TARGETDIR)/,$(BD_FILES)) : | $(BD_TARGETDIR)
990 $(BD_DEPS) $(BD_OBJS) : | $(BD_OBJDIR)
991 GLOB_MKDIRS += $(BD_TARGETDIR) $(BD_OBJDIR)
993 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_EXES) $(BD_DEPS)
996 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1000 #------------------------------------------------------------------------------
1003 #------------------------------------------------------------------------------
1005 # This is a bare version: It just compiles and links the given files. It is
1006 # assumed that all needed boiler plate code is in the files. This should only
1007 # be used for compiling external code. For AROS code use %build_module
1008 %define build_module_simple mmake=/A modname=/A modtype=/A \
1009 files="$(basename $(call WILDCARD, *.c))" \
1010 cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1011 objdir=$(OBJDIR) moduledir= \
1012 uselibs= usehostlibs= compiler=target
1014 # Define metamake targets and their dependencies
1015 #MM %(mmake) : core-linklibs includes-generate-deps
1016 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1017 #MM %(mmake)-pkg : core-linklibs includes-generate-deps
1021 BD_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj %(mmake)-pkg
1023 .PHONY : $(BD_ALLTARGETS)
1026 $(error using %build_module_simple: modname may not be empty)
1029 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1032 # Default values for variables and arguments
1033 BD_DEFLINKLIBNAME := %(modname)
1034 BD_DEFDFLAGS := %(cflags)
1035 OBJDIR ?= $(GENDIR)/$(CURDIR)
1036 BD_MODDIR := %(moduledir)
1037 ifeq ($(BD_MODDIR),)
1038 ifeq (%(modtype),library)
1039 BD_MODDIR := $(AROS_LIBS)
1041 ifeq (%(modtype),gadget)
1042 BD_MODDIR := $(AROS_GADGETS)
1044 ifeq (%(modtype),datatype)
1045 BD_MODDIR := $(AROS_DATATYPES)
1047 ifeq (%(modtype),handler)
1048 BD_MODDIR := $(AROS_FS)
1050 ifeq (%(modtype),device)
1051 BD_MODDIR := $(AROS_DEVS)
1053 ifeq (%(modtype),resource)
1054 BD_MODDIR := $(AROS_RESOURCES)
1056 ifeq (%(modtype),hook)
1057 BD_MODDIR := $(AROS_RESOURCES)
1059 ifeq (%(modtype),mui)
1060 BD_MODDIR := $(AROS_CLASSES)/Zune
1062 ifeq (%(modtype),mcc)
1063 BD_MODDIR := $(AROS_CLASSES)/Zune
1065 ifeq (%(modtype),mcp)
1066 BD_MODDIR := $(AROS_CLASSES)/Zune
1068 ifeq (%(modtype),usbclass)
1069 BD_MODDIR := $(AROS_CLASSES)/USB
1071 ifeq (%(modtype),hidd)
1072 BD_MODDIR := $(AROS_DRIVERS)
1075 ifeq ($(BD_MODDIR),)
1076 $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1079 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1080 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1081 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),%(files))
1083 %rule_compile_multi \
1084 basenames="$(BD_NARCHFILES)" targetdir="%(objdir)" \
1085 cflags="%(cflags)" dflags="%(dflags)" \
1086 compiler=%(compiler)
1088 BD_MODULE := $(BD_MODDIR)/%(modname).%(modtype)
1089 BD_PKGMOD := $(PKGDIR)/%(modname).%(modtype)
1090 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1092 %(mmake)-quick : %(mmake)
1093 %(mmake) : $(BD_MODULE)
1094 %(mmake)-pkg : $(BD_PKGMOD)
1095 %(mmake)-kobj : $(BD_KOBJ)
1097 # The module is linked from all the compiled .o files
1098 BD_OBJS := $(BD_ARCHOBJS) $(addprefix %(objdir)/, $(addsuffix .o,$(notdir $(BD_NARCHFILES))))
1100 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1101 endobj= err=%(modname).err objdir=%(objdir) \
1102 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1104 %rule_linkmodule module=$(BD_PKGMOD) objs=$(BD_OBJS) \
1105 endobj= err=%(modname).err objdir=%(objdir) \
1106 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1108 # Link kernel object file
1109 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1111 # Make these symbols local
1112 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1113 UtilityBase ExpansionBase KeymapBase KernelBase
1115 BD_SYMBOLS := $(BD_KBASE)
1117 BD_KLIB := hiddstubs amiga arossupport rom arosm autoinit libinit
1118 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1119 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1120 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
1121 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1122 @$(ECHO) "Linking $@"
1123 @$(AROS_LD) -Ur -o $@ $^ -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1124 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^libraryset_.*$$/) {print "-L " $$3;}'`
1127 ## Dependency fine-tuning
1129 BD_DEPS := $(addprefix %(objdir)/, $(addsuffix .d,%(files)))
1130 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj %(mmake)-pkg" deps=$(BD_DEPS)
1132 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1133 $(BD_MODULE) : | $(BD_MODDIR)
1134 $(BD_KOBJ) : | $(KOBJSDIR)
1135 GLOB_MKDIRS += %(objdir) $(BD_MODDIR) $(KOBJSDIR)
1137 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_MODULE) $(BD_KOBJ) $(BD_DEPS)
1139 @$(ECHO) "Cleaning up for module %(modname)"
1142 #------------------------------------------------------------------------------
1145 #------------------------------------------------------------------------------
1147 # Explanation of this macro is done in the developer's manual
1148 %define build_module mmake=/A modname=/A modtype=/A modsuffix= \
1149 conffile= files="$(basename $(call WILDCARD, *.c))" \
1150 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1151 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
1152 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
1155 # Define metamake targets and their dependencies
1156 #MM- includes-all : %(mmake)-includes
1157 #MM %(mmake) : %(mmake)-includes core-linklibs
1158 #MM %(mmake)-kobj : %(mmake)-includes core-linklibs
1159 #MM %(mmake)-kobj-quick : %(mmake)-includes-quick
1160 #MM %(mmake)-pkg : %(mmake)-includes core-linklibs
1161 #MM %(mmake)-pkg-quick : %(mmake)-includes-quick
1162 #MM %(mmake)-linklib : %(mmake)-includes
1163 #MM %(mmake)-quick : %(mmake)-includes-quick
1164 #MM %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1165 #MM includes-generate-deps
1166 #MM %(mmake)-includes-quick
1167 #MM %(mmake)-includes-dirs
1168 #MM %(mmake)-makefile
1171 # All MetaMake targets defined by this macro
1172 BD_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-includes \
1173 %(mmake)-includes-quick %(mmake)-includes-dirs %(mmake)-clean \
1174 %(mmake)-kobj %(mmake)-kobj-quick %(mmake)-pkg %(mmake)-pkg-quick %(mmake)-linklib
1176 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1179 $(error using %build_module: modname may not be empty)
1182 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1185 # Default values for variables and arguments
1186 BD_DEFLINKLIBNAME := %(modname)
1187 BD_DEFDFLAGS := %(cflags)
1188 OBJDIR ?= $(GENDIR)/$(CURDIR)
1190 ## Create genmodule include Makefile for the module
1192 %(mmake)-makefile : %(objdir)/Makefile.%(modname)
1194 %rule_genmodule_makefile \
1195 modname=%(modname) modtype=%(modtype) \
1196 modsuffix=%(modsuffix) targetdir=%(objdir) \
1197 conffile=%(conffile)
1199 %(objdir)/Makefile.%(modname) : | %(objdir)
1201 GLOB_MKDIRS += %(objdir)
1203 # Do not parse these statements if metatarget is not appropriate
1204 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1206 include %(objdir)/Makefile.%(modname)
1208 BD_DEFMODDIR := $(%(modname)_MODDIR)
1211 ## include files generation
1213 BD_INCDIR := %(prefix)/$(AROS_DIR_INCLUDE)
1214 BD_LIBDEFSINC := %(objdir)/include/%(modname)_libdefs.h
1215 BD_DEFLIBDEFSINC := %(objdir)/include/%(modname)_deflibdefs.h
1217 %(mmake)-includes-quick : %(mmake)-includes
1218 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1219 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1220 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1222 ifneq ($(%(modname)_INCLUDES),)
1223 %rule_genmodule_includes modname=%(modname) modtype=%(modtype) \
1224 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1225 conffile=%(conffile)
1227 %rule_copy_diff_multi \
1228 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(GENINCDIR) \
1229 stampfile=%(objdir)/%(modname)_geninc
1231 %rule_copy_diff_multi \
1232 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(BD_INCDIR) \
1233 stampfile=%(objdir)/%(modname)_incs
1235 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1237 TMP%(modname)_INCDIRS := \
1238 %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1239 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1240 $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1241 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget=%(mmake)-includes-dirs
1245 %rule_genmodule_genlibdefs modname=%(modname) modtype=%(modtype) \
1246 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1247 conffile=%(conffile)
1249 $(BD_DEFLIBDEFSINC) : FILENAME := $(BD_LIBDEFSINC)
1250 $(BD_DEFLIBDEFSINC) :
1251 @$(ECHO) "generating $@"
1252 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1254 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) : | %(objdir)/include
1255 GLOB_MKDIRS += %(objdir)/include
1257 ## Extra genmodule src files generation
1259 %rule_genmodule_files modname=%(modname) modtype=%(modtype) \
1260 modsuffix=%(modsuffix) targetdir=%(objdir) \
1261 conffile=%(conffile)
1265 BD_FILES := %(files)
1266 BD_FDIRS := $(sort $(dir $(BD_FILES)))
1267 BD_STARTFILES := $(addprefix %(objdir)/,$(%(modname)_STARTFILES))
1268 BD_ENDFILES := $(addprefix %(objdir)/,$(%(modname)_ENDFILES))
1270 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1271 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1272 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1274 BD_CFLAGS := %(cflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1275 BD_DFLAGS := %(dflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1277 BD_LINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBFILES))
1278 BD_LINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBAFILES))
1279 ifeq ($(strip $(%(modname)_LINKLIBFILES) %(linklibfiles)),)
1282 BD_LINKLIB := %(prefix)/$(AROS_DIR_LIB)/lib%(linklibname).a
1284 BD_LINKLIBFILES := $(BD_LINKLIBCFILES) $(BD_LINKLIBAFILES)
1286 BD_CCFILES := $(BD_NARCHFILES) %(linklibfiles)
1287 BD_TARGETCCFILES := $(BD_STARTFILES) $(BD_ENDFILES) $(BD_LINKLIBCFILES)
1289 %rule_compile_multi \
1290 basenames=$(BD_CCFILES) targetdir=%(objdir) \
1291 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) \
1292 compiler=%(compiler)
1293 %rule_compile_multi \
1294 basenames=$(BD_TARGETCCFILES) targetdir=%(objdir) \
1295 cflags="$(BD_CFLAGS) -D__AROS__" dflags=$(BD_DFLAGS) \
1296 compiler=%(compiler)
1298 ifneq ($(BD_LINKLIBAFILES),)
1299 %rule_assemble_multi \
1300 basenames=$(BD_LINKLIBAFILES) targetdir=%(objdir) suffix=.S
1305 ifeq (%(modsuffix),)
1306 BD_MODULE := %(prefix)/%(moduledir)/%(modname).%(modtype)
1307 BD_PKGMOD := $(PKGDIR)/%(modname).%(modtype)
1308 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1310 BD_MODULE := %(prefix)/%(moduledir)/%(modname).%(modsuffix)
1311 BD_PKGMOD := $(PKGDIR)/%(modname).%(modsuffix)
1312 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modsuffix).o
1315 %(mmake)-quick : %(mmake)
1316 %(mmake) : $(BD_MODULE) $(BD_LINKLIB)
1317 %(mmake)-pkg : $(BD_PKGMOD) $(BD_LINKLIB)
1318 %(mmake)-pkg-quick : $(BD_PKGMOD) $(BD_LINKLIB)
1319 %(mmake)-kobj : $(BD_KOBJ) $(BD_LINKLIB)
1320 %(mmake)-kobj-quick : $(BD_KOBJ) $(BD_LINKLIB)
1321 %(mmake)-linklib : $(BD_LINKLIB)
1323 BD_OBJS := $(addsuffix .o,$(BD_STARTFILES)) $(BD_ARCHOBJS) \
1324 $(addsuffix .o, $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES))))
1325 BD_STARTOBJS := $(addsuffix .o,$(addprefix $(GENDIR)/,$(RESIDENT_BEGIN)))
1326 BD_ENDOBJS := $(addsuffix .o,$(BD_ENDFILES))
1327 BD_LINKLIBOBJS:= $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_LINKLIBFILES)) \
1330 # The module is linked from all the compiled .o files
1331 %rule_linkmodule module=$(BD_MODULE) objs="$(BD_STARTOBJS) $(BD_OBJS) $(USER_OBJS)" \
1332 endobj=$(BD_ENDOBJS) err=%(modname).err objdir=%(objdir) \
1333 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1335 %rule_linkmodule module=$(BD_PKGMOD) objs="$(BD_STARTOBJS) $(BD_OBJS) $(USER_OBJS)" \
1336 endobj=$(BD_ENDOBJS) err=%(modname).err objdir=%(objdir) \
1337 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1340 ifneq ($(BD_LINKLIB),)
1341 %rule_link_linklib libname=%(linklibname) objs=$(BD_LINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1343 $(BD_LINKLIB) : | %(prefix)/$(AROS_DIR_LIB)
1344 GLOB_MKDIRS += %(prefix)/$(AROS_DIR_LIB)
1347 # Link kernel object file
1348 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1350 # Make these symbols local
1351 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1352 UtilityBase ExpansionBase KeymapBase KernelBase
1354 BD_SYMBOLS := $(BD_KBASE)
1356 ifeq ($(USER_LIBDIR),)
1357 $(BD_KOBJ) : TMP_LDFLAGS :=
1359 $(BD_KOBJ) : TMP_LDFLAGS := -L$(USER_LIBDIR)
1362 BD_KLIB := hiddstubs amiga arossupport rom arosm autoinit libinit
1363 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1364 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1365 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
1366 $(BD_KOBJ) : $(BD_OBJS) $(USER_OBJS) $(BD_ENDOBJS)
1367 @$(ECHO) "Linking $@"
1368 @$(AROS_LD) -Ur -o $@ $^ -L$(AROS_LIB) $(TMP_LDFLAGS) $(addprefix -l,$(LINKLIBS))
1369 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^libraryset_.*$$/) {print "-L " $$3;}'`
1371 ## Dependency fine-tuning
1373 BD_DEPS := $(addsuffix .d,$(addprefix %(objdir)/,$(notdir $(BD_CCFILES) $(BD_TARGETCCFILES))))
1374 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick %(mmake)-pkg %(mmake)-pkg-quick" deps=$(BD_DEPS)
1376 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1377 $(BD_MODULE) : | %(prefix)/%(moduledir)
1378 $(BD_PKGMOD) : | $(PKGDIR)
1379 $(BD_KOBJ) : | $(KOBJSDIR)
1380 GLOB_MKDIRS += %(objdir) %(prefix)/%(moduledir) $(KOBJSDIR) $(PKGDIR)
1382 # Some include files need to be generated before the .c can be parsed.
1383 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick %(mmake)-pkg %(mmake)-pkg-quick),) # Only for this target these deps are wanted
1385 BD_DFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
1386 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES))
1387 $(BD_DEPS) : $(BD_DFILE_DEPS)
1390 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) \
1391 $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
1392 %(objdir)/Makefile.%(modname) \
1393 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
1394 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1395 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1396 %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
1397 $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
1398 $(BD_DEFLIBDEFSINC) $(addsuffix .c,$(BD_STARTFILES) $(BD_ENDFILES)) \
1400 %(mmake)-clean : FILES := $(BD_TOCLEAN)
1402 @$(ECHO) "Cleaning up for module %(modname)"
1405 endif # $(TARGET) in $(BD_ALLTARGETS)
1407 #------------------------------------------------------------------------------
1410 #------------------------------------------------------------------------------
1411 # Build a module skeleton
1412 # This is a stripped-down version of build_module, it only creates include files,
1413 # but no actual object. This is used when for plugins or classes with the same
1414 # API, but no actual implementation here.
1415 %define build_module_skeleton mmake=/A modname=/A modtype=/A modsuffix= \
1417 objdir=$(OBJDIR) prefix=$(AROSDIR)
1419 # Define metamake targets and their dependencies
1420 #MM- includes-all : %(mmake)-includes
1421 #MM %(mmake) : %(mmake)-includes core-linklibs
1422 #MM %(mmake)-kobj : %(mmake)-includes core-linklibs
1423 #MM %(mmake)-pkg : %(mmake)-includes core-linklibs
1424 #MM %(mmake)-linklib : %(mmake)-includes
1425 #MM %(mmake)-quick : %(mmake)-includes-quick
1426 #MM %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1427 #MM includes-generate-deps
1428 #MM %(mmake)-includes-quick
1429 #MM %(mmake)-includes-dirs
1430 #MM %(mmake)-makefile
1433 # All MetaMake targets defined by this macro
1434 BD_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-includes \
1435 %(mmake)-includes-quick %(mmake)-includes-dirs %(mmake)-clean \
1436 %(mmake)-kobj %(mmake)-pkg
1438 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1441 $(error using %build_module_skeleton: modname may not be empty)
1444 $(error using %build_module_skeleton: $(MODTYPE) has to be defined with the type of the module)
1447 # Default values for variables and arguments
1448 BD_DEFLINKLIBNAME := %(modname)
1449 BD_DEFDFLAGS := %(cflags)
1450 OBJDIR ?= $(GENDIR)/$(CURDIR)
1452 ## Create genmodule include Makefile for the module
1454 %(mmake)-makefile : %(objdir)/Makefile.%(modname)
1456 %rule_genmodule_makefile \
1457 modname=%(modname) modtype=%(modtype) \
1458 modsuffix=%(modsuffix) targetdir=%(objdir) \
1459 conffile=%(conffile)
1461 %(objdir)/Makefile.%(modname) : | %(objdir)
1463 GLOB_MKDIRS += %(objdir)
1465 # Do not parse these statements if metatarget is not appropriate
1466 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1468 include %(objdir)/Makefile.%(modname)
1470 BD_DEFMODDIR := $(%(modname)_MODDIR)
1473 ## include files generation
1475 BD_INCDIR := %(prefix)/$(AROS_DIR_INCLUDE)
1476 BD_LIBDEFSINC := %(objdir)/include/%(modname)_libdefs.h
1477 BD_DEFLIBDEFSINC := %(objdir)/include/%(modname)_deflibdefs.h
1479 %(mmake)-includes-quick : %(mmake)-includes
1480 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1481 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1482 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1484 ifneq ($(%(modname)_INCLUDES),)
1485 %rule_genmodule_includes modname=%(modname) modtype=%(modtype) \
1486 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1487 conffile=%(conffile)
1489 %rule_copy_diff_multi \
1490 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(GENINCDIR) \
1491 stampfile=%(objdir)/%(modname)_geninc
1493 %rule_copy_diff_multi \
1494 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(BD_INCDIR) \
1495 stampfile=%(objdir)/%(modname)_incs
1497 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1499 TMP%(modname)_INCDIRS := \
1500 %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1501 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1502 $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1503 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget=%(mmake)-includes-dirs
1507 %rule_genmodule_genlibdefs modname=%(modname) modtype=%(modtype) \
1508 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1509 conffile=%(conffile)
1511 $(BD_DEFLIBDEFSINC) : FILENAME := $(BD_LIBDEFSINC)
1512 $(BD_DEFLIBDEFSINC) :
1513 @$(ECHO) "generating $@"
1514 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1516 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) : | %(objdir)/include
1517 GLOB_MKDIRS += %(objdir)/include
1519 ## Extra genmodule src files generation
1521 %rule_genmodule_files modname=%(modname) modtype=%(modtype) \
1522 modsuffix=%(modsuffix) targetdir=%(objdir) \
1523 conffile=%(conffile)
1525 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) \
1526 $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
1527 %(objdir)/Makefile.%(modname) \
1528 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
1529 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1530 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1531 %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
1532 $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
1534 %(mmake)-clean : FILES := $(BD_TOCLEAN)
1536 @$(ECHO) "Cleaning up for module %(modname)"
1539 endif # $(TARGET) in $(BD_ALLTARGETS)
1541 #------------------------------------------------------------------------------
1544 #------------------------------------------------------------------------------
1546 # - mmake is the mmaketarget
1547 # - libname is the baselibname e.g. lib%(libname).a will be created
1548 # - files are the C source files to include in the lib. The list of files
1549 # has to be given without the .c suffix
1550 # - asmfiles are the asm files to include in the lib. The list of files has to
1551 # be given without the .s suffix
1552 # - objs additional object to link into the linklib. The objects have to be
1553 # given with full absolute path and the .o suffix.
1554 # - cflags are the flags to compile the source (default $(CFLAGS))
1555 # - dflags are the flags use during makedepend (default equal to cflags)
1556 # - aflags are the flags use during assembling (default $(AFLAGS))
1557 # - objdir is where the .o are generated
1558 # - libdir is the directory where the linklib will be placed (default $(LIBDIR))
1559 %define build_linklib mmake=/A libname=/A \
1560 files="$(basename $(call WILDCARD, *.c))" asmfiles= objs= \
1561 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) objdir=$(OBJDIR) libdir=$(LIBDIR)
1563 # assign and generate the local variables used in this macro
1564 OBJDIR ?= $(GENDIR)/$(CURDIR)
1566 BD_FILES := %(files)
1567 BD_ASMFILES := %(asmfiles)
1569 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1570 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1571 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1573 BD_OBJS := $(BD_ARCHOBJS) \
1574 $(addsuffix .o,$(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES) $(BD_ASMFILES)))) \
1576 BD_DEPS := $(patsubst %.o,%.d,$(BD_OBJS))
1578 BD_CFLAGS := %(cflags)
1580 BD_DFLAGS := $(BD_CFLAGS)
1582 BD_DFLAGS := %(dflags)
1584 BD_AFLAGS := %(aflags)
1586 BD_LINKLIB := %(libdir)/lib%(libname).a
1588 .PHONY : %(mmake) %(mmake)-clean
1590 #MM %(mmake) : includes-generate-deps
1591 %(mmake) : $(BD_LINKLIB)
1595 @$(RM) $(BD_OBJS) $(BD_DEPS)
1597 ifeq ($(TARGET),%(mmake))
1598 ifneq ($(dir $(BD_FILES)),./)
1599 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
1600 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir $(BD_FILES)))
1603 %rule_compile basename=% targetdir=%(objdir) \
1604 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1605 %rule_assemble basename=% targetdir=%(objdir) \
1609 %rule_link_linklib libname=%(libname) objs=$(BD_OBJS) libdir=%(libdir)
1611 %include_deps depstargets=%(mmake) deps=$(BD_DEPS)
1613 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1614 $(BD_LINKLIB) : | %(libdir)
1615 GLOB_MKDIRS += %(objdir) %(libdir)
1618 #------------------------------------------------------------------------------
1621 #------------------------------------------------------------------------------
1623 # - mmake is the mmaketarget
1624 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
1625 # - description is the catalog description file (.cd), without the .ct suffix (default *.cd)
1626 # - subdir is the destination subdirectory of the catalogs
1627 # - name is the name of the destination catalog, without the .catalog suffix
1628 # - source is the path to the generated source code file
1629 # - dir is the base destination directory (default $(AROS_CATALOGS))
1630 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
1631 # - srcdir is the directory in which the *.cd and *.ct files are searched
1633 %define build_catalogs mmake=/A name=/A subdir=/A \
1634 catalogs= source="../strings.h" description= dir=$(AROS_CATALOGS) \
1635 sourcedescription="$(TOOLDIR)/C_h_orig" srcdir="$(SRCDIR)/$(CURDIR)"
1637 ifeq (%(description),)
1638 BD_DESC := $(basename $(wildcard %(srcdir)/*.cd))
1640 BD_DESC := %(description)
1644 BD_LNGS := $(basename $(notdir $(call WILDCARD, %(srcdir)/*.ct)))
1646 BD_LNGS := %(catalogs)
1649 BD_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, $(BD_LNGS)))
1650 BD_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, $(BD_LNGS))) $(dir %(source))
1653 %(mmake) : $(BD_OBJS) %(source)
1655 $(BD_OBJS) : | $(BD_DIRS)
1656 GLOB_MKDIRS += $(BD_DIRS)
1658 %(dir)/%/%(subdir)/%(name).catalog : %(srcdir)/%.ct $(BD_DESC).cd
1659 @$(ECHO) "Creating %(name) catalog for language $*."
1660 @$(FLEXCAT) $(BD_DESC).cd $< CATALOG=%(dir)/$*/%(subdir)/%(name).catalog || [ $$? -lt 10 ]
1663 %(source) : TMP_SOURCEDESCRIPTION := $(shell echo %(sourcedescription) | sed 's/^\(.\):\//\/\1\//')
1664 %(source) : $(BD_DESC).cd | $(dir %(source))
1665 @$(ECHO) "Creating %(name) catalog source file %(source)"
1666 @$(FLEXCAT) $(BD_DESC).cd %(source)=$(TMP_SOURCEDESCRIPTION).sd
1671 $(RM) $(BD_OBJS) %(source)
1673 .PHONY: %(mmake) %(mmake)-clean
1676 #-----------------------------------------------------------------------------
1679 #-----------------------------------------------------------------------------
1681 # - mmake is the mmaketarget
1682 # - icons is a list of icon base names (ie. without the .info suffix)
1683 # - dir is the destination directory
1684 # - srcdir is where *.png and *.info.src are searched
1685 #-----------------------------------------------------------------------------
1687 %define build_icons mmake=/A icons=/A dir=/A srcdir="$(SRCDIR)/$(CURDIR)" image=
1689 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
1692 %(mmake) : $(BD_OBJS)
1696 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%.png
1697 @$(ECHO) Creating $(notdir $@)...
1698 @$(ILBMTOICON) $+ $@
1702 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%(image)
1703 @$(ECHO) Creating $(notdir $@)...
1704 @$(ILBMTOICON) $+ $@
1708 $(BD_OBJS) : | %(dir)
1709 GLOB_MKDIRS += %(dir)
1711 %(mmake)-clean : FILES := $(BD_OBJS)
1716 .PHONY: %(mmake) %(mmake)-clean
1719 #-----------------------------------------------------------------------------
1722 #------------------------------------------------------------------------------
1723 # Compile files for an arch-specific replacement of code for a module
1724 # - files: the basenames of the C files to compile.
1725 # - asmfiles: the basenames of the asm files to assemble.
1726 # - mainmmake: the mmake of the module in the main directory to compile these
1727 # arch specific files for.
1728 # - maindir: the object directory for the main module
1729 # - arch: the arch for which to compile these files. It can have the form
1730 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
1731 # - cflags (default $(CFLAGS)): the C flags to use for compilation
1732 # - dflags: the flags used during creation of dependency file. If not specified
1733 # the same value as cflags will be used
1734 # - aflags: the flags used during assembling
1735 # - compiler: (host, kernel or target) specifies which compiler to use. By default
1736 # the target compiler is used
1737 %define build_archspecific files= asmfiles= mainmmake=/A maindir=/A arch=/A \
1738 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
1740 ifeq (%(files) %(asmfiles),)
1741 $(error no files or asmfiles given)
1744 %buildid targets="%(mainmmake)-%(arch)"
1746 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1747 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1748 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1749 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1750 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1751 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1752 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1753 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1754 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1755 #MM- %(mainmmake)-kobj-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1756 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1757 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1758 #MM- %(mainmmake)-pkg : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1759 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1760 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1761 #MM- %(mainmmake)-pkg-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1762 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1763 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1764 #MM- %(mainmmake)-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1765 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1766 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1768 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
1771 $(error argument arch has to be non empty for the rule_compile_archspecific macro)
1774 BD_OBJDIR$(BDID) := $(GENDIR)/%(maindir)/arch
1775 BD_COBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1776 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
1777 BD_OBJS$(BDID) := $(BD_COBJS$(BDID)) $(BD_ASMOBJS$(BDID))
1778 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1780 ifneq (%(modulename),)
1781 BD_DEFLIBDEFSINC$(BDID) := -include $(GENDIR)/%(maindir)/include/%(modulename)_deflibdefs.h
1784 ifeq ($(TARGET),%(mainmmake)-%(arch))
1785 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
1786 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(files)))
1787 vpath %.s $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
1788 vpath %.S $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
1791 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID))
1792 GLOB_MKDIRS += $(BD_OBJDIR$(BDID))
1795 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
1797 ifeq ($(findstring %(compiler),host kernel target),)
1798 $(error unknown compiler %(compiler))
1800 ifeq (%(compiler),target)
1801 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
1802 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
1803 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
1805 ifeq (%(compiler),host)
1806 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(HOST_CC)
1807 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
1808 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
1810 ifeq (%(compiler),kernel)
1811 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
1812 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
1813 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
1815 ifneq (%(modulename),)
1816 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) $(BD_DEFLIBDEFSINC$(BDID))
1818 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
1820 ifeq ($(TARGET),%(mainmmake)-%(arch))
1821 $(BD_OBJDIR$(BDID))/%.o : %.c
1822 %compile_q opt=$(TMP_CFLAGS) cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
1826 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags) $(BD_DEFLIBDEFSINC$(BDID))
1828 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
1830 ifeq ($(TARGET),%(mainmmake)-%(arch))
1831 $(BD_OBJDIR$(BDID))/%.d : %.c
1832 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
1835 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
1837 ifeq ($(TARGET),%(mainmmake)-%(arch))
1838 $(BD_OBJDIR$(BDID))/%.o : %.s
1839 %assemble_q opt=$(AFLAGS)
1840 $(BD_OBJDIR$(BDID))/%.o : %.S
1841 %assemble_q opt=$(AFLAGS)
1844 %include_deps depstargets=%(mainmmake)-%(arch) deps=$(BD_DEPS$(BDID))
1846 #------------------------------------------------------------------------------
1849 #------------------------------------------------------------------------------
1850 # generate asm files from c files (for debugging purposes)
1853 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
1854 @$(TARGET_CC) -S $(CFLAGS) $(TARGET_CFLAGS) $< -c -o $@
1856 #------------------------------------------------------------------------------
1859 #------------------------------------------------------------------------------
1860 # Copy files from one directory to another.
1862 %define copy_files_q mmake=/A files=$(FILES) src=. dst=/A
1864 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
1866 GLOB_MKDIRS += %(dst)
1872 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC))/, $(file)) $(addprefix %(dst)/, $(file))))
1875 #------------------------------------------------------------------------------
1878 #------------------------------------------------------------------------------
1879 # Copy a directory recursively to another place, preserving the original
1880 # hierarchical structure
1882 # src: the source directory whose content will be copied
1883 # dst: the directory where to copy src's content. If not existing, it will be made.
1885 %define copy_dir_recursive mmake=/A src=. dst=/A excludefiles=
1887 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
1888 %(mmake)_FILES := $(shell cd $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC)); find . -path '*/CVS' -prune -o -path '*/.svn' -prune -o -name .cvsignore -prune -o -name mmakefile -prune -o -name mmakefile.src -prune $(%(mmake)_FILTER) -o -type f -print)
1889 %(mmake)_DIRS := $(sort $(dir $(%(mmake)_FILES)))
1891 %(mmake)_EXCLUDEFILES := $(addprefix ./,%(excludefiles))
1892 %(mmake)_FILES := $(filter-out $(%(mmake)_EXCLUDEFILES),$(%(mmake)_FILES))
1894 GLOB_MKDIRS += $(GENDIR)/$(CURDIR)
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 /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC)) all; \
1915 #------------------------------------------------------------------------------
1918 #------------------------------------------------------------------------------
1919 # Copy include files into the includes directories. There are currently
1920 # two include directories. One for building AROS $(AROS_INCLUDES) and one
1921 # for building tools that need to run on the host system $(GENINCDIR). The
1922 # $(GENINCDIR) path must not contain any references to the C runtime
1923 # library header files.
1925 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
1926 dir= compiler=target
1928 ifeq ($(findstring %(compiler),host kernel target),)
1929 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
1933 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),$(dir %(includes)))
1934 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,$(notdir %(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),$(dir %(includes)))
1949 BD_INCL_FILES2 := $(addprefix $(AROS_INCLUDES)/%(path)/,$(notdir %(includes)))
1951 BD_INCL_FILES2 := $(addprefix $(AROS_INCLUDES)/%(path)/,%(includes))
1954 BD_INCL_FILES += $(BD_INCL_FILES2)
1956 $(BD_INCL_FILES2) : $(AROS_INCLUDES)/%(path)/% : $(BD_INC_PATH)%
1961 %(mmake) : $(BD_INCL_FILES)
1965 $(BD_INCL_FILES) : | $(dir $(BD_INCL_FILES))
1966 GLOB_MKDIRS += $(dir $(BD_INCL_FILES))
1968 #------------------------------------------------------------------------------
1971 #------------------------------------------------------------------------------
1972 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
1973 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
1974 STUBS_MEM := $(addsuffix .o,$(STUBS))
1975 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
1976 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
1977 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
1979 #MM- linklibs : hidd-%(hidd)-stubs
1980 #MM- %(parenttarget): hidd-%(hidd)-stubs
1981 #MM hidd-%(hidd)-stubs : includes includes-copy
1982 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
1984 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
1987 $(STUBS_OBJ) : $(STUBS_SRC)
1988 %compile_q cmd="$(TARGET_CC) $(TARGET_CFLAGS)" opt=%(cflags) iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
1990 $(STUBS_DEP) : $(STUBS_SRC)
1991 %mkdepend_q flags=%(dflags)
1994 %mkdirs_q $(OBJDIR) $(LIBDIR)
1998 -@$(RM) $(HIDD_LIB) $(OBJDIR)
2000 DEPS := $(DEPS) $(STUBS_DEP)
2003 #------------------------------------------------------------------------------
2006 #------------------------------------------------------------------------------
2007 # Build an imported source tree which uses the configure script from the
2008 # autoconf package. This rule will try to "integrate" the produced files as
2009 # much as possible in the AROS build, for example by putting libraries in the
2010 # standard library directory, includes in the standard include directory, and
2011 # so on. You can however override this behaviour.
2013 # As a special "bonus" for you, the PROGDIR environment variable is defined to
2014 # be %(bindir) (or its deduced value) when running "make install", and
2015 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
2016 # configure script some more parameters whose value depends upon the PROGDIR
2017 # env var, so that the program gets all its stuff installed in the proper place
2018 # when building it, but when running it from inside AROS it can also find that
2019 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
2020 # the configuration parameters set when running ./configure
2022 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
2023 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
2024 # to the name which has to follow it.
2027 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) prefix= \
2028 aros_prefix= extraoptions= extracflags= nix_dir_layout= nix=no compiler=target \
2029 install_target=install preconfigure= postconfigure= postinstall= \
2033 %(mmake)-prefix := %(prefix)
2035 %(mmake)-prefix := $(AROS_CONTRIB)
2038 ifneq (%(aros_prefix),)
2039 %(mmake)-aros_prefix := %(aros_prefix)
2041 %(mmake)-aros_prefix := $(%(mmake)-prefix)
2045 %(mmake)-nix := -nix
2046 %(mmake)-volpfx := /
2047 %(mmake)-volsfx := /
2049 ifeq (%(nix_dir_layout),)
2050 %(mmake)-nix_dir_layout := yes
2053 %(mmake)-volsfx := :
2055 ifeq (%(nix_dir_layout),)
2056 %(mmake)-nix_dir_layout := no
2060 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
2062 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
2063 exec_prefix=$(%(mmake)-prefix) %(install_env)
2065 # Check if chosen compiler is valid
2066 ifeq ($(findstring %(compiler),host target kernel),)
2067 $(error unknown compiler %(compiler))
2070 # Set legacy 'host' variable based on chosen compiler
2071 ifeq (%(compiler),host)
2074 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
2076 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
2081 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
2083 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
2087 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
2088 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
2090 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
2091 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
2092 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2095 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
2096 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
2098 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2101 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
2103 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
2104 sbindir=$(%(mmake)-prefix) \
2105 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
2106 oldincludedir=$(AROS_INCLUDES) %(install_env)
2109 ifneq ($(DEBUG),yes)
2110 %(mmake)-s_flag = -s
2113 # Set up build environment, and options for configure script
2114 ifeq (%(compiler),host)
2116 CC="$(HOST_CC) $(HOST_CFLAGS)" \
2117 TARGET_CC="$(KERNEL_CC) $(KERNEL_CFLAGS) $(%(mmake)-s_flag)" \
2118 TARGET_AS="$(TARGET_AS)" OBJCOPY="$(OBJCOPY)" \
2119 TARGET_RANLIB="$(RANLIB)"
2120 %(mmake)-config_opts += --target=$(AROS_TARGET_CPU)-aros
2122 ifeq (%(compiler),target)
2124 CC="$(TARGET_CC) $(TARGET_CFLAGS) %(extracflags) $(LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)"\
2125 AS="$(TARGET_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)" AR="$(AR_PLAIN)"\
2126 TARGET_CC="$(KERNEL_CC) $(KERNEL_CFLAGS) $(%(mmake)-s_flag)"\
2127 TARGET_AS="$(TARGET_AS)" OBJCOPY="$(OBJCOPY)"\
2128 TARGET_RANLIB="$(RANLIB)"
2129 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)\
2130 --host=$(AROS_TARGET_CPU)-aros\
2131 --target=$(AROS_TARGET_CPU)-aros\
2133 --without-x --without-pic --disable-shared
2135 ifeq (%(compiler),kernel)
2137 CC="$(KERNEL_CC) $(KERNEL_CFLAGS) %(extracflags) $(%(mmake)-s_flag)"\
2138 AS="$(TARGET_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)"\
2139 TARGET_RANLIB="$(RANLIB)"
2140 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)\
2141 --host=$(AROS_TARGET_CPU)-aros\
2142 --target=$(AROS_TARGET_CPU)-aros --disable-nls\
2143 --without-x --without-pic --disable-shared
2147 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
2149 #MM- %(mmake) : setup includes linklibs-core %(mmake)-quick
2151 # Using -j1 in install_command may result in a warning but finally
2152 # it does its job. make install for gcc does not work reliably for -jN
2154 ifneq (%(install_target),)
2155 %(mmake)-install_command = \
2156 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2157 -C $(%(mmake)-pkgdir) %(install_target) -j1
2159 %(mmake)-uninstall_command = \
2160 $(RM) $(%(mmake)-installflag) && \
2161 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" \
2162 $(%(mmake)-install_opts) -C $(%(mmake)-pkgdir) uninstall
2164 %(mmake)-install_command := true
2165 %(mmake)-uninstall_command := true
2168 #MM- %(mmake)-quick : %(preconfigure) %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
2171 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
2173 $(%(mmake)-installflag) : $(%(mmake)-configflag)
2174 if ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q -C $(%(mmake)-pkgdir); then \
2175 $(RM) $(%(mmake)-installflag) && \
2176 $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)"\
2177 -C $(%(mmake)-pkgdir) && \
2178 $(%(mmake)-install_command) && \
2179 $(TOUCH) $@ -r $^; \
2182 $(%(mmake)-pkgdir)/.files-touched:
2183 %mkdirs_q $(%(mmake)-pkgdir)
2184 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/configure '{}' \; && \
2188 %(mmake)-uninstall :
2189 $(%(mmake)-uninstall_command)
2192 %(mmake)-configure : $(%(mmake)-configflag)
2194 $(%(mmake)-configflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
2195 $(%(mmake)-configflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2197 %mkdirs_q $(%(mmake)-pkgdir)
2198 cd $(%(mmake)-pkgdir) && \
2199 find . -name config.cache -exec $(RM) '{}' \; && \
2200 $(COMPILER_ENV) $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) \
2201 %(extraoptions) && \
2205 %(mmake)-clean : %(mmake)-uninstall
2206 @$(RM) $(%(mmake)-pkgdir)
2208 #------------------------------------------------------------------------------
2211 #------------------------------------------------------------------------------
2212 # Given an archive name, patches names and locations where to find them, fetch
2213 # the archive and the patches from any of those locations, unpack the archive
2214 # and then apply the patches.
2216 # Locations currently supported are http and ftp sites, plus local filesystem
2217 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
2218 # the fetch.sh script needs to be modified, since this macro relies on that script.
2222 # - mmake = mmaketarget
2223 # - archive_origins = list of locations where to find the archive. They are tried
2224 # in sequence, until the archive is found and fetching it
2225 # succeeded. If not specified, the current directory is assumed.
2226 # - archive = the archive name. Mandatory.
2227 # - suffixes = a list of suffixes to append to the the package name plus the
2228 # version. Each one of them is tried until a matching archive is
2229 # found. They are appended to patches and these are tried the
2230 # same way as packages are.
2231 # - location = the local directory where to put the fetched archive and patches.
2232 # If not specified, the directory specified by destination is used.
2233 # - destination = the directory to unpack the archive to.
2234 # If not specified, the current directory is assumed.
2235 # - patches_origins = list of locations where to find the patches. They are tried
2236 # in sequence, until a patch is found and fetching it
2237 # succeeded. If not specified, the current directory is assumed.
2238 # - patches_specs = list of "patch specs". A patch spec is of the form
2239 # patch_name[:[patch_subdir][:patch_opt]].
2241 # - patch_name = the name of the patch file
2242 # - patch_subdir = the directory within \destination\ where to
2244 # - patch_opt = any options to pass to the `patch' command
2245 # when applying the patch.
2247 # The patch_subdir and patch_opt fields are optional.
2249 %define fetch mmake=/A archive_origins=. archive=/A suffixes= location= destination=. \
2250 patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
2254 ifneq (%(location),)
2255 %(mmake)-location := %(location)
2257 %(mmake)-location := %(destination)
2262 $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
2263 -d %(destination) -po "%(patches_origins)" -p %(patches_specs)
2265 #------------------------------------------------------------------------------
2268 #------------------------------------------------------------------------------
2269 # This macro can aid in patch creation for fetched ports. It temporarily creates another
2270 # unpatched source tree and runs diff against this and a previously fetched and possibly
2271 # patched tree. Depending on what happens after patching during a normal build it might
2272 # give best results if the new patch is created directly after fetch.
2276 # - mmake = mmaketarget
2277 # - archive = archive base name
2278 # - suffixes = a list of suffixes to append to the the package name plus the
2279 # version. Each one of them is tried until a matching archive is
2281 # - destination = the directory to unpack the archive to.
2282 # - excludes = diff patterns to exclude files or directories from the patch
2284 %define create_patch mmake=/A archive=/A suffixes="tar.bz2 tar.gz" destination=/A excludes=
2288 ifneq (%(excludes),)
2289 %(mmake)-exclude := -X ./exclude.patterns
2294 @$(FETCH) -a %(archive) -s "%(suffixes)" -l $(PORTSSOURCEDIR) -d %(destination)/tmp ; \
2295 $(MV) %(destination)/%(archive) %(destination)/tmp/%(archive).aros ; \
2296 cd %(destination)/tmp ; \
2297 $(FOR) f in %(excludes) ; do \
2298 $(ECHO) $$f >> ./exclude.patterns ; \
2300 diff -ruN $(%(mmake)-exclude) \
2303 >$(SRCDIR)/$(CURDIR)/%(archive)-aros-new.diff ; \
2304 $(MV) %(destination)/tmp/%(archive).aros %(destination)/%(archive) ; \
2305 $(RM) %(destination)/tmp
2307 #------------------------------------------------------------------------------
2310 #------------------------------------------------------------------------------
2311 # Joins the features of %fetch and %build_with_configure, taking advantage of
2312 # the naming scheme of GNU packages. GNU packages names are in the form
2314 # <package name>-<version number>.<archive format suffix>
2316 # If a patch is provided, it *must* be named the following way:
2318 # <package name>-<version number>-aros.diff
2320 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
2321 # CD'ing into the archive's extracted directory.
2323 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
2324 # the %fetch_and_build macro only accept *one* patch for each package. It's up to you
2325 # to make that patch fully comprehensive.
2327 # NOTE: GNU packages are always compiled with *nix semantics turned on.
2331 # - mmake = the meta make target, as would be supplied to the %build_with_configure
2333 # - package = the GNU package name, sans version and archive format suffixes.
2334 # - version = the package's version number, or otherwise any other version string.
2335 # It gets appended to the package name to form the basename of the archive.
2336 # - suffixes = a list of suffixes to apped to the the package name plus the
2337 # version. Each one of them is tried until a matching archive is found.
2338 # Defaults to "tar.bz2 tar.gz".
2339 # - destination = same meaning as the one for the %fetch macro
2340 # - location = same meaning as the one for the %fetch macro
2341 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
2342 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
2344 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
2345 # - prefix = same meaning as the one for the %build_with_configure macro. Defaults to
2347 # - aros_prefix = same meaning as the one for the %build_with_configure macro. Defaults to
2349 # - extraoptions = same meaning as the one for the %build_with_configure macro.
2350 # - extracflags = same meaning as the one for the %build_with_configure macro.
2351 # - postinstall = same meaning as the one for the %build_with_configure macro.
2352 # - create_pkg = create a distributable package of the compiled sources, defaults to no
2354 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target version=/A suffixes="tar.bz2 tar.gz" \
2355 srcdir= package_repo= patch=no patch_repo= prefix= aros_prefix= extraoptions= extracflags= \
2356 preconfigure= postconfigure= postinstall= nix=no nix_dir_layout= create_pkg=no
2358 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
2359 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
2360 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
2361 #MM- %(mmake)-create-patch : %(mmake)-%(subpackage)-create-patch
2363 %(mmake)-archbase := %(package)-%(version)
2365 ifeq (%(compiler),host)
2366 %(mmake)-portdir := $(HOSTDIR)/Ports/%(package)
2368 %(mmake)-portdir := $(PORTSDIR)/%(package)
2372 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
2374 %(mmake)-prefix := %(prefix)
2377 ifneq (%(subpackage),)
2378 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
2380 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
2384 %(mmake)-%(subpackage)-srcdir := %(srcdir)
2386 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
2390 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-p1
2392 %(mmake)-%(subpackage)-patches_specs := ::
2395 %fetch mmake=%(mmake)-%(subpackage)-fetch archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
2396 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
2397 archive_origins=". %(package_repo)" \
2398 patches_specs="$(%(mmake)-%(subpackage)-patches_specs)" patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
2400 %create_patch mmake=%(mmake)-%(subpackage)-create-patch \
2401 archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" destination=$(%(mmake)-portdir)
2403 #MM- %(mmake) : %(mmake)-%(subpackage)
2405 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
2407 %(mmake)-%(subpackage)-package-basename := \
2408 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
2410 ifneq (%(create_pkg),no)
2411 %(mmake)-%(subpackage)-package := $(%(mmake)-%(subpackage)-package-basename).tar.bz2
2414 %build_with_configure mmake=%(mmake)-%(subpackage) package=%(package) compiler=%(compiler) \
2415 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-srcdir) \
2416 nix=%(nix) nix_dir_layout=%(nix_dir_layout) prefix="$(%(mmake)-prefix)" \
2417 aros_prefix="%(aros_prefix)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
2418 %(mmake)-%(subpackage)-make-package" extraoptions="%(extraoptions)" extracflags="%(extracflags)"
2420 .PHONY : %(mmake)-%(subpackage)-make-package %(mmake)-%(subpackage)-create-patch
2421 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
2424 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package)
2426 #There seems to be a bug, either with my clock or with make, 'cause it may happen
2427 #that $^ and $@ have exactly the same mtime, and in that case make tries
2428 #to rebuild $@ again, which would fail because the directory where
2429 #the package got installed would not exist anymore.
2430 #We work this around by using an if statement to manually check the mtimes.
2431 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
2432 @$(IF) test $(%(mmake)-installflag) -nt $@ || ! test -f $@; then \
2434 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
2435 mkdir -p "$(DISTDIR)/Packages" ; \
2436 mkdir -p "$(%(mmake)-prefix)" ; \
2437 cd $(%(mmake)-%(subpackage)-package-dir) ; \
2438 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
2439 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
2442 #------------------------------------------------------------------------------
2445 #------------------------------------------------------------------------------
2446 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2447 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
2448 aros_prefix=/GNU extraoptions= extracflags= preconfigure= postconfigure= postinstall=
2450 GNU_REPOSITORY := gnu://
2452 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
2453 suffixes="%(suffixes)" srcdir="%(srcdir)" \
2454 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
2455 patch="%(patch)" patch_repo="%(patch_repo)" \
2456 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" extracflags="%(extracflags)" \
2457 preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=yes
2460 #------------------------------------------------------------------------------
2463 #------------------------------------------------------------------------------
2464 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
2465 # that the package is a "Development" package, and as such it needs to be placed
2466 # under the $(AROS_DEVELOPMENT) directory, as a default.
2468 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
2469 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
2470 # "mmake" argument, because the metatarget is implicitely defined as
2472 # #MM- development-%(package)
2474 %define fetch_and_build_gnu_development package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2475 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPMENT) \
2476 aros_prefix=/Development preconfigure= postconfigure= postinstall= extraoptions= extracflags=
2478 #MM- development : development-%(package)
2481 %fetch_and_build_gnu mmake=development-%(package) package=%(package) subpackage="%(subpackage)" \
2482 version=%(version) suffixes="%(suffixes)" srcdir="%(srcdir)" \
2483 package_repo="%(package_repo)" patch="%(patch)" patch_repo="%(patch_repo)" prefix=%(prefix) \
2484 aros_prefix="%(aros_prefix)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" \
2485 extraoptions="%(extraoptions)" extracflags="%(extracflags)"
2488 #------------------------------------------------------------------------------
2490 # Builds a kickstart package in PKG format
2491 # mmake - target name
2492 # file - Destination file name with path
2493 # startup - The file which will be put first
2494 # Other arguments are self-explanatory
2496 %define make_package mmake=/A file=/A classes= devs= handlers= hidds= libs= res= startup=
2498 PKG_CLASSES := $(addsuffix .class, %(classes))
2499 PKG_DEVICES := $(addsuffix .device, %(devs))
2500 PKG_HANDLERS := $(addsuffix .handler, %(handlers))
2501 PKG_HIDD := $(addsuffix .hidd, %(hidds))
2502 PKG_LIBS := $(addsuffix .library, %(libs))
2503 PKG_RESOURCES := $(addsuffix .resource, %(res))
2505 PKG_FILES := %(startup) $(PKG_CLASSES) $(PKG_DEVICES) $(PKG_HANDLERS) $(PKG_HIDD) $(PKG_LIBS) $(PKG_RESOURCES)
2506 PKG_DIR := $(dir %(file))
2507 PKG_DEPS := $(addprefix $(PKGDIR)/, $(PKG_FILES))
2513 %(mmake)-quick : %(file)
2515 %(file): $(PKG_DIR) $(PKG_DEPS)
2516 @$(ECHO) Packaging $@...
2517 @$(SRCDIR)/tools/package/pkg c $@ $(PKGDIR) $(PKG_FILES)
2519 GLOB_MKDIRS += $(PKG_DIR)
2522 #------------------------------------------------------------------------------
2524 # Links a kickstart module in ELF format
2525 # Arguments are similar to make_package
2527 %define link_kickstart mmake=/A file=/A classes= devs= handlers= hidds= libs= res= startup= uselibs= map=
2529 KOBJ_CLASSES := $(addprefix $(KOBJSDIR)/, $(addsuffix _class.o, %(classes)))
2530 KOBJ_DEVICES := $(addprefix $(KOBJSDIR)/, $(addsuffix _device.o, %(devs)))
2531 KOBJ_HANDLERS := $(addprefix $(KOBJSDIR)/, $(addsuffix _handler.o, %(handlers)))
2532 KOBJ_HIDD := $(addprefix $(KOBJSDIR)/, $(addsuffix _hidd.o, %(hidds)))
2533 KOBJ_LIBS := $(addprefix $(KOBJSDIR)/, $(addsuffix _library.o, %(libs)))
2534 KOBJ_RES := $(addprefix $(KOBJSDIR)/, $(addsuffix _resource.o, %(res)))
2537 KOBJ_STARTUP := $(GENDIR)/$(RESIDENT_BEGIN).o
2539 KOBJ_STARTUP := %(startup)
2542 KOBJS := $(KOBJ_STARTUP) $(KOBJ_CLASSES) $(KOBJ_HANDLERS) $(KOBJ_LIBS) $(KOBJ_DEVICES) $(KOBJ_HIDD) $(KOBJ_RES)
2543 LDLIBS := $(addprefix -l, %(uselibs))
2544 DEPDIRS := $(dir %(file))
2545 DEPLIBS := $(addprefix lib,$(addsuffix .a, %(uselibs)))
2547 TMP_LDFLAGS := -L$(LIBDIR)
2549 ifneq ($(USER_LIBDIR),)
2550 ALL_USERLIBS := $(notdir $(wildcard $(USER_LIBDIR)/lib*.a))
2551 USER_DEPLIBS := $(addprefix $(USER_LIBDIR)/, $(filter $(ALL_USERLIBS),$(DEPLIBS)))
2552 DEPLIBS := $(filter-out $(ALL_USERLIBS),$(DEPLIBS))
2553 TMP_LDFLAGS := -L$(USER_LIBDIR) $(TMP_LDFLAGS)
2556 DEPLIBS := $(addprefix $(LIBDIR)/, $(DEPLIBS))
2559 TMP_LDFLAGS += $(GENMAP) %(map)
2560 DEPDIRS += $(dir %(map))
2567 %(mmake)-quick : %(file)
2569 %(file): $(KOBJS) $(DEPDIRS) $(DEPLIBS) $(USER_DEPLIBS)
2570 @$(ECHO) Linking $@...
2571 @$(TARGET_CC) -o $@ $(KOBJS) $(LDFLAGS) $(NOSTARTUP_LDFLAGS) $(TMP_LDFLAGS) $(LDLIBS)
2573 GLOB_MKDIRS += $(DEPDIRS)
2577 #------------------------------------------------------------------------------
2578 # Link %(objs) to binary blob in %(file) using %(name) as name of embedded binary object
2579 # 'start' is an optional starting address
2580 # 'ldflags' is optional additional flags for the linker
2581 %define rule_link_binary file=/A name=/A objs=/A start=0 ldflags=
2583 BD_OUTDIR := $(dir %(file))
2584 BD_TMPDIR := $(GENDIR)/$(CURDIR)
2586 %(file) : %(objs) $(BD_OUTDIR)
2587 @$(ECHO) Linking $@...
2588 @$(KERNEL_LD) -melf_i386 --oformat=binary -e %(start) -Ttext=%(start) -o $(BD_TMPDIR)/%(name) %(objs)
2589 @cd $(BD_TMPDIR) && $(KERNEL_LD) -r --format binary %(ldflags) %(name) -o $@
2591 GLOB_MKDIRS += $(BD_OUTDIR)