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_SYSROOT)" 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) -D__SRCFILENAME__="\"$(subst $(TOP)/,,$(subst $(SRCDIR)/,,$(abspath %(from))))"\" -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) -D__SRCFILENAME__=\"$(subst $(TOP)/,,$(subst $(SRCDIR)/,,$(abspath %(from))))\" -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) -D__SRCFILENAME__=\"$(subst $(TOP)/,,$(subst $(SRCDIR)/,,$(abspath %(from))))\" -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) $(TARGET_SYSROOT)" 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) $(TARGET_SYSROOT)" opt=$(LDFLAGS) from=$< to=$@ libs=$(LIBS) strip=$(STRIP) objdir=$(GENDIR)/$(CURDIR)
66 @$(eval LINKTARGET=%(to))
67 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$(LINKTARGET))..."
68 @$(eval LINKTMPFILE=%(objdir)/$(notdir $(LINKTARGET)))
69 @$(IF) %(cmd) %(from) -o $(LINKTMPFILE) %(opt) %(libs) 2>&1 > $(GENDIR)/cerrors 2>&1 ; then \
70 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
71 $(ECHO) "$(LINKTARGET): %(cmd) %(from) -o $(LINKTARGET) %(opt) %(libs)" >> $(GENDIR)/errors ; \
72 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
76 $(CP) $(LINKTMPFILE) $(LINKTARGET) ; \
78 $(ECHO) "Link failed: %(cmd) %(from) -o $(LINKTARGET) %(opt) %(libs)" 1>&2 ; \
79 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
82 @$(IF) [ "$(DEBUG)" = "yes" ]; then \
83 %(strip) $(LINKTARGET) --only-keep-debug -o $(LINKTARGET).dbg; \
85 %(strip) $(LINKTARGET)
87 #------------------------------------------------------------------------------
90 #-------------------------------------------------------------------------
91 # Link a module based upon a number of arguments and the standard $(LIBS)
92 # and $(DEPLIBS) make variables.
94 %define link_module_q cmd="$(AROS_CC) $(TARGET_SYSROOT)" err="$(notdir $@).err" objs=/A endtag= module=$(MODULE) ldflags=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
95 @$(ECHO) "Building $(subst $(TARGETDIR)/,,$@) ..."
96 @$(IF) %(cmd) $(NOSTARTUP_LDFLAGS) \
97 $(GENMAP) %(objdir)/%(module).map \
98 %(objs) %(libs) %(ldflags) %(endtag) \
99 -o $@ 2>&1 > %(objdir)/%(err); \
101 cat %(objdir)/%(err); \
103 echo "%(cmd) $(NOSTARTUP_LDFLAGS) $(GENMAP) %(objdir)/%(module).map %(objs) %(libs) %(ldflags) %(endtag) -o $@"; \
104 cat %(objdir)/%(err); \
107 @$(IF) $(TEST) ! -s %(objdir)/%(err) ; then $(RM) %(objdir)/%(err) ; fi
108 @$(IF) [ "$(DEBUG)" = "yes" ]; then \
109 $(STRIP) $@ --only-keep-debug -o $@.dbg; \
113 #------------------------------------------------------------------------------
116 #------------------------------------------------------------------------------
118 %define mklib_q ar=$(AR) ranlib=$(RANLIB) to=$@ from=$(OBJS)
119 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,%(to))..."
123 #------------------------------------------------------------------------------
126 #------------------------------------------------------------------------------
127 # Create the dependency file %(to) for %(from)
128 %define mkdepend_q flags=$(CFLAGS) from=$< to=$@ cc="$(AROS_CC) $(TARGET_SYSROOT)"
129 %mkdir_q dir="$(dir %(to))"
130 @$(ECHO) "Makedepend $(if $(filter /%,%(from)),$(if $(filter $(SRCDIR)/%,$(abspath %(from))),$(patsubst $(SRCDIR)/%,%,$(abspath %(from))),$(patsubst $(TOP)/%,%,$(abspath %(from)))),$(patsubst $(SRCDIR)/%,%,$(abspath $(SRCDIR)/$(CURDIR)/%(from))))..."
131 @AROS_CC="%(cc)" $(MKDEPEND) %(flags) -I$(TOP)/$(CURDIR) -I$(SRCDIR)/$(CURDIR) %(from) -o %(to)
133 #------------------------------------------------------------------------------
136 #------------------------------------------------------------------------------
137 # Create one directory without any output
138 %define mkdir_q dir=.
139 @$(IF) $(TEST) ! -d %(dir) ; then $(MKDIR) %(dir) ; else $(NOP) ; fi
141 #------------------------------------------------------------------------------
144 #------------------------------------------------------------------------------
145 # Create several directories without any output
146 %define mkdirs_q dirs=/M
147 @$(FOR) dir in %(dirs) ; do \
148 $(IF) $(TEST) ! -d $$dir ; then $(MKDIR) $$dir ; else $(NOP) ; fi ; \
151 #------------------------------------------------------------------------------
154 #############################################################################
155 #############################################################################
157 ## Here are the mmakefile macros that are used to do certain tasks in a ##
158 ## mmakefile. They consist of one or more full makefile rules. ##
159 ## In general the files generated in these macros are also defined as ##
160 ## make targets so that they can be used as a dependency in other rules ##
162 #############################################################################
163 #############################################################################
165 #------------------------------------------------------------------------------
166 # Generate a unique id for each of the %build... rules
167 %define buildid targets=/A
169 ifneq ($(filter $(TARGET),%(targets)),)
170 BDTARGETID := $(BDID)
173 #------------------------------------------------------------------------------
176 #------------------------------------------------------------------------------
177 # Copy file %(from) to %(to) in a makefile rule
178 %define rule_copy from=/A to=/A
182 #------------------------------------------------------------------------------
185 #------------------------------------------------------------------------------
186 # Copy the files %(files) to %(targetdir). For each file in %(files),
187 # %(srcdir)/file is copied to %(targetdir)/file. The targetdir and the
188 # appropriate subdirs are not generated by this rule so they have to be
190 %define rule_copy_multi files=/A targetdir=/A srcdir=.
192 $(addprefix %(targetdir)/,%(files)) : %(targetdir)/% : %(srcdir)/%
195 #------------------------------------------------------------------------------
198 #------------------------------------------------------------------------------
199 # Copy the files %(files) to %(targetdir). For each file in %(files),
200 # %(srcdir)/file is copied to %(targetdir)/file if these files are different.
201 # %(stampfile) is used to keep track of when the last time the comparison has
202 # been done. The targetdir and the appropriate subdirs are not generated by
203 # this rule so they have to be present.
204 %define rule_copy_diff_multi files=/A targetdir=/A srcdir=. \
205 stampfile=$(TMP_SRCDIR)/.copy_stamp
207 TMP_SRCDIR := %(srcdir)
209 $(addprefix %(targetdir)/,%(files)) : | %(stampfile)
211 %(stampfile) : COPYSRCDIR := %(srcdir)
212 %(stampfile) : TGTDIR := %(targetdir)
213 %(stampfile) : FILES := %(files)
214 %(stampfile) : $(addprefix %(srcdir)/,%(files))
215 @for f in $(FILES); do \
216 $(IF) ! $(CMP) -s $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; then \
217 $(CP) $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; \
222 #------------------------------------------------------------------------------
225 #------------------------------------------------------------------------------
226 # Will join all the files in %(from) to %(to). When text is specified it will
228 # Restriction: at the moment when using a non-empty target dir %(from) may
230 %define rule_join to=/A from=/A text=
238 #------------------------------------------------------------------------------
241 #------------------------------------------------------------------------------
242 # Include the dependency files and add some internal rules
243 # When depstargets is provided the depencies will only be included when one of
244 # these targets is the $(TARGET). Otherwise the dependencies will only be
245 # included when the $(TARGET) is not for setup or clean
246 %define include_deps deps=$(DEPS)/M depstargets=
248 ifneq (%(depstargets),)
249 ifneq ($(findstring $(TARGET),%(depstargets)),)
253 ifeq (,$(filter clean% %clean %clean% setup% includes% %setup,$(TARGET)))
259 #------------------------------------------------------------------------------
262 #------------------------------------------------------------------------------
263 # Create the directories %(dirs). The creation will be done by adding rules to
264 # the %(setuptarget) make target with setup as the default.
265 %define rule_makedirs dirs=/A setuptarget=setup
267 %(setuptarget) :: %(dirs)
269 GLOB_MKDIRS += %(dirs)
272 #------------------------------------------------------------------------------
275 #------------------------------------------------------------------------------
276 # Generate a rule to compile a C source file to an object file and generate
277 # the dependency file. Basename may contain a directory part, then the source
278 # file has to be in that directory. The generated file will be put in the
279 # object directory without the directory.
281 # - basename: the basename of the file to compile. Use % for a wildcard rule
282 # - cflags (default $(CFLAGS)): the C flags to use for compilation
283 # - dflags: the flags used during creation of dependency file. If not specified
284 # the same value as cflags will be used
285 # - targetdir: the directory to put the .o file and the .d file. By default
286 # it is put in the same directory as the .c file
287 %define rule_compile basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target
292 TMP_TARGETBASE := %(basename)
294 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
297 # Adjust compiler flags to suit C
298 TMP_CFLAGS := %(cflags)
299 TMP_CFLAGS := $(subst -fpermissive,, $(TMP_CFLAGS))
301 TMP_DFLAGS := %(cflags)
303 TMP_DFLAGS := %(dflags)
306 ifeq ($(findstring %(compiler),host kernel target),)
307 $(error unknown compiler %(compiler))
309 ifeq (%(compiler),target)
310 BD_LINK ?= $(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
311 BD_STRIP ?= $(TARGET_STRIP)
312 $(TMP_TARGETBASE).o : TMP_CMD:=$(TARGET_CC) $(TARGET_SYSROOT)
313 $(TMP_TARGETBASE).d : TMP_CMD:=$(TARGET_CC) $(TARGET_SYSROOT)
314 $(TMP_TARGETBASE).o : TMP_CFLAGS:=$(TMP_CFLAGS)
315 $(TMP_TARGETBASE).d : TMP_DFLAGS:=$(TMP_DFLAGS)
316 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
317 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
318 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
319 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
321 ifeq (%(compiler),host)
322 BD_LINK ?= $(HOST_CC) $(HOST_LDFLAGS)
323 BD_STRIP ?= $(HOST_STRIP)
324 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
325 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
326 $(TMP_TARGETBASE).o : TMP_CFLAGS:=$(HOST_CFLAGS) $(TMP_CFLAGS)
327 $(TMP_TARGETBASE).d : TMP_DFLAGS:=$(HOST_CFLAGS) $(TMP_DFLAGS)
328 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
329 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
330 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
331 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
333 ifeq (%(compiler),kernel)
334 BD_LINK ?= $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
335 BD_STRIP ?= $(ECHO) >/dev/null
336 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
337 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
338 $(TMP_TARGETBASE).o : TMP_CFLAGS:=$(KERNEL_CFLAGS) $(TMP_CFLAGS)
339 $(TMP_TARGETBASE).d : TMP_DFLAGS:=$(KERNEL_CFLAGS) $(TMP_DFLAGS)
340 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
341 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
342 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
343 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
346 $(TMP_TARGETBASE).o : CFLAGS := $(TMP_CFLAGS)
347 $(TMP_TARGETBASE).o : %(basename).c
348 %compile_q cmd=$(TMP_CMD) opt=$(TMP_CFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
351 $(TMP_TARGETBASE).d : TMP_DFLAGS:=$(BD_NIXFLAG) $(TMP_DFLAGS)
353 $(TMP_TARGETBASE).d : %(basename).c
354 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
356 #------------------------------------------------------------------------------
359 #------------------------------------------------------------------------------
360 # Generate a rule to compile a C++ source file to an object file and generate
361 # the dependency file. Basename may contain a directory part, then the source
362 # file has to be in that directory. The generated file will be put in the
363 # object directory without the directory.
365 # - basename: the basename of the file to compile. Use % for a wildcard rule
366 # - cflags (default $(CFLAGS)): the C flags to use for compilation
367 # - dflags: the flags used during creation of dependency file. If not specified
368 # the same value as cflags will be used
369 # - targetdir: the directory to put the .o file and the .d file. By default
370 # it is put in the same directory as the .c file
371 %define rule_compile_cxx basename=/A cxxflags=$(CXXFLAGS) dxxflags= targetdir= compiler=target
376 TMP_TARGETBASE := %(basename)
378 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
381 # Adjust compiler flags to suit C++
382 TMP_CXXFLAGS := %(cxxflags)
384 TMP_DXXFLAGS := %(cxxflags)
386 TMP_DXXFLAGS := %(dxxflags)
389 ifeq ($(findstring %(compiler),host kernel target),)
390 $(error unknown compiler %(compiler))
392 ifeq (%(compiler),target)
393 BD_LINK ?= $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
394 BD_STRIP ?= $(TARGET_STRIP)
395 $(TMP_TARGETBASE).o : TMP_CMD:=$(AROS_CXX) $(TARGET_SYSROOT)
396 $(TMP_TARGETBASE).d : TMP_CMD:=$(AROS_CXX) $(TARGET_SYSROOT)
397 $(TMP_TARGETBASE).o : TMP_CXXFLAGS:=$(TMP_CXXFLAGS)
398 $(TMP_TARGETBASE).d : TMP_DXXFLAGS:=$(TMP_DXXFLAGS)
399 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
400 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
401 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
402 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
404 ifeq (%(compiler),host)
405 BD_LINK ?= $(HOST_CXX) $(HOST_LDFLAGS)
406 BD_STRIP ?= $(HOST_STRIP)
407 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CXX)
408 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CXX)
409 $(TMP_TARGETBASE).o : TMP_CXXFLAGS:=$(HOST_CXXFLAGS) $(TMP_CXXFLAGS)
410 $(TMP_TARGETBASE).d : TMP_DXXFLAGS:=$(HOST_CXXFLAGS) $(TMP_DXXFLAGS)
411 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
412 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
413 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
414 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
416 ifeq (%(compiler),kernel)
417 KERNEL_CXX ?= $(KERNEL_CC)
418 BD_LINK ?= $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
419 BD_STRIP ?= $(ECHO) >/dev/null
420 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CXX) $(KERNEL_SYSROOT)
421 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CXX) $(KERNEL_SYSROOT)
422 $(TMP_TARGETBASE).o : TMP_CXXFLAGS:=$(KERNEL_CXXFLAGS) $(TMP_CXXFLAGS)
423 $(TMP_TARGETBASE).d : TMP_DXXFLAGS:=$(KERNEL_CXXFLAGS) $(TMP_DXXFLAGS)
424 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
425 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
426 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
427 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
430 $(TMP_TARGETBASE).o : CXXFLAGS := $(TMP_CXXFLAGS)
431 $(TMP_TARGETBASE).o : %(basename).cpp
432 %compile_q cmd=$(TMP_CMD) opt=$(TMP_CXXFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
435 $(TMP_TARGETBASE).d : TMP_DXXFLAGS:=$(BD_NIXFLAG) $(TMP_DXXFLAGS)
437 $(TMP_TARGETBASE).d : %(basename).cpp
438 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DXXFLAGS)
443 #------------------------------------------------------------------------------
446 #------------------------------------------------------------------------------
447 # Generate a rule to compile an ObjC source file to an object file and generate
448 # the dependency file. Basename may contain a directory part, then the source
449 # file has to be in that directory. The generated file will be put in the
450 # object directory without the directory.
452 # - basename: the basename of the file to compile. Use % for a wildcard rule
453 # - cflags (default $(CFLAGS)): the C flags to use for compilation
454 # - dflags: the flags used during creation of dependency file. If not specified
455 # the same value as cflags will be used
456 # - targetdir: the directory to put the .o file and the .d file. By default
457 # it is put in the same directory as the .m file
458 %define rule_compile_objc basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target
463 TMP_TARGETBASE := %(basename)
465 TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
468 # Adjust compiler flags to suit ObjC
469 TMP_OBJCFLAGS := %(cflags)
470 TMP_OBJCFLAGS := $(TMP_OBJCFLAGS) -isystem $(AROS_DEVELOPER)/include
471 TMP_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(TMP_OBJCFLAGS)))
473 TMP_OBJCDFLAGS := %(cflags)
475 TMP_OBJCDFLAGS := %(dflags)
478 # Define the use of cross compiler
479 ifeq ($(TARGET_OBJC),)
480 TMP_CC := $(TARGET_CC)
482 TMP_CC := $(TARGET_OBJC)
485 ifeq ($(findstring %(compiler),host kernel target),)
486 $(error unknown compiler %(compiler))
488 ifeq (%(compiler),target)
489 BD_LINK ?= $(TMP_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
490 BD_STRIP ?= $(TARGET_STRIP)
491 $(TMP_TARGETBASE).o : TMP_CMD:=$(TMP_CC) $(TARGET_SYSROOT)
492 $(TMP_TARGETBASE).d : TMP_CMD:=$(TMP_CC) $(TARGET_SYSROOT)
493 $(TMP_TARGETBASE).o : TMP_OBJCFLAGS:=$(TMP_OBJCFLAGS)
494 $(TMP_TARGETBASE).d : TMP_OBJCDFLAGS:=$(TMP_OBJCDFLAGS)
495 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
496 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
497 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
498 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
500 ifeq (%(compiler),host)
501 BD_LINK ?= $(HOST_CC) $(HOST_LDFLAGS)
502 BD_STRIP ?= $(HOST_STRIP)
503 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
504 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
505 $(TMP_TARGETBASE).o : TMP_OBJCFLAGS:=$(HOST_CFLAGS) $(TMP_OBJCFLAGS)
506 $(TMP_TARGETBASE).d : TMP_OBJCDFLAGS:=$(HOST_CFLAGS) $(TMP_OBJCDFLAGS)
507 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
508 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
509 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
510 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
512 ifeq (%(compiler),kernel)
513 BD_LINK ?= $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
514 BD_STRIP ?= $(ECHO) >/dev/null
515 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
516 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
517 $(TMP_TARGETBASE).o : TMP_OBJCFLAGS:=$(KERNEL_CFLAGS) $(TMP_OBJCFLAGS)
518 $(TMP_TARGETBASE).d : TMP_OBJCDFLAGS:=$(KERNEL_CFLAGS) $(TMP_OBJCDFLAGS)
519 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
520 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
521 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
522 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
525 $(TMP_TARGETBASE).o : CFLAGS := $(TMP_OBJCFLAGS)
526 $(TMP_TARGETBASE).o : %(basename).m
527 %compile_q cmd=$(TMP_CMD) opt=$(TMP_OBJCFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
530 $(TMP_TARGETBASE).d : TMP_OBJCDFLAGS:=$(BD_NIXFLAG) $(TMP_OBJCDFLAGS)
532 $(TMP_TARGETBASE).d : %(basename).m
533 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_OBJCDFLAGS)
538 #------------------------------------------------------------------------------
541 #------------------------------------------------------------------------------
542 # Generate a rule to compile multiple C source files to an object file and
543 # generate the corresponding dependency files. The generated file will be put
544 # in the object directory without the directory part of the source file.
546 # - basenames: the basenames of the files to compile. The names may include
547 # relative or absolute path names. No wildcard is allowed
548 # - cflags (default $(CFLAGS)): the C flags to use for compilation
549 # - dflags: the flags used during creation of dependency file. If not specified
550 # the same value as cflags will be used
551 # - targetdir: the directory to put the .o file and the .d file. By default
552 # it is put in the same directory as the .c file. When targetdir is not
553 # empty, path names will be stripped from the file names so that all files
554 # are in that dir and not in subdirectories.
555 # - compiler (default target): compiler to use, target, kernel or host
556 %define rule_compile_multi basenames=/A cflags=$(CFLAGS) dflags= srcdir= targetdir= \
562 TMP_SRCWILDCARD := %(srcdir)/%
566 TMP_TARGETS := $(addsuffix .o,%(basenames))
567 TMP_DTARGETS := $(addsuffix .d,%(basenames))
570 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
571 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
572 TMP_TGTWILDCARD := %(targetdir)/%
574 # Be sure that all .c files are generated
575 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .c,%(basenames))
577 # Be sure that all .c files are found
578 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
579 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
580 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
582 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
583 vpath %.c $(TMP_DIRS)
588 TMP_CFLAGS := %(cflags)
590 TMP_DFLAGS := %(cflags)
592 TMP_DFLAGS := %(dflags)
595 ifeq ($(findstring %(compiler),host kernel target),)
596 $(error unknown compiler %(compiler))
598 ifeq (%(compiler),target)
599 BD_LINK ?= $(TARGET_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
600 BD_STRIP ?= $(TARGET_STRIP)
601 BD_ASSEMBLER ?= $(TARGET_CC) $(TARGET_SYSROOT)
602 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TARGET_CC) $(TARGET_SYSROOT)
603 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_CFLAGS:=$(TMP_CFLAGS)
604 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_DFLAGS:=$(TMP_DFLAGS)
605 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
606 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
608 ifeq (%(compiler),host)
609 BD_LINK ?= $(HOST_CC) $(HOST_LDFLAGS)
610 BD_STRIP ?= $(HOST_STRIP)
611 BD_ASSEMBLER ?= $HOST_CC) $(HOST_SYSROOT)
612 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_CC)
613 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_CFLAGS:=$(HOST_CFLAGS) $(TMP_CFLAGS)
614 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_DFLAGS:=$(HOST_CFLAGS) $(TMP_DFLAGS)
615 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
616 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
618 ifeq (%(compiler),kernel)
619 BD_LINK ?= $(KERNEL_CC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
620 BD_STRIP ?= $(ECHO) >/dev/null
621 BD_ASSEMBLER ?= $(KERNEL_CC) $(KERNEL_SYSROOT)
622 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
623 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_CFLAGS:=$(KERNEL_CFLAGS) $(TMP_CFLAGS)
624 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_DFLAGS:=$(KERNEL_CFLAGS) $(TMP_DFLAGS)
625 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
626 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
629 $(TMP_TARGETS) : CFLAGS := %(TMP_CFLAGS)
630 $(TMP_TARGETS) : $(TMP_TGTWILDCARD).o : $(TMP_SRCWILDCARD).c
631 %compile_q cmd=$(CMD) opt=$(TMP_CFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
633 $(TMP_DTARGETS) : $(TMP_TGTWILDCARD).d : $(TMP_SRCWILDCARD).c
634 %mkdepend_q cc=$(CMD) flags=$(TMP_DFLAGS)
636 #------------------------------------------------------------------------------
639 #------------------------------------------------------------------------------
640 # Generate a rule to compile multiple C++ source files to an object file and
641 # generate the corresponding dependency files. The generated file will be put
642 # in the object directory without the directory part of the source file.
644 # - basenames: the basenames of the files to compile. The names may include
645 # relative or absolute path names. No wildcard is allowed. basenames will be
646 # matched to supported AROS_CXXEXTS.
647 # - cflags (default $(CFLAGS)): the C flags to use for compilation
648 # - dflags: the flags used during creation of dependency file. If not specified
649 # the same value as cflags will be used
650 # - targetdir: the directory to put the .o file and the .d file. By default
651 # it is put in the same directory as the .c file. When targetdir is not
652 # empty, path names will be stripped from the file names so that all files
653 # are in that dir and not in subdirectories.
654 # - compiler (default target): compiler to use, target, kernel or host
655 %define rule_compile_cxx_multi basenames=/A cxxflags=$(CXXFLAGS) dxxflags= \
656 targetdir= compiler=target
658 TMP_CXXABSBASENAMES := $(foreach TMP_CXXBASE,%(basenames),$(if $(filter /%,$(TMP_CXXBASE)),$(TMP_CXXBASE),$(abspath $(SRCDIR)/$(CURDIR)/$(TMP_CXXBASE))))
660 ifneq ($(TMP_CXXABSBASENAMES),)
662 TMP_CXXBASENAMES := $(basename $(TMP_CXXABSBASENAMES))
664 # Identify the "real" c++ files from the passed in basenames
665 TMP_CXXFILES := $(strip $(foreach TMP_CXXBASE,$(TMP_CXXABSBASENAMES), $(firstword $(wildcard $(foreach TMP_EXT, $(AROS_CXXEXTS),$(addsuffix .$(TMP_EXT),$(TMP_CXXBASE)))))))
668 TMP_CXXTARGETS := $(notdir $(TMP_CXXBASENAMES:=.o))
669 TMP_CXXDTARGETS := $(notdir $(TMP_CXXBASENAMES:=.d))
672 TMP_CXXTARGETS := $(addprefix %(targetdir)/,$(notdir $(TMP_CXXBASENAMES:=.o)))
673 TMP_CXXDTARGETS := $(addprefix %(targetdir)/,$(notdir $(TMP_CXXBASENAMES:=.d)))
674 TMP_WILDCARD := %(targetdir)/%
676 # Be sure that all source files are generated
677 $(TMP_CXXTARGETS) $(TMP_CXXDTARGETS) : | $(TMP_CXXFILES)
680 # Adjust compiler flags to suit C++
681 TMP_CXXFLAGS := %(cxxflags)
683 TMP_DXXFLAGS := %(cxxflags)
685 TMP_DXXFLAGS := %(dxxflags)
688 ifeq ($(findstring %(compiler),host kernel target),)
689 $(error unknown compiler %(compiler))
691 ifeq (%(compiler),host)
692 BD_LINK ?= $(HOST_CXX) $(HOST_LDFLAGS)
693 BD_STRIP ?= $(HOST_STRIP)
694 BD_ASSEMBLER ?= $(HOST_CC) $(HOST_SYSROOT)
695 TMP_CXXCMD:=$(HOST_CXX)
696 TMP_CXXFLAGS := $(HOST_CXXFLAGS) $(TMP_CXXFLAGS)
697 TMP_DXXFLAGS := $(HOST_CXXFLAGS) $(TMP_DXXFLAGS)
698 TMP_CXXIQUOTE:=$(HOST_IQUOTE)
699 TMP_CXXIQUOTE_END:=$(HOST_IQUOTE_END)
701 ifeq (%(compiler),target)
702 BD_LINK ?= $(AROS_CXX) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
703 BD_STRIP ?= $(TARGET_STRIP)
704 BD_ASSEMBLER ?= $(TARGET_CC) $(TARGET_SYSROOT)
705 TMP_CXXCMD:=$(AROS_CXX) $(TARGET_SYSROOT)
706 TMP_CXXFLAGS := $(TMP_CXXFLAGS)
707 TMP_DXXFLAGS := $(TMP_DXXFLAGS)
708 TMP_CXXIQUOTE:=$(CFLAGS_IQUOTE)
709 TMP_CXXIQUOTE_END:=$(CFLAGS_IQUOTE_END)
711 ifeq (%(compiler),kernel)
712 KERNEL_CXX ?= $(KERNEL_CC)
713 BD_LINK ?= $(KERNEL_CXX) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
714 BD_STRIP ?= $(ECHO) >/dev/null
715 BD_ASSEMBLER ?= $(KERNEL_CC) $(KERNEL_SYSROOT)
716 TMP_CXXCMD:=$(KERNEL_CXX) $(KERNEL_SYSROOT)
717 TMP_CXXFLAGS := $(KERNEL_CXXFLAGS) $(TMP_CXXFLAGS)
718 TMP_DXXFLAGS := $(KERNEL_CXXFLAGS) $(TMP_DXXFLAGS)
719 TMP_CXXIQUOTE:=$(KERNEL_IQUOTE)
720 TMP_CXXIQUOTE_END:=$(KERNEL_IQUOTE_END)
723 define cxx_multi_recipe_template
725 %compile_q cmd=$(TMP_CXXCMD) opt=$(TMP_CXXFLAGS) iquote=$(TMP_CXXIQUOTE) iquote_end=$(TMP_CXXIQUOTE_END) from=$(2) to=$(1).o
728 %mkdepend_q cc=$(TMP_CXXCMD) flags=$(TMP_DXXFLAGS) from=$(2) to=$(1).d
731 $(foreach TMP_CXXFILE,$(TMP_CXXFILES),$(eval $(call cxx_multi_recipe_template,$(notdir $(basename $(TMP_CXXFILE))),$(TMP_CXXFILE))))
733 $(foreach TMP_CXXFILE,$(TMP_CXXFILES),$(eval $(call cxx_multi_recipe_template,$(addprefix %(targetdir)/,$(notdir $(basename $(TMP_CXXFILE)))),$(TMP_CXXFILE))))
739 #------------------------------------------------------------------------------
742 #------------------------------------------------------------------------------
743 # Generate a rule to compile multiple ObjC source files to an object file and
744 # generate the corresponding dependency files. The generated file will be put
745 # in the object directory without the directory part of the source file.
747 # - basenames: the basenames of the files to compile. The names may include
748 # relative or absolute path names. No wildcard is allowed
749 # - cflags (default $(CFLAGS)): the C flags to use for compilation
750 # - dflags: the flags used during creation of dependency file. If not specified
751 # the same value as cflags will be used
752 # - targetdir: the directory to put the .o file and the .d file. By default
753 # it is put in the same directory as the .m file. When targetdir is not
754 # empty, path names will be stripped from the file names so that all files
755 # are in that dir and not in subdirectories.
756 # - compiler (default target): compiler to use, target, kernel or host
757 %define rule_compile_objc_multi basenames=/A cflags=$(CFLAGS) dflags= \
758 targetdir= compiler=target
760 ifneq (%(basenames),)
763 TMP_TARGETS := $(addsuffix .o,%(basenames))
764 TMP_DTARGETS := $(addsuffix .d,%(basenames))
767 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,%(basenames)))
768 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,%(basenames)))
769 TMP_WILDCARD := %(targetdir)/%
771 # Be sure that all .m files are generated
772 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .m,%(basenames))
774 # Be sure that all .m files are found
775 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
776 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
777 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
779 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
780 vpath %.m $(TMP_DIRS)
784 # Define the use of cross compiler
785 ifeq ($(TARGET_OBJC),)
786 TMP_CC := $(TARGET_CC)
788 TMP_CC := $(TARGET_OBJC)
791 # Adjust compiler flags to suit ObjC
792 TMP_OBJCFLAGS := %(cflags)
793 TMP_OBJCFLAGS := $(TMP_OBJCFLAGS) -isystem $(AROS_DEVELOPER)/include
794 TMP_OBJCFLAGS := $(subst -Wno-pointer-sign,, $(subst -Werror-implicit-function-declaration,, $(TMP_OBJCFLAGS)))
796 TMP_OBJCDFLAGS := %(cflags)
798 TMP_OBJCDFLAGS := %(dflags)
801 ifeq ($(findstring %(compiler),host kernel target),)
802 $(error unknown compiler %(compiler))
804 ifeq (%(compiler),target)
805 BD_LINK ?= $(TMP_CC) $(TARGET_SYSROOT) $(TARGET_LDFLAGS)
806 BD_STRIP ?= $(TARGET_STRIP)
807 BD_ASSEMBLER ?= $(TARGET_CC) $(TARGET_SYSROOT)
808 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TMP_CC) $(TARGET_SYSROOT)
809 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCFLAGS:=$(TMP_OBJCFLAGS)
810 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCDFLAGS:=$(TMP_OBJCDFLAGS)
811 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
812 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
814 ifeq (%(compiler),host)
815 BD_LINK ?= $(HOST_OBJC) $(HOST_LDFLAGS)
816 BD_STRIP ?= $(HOST_STRIP)
817 BD_ASSEMBLER ?= $(HOST_CC) $(HOST_SYSROOT)
818 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_OBJC)
819 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCFLAGS:=$(HOST_CFLAGS) $(TMP_OBJCFLAGS)
820 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCDFLAGS:=$(HOST_CFLAGS) $(TMP_OBJCDFLAGS)
821 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
822 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
824 ifeq (%(compiler),kernel)
825 KERNEL_OBJC ?= $(KERNEL_CC)
826 BD_LINK ?= $(KERNEL_OBJC) $(KERNEL_SYSROOT) $(KERNEL_LDFLAGS)
827 BD_STRIP ?= $(ECHO) >/dev/null
828 BD_ASSEMBLER ?= $(KERNEL_CC) $(KERNEL_SYSROOT)
829 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_OBJC) $(KERNEL_SYSROOT)
830 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCFLAGS:=$(KERNEL_CFLAGS) $(TMP_OBJCFLAGS)
831 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_OBJCDFLAGS:=$(KERNEL_CFLAGS) $(TMP_OBJCDFLAGS)
832 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
833 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
836 $(TMP_TARGETS) : CFLAGS := $(TMP_OBJCFLAGS)
837 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.m
838 %compile_q cmd=$(CMD) opt=$(TMP_OBJCFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
840 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.m
841 %mkdepend_q cc=$(CMD) flags=$(DFLAGS)
846 #------------------------------------------------------------------------------
849 #------------------------------------------------------------------------------
850 # Make an alias from one arch specific build to another arch.
852 # - mainmmake: the mmake of the module in the main tree
853 # - arch: the current arch
854 # - alias: the alias to which this should point
855 %define rule_archalias mainmmake=\A arch=\A alias=\A
857 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
859 #------------------------------------------------------------------------------
862 #------------------------------------------------------------------------------
863 # Generate a rule to assemble a source file to an object file. Basename may
864 # contain a directory part, then the source file has to be in that directory.
865 # The generated file will be put in the object directory without the directory.
867 # - basename: the basename of the file to compile. Use % for a wildcard rule
868 # - flags (default $(AFLAGS)): the asm flags to use for assembling
869 # - targetdir: the directory to put the .o file in. By default it is put in the
870 # same directory as the .s file
871 %define rule_assemble basename=/A aflags=$(AFLAGS) targetdir=
874 %(basename).o : AFLAGS := %(aflags)
875 %(basename).o : %(basename).s
877 %(basename).o : %(basename).S
881 %(targetdir)/$(notdir %(basename)).o : AFLAGS := %(aflags)
882 %(targetdir)/$(notdir %(basename)).o : %(basename).s
884 %(targetdir)/$(notdir %(basename)).o : %(basename).S
889 #------------------------------------------------------------------------------
892 #------------------------------------------------------------------------------
893 # Generate a rule to assemble multiple source files to an object file. The
894 # generated file will be put in the object directory with the directory part
895 # of the source file stripped off.
897 # - basenames: the basenames of the files to compile. The names may include
898 # relative or absolute path names. No wildcard is allowed
899 # - aflags (default $(AFLAGS)): the flags to use for assembly
900 # - targetdir: the directory to put the .o file and the .d file. By default
901 # it is put in the same directory as the .c file. When targetdir is not
902 # empty, path names will be stripped from the file names so that all files
903 # are in that dir and not in subdirectories.
904 %define rule_assemble_multi cmd="$(CC) $(TARGET_SYSROOT)" basenames=/A aflags=$(AFLAGS) targetdir= suffix=.s
907 TMP_TARGETS := $(addsuffix .o,%(basenames))
910 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
911 TMP_WILDCARD := %(targetdir)/%
913 # Be sure that all .s files are generated
914 $(TMP_TARGETS) : | $(addsuffix %(suffix),%(basenames))
916 # Be sure that all .c files are found
917 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
918 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
919 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
921 TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
922 vpath %%(suffix) $(TMP_DIRS)
927 BD_ASSEMBLER ?= %(cmd)
929 $(TMP_TARGETS) : TMP_CMD:= $(BD_ASSEMBLER)
931 $(TMP_TARGETS) : AFLAGS := %(aflags)
932 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %%(suffix)
933 %assemble_q cmd=$(TMP_CMD)
935 #------------------------------------------------------------------------------
938 #------------------------------------------------------------------------------
939 # Link %(objs) to %(prog) using the libraries in %(uselibs)
940 %define rule_link_prog prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
941 usehostlibs= usestartup=yes detach=no nix=no cmd="$(AROS_CC) $(TARGET_SYSROOT)" strip=$(TARGET_STRIP) objdir=$(GENDIR)/$(CURDIR)
946 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
948 ifeq (%(usestartup),no)
949 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
952 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
955 # Make a list of the lib files this program depends on.
956 # In LDFLAGS remove white space between -L and directory
957 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
958 # Filter out only the libdirs and remove -L
959 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
961 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
962 # Add normal linklib path
963 TMP_DIRS += $(AROS_LIB)/
964 # add lib and .a to static linklib names
965 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(TMP_EXTRA_LIBS)))
966 ifeq (%(usestartup),yes)
967 TMP_LIBS += startup.o
972 # search for the linklibs in the given path, ignore ones not found
973 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
974 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
977 %(prog) : OBJDIR := %(objdir)
978 %(prog) : OBJS := %(objs)
979 %(prog) : LDFLAGS := %(ldflags) $(TMP_EXTRA_LDFLAGS)
980 %(prog) : LIBS := $(addprefix -l,%(uselibs) $(TMP_EXTRA_LIBS) %(usehostlibs))
981 %(prog) : %(objs) $(TMP_DEPLIBS)
982 %link_q cmd="%(cmd)" strip="%(strip)" from=$(OBJS) opt=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
984 #------------------------------------------------------------------------------
987 #------------------------------------------------------------------------------
988 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
989 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
990 %define rule_link_progs progs=/A targetdir=$(AROSDIR)/$(CURDIR) nix=%(nix) \
991 objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
992 usestartup=yes detach=no cmd="$(AROS_CC) $(TARGET_SYSROOT)" strip=$(TARGET_STRIP)
997 TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
999 ifeq (%(usestartup),no)
1000 TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
1002 ifeq (%(detach),yes)
1003 TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
1006 # Make a list of the lib files the programs depend on.
1007 # In LDFLAGS remove white space between -L and directory
1008 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
1009 # Filter out only the libdirs and remove -L
1010 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
1012 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
1013 # Add normal linklib path
1014 TMP_DIRS += $(AROS_LIB)/
1015 # add lib and .a to static linklib names
1016 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) $(TMP_EXTRA_LIBS)))
1017 # search for the linklibs in the given path, ignore ones not found
1018 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
1019 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
1021 TMP_PROGS := $(addprefix %(targetdir)/,%(progs))
1023 $(TMP_PROGS) : OBJDIR := %(objdir)
1024 $(TMP_PROGS) : LDFLAGS := %(ldflags) $(TMP_EXTRA_LDFLAGS)
1025 $(TMP_PROGS) : LIBS := $(addprefix -l,%(uselibs) $(TMP_EXTRA_LIBS) %(usehostlibs))
1026 $(TMP_PROGS) : %(targetdir)/% : %(objdir)/%.o $(TMP_DEPLIBS)
1027 %link_q cmd="%(cmd)" strip="%(strip)" from=$< opt=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
1029 #------------------------------------------------------------------------------
1032 #------------------------------------------------------------------------------
1033 # Link the %(objs) to the library %(libdir)/lib%(libname).a
1034 %define rule_link_linklib libname=/A objs=/A libdir=$(AROS_LIB) linker=target
1036 ifeq (%(linker),target)
1037 %(libdir)/lib%(libname).a : TMP_AR:=$(AR)
1038 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(RANLIB)
1040 ifeq (%(linker),host)
1041 %(libdir)/lib%(libname).a : TMP_AR:=$(HOST_AR)
1042 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(HOST_RANLIB)
1044 ifeq (%(linker),kernel)
1045 %(libdir)/lib%(libname).a : TMP_AR:=$(KERNEL_AR)
1046 %(libdir)/lib%(libname).a : TMP_RANLIB:=$(KERNEL_RANLIB)
1049 %(libdir)/lib%(libname).a : %(objs)
1050 %mklib_q from=$^ ar=$(TMP_AR) ranlib=$(TMP_RANLIB)
1052 #------------------------------------------------------------------------------
1054 #------------------------------------------------------------------------------
1055 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
1056 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
1057 %define rule_linkmodule module=/A objs=/A endobj=/A err=/A objdir=$(OBJDIR) \
1058 cmd="$(AROS_CC) $(TARGET_SYSROOT)" ldflags=$(LDFLAGS) uselibs= usehostlibs=
1060 TMP_LDFLAGS := %(ldflags)
1061 # Make a list of the lib files the programs depend on.
1062 # In LDFLAGS remove white space between -L and directory
1063 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
1064 # Filter out only the libdirs and remove -L
1065 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
1067 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
1068 # Add normal linklib path
1069 TMP_DIRS += $(AROS_LIB)/
1070 # add lib and .a to static linklib names
1071 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
1072 # search for the linklibs in the given path, ignore ones not found
1073 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
1074 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
1077 %(module) : LIB_NAMES := %(uselibs)
1078 %(module) : OBJS := %(objs)
1079 %(module) : ENDTAG := %(endobj)
1080 %(module) : ERR := %(err)
1081 %(module) : OBJDIR := %(objdir)
1082 %(module) : LDFLAGS := $(TMP_LDFLAGS)
1083 ifeq (%(usehostlibs),)
1084 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES))
1086 # Warning: the -L/usr/lib here can result in modules
1087 # linking against host libs instead of AROS libs (e.g stdc++) !!
1088 %(module) : LIBS := $(addprefix -l,$(LIB_NAMES)) \
1089 -L/usr/lib $(addprefix -l,%(usehostlibs))
1091 %(module) : %(objs) %(endobj) $(TMP_DEPLIBS) $(USER_DEPLIBS)
1092 %link_module_q cmd="%(cmd)" err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS) objdir=$(OBJDIR) ldflags=$(LDFLAGS)
1095 #------------------------------------------------------------------------------
1098 #------------------------------------------------------------------------------
1099 # Generate the libdefs.h include file for a module.
1100 %define rule_genmodule_genlibdefs modname=/A modtype=/A modsuffix= conffile= targetdir= version=
1102 TMP_TARGET := %(modname)_libdefs.h
1103 TMP_DEPS := $(GENMODULE)
1105 ifneq (%(conffile),)
1106 ifeq ($(dir %(conffile)),./)
1107 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1108 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1110 TMP_OPTS += -c %(conffile)
1111 TMP_DEPS += %(conffile)
1114 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1115 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1117 ifneq (%(modsuffix),)
1118 TMP_OPTS += -s %(modsuffix)
1120 ifneq (%(targetdir),)
1121 TMP_OPTS += -d %(targetdir)
1122 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1125 TMP_OPTS += -v %(version)
1128 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1129 $(TMP_TARGET) : MODNAME := %(modname)
1130 $(TMP_TARGET) : MODTYPE := %(modtype)
1131 $(TMP_TARGET) : $(TMP_DEPS)
1132 @$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1133 @$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
1135 #------------------------------------------------------------------------------
1137 #------------------------------------------------------------------------------
1138 # Generate the _lib.fd file for a module.
1139 %define rule_genmodule_fd modname=/A modtype=/A modsuffix= conffile= targetdir=
1141 TMP_TARGET := %(modname)_lib.fd
1142 TMP_DEPS := $(GENMODULE)
1144 ifneq (%(conffile),)
1145 ifeq ($(dir %(conffile)),./)
1146 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1147 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1149 TMP_OPTS += -c %(conffile)
1150 TMP_DEPS += %(conffile)
1153 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1154 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1156 ifneq (%(modsuffix),)
1157 TMP_OPTS += -s %(modsuffix)
1159 ifneq (%(targetdir),)
1160 TMP_OPTS += -d %(targetdir)
1161 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1164 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1165 $(TMP_TARGET) : MODNAME := %(modname)
1166 $(TMP_TARGET) : MODTYPE := %(modtype)
1167 $(TMP_TARGET) : $(TMP_DEPS)
1168 @$(ECHO) "Generating $(subst $(TARGETDIR)/,,$@)"
1169 @$(GENMODULE) $(OPTS) writefd $(MODNAME) $(MODTYPE)
1171 #------------------------------------------------------------------------------
1173 #------------------------------------------------------------------------------
1174 # Generate a Makefile.%(modname)%(modtype) with the genmodule program and include this
1175 # generated file in this Makefile
1176 %define rule_genmodule_makefile modname=/A modtype=/A modsuffix= conffile= \
1179 TMP_TARGET := Makefile.%(modname)%(modtype)
1180 TMP_DEPS := $(GENMODULE)
1182 ifneq (%(conffile),)
1183 ifeq ($(dir %(conffile)),./)
1184 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1185 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1187 TMP_OPTS += -c %(conffile)
1188 TMP_DEPS += %(conffile)
1191 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1192 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1194 ifneq (%(modsuffix),)
1195 TMP_OPTS += -s %(modsuffix)
1197 ifneq (%(targetdir),)
1198 TMP_OPTS += -d %(targetdir)
1199 TMP_TARGET := %(targetdir)/$(TMP_TARGET)
1202 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
1203 $(TMP_TARGET) : MODNAME := %(modname)
1204 $(TMP_TARGET) : MODTYPE := %(modtype)
1205 $(TMP_TARGET) : $(TMP_DEPS)
1206 @$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
1208 #------------------------------------------------------------------------------
1211 #------------------------------------------------------------------------------
1212 # Generate the support files for compiling a module. This includes include
1213 # files and source files. This rule has to be preceeded by
1214 # %rule_genmodule_makefile
1215 %define rule_genmodule_files modname=/A modtype=/A modsuffix= targetdir= stubdir= \
1218 TMP_GENTARGETS := $(%(modname)_STARTFILES) $(%(modname)_ENDFILES)
1219 TMP_STUBTARGETS := $(%(modname)_LINKLIBFILES) $(%(modname)_RELLINKLIBFILES)
1220 TMP_GENTARGETS := $(addsuffix .c,$(TMP_GENTARGETS))
1221 TMP_STUBTARGETS := $(addsuffix .c,$(TMP_STUBTARGETS)) \
1222 $(addsuffix .S, $(%(modname)_LINKLIBAFILES) $(%(modname)_RELLINKLIBAFILES))
1225 TMP_DEPS := $(GENMODULE)
1228 ifneq (%(conffile),)
1229 ifeq ($(dir %(conffile)),./)
1230 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1231 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1233 TMP_OPTS += -c %(conffile)
1234 TMP_DEPS += %(conffile)
1237 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1238 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1240 ifneq (%(modsuffix),)
1241 TMP_OPTS += -s %(modsuffix)
1243 ifneq (%(targetdir),)
1244 TMP_OPTS += -d %(targetdir)
1245 TMP_TARGETDIR := $(shell echo %(targetdir) | sed 's/^\(.\):\//\/\1\//')
1246 TMP_GENTARGETS := $(addprefix $(TMP_TARGETDIR)/,$(TMP_GENTARGETS))
1249 TMP_OPTS += -l %(stubdir)
1250 TMP_STUBTARGETDIR := $(shell echo %(stubdir) | sed 's/^\(.\):\//\/\1\//')
1251 TMP_STUBTARGETS := $(addprefix $(TMP_STUBTARGETDIR)/,$(TMP_STUBTARGETS))
1252 TMP_TARGETDIRS += %(stubdir)
1254 ifneq (%(targetdir),)
1255 TMP_STUBTARGETS := $(addprefix $(TMP_TARGETDIR)/,$(TMP_STUBTARGETS))
1259 TMP_TARGETS := $(TMP_GENTARGETS) $(TMP_STUBTARGETS)
1260 ifneq ($(TMP_TARGETDIRS),)
1261 $(TMP_TARGETS) : | $(TMP_TARGETDIRS)
1264 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
1265 $(TMP_TARGETS) : MODNAME := %(modname)
1266 $(TMP_TARGETS) : MODTYPE := %(modtype)
1267 $(TMP_TARGETS) : $(TMP_DEPS)
1268 @$(ECHO) "Generating support files for module $(MODNAME$(BDID))"
1269 ifneq (%(conffile),lib.conf)
1270 @$(IF) $(TEST) -f lib.conf; then \
1271 $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
1274 @$(IF) $(TEST) -f libdefs.h; then \
1275 $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
1277 @$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
1279 #------------------------------------------------------------------------------
1282 #------------------------------------------------------------------------------
1283 # Generate the support files for compiling a module. This includes include
1284 # files and source files.
1285 %define rule_genmodule_includes modname=/A modtype=/A modsuffix= \
1286 targetdir= conffile=
1288 ifneq ($(%(modname)_INCLUDES),)
1289 TMP_TARGETS := $(%(modname)_INCLUDES)
1291 TMP_DEPS := $(GENMODULE)
1294 ifneq (%(conffile),)
1295 ifeq ($(dir %(conffile)),./)
1296 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
1297 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
1299 TMP_OPTS += -c %(conffile)
1300 TMP_DEPS += %(conffile)
1303 TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
1304 TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
1306 ifneq (%(modsuffix),)
1307 TMP_OPTS += -s %(modsuffix)
1309 ifneq (%(targetdir),)
1310 TMP_OPTS += -d %(targetdir)
1311 TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
1314 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
1315 $(TMP_TARGETS) : MODNAME := %(modname)
1316 $(TMP_TARGETS) : MODTYPE := %(modtype)
1317 $(TMP_TARGETS) : $(TMP_DEPS)
1318 @$(ECHO) "Generating $(MODNAME).$(MODTYPE) includes"
1319 @$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
1322 #------------------------------------------------------------------------------
1324 #------------------------------------------------------------------------------
1325 # Link %(objs) to binary blob in %(file) using %(name) as name of embedded binary object
1326 # 'start' is an optional starting address
1327 # 'ldflags' is optional additional flags for the linker
1328 %define rule_link_binary file=/A name=/A objs= files= start=0 ldflags=
1330 BD_OUTDIR := $(dir %(file))
1331 # This trick removes the trailing '/', otherwise findstring below fails, causing a warning
1332 BD_OUTDIR := $(subst /*,,$(addsuffix *,$(BD_OUTDIR)))
1333 BD_TMPDIR := $(GENDIR)/$(CURDIR)
1334 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(notdir %(files))))
1335 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(notdir %(files))))
1338 %rule_compile_multi basenames="%(files)" targetdir=$(BD_OBJDIR)
1340 %(file) : $(BD_OBJS) $(BD_DEPS) $(BD_OUTDIR)
1341 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)..."
1342 @$(KERNEL_LD) %(ldflags) --entry=%(start) --oformat=binary -Ttext=%(start) -o $(BD_TMPDIR)/%(name) $(BD_OBJS)
1343 @cd $(BD_TMPDIR) && $(AROS_LD) %(ldflags) -r --format binary %(name) -o $@
1345 ifeq ($(findstring $(BD_OUTDIR),$(GLOB_MKDIRS)),)
1346 GLOB_MKDIRS += $(BD_OUTDIR)
1351 #------------------------------------------------------------------------------
1352 # Common rules for all makefiles
1354 # Delete generated makefiles
1357 @$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
1359 include $(SRCDIR)/config/make.tail
1361 BDID := $(BDTARGETID)
1363 #------------------------------------------------------------------------------
1366 #############################################################################
1367 #############################################################################
1369 ## Here are the mmakefile build macros. These are macros that takes care ##
1370 ## of everything to go from the sources to the generated target. Also all ##
1371 ## intermediate files and directories that are needed are created by these ##
1374 #############################################################################
1375 #############################################################################
1377 #------------------------------------------------------------------------------
1379 %define build_prog mmake=/A progname=/A files=$(BD_PROGNAME) cxxfiles= \
1381 asmfiles= objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1382 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_CXXFLAGS) ldflags=$(LDFLAGS) \
1383 aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
1384 includedir= libdir= \
1385 compiler=target linker= lto=$(TARGET_LTO)
1389 BD_PROGNAME := %(progname)
1390 BD_OBJDIR := %(objdir)
1391 BD_TARGETDIR := %(targetdir)
1392 BD_LINKER := %(linker)
1394 # If not supplied, linker is equal to compiler
1395 ifeq ($(BD_LINKER),)
1396 BD_LINKER := %(compiler)
1399 BD_FILES := %(files)
1400 BD_OBJCFILES := %(objcfiles)
1401 BD_ASMFILES := %(asmfiles)
1402 BD_CXXFILES := %(cxxfiles)
1404 BD_ARCHOBJS := $(wildcard $(BD_OBJDIR)/arch/*.o)
1405 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1406 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1408 TMP_FILES := $(BD_NARCHFILES) $(BD_CXXFILES) $(BD_ASMFILES) $(BD_OBJCFILES)
1409 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(notdir $(TMP_FILES))))
1410 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(notdir $(TMP_FILES))))
1412 BD_CFLAGS := %(cflags)
1413 BD_CXXFLAGS := %(cxxflags)
1415 ifeq (%(compiler),target)
1416 BD_CFLAGS := $(LTO_BINARY_CFLAGS) $(BD_CFLAGS)
1417 BD_CXXFLAGS := $(LTO_BINARY_CFLAGS) $(BD_CXXFLAGS)
1420 ifneq (%(includedir),)
1421 BD_CFLAGS += -I%(includedir)
1422 BD_CXXFLAGS += -I%(includedir)
1424 BD_AFLAGS := %(aflags)
1425 ifneq (%(includedir),)
1426 BD_AFLAGS += -I%(includedir)
1428 BD_DFLAGS := %(dflags)
1429 BD_DXXFLAGS := %(dxxflags)
1430 BD_LDFLAGS := %(ldflags)
1432 BD_LDFLAGS += -L%(libdir)
1436 %(mmake)-quick : %(mmake)
1438 #MM %(mmake) : includes-generate-deps core-linklibs linklibs-%(uselibs)
1439 %(mmake) : $(BD_TARGETDIR)/$(BD_PROGNAME)
1441 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick %(mmake)-gz-quick),)
1442 %rule_compile_cxx_multi basenames=$(BD_CXXFILES) targetdir=$(BD_OBJDIR) \
1443 cxxflags=$(BD_CXXFLAGS) dxxflags=$(BD_DXXFLAGS) compiler="%(compiler)"
1444 %rule_compile_objc_multi basenames=$(BD_OBJCFILES) targetdir=$(BD_OBJDIR) \
1445 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler="%(compiler)"
1446 %rule_compile_multi basenames=$(BD_NARCHFILES) targetdir=$(BD_OBJDIR) \
1447 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler="%(compiler)"
1448 %rule_assemble_multi cmd=$(BD_ASSEMBLER) basenames=$(BD_ASMFILES) targetdir=$(BD_OBJDIR) \
1451 %rule_link_prog prog=$(BD_TARGETDIR)/$(BD_PROGNAME) \
1452 objs="$(BD_OBJS) $(BD_ARCHOBJS) $(USER_OBJS)" ldflags=$(BD_LDFLAGS) \
1453 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1454 usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)" \
1455 cmd=$(BD_LINK) strip=$(BD_STRIP) objdir=$(BD_OBJDIR)
1459 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1461 $(BD_OBJS) $(BD_DEPS) : | $(BD_OBJDIR)
1462 $(BD_TARGETDIR)/$(BD_PROGNAME) : | $(BD_TARGETDIR)
1463 GLOB_MKDIRS += $(BD_OBJDIR) $(BD_TARGETDIR)
1465 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_TARGETDIR)/$(BD_PROGNAME) $(BD_DEPS)
1468 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1472 #------------------------------------------------------------------------------
1475 #------------------------------------------------------------------------------
1476 # Build programs, for every C file an executable will be built with the same
1477 # name as the C file
1478 %define build_progs mmake=/A files=/A nix=no \
1479 objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
1480 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
1481 includedir= libdir= \
1483 uselibs= usehostlibs= usestartup=yes detach=no lto=$(TARGET_LTO)
1487 BD_OBJDIR := %(objdir)
1488 BD_TARGETDIR := %(targetdir)
1490 BD_FILES := %(files)
1491 BD_OBJS := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1492 BD_DEPS := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
1493 BD_EXES := $(addprefix $(BD_TARGETDIR)/,$(BD_FILES))
1495 BD_CFLAGS := %(cflags)
1497 ifeq (%(compiler),target)
1498 BD_CFLAGS := $(LTO_BINARY_CFLAGS) $(BD_CFLAGS)
1501 ifneq (%(includedir),)
1502 BD_CFLAGS += -I%(includedir)
1504 BD_DFLAGS := %(dflags)
1505 BD_LDFLAGS := %(ldflags)
1507 BD_LDFLAGS += -L%(libdir)
1511 %(mmake)-quick : %(mmake)
1513 #MM %(mmake) : includes-generate-deps core-linklibs linklibs-%(uselibs)
1514 %(mmake) : $(BD_EXES)
1516 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
1517 %rule_compile_multi basenames=$(BD_FILES) targetdir=$(BD_OBJDIR) \
1518 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler="%(compiler)"
1520 %rule_link_progs progs=$(BD_FILES) nix="%(nix)" \
1521 targetdir=$(BD_TARGETDIR) objdir=$(BD_OBJDIR) \
1522 ldflags=$(BD_LDFLAGS) \
1523 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
1524 usestartup="%(usestartup)" detach="%(detach)" \
1525 cmd=$(BD_LINK) strip=$(BD_STRIP) objdir=$(BD_OBJDIR)
1529 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
1531 $(addprefix $(BD_TARGETDIR)/,$(BD_FILES)) : | $(BD_TARGETDIR)
1532 $(BD_DEPS) $(BD_OBJS) : | $(BD_OBJDIR)
1533 GLOB_MKDIRS += $(BD_TARGETDIR) $(BD_OBJDIR)
1535 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_EXES) $(BD_DEPS)
1538 @$(ECHO) "Cleaning up for metatarget %(mmake)"
1542 #------------------------------------------------------------------------------
1545 #------------------------------------------------------------------------------
1547 # This is a bare version: It just compiles and links the given files. It is
1548 # assumed that all needed boiler plate code is in the files. This should only
1549 # be used for compiling external code. For AROS code use %build_module
1550 %define build_module_simple mmake=/A modname=/A modtype=/A \
1551 files="$(basename $(call WILDCARD, *.c))" \
1552 cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1553 objdir=$(OBJDIR) moduledir= \
1554 uselibs= usehostlibs= compiler=target lto=$(TARGET_LTO)
1556 # Define metamake targets and their dependencies
1557 #MM %(mmake) : core-linklibs includes-generate-deps
1558 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1559 #MM %(mmake)-kobj-quick
1563 BD_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj
1565 .PHONY : $(BD_ALLTARGETS)
1568 $(error using %build_module_simple: modname may not be empty)
1571 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1574 # Default values for variables and arguments
1575 BD_DEFLINKLIBNAME := %(modname)
1576 BD_DEFDFLAGS := %(cflags)
1578 ifeq (%(compiler),target)
1579 BD_DEFDFLAGS := $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(BD_DEFDFLAGS)
1582 BD_DEFDXXFLAGS := %(dxxflags)
1583 OBJDIR ?= $(GENDIR)/$(CURDIR)
1584 BD_MODDIR := %(moduledir)
1585 ifeq ($(BD_MODDIR),)
1586 ifeq (%(modtype),library)
1587 BD_MODDIR := $(AROS_LIBRARIES)
1589 ifeq (%(modtype),gadget)
1590 BD_MODDIR := $(AROS_GADGETS)
1592 ifeq (%(modtype),datatype)
1593 BD_MODDIR := $(AROS_DATATYPES)
1595 ifeq (%(modtype),handler)
1596 BD_MODDIR := $(AROS_FS)
1598 ifeq (%(modtype),device)
1599 BD_MODDIR := $(AROS_DEVS)
1601 ifeq (%(modtype),resource)
1602 BD_MODDIR := $(AROS_RESOURCES)
1604 ifeq (%(modtype),hook)
1605 BD_MODDIR := $(AROS_RESOURCES)
1607 ifeq (%(modtype),mui)
1608 BD_MODDIR := $(AROS_CLASSES)/Zune
1610 ifeq (%(modtype),mcc)
1611 BD_MODDIR := $(AROS_CLASSES)/Zune
1613 ifeq (%(modtype),mcp)
1614 BD_MODDIR := $(AROS_CLASSES)/Zune
1616 ifeq (%(modtype),usbclass)
1617 BD_MODDIR := $(AROS_CLASSES)/USB
1619 ifeq (%(modtype),hidd)
1620 BD_MODDIR := $(AROS_DRIVERS)
1622 ifeq (%(modtype),printer)
1623 BD_MODDIR := $(AROS_PRINTERS)
1626 ifeq ($(BD_MODDIR),)
1627 $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1630 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1631 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1632 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),%(files))
1634 %rule_compile_multi \
1635 basenames=$(BD_NARCHFILES) targetdir="%(objdir)" \
1636 cflags="$(BD_DEFDFLAGS)" dflags="%(dflags)" \
1637 compiler="%(compiler)"
1639 # Handlers use dash instead of dot in their names
1640 ifeq (%(modtype),handler)
1641 BD_MODULE := $(BD_MODDIR)/%(modname)-%(modtype)
1643 ifeq (%(modtype),printer)
1644 BD_MODULE := $(BD_MODDIR)/%(modname)
1646 BD_MODULE := $(BD_MODDIR)/%(modname).%(modtype)
1649 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1651 %(mmake)-quick : %(mmake)
1652 %(mmake)-kobj-quick : $(BD_KOBJ)
1653 %(mmake) : $(BD_MODULE)
1654 %(mmake)-kobj : $(BD_KOBJ)
1656 # The module is linked from all the compiled .o files
1657 BD_OBJS := $(BD_ARCHOBJS) $(addprefix %(objdir)/, $(addsuffix .o,$(notdir $(BD_NARCHFILES))))
1659 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
1660 # This breaks con-handler build. Here we work around this
1661 ifeq (%(modname),con)
1662 BD_ERR := $(notdir $(BD_MODULE)).err
1664 BD_ERR := %(modname).err
1667 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1668 endobj= err=$(BD_ERR) objdir="%(objdir)" \
1669 ldflags="$(LDFLAGS) $(%(modname)_LDFLAGS)" \
1670 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
1672 # Link kernel object file
1673 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1675 # Make these symbols local
1676 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1677 UtilityBase ExpansionBase KeymapBase KernelBase
1679 BD_SYMBOLS := $(BD_KBASE)
1681 BD_KLIB := hiddstubs amiga arossupport autoinit libinit
1682 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1683 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1684 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
1685 $(BD_KOBJ) : USER_LDFLAGS := $(USER_LDFLAGS)
1686 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1687 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
1688 @$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1689 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
1692 ## Dependency fine-tuning
1694 BD_DEPS := $(addprefix %(objdir)/, $(addsuffix .d,%(files)))
1695 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1697 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1698 $(BD_MODULE) : | $(BD_MODDIR)
1699 $(BD_KOBJ) : | $(KOBJSDIR)
1700 GLOB_MKDIRS += %(objdir) $(BD_MODDIR) $(KOBJSDIR)
1702 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_MODULE) $(BD_KOBJ) $(BD_DEPS)
1704 @$(ECHO) "Cleaning up for module %(modname)"
1707 #------------------------------------------------------------------------------
1710 #------------------------------------------------------------------------------
1711 # Build a module - core routine
1712 # Explanation of this macro is done in the developer's manual
1713 %define build_module_core mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
1714 files="$(basename $(call WILDCARD, *.c))" \
1715 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
1716 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_DEFDXXFLAGS) \
1717 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
1718 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
1719 compiler=target lto=$(TARGET_LTO) nostartup=yes archspecific=no \
1720 includedir= libdir= \
1721 build_abi= build_library=
1723 # We will employ a terrifying, but unavoidable, hack here.
1724 # genmf has no concept of conditionals (ie %ifeq), and MetaMake
1725 # ignores GNU Make ifeq() statements, but will process any #MM
1726 # headed lines in the file.
1728 # So, to make the following #MM lines conditional on whether we want
1729 # to build the ABI, Library, or both, we define build_abi= and
1730 # build_library as 'M' to enable, or '' to disable, which allows genmf
1731 # to do the following conversions:
1733 # #%(build_abi)M includes-foo: foo-include
1734 # becomes, when build_abi=M
1735 # #MM includes-foo: foo-include <= Processed by MetaMake
1736 # but, when build_abi= ...
1737 # #M includes-foo: foo-includes <= ignored by MetaMake! Yes!
1739 # Taking full blame for this: Jason S. McMullan <jason.mcmullan@gmail.com>
1741 # Define metamake targets and their dependencies
1744 #MM %(mmake)-makefile
1748 #M%(build_abi)- includes-all : %(mmake)-includes
1749 #M%(build_abi)- linklibs-%(modname): %(mmake)-linklib
1750 #M%(build_abi)- linklibs-%(modname)_rel : %(mmake)-linklib
1751 #M%(build_abi)- includes-%(modname): %(mmake)-includes
1752 #M%(build_abi)- includes-%(modname)_rel : %(mmake)-includes
1753 #M%(build_abi)- %(mmake) : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1754 #M%(build_abi) %(mmake)-linklib : %(mmake)-includes includes-%(uselibs)
1755 #M%(build_abi)- %(mmake)-quick : %(mmake)-includes-quick
1756 #M%(build_abi) %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1757 #M%(build_abi) includes-generate-deps %(mmake)-fd
1758 #M%(build_abi) %(mmake)-includes-quick
1759 #M%(build_abi) %(mmake)-includes-dirs
1760 #M%(build_abi) %(mmake)-fd
1763 #%(build_library)M %(mmake)-kobj : core-linklibs linklibs-%(uselibs)
1764 #%(build_library)M %(mmake)-kobj-quick :
1766 # Library with ABI targets:
1767 #%(build_library)%(build_abi) %(mmake)-kobj : %(mmake)-includes core-linklibs linklibs-%(uselibs)
1768 #%(build_library)%(build_abi) %(mmake)-kobj-quick : %(mmake)-includes-quick
1770 # All MetaMake targets defined by this macro
1771 BD_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-clean
1773 ifeq (%(build_library),M)
1774 BD_ALLTARGETS += %(mmake)-kobj %(mmake)-kobj-quick
1777 ifeq (%(build_abi),M)
1778 BD_ALLTARGETS += %(mmake)-includes \
1779 %(mmake)-includes-quick %(mmake)-includes-dirs \
1780 %(mmake)-linklib %(mmake)-fd
1783 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1786 $(error using %build_module: modname may not be empty)
1789 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1792 # Default values for variables and arguments
1793 BD_DEFLINKLIBNAME := %(modname)
1794 BD_DEFDFLAGS := %(cflags)
1795 BD_DEFDXXFLAGS := %(cxxflags)
1797 ifeq (%(compiler),target)
1798 BD_DEFDFLAGS := $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH) $(BD_DEFDFLAGS)
1799 BD_DEFDXXFLAGS := $(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH) $(BD_DEFDXXFLAGS)
1802 ifneq (%(includedir),)
1803 BD_DEFDFLAGS += -I%(includedir)
1804 BD_DEFDXXFLAGS += -I%(includedir)
1806 OBJDIR ?= $(GENDIR)/$(CURDIR)
1808 ## Create genmodule include Makefile for the module
1810 %(mmake)-makefile : %(objdir)/Makefile.%(modname)%(modtype)
1812 %rule_genmodule_makefile \
1813 modname="%(modname)" modtype="%(modtype)" \
1814 modsuffix="%(modsuffix)" targetdir="%(objdir)" \
1815 conffile="%(conffile)"
1817 %(objdir)/Makefile.%(modname)%(modtype) : | %(objdir)
1819 GLOB_MKDIRS += %(objdir)
1821 # Do not parse these statements if metatarget is not appropriate
1822 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1824 # suppress makes warning that the Makefile doesnt yet exist
1825 # on early passes (it will generate the file as needed though)
1826 # when we include it.
1827 -include %(objdir)/Makefile.%(modname)%(modtype)
1829 BD_DEFMODDIR := $(%(modname)_MODDIR)
1830 ifeq (%(archspecific),yes)
1831 BD_DEFMODDIR := $(AROS_DIR_ARCH)/$(BD_DEFMODDIR)
1835 ## include files generation
1837 ifneq (%(includedir),)
1838 BD_INCDIR := %(includedir)
1840 BD_INCDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/$(AROS_DIR_INCLUDE)
1842 BD_LIBDEFSINC := %(objdir)/include/%(modname)_libdefs.h
1843 BD_DEFLIBDEFSINC := %(objdir)/include/%(modname)_deflibdefs.h
1845 ifeq (%(build_abi),M)
1846 %(mmake)-includes-quick : %(mmake)-includes
1847 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1848 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1849 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1851 ifneq ($(%(modname)_INCLUDES),)
1852 %rule_genmodule_includes modname="%(modname)" modtype="%(modtype)" \
1853 modsuffix="%(modsuffix)" targetdir="%(objdir)/include" \
1854 conffile="%(conffile)"
1856 %rule_copy_diff_multi \
1857 files=$(%(modname)_INCLUDES) srcdir="%(objdir)/include" targetdir=$(GENINCDIR) \
1858 stampfile="%(objdir)/%(modname)_geninc"
1860 %rule_copy_diff_multi \
1861 files=$(%(modname)_INCLUDES) srcdir="%(objdir)/include" targetdir=$(BD_INCDIR) \
1862 stampfile="%(objdir)/%(modname)_incs"
1864 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1866 TMP%(modname)_INCDIRS := \
1867 %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1868 $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1869 $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1870 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget="%(mmake)-includes-dirs"
1876 %rule_genmodule_genlibdefs modname="%(modname)" modtype="%(modtype)" \
1877 modsuffix="%(modsuffix)" targetdir="%(objdir)/include" \
1878 conffile="%(conffile)" version="%(version)"
1880 $(BD_DEFLIBDEFSINC) : FILENAME := $(BD_LIBDEFSINC)
1881 $(BD_DEFLIBDEFSINC) :
1882 @$(ECHO) "Generating $@"
1883 @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1885 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) : | %(objdir)/include
1886 GLOB_MKDIRS += %(objdir)/include
1888 ## Extra genmodule src files generation
1890 %rule_genmodule_files modname="%(modname)" modtype="%(modtype)" \
1891 modsuffix="%(modsuffix)" targetdir="%(objdir)" stubdir="%(objdir)/linklib" \
1892 conffile="%(conffile)"
1894 GLOB_MKDIRS += %(objdir)/linklib
1896 ifeq (%(build_abi),M)
1898 ifeq (%(includedir),)
1899 BD_FDDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/fd
1901 BD_FDDIR := %(includedir)/../fd
1903 %(mmake)-fd : $(BD_FDDIR)/%(modname)_lib.fd
1905 %rule_genmodule_fd modname="%(modname)" modtype="%(modtype)" \
1906 modsuffix="%(modsuffix)" targetdir=$(BD_FDDIR) conffile="%(conffile)"
1908 $(BD_FDDIR)/%(modname)_lib.fd : | $(BD_FDDIR)
1910 GLOB_MKDIRS += $(BD_FDDIR)
1915 BD_FILES := %(files)
1916 BD_CXXFILES := %(cxxfiles)
1918 BD_LIBFILES := %(linklibfiles)
1920 BD_FDIRS := $(sort $(dir $(BD_FILES)))
1922 BD_STARTFILES := $(addprefix %(objdir)/,$(%(modname)_STARTFILES))
1923 BD_ENDFILES := $(addprefix %(objdir)/,$(%(modname)_ENDFILES))
1925 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
1926 BD_LIBARCHOBJS := $(wildcard %(objdir)/linklib/arch/*.o)
1927 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
1928 BD_LIBARCHFILES := $(basename $(notdir $(BD_LIBARCHOBJS)))
1929 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1930 BD_NLIBARCHFILES := $(filter-out $(BD_LIBARCHFILES),$(BD_LIBFILES))
1931 BD_ARCHNLIBFILES := $(filter-out $(BD_LIBFILES),$(BD_LIBARCHFILES))
1933 BD_COMMONCFLAGS=-I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1934 BD_CFLAGS := %(cflags) $(BD_COMMONCFLAGS) $(%(modname)_CFLAGS)
1935 BD_LINKLIBCFLAGS := %(cflags) $(BD_COMMONCFLAGS) $(%(modname)_LINKLIBCFLAGS)
1936 BD_CXXFLAGS := %(cxxflags) $(BD_COMMONCFLAGS) $(%(modname)_CXXFLAGS)
1938 ifeq (%(compiler),target)
1939 BD_LTOFLAGS=$(LTO_BINARY_CFLAGS) $(CFLAGS_NO_STRICT_ALIASING) $(NOWARN_LTO_TYPE_MISMATCH)
1940 BD_CFLAGS := $(BD_LTOFLAGS) $(BD_CFLAGS)
1941 BD_LINKLIBCFLAGS := $(BD_LTOFLAGS) $(BD_LINKLIBCFLAGS)
1942 BD_CXXFLAGS := $(BD_LTOFLAGS) $(BD_CXXFLAGS)
1945 ifneq (%(includedir),)
1946 BD_CFLAGS += -I%(includedir)
1947 BD_LINKLIBCFLAGS += -I%(includedir)
1948 BD_CXXFLAGS += -I%(includedir)
1950 BD_DFLAGS := %(dflags) $(BD_COMMONCFLAGS) $(%(modname)_DFLAGS)
1951 BD_LINKLIBDFLAGS := %(dflags) $(BD_COMMONCFLAGS) $(%(modname)_LINKLIBDFLAGS)
1952 BD_DXXFLAGS := %(dxxflags) $(BD_COMMONCFLAGS) $(%(modname)_DXXFLAGS)
1954 ifeq (%(modtype),library)
1957 BD_LIBSUFFIX := .%(modtype)
1961 BD_LIBDIR := %(prefix)/$(AROS_DIR_DEVELOPER)/$(AROS_DIR_LIB)
1963 BD_LIBDIR := %(libdir)
1966 ifeq (%(build_abi),M)
1967 BD_LINKLIBCFILES := $(addprefix %(objdir)/linklib/,$(%(modname)_LINKLIBFILES))
1968 BD_LINKLIBAFILES := $(addprefix %(objdir)/linklib/,$(%(modname)_LINKLIBAFILES))
1969 ifeq ($(strip $(%(modname)_LINKLIBFILES) $(%(modname)_LINKLIBAFILES) %(linklibfiles) $(BD_ARCHNLIBFILES)),)
1972 BD_LINKLIB := $(BD_LIBDIR)/lib%(modname)$(BD_LIBSUFFIX).a
1973 ifneq (%(modname),%(linklibname))
1974 BD_LINKLIB += $(BD_LIBDIR)/lib%(linklibname)$(BD_LIBSUFFIX).a
1977 BD_LINKLIBFILES := $(BD_LINKLIBCFILES) $(BD_LINKLIBAFILES)
1979 BD_RELLINKLIBCFILES := $(addprefix %(objdir)/linklib/,$(%(modname)_RELLINKLIBFILES))
1980 BD_RELLINKLIBAFILES := $(addprefix %(objdir)/linklib/,$(%(modname)_RELLINKLIBAFILES))
1981 ifeq ($(strip $(%(modname)_RELLINKLIBFILES) $(%(modname)_RELLINKLIBAFILES) %(linklibfiles) $(BD_ARCHNLIBFILES)),)
1984 BD_RELLINKLIB := $(BD_LIBDIR)/lib%(modname)_rel$(BD_LIBSUFFIX).a
1985 ifneq (%(modname),%(linklibname))
1986 BD_RELLINKLIB += $(BD_LIBDIR)/lib%(linklibname)_rel$(BD_LIBSUFFIX).a
1989 BD_RELLINKLIBFILES := $(BD_RELLINKLIBCFILES) $(BD_RELLINKLIBAFILES)
1992 BD_ENDOBJS := $(addsuffix .o,$(BD_ENDFILES))
1993 BD_LINKLIBOBJS:= $(addsuffix .o,$(addprefix %(objdir)/linklib/,$(notdir $(BD_NLIBARCHFILES))) $(addprefix %(objdir)/linklib/arch/,$(notdir $(BD_ARCHNLIBFILES))) $(BD_LINKLIBFILES)) \
1995 BD_RELLINKLIBOBJS := $(addsuffix .o,$(addprefix %(objdir)/linklib/,$(notdir $(BD_NLIBARCHFILES))) $(addprefix %(objdir)/linklib/arch/,$(notdir $(BD_ARCHNLIBFILES))) $(BD_RELLINKLIBFILES)) \
1997 $(BD_LINKLIBFILES) $(BD_RELLINKLIBFILES) : | %(objdir)/linklib
1998 $(BD_LINKLIBOBJS) $(BD_RELLINKLIBOBJS) : | %(objdir)/linklib
2000 BD_CCFILES := $(BD_NARCHFILES)
2001 BD_TARGETCCFILES := $(BD_STARTFILES) $(BD_ENDFILES)
2002 BD_LINKLIBCCFILES := $(BD_NLIBARCHFILES) $(BD_LINKLIBCFILES) $(BD_RELLINKLIBCFILES)
2003 BD_LINKLIBCCGENFILES := $(BD_LINKLIBCFILES) $(BD_RELLINKLIBCFILES)
2005 %rule_compile_cxx_multi \
2006 basenames=$(BD_CXXFILES) targetdir="%(objdir)" \
2007 cxxflags=$(BD_CXXFLAGS) dxxflags=$(BD_DXXFLAGS) \
2008 compiler="%(compiler)"
2009 %rule_compile_multi \
2010 basenames=$(BD_CCFILES) targetdir="%(objdir)" \
2011 cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) \
2012 compiler="%(compiler)"
2013 %rule_compile_multi \
2014 basenames=$(BD_TARGETCCFILES) targetdir="%(objdir)" \
2015 cflags="$(BD_CFLAGS) -D__AROS__" dflags=$(BD_DFLAGS) \
2016 compiler="%(compiler)"
2017 %rule_compile_multi \
2018 basenames=$(BD_NLIBARCHFILES) targetdir="%(objdir)/linklib" \
2019 cflags="$(BD_LINKLIBCFLAGS) -D__AROS__" dflags=$(BD_LINKLIBDFLAGS) \
2020 compiler="%(compiler)"
2021 %rule_compile_multi \
2022 basenames=$(BD_LINKLIBCCGENFILES) srcdir="%(objdir)/linklib" targetdir="%(objdir)/linklib" \
2023 cflags="$(BD_LINKLIBCFLAGS) -D__AROS__" dflags=$(BD_LINKLIBDFLAGS) \
2024 compiler="%(compiler)"
2026 ifneq ($(BD_LINKLIBAFILES),)
2027 %rule_assemble_multi \
2028 cmd=$(BD_ASSEMBLER) basenames="$(BD_LINKLIBAFILES) $(BD_RELLINKLIBAFILES)" targetdir="%(objdir)/linklib" suffix=.S
2033 ifeq (%(modsuffix),)
2034 BD_SUFFIX := %(modtype)
2036 BD_SUFFIX := %(modsuffix)
2039 ifeq (%(build_library),M)
2040 # Handlers use dash instead of dot in their names
2041 ifeq ($(BD_SUFFIX),handler)
2042 BD_MODULE := %(prefix)/%(moduledir)/%(modname)-$(BD_SUFFIX)
2044 BD_MODULE := %(prefix)/%(moduledir)/%(modname).$(BD_SUFFIX)
2046 BD_KOBJ := $(KOBJSDIR)/%(modname)_$(BD_SUFFIX).o
2052 %(mmake)-quick : %(mmake)
2053 %(mmake) : $(BD_MODULE) $(BD_LINKLIB) $(BD_RELLINKLIB)
2054 ifeq (%(build_library),M)
2055 %(mmake)-kobj : $(BD_KOBJ) $(BD_LINKLIB) $(BD_RELLINKLIB)
2056 %(mmake)-kobj-quick : $(BD_KOBJ) $(BD_LINKLIB) $(BD_RELLINKLIB)
2058 ifeq (%(build_abi),M)
2059 %(mmake)-linklib : $(BD_LINKLIB) $(BD_RELLINKLIB)
2062 BD_OBJS := $(addsuffix .o,$(BD_STARTFILES)) $(BD_ARCHOBJS) \
2063 $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES:=.o) $(BD_CXXFILES:=.o)))
2065 ifeq (%(nostartup),yes)
2066 # Handlers always have entry point
2067 ifneq (%(modtype),handler)
2068 BD_STARTOBJS := $(addsuffix .o,$(addprefix $(GENDIR)/,$(RESIDENT_BEGIN)))
2072 # Under Windows con* is a reserved name, it refers to console. Files with such names can't be created.
2073 # This breaks con-handler build. Here we work around this
2074 ifeq (%(modname),con)
2075 BD_ERR := $(notdir $(BD_MODULE)).err
2077 BD_ERR := %(modname).err
2080 ifeq (%(build_library),M)
2081 # The module is linked from all the compiled .o files
2082 %rule_linkmodule module=$(BD_MODULE) objs="$(BD_STARTOBJS) $(BD_OBJS) $(USER_OBJS)" \
2083 endobj=$(BD_ENDOBJS) err=$(BD_ERR) objdir="%(objdir)" \
2084 cmd=$(BD_LINK) ldflags="$(LDFLAGS) $(%(modname)_LDFLAGS)" \
2085 uselibs="%(uselibs) $(%(modname)_LIBS)" usehostlibs="%(usehostlibs)"
2088 ifeq (%(build_abi),M)
2090 BD_LINKLIBNAME := $(shell echo %(linklibname) | tr A-Z a-z)
2091 BD_MODNAME := $(shell echo %(modname) | tr A-Z a-z)
2092 ifneq ($(BD_LINKLIB),)
2093 %rule_link_linklib libname="%(linklibname)$(BD_LIBSUFFIX)" objs=$(BD_LINKLIBOBJS) libdir="$(BD_LIBDIR)"
2094 ifneq ($(BD_MODNAME),$(BD_LINKLIBNAME))
2095 %rule_link_linklib libname="%(modname)$(BD_LIBSUFFIX)" objs=$(BD_LINKLIBOBJS) libdir="$(BD_LIBDIR)"
2098 $(BD_LINKLIB) : | $(BD_LIBDIR)
2099 GLOB_MKDIRS += $(BD_LIBDIR)
2102 ifneq ($(BD_RELLINKLIB),)
2103 %rule_link_linklib libname="%(linklibname)_rel$(BD_LIBSUFFIX)" objs=$(BD_RELLINKLIBOBJS) libdir="$(BD_LIBDIR)"
2104 ifneq ($(BD_MODNAME),$(BD_LINKLIBNAME))
2105 %rule_link_linklib libname="%(modname)_rel$(BD_LIBSUFFIX)" objs=$(BD_RELLINKLIBOBJS) libdir="$(BD_LIBDIR)"
2108 $(BD_RELLINKLIB) : | $(BD_LIBDIR)
2109 GLOB_MKDIRS += $(BD_LIBDIR)
2113 ifeq (%(build_library),M)
2114 # Link kernel object file
2115 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
2117 # Make these symbols local
2118 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
2119 UtilityBase ExpansionBase KeymapBase KernelBase
2121 BD_SYMBOLS := $(BD_KBASE)
2123 BD_KLIB := hiddstubs amiga arossupport autoinit libinit
2124 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
2125 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS) $(%(modname)_LIBS)
2126 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
2127 $(BD_KOBJ) : USER_LDFLAGS:=$(USER_LDFLAGS)
2128 $(BD_KOBJ) : $(BD_OBJS) $(USER_OBJS) $(BD_ENDOBJS)
2129 @$(ECHO) "Linking $(subst $(TARGETDIR)/,,$@)"
2130 @$(AROS_LD) -Ur -o $@ $^ $(USER_LDFLAGS) -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
2131 @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^__aros_lib.*\r?$$/) {print "-L " $$3;}'`
2134 ## Dependency fine-tuning
2136 BD_DEPS := $(addprefix %(objdir)/,$(notdir $(BD_CCFILES:=.d) $(BD_TARGETCCFILES:=.d) $(BD_CXXFILES:=.d))) $(addprefix %(objdir)/linklib/,$(notdir $(BD_LINKLIBCCFILES:=.d)))
2138 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick" deps=$(BD_DEPS)
2140 $(BD_OBJS) $(BD_DEPS) : | %(objdir) %(objdir)/linklib
2141 $(BD_MODULE) : | %(prefix)/%(moduledir)
2142 $(BD_KOBJ) : | $(KOBJSDIR)
2143 GLOB_MKDIRS += %(objdir) %(prefix)/%(moduledir) $(KOBJSDIR)
2145 # Some include files need to be generated before the .c can be parsed.
2146 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick),) # Only for this target these deps are wanted
2148 BD_DFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
2149 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES))
2150 $(BD_DEPS) : $(BD_DFILE_DEPS)
2153 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) \
2154 $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
2155 %(objdir)/Makefile.%(modname)%(modtype) \
2156 $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
2157 $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
2158 $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
2159 %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
2160 $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
2161 $(BD_DEFLIBDEFSINC) $(addsuffix .c,$(BD_STARTFILES) $(BD_ENDFILES)) \
2163 %(mmake)-clean : FILES := $(BD_TOCLEAN)
2165 @$(ECHO) "Cleaning up for module %(modname)"
2168 endif # $(TARGET) in $(BD_ALLTARGETS)
2170 #------------------------------------------------------------------------------
2172 #------------------------------------------------------------------------------
2173 # Build a module - ABI and library
2174 # Explanation of this macro is done in the developer's manual
2175 %define build_module mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2176 files="$(basename $(call WILDCARD, *.c))" \
2177 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2178 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_DEFDXXFLAGS) \
2179 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
2180 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
2181 compiler=target lto=$(TARGET_LTO) nostartup=yes archspecific=no \
2184 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2185 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2186 files="%(files)" cxxfiles="%(cxxfiles)" \
2187 linklibname="%(linklibname)" \
2188 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2189 cflags="%(cflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2190 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2191 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" lto=%(lto) \
2192 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2193 includedir="%(includedir)" libdir="%(libdir)" \
2194 build_abi=M build_library=M
2197 #------------------------------------------------------------------------------
2200 #------------------------------------------------------------------------------
2201 # Build a module skeleton ABI
2202 # This is a stripped-down version of build_module, it only creates include
2203 # files and the linklibs.
2204 # This is used when for plugins or classes with the same API, but no actual
2205 # implementation here.
2206 %define build_module_abi mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2207 linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_DEFDXXFLAGS) \
2208 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
2209 linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
2210 compiler=target nostartup=yes archspecific=no \
2213 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2214 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2215 linklibname="%(linklibname)" \
2216 linklibfiles="%(linklibfiles)" linklibobjs="%(linklibobjs)" \
2217 cflags="%(cflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2218 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2219 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" lto=%(lto) \
2220 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2221 includedir="%(includedir)" libdir="%(libdir)" \
2222 build_abi=M build_library=
2225 #------------------------------------------------------------------------------
2227 #------------------------------------------------------------------------------
2228 # Build a module library - no includes nor linklibs
2229 # Explanation of this macro is done in the developer's manual
2230 %define build_module_library mmake=/A modname=/A modtype=/A modsuffix= version= conffile= \
2231 files="$(basename $(call WILDCARD, *.c))" \
2232 cxxfiles="$(basename $(call WILDCARD $(foreach CXX_EXT, $(AROS_CXXEXTS), *.$(CXX_EXT))))" \
2233 cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) cxxflags="$(CXXFLAGS)" dxxflags="$(BD_DEFDXXFLAGS)" \
2234 objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
2235 uselibs= usehostlibs= \
2236 compiler=target lto=$(TARGET_LTO) nostartup=yes archspecific=no \
2239 %build_module_core mmake="%(mmake)" modname="%(modname)" modtype="%(modtype)" \
2240 modsuffix="%(modsuffix)" version="%(version)" conffile="%(conffile)" \
2241 files="%(files)" cxxfiles="%(cxxfiles)" \
2242 cflags="%(cflags)" dflags="%(dflags)" cxxflags="%(cxxflags)" dxxflags="%(dxxflags)" \
2243 objdir="%(objdir)" moduledir="%(moduledir)" prefix="%(prefix)" \
2244 uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" compiler="%(compiler)" lto=%(lto) \
2245 nostartup="%(nostartup)" archspecific="%(archspecific)" \
2246 includedir="%(includedir)" libdir="%(libdir)" \
2247 build_abi= build_library=M
2250 #------------------------------------------------------------------------------
2254 #------------------------------------------------------------------------------
2256 # - mmake is the mmaketarget
2257 # - libname is the baselibname e.g. lib%(libname).a will be created
2258 # - files are the C source files to include in the lib. The list of files
2259 # has to be given without the .c suffix
2260 # - cxxfiles are C++ source files without suffix.
2261 # NB: files will be matched in the order .cpp > .cxx > .cc
2262 # - asmfiles are the asm files to include in the lib. The list of files has to
2263 # be given without the .s suffix
2264 # - objs additional object to link into the linklib. The objects have to be
2265 # given with full absolute path and the .o suffix.
2266 # - objdir is where the .o are generated. Defaults to $(GENDIR)/$(CURDIR)
2267 # - libdir is the directory where the linklib will be placed (default $(AROS_LIB))
2268 # - cflags are the flags to compile the source (default $(CFLAGS))
2269 # - dflags are the flags used during makedepend (default equal to cflags)
2270 # - aflags are the flags used during assembling (default $(AFLAGS))
2271 # - libdir is the directory where the linklib will be placed (default $(AROS_LIB))
2272 %define build_linklib mmake=/A libname=/A files= cxxfiles= \
2273 asmfiles= objs= objdir=$(GENDIR)/$(CURDIR) libdir=$(AROS_LIB) \
2275 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_CXXFLAGS) \
2276 aflags=$(AFLAGS) compiler=target lto=$(TARGET_LTO)
2278 # assign and generate the local variables used in this macro
2279 BD_LIBNAME := %(libname)
2280 BD_LINKLIB := %(libdir)/lib%(libname).a
2282 BD_FILES := %(files)
2283 BD_ASMFILES := %(asmfiles)
2284 BD_CXXFILES := %(cxxfiles)
2286 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
2287 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
2288 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
2290 BD_OBJS := $(BD_ARCHOBJS) \
2291 $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES:=.o) $(BD_CXXFILES:=.o) $(BD_ASMFILES:=.o))) \
2293 BD_DEPS := $(patsubst %.o,%.d,$(BD_OBJS))
2295 BD_CFLAGS := %(cflags)
2296 BD_CXXFLAGS := %(cxxflags)
2298 ifeq (%(compiler),target)
2299 BD_CFLAGS := $(LTO_CFLAGS) $(BD_CFLAGS)
2300 BD_CXXFLAGS := $(LTO_CFLAGS) $(BD_CXXFLAGS)
2303 ifneq (%(includedir),)
2304 BD_CFLAGS += -I%(includedir)
2305 BD_CXXFLAGS += -I%(includedir)
2307 BD_AFLAGS := %(aflags)
2308 BD_DFLAGS := %(dflags)
2309 BD_DXXFLAGS := %(dxxflags)
2311 .PHONY : %(mmake) %(mmake)-clean %(mmake)-quick
2314 %(mmake)-quick : %(mmake)
2316 #MM %(mmake) : includes-generate-deps
2317 %(mmake) : $(BD_LINKLIB)
2319 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
2321 %rule_compile_cxx_multi basenames=$(BD_CXXFILES) targetdir="%(objdir)" \
2322 compiler="%(compiler)" cxxflags=$(BD_CXXFLAGS) dxxflags=$(BD_DXXFLAGS)
2323 %rule_compile_multi basenames=$(BD_FILES) targetdir="%(objdir)" \
2324 compiler="%(compiler)" cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
2325 %rule_assemble basename=% targetdir="%(objdir)" \
2328 %rule_link_linklib libname="%(libname)" objs=$(BD_OBJS) libdir="%(libdir)" linker="%(compiler)"
2331 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
2333 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
2334 $(BD_LINKLIB) : | %(libdir)
2335 GLOB_MKDIRS += %(objdir) %(libdir)
2337 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_LINKLIB) $(BD_DEPS)
2340 @$(ECHO) "Cleaning up for metatarget %(mmake)"
2344 #------------------------------------------------------------------------------
2347 #------------------------------------------------------------------------------
2349 # - mmake is the mmaketarget
2350 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
2351 # - description is the catalog description file (.cd), without the .cd suffix (default *.cd)
2352 # - subdir is the destination subdirectory of the catalogs
2353 # - name is the name of the destination catalog, without the .catalog suffix
2354 # - source is the path to the generated source code file
2355 # - dir is the base destination directory (default $(AROS_CATALOGS))
2356 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
2357 # - srcdir is the directory in which the *.cd and *.ct files are searched
2359 %define build_catalogs mmake=/A name=/A subdir=/A \
2360 catalogs= source="../strings.h" description= dir=$(AROS_CATALOGS) \
2361 sourcedescription=$(TOOLDIR)/C_h_aros srcdir=$(SRCDIR)/$(CURDIR)
2363 ifeq (%(description),)
2364 BD_DESC := $(basename $(wildcard %(srcdir)/*.cd))
2366 BD_DESC := %(description)
2369 BD_SRC := $(shell echo %(sourcedescription) | sed 's/^\(.\):\//\/\1\//')
2372 BD_LNGS := $(basename $(notdir $(call WILDCARD, %(srcdir)/*.ct)))
2374 BD_LNGS := %(catalogs)
2377 BD_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, $(BD_LNGS)))
2378 BD_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, $(BD_LNGS))) $(dir %(source))
2381 %(mmake) : $(BD_OBJS) %(source)
2383 $(BD_OBJS) : | $(BD_DIRS)
2384 GLOB_MKDIRS += $(BD_DIRS)
2386 %(dir)/%/%(subdir)/%(name).catalog : %(srcdir)/%.ct $(BD_DESC).cd
2387 @$(ECHO) "Creating %(name) catalog for language $*."
2388 @$(FLEXCAT) $(BD_DESC).cd $< CATALOG="%(dir)/$*/%(subdir)/%(name).catalog" || [ $$? -lt 10 ]
2391 %(source) : BD_DESC := $(BD_DESC)
2392 %(source) : BD_SRC := $(BD_SRC)
2393 %(source) : $(BD_DESC).cd $(BD_SRC).sd | $(dir %(source))
2394 @$(ECHO) "Creating %(name) catalog source file $@"
2395 @$(FLEXCAT) $(BD_DESC).cd $@=$(BD_SRC).sd
2398 %(mmake)-clean : FILES := $(BD_OBJS) %(source)
2401 @$(ECHO) "Cleaning up for metatarget %(mmake)"
2404 .PHONY: %(mmake) %(mmake)-clean
2407 #-----------------------------------------------------------------------------
2410 #-----------------------------------------------------------------------------
2412 # - mmake is the mmaketarget
2413 # - icons is a list of icon base names (ie. without the .info suffix)
2414 # - dir is the destination directory
2415 # - srcdir is where *.png and *.info.src are searched
2416 #-----------------------------------------------------------------------------
2418 %define build_icons mmake=/A icons=/A dir=/A srcdir=$(SRCDIR)/$(CURDIR) image=
2420 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
2423 %(mmake) : $(BD_OBJS)
2427 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%.png
2428 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2429 @$(ILBMTOICON) $+ $@
2433 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%(image)
2434 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2435 @$(ILBMTOICON) $+ $@
2439 $(BD_OBJS) : | %(dir)
2440 GLOB_MKDIRS += %(dir)
2442 %(mmake)-clean : FILES := $(BD_OBJS)
2447 .PHONY: %(mmake) %(mmake)-clean
2450 #-----------------------------------------------------------------------------
2453 #------------------------------------------------------------------------------
2454 # Compile files for an arch-specific replacement of code for a module
2455 # - files: the basenames of the C files to compile.
2456 # - asmfiles: the basenames of the asm files to assemble.
2457 # - mainmmake: the mmake of the module in the main directory to compile these
2458 # arch specific files for.
2459 # - maindir: the object directory for the main module
2460 # - arch: the arch for which to compile these files. It can have the form
2461 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
2462 # - cflags (default $(CFLAGS)): the C flags to use for compilation
2463 # - dflags: the flags used during creation of dependency file. If not specified
2464 # the same value as cflags will be used
2465 # - aflags: the flags used during assembling
2466 # - compiler: (host, kernel or target) specifies which compiler to use. By default
2467 # the target compiler is used
2468 %define build_archspecific files= cxxfiles= asmfiles= linklibfiles= linklibobjs= mainmmake=/A maindir=/A arch=/A \
2469 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
2471 ifeq (%(files) %(linklibfiles) %(linklibobjs) %(asmfiles),)
2472 $(error no files or asmfiles given)
2475 ifneq (%(cxxfiles),)
2476 $(error cxx support is TODO)
2479 %buildid targets="%(mainmmake)-%(arch)"
2481 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2482 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2483 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2484 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2485 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2486 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2487 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2488 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2489 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2490 #MM- %(mainmmake)-kobj-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2491 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2492 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2493 #MM- %(mainmmake)-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2494 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2495 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2497 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
2499 BD_OBJDIR$(BDID) := $(GENDIR)/%(maindir)/arch
2500 BD_LIBOBJDIR$(BDID) := $(GENDIR)/%(maindir)/linklib/arch
2501 BD_FILEOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files)))) $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(cxxfiles))))
2502 BD_LINKLIBOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibfiles))))
2503 BD_LINKLIBARCHOBJS$(BDID) := $(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibobjs)))
2504 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
2505 BD_OBJS$(BDID) := $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) $(BD_ASMOBJS$(BDID))
2506 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files)))) $(addsuffix .d,$(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibfiles))))
2508 ifneq (%(modulename),)
2509 BD_DEFLIBDEFSINC$(BDID) := -include $(GENDIR)/%(maindir)/include/%(modulename)_deflibdefs.h
2512 ifeq ($(TARGET),%(mainmmake)-%(arch)-quick)
2513 BD_TARGET := %(mainmmake)-%(arch)-quick
2515 BD_TARGET := %(mainmmake)-%(arch)
2519 ifeq ($(TARGET),$(BD_TARGET))
2520 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
2521 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(files)))
2522 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(linklibfiles)))
2523 vpath %.s $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2524 vpath %.S $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2527 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID)) $(BD_LIBOBJDIR$(BDID))
2528 GLOB_MKDIRS += $(BD_OBJDIR$(BDID)) $(BD_LIBOBJDIR$(BDID))
2531 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
2534 %(mainmmake)-%(arch)-quick :: $(BD_OBJS$(BDID))
2536 ifeq ($(findstring %(compiler),host kernel target),)
2537 $(error unknown compiler %(compiler))
2539 ifneq (%(modulename),)
2540 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) $(BD_DEFLIBDEFSINC$(BDID))
2542 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
2544 ifeq (%(compiler),target)
2545 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(TARGET_CC) $(TARGET_SYSROOT)
2546 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
2547 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
2549 ifeq (%(compiler),host)
2550 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(HOST_CC)
2551 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
2552 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
2554 ifeq (%(compiler),kernel)
2555 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
2556 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=$(KERNEL_CFLAGS) $(TMP_CFLAGS)
2557 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
2558 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
2561 ifeq ($(TARGET),$(BD_TARGET))
2562 $(BD_LIBOBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2563 %compile_q cmd=$(TMP_CMD) opt=$(TMP_CFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2564 $(BD_OBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2565 %compile_q cmd=$(TMP_CMD) opt=$(TMP_CFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2569 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags) $(BD_DEFLIBDEFSINC$(BDID))
2571 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
2573 ifeq ($(TARGET),$(BD_TARGET))
2574 $(BD_LIBOBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2575 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
2577 $(BD_OBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2578 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
2581 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
2583 ifeq ($(TARGET),$(BD_TARGET))
2584 $(BD_OBJDIR$(BDID))/%.o : %.s
2586 $(BD_OBJDIR$(BDID))/%.o : %.S
2590 %include_deps depstargets=$(BD_TARGET) deps=$(BD_DEPS$(BDID))
2592 #------------------------------------------------------------------------------
2595 #------------------------------------------------------------------------------
2596 # generate asm files from c files (for debugging purposes)
2599 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
2600 @$(TARGET_CC) $(TARGET_SYSROOT) -S $(CFLAGS) $< -c -o $@
2602 #------------------------------------------------------------------------------
2605 #------------------------------------------------------------------------------
2606 # Copy files from one directory to another.
2608 %define copy_files_q mmake=/A files=$(FILES) src=. dst=/A
2610 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
2612 GLOB_MKDIRS += %(dst)
2618 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC))/, $(file)) $(addprefix %(dst)/, $(file))))
2621 #------------------------------------------------------------------------------
2624 #------------------------------------------------------------------------------
2625 # Copy a directory recursively to another place, preserving the original
2626 # hierarchical structure
2628 # src: the source directory whose content will be copied.
2629 # dst: the directories where to copy src's content. If not existing, they will be made.
2630 # excludefiles: files which must not be copied. Path must be relative to src.
2632 %define copy_dir_recursive mmake=/A src=. dst=/A excludefiles=
2638 @cd $(SRCDIR)/$(CURDIR) && $(CPYDIRREC) -s %(src) -d %(dst) -e %(excludefiles)
2641 #------------------------------------------------------------------------------
2644 #------------------------------------------------------------------------------
2645 # Copy include files into the includes directories. There are currently
2646 # two include directories. One for building AROS $(AROS_INCLUDES) and one
2647 # for building tools that need to run on the host system $(GENINCDIR). The
2648 # $(GENINCDIR) path must not contain any references to the C runtime
2649 # library header files.
2651 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
2652 dir= compiler=target includedir=$(AROS_INCLUDES)
2654 ifeq ($(findstring %(compiler),host kernel target),)
2655 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
2660 $(eval TMP_DIRREMAIN := $$$(TMP_DIR))
2661 TMP_DIRFIRST := $(subst $(TMP_DIRREMAIN),,$(TMP_DIR))
2662 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),$(dir %(includes)))
2663 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,$(notdir %(includes)))
2664 ifeq ($(TMP_DIRFIRST),/)
2665 BD_INC_PATH := %(dir)/
2667 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
2670 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
2671 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
2674 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
2677 ifeq (%(compiler),target)
2680 BD_INCL_FILES2 := $(subst %(dir),%(includedir)/%(path),$(dir %(includes)))
2681 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,$(notdir %(includes)))
2683 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,%(includes))
2686 BD_INCL_FILES += $(BD_INCL_FILES2)
2688 $(BD_INCL_FILES2) : %(includedir)/%(path)/% : $(BD_INC_PATH)%
2693 %(mmake) : $(BD_INCL_FILES)
2697 $(BD_INCL_FILES) : | $(dir $(BD_INCL_FILES))
2698 GLOB_MKDIRS += $(dir $(BD_INCL_FILES))
2700 #------------------------------------------------------------------------------
2703 #------------------------------------------------------------------------------
2704 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
2705 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
2706 STUBS_MEM := $(addsuffix .o,$(STUBS))
2707 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
2708 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
2709 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
2711 #MM- linklibs : hidd-%(hidd)-stubs
2712 #MM- %(parenttarget): hidd-%(hidd)-stubs
2713 #MM hidd-%(hidd)-stubs : includes includes-copy
2714 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
2716 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
2719 $(STUBS_OBJ) : $(STUBS_SRC)
2720 %compile_q cmd="$(TARGET_CC) $(TARGET_SYSROOT)" opt="%(cflags)" iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
2722 $(STUBS_DEP) : $(STUBS_SRC)
2723 %mkdepend_q flags="%(dflags)"
2726 %mkdirs_q $(OBJDIR) $(AROS_LIB)
2730 -@$(RM) $(HIDD_LIB) $(OBJDIR)
2732 DEPS := $(DEPS) $(STUBS_DEP)
2735 #------------------------------------------------------------------------------
2738 #------------------------------------------------------------------------------
2739 # Build an imported source tree which uses the configure script from the
2740 # autoconf package. This rule will try to "integrate" the produced files as
2741 # much as possible in the AROS build, for example by putting libraries in the
2742 # standard library directory, includes in the standard include directory, and
2743 # so on. You can however override this behaviour.
2745 # As a special "bonus" for you, the PROGDIR environment variable is defined to
2746 # be %(bindir) (or its deduced value) when running "make install", and
2747 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
2748 # configure script some more parameters whose value depends upon the PROGDIR
2749 # env var, so that the program gets all its stuff installed in the proper place
2750 # when building it, but when running it from inside AROS it can also find that
2751 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
2752 # the configuration parameters set when running ./configure
2754 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
2755 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
2756 # to the name which has to follow it.
2760 # - mmake = the meta make target.
2761 # - package = name of the package to be built.
2762 # - srcdir = the location of the unpacked source code. Defaults
2763 # to $(SRCDIR)/$(CURDIR).
2764 # - prefix = the target directory. Must be an absolute path of the
2765 # host system. Defaults to $(AROS_CONTRIB).
2766 # - aros_prefix = set a path which is valid within the AROS filesystem.
2767 # Defaults to the value of the prefix option.
2768 # - extraoptions = additional options for the configure script.
2769 # - extracflags = additional flags to use with the C compiler.
2770 # - extracxxflags = additional flags to use with the C++ compiler.
2771 # - nix_dir_layout = if yes the binary will be stored in a bin subdirectory.
2772 # Defaults to the value of the nix argument.
2773 # - nix = enable u*nix path handling, i.e. a path like
2774 # /progdir//./file will be translated to
2775 # progdir:file during run-time. Defaults to no.
2776 # - compiler = target, host or kernel. Defaults to target.
2777 # - install_target = the command used for installing. Defaults to install. Leave
2778 # it empty if you want to suppress installing.
2779 # - preconfigure = a metatarget which is executed before configure is called.
2780 # - postconfigure = a metatarget which is executed after configure is called.
2781 # - postinstall = a metatarget which is executed after installing.
2782 # - install_env = set additional options for installing.
2783 # - use_build_env = if yes the configuration environment is used for
2784 # installing, too. Defaults to no.
2786 # The arguments aros_prefix, nix and nix_dir_layout are related. The logic is
2790 # --prefix = $(aros_prefix)
2791 # progdir = $(aros_prefix)/bin
2794 # --prefix = /PROGDIR
2795 # --bindir = /PROGDIR
2796 # --sbindir = /PROGDIR
2798 # --includedir = /INCLUDE
2799 # --oldincludedir = /INCLUDE
2801 # --prefix = $(aros_prefix)
2804 # progdir = $(aros_prefix)
2807 # bindir = $(prefix)
2808 # sbindir = $(prefix)
2809 # libdir = $(AROS_LIB)
2810 # includedir = $(AROS_INCLUDES)
2811 # oldincludedir = $(AROS_INCLUDES)
2815 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) \
2816 prefix= gendir= basedir=$(CURDIR) extraoptions= \
2817 extracflags="$(OPTIMIZATION_CFLAGS)" extracxxflags="$(OPTIMIZATION_CFLAGS)" \
2818 aros_prefix= nix_dir_layout= nix=no compiler=target crossbuild=no \
2819 install_target=install preconfigure= postconfigure= postinstall= \
2820 config_env_extra= install_env= use_build_env=no buildflags=yes gnuflags=yes
2823 %(mmake)-prefix := %(prefix)
2825 %(mmake)-prefix := $(AROS_CONTRIB)
2828 ifneq (%(aros_prefix),)
2829 %(mmake)-aros_prefix := %(aros_prefix)
2831 %(mmake)-aros_prefix := $(%(mmake)-prefix)
2837 %(mmake)-nix := $(BD_NIXFLAG)
2838 %(mmake)-volpfx := /
2839 %(mmake)-volsfx := /
2841 ifeq (%(nix_dir_layout),)
2842 %(mmake)-nix_dir_layout := yes
2845 %(mmake)-volsfx := :
2847 ifeq (%(nix_dir_layout),)
2848 %(mmake)-nix_dir_layout := no
2852 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
2854 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
2855 exec_prefix=$(%(mmake)-prefix) %(install_env)
2857 # Check if chosen compiler is valid
2858 ifeq ($(findstring %(compiler),host target kernel),)
2859 $(error unknown compiler %(compiler))
2862 # Set legacy 'host' variable based on chosen compiler
2863 ifeq (%(compiler),host)
2866 %(mmake)-pkgbasedir := $(HOSTGENDIR)
2868 %(mmake)-pkgbasedir := $(HOSTGENDIR)/%(basedir)
2873 %(mmake)-pkgbasedir := $(GENDIR)
2875 %(mmake)-pkgbasedir := $(GENDIR)/%(basedir)
2880 %(mmake)-pkgbasedir := %(gendir)
2882 %(mmake)-pkgbasedir := %(gendir)/%(basedir)
2887 %(mmake)-pkgdir := $(%(mmake)-pkgbasedir)
2889 %(mmake)-pkgdir := $(%(mmake)-pkgbasedir)/%(package)
2892 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
2893 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
2895 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
2896 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
2897 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2900 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
2901 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
2903 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2906 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
2908 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
2909 sbindir=$(%(mmake)-prefix) \
2910 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
2911 oldincludedir=$(AROS_INCLUDES) %(install_env)
2914 ifneq ($(DEBUG),yes)
2915 %(mmake)-s_flag = -s
2918 # Set up build environment, and options for configure script
2919 ifeq (%(compiler),host)
2920 # NB: We need to pass in our crosstoolsdir, but cannot set CFLAGS since it
2921 # confused configure scripts. We also cannot pass it via _FOR_BUILD
2922 # since that won't get picked up during configure.
2923 # We also cannot pass in the compiler including std flags so we need to use
2924 # the "plain" host compiler.
2925 %(mmake)-cfg-env := %(config_env_extra) \
2927 CXXCPP="$(HOST_CPP)" \
2928 CC="$(HOST_DEF_CC) $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include" \
2929 CXX="$(HOST_CXX) $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include" \
2930 LDFLAGS="-L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS)" \
2931 TARGET_CC="$(KERNEL_CC) $(KERNEL_SYSROOT)" \
2932 TARGET_CFLAGS="$(KERNEL_CFLAGS) $(%(mmake)-s_flag)" \
2933 TARGET_CXX="$(KERNEL_CXX) $(KERNEL_SYSROOT)" \
2934 TARGET_CXXFLAGS="$(KERNEL_CXXFLAGS) $(%(mmake)-s_flag)" \
2935 TARGET_AS="$(TARGET_AS)" \
2936 OBJCOPY="$(OBJCOPY)" \
2937 TARGET_RANLIB="$(RANLIB)" \
2938 TARGET_STRIP="$(STRIP_PLAIN)" \
2939 TARGET_NM="$(NM_PLAIN)" \
2940 TARGET_OBJCOPY="$(TARGET_OBJCOPY)"
2942 ifeq (%(compiler),target)
2943 %(mmake)-cfg-env := %(config_env_extra) \
2944 PKG_CONFIG_LIBDIR="$(AROS_DEVELOPER)/lib/pkgconfig" \
2945 PKG_CONFIG_SYSROOT_DIR="$(AROSDIR)"
2946 %(mmake)-cfg-env += CPP="$(strip $(TARGET_CPP) $(TARGET_SYSROOT))" \
2947 CXXCPP="$(strip $(TARGET_CPP) $(TARGET_SYSROOT))" \
2948 CC="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
2949 CXX="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
2950 LD="$(strip $(TARGET_LD))"
2951 ifeq (%(crossbuild),yes)
2952 %(mmake)-cfg-env += CFLAGS="$(strip $(ISA_FLAGS) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) %(extracflags) $(%(mmake)-s_flag))" \
2953 CXXFLAGS="$(strip $(ISA_FLAGS) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) %(extracxxflags) $(%(mmake)-s_flag))"
2955 %(mmake)-cfg-env += CFLAGS="$(strip $(ISA_FLAGS) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) %(extracflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
2956 CXXFLAGS="$(strip $(ISA_FLAGS) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) %(extracxxflags) $(%(mmake)-nix) $(%(mmake)-s_flag))"
2958 %(mmake)-cfg-env += LDFLAGS="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
2959 CC_FOR_BUILD="$(strip $(HOST_DEF_CC))" \
2960 CFLAGS_FOR_BUILD="$(strip $(HOST_CFLAGS) $(%(mmake)-s_flag))" \
2961 CXX_FOR_BUILD="$(strip $(HOST_CXX))" \
2962 CXXFLAGS_FOR_BUILD="$(strip $(HOST_CXXFLAGS) $(%(mmake)-s_flag))" \
2963 LD_FOR_BUILD="$(strip $(HOST_LD))" \
2964 LDFLAGS_FOR_BUILD="$(strip $(HOST_LDFLAGS) $(%(mmake)-s_flag))" \
2965 CC_FOR_HOST="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
2966 CFLAGS_FOR_HOST="$(strip $(ISA_FLAGS) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) -L$(AROS_DEVELOPER)/lib %(extracflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
2967 CXX_FOR_HOST="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
2968 CXXFLAGS_FOR_HOST="$(strip $(ISA_FLAGS) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) -L$(AROS_DEVELOPER)/lib %(extracxxflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
2969 LD_FOR_HOST="$(strip $(TARGET_LD))" \
2970 LDFLAGS_FOR_HOST="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
2971 CC_FOR_TARGET="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
2972 CFLAGS_FOR_TARGET="$(strip $(ISA_FLAGS) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) -L$(AROS_DEVELOPER)/lib %(extracflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
2973 CXX_FOR_TARGET="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
2974 CXXFLAGS_FOR_TARGET="$(strip $(ISA_FLAGS) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) -L$(AROS_DEVELOPER)/lib %(extracxxflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
2975 LD_FOR_TARGET="$(strip $(TARGET_LD))" \
2976 LDFLAGS_FOR_TARGET="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
2977 AR="$(strip $(AR_PLAIN))" \
2978 AS="$(strip $(TARGET_AS))" \
2979 OBJCOPY="$(strip $(OBJCOPY))" \
2980 RANLIB="$(strip $(RANLIB))" \
2981 STRIP="$(strip $(STRIP_PLAIN))" \
2982 TARGET_CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
2983 TARGET_CFLAGS="$(strip $(KERNEL_CFLAGS) $(%(mmake)-s_flag))" \
2984 TARGET_CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
2985 TARGET_CXXFLAGS="$(strip $(KERNEL_CXXFLAGS) $(%(mmake)-s_flag))" \
2986 TARGET_AS="$(strip $(TARGET_AS))" \
2987 TARGET_RANLIB="$(strip $(RANLIB))" \
2988 TARGET_STRIP="$(strip $(STRIP_PLAIN))" \
2989 TARGET_NM="$(strip $(NM_PLAIN))"
2990 ifeq (%(buildflags),yes)
2991 %(mmake)-config_opts += --target=$(AROS_TARGET_CPU)-aros
2992 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)
2993 %(mmake)-config_opts += --host=$(AROS_TARGET_CPU)-aros
2995 ifeq (%(gnuflags),yes)
2996 %(mmake)-config_opts += --without-pic --disable-shared
2997 %(mmake)-config_opts += --disable-nls --without-x
3000 ifeq (%(compiler),kernel)
3001 %(mmake)-cfg-env := %(config_env_extra) \
3002 CPP="$(KERNEL_CPP)" \
3003 CXXCPP="$(KERNEL_CPP)" \
3004 CC="$(KERNEL_CC) $(KERNEL_SYSROOT)" \
3005 CFLAGS="$(KERNEL_CFLAGS) %(extracflags) $(%(mmake)-s_flag)" \
3006 CXX="$(KERNEL_CXX) $(KERNEL_SYSROOT)" \
3007 CXXFLAGS="$(KERNEL_CXXFLAGS) %(extracxxflags) $(%(mmake)-s_flag)" \
3009 CC_FOR_BUILD="$(HOST_DEF_CC)" \
3010 CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
3011 CXX_FOR_BUILD="$(HOST_CXX)" \
3012 CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
3013 RANLIB="$(RANLIB)" \
3014 TARGET_RANLIB="$(RANLIB)" \
3015 TARGET_STRIP="$(STRIP_PLAIN)" \
3016 TARGET_NM="$(NM_PLAIN)"
3017 ifeq (%(buildflags),yes)
3018 %(mmake)-config_opts += --target=$(AROS_TARGET_CPU)-aros
3019 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)
3020 %(mmake)-config_opts += --host=$(AROS_TARGET_CPU)-aros
3022 ifeq (%(gnuflags),yes)
3023 %(mmake)-config_opts += --without-pic --disable-shared
3024 %(mmake)-config_opts += --disable-nls --without-x
3028 ifeq (%(use_build_env),yes)
3029 BUILD_ENV := $(%(mmake)-cfg-env)
3032 ifneq ("$(wildcard %(srcdir)/Makefile)","")
3033 # in an ideal world, we would depend on the files in the source directory,
3034 # so we could copy them when they change. unfortunately filenames with
3035 # spaces causes problems with this
3036 $(%(mmake)-pkgdir)/.local-copy:
3037 %mkdirs_q $(%(mmake)-pkgdir)
3038 @$(ECHO) "Copying Local-Build Sources to \`$(patsubst $(TOP)/%,%,$(abspath $(%(mmake)-pkgdir)))'"
3039 @$(CP) -Rf "%(srcdir)/." $(%(mmake)-pkgdir)/ && $(TOUCH) $@
3041 $(%(mmake)-pkgdir)/.files-touched : $(%(mmake)-pkgdir)/.local-copy
3043 %(mmake)-cfg-srcdir=$(%(mmake)-pkgdir)
3045 %(mmake)-cfg-srcdir=%(srcdir)
3047 %(mmake)-make-env := -C $(%(mmake)-pkgdir)
3049 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3051 # When building for the host, we don't need to build the
3052 # linklibs - this is especially true when building the
3053 # crosstool toolchain on 'foreign' architectures (such as
3054 # building PPC on x86)
3056 #MM- %(mmake)-host : setup includes %(mmake)-quick
3057 #MM- %(mmake)-target : setup includes core-linklibs %(mmake)-quick
3058 #MM- %(mmake): %(mmake)-%(compiler)
3060 # Using -j1 in install_command may result in a warning but finally
3061 # it does its job. make install for gcc does not work reliably for -jN
3063 ifneq (%(install_target),)
3064 %(mmake)-install_command = \
3065 $(ECHO) "Installing from build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))" && \
3066 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
3067 $(%(mmake)-make-env) %(install_target) -j1
3069 %(mmake)-uninstall_command = \
3070 $(RM) $(%(mmake)-installflag) && \
3071 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" \
3072 $(%(mmake)-install_opts) $(%(mmake)-make-env) uninstall
3074 %(mmake)-install_command := true
3075 %(mmake)-uninstall_command := true
3078 #MM- %(mmake)-quick : %(preconfigure) %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
3081 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3084 # NB : the make test for the targets being upto date generates a benign Error 1.
3086 $(%(mmake)-installflag) : $(%(mmake)-configflag)
3087 @$(IF) ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q $(%(mmake)-make-env); then \
3088 $(RM) $(%(mmake)-installflag) && \
3089 $(ECHO) "Performing build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))" && \
3090 $(BUILD_ENV) $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" $(%(mmake)-make-env) && \
3091 $(%(mmake)-install_command) && \
3092 $(TOUCH) $@ -r $^; \
3095 $(%(mmake)-pkgdir)/.files-touched:
3096 %mkdirs_q $(%(mmake)-pkgdir)
3097 @find %(srcdir) -exec $(TOUCH) -c -r $(%(mmake)-cfg-srcdir)/configure '{}' \; && \
3101 %(mmake)-uninstall :
3102 $(%(mmake)-uninstall_command)
3105 %(mmake)-configure : $(%(mmake)-configflag)
3107 $(%(mmake)-configflag) : TMP_SRCDIR := $(shell echo $(%(mmake)-cfg-srcdir) | sed 's/^\(.\):\//\/\1\//')
3108 $(%(mmake)-configflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
3110 %mkdirs_q $(%(mmake)-pkgdir)
3111 @$(ECHO) "Configuring build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))"
3112 @cd $(%(mmake)-pkgdir) && \
3113 find . -name config.cache -exec $(RM) '{}' \; && \
3114 $(%(mmake)-cfg-env) $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) %(extraoptions) && \
3118 %(mmake)-clean : %(mmake)-uninstall
3119 @$(RM) $(%(mmake)-pkgdir)
3121 #------------------------------------------------------------------------------
3124 #------------------------------------------------------------------------------
3125 # Build an imported source tree which uses cmake
3129 # - mmake = the meta make target.
3130 # - package = name of the package to be built.
3131 # - srcdir = the location of the unpacked source code. Defaults
3132 # to $(SRCDIR)/$(CURDIR).
3133 # - prefix = the target directory. Must be an absolute path of the
3134 # host system. Defaults to $(AROS_CONTRIB).
3135 # - aros_prefix = set a path which is valid within the AROS filesystem.
3136 # Defaults to the value of the prefix option.
3137 # - extraoptions = additional options for the cmake script.
3138 # - installoptions = additional options for the install step.
3141 %define build_with_cmake mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) gendir= prefix= \
3142 aros_prefix= extraoptions= installoptions= maketarget= compiler=target \
3143 cflags=$(CFLAGS) cxxflags=$(CXXFLAGS) ldflags=$(LDFLAGS)
3146 %(mmake)-prefix := %(prefix)
3148 %(mmake)-prefix := $(AROS_CONTRIB)
3151 ifneq (%(aros_prefix),)
3152 %(mmake)-aros_prefix := %(aros_prefix)
3154 %(mmake)-aros_prefix := $(%(mmake)-prefix)
3157 ifeq (%(compiler),host)
3158 BD_LDFLAGS := -L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS)
3159 BD_CFLAGS := $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include
3160 BD_CXXFLAGS := $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include
3161 %(mmake)-cmake_opts := -DCMAKE_INSTALL_PREFIX=$(%(mmake)-prefix) -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(HOST_DEF_CC)" -DCMAKE_C_FLAGS="$(BD_CFLAGS)" -DCMAKE_CXX_COMPILER="$(HOST_CXX)" -DCMAKE_CXX_FLAGS="$(BD_CXXFLAGS)"
3163 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
3165 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
3168 BD_LDFLAGS := %(ldflags)
3169 BD_CFLAGS := %(cflags)
3170 BD_CXXFLAGS := %(cxxflags)
3171 %(mmake)-cmake_opts := -DCMAKE_TOOLCHAIN_FILE=$(GENDIR)/config/conf.cmake -DCMAKE_INSTALL_PREFIX=$(%(mmake)-prefix) -DCMAKE_C_FLAGS="$(BD_CFLAGS)" -DCMAKE_CXX_FLAGS="$(BD_CXXFLAGS)" -DCMAKE_EXE_LINKER_FLAGS="$(BD_LDFLAGS)"
3173 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
3175 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
3180 %(mmake)-pkgdir := %(gendir)/$(CURDIR)
3182 %(mmake)-pkgdir := %(gendir)/$(CURDIR)/%(package)
3186 %(mmake)-cmakeflag := $(%(mmake)-pkgdir)/.cmake
3187 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
3189 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3191 #MM- %(mmake): setup includes core-linklibs %(mmake)-quick
3193 #MM- %(mmake)-quick : %(mmake)-cmake %(mmake)-build_and_install-quick
3196 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3198 $(%(mmake)-installflag) : $(%(mmake)-cmakeflag)
3199 $(IF) ! $(MAKE) -q -C $(%(mmake)-pkgdir); then \
3200 $(RM) $(%(mmake)-installflag) && \
3201 $(MAKE) -C $(%(mmake)-pkgdir) %(maketarget) && \
3202 cd $(%(mmake)-pkgdir) && \
3203 cmake %(installoptions) -P cmake_install.cmake && \
3204 $(TOUCH) $@ -r $^; \
3207 $(%(mmake)-pkgdir)/.files-touched:
3208 %mkdirs_q $(%(mmake)-pkgdir)
3209 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/CMakeLists.txt '{}' \; && \
3213 %(mmake)-cmake : $(%(mmake)-cmakeflag)
3215 $(%(mmake)-cmakeflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
3216 $(%(mmake)-cmakeflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
3218 %mkdirs_q $(%(mmake)-pkgdir)
3219 cd $(%(mmake)-pkgdir) && \
3220 $(RM) -Rf CMakeCache.txt CMakeFiles \; && \
3221 cmake $(%(mmake)-cmake_opts) %(extraoptions) $(TMP_SRCDIR) && \
3225 %(mmake)-clean : %(mmake)-uninstall
3226 @$(RM) $(%(mmake)-pkgdir)
3228 #------------------------------------------------------------------------------
3231 #------------------------------------------------------------------------------
3232 # Given an archive name, patches names and locations where to find them, fetch
3233 # the archive and the patches from any of those locations, unpack the archive
3234 # and then apply the patches.
3236 # Locations currently supported are http and ftp sites, plus local filesystem
3237 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
3238 # the fetch.sh script needs to be modified, since this macro relies on that script.
3242 # - mmake = mmaketarget
3243 # - archive_origins = list of locations where to find the archive. They are tried
3244 # in sequence, until the archive is found and fetching it
3245 # succeeded. If not specified, the current directory is assumed.
3246 # - archive = the archive name. Mandatory.
3247 # - suffixes = a list of suffixes to append to the the package name plus the
3248 # version. Each one of them is tried until a matching archive is
3249 # found. They are appended to patches and these are tried the
3250 # same way as packages are.
3251 # - location = the local directory where to put the fetched archive and patches.
3252 # If not specified, the directory specified by destination is used.
3253 # - destination = the directory to unpack the archive to.
3254 # If not specified, the current directory is assumed.
3255 # - patches_origins = list of locations where to find the patches. They are tried
3256 # in sequence, until a patch is found and fetching it
3257 # succeeded. If not specified, the current directory is assumed.
3258 # - patches_specs = list of "patch specs". A patch spec is of the form
3259 # patch_name[:[patch_subdir][:patch_opt]].
3261 # - patch_name = the name of the patch file
3262 # - patch_subdir = the directory within \destination\ where to
3264 # - patch_opt = any options to pass to the `patch' command
3265 # when applying the patch.
3267 # The patch_subdir and patch_opt fields are optional.
3269 %define fetch mmake=/A archive_origins=. archive=/A suffixes= location= destination=. \
3270 patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
3274 ifneq (%(location),)
3275 %(mmake)-location := %(location)
3277 %(mmake)-location := %(destination)
3282 $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
3283 -d %(destination) -po "%(patches_origins)" -p "%(patches_specs)"
3285 #------------------------------------------------------------------------------
3288 #------------------------------------------------------------------------------
3289 # This macro can aid in patch creation for fetched ports. It temporarily creates another
3290 # unpatched source tree and runs diff against this and a previously fetched and possibly
3291 # patched tree. Depending on what happens after patching during a normal build it might
3292 # give best results if the new patch is created directly after fetch.
3296 # - mmake = mmaketarget
3297 # - archive = archive base name
3298 # - srcdir = the top level directory the package is unpacked to, useful if
3299 # an archive unpacks to a directory other than its name suggests.
3300 # this should not be deeper than a single path element.
3301 # - suffixes = a list of suffixes to append to the the package name plus the
3302 # version. Each one of them is tried until a matching archive is
3304 # - destination = the directory to unpack the archive to.
3305 # - excludes = diff patterns to exclude files or directories from the patch
3307 %define create_patch mmake=/A archive=/A srcdir= suffixes="tar.bz2 tar.gz" destination=/A excludes=
3311 ifneq (%(excludes),)
3312 %(mmake)-exclude := -X ./exclude.patterns
3316 %(mmake)-srcdir := %(srcdir)
3318 %(mmake)-srcdir := %(archive)
3321 #MM- %(mmake) : %(mmake)-diff
3322 #MM- %(mmake)-quick : %(mmake)-diff
3326 @$(FETCH) -a %(archive) -s "%(suffixes)" -l $(PORTSSOURCEDIR) -d %(destination)/tmp ; \
3327 $(MV) %(destination)/$(%(mmake)-srcdir) %(destination)/tmp/$(%(mmake)-srcdir).aros ; \
3328 cd %(destination)/tmp ; \
3329 $(FOR) f in %(excludes) ; do \
3330 $(ECHO) $$f >> ./exclude.patterns ; \
3332 diff -ruN $(%(mmake)-exclude) \
3333 $(%(mmake)-srcdir) \
3334 $(%(mmake)-srcdir).aros \
3335 >$(SRCDIR)/$(CURDIR)/%(archive)-aros-new.diff ; \
3336 $(MV) %(destination)/tmp/$(%(mmake)-srcdir).aros %(destination)/$(%(mmake)-srcdir) ; \
3337 $(RM) %(destination)/tmp
3339 #------------------------------------------------------------------------------
3342 #------------------------------------------------------------------------------
3343 # Joins the features of %fetch and %build_with_configure.
3345 # If a patch is provided, it *must* be named the following way:
3347 # <package name>-<version number>-aros.diff
3349 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3350 # CD'ing into the archive's extracted directory.
3352 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3353 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3354 # to make that patch fully comprehensive.
3358 # - mmake = the meta make target.
3359 # - package = the GNU package name, sans version and archive format suffixes.
3360 # - subpackage = ???
3361 # - compiler = same meaning as the one for the %build_with_configure macro.
3362 # - install_target = same meaning as the one for the %build_with_configure macro.
3363 # - version = the package's version number, or otherwise any other version string.
3364 # It gets appended to the package name to form the basename of the archive.
3365 # - suffixes = a list of suffixes to apped to the the package name plus the
3366 # version. Each one of them is tried until a matching archive is found.
3367 # Defaults to "tar.bz2 tar.gz".
3368 # - srcdir = the top level directory the package is unpacked to (see create_patch).
3369 # - builddir = override the location we expect to run configure/make in.
3370 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
3371 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
3372 # fetched or not. Default to no.
3373 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
3374 # - prefix = same meaning as the one for the %build_with_configure macro.
3375 # - aros_prefix = same meaning as the one for the %build_with_configure macro.
3376 # - extraoptions = same meaning as the one for the %build_with_configure macro.
3377 # - extracflags = same meaning as the one for the %build_with_configure macro.
3378 # - extracxxflags = same meaning as the one for the %build_with_configure macro.
3379 # - preconfigure = same meaning as the one for the %build_with_configure macro.
3380 # - postconfigure = same meaning as the one for the %build_with_configure macro.
3381 # - postinstall = same meaning as the one for the %build_with_configure macro.
3382 # - install_env = same meaning as the one for the %build_with_configure macro.
3383 # - use_build_env = same meaning as the one for the %build_with_configure macro.
3384 # - nix = same meaning as the one for the %build_with_configure macro.
3385 # - nix_dir_layout = same meaning as the one for the %build_with_configure macro.
3386 # - create_pkg = create a distributable package of the compiled sources, defaults to no
3388 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target crossbuild=no install_target=install \
3389 version=/A suffixes="tar.bz2 tar.gz" srcdir= builddir= gendir= basedir=$(CURDIR) package_repo= patch=no patch_repo= \
3390 prefix= aros_prefix= preconfigure= postconfigure= postinstall= \
3391 extraoptions= extracflags="$(OPTIMIZATION_CFLAGS)" extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3392 config_env_extra= install_env= use_build_env=no nix=no nix_dir_layout= create_pkg=no buildflags=yes gnuflags=yes
3394 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
3395 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
3396 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
3397 #MM- %(mmake)-create-patch : %(mmake)-%(subpackage)-create-patch
3399 %(mmake)-archbase := %(package)-%(version)
3401 ifeq (%(compiler),host)
3402 %(mmake)-portdir := $(HOSTDIR)/Ports/host/%(package)
3404 %(mmake)-portdir := $(PORTSDIR)/%(package)
3408 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
3410 %(mmake)-prefix := %(prefix)
3413 ifneq (%(subpackage),)
3414 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
3416 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
3420 %(mmake)-%(subpackage)-srcdir := %(srcdir)
3422 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
3425 ifneq (%(builddir),)
3426 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)/%(builddir)
3428 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)
3432 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-f,-p1
3434 %(mmake)-%(subpackage)-patches_specs := ::
3437 %fetch mmake="%(mmake)-%(subpackage)-fetch" archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
3438 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
3439 archive_origins=". %(package_repo)" \
3440 patches_specs=$(%(mmake)-%(subpackage)-patches_specs) patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
3442 %create_patch mmake="%(mmake)-%(subpackage)-create-patch" \
3443 archive=$(%(mmake)-%(subpackage)-archbase) \
3444 srcdir=$(%(mmake)-%(subpackage)-srcdir) \
3445 suffixes="%(suffixes)" \
3446 destination=$(%(mmake)-portdir)
3448 #MM- %(mmake) : %(mmake)-%(subpackage)
3450 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
3452 %(mmake)-%(subpackage)-package-basename := \
3453 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
3455 ifneq (%(create_pkg),no)
3456 %(mmake)-%(subpackage)-package := $(%(mmake)-%(subpackage)-package-basename).tar.bz2
3459 %build_with_configure mmake="%(mmake)-%(subpackage)" package="%(package)" compiler="%(compiler)" crossbuild="%(crossbuild)" install_target="%(install_target)" \
3460 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-builddir) gendir="%(gendir)" basedir="%(basedir)" \
3461 config_env_extra="%(config_env_extra)" install_env="%(install_env)" use_build_env="%(use_build_env)" \
3462 nix="%(nix)" nix_dir_layout="%(nix_dir_layout)" prefix=$(%(mmake)-prefix) \
3463 aros_prefix="%(aros_prefix)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
3464 %(mmake)-%(subpackage)-make-package" extraoptions="%(extraoptions)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)" buildflags=%(buildflags) gnuflags=%(gnuflags)
3466 .PHONY : %(mmake)-%(subpackage)-make-package %(mmake)-%(subpackage)-create-patch
3467 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
3470 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package)
3472 #There seems to be a bug, either with my clock or with make, 'cause it may happen
3473 #that $^ and $@ have exactly the same mtime, and in that case make tries
3474 #to rebuild $@ again, which would fail because the directory where
3475 #the package got installed would not exist anymore.
3476 #We work this around by using an if statement to manually check the mtimes.
3477 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
3478 @$(IF) $(TEST) $(%(mmake)-installflag) -nt $@ || ! $(TEST) -f $@; then \
3480 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
3481 $(MKDIR) -p "$(DISTDIR)/Packages" ; \
3482 $(MKDIR) -p "$(%(mmake)-prefix)" ; \
3483 cd $(%(mmake)-%(subpackage)-package-dir) ; \
3484 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
3485 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
3488 #------------------------------------------------------------------------------
3491 #------------------------------------------------------------------------------
3492 # Joins the features of %fetch and %build_with_configure, taking advantage of
3493 # the naming scheme of GNU packages. GNU packages names are in the form
3495 # <package name>-<version number>.<archive format suffix>
3497 # If a patch is provided, it *must* be named the following way:
3499 # <package name>-<version number>-aros.diff
3501 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3502 # CD'ing into the archive's extracted directory.
3504 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3505 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3506 # to make that patch fully comprehensive.
3508 # NOTE: GNU packages are always compiled with *nix semantics turned on.
3512 # Arguments have the same meaning as the one for the %fetch_and_build macro, except:
3514 # - prefix = defaults to $(GNUDIR).
3515 # - aros_prefix = defaults to /GNU.
3517 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A crossbuild=no suffixes="tar.bz2 tar.gz" \
3518 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
3519 aros_prefix=/GNU config_env_extra= preconfigure= postconfigure= postinstall= nix=yes \
3520 extraoptions= extracflags="$(OPTIMIZATION_CFLAGS)" extracxxflags="$(OPTIMIZATION_CFLAGS)"
3522 GNU_REPOSITORY := gnu://
3524 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
3525 crossbuild="%(crossbuild)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
3526 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
3527 patch="%(patch)" patch_repo="%(patch_repo)" \
3528 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)" \
3529 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=%(nix)
3532 #------------------------------------------------------------------------------
3535 #------------------------------------------------------------------------------
3536 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
3537 # that the package is a "Developer" package, and as such it needs to be placed
3538 # under the $(AROS_DEVELOPER) directory, as a default.
3540 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
3541 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
3542 # "mmake" argument, because the metatarget is implicitely defined as
3544 # #MM- development-%(package)
3546 %define fetch_and_build_gnu_development package=/A subpackage= version=/A crossbuild=no suffixes="tar.bz2 tar.gz" \
3547 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPER) \
3548 aros_prefix=/Developer config_env_extra= preconfigure= postconfigure= postinstall= nix=yes \
3549 extraoptions= extracflags="$(OPTIMIZATION_CFLAGS)" extracxxflags="$(OPTIMIZATION_CFLAGS)"
3551 #MM- development : development-%(package)
3554 %fetch_and_build_gnu mmake="development-%(package)" package="%(package)" subpackage="%(subpackage)" \
3555 version="%(version)" crossbuild="%(crossbuild)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
3556 package_repo="%(package_repo)" \
3557 patch="%(patch)" patch_repo="%(patch_repo)" \
3558 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)" \
3559 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="postinstall-%(package)-delete-la-files %(postinstall)" nix=%(nix)
3562 postinstall-%(package)-delete-la-files:
3563 $(RM) %(prefix)/lib/*.la
3566 #------------------------------------------------------------------------------
3568 # Builds a kickstart package in PKG format
3572 # - mmake = target name
3573 # - file = destination file name with path
3575 # Other arguments are self-explanatory
3577 %define make_package mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
3578 arch_classes= arch_devs= arch_handlers= arch_hidds= arch_libs= arch_res=
3580 PKG_CLASSES := $(addprefix $(AROS_CLASSES)/,$(addsuffix .class, %(classes)))
3581 PKG_DEVICES := $(addprefix $(AROS_DEVS)/,$(addsuffix .device, %(devs)))
3582 PKG_HANDLERS := $(addprefix $(AROS_FS)/,$(addsuffix -handler, %(handlers)))
3583 PKG_HIDD := $(addprefix $(AROS_DEVS)/Drivers/,$(addsuffix .hidd, %(hidds)))
3584 PKG_LIBS := $(addprefix $(AROS_LIBRARIES)/,$(addsuffix .library, %(libs)))
3585 PKG_RESOURCES := $(addprefix $(AROS_DEVS)/,$(addsuffix .resource, %(res)))
3587 PKG_CLASSES_ARCH := $(addprefix $(AROS_CLASSES_ARCH)/,$(addsuffix .class, %(arch_classes)))
3588 PKG_DEVICES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .device, %(arch_devs)))
3589 PKG_HANDLERS_ARCH := $(addprefix $(AROS_FS_ARCH)/,$(addsuffix -handler, %(arch_handlers)))
3590 PKG_HIDD_ARCH := $(addprefix $(AROS_DEVS_ARCH)/Drivers/,$(addsuffix .hidd, %(arch_hidds)))
3591 PKG_LIBRARIES_ARCH := $(addprefix $(AROS_LIBRARIES_ARCH)/,$(addsuffix .library, %(arch_libs)))
3592 PKG_RESOURCES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .resource, %(arch_res)))
3594 PKG_FILES := $(PKG_CLASSES) $(PKG_DEVICES) $(PKG_HANDLERS) $(PKG_HIDD) $(PKG_LIBS) $(PKG_RESOURCES) \
3595 $(PKG_CLASSES_ARCH) $(PKG_DEVICES_ARCH) $(PKG_HANDLERS_ARCH) $(PKG_HIDD_ARCH) $(PKG_LIBRARIES_ARCH) $(PKG_RESOURCES_ARCH)
3596 PKG_DIR := $(dir %(file))
3602 %(mmake)-quick : %(file)
3604 %(file): $(PKG_FILES) | $(PKG_DIR)
3605 @$(ECHO) Packaging $@...
3606 @$(SRCDIR)/tools/package/pkg c $@ $^
3608 %compress_file mmake="%(mmake)" file="%(file)"
3610 GLOB_MKDIRS += $(PKG_DIR)
3614 #------------------------------------------------------------------------------
3615 # Compresses %(file) with a gzip.
3616 # Good in conjunction with for example %build_prog
3618 %define compress_file mmake=/A file=/A
3620 #MM- %(mmake)-gz : %(mmake) %(mmake)-gz-quick
3623 %(mmake)-gz-quick : %(file).gz
3626 @$(ECHO) Compressing $(subst $(TARGETDIR)/,,$^)...
3631 #------------------------------------------------------------------------------
3632 # Links a kickstart module in ELF format
3633 # Arguments are similar to make_package
3635 %define link_kickstart mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
3636 startup= uselibs= ldflags=$(LDFLAGS) map= deps=
3638 KOBJ_CLASSES := $(addprefix $(KOBJSDIR)/, $(addsuffix _class.o, %(classes)))
3639 KOBJ_DEVICES := $(addprefix $(KOBJSDIR)/, $(addsuffix _device.o, %(devs)))
3640 KOBJ_HANDLERS := $(addprefix $(KOBJSDIR)/, $(addsuffix _handler.o, %(handlers)))
3641 KOBJ_HIDD := $(addprefix $(KOBJSDIR)/, $(addsuffix _hidd.o, %(hidds)))
3642 KOBJ_LIBS := $(addprefix $(KOBJSDIR)/, $(addsuffix _library.o, %(libs)))
3643 KOBJ_RES := $(addprefix $(KOBJSDIR)/, $(addsuffix _resource.o, %(res)))
3646 KOBJ_STARTUP := $(GENDIR)/$(RESIDENT_BEGIN).o
3648 KOBJ_STARTUP := %(startup)
3651 KOBJS := $(KOBJ_STARTUP) $(KOBJ_CLASSES) $(KOBJ_HANDLERS) $(KOBJ_LIBS) $(KOBJ_DEVICES) $(KOBJ_HIDD) $(KOBJ_RES)
3653 TMP_LDFLAGS := %(ldflags)
3655 # Make a list of the lib files this program depends on.
3656 # In LDFLAGS remove white space between -L and directory
3657 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
3658 # Filter out only the libdirs and remove -L
3659 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
3661 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
3662 # Add normal linklib path
3663 TMP_DIRS += $(AROS_LIB)/
3664 # add lib and .a to static linklib names
3665 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
3666 # search for the linklibs in the given path, ignore ones not found
3667 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
3668 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
3671 TMP_DIRS += $(dir %(file))
3673 TMP_LDFLAGS += $(GENMAP) %(map)
3674 TMP_DIRS += $(dir %(map))
3677 #MM %(mmake) : %(deps)
3683 %(mmake)-quick : %(file)
3685 %(file): KOBJS := $(KOBJS)
3686 %(file): LDFLAGS := $(TMP_LDFLAGS) $(NOSTARTUP_LDFLAGS) \
3687 -static -nosysbase -Wl,-Ur
3688 %(file): LDLIBS := $(addprefix -l, %(uselibs))
3689 %(file): $(KOBJS) $(DEPLIBS) | $(TMP_DIRS)
3690 @$(ECHO) "Kickstart $(subst $(TARGETDIR)/,,$@)..."
3691 @$(TARGET_CC) $(TARGET_SYSROOT) -o $@ $(KOBJS) $(LDFLAGS) $(LDLIBS)
3693 @$(STRIP) $@ --only-keep-debug -o $@.dbg
3697 %compress_file mmake="%(mmake)" file="%(file)"
3699 GLOB_MKDIRS += $(TMP_DIRS)