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 # Convert the ISO-8859-1 string in %(string) to the host's locale (if necessary)
14 %define localisestr string= var=
15 ifeq (,$(findstring "ISO-8859-1",$(LOCALE)))
16 %(var) := $(shell echo %(string) | iconv -f iso-8859-1 )
22 #------------------------------------------------------------------------------
23 # Compile the file %(from) to %(to) with %(cmd). Write any errors to %(err)
24 # and use the options in %(opt). Use %(iquote) and %(iquote_end) for supplying -iquote or -I- flags
25 %define compile_q cmd="$(TARGET_CC) $(TARGET_CFLAGS)" opt=$(CFLAGS) from=$< to=$@ iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
26 @$(ECHO) "Compiling $(if $(filter /%,%(from)),$(if $(filter $(SRCDIR)/%,$(abspath %(from))),$(patsubst $(SRCDIR)/%,%,$(abspath %(from))),$(patsubst $(TOP)/%,%,$(abspath %(from)))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/%(from))))"
27 @$(IF) %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -c %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
28 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
29 $(ECHO) "%(from): %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -c %(from) -o %(to)" >> $(GENDIR)/errors ; \
30 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors ; \
35 $(ECHO) "Compile failed: %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -c %(from) -o %(to)" 1>&2 ; \
36 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
40 #------------------------------------------------------------------------------
43 #------------------------------------------------------------------------------
44 # Assemble the file %(from) to %(to) with %(cmd) with the options in %(opt).
45 %define assemble_q cmd=$(CC) opt=$(AFLAGS) from=$< to=$@
46 @$(ECHO) "Assembling $(notdir %(from))..."
47 @$(IF) %(cmd) %(opt) %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
48 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
49 $(ECHO) "$(notdir %(from)): %(cmd) %(opt) %(from) -o %(to)" >> $(GENDIR)/errors ; \
50 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
55 $(ECHO) "Assemble failed: %(cmd) %(opt) %(from) -o %(to)" 1>&2 ; \
56 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
60 #-------------------------------------------------------------------------
63 #------------------------------------------------------------------------------
64 # Link a specified number of objects to an executable
65 %define link_q cmd=$(AROS_CC) opt=$(LDFLAGS) from=$< to=$@ libs=$(LIBS) strip=$(STRIP)
66 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,%(to))..."
67 @$(IF) %(cmd) %(from) -o %(to) %(opt) %(libs) 2>&1 > $(GENDIR)/cerrors 2>&1 ; then \
68 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
69 $(ECHO) "%(to): %(cmd) %(from) -o %(to) %(opt) %(libs)" >> $(GENDIR)/errors ; \
70 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
75 $(ECHO) "Link failed: %(cmd) %(from) -o %(to) %(opt) %(libs)" 1>&2 ; \
76 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
81 #------------------------------------------------------------------------------
84 #-------------------------------------------------------------------------
85 # Link a module based upon a number of arguments and the standard $(LIBS)
86 # and $(DEPLIBS) make variables.
88 %define link_module_q cmd=$(AROS_CC) err="$(notdir $@).err" objs=/A endtag= module=$(MODULE) ldflags=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
89 @$(ECHO) "Building $(subst $(TARGETDIR)/,,$@) ..."
90 @if %(cmd) $(NOSTARTUP_LDFLAGS) \
91 $(GENMAP) %(objdir)/%(module).map \
92 %(objs) %(libs) %(ldflags) %(endtag) \
93 -o $@ 2>&1 > %(objdir)/%(err); \
95 cat %(objdir)/%(err); \
97 echo "%(cmd) $(NOSTARTUP_LDFLAGS) $(GENMAP) %(objdir)/%(module).map %(objs) %(libs) %(ldflags) %(endtag) -o $@"; \
98 cat %(objdir)/%(err); \
102 @if $(TEST) ! -s %(objdir)/%(err) ; then $(RM) %(objdir)/%(err) ; fi
105 #------------------------------------------------------------------------------
108 #------------------------------------------------------------------------------
110 %define mklib_q ar=$(AR) ranlib=$(RANLIB) to=$@ from=$(OBJS)
111 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,%(to))..."
115 #------------------------------------------------------------------------------
118 #------------------------------------------------------------------------------
119 # Create the dependency file %(to) for %(from)
120 %define mkdepend_q flags=$(CFLAGS) from=$< to=$@ cc=$(AROS_CC)
121 %mkdir_q dir="$(dir %(to))"
122 @$(ECHO) "Makedepend $(if $(filter /%,%(from)),$(if $(filter $(SRCDIR)/%,$(abspath %(from))),$(patsubst $(SRCDIR)/%,%,$(abspath %(from))),$(patsubst $(TOP)/%,%,$(abspath %(from)))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/%(from))))..."
123 @AROS_CC="%(cc)" $(MKDEPEND) %(flags) -I$(TOP)/$(CURDIR) -I$(SRCDIR)/$(CURDIR) %(from) -o %(to)
125 #------------------------------------------------------------------------------
128 #------------------------------------------------------------------------------
129 # Create one directory without any output
130 %define mkdir_q dir=.
131 @$(IF) $(TEST) ! -d %(dir) ; then $(MKDIR) %(dir) ; else $(NOP) ; fi
133 #------------------------------------------------------------------------------
136 #------------------------------------------------------------------------------
137 # Create several directories without any output
138 %define mkdirs_q dirs=/M
139 @$(FOR) dir in %(dirs) ; do \
140 $(IF) $(TEST) ! -d $$dir ; then $(MKDIR) $$dir ; else $(NOP) ; fi ; \
143 #------------------------------------------------------------------------------
146 #############################################################################
147 #############################################################################
149 ## Here are the mmakefile macros that are used to do certain tasks in a ##
150 ## mmakefile. They consist of one or more full makefile rules. ##
151 ## In general the files generated in these macros are also defined as ##
152 ## make targets so that they can be used as a dependency in other rules ##
154 #############################################################################
155 #############################################################################
157 #------------------------------------------------------------------------------
158 # Generate a unique id for each of the %build... rules
159 %define buildid targets=/A
161 ifneq ($(filter $(TARGET),%(targets)),)
162 BDTARGETID := $(BDID)
165 #------------------------------------------------------------------------------
168 #------------------------------------------------------------------------------
169 # Copy file %(from) to %(to) in a makefile rule
170 %define rule_copy from=/A to=/A
174 #------------------------------------------------------------------------------
177 #------------------------------------------------------------------------------
178 # Copy the files %(files) to %(targetdir). For each file in %(files),
179 # %(srcdir)/file is copied to %(targetdir)/file. The targetdir and the
180 # appropriate subdirs are not generated by this rule so they have to be
182 %define rule_copy_multi files=/A targetdir=/A srcdir=.
184 $(addprefix %(targetdir)/,%(files)) : %(targetdir)/% : %(srcdir)/%
187 #------------------------------------------------------------------------------
190 #------------------------------------------------------------------------------
191 # Copy the files %(files) to %(targetdir). For each file in %(files),
192 # %(srcdir)/file is copied to %(targetdir)/file if these files are different.
193 # %(stampfile) is used to keep track of when the last time the comparison has
194 # been done. The targetdir and the appropriate subdirs are not generated by
195 # this rule so they have to be present.
196 %define rule_copy_diff_multi files=/A targetdir=/A srcdir=. \
197 stampfile=$(TMP_SRCDIR)/.copy_stamp
199 TMP_SRCDIR := %(srcdir)
201 $(addprefix %(targetdir)/,%(files)) : | %(stampfile)
203 %(stampfile) : COPYSRCDIR := %(srcdir)
204 %(stampfile) : TGTDIR := %(targetdir)
205 %(stampfile) : FILES := %(files)
206 %(stampfile) : $(addprefix %(srcdir)/,%(files))
207 @for f in $(FILES); do \
208 $(IF) ! $(CMP) -s $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; then \
209 $(CP) $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; \
214 #------------------------------------------------------------------------------
217 #------------------------------------------------------------------------------
218 # Will join all the files in %(from) to %(to). When text is specified it will
220 # Restriction: at the moment when using a non-empty target dir %(from) may
222 %define rule_join to=/A from=/A text=
230 #------------------------------------------------------------------------------
233 #------------------------------------------------------------------------------
234 # Include the dependency files and add some internal rules
235 # When depstargets is provided the depencies will only be included when one of
236 # these targets is the $(TARGET). Otherwise the dependencies will only be
237 # included when the $(TARGET) is not for setup or clean
238 %define include_deps deps=$(DEPS)/M depstargets=
240 ifneq (%(depstargets),)
241 ifneq ($(findstring $(TARGET),%(depstargets)),)
245 ifeq (,$(filter clean% %clean %clean% setup% includes% %setup,$(TARGET)))
251 #------------------------------------------------------------------------------
254 #------------------------------------------------------------------------------
255 # Create the directories %(dirs). The creation will be done by adding rules to
256 # the %(setuptarget) make target with setup as the default.
257 %define rule_makedirs dirs=/A setuptarget=setup
259 %(setuptarget) :: %(dirs)
261 GLOB_MKDIRS += %(dirs)
264 #------------------------------------------------------------------------------
267 #------------------------------------------------------------------------------
268 # Generate a rule to compile a C source file to an object file and generate
269 # the dependency file. Basename may contain a directory part, then the source
270 # file has to be in that directory. The generated file will be put in the
271 # object directory without the directory.
273 # - basename: the basename of the file to compile. Use % for a wildcard rule
274 # - cflags (default $(CFLAGS)): the C flags to use for compilation
275 # - dflags: the flags used during creation of dependency file. If not specified
276 # the same value as cflags will be used
277 # - targetdir: the directory to put the .o file and the .d file. By default
278 # it is put in the same directory as the .c file
279 %define rule_compile basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target
282 TMP_TARGETBASE := %(basename)
284 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
287 # Adjust compiler flags to suit C
288 TMP_CFLAGS := %(cflags)
289 TMP_CFLAGS := $(subst -fpermissive,, $(TMP_CFLAGS))
291 ifeq ($(findstring %(compiler),host kernel target),)
292 $(error unknown compiler %(compiler))
294 ifeq (%(compiler),target)
295 BD_LINK := $(TARGET_CC)
296 BD_STRIP := $(TARGET_STRIP)
297 $(TMP_TARGETBASE).o : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
298 $(TMP_TARGETBASE).d : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
299 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
300 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
301 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
302 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
304 ifeq (%(compiler),host)
305 BD_LINK := $(HOST_CC)
306 BD_STRIP := $(HOST_STRIP)
307 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
308 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
309 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
310 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
311 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
312 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
314 ifeq (%(compiler),kernel)
315 BD_LINK := $(KERNEL_CC) $(KERNEL_LDFLAGS)
316 BD_STRIP := $(ECHO) >/dev/null
317 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
318 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
319 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
320 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
321 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
322 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
325 $(TMP_TARGETBASE).o : CFLAGS := $(TMP_CFLAGS)
326 $(TMP_TARGETBASE).o : %(basename).c
327 %compile_q cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
331 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(cflags)
333 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(cflags)
337 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(dflags)
339 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(dflags)
342 $(TMP_TARGETBASE).d : %(basename).c
343 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
345 #------------------------------------------------------------------------------
348 #------------------------------------------------------------------------------
349 # Generate a rule to compile a C++ source file to an object file and generate
350 # the dependency file. Basename may contain a directory part, then the source
351 # file has to be in that directory. The generated file will be put in the
352 # object directory without the directory.
354 # - basename: the basename of the file to compile. Use % for a wildcard rule
355 # - cflags (default $(CFLAGS)): the C flags to use for compilation
356 # - dflags: the flags used during creation of dependency file. If not specified
357 # the same value as cflags will be used
358 # - targetdir: the directory to put the .o file and the .d file. By default
359 # it is put in the same directory as the .c file
360 %define rule_compile_cxx basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target
363 TMP_TARGETBASE := %(basename)
365 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
368 # Adjust compiler flags to suit C++
369 TMP_CXXFLAGS := %(cflags)
370 TMP_CXXFLAGS := -fno-rtti -fno-exceptions -fno-check-new $(TMP_CXXFLAGS) -isystem $(AROS_DEVELOPMENT)/include
371 TMP_CXXFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(TMP_CXXFLAGS)))
373 ifeq ($(findstring %(compiler),host kernel target),)
374 $(error unknown compiler %(compiler))
376 ifeq (%(compiler),target)
377 BD_LINK := $(AROS_CXX)
378 BD_STRIP := $(TARGET_STRIP)
379 $(TMP_TARGETBASE).o : TMP_CMD:=$(AROS_CXX) $(TARGET_CFLAGS)
380 $(TMP_TARGETBASE).d : TMP_CMD:=$(AROS_CXX) $(TARGET_CFLAGS)
381 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
382 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
383 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
384 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
386 ifeq (%(compiler),host)
387 BD_LINK := $(HOST_CXX)
388 BD_STRIP := $(HOST_STRIP)
389 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CXX)
390 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CXX)
391 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
392 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
393 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
394 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
396 ifeq (%(compiler),kernel)
397 BD_LINK := $(KERNEL_CXX) $(KERNEL_LDFLAGS)
398 BD_STRIP := $(ECHO) >/dev/null
399 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CXX) $(KERNEL_CFLAGS)
400 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CXX) $(KERNEL_CFLAGS)
401 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
402 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
403 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
404 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
407 $(TMP_TARGETBASE).o : CFLAGS := $(TMP_CXXFLAGS)
408 $(TMP_TARGETBASE).o : %(basename).cpp
409 %compile_q cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
413 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix $(TMP_CXXFLAGS)
415 $(TMP_TARGETBASE).d : TMP_DFLAGS:=$(TMP_CXXFLAGS)
419 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(dflags)
421 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(dflags)
424 $(TMP_TARGETBASE).d : %(basename).cpp
425 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
427 #------------------------------------------------------------------------------
430 #------------------------------------------------------------------------------
431 # Generate a rule to compile multiple C source files to an object file and
432 # generate the corresponding dependency files. The generated file will be put
433 # in the object directory without the directory part of the source file.
435 # - basenames: the basenames of the files to compile. The names may include
436 # relative or absolute path names. No wildcard is allowed
437 # - cflags (default $(CFLAGS)): the C flags to use for compilation
438 # - dflags: the flags used during creation of dependency file. If not specified
439 # the same value as cflags will be used
440 # - targetdir: the directory to put the .o file and the .d file. By default
441 # it is put in the same directory as the .c file. When targetdir is not
442 # empty, path names will be stripped from the file names so that all files
443 # are in that dir and not in subdirectories.
444 # - compiler (default target): compiler to use, target, kernel or host
445 %define rule_compile_multi basenames=/A cflags=$(CFLAGS) dflags= targetdir= \
449 TMP_TARGETS := $(addsuffix .o,%(basenames))
450 TMP_DTARGETS := $(addsuffix .d,%(basenames))
453 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
454 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
455 TMP_WILDCARD := %(targetdir)/%
457 # Be sure that all .c files are generated
458 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .c,%(basenames))
460 # Be sure that all .c files are found
461 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
462 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
463 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
465 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
466 vpath %.c $(TMP_DIRS)
471 ifeq ($(findstring %(compiler),host kernel target),)
472 $(error unknown compiler %(compiler))
474 ifeq (%(compiler),target)
475 BD_LINK := $(TARGET_CC)
476 BD_STRIP := $(TARGET_STRIP)
477 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
478 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
479 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
481 ifeq (%(compiler),host)
482 BD_LINK := $(HOST_CC)
483 BD_STRIP := $(HOST_STRIP)
484 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_CC)
485 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
486 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
488 ifeq (%(compiler),kernel)
489 BD_LINK := $(KERNEL_CC) $(KERNEL_LDFLAGS)
490 BD_STRIP := $(ECHO) >/dev/null
491 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
492 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
493 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
496 $(TMP_TARGETS) : CFLAGS := %(cflags)
497 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.c
498 %compile_q cmd=$(CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
501 $(TMP_DTARGETS) : DFLAGS:=%(cflags)
503 $(TMP_DTARGETS) : DFLAGS:=%(dflags)
505 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.c
506 %mkdepend_q cc=$(CMD) flags=$(DFLAGS)
508 #------------------------------------------------------------------------------
511 #------------------------------------------------------------------------------
512 # Generate a rule to compile multiple C++ source files to an object file and
513 # generate the corresponding dependency files. The generated file will be put
514 # in the object directory without the directory part of the source file.
516 # - basenames: the basenames of the files to compile. The names may include
517 # relative or absolute path names. No wildcard is allowed. basenames will be
518 # matched to supported AROS_CXXEXTS.
519 # - cflags (default $(CFLAGS)): the C flags to use for compilation
520 # - dflags: the flags used during creation of dependency file. If not specified
521 # the same value as cflags will be used
522 # - targetdir: the directory to put the .o file and the .d file. By default
523 # it is put in the same directory as the .c file. When targetdir is not
524 # empty, path names will be stripped from the file names so that all files
525 # are in that dir and not in subdirectories.
526 # - compiler (default target): compiler to use, target, kernel or host
527 %define rule_compile_cxx_multi basenames=/A cflags=$(CFLAGS) dflags= \
528 targetdir= compiler=target
530 # Adjust compiler flags to suit C++
531 TMP_CXXFLAGS := %(cflags)
532 TMP_CXXFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(TMP_CXXFLAGS)))
533 TMP_CXXFLAGS := -fno-rtti -fno-exceptions -fno-check-new $(TMP_CXXFLAGS) -isystem $(AROS_DEVELOPMENT)/include
535 TMP_CXXABSBASENAMES := $(foreach TMP_CXXBASE,%(basenames),$(if $(filter /%,$(TMP_CXXBASE)),$(TMP_CXXBASE),$(abspath $(SRCDIR)/$(CURDIR)/$(TMP_CXXBASE))))
536 ifneq ($(TMP_CXXABSBASENAMES),)
537 TMP_CXXBASENAMES := $(basename $(TMP_CXXABSBASENAMES))
539 # Identify the "real" c++ files from the passed in basenames
540 TMP_CXXFILES := $(strip $(foreach TMP_CXXBASE,$(TMP_CXXABSBASENAMES), $(firstword $(wildcard $(foreach TMP_EXT, $(AROS_CXXEXTS),$(addsuffix .$(TMP_EXT),$(TMP_CXXBASE)))))))
543 TMP_CXXTARGETS := $(notdir $(TMP_CXXBASENAMES:=.o))
544 TMP_CXXDTARGETS := $(notdir $(TMP_CXXBASENAMES:=.d))
547 TMP_CXXTARGETS := $(addprefix %(targetdir)/,$(notdir $(TMP_CXXBASENAMES:=.o)))
548 TMP_CXXDTARGETS := $(addprefix %(targetdir)/,$(notdir $(TMP_CXXBASENAMES:=.d)))
549 TMP_WILDCARD := %(targetdir)/%
551 # Be sure that all source files are generated
552 $(TMP_CXXTARGETS) $(TMP_CXXDTARGETS) : | $(TMP_CXXFILES)
555 ifeq ($(findstring %(compiler),host kernel target),)
556 $(error unknown compiler %(compiler))
558 ifeq (%(compiler),target)
559 BD_LINK := $(AROS_CXX)
560 BD_STRIP := $(TARGET_STRIP)
561 TMP_CXXCMD:=$(AROS_CXX) $(TARGET_CFLAGS)
562 TMP_CXXIQUOTE:=$(CFLAGS_IQUOTE)
563 TMP_CXXIQUOTE_END:=$(CFLAGS_IQUOTE_END)
565 ifeq (%(compiler),host)
566 BD_LINK := $(HOST_CXX)
567 BD_STRIP := $(TARGET_STRIP)
568 TMP_CXXCMD:=$(HOST_CXX)
569 TMP_CXXIQUOTE:=$(HOST_IQUOTE)
570 TMP_CXXIQUOTE_END:=$(HOST_IQUOTE_END)
572 ifeq (%(compiler),kernel)
573 BD_LINK := $(KERNEL_CXX) $(KERNEL_LDFLAGS)
574 BD_STRIP := $(ECHO) >/dev/null
575 TMP_CXXCMD:=$(KERNEL_CXX) $(KERNEL_CFLAGS)
576 TMP_CXXIQUOTE:=$(KERNEL_IQUOTE)
577 TMP_CXXIQUOTE_END:=$(KERNEL_IQUOTE_END)
581 TMP_CXXDFLAGS:=$(TMP_CXXFLAGS)
583 ifeq (%(dflags),%(cflags))
584 TMP_CXXDFLAGS:=$(TMP_CXXFLAGS)
586 TMP_CXXDFLAGS:=%(dflags)
590 define cxx_multi_recipe_template
592 %compile_q cmd=$(TMP_CXXCMD) opt=$(TMP_CXXFLAGS) iquote=$(TMP_CXXIQUOTE) iquote_end=$(TMP_CXXIQUOTE_END) from=$(2) to=$(1).o
595 %mkdepend_q cc=$(TMP_CXXCMD) flags=$(TMP_CXXDFLAGS) from=$(2) to=$(1).d
598 $(foreach TMP_CXXFILE,$(TMP_CXXFILES),$(eval $(call cxx_multi_recipe_template,$(notdir $(basename $(TMP_CXXFILE))),$(TMP_CXXFILE))))
600 $(foreach TMP_CXXFILE,$(TMP_CXXFILES),$(eval $(call cxx_multi_recipe_template,$(addprefix %(targetdir)/,$(notdir $(basename $(TMP_CXXFILE)))),$(TMP_CXXFILE))))
604 #------------------------------------------------------------------------------
607 #------------------------------------------------------------------------------
608 # Generate a rule to compile an ObjC source file to an object file and generate
609 # the dependency file. Basename may contain a directory part, then the source
610 # file has to be in that directory. The generated file will be put in the
611 # object directory without the directory.
613 # - basename: the basename of the file to compile. Use % for a wildcard rule
614 # - cflags (default $(CFLAGS)): the C flags to use for compilation
615 # - dflags: the flags used during creation of dependency file. If not specified
616 # the same value as cflags will be used
617 # - targetdir: the directory to put the .o file and the .d file. By default
618 # it is put in the same directory as the .m file
619 %define rule_compile_objc basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target
622 TMP_TARGETBASE := %(basename)
624 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
627 # Adjust compiler flags to suit ObjC
628 TMP_OBJCFLAGS := %(cflags)
629 TMP_OBJCFLAGS := $(TMP_OBJCFLAGS) -isystem $(AROS_DEVELOPMENT)/include
630 TMP_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(TMP_OBJCFLAGS)))
632 # Define the use of cross compiler
633 ifeq ($(TARGET_OBJC),)
634 TMP_CC := $(TARGET_CC)
636 TMP_CC := $(TARGET_OBJC)
639 ifeq ($(findstring %(compiler),host kernel target),)
640 $(error unknown compiler %(compiler))
642 ifeq (%(compiler),target)
644 BD_STRIP := $(TARGET_STRIP)
645 $(TMP_TARGETBASE).o : TMP_CMD:=$(TMP_CC) $(TARGET_CFLAGS)
646 $(TMP_TARGETBASE).d : TMP_CMD:=$(TMP_CC) $(TARGET_CFLAGS)
647 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
648 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
649 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
650 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
652 ifeq (%(compiler),host)
653 BD_LINK := $(HOST_CC)
654 BD_STRIP := $(HOST_STRIP)
655 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
656 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
657 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
658 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
659 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
660 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
662 ifeq (%(compiler),kernel)
663 BD_LINK := $(KERNEL_CC) $(KERNEL_LDFLAGS)
664 BD_STRIP := $(ECHO) >/dev/null
665 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
666 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
667 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
668 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
669 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
670 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
673 $(TMP_TARGETBASE).o : CFLAGS := $(TMP_OBJCFLAGS)
674 $(TMP_TARGETBASE).o : %(basename).m
675 %compile_q cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
679 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix $(TMP_OBJCFLAGS)
681 $(TMP_TARGETBASE).d : TMP_DFLAGS:=$(TMP_OBJCFLAGS)
685 $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(dflags)
687 $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(dflags)
690 $(TMP_TARGETBASE).d : %(basename).m
691 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
693 #------------------------------------------------------------------------------
695 #------------------------------------------------------------------------------
696 # Generate a rule to compile multiple ObjC source files to an object file and
697 # generate the corresponding dependency files. The generated file will be put
698 # in the object directory without the directory part of the source file.
700 # - basenames: the basenames of the files to compile. The names may include
701 # relative or absolute path names. No wildcard is allowed
702 # - cflags (default $(CFLAGS)): the C flags to use for compilation
703 # - dflags: the flags used during creation of dependency file. If not specified
704 # the same value as cflags will be used
705 # - targetdir: the directory to put the .o file and the .d file. By default
706 # it is put in the same directory as the .m file. When targetdir is not
707 # empty, path names will be stripped from the file names so that all files
708 # are in that dir and not in subdirectories.
709 # - compiler (default target): compiler to use, target, kernel or host
710 %define rule_compile_objc_multi basenames=/A cflags=$(CFLAGS) dflags= \
711 targetdir= compiler=target
713 # Adjust compiler flags to suit ObjC
714 TMP_OBJCFLAGS := %(cflags)
715 TMP_OBJCFLAGS := $(TMP_OBJCFLAGS) -isystem $(AROS_DEVELOPMENT)/include
716 TMP_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(TMP_OBJCFLAGS)))
719 TMP_TARGETS := $(addsuffix .o,%(basenames))
720 TMP_DTARGETS := $(addsuffix .d,%(basenames))
723 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,%(basenames)))
724 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,%(basenames)))
725 TMP_WILDCARD := %(targetdir)/%
727 # Be sure that all .m files are generated
728 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .m,%(basenames))
730 # Be sure that all .m files are found
731 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
732 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
733 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
735 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
736 vpath %.m $(TMP_DIRS)
740 # Define the use of cross compiler
741 ifeq ($(TARGET_OBJC),)
742 TMP_CC := $(TARGET_CC)
744 TMP_CC := $(TARGET_OBJC)
747 ifeq ($(findstring %(compiler),host kernel target),)
748 $(error unknown compiler %(compiler))
750 ifeq (%(compiler),target)
752 BD_STRIP := $(TARGET_STRIP)
753 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TMP_CC) $(TARGET_CFLAGS)
754 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
755 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
757 ifeq (%(compiler),host)
758 BD_LINK := $(HOST_OBJC)
759 BD_STRIP := $(HOST_STRIP)
760 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_OBJC)
761 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
762 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
764 ifeq (%(compiler),kernel)
765 BD_LINK := $(KERNEL_OBJC) $(KERNEL_LDFLAGS)
766 BD_STRIP := $(ECHO) >/dev/null
767 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_OBJC) $(KERNEL_CFLAGS)
768 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
769 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
772 $(TMP_TARGETS) : CFLAGS := $(TMP_OBJCFLAGS)
773 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.m
774 %compile_q cmd=$(CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
777 $(TMP_DTARGETS) : DFLAGS:=$(TMP_OBJCFLAGS)
779 ifeq (%(dflags),%(cflags))
780 $(TMP_DTARGETS) : DFLAGS:=$(TMP_OBJCFLAGS)
782 $(TMP_DTARGETS) : DFLAGS:=%(dflags)
785 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.m
786 %mkdepend_q cc=$(CMD) flags=$(DFLAGS)
788 #------------------------------------------------------------------------------
791 #------------------------------------------------------------------------------
792 # Make an alias from one arch specific build to another arch.
794 # - mainmmake: the mmake of the module in the main tree
795 # - arch: the current arch
796 # - alias: the alias to which this should point
797 %define rule_archalias mainmmake=\A arch=\A alias=\A
799 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
801 #------------------------------------------------------------------------------
804 #------------------------------------------------------------------------------
805 # Generate a rule to assemble a source file to an object file. Basename may
806 # contain a directory part, then the source file has to be in that directory.
807 # The generated file will be put in the object directory without the directory.
809 # - basename: the basename of the file to compile. Use % for a wildcard rule
810 # - flags (default $(AFLAGS)): the asm flags to use for assembling
811 # - targetdir: the directory to put the .o file in. By default it is put in the
812 # same directory as the .s file
813 %define rule_assemble basename=/A aflags=$(AFLAGS) targetdir=
816 %(basename).o : AFLAGS := %(aflags)
817 %(basename).o : %(basename).s
819 %(basename).o : %(basename).S
823 %(targetdir)/$(notdir %(basename)).o : AFLAGS := %(aflags)
824 %(targetdir)/$(notdir %(basename)).o : %(basename).s
826 %(targetdir)/$(notdir %(basename)).o : %(basename).S
831 #------------------------------------------------------------------------------
834 #------------------------------------------------------------------------------
835 # Generate a rule to assemble multiple source files to an object file. The
836 # generated file will be put in the object directory with the directory part
837 # of the source file stripped off.
839 # - basenames: the basenames of the files to compile. The names may include
840 # relative or absolute path names. No wildcard is allowed
841 # - aflags (default $(AFLAGS)): the flags to use for assembly
842 # - targetdir: the directory to put the .o file and the .d file. By default
843 # it is put in the same directory as the .c file. When targetdir is not
844 # empty, path names will be stripped from the file names so that all files
845 # are in that dir and not in subdirectories.
846 %define rule_assemble_multi basenames=/A aflags=$(AFLAGS) targetdir= suffix=.s compiler=target
849 TMP_TARGETS := $(addsuffix .o,%(basenames))
852 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
853 TMP_WILDCARD := %(targetdir)/%
855 # Be sure that all .s files are generated
856 $(TMP_TARGETS) : | $(addsuffix %(suffix),%(basenames))
858 # Be sure that all .c files are found
859 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
860 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
861 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
863 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
864 vpath %%(suffix) $(TMP_DIRS)
869 ifeq ($(findstring %(compiler),host kernel target),)
870 $(error unknown compiler %(compiler))
872 ifeq (%(compiler),target)
873 $(TMP_TARGETS) : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
875 ifeq (%(compiler),host)
876 $(TMP_TARGETS) : TMP_CMD:=$(HOST_CC)
878 ifeq (%(compiler),kernel)
879 $(TMP_TARGETS) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
882 $(TMP_TARGETS) : AFLAGS := %(aflags)
883 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %%(suffix)
884 %assemble_q cmd=$(TMP_CMD) opt=$(AFLAGS)
886 #------------------------------------------------------------------------------
889 #------------------------------------------------------------------------------
890 # Link %(objs) to %(prog) using the libraries in %(uselibs)
891 %define rule_link_prog prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
892 usehostlibs= usestartup=yes detach=no nix=no cmd=$(AROS_CC) strip=$(TARGET_STRIP)
897 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
899 ifeq (%(usestartup),no)
900 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
903 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
906 # Make a list of the lib files this program depends on.
907 # In LDFLAGS remove white space between -L and directory
908 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
909 # Filter out only the libdirs and remove -L
910 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
912 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
913 # Add normal linklib path
914 TMP_DIRS += $(AROS_LIB)/
915 # add lib and .a to static linklib names
916 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(TMP_EXTRA_LIBS)))
917 ifeq (%(usestartup),yes)
918 TMP_LIBS += startup.o
923 # search for the linklibs in the given path, ignore ones not found
924 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
925 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
928 %(prog) : OBJS := %(objs)
929 %(prog) : LDFLAGS := %(ldflags) $(TMP_EXTRA_LDFLAGS)
930 %(prog) : LIBS := $(addprefix -l,%(uselibs) $(TMP_EXTRA_LIBS) %(usehostlibs))
931 %(prog) : %(objs) $(TMP_DEPLIBS)
932 %link_q cmd=%(cmd) strip=%(strip) from=$(OBJS) opt=$(LDFLAGS) libs=$(LIBS)
934 #------------------------------------------------------------------------------
937 #------------------------------------------------------------------------------
938 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
939 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
940 %define rule_link_progs progs=/A targetdir=$(AROSDIR)/$(CURDIR) nix=%(nix) \
941 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
942 usestartup=yes detach=no cmd=$(AROS_CC) strip=$(TARGET_STRIP)
947 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
949 ifeq (%(usestartup),no)
950 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
953 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
956 # Make a list of the lib files the programs depend on.
957 # In LDFLAGS remove white space between -L and directory
958 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
959 # Filter out only the libdirs and remove -L
960 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
962 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
963 # Add normal linklib path
964 TMP_DIRS += $(AROS_LIB)/
965 # add lib and .a to static linklib names
966 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(TMP_EXTRA_LIBS)))
967 # search for the linklibs in the given path, ignore ones not found
968 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
969 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
971 TMP_PROGS := $(addprefix %(targetdir)/,%(progs))
973 $(TMP_PROGS) : LDFLAGS:= %(ldflags) $(TMP_EXTRA_LDFLAGS)
974 $(TMP_PROGS) : LIBS:= $(addprefix -l,%(uselibs) $(TMP_EXTRA_LIBS) %(usehostlibs))
975 $(TMP_PROGS) : %(targetdir)/% : %(objdir)/%.o $(TMP_DEPLIBS)
976 %link_q cmd=%(cmd) strip=%(strip) from=$< opt=$(LDFLAGS) libs=$(LIBS)
978 #------------------------------------------------------------------------------
981 #------------------------------------------------------------------------------
982 # Link the %(objs) to the library %(libdir)/lib%(libname).a
983 %define rule_link_linklib libname=/A objs=/A libdir=$(AROS_LIB) linker=target
985 ifeq (%(linker),target)
986 %(libdir)/lib%(libname).a : TMP_AR:=$(AR)
987 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(RANLIB)
989 ifeq (%(linker),host)
990 %(libdir)/lib%(libname).a : TMP_AR:=$(HOST_AR)
991 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(HOST_RANLIB)
993 ifeq (%(linker),kernel)
994 %(libdir)/lib%(libname).a : TMP_AR:=$(KERNEL_AR)
995 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(KERNEL_RANLIB)
998 %(libdir)/lib%(libname).a : %(objs)
999 %mklib_q from=$^ ar=$(TMP_AR) ranlib=$(TMP_RANLIB)
1001 #------------------------------------------------------------------------------
1003 #------------------------------------------------------------------------------
1004 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
1005 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
1006 %define rule_linkmodule module=/A objs=/A endobj=/A err=/A objdir=$(OBJDIR) \
1007 cmd=$(AROS_CC) ldflags=$(LDFLAGS) uselibs= usehostlibs=
1009 TMP_LDFLAGS := %(ldflags)
1010 # Make a list of the lib files the programs depend on.
1011 # In LDFLAGS remove white space between -L and directory
1012 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
1013 # Filter out only the libdirs and remove -L
1014 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
1016 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
1017 # Add normal linklib path
1018 TMP_DIRS += $(AROS_LIB)/
1019 # add lib and .a to static linklib names
1020 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
1021 # search for the linklibs in the given path, ignore ones not found
1022 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
1023 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
1026 %(module) : LIB_NAMES := %(uselibs)
1027 %(module) : OBJS := %(objs)
1028 %(module) : ENDTAG := %(endobj)
1029 %(module) : ERR := %(err)
1030 %(module) : OBJDIR := %(objdir)
1031 %(module) : LDFLAGS := $(TMP_LDFLAGS)
1032 ifeq (%(usehostlibs),)
1033 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES))
1035 # Warning: the -L/usr/lib here can result in modules
1036 # linking against host libs instead of AROS libs (e.g stdc++) !!
1037 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES)) \
1038 -L/usr/lib $(addprefix -l,%(usehostlibs))
1040 %(module) : %(objs) %(endobj) $(TMP_DEPLIBS) $(USER_DEPLIBS)
1041 %link_module_q cmd=%(cmd) err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS) objdir=$(OBJDIR) ldflags="$(LDFLAGS)"
1044 #------------------------------------------------------------------------------
1047 #------------------------------------------------------------------------------
1048 # Generate the libdefs.h include file for a module.
1049 %define rule_genmodule_genlibdefs modname=/A modtype=/A modsuffix= conffile= targetdir= version=
1051 TMP_TARGET := %(modname)_libdefs.h
1052 TMP_DEPS := $(GENMODULE)
1054 ifneq (%(conffile),)
1055 ifeq ($(dir %(conffile)),./)
1056 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1057 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1059 TMP_OPTS += -c %(conffile)
1060 TMP_DEPS += %(conffile)
1063 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1064 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1066 ifneq (%(modsuffix),)
1067 TMP_OPTS += -s %(modsuffix)
1069 ifneq (%(targetdir),)
1070 TMP_OPTS += -d %(targetdir)
1071 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1074 TMP_OPTS += -v %(version)
1077 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1078 $(TMP_TARGET) : MODNAME := %(modname)
1079 $(TMP_TARGET) : MODTYPE := %(modtype)
1080 $(TMP_TARGET) : $(TMP_DEPS)
1081 @$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1082 @$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
1084 #------------------------------------------------------------------------------
1086 #------------------------------------------------------------------------------
1087 # Generate the _lib.fd file for a module.
1088 %define rule_genmodule_fd modname=/A modtype=/A modsuffix= conffile= targetdir=
1090 TMP_TARGET := %(modname)_lib.fd
1091 TMP_DEPS := $(GENMODULE)
1093 ifneq (%(conffile),)
1094 ifeq ($(dir %(conffile)),./)
1095 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1096 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1098 TMP_OPTS += -c %(conffile)
1099 TMP_DEPS += %(conffile)
1102 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1103 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1105 ifneq (%(modsuffix),)
1106 TMP_OPTS += -s %(modsuffix)
1108 ifneq (%(targetdir),)
1109 TMP_OPTS += -d %(targetdir)
1110 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1113 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1114 $(TMP_TARGET) : MODNAME := %(modname)
1115 $(TMP_TARGET) : MODTYPE := %(modtype)
1116 $(TMP_TARGET) : $(TMP_DEPS)
1117 @$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1118 @$(GENMODULE) $(OPTS) writefd $(MODNAME) $(MODTYPE)
1120 #------------------------------------------------------------------------------
1122 #------------------------------------------------------------------------------
1123 # Generate a Makefile.%(modname)%(modtype) with the genmodule program and include this
1124 # generated file in this Makefile
1125 %define rule_genmodule_makefile modname=/A modtype=/A modsuffix= conffile= \
1128 TMP_TARGET := Makefile.%(modname)%(modtype)
1129 TMP_DEPS := $(GENMODULE)
1131 ifneq (%(conffile),)
1132 ifeq ($(dir %(conffile)),./)
1133 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1134 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1136 TMP_OPTS += -c %(conffile)
1137 TMP_DEPS += %(conffile)
1140 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1141 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1143 ifneq (%(modsuffix),)
1144 TMP_OPTS += -s %(modsuffix)
1146 ifneq (%(targetdir),)
1147 TMP_OPTS += -d %(targetdir)
1148 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1151 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1152 $(TMP_TARGET) : MODNAME := %(modname)
1153 $(TMP_TARGET) : MODTYPE := %(modtype)
1154 $(TMP_TARGET) : $(TMP_DEPS)
1155 @$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
1157 #------------------------------------------------------------------------------
1160 #------------------------------------------------------------------------------
1161 # Generate the support files for compiling a module. This includes include
1162 # files and source files. This rule has to be preceeded by
1163 # %rule_genmodule_makefile
1164 %define rule_genmodule_files modname=/A modtype=/A modsuffix= targetdir= \
1167 TMP_TARGETS := $(%(modname)_STARTFILES) $(%(modname)_ENDFILES) \
1168 $(%(modname)_LINKLIBFILES) $(%(modname)_RELLINKLIBFILES)
1169 TMP_TARGETS := $(addsuffix .c,$(TMP_TARGETS)) \
1170 $(addsuffix .S, $(%(modname)_LINKLIBAFILES) $(%(modname)_RELLINKLIBAFILES))
1172 TMP_DEPS := $(GENMODULE)
1175 ifneq (%(conffile),)
1176 ifeq ($(dir %(conffile)),./)
1177 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1178 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1180 TMP_OPTS += -c %(conffile)
1181 TMP_DEPS += %(conffile)
1184 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1185 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1187 ifneq (%(modsuffix),)
1188 TMP_OPTS += -s %(modsuffix)
1190 ifneq (%(targetdir),)
1191 TMP_OPTS += -d %(targetdir)
1192 TMP_TARGETDIR := $(shell echo %(targetdir) | sed 's/^\(.\):\//\/\1\//')
1193 TMP_TARGETS := $(addprefix $(TMP_TARGETDIR)/,$(TMP_TARGETS))
1196 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
1197 $(TMP_TARGETS) : MODNAME := %(modname)
1198 $(TMP_TARGETS) : MODTYPE := %(modtype)
1199 $(TMP_TARGETS) : $(TMP_DEPS)
1200 @$(ECHO) "Generating support files for module $(MODNAME$(BDID))"
1201 ifneq (%(conffile),lib.conf)
1202 @$(IF) $(TEST) -f lib.conf; then \
1203 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
1206 @$(IF) $(TEST) -f libdefs.h; then \
1207 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
1209 @$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
1211 #------------------------------------------------------------------------------
1214 #------------------------------------------------------------------------------
1215 # Generate the support files for compiling a module. This includes include
1216 # files and source files.
1217 %define rule_genmodule_includes modname=/A modtype=/A modsuffix= \
1218 targetdir= conffile=
1220 ifneq ($(%(modname)_INCLUDES),)
1221 TMP_TARGETS := $(%(modname)_INCLUDES)
1223 TMP_DEPS := $(GENMODULE)
1226 ifneq (%(conffile),)
1227 ifeq ($(dir %(conffile)),./)
1228 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1229 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1231 TMP_OPTS += -c %(conffile)
1232 TMP_DEPS += %(conffile)
1235 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1236 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1238 ifneq (%(modsuffix),)
1239 TMP_OPTS += -s %(modsuffix)
1241 ifneq (%(targetdir),)
1242 TMP_OPTS += -d %(targetdir)
1243 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
1246 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
1247 $(TMP_TARGETS) : MODNAME := %(modname)
1248 $(TMP_TARGETS) : MODTYPE := %(modtype)
1249 $(TMP_TARGETS) : $(TMP_DEPS)
1250 @$(ECHO) "Generating $(MODNAME).$(MODTYPE) includes"
1251 @$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
1254 #------------------------------------------------------------------------------
1256 #------------------------------------------------------------------------------
1257 # Link %(objs) to binary blob in %(file) using %(name) as name of embedded binary object
1258 # 'start' is an optional starting address
1259 # 'ldflags' is optional additional flags for the linker
1260 %define rule_link_binary file=/A name=/A objs= files= start=0 ldflags=
1262 BD_OUTDIR := $(dir %(file))
1263 # This trick removes the trailing '/', otherwise findstring below fails, causing a warning
1264 BD_OUTDIR := $(subst /*,,$(addsuffix *,$(BD_OUTDIR)))
1265 BD_TMPDIR := $(GENDIR)/$(CURDIR)
1266 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(notdir %(files))))
1267 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(notdir %(files))))
1270 %rule_compile_multi basenames=%(files) targetdir=$(BD_OBJDIR)
1272 %(file) : $(BD_OBJS) $(BD_DEPS) $(BD_OUTDIR)
1273 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)..."
1274 @$(KERNEL_LD) %(ldflags) --entry=%(start) --oformat=binary -Ttext=%(start) -o $(BD_TMPDIR)/%(name) $(BD_OBJS)
1275 @cd $(BD_TMPDIR) && $(AROS_LD) %(ldflags) -r --format binary %(name) -o $@
1277 ifeq ($(findstring $(BD_OUTDIR),$(GLOB_MKDIRS)),)
1278 GLOB_MKDIRS += $(BD_OUTDIR)
1283 #------------------------------------------------------------------------------
1284 # Common rules for all makefiles
1286 # Delete generated makefiles
1289 @$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
1291 include $(SRCDIR)/config/make.tail
1293 BDID := $(BDTARGETID)
1295 #------------------------------------------------------------------------------
1298 #############################################################################
1299 #############################################################################
1301 ## Here are the mmakefile build macros. These are macros that takes care ##
1302 ## of everything to go from the sources to the generated target. Also all ##
1303 ## intermediate files and directories that are needed are created by these ##
1306 #############################################################################
1307 #############################################################################
1309 #------------------------------------------------------------------------------
1311 %define build_prog mmake=/A progname=/A files=$(BD_PROGNAME) cxxfiles= \
1313 asmfiles= objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1314 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
1315 aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
1316 compiler=target linker=
1320 BD_PROGNAME := %(progname)
1321 BD_OBJDIR := %(objdir)
1322 BD_TARGETDIR := %(targetdir)
1323 BD_LINKER := %(linker)
1325 # If not supplied, linker is equal to compiler
1326 ifeq ($(BD_LINKER),)
1327 BD_LINKER := %(compiler)
1330 BD_FILES := %(files)
1331 BD_OBJCFILES := %(objcfiles)
1332 BD_ASMFILES := %(asmfiles)
1333 BD_CXXFILES := %(cxxfiles)
1335 BD_ARCHOBJS := $(wildcard $(BD_OBJDIR)/arch/*.o)
1336 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1337 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1339 TMP_FILES := $(BD_NARCHFILES) $(BD_CXXFILES) $(BD_ASMFILES) $(BD_OBJCFILES)
1340 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(notdir $(TMP_FILES))))
1341 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(notdir $(TMP_FILES))))
1343 BD_CFLAGS := %(cflags)
1344 BD_AFLAGS := %(aflags)
1345 BD_DFLAGS := %(dflags)
1346 BD_LDFLAGS := %(ldflags)
1349 %(mmake)-quick : %(mmake)
1351 #MM %(mmake) : includes-generate-deps core-linklibs linklibs-%(uselibs)
1352 %(mmake) : $(BD_TARGETDIR)/$(BD_PROGNAME)
1354 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick %(mmake)-gz-quick),)
1355 %rule_compile_cxx_multi basenames=$(BD_CXXFILES) targetdir=$(BD_OBJDIR) \
1356 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler=%(compiler)
1357 %rule_compile_objc_multi basenames=$(BD_OBJCFILES) targetdir=$(BD_OBJDIR) \
1358 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler=%(compiler)
1359 %rule_compile_multi basenames=$(BD_NARCHFILES) targetdir=$(BD_OBJDIR) \
1360 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler=%(compiler)
1361 %rule_assemble_multi basenames=$(BD_ASMFILES) targetdir=$(BD_OBJDIR) \
1362 aflags=$(BD_AFLAGS) compiler=%(compiler)
1364 %rule_link_prog prog=$(BD_TARGETDIR)/$(BD_PROGNAME) \
1365 objs="$(BD_OBJS) $(BD_ARCHOBJS) $(USER_OBJS)" ldflags=$(BD_LDFLAGS) \
1366 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1367 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)" \
1368 cmd=$(BD_LINK) strip=$(BD_STRIP)
1372 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1374 $(BD_OBJS) $(BD_DEPS) : | $(BD_OBJDIR)
1375 $(BD_TARGETDIR)/$(BD_PROGNAME) : | $(BD_TARGETDIR)
1376 GLOB_MKDIRS += $(BD_OBJDIR) $(BD_TARGETDIR)
1378 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_TARGETDIR)/$(BD_PROGNAME) $(BD_DEPS)
1381 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1385 #------------------------------------------------------------------------------
1388 #------------------------------------------------------------------------------
1389 # Build programs, for every C file an executable will be built with the same
1390 # name as the C file
1391 %define build_progs mmake=/A files=/A nix=no \
1392 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1393 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
1394 uselibs= usehostlibs= usestartup=yes detach=no
1398 BD_OBJDIR := %(objdir)
1399 BD_TARGETDIR := %(targetdir)
1401 BD_FILES := %(files)
1402 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1403 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1404 BD_EXES := $(addprefix $(BD_TARGETDIR)/,$(BD_FILES))
1406 BD_CFLAGS := %(cflags)
1407 BD_DFLAGS := %(dflags)
1408 BD_LDFLAGS := %(ldflags)
1411 %(mmake)-quick : %(mmake)
1413 #MM %(mmake) : includes-generate-deps core-linklibs linklibs-%(uselibs)
1414 %(mmake) : $(BD_EXES)
1416 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1417 %rule_compile_multi basenames=$(BD_FILES) targetdir=$(BD_OBJDIR) \
1418 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1420 %rule_link_progs progs=$(BD_FILES) nix=%(nix) \
1421 targetdir=$(BD_TARGETDIR) objdir=$(BD_OBJDIR) \
1422 ldflags=$(BD_LDFLAGS) \
1423 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1424 usestartup="%(usestartup)" detach="%(detach)" \
1425 cmd=$(BD_LINK) strip=$(BD_STRIP)
1429 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1431 $(addprefix $(BD_TARGETDIR)/,$(BD_FILES)) : | $(BD_TARGETDIR)
1432 $(BD_DEPS) $(BD_OBJS) : | $(BD_OBJDIR)
1433 GLOB_MKDIRS += $(BD_TARGETDIR) $(BD_OBJDIR)
1435 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_EXES) $(BD_DEPS)
1438 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1442 #------------------------------------------------------------------------------
1445 #------------------------------------------------------------------------------
1447 # This is a bare version: It just compiles and links the given files. It is
1448 # assumed that all needed boiler plate code is in the files. This should only
1449 # be used for compiling external code. For AROS code use %build_module
1450 %define build_module_simple mmake=/A modname=/A modtype=/A \
1451 files="$(basename $(call WILDCARD, *.c))" \
1452 cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1453 objdir=$(OBJDIR) moduledir= \
1454 uselibs= usehostlibs= compiler=target
1456 # Define metamake targets and their dependencies
1457 #MM %(mmake) : core-linklibs includes-generate-deps
1458 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1459 #MM %(mmake)-kobj-quick
1463 BD_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj
1465 .PHONY : $(BD_ALLTARGETS)
1468 $(error using %build_module_simple: modname may not be empty)
1471 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1474 # Default values for variables and arguments
1475 BD_DEFLINKLIBNAME := %(modname)
1476 BD_DEFDFLAGS := %(cflags)
1477 OBJDIR ?= $(GENDIR)/$(CURDIR)
1478 BD_MODDIR := %(moduledir)
1479 ifeq ($(BD_MODDIR),)
1480 ifeq (%(modtype),library)
1481 BD_MODDIR := $(AROS_LIBRARIES)
1483 ifeq (%(modtype),gadget)
1484 BD_MODDIR := $(AROS_GADGETS)
1486 ifeq (%(modtype),datatype)
1487 BD_MODDIR := $(AROS_DATATYPES)
1489 ifeq (%(modtype),handler)
1490 BD_MODDIR := $(AROS_FS)
1492 ifeq (%(modtype),device)
1493 BD_MODDIR := $(AROS_DEVS)
1495 ifeq (%(modtype),resource)
1496 BD_MODDIR := $(AROS_RESOURCES)
1498 ifeq (%(modtype),hook)
1499 BD_MODDIR := $(AROS_RESOURCES)
1501 ifeq (%(modtype),mui)
1502 BD_MODDIR := $(AROS_CLASSES)/Zune
1504 ifeq (%(modtype),mcc)
1505 BD_MODDIR := $(AROS_CLASSES)/Zune
1507 ifeq (%(modtype),mcp)
1508 BD_MODDIR := $(AROS_CLASSES)/Zune
1510 ifeq (%(modtype),usbclass)
1511 BD_MODDIR := $(AROS_CLASSES)/USB
1513 ifeq (%(modtype),hidd)
1514 BD_MODDIR := $(AROS_DRIVERS)
1516 ifeq (%(modtype),printer)
1517 BD_MODDIR := $(AROS_PRINTERS)
1520 ifeq ($(BD_MODDIR),)
1521 $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1524 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1525 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1526 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),%(files))
1528 %rule_compile_multi \
1529 basenames="$(BD_NARCHFILES)" targetdir="%(objdir)" \
1530 cflags="%(cflags)" dflags="%(dflags)" \
1531 compiler=%(compiler)
1533 # Handlers use dash instead of dot in their names
1534 ifeq (%(modtype),handler)
1535 BD_MODULE := $(BD_MODDIR)/%(modname)-%(modtype)
1537 ifeq (%(modtype),printer)
1538 BD_MODULE := $(BD_MODDIR)/%(modname)
1540 BD_MODULE := $(BD_MODDIR)/%(modname).%(modtype)
1543 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1545 %(mmake)-quick : %(mmake)
1546 %(mmake)-kobj-quick : $(BD_KOBJ)
1547 %(mmake) : $(BD_MODULE)
1548 %(mmake)-kobj : $(BD_KOBJ)
1550 # The module is linked from all the compiled .o files
1551 BD_OBJS := $(BD_ARCHOBJS) $(addprefix %(objdir)/, $(addsuffix .o,$(notdir $(BD_NARCHFILES))))
1553 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
1554 # This breaks con-handler build. Here we work around this
1555 ifeq (%(modname),con)
1556 BD_ERR := $(notdir $(BD_MODULE)).err
1558 BD_ERR := %(modname).err
1561 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1562 endobj= err=$(BD_ERR) objdir=%(objdir) \
1563 cmd=$(AROS_CC) ldflags="$(LDFLAGS) $(%(modname)_LDFLAGS)" \
1564 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
1566 # Link kernel object file
1567 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1569 # Make these symbols local
1570 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1571 UtilityBase ExpansionBase KeymapBase KernelBase
1573 BD_SYMBOLS := $(BD_KBASE)
1575 BD_KLIB := hiddstubs amiga arossupport autoinit libinit
1576 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1577 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1578 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
1579 $(BD_KOBJ) : USER_LDFLAGS := $(USER_LDFLAGS)
1580 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1581 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
1582 @$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1583 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
1586 ## Dependency fine-tuning
1588 BD_DEPS := $(addprefix %(objdir)/, $(addsuffix .d,%(files)))
1589 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1591 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1592 $(BD_MODULE) : | $(BD_MODDIR)
1593 $(BD_KOBJ) : | $(KOBJSDIR)
1594 GLOB_MKDIRS += %(objdir) $(BD_MODDIR) $(KOBJSDIR)
1596 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_MODULE) $(BD_KOBJ) $(BD_DEPS)
1598 @$(ECHO) "Cleaning up for module %(modname)"
1601 #------------------------------------------------------------------------------
1604 #------------------------------------------------------------------------------
1605 # Build a module - core routine
1606 # Explanation of this macro is done in the developer's manual
1607 %define build_module_core mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
1608 files="$(basename $(call WILDCARD, *.c))" \
1609 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
1610 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1611 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
1612 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
1613 compiler=target nostartup=yes archspecific=no \
1614 build_abi= build_library=
1616 # We will employ a terrifying, but unavoidable, hack here.
1617 # genmf has no concept of conditionals (ie %ifeq), and MetaMake
1618 # ignores GNU Make ifeq() statements, but will process any #MM
1619 # headed lines in the file.
1621 # So, to make the following #MM lines conditional on whether we want
1622 # to build the ABI, Library, or both, we define build_abi= and
1623 # build_library as 'M' to enable, or '' to disable, which allows genmf
1624 # to do the following conversions:
1626 # #%(build_abi)M includes-foo: foo-include
1627 # becomes, when build_abi=M
1628 # #MM includes-foo: foo-include <= Processed by MetaMake
1629 # but, when build_abi= ...
1630 # #M includes-foo: foo-includes <= ignored by MetaMake! Yes!
1632 # Taking full blame for this: Jason S. McMullan <jason.mcmullan@gmail.com>
1634 # Define metamake targets and their dependencies
1637 #MM %(mmake)-makefile
1641 #M%(build_abi)- includes-all : %(mmake)-includes
1642 #M%(build_abi)- linklibs-%(modname): %(mmake)-linklib
1643 #M%(build_abi)- linklibs-%(modname)_rel : %(mmake)-linklib
1644 #M%(build_abi)- includes-%(modname): %(mmake)-includes
1645 #M%(build_abi)- includes-%(modname)_rel : %(mmake)-includes
1646 #M%(build_abi)- %(mmake) : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1647 #M%(build_abi) %(mmake)-linklib : %(mmake)-includes includes-%(uselibs)
1648 #M%(build_abi)- %(mmake)-quick : %(mmake)-includes-quick
1649 #M%(build_abi) %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1650 #M%(build_abi) includes-generate-deps %(mmake)-fd
1651 #M%(build_abi) %(mmake)-includes-quick
1652 #M%(build_abi) %(mmake)-includes-dirs
1653 #M%(build_abi) %(mmake)-fd
1656 #%(build_library)M %(mmake)-kobj : core-linklibs linklibs-%(uselibs)
1657 #%(build_library)M %(mmake)-kobj-quick :
1659 # Library with ABI targets:
1660 #%(build_library)%(build_abi) %(mmake)-kobj : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1661 #%(build_library)%(build_abi) %(mmake)-kobj-quick : %(mmake)-includes-quick
1663 # All MetaMake targets defined by this macro
1664 BD_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-clean
1666 ifeq (%(build_library),M)
1667 BD_ALLTARGETS += %(mmake)-kobj %(mmake)-kobj-quick
1670 ifeq (%(build_abi),M)
1671 BD_ALLTARGETS += %(mmake)-includes \
1672 %(mmake)-includes-quick %(mmake)-includes-dirs \
1673 %(mmake)-linklib %(mmake)-fd
1676 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1679 $(error using %build_module: modname may not be empty)
1682 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1685 # Default values for variables and arguments
1686 BD_DEFLINKLIBNAME := %(modname)
1687 BD_DEFDFLAGS := %(cflags)
1688 OBJDIR ?= $(GENDIR)/$(CURDIR)
1690 ## Create genmodule include Makefile for the module
1692 %(mmake)-makefile : %(objdir)/Makefile.%(modname)%(modtype)
1694 %rule_genmodule_makefile \
1695 modname=%(modname) modtype=%(modtype) \
1696 modsuffix=%(modsuffix) targetdir=%(objdir) \
1697 conffile=%(conffile)
1699 %(objdir)/Makefile.%(modname)%(modtype) : | %(objdir)
1701 GLOB_MKDIRS += %(objdir)
1703 # Do not parse these statements if metatarget is not appropriate
1704 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1706 include %(objdir)/Makefile.%(modname)%(modtype)
1708 BD_DEFMODDIR := $(%(modname)_MODDIR)
1709 ifeq (%(archspecific),yes)
1710 BD_DEFMODDIR := $(AROS_DIR_ARCH)/$(BD_DEFMODDIR)
1714 ## include files generation
1716 BD_INCDIR := %(prefix)/$(AROS_DIR_INCLUDE)
1717 BD_LIBDEFSINC := %(objdir)/include/%(modname)_libdefs.h
1718 BD_DEFLIBDEFSINC := %(objdir)/include/%(modname)_deflibdefs.h
1720 ifeq (%(build_abi),M)
1721 %(mmake)-includes-quick : %(mmake)-includes
1722 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1723 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1724 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1726 ifneq ($(%(modname)_INCLUDES),)
1727 %rule_genmodule_includes modname=%(modname) modtype=%(modtype) \
1728 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1729 conffile=%(conffile)
1731 %rule_copy_diff_multi \
1732 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(GENINCDIR) \
1733 stampfile=%(objdir)/%(modname)_geninc
1735 %rule_copy_diff_multi \
1736 files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(BD_INCDIR) \
1737 stampfile=%(objdir)/%(modname)_incs
1739 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1741 TMP%(modname)_INCDIRS := \
1742 %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1743 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1744 $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1745 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget=%(mmake)-includes-dirs
1751 %rule_genmodule_genlibdefs modname=%(modname) modtype=%(modtype) \
1752 modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1753 conffile=%(conffile) version=%(version)
1755 $(BD_DEFLIBDEFSINC) : FILENAME := $(BD_LIBDEFSINC)
1756 $(BD_DEFLIBDEFSINC) :
1757 @$(ECHO) "Generating $@"
1758 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1760 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) : | %(objdir)/include
1761 GLOB_MKDIRS += %(objdir)/include
1763 ## Extra genmodule src files generation
1765 %rule_genmodule_files modname=%(modname) modtype=%(modtype) \
1766 modsuffix=%(modsuffix) targetdir=%(objdir) \
1767 conffile=%(conffile)
1770 ifeq (%(build_abi),M)
1772 BD_FDDIR := %(prefix)/$(AROS_DIR_DEVELOPMENT)/fd
1773 %(mmake)-fd : $(BD_FDDIR)/%(modname)_lib.fd
1775 %rule_genmodule_fd modname=%(modname) modtype=%(modtype) \
1776 modsuffix=%(modsuffix) targetdir=$(BD_FDDIR) conffile=%(conffile)
1778 $(BD_FDDIR)/%(modname)_lib.fd : | $(BD_FDDIR)
1780 GLOB_MKDIRS += $(BD_FDDIR)
1785 BD_FILES := %(files)
1786 BD_CXXFILES := %(cxxfiles)
1788 BD_FDIRS := $(sort $(dir $(BD_FILES)))
1790 BD_STARTFILES := $(addprefix %(objdir)/,$(%(modname)_STARTFILES))
1791 BD_ENDFILES := $(addprefix %(objdir)/,$(%(modname)_ENDFILES))
1793 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1794 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1795 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1797 BD_CFLAGS := %(cflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC) $(%(modname)_CFLAGS)
1798 BD_DFLAGS := %(dflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC) $(%(modname)_DFLAGS)
1800 ifeq (%(modtype),library)
1803 BD_LIBSUFFIX := .%(modtype)
1806 ifeq (%(build_abi),M)
1807 BD_LINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBFILES))
1808 BD_LINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBAFILES))
1809 ifeq ($(strip $(%(modname)_LINKLIBFILES) $(%(modname)_LINKLIBAFILES) %(linklibfiles)),)
1812 BD_LINKLIB := %(prefix)/$(AROS_DIR_LIB)/lib%(modname)$(BD_LIBSUFFIX).a
1813 ifneq (%(modname),%(linklibname))
1814 BD_LINKLIB += %(prefix)/$(AROS_DIR_LIB)/lib%(linklibname)$(BD_LIBSUFFIX).a
1817 BD_LINKLIBFILES := $(BD_LINKLIBCFILES) $(BD_LINKLIBAFILES)
1819 BD_RELLINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_RELLINKLIBFILES))
1820 BD_RELLINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_RELLINKLIBAFILES))
1821 ifeq ($(strip $(%(modname)_RELLINKLIBFILES) $(%(modname)_RELLINKLIBAFILES) %(linklibfiles)),)
1824 BD_RELLINKLIB := %(prefix)/$(AROS_DIR_LIB)/lib%(modname)_rel$(BD_LIBSUFFIX).a
1825 ifneq (%(modname),%(linklibname))
1826 BD_RELLINKLIB += %(prefix)/$(AROS_DIR_LIB)/lib%(linklibname)_rel$(BD_LIBSUFFIX).a
1829 BD_RELLINKLIBFILES := $(BD_RELLINKLIBCFILES) $(BD_RELLINKLIBAFILES)
1832 BD_CCFILES := $(BD_NARCHFILES) %(linklibfiles)
1833 BD_TARGETCCFILES := $(BD_STARTFILES) $(BD_ENDFILES) $(BD_LINKLIBCFILES) \
1834 $(BD_RELLINKLIBCFILES)
1836 %rule_compile_cxx_multi \
1837 basenames=$(BD_CXXFILES) targetdir=%(objdir) \
1838 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) \
1839 compiler=%(compiler)
1840 %rule_compile_multi \
1841 basenames=$(BD_CCFILES) targetdir=%(objdir) \
1842 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) \
1843 compiler=%(compiler)
1844 %rule_compile_multi \
1845 basenames=$(BD_TARGETCCFILES) targetdir=%(objdir) \
1846 cflags="$(BD_CFLAGS) -D__AROS__" dflags=$(BD_DFLAGS) \
1847 compiler=%(compiler)
1849 ifneq ($(BD_LINKLIBAFILES),)
1850 %rule_assemble_multi \
1851 basenames="$(BD_LINKLIBAFILES) $(BD_RELLINKLIBAFILES)" targetdir=%(objdir) suffix=.S
1856 ifeq (%(modsuffix),)
1857 BD_SUFFIX := %(modtype)
1859 BD_SUFFIX := %(modsuffix)
1862 ifeq (%(build_library),M)
1863 # Handlers use dash instead of dot in their names
1864 ifeq ($(BD_SUFFIX),handler)
1865 BD_MODULE := %(prefix)/%(moduledir)/%(modname)-$(BD_SUFFIX)
1867 BD_MODULE := %(prefix)/%(moduledir)/%(modname).$(BD_SUFFIX)
1869 BD_KOBJ := $(KOBJSDIR)/%(modname)_$(BD_SUFFIX).o
1875 %(mmake)-quick : %(mmake)
1876 %(mmake) : $(BD_MODULE) $(BD_LINKLIB) $(BD_RELLINKLIB)
1877 ifeq (%(build_library),M)
1878 %(mmake)-kobj : $(BD_KOBJ) $(BD_LINKLIB) $(BD_RELLINKLIB)
1879 %(mmake)-kobj-quick : $(BD_KOBJ) $(BD_LINKLIB) $(BD_RELLINKLIB)
1881 ifeq (%(build_abi),M)
1882 %(mmake)-linklib : $(BD_LINKLIB) $(BD_RELLINKLIB)
1885 BD_OBJS := $(addsuffix .o,$(BD_STARTFILES)) $(BD_ARCHOBJS) \
1886 $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES:=.o) $(BD_CXXFILES:=.o)))
1888 ifeq (%(nostartup),yes)
1889 # Handlers always have entry point
1890 ifneq (%(modtype),handler)
1891 BD_STARTOBJS := $(addsuffix .o,$(addprefix $(GENDIR)/,$(RESIDENT_BEGIN)))
1895 BD_ENDOBJS := $(addsuffix .o,$(BD_ENDFILES))
1896 BD_LINKLIBOBJS:= $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_LINKLIBFILES)) \
1899 := $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_RELLINKLIBFILES)) \
1902 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
1903 # This breaks con-handler build. Here we work around this
1904 ifeq (%(modname),con)
1905 BD_ERR := $(notdir $(BD_MODULE)).err
1907 BD_ERR := %(modname).err
1910 ifeq (%(build_library),M)
1911 # The module is linked from all the compiled .o files
1912 %rule_linkmodule module=$(BD_MODULE) objs="$(BD_STARTOBJS) $(BD_OBJS) $(USER_OBJS)" \
1913 endobj=$(BD_ENDOBJS) err=$(BD_ERR) objdir=%(objdir) \
1914 cmd=$(BD_LINK) ldflags="$(LDFLAGS) $(%(modname)_LDFLAGS)" \
1915 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
1918 ifeq (%(build_abi),M)
1920 BD_LINKLIBNAME := $(shell echo %(linklibname) | tr A-Z a-z)
1921 BD_MODNAME := $(shell echo %(modname) | tr A-Z a-z)
1922 ifneq ($(BD_LINKLIB),)
1923 %rule_link_linklib libname=%(linklibname)$(BD_LIBSUFFIX) objs=$(BD_LINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1924 ifneq ($(BD_MODNAME),$(BD_LINKLIBNAME))
1925 %rule_link_linklib libname=%(modname)$(BD_LIBSUFFIX) objs=$(BD_LINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1928 $(BD_LINKLIB) : | %(prefix)/$(AROS_DIR_LIB)
1929 GLOB_MKDIRS += %(prefix)/$(AROS_DIR_LIB)
1932 ifneq ($(BD_RELLINKLIB),)
1933 %rule_link_linklib libname=%(linklibname)_rel$(BD_LIBSUFFIX) objs=$(BD_RELLINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1934 ifneq ($(BD_MODNAME),$(BD_LINKLIBNAME))
1935 %rule_link_linklib libname=%(modname)_rel$(BD_LIBSUFFIX) objs=$(BD_RELLINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1938 $(BD_RELLINKLIB) : | %(prefix)/$(AROS_DIR_LIB)
1939 GLOB_MKDIRS += %(prefix)/$(AROS_DIR_LIB)
1943 ifeq (%(build_library),M)
1944 # Link kernel object file
1945 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1947 # Make these symbols local
1948 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1949 UtilityBase ExpansionBase KeymapBase KernelBase
1951 BD_SYMBOLS := $(BD_KBASE)
1953 BD_KLIB := hiddstubs amiga arossupport autoinit libinit
1954 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1955 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS) $(%(modname)_LIBS)
1956 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
1957 $(BD_KOBJ) : USER_LDFLAGS:=$(USER_LDFLAGS)
1958 $(BD_KOBJ) : $(BD_OBJS) $(USER_OBJS) $(BD_ENDOBJS)
1959 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
1960 @$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1961 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
1964 ## Dependency fine-tuning
1966 BD_DEPS := $(addprefix %(objdir)/,$(notdir $(BD_CCFILES:=.d) $(BD_TARGETCCFILES:=.d) $(BD_CXXFILES:=.d)))
1968 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick" deps=$(BD_DEPS)
1970 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1971 $(BD_MODULE) : | %(prefix)/%(moduledir)
1972 $(BD_KOBJ) : | $(KOBJSDIR)
1973 GLOB_MKDIRS += %(objdir) %(prefix)/%(moduledir) $(KOBJSDIR)
1975 # Some include files need to be generated before the .c can be parsed.
1976 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick),) # Only for this target these deps are wanted
1978 BD_DFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
1979 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES))
1980 $(BD_DEPS) : $(BD_DFILE_DEPS)
1983 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) \
1984 $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
1985 %(objdir)/Makefile.%(modname)%(modtype) \
1986 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
1987 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1988 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1989 %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
1990 $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
1991 $(BD_DEFLIBDEFSINC) $(addsuffix .c,$(BD_STARTFILES) $(BD_ENDFILES)) \
1993 %(mmake)-clean : FILES := $(BD_TOCLEAN)
1995 @$(ECHO) "Cleaning up for module %(modname)"
1998 endif # $(TARGET) in $(BD_ALLTARGETS)
2000 #------------------------------------------------------------------------------
2002 #------------------------------------------------------------------------------
2003 # Build a module - ABI and library
2004 # Explanation of this macro is done in the developer's manual
2005 %define build_module mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2006 files="$(basename $(call WILDCARD, *.c))" \
2007 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2008 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
2009 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
2010 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
2011 compiler=target nostartup=yes archspecific=no
2013 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2014 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2015 files="%(files)" cxxfiles="%(cxxfiles)" \
2016 linklibname="%(linklibname)" \
2017 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2018 cflags="%(cflags)" dflags="%(dflags)" \
2019 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2020 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" \
2021 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2022 build_abi=M build_library=M
2025 #------------------------------------------------------------------------------
2028 #------------------------------------------------------------------------------
2029 # Build a module skeleton ABI
2030 # This is a stripped-down version of build_module, it only creates include
2031 # files and the linklibs.
2032 # This is used when for plugins or classes with the same API, but no actual
2033 # implementation here.
2034 %define build_module_abi mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2035 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
2036 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
2037 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
2038 compiler=target nostartup=yes archspecific=no
2040 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2041 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2042 linklibname="%(linklibname)" \
2043 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2044 cflags="%(cflags)" dflags="%(dflags)" \
2045 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2046 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" \
2047 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2048 build_abi=M build_library=
2051 #------------------------------------------------------------------------------
2053 #------------------------------------------------------------------------------
2054 # Build a module library - no includes nor linklibs
2055 # Explanation of this macro is done in the developer's manual
2056 %define build_module_library mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2057 files="$(basename $(call WILDCARD, *.c))" \
2058 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2059 cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
2060 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
2061 uselibs= usehostlibs= \
2062 compiler=target nostartup=yes archspecific=no
2064 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2065 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2066 files="%(files)" cxxfiles="%(cxxfiles)" \
2067 cflags="%(cflags)" dflags="%(dflags)" \
2068 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2069 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" \
2070 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2071 build_abi= build_library=M
2074 #------------------------------------------------------------------------------
2078 #------------------------------------------------------------------------------
2080 # - mmake is the mmaketarget
2081 # - libname is the baselibname e.g. lib%(libname).a will be created
2082 # - files are the C source files to include in the lib. The list of files
2083 # has to be given without the .c suffix
2084 # - cxxfiles are C++ source files without suffix.
2085 # NB: files will be matched in the order .cpp > .cxx > .cc
2086 # - asmfiles are the asm files to include in the lib. The list of files has to
2087 # be given without the .s suffix
2088 # - objs additional object to link into the linklib. The objects have to be
2089 # given with full absolute path and the .o suffix.
2090 # - objdir is where the .o are generated. Defaults to $(GENDIR)/$(CURDIR)
2091 # - libdir is the directory where the linklib will be placed (default $(AROS_LIB))
2092 # - cflags are the flags to compile the source (default $(CFLAGS))
2093 # - dflags are the flags use during makedepend (default equal to cflags)
2094 # - aflags are the flags use during assembling (default $(AFLAGS))
2095 # - libdir is the directory where the linklib will be placed (default $(AROS_LIB))
2096 %define build_linklib mmake=/A libname=/A files= cxxfiles= \
2097 asmfiles= objs= objdir=$(GENDIR)/$(CURDIR) libdir=$(AROS_LIB) \
2098 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) \
2099 aflags=$(AFLAGS) compiler=target
2101 # assign and generate the local variables used in this macro
2102 BD_LIBNAME := %(libname)
2103 BD_LINKLIB := %(libdir)/lib%(libname).a
2105 BD_FILES := %(files)
2106 BD_ASMFILES := %(asmfiles)
2107 BD_CXXFILES := %(cxxfiles)
2109 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
2110 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
2111 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
2113 BD_OBJS := $(BD_ARCHOBJS) \
2114 $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES:=.o) $(BD_CXXFILES:=.o) $(BD_ASMFILES:=.o))) \
2116 BD_DEPS := $(patsubst %.o,%.d,$(BD_OBJS))
2118 BD_CFLAGS := %(cflags)
2119 BD_AFLAGS := %(aflags)
2120 BD_DFLAGS := %(dflags)
2122 .PHONY : %(mmake) %(mmake)-clean
2124 #MM %(mmake) : includes-generate-deps
2125 %(mmake) : $(BD_LINKLIB)
2127 ifeq ($(TARGET),%(mmake))
2129 %rule_compile_cxx_multi basenames=$(BD_CXXFILES) targetdir=%(objdir) \
2130 compiler=%(compiler) cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
2131 %rule_compile_multi basenames=$(BD_FILES) targetdir=%(objdir) \
2132 compiler=%(compiler) cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
2133 %rule_assemble basename=% targetdir=%(objdir) \
2136 %rule_link_linklib libname=%(libname) objs=$(BD_OBJS) libdir=%(libdir) linker=%(compiler)
2139 %include_deps depstargets=%(mmake) deps=$(BD_DEPS)
2141 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
2142 $(BD_LINKLIB) : | %(libdir)
2143 GLOB_MKDIRS += %(objdir) %(libdir)
2145 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_LINKLIB) $(BD_DEPS)
2148 @$(ECHO) "Cleaning up for metatarget %(mmake)"
2152 #------------------------------------------------------------------------------
2155 #------------------------------------------------------------------------------
2157 # - mmake is the mmaketarget
2158 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
2159 # - description is the catalog description file (.cd), without the .cd suffix (default *.cd)
2160 # - subdir is the destination subdirectory of the catalogs
2161 # - name is the name of the destination catalog, without the .catalog suffix
2162 # - source is the path to the generated source code file
2163 # - dir is the base destination directory (default $(AROS_CATALOGS))
2164 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
2165 # - srcdir is the directory in which the *.cd and *.ct files are searched
2167 %define build_catalogs mmake=/A name=/A subdir=/A \
2168 catalogs= source="../strings.h" description= dir=$(AROS_CATALOGS) \
2169 sourcedescription="$(TOOLDIR)/C_h_aros" srcdir="$(SRCDIR)/$(CURDIR)"
2171 ifeq (%(description),)
2172 BD_DESC := $(basename $(wildcard %(srcdir)/*.cd))
2174 BD_DESC := %(description)
2177 BD_SRC := $(shell echo %(sourcedescription) | sed 's/^\(.\):\//\/\1\//')
2180 BD_LNGS := $(basename $(notdir $(call WILDCARD, %(srcdir)/*.ct)))
2182 BD_LNGS := %(catalogs)
2185 BD_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, $(BD_LNGS)))
2186 BD_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, $(BD_LNGS))) $(dir %(source))
2189 %(mmake) : $(BD_OBJS) %(source)
2191 $(BD_OBJS) : | $(BD_DIRS)
2192 GLOB_MKDIRS += $(BD_DIRS)
2194 %(dir)/%/%(subdir)/%(name).catalog : %(srcdir)/%.ct $(BD_DESC).cd
2195 @$(ECHO) "Creating %(name) catalog for language $*."
2196 @$(FLEXCAT) $(BD_DESC).cd $< CATALOG=%(dir)/$*/%(subdir)/%(name).catalog || [ $$? -lt 10 ]
2199 %(source) : BD_DESC := $(BD_DESC)
2200 %(source) : BD_SRC := $(BD_SRC)
2201 %(source) : $(BD_DESC).cd $(BD_SRC).sd | $(dir %(source))
2202 @$(ECHO) "Creating %(name) catalog source file $@"
2203 @$(FLEXCAT) $(BD_DESC).cd $@=$(BD_SRC).sd
2206 %(mmake)-clean : FILES := $(BD_OBJS) %(source)
2209 @$(ECHO) "Cleaning up for metatarget %(mmake)"
2212 .PHONY: %(mmake) %(mmake)-clean
2215 #-----------------------------------------------------------------------------
2218 #-----------------------------------------------------------------------------
2220 # - mmake is the mmaketarget
2221 # - icons is a list of icon base names (ie. without the .info suffix)
2222 # - dir is the destination directory
2223 # - srcdir is where *.png and *.info.src are searched
2224 #-----------------------------------------------------------------------------
2226 %define build_icons mmake=/A icons=/A dir=/A srcdir="$(SRCDIR)/$(CURDIR)" image=
2228 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
2231 %(mmake) : $(BD_OBJS)
2235 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%.png
2236 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2237 @$(ILBMTOICON) $+ $@
2241 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%(image)
2242 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2243 @$(ILBMTOICON) $+ $@
2247 $(BD_OBJS) : | %(dir)
2248 GLOB_MKDIRS += %(dir)
2250 %(mmake)-clean : FILES := $(BD_OBJS)
2255 .PHONY: %(mmake) %(mmake)-clean
2258 #-----------------------------------------------------------------------------
2261 #------------------------------------------------------------------------------
2262 # Compile files for an arch-specific replacement of code for a module
2263 # - files: the basenames of the C files to compile.
2264 # - asmfiles: the basenames of the asm files to assemble.
2265 # - mainmmake: the mmake of the module in the main directory to compile these
2266 # arch specific files for.
2267 # - maindir: the object directory for the main module
2268 # - arch: the arch for which to compile these files. It can have the form
2269 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
2270 # - cflags (default $(CFLAGS)): the C flags to use for compilation
2271 # - dflags: the flags used during creation of dependency file. If not specified
2272 # the same value as cflags will be used
2273 # - aflags: the flags used during assembling
2274 # - compiler: (host, kernel or target) specifies which compiler to use. By default
2275 # the target compiler is used
2276 %define build_archspecific files= asmfiles= mainmmake=/A maindir=/A arch=/A \
2277 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
2279 ifeq (%(files) %(asmfiles),)
2280 $(error no files or asmfiles given)
2283 %buildid targets="%(mainmmake)-%(arch)"
2285 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2286 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2287 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2288 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2289 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2290 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2291 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2292 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2293 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2294 #MM- %(mainmmake)-kobj-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2295 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2296 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2297 #MM- %(mainmmake)-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2298 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2299 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2301 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
2303 BD_OBJDIR$(BDID) := $(GENDIR)/%(maindir)/arch
2304 BD_COBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
2305 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
2306 BD_OBJS$(BDID) := $(BD_COBJS$(BDID)) $(BD_ASMOBJS$(BDID))
2307 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
2309 ifneq (%(modulename),)
2310 BD_DEFLIBDEFSINC$(BDID) := -include $(GENDIR)/%(maindir)/include/%(modulename)_deflibdefs.h
2313 ifeq ($(TARGET),%(mainmmake)-%(arch)-quick)
2314 BD_TARGET := %(mainmmake)-%(arch)-quick
2316 BD_TARGET := %(mainmmake)-%(arch)
2320 ifeq ($(TARGET),$(BD_TARGET))
2321 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
2322 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(files)))
2323 vpath %.s $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2324 vpath %.S $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2327 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID))
2328 GLOB_MKDIRS += $(BD_OBJDIR$(BDID))
2331 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
2334 %(mainmmake)-%(arch)-quick :: $(BD_OBJS$(BDID))
2336 ifeq ($(findstring %(compiler),host kernel target),)
2337 $(error unknown compiler %(compiler))
2339 ifeq (%(compiler),target)
2340 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
2341 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
2342 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
2344 ifeq (%(compiler),host)
2345 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(HOST_CC)
2346 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
2347 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
2349 ifeq (%(compiler),kernel)
2350 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
2351 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
2352 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
2354 ifneq (%(modulename),)
2355 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) $(BD_DEFLIBDEFSINC$(BDID))
2357 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
2359 ifeq ($(TARGET),$(BD_TARGET))
2360 $(BD_OBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2361 %compile_q opt=$(TMP_CFLAGS) cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2365 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags) $(BD_DEFLIBDEFSINC$(BDID))
2367 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
2369 ifeq ($(TARGET),$(BD_TARGET))
2370 $(BD_OBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2371 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
2374 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
2376 ifeq ($(TARGET),$(BD_TARGET))
2377 $(BD_OBJDIR$(BDID))/%.o : %.s
2378 %assemble_q opt=$(AFLAGS)
2379 $(BD_OBJDIR$(BDID))/%.o : %.S
2380 %assemble_q opt=$(AFLAGS)
2383 %include_deps depstargets=$(BD_TARGET) deps=$(BD_DEPS$(BDID))
2385 #------------------------------------------------------------------------------
2388 #------------------------------------------------------------------------------
2389 # generate asm files from c files (for debugging purposes)
2392 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
2393 @$(TARGET_CC) -S $(CFLAGS) $(TARGET_CFLAGS) $< -c -o $@
2395 #------------------------------------------------------------------------------
2398 #------------------------------------------------------------------------------
2399 # Copy files from one directory to another.
2401 %define copy_files_q mmake=/A files=$(FILES) src=. dst=/A
2403 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
2405 GLOB_MKDIRS += %(dst)
2411 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC))/, $(file)) $(addprefix %(dst)/, $(file))))
2414 #------------------------------------------------------------------------------
2417 #------------------------------------------------------------------------------
2418 # Copy a directory recursively to another place, preserving the original
2419 # hierarchical structure
2421 # src: the source directory whose content will be copied.
2422 # dst: the directories where to copy src's content. If not existing, they will be made.
2423 # excludefiles: files which must not be copied. Path must be relative to src.
2425 %define copy_dir_recursive mmake=/A src=. dst=/A excludefiles=
2431 @cd $(SRCDIR)/$(CURDIR) && $(CPYDIRREC) -s %(src) -d %(dst) -e %(excludefiles)
2434 #------------------------------------------------------------------------------
2437 #------------------------------------------------------------------------------
2438 # Copy include files into the includes directories. There are currently
2439 # two include directories. One for building AROS $(AROS_INCLUDES) and one
2440 # for building tools that need to run on the host system $(GENINCDIR). The
2441 # $(GENINCDIR) path must not contain any references to the C runtime
2442 # library header files.
2444 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
2445 dir= compiler=target
2447 ifeq ($(findstring %(compiler),host kernel target),)
2448 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
2452 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),$(dir %(includes)))
2453 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,$(notdir %(includes)))
2454 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
2456 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
2457 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
2460 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
2464 ifeq (%(compiler),target)
2467 BD_INCL_FILES2 := $(subst %(dir),$(AROS_INCLUDES)/%(path),$(dir %(includes)))
2468 BD_INCL_FILES2 := $(addprefix $(AROS_INCLUDES)/%(path)/,$(notdir %(includes)))
2470 BD_INCL_FILES2 := $(addprefix $(AROS_INCLUDES)/%(path)/,%(includes))
2473 BD_INCL_FILES += $(BD_INCL_FILES2)
2475 $(BD_INCL_FILES2) : $(AROS_INCLUDES)/%(path)/% : $(BD_INC_PATH)%
2480 %(mmake) : $(BD_INCL_FILES)
2484 $(BD_INCL_FILES) : | $(dir $(BD_INCL_FILES))
2485 GLOB_MKDIRS += $(dir $(BD_INCL_FILES))
2487 #------------------------------------------------------------------------------
2490 #------------------------------------------------------------------------------
2491 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
2492 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
2493 STUBS_MEM := $(addsuffix .o,$(STUBS))
2494 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
2495 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
2496 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
2498 #MM- linklibs : hidd-%(hidd)-stubs
2499 #MM- %(parenttarget): hidd-%(hidd)-stubs
2500 #MM hidd-%(hidd)-stubs : includes includes-copy
2501 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
2503 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
2506 $(STUBS_OBJ) : $(STUBS_SRC)
2507 %compile_q cmd="$(TARGET_CC) $(TARGET_CFLAGS)" opt=%(cflags) iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
2509 $(STUBS_DEP) : $(STUBS_SRC)
2510 %mkdepend_q flags=%(dflags)
2513 %mkdirs_q $(OBJDIR) $(AROS_LIB)
2517 -@$(RM) $(HIDD_LIB) $(OBJDIR)
2519 DEPS := $(DEPS) $(STUBS_DEP)
2522 #------------------------------------------------------------------------------
2525 #------------------------------------------------------------------------------
2526 # Build an imported source tree which uses the configure script from the
2527 # autoconf package. This rule will try to "integrate" the produced files as
2528 # much as possible in the AROS build, for example by putting libraries in the
2529 # standard library directory, includes in the standard include directory, and
2530 # so on. You can however override this behaviour.
2532 # As a special "bonus" for you, the PROGDIR environment variable is defined to
2533 # be %(bindir) (or its deduced value) when running "make install", and
2534 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
2535 # configure script some more parameters whose value depends upon the PROGDIR
2536 # env var, so that the program gets all its stuff installed in the proper place
2537 # when building it, but when running it from inside AROS it can also find that
2538 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
2539 # the configuration parameters set when running ./configure
2541 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
2542 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
2543 # to the name which has to follow it.
2547 # - mmake = the meta make target.
2548 # - package = name of the package to be built.
2549 # - srcdir = the location of the unpacked source code. Defaults
2550 # to $(SRCDIR)/$(CURDIR).
2551 # - prefix = the target directory. Must be an absolute path of the
2552 # host system. Defaults to $(AROS_CONTRIB).
2553 # - aros_prefix = set a path which is valid within the AROS filesystem.
2554 # Defaults to the value of the prefix option.
2555 # - extraoptions = additional options for the configure script.
2556 # - extracflags = additional flags which are used for both C and C++.
2557 # - nix_dir_layout = if yes the binary will be stored in a bin subdirectory.
2558 # Defaults to the value of the nix argument.
2559 # - nix = enable u*nix path handling, i.e. a path like
2560 # /progdir//./file will be translated to
2561 # progdir:file during run-time. Defaults to no.
2562 # - compiler = target, host or kernel. Defaults to target.
2563 # - install_target = the command used for installing. Defaults to install. Leave
2564 # it empty if you want to suppress installing.
2565 # - preconfigure = a metatarget which is executed before configure is called.
2566 # - postconfigure = a metatarget which is executed after configure is called.
2567 # - postinstall = a metatarget which is executed after installing.
2568 # - install_env = set additional options for installing.
2569 # - use_build_env = if yes the configuration environment is used for
2570 # installing, too. Defaults to no.
2572 # The arguments aros_prefix, nix and nix_dir_layout are related. The logic is
2576 # --prefix = $(aros_prefix)
2577 # progdir = $(aros_prefix)/bin
2580 # --prefix = /PROGDIR
2581 # --bindir = /PROGDIR
2582 # --sbindir = /PROGDIR
2584 # --includedir = /INCLUDE
2585 # --oldincludedir = /INCLUDE
2587 # --prefix = $(aros_prefix)
2590 # progdir = $(aros_prefix)
2593 # bindir = $(prefix)
2594 # sbindir = $(prefix)
2595 # libdir = $(AROS_LIB)
2596 # includedir = $(AROS_INCLUDES)
2597 # oldincludedir = $(AROS_INCLUDES)
2601 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) gendir= prefix= \
2602 aros_prefix= extraoptions= extracflags= nix_dir_layout= nix=no compiler=target \
2603 install_target=install preconfigure= postconfigure= postinstall= \
2604 install_env= use_build_env=no
2607 %(mmake)-prefix := %(prefix)
2609 %(mmake)-prefix := $(AROS_CONTRIB)
2612 ifneq (%(aros_prefix),)
2613 %(mmake)-aros_prefix := %(aros_prefix)
2615 %(mmake)-aros_prefix := $(%(mmake)-prefix)
2619 %(mmake)-nix := -nix
2620 %(mmake)-volpfx := /
2621 %(mmake)-volsfx := /
2623 ifeq (%(nix_dir_layout),)
2624 %(mmake)-nix_dir_layout := yes
2627 %(mmake)-volsfx := :
2629 ifeq (%(nix_dir_layout),)
2630 %(mmake)-nix_dir_layout := no
2634 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
2636 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
2637 exec_prefix=$(%(mmake)-prefix) %(install_env)
2639 # Check if chosen compiler is valid
2640 ifeq ($(findstring %(compiler),host target kernel),)
2641 $(error unknown compiler %(compiler))
2644 # Set legacy 'host' variable based on chosen compiler
2645 ifeq (%(compiler),host)
2648 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
2650 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
2655 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
2657 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
2662 %(mmake)-pkgdir := %(gendir)/$(CURDIR)
2664 %(mmake)-pkgdir := %(gendir)/$(CURDIR)/%(package)
2668 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
2669 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
2671 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
2672 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
2673 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2676 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
2677 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
2679 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2682 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
2684 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
2685 sbindir=$(%(mmake)-prefix) \
2686 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
2687 oldincludedir=$(AROS_INCLUDES) %(install_env)
2690 ifneq ($(DEBUG),yes)
2691 %(mmake)-s_flag = -s
2694 # Set up build environment, and options for configure script
2695 ifeq (%(compiler),host)
2698 CXXCPP="$(HOST_CPP)" \
2699 CC="$(HOST_CC) $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include" \
2700 CXX="$(HOST_CXX) $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include" \
2701 LDFLAGS="-L$(CROSSTOOLSDIR)/lib" \
2702 TARGET_CC="$(KERNEL_CC) $(KERNEL_CFLAGS) $(%(mmake)-s_flag)" \
2703 TARGET_AS="$(TARGET_AS)" OBJCOPY="$(OBJCOPY)" \
2704 TARGET_RANLIB="$(RANLIB)" TARGET_STRIP="$(STRIP_PLAIN)" \
2705 TARGET_NM="$(NM_PLAIN)"
2707 ifeq (%(compiler),target)
2709 PKG_CONFIG_LIBDIR="$(AROS_DEVELOPMENT)/lib/pkgconfig" \
2710 PKG_CONFIG_SYSROOT_DIR="$(AROSDIR)" \
2711 CFLAGS="$(DEBUG_CFLAGS) $(OPTIMIZATION_CFLAGS)" \
2712 CXXFLAGS="$(DEBUG_CFLAGS) $(OPTIMIZATION_CFLAGS)" \
2713 CPP="$(TARGET_CPP)" \
2714 CXXCPP="$(TARGET_CPP)" \
2715 CC="$(TARGET_CC) $(TARGET_CFLAGS) -I$(AROS_DEVELOPMENT)/include %(extracflags) $(ISA_FLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)"\
2716 CXX="$(TARGET_CXX) $(TARGET_CFLAGS) -I$(AROS_DEVELOPMENT)/include %(extracflags) $(ISA_FLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)"\
2717 LDFLAGS="-L$(AROS_DEVELOPMENT)/lib" \
2718 AS="$(TARGET_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)" AR="$(AR_PLAIN)" STRIP="$(STRIP_PLAIN)"\
2719 TARGET_CC="$(KERNEL_CC) $(KERNEL_CFLAGS) $(%(mmake)-s_flag)"\
2720 TARGET_AS="$(TARGET_AS)" OBJCOPY="$(OBJCOPY)"\
2721 TARGET_RANLIB="$(RANLIB)" TARGET_STRIP="$(STRIP_PLAIN)"\
2722 TARGET_NM="$(NM_PLAIN)" \
2723 CC_FOR_TARGET="$(TARGET_CC) $(TARGET_CFLAGS) -L$(AROS_DEVELOPMENT)/lib -I$(AROS_DEVELOPMENT)/include %(extracflags) $(ISA_FLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)"\
2724 CXX_FOR_TARGET="$(TARGET_CXX) $(TARGET_CFLAGS) -L$(AROS_DEVELOPMENT)/lib -I$(AROS_DEVELOPMENT)/include %(extracflags) $(ISA_FLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)"
2725 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)\
2726 --host=$(AROS_TARGET_CPU)-aros\
2727 --target=$(AROS_TARGET_CPU)-aros\
2729 --without-x --without-pic --disable-shared
2731 ifeq (%(compiler),kernel)
2733 CPP="$(KERNEL_CPP)" \
2734 CXXCPP="$(KERNEL_CPP)" \
2735 CC="$(KERNEL_CC) $(KERNEL_CFLAGS) %(extracflags) $(%(mmake)-s_flag)"\
2736 CXX="$(KERNEL_CXX) $(KERNEL_CFLAGS) %(extracflags) $(%(mmake)-s_flag)"\
2737 AS="$(KERNEL_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)"\
2738 TARGET_RANLIB="$(RANLIB)" TARGET_STRIP="$(STRIP_PLAIN)" \
2739 TARGET_NM="$(NM_PLAIN)"
2740 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)\
2741 --host=$(AROS_TARGET_CPU)-aros\
2742 --target=$(AROS_TARGET_CPU)-aros --disable-nls\
2743 --without-x --without-pic --disable-shared
2746 ifeq (%(use_build_env),yes)
2747 BUILD_ENV := $(CONFIG_ENV)
2751 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
2753 # When building for the host, we don't need to build the
2754 # linklibs - this is especially true when building the
2755 # crosstool toolchain on 'foreign' architectures (such as
2756 # building PPC on x86)
2758 #MM- %(mmake)-host : setup includes %(mmake)-quick
2759 #MM- %(mmake)-target : setup includes core-linklibs %(mmake)-quick
2760 #MM- %(mmake): %(mmake)-%(compiler)
2762 # Using -j1 in install_command may result in a warning but finally
2763 # it does its job. make install for gcc does not work reliably for -jN
2765 ifneq (%(install_target),)
2766 %(mmake)-install_command = \
2767 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2768 -C $(%(mmake)-pkgdir) %(install_target) -j1
2770 %(mmake)-uninstall_command = \
2771 $(RM) $(%(mmake)-installflag) && \
2772 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" \
2773 $(%(mmake)-install_opts) -C $(%(mmake)-pkgdir) uninstall
2775 %(mmake)-install_command := true
2776 %(mmake)-uninstall_command := true
2779 #MM- %(mmake)-quick : %(preconfigure) %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
2782 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
2784 $(%(mmake)-installflag) : $(%(mmake)-configflag)
2785 if ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q -C $(%(mmake)-pkgdir); then \
2786 $(RM) $(%(mmake)-installflag) && \
2787 $(BUILD_ENV) $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)"\
2788 -C $(%(mmake)-pkgdir) && \
2789 $(%(mmake)-install_command) && \
2790 $(TOUCH) $@ -r $^; \
2793 $(%(mmake)-pkgdir)/.files-touched:
2794 %mkdirs_q $(%(mmake)-pkgdir)
2795 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/configure '{}' \; && \
2799 %(mmake)-uninstall :
2800 $(%(mmake)-uninstall_command)
2803 %(mmake)-configure : $(%(mmake)-configflag)
2805 $(%(mmake)-configflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
2806 $(%(mmake)-configflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2808 %mkdirs_q $(%(mmake)-pkgdir)
2809 cd $(%(mmake)-pkgdir) && \
2810 find . -name config.cache -exec $(RM) '{}' \; && \
2811 $(CONFIG_ENV) $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) \
2812 %(extraoptions) && \
2816 %(mmake)-clean : %(mmake)-uninstall
2817 @$(RM) $(%(mmake)-pkgdir)
2819 #------------------------------------------------------------------------------
2822 #------------------------------------------------------------------------------
2823 # Given an archive name, patches names and locations where to find them, fetch
2824 # the archive and the patches from any of those locations, unpack the archive
2825 # and then apply the patches.
2827 # Locations currently supported are http and ftp sites, plus local filesystem
2828 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
2829 # the fetch.sh script needs to be modified, since this macro relies on that script.
2833 # - mmake = mmaketarget
2834 # - archive_origins = list of locations where to find the archive. They are tried
2835 # in sequence, until the archive is found and fetching it
2836 # succeeded. If not specified, the current directory is assumed.
2837 # - archive = the archive name. Mandatory.
2838 # - suffixes = a list of suffixes to append to the the package name plus the
2839 # version. Each one of them is tried until a matching archive is
2840 # found. They are appended to patches and these are tried the
2841 # same way as packages are.
2842 # - location = the local directory where to put the fetched archive and patches.
2843 # If not specified, the directory specified by destination is used.
2844 # - destination = the directory to unpack the archive to.
2845 # If not specified, the current directory is assumed.
2846 # - patches_origins = list of locations where to find the patches. They are tried
2847 # in sequence, until a patch is found and fetching it
2848 # succeeded. If not specified, the current directory is assumed.
2849 # - patches_specs = list of "patch specs". A patch spec is of the form
2850 # patch_name[:[patch_subdir][:patch_opt]].
2852 # - patch_name = the name of the patch file
2853 # - patch_subdir = the directory within \destination\ where to
2855 # - patch_opt = any options to pass to the `patch' command
2856 # when applying the patch.
2858 # The patch_subdir and patch_opt fields are optional.
2860 %define fetch mmake=/A archive_origins=. archive=/A suffixes= location= destination=. \
2861 patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
2865 ifneq (%(location),)
2866 %(mmake)-location := %(location)
2868 %(mmake)-location := %(destination)
2873 $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
2874 -d %(destination) -po "%(patches_origins)" -p "%(patches_specs)"
2876 #------------------------------------------------------------------------------
2879 #------------------------------------------------------------------------------
2880 # This macro can aid in patch creation for fetched ports. It temporarily creates another
2881 # unpatched source tree and runs diff against this and a previously fetched and possibly
2882 # patched tree. Depending on what happens after patching during a normal build it might
2883 # give best results if the new patch is created directly after fetch.
2887 # - mmake = mmaketarget
2888 # - archive = archive base name
2889 # - srcdir = the top level directory the package is unpacked to, useful if
2890 # an archive unpacks to a directory other than its name suggests.
2891 # this should not be deeper than a single path element.
2892 # - suffixes = a list of suffixes to append to the the package name plus the
2893 # version. Each one of them is tried until a matching archive is
2895 # - destination = the directory to unpack the archive to.
2896 # - excludes = diff patterns to exclude files or directories from the patch
2898 %define create_patch mmake=/A archive=/A srcdir= suffixes="tar.bz2 tar.gz" destination=/A excludes=
2902 ifneq (%(excludes),)
2903 %(mmake)-exclude := -X ./exclude.patterns
2907 %(mmake)-srcdir := %(srcdir)
2909 %(mmake)-srcdir := %(archive)
2914 @$(FETCH) -a %(archive) -s "%(suffixes)" -l $(PORTSSOURCEDIR) -d %(destination)/tmp ; \
2915 $(MV) %(destination)/$(%(mmake)-srcdir) %(destination)/tmp/$(%(mmake)-srcdir).aros ; \
2916 cd %(destination)/tmp ; \
2917 $(FOR) f in %(excludes) ; do \
2918 $(ECHO) $$f >> ./exclude.patterns ; \
2920 diff -ruN $(%(mmake)-exclude) \
2921 $(%(mmake)-srcdir) \
2922 $(%(mmake)-srcdir).aros \
2923 >$(SRCDIR)/$(CURDIR)/%(archive)-aros-new.diff ; \
2924 $(MV) %(destination)/tmp/$(%(mmake)-srcdir).aros %(destination)/$(%(mmake)-srcdir) ; \
2925 $(RM) %(destination)/tmp
2927 #------------------------------------------------------------------------------
2930 #------------------------------------------------------------------------------
2931 # Joins the features of %fetch and %build_with_configure.
2933 # If a patch is provided, it *must* be named the following way:
2935 # <package name>-<version number>-aros.diff
2937 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
2938 # CD'ing into the archive's extracted directory.
2940 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
2941 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
2942 # to make that patch fully comprehensive.
2946 # - mmake = the meta make target.
2947 # - package = the GNU package name, sans version and archive format suffixes.
2948 # - subpackage = ???
2949 # - compiler = same meaning as the one for the %build_with_configure macro.
2950 # - install_target = same meaning as the one for the %build_with_configure macro.
2951 # - version = the package's version number, or otherwise any other version string.
2952 # It gets appended to the package name to form the basename of the archive.
2953 # - suffixes = a list of suffixes to apped to the the package name plus the
2954 # version. Each one of them is tried until a matching archive is found.
2955 # Defaults to "tar.bz2 tar.gz".
2956 # - srcdir = the top level directory the package is unpacked to (see create_patch).
2957 # - builddir = override the location we expect to run configure/make in.
2958 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
2959 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
2960 # fetched or not. Default to no.
2961 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
2962 # - prefix = same meaning as the one for the %build_with_configure macro.
2963 # - aros_prefix = same meaning as the one for the %build_with_configure macro.
2964 # - extraoptions = same meaning as the one for the %build_with_configure macro.
2965 # - extracflags = same meaning as the one for the %build_with_configure macro.
2966 # - preconfigure = same meaning as the one for the %build_with_configure macro.
2967 # - postconfigure = same meaning as the one for the %build_with_configure macro.
2968 # - postinstall = same meaning as the one for the %build_with_configure macro.
2969 # - install_env = same meaning as the one for the %build_with_configure macro.
2970 # - use_build_env = same meaning as the one for the %build_with_configure macro.
2971 # - nix = same meaning as the one for the %build_with_configure macro.
2972 # - nix_dir_layout = same meaning as the one for the %build_with_configure macro.
2973 # - create_pkg = create a distributable package of the compiled sources, defaults to no
2975 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target install_target=install \
2976 version=/A suffixes="tar.bz2 tar.gz" srcdir= builddir= gendir= package_repo= patch=no patch_repo= \
2977 prefix= aros_prefix= extraoptions= extracflags= preconfigure= postconfigure= postinstall= \
2978 install_env= use_build_env=no nix=no nix_dir_layout= create_pkg=no
2980 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
2981 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
2982 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
2983 #MM- %(mmake)-create-patch : %(mmake)-%(subpackage)-create-patch
2985 %(mmake)-archbase := %(package)-%(version)
2987 ifeq (%(compiler),host)
2988 %(mmake)-portdir := $(HOSTDIR)/Ports/%(package)
2990 %(mmake)-portdir := $(PORTSDIR)/%(package)
2994 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
2996 %(mmake)-prefix := %(prefix)
2999 ifneq (%(subpackage),)
3000 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
3002 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
3006 %(mmake)-%(subpackage)-srcdir := %(srcdir)
3008 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
3011 ifneq (%(builddir),)
3012 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)/%(builddir)
3014 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)
3018 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-f,-p1
3020 %(mmake)-%(subpackage)-patches_specs := ::
3023 %fetch mmake=%(mmake)-%(subpackage)-fetch archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
3024 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
3025 archive_origins=". %(package_repo)" \
3026 patches_specs="$(%(mmake)-%(subpackage)-patches_specs)" patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
3028 %create_patch mmake=%(mmake)-%(subpackage)-create-patch \
3029 archive=$(%(mmake)-%(subpackage)-archbase) \
3030 srcdir=$(%(mmake)-%(subpackage)-srcdir) \
3031 suffixes="%(suffixes)" \
3032 destination=$(%(mmake)-portdir)
3034 #MM- %(mmake) : %(mmake)-%(subpackage)
3036 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
3038 %(mmake)-%(subpackage)-package-basename := \
3039 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
3041 ifneq (%(create_pkg),no)
3042 %(mmake)-%(subpackage)-package := $(%(mmake)-%(subpackage)-package-basename).tar.bz2
3045 %build_with_configure mmake=%(mmake)-%(subpackage) package=%(package) compiler=%(compiler) install_target=%(install_target) \
3046 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-builddir) gendir=%(gendir) \
3047 install_env=%(install_env) use_build_env=%(use_build_env) \
3048 nix=%(nix) nix_dir_layout=%(nix_dir_layout) prefix="$(%(mmake)-prefix)" \
3049 aros_prefix="%(aros_prefix)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
3050 %(mmake)-%(subpackage)-make-package" extraoptions="%(extraoptions)" extracflags="%(extracflags)"
3052 .PHONY : %(mmake)-%(subpackage)-make-package %(mmake)-%(subpackage)-create-patch
3053 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
3056 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package)
3058 #There seems to be a bug, either with my clock or with make, 'cause it may happen
3059 #that $^ and $@ have exactly the same mtime, and in that case make tries
3060 #to rebuild $@ again, which would fail because the directory where
3061 #the package got installed would not exist anymore.
3062 #We work this around by using an if statement to manually check the mtimes.
3063 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
3064 @$(IF) test $(%(mmake)-installflag) -nt $@ || ! test -f $@; then \
3066 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
3067 mkdir -p "$(DISTDIR)/Packages" ; \
3068 mkdir -p "$(%(mmake)-prefix)" ; \
3069 cd $(%(mmake)-%(subpackage)-package-dir) ; \
3070 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
3071 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
3074 #------------------------------------------------------------------------------
3077 #------------------------------------------------------------------------------
3078 # Joins the features of %fetch and %build_with_configure, taking advantage of
3079 # the naming scheme of GNU packages. GNU packages names are in the form
3081 # <package name>-<version number>.<archive format suffix>
3083 # If a patch is provided, it *must* be named the following way:
3085 # <package name>-<version number>-aros.diff
3087 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3088 # CD'ing into the archive's extracted directory.
3090 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3091 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3092 # to make that patch fully comprehensive.
3094 # NOTE: GNU packages are always compiled with *nix semantics turned on.
3098 # Arguments have the same meaning as the one for the %fetch_and_build macro, except:
3100 # - prefix = defaults to $(GNUDIR).
3101 # - aros_prefix = defaults to /GNU.
3103 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
3104 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
3105 aros_prefix=/GNU extraoptions= extracflags= preconfigure= postconfigure= postinstall=
3107 GNU_REPOSITORY := gnu://
3109 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
3110 suffixes="%(suffixes)" srcdir="%(srcdir)" \
3111 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
3112 patch="%(patch)" patch_repo="%(patch_repo)" \
3113 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" extracflags="%(extracflags)" \
3114 preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=yes
3117 #------------------------------------------------------------------------------
3120 #------------------------------------------------------------------------------
3121 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
3122 # that the package is a "Development" package, and as such it needs to be placed
3123 # under the $(AROS_DEVELOPMENT) directory, as a default.
3125 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
3126 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
3127 # "mmake" argument, because the metatarget is implicitely defined as
3129 # #MM- development-%(package)
3131 %define fetch_and_build_gnu_development package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
3132 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPMENT) \
3133 aros_prefix=/Development preconfigure= postconfigure= postinstall= extraoptions= extracflags=
3135 #MM- development : development-%(package)
3138 %fetch_and_build_gnu mmake=development-%(package) package=%(package) subpackage="%(subpackage)" \
3139 version=%(version) suffixes="%(suffixes)" srcdir="%(srcdir)" \
3140 package_repo="%(package_repo)" patch="%(patch)" patch_repo="%(patch_repo)" prefix=%(prefix) \
3141 aros_prefix="%(aros_prefix)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="postinstall-%(package)-delete-la-files %(postinstall)" \
3142 extraoptions="%(extraoptions)" extracflags="%(extracflags)"
3145 postinstall-%(package)-delete-la-files:
3146 $(RM) $(AROS_DEVELOPMENT)/lib/*.la
3149 #------------------------------------------------------------------------------
3151 # Builds a kickstart package in PKG format
3155 # - mmake = target name
3156 # - file = destination file name with path
3158 # Other arguments are self-explanatory
3160 %define make_package mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
3161 arch_classes= arch_devs= arch_handlers= arch_hidds= arch_libs= arch_res=
3163 PKG_CLASSES := $(addprefix $(AROS_CLASSES)/,$(addsuffix .class, %(classes)))
3164 PKG_DEVICES := $(addprefix $(AROS_DEVS)/,$(addsuffix .device, %(devs)))
3165 PKG_HANDLERS := $(addprefix $(AROS_FS)/,$(addsuffix -handler, %(handlers)))
3166 PKG_HIDD := $(addprefix $(AROS_DEVS)/Drivers/,$(addsuffix .hidd, %(hidds)))
3167 PKG_LIBS := $(addprefix $(AROS_LIBRARIES)/,$(addsuffix .library, %(libs)))
3168 PKG_RESOURCES := $(addprefix $(AROS_DEVS)/,$(addsuffix .resource, %(res)))
3170 PKG_CLASSES_ARCH := $(addprefix $(AROS_CLASSES_ARCH)/,$(addsuffix .class, %(arch_classes)))
3171 PKG_DEVICES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .device, %(arch_devs)))
3172 PKG_HANDLERS_ARCH := $(addprefix $(AROS_FS_ARCH)/,$(addsuffix -handler, %(arch_handlers)))
3173 PKG_HIDD_ARCH := $(addprefix $(AROS_DEVS_ARCH)/Drivers/,$(addsuffix .hidd, %(arch_hidds)))
3174 PKG_LIBRARIES_ARCH := $(addprefix $(AROS_LIBRARIES_ARCH)/,$(addsuffix .library, %(arch_libs)))
3175 PKG_RESOURCES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .resource, %(arch_res)))
3177 PKG_FILES := $(PKG_CLASSES) $(PKG_DEVICES) $(PKG_HANDLERS) $(PKG_HIDD) $(PKG_LIBS) $(PKG_RESOURCES) \
3178 $(PKG_CLASSES_ARCH) $(PKG_DEVICES_ARCH) $(PKG_HANDLERS_ARCH) $(PKG_HIDD_ARCH) $(PKG_LIBRARIES_ARCH) $(PKG_RESOURCES_ARCH)
3179 PKG_DIR := $(dir %(file))
3185 %(mmake)-quick : %(file)
3187 %(file): $(PKG_FILES) | $(PKG_DIR)
3188 @$(ECHO) Packaging $@...
3189 @$(SRCDIR)/tools/package/pkg c $@ $^
3191 %compress_file mmake=%(mmake) file=%(file)
3193 GLOB_MKDIRS += $(PKG_DIR)
3197 #------------------------------------------------------------------------------
3198 # Compresses %(file) with a gzip.
3199 # Good in conjunction with for example %build_prog
3201 %define compress_file mmake=/A file=/A
3203 #MM- %(mmake)-gz : %(mmake) %(mmake)-gz-quick
3206 %(mmake)-gz-quick : %(file).gz
3209 @$(ECHO) Compressing $(subst $(TARGETDIR)/,,$^)...
3214 #------------------------------------------------------------------------------
3215 # Links a kickstart module in ELF format
3216 # Arguments are similar to make_package
3218 %define link_kickstart mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
3219 startup= uselibs= ldflags=$(LDFLAGS) map= deps=
3221 KOBJ_CLASSES := $(addprefix $(KOBJSDIR)/, $(addsuffix _class.o, %(classes)))
3222 KOBJ_DEVICES := $(addprefix $(KOBJSDIR)/, $(addsuffix _device.o, %(devs)))
3223 KOBJ_HANDLERS := $(addprefix $(KOBJSDIR)/, $(addsuffix _handler.o, %(handlers)))
3224 KOBJ_HIDD := $(addprefix $(KOBJSDIR)/, $(addsuffix _hidd.o, %(hidds)))
3225 KOBJ_LIBS := $(addprefix $(KOBJSDIR)/, $(addsuffix _library.o, %(libs)))
3226 KOBJ_RES := $(addprefix $(KOBJSDIR)/, $(addsuffix _resource.o, %(res)))
3229 KOBJ_STARTUP := $(GENDIR)/$(RESIDENT_BEGIN).o
3231 KOBJ_STARTUP := %(startup)
3234 KOBJS := $(KOBJ_STARTUP) $(KOBJ_CLASSES) $(KOBJ_HANDLERS) $(KOBJ_LIBS) $(KOBJ_DEVICES) $(KOBJ_HIDD) $(KOBJ_RES)
3236 TMP_LDFLAGS := %(ldflags)
3238 # Make a list of the lib files this program depends on.
3239 # In LDFLAGS remove white space between -L and directory
3240 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
3241 # Filter out only the libdirs and remove -L
3242 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
3244 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
3245 # Add normal linklib path
3246 TMP_DIRS += $(AROS_LIB)/
3247 # add lib and .a to static linklib names
3248 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
3249 # search for the linklibs in the given path, ignore ones not found
3250 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
3251 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
3254 TMP_DIRS += $(dir %(file))
3256 TMP_LDFLAGS += $(GENMAP) %(map)
3257 TMP_DIRS += $(dir %(map))
3260 #MM %(mmake) : %(deps)
3266 %(mmake)-quick : %(file)
3268 %(file): KOBJS := $(KOBJS)
3269 %(file): LDFLAGS := $(TMP_LDFLAGS) $(NOSTARTUP_LDFLAGS) \
3270 -static -nosysbase -Wl,-Ur
3271 %(file): LDLIBS := $(addprefix -l, %(uselibs))
3272 %(file): $(KOBJS) $(DEPLIBS) | $(TMP_DIRS)
3273 @$(ECHO) "Kickstart $(subst $(TARGETDIR)/,,$@)..."
3274 @$(TARGET_CC) -o $@ $(KOBJS) $(LDFLAGS) $(LDLIBS)
3277 %compress_file mmake=%(mmake) file=%(file)
3279 GLOB_MKDIRS += $(TMP_DIRS)