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 %define build_linklib mmake=/A libname=/A files= cxxfiles= \
2272 asmfiles= objs= objdir=$(GENDIR)/$(CURDIR) libdir=$(AROS_LIB) \
2274 cflags=$(CFLAGS) dflags=$(BD_CFLAGS) cxxflags=$(CXXFLAGS) dxxflags=$(BD_CXXFLAGS) \
2275 aflags=$(AFLAGS) compiler=target lto=$(TARGET_LTO)
2277 # assign and generate the local variables used in this macro
2278 BD_LIBNAME := %(libname)
2279 BD_LINKLIB := %(libdir)/lib%(libname).a
2281 BD_FILES := %(files)
2282 BD_ASMFILES := %(asmfiles)
2283 BD_CXXFILES := %(cxxfiles)
2285 BD_ARCHOBJS := $(wildcard %(objdir)/arch/*.o)
2286 BD_ARCHFILES := $(basename $(notdir $(BD_ARCHOBJS)))
2287 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
2289 BD_OBJS := $(BD_ARCHOBJS) \
2290 $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES:=.o) $(BD_CXXFILES:=.o) $(BD_ASMFILES:=.o))) \
2292 BD_DEPS := $(patsubst %.o,%.d,$(BD_OBJS))
2294 BD_CFLAGS := %(cflags)
2295 BD_CXXFLAGS := %(cxxflags)
2297 ifeq (%(compiler),target)
2298 BD_CFLAGS := $(LTO_CFLAGS) $(BD_CFLAGS)
2299 BD_CXXFLAGS := $(LTO_CFLAGS) $(BD_CXXFLAGS)
2302 ifneq (%(includedir),)
2303 BD_CFLAGS += -I%(includedir)
2304 BD_CXXFLAGS += -I%(includedir)
2306 BD_AFLAGS := %(aflags)
2307 BD_DFLAGS := %(dflags)
2308 BD_DXXFLAGS := %(dxxflags)
2310 .PHONY : %(mmake) %(mmake)-clean %(mmake)-quick
2313 %(mmake)-quick : %(mmake)
2315 #MM %(mmake) : includes-generate-deps
2316 %(mmake) : $(BD_LINKLIB)
2318 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
2320 %rule_compile_cxx_multi basenames=$(BD_CXXFILES) targetdir="%(objdir)" \
2321 compiler="%(compiler)" cxxflags=$(BD_CXXFLAGS) dxxflags=$(BD_DXXFLAGS)
2322 %rule_compile_multi basenames=$(BD_FILES) targetdir="%(objdir)" \
2323 compiler="%(compiler)" cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
2324 %rule_assemble basename=% targetdir="%(objdir)" \
2327 %rule_link_linklib libname="%(libname)" objs=$(BD_OBJS) libdir="%(libdir)" linker="%(compiler)"
2330 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
2332 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
2333 $(BD_LINKLIB) : | %(libdir)
2334 GLOB_MKDIRS += %(objdir) %(libdir)
2336 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_LINKLIB) $(BD_DEPS)
2339 @$(ECHO) "Cleaning up for metatarget %(mmake)"
2343 #------------------------------------------------------------------------------
2346 #------------------------------------------------------------------------------
2348 # - mmake is the mmaketarget
2349 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
2350 # - description is the catalog description file (.cd), without the .cd suffix (default *.cd)
2351 # - subdir is the destination subdirectory of the catalogs
2352 # - name is the name of the destination catalog, without the .catalog suffix
2353 # - source is the path to the generated source code file
2354 # - dir is the base destination directory (default $(AROS_CATALOGS))
2355 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
2356 # - srcdir is the directory in which the *.cd and *.ct files are searched
2358 %define build_catalogs mmake=/A name=/A subdir=/A \
2359 catalogs= source="../strings.h" description= dir=$(AROS_CATALOGS) \
2360 sourcedescription=$(TOOLDIR)/C_h_aros srcdir=$(SRCDIR)/$(CURDIR)
2362 ifeq (%(description),)
2363 BD_DESC := $(basename $(wildcard %(srcdir)/*.cd))
2365 BD_DESC := %(description)
2368 BD_SRC := $(shell echo %(sourcedescription) | sed 's/^\(.\):\//\/\1\//')
2371 BD_LNGS := $(basename $(notdir $(call WILDCARD, %(srcdir)/*.ct)))
2373 BD_LNGS := %(catalogs)
2376 BD_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, $(BD_LNGS)))
2377 BD_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, $(BD_LNGS))) $(dir %(source))
2380 %(mmake) : $(BD_OBJS) %(source)
2382 $(BD_OBJS) : | $(BD_DIRS)
2383 GLOB_MKDIRS += $(BD_DIRS)
2385 %(dir)/%/%(subdir)/%(name).catalog : %(srcdir)/%.ct $(BD_DESC).cd
2386 @$(ECHO) "Creating %(name) catalog for language $*."
2387 @$(FLEXCAT) $(BD_DESC).cd $< CATALOG="%(dir)/$*/%(subdir)/%(name).catalog" || [ $$? -lt 10 ]
2390 %(source) : BD_DESC := $(BD_DESC)
2391 %(source) : BD_SRC := $(BD_SRC)
2392 %(source) : $(BD_DESC).cd $(BD_SRC).sd | $(dir %(source))
2393 @$(ECHO) "Creating %(name) catalog source file $@"
2394 @$(FLEXCAT) $(BD_DESC).cd $@=$(BD_SRC).sd
2397 %(mmake)-clean : FILES := $(BD_OBJS) %(source)
2400 @$(ECHO) "Cleaning up for metatarget %(mmake)"
2403 .PHONY: %(mmake) %(mmake)-clean
2406 #-----------------------------------------------------------------------------
2409 #-----------------------------------------------------------------------------
2411 # - mmake is the mmaketarget
2412 # - icons is a list of icon base names (i.e. without the .info suffix)
2413 # - dir is the destination directory
2414 # - srcdir is where *.png and *.info.src are sought
2415 #-----------------------------------------------------------------------------
2417 %define build_icons mmake=/A icons=/A dir=/A srcdir=$(SRCDIR)/$(CURDIR) image=
2419 BD_OBJS := $(addprefix %(dir)/, $(addsuffix .info,%(icons)))
2422 %(mmake) : $(BD_OBJS)
2426 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%.png
2427 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2428 @$(ILBMTOICON) $+ $@
2432 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%(image)
2433 @$(ECHO) "Creating $(subst $(TARGETDIR)/,,$@)..."
2434 @$(ILBMTOICON) $+ $@
2438 $(BD_OBJS) : | %(dir)
2439 GLOB_MKDIRS += %(dir)
2441 %(mmake)-clean : FILES := $(BD_OBJS)
2446 .PHONY: %(mmake) %(mmake)-clean
2449 #-----------------------------------------------------------------------------
2452 #------------------------------------------------------------------------------
2453 # Compile files for an arch-specific replacement of code for a module
2454 # - files: the basenames of the C files to compile.
2455 # - asmfiles: the basenames of the asm files to assemble.
2456 # - mainmmake: the mmake of the module in the main directory to compile these
2457 # arch specific files for.
2458 # - maindir: the object directory for the main module
2459 # - arch: the arch for which to compile these files. It can have the form
2460 # of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
2461 # - cflags (default $(CFLAGS)): the C flags to use for compilation
2462 # - dflags: the flags used during creation of dependency file. If not specified
2463 # the same value as cflags will be used
2464 # - aflags: the flags used during assembling
2465 # - compiler: (host, kernel or target) specifies which compiler to use. By default
2466 # the target compiler is used
2467 %define build_archspecific files= cxxfiles= asmfiles= linklibfiles= linklibobjs= mainmmake=/A maindir=/A arch=/A \
2468 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
2470 ifeq (%(files) %(linklibfiles) %(linklibobjs) %(asmfiles),)
2471 $(error no files or asmfiles given)
2474 ifneq (%(cxxfiles),)
2475 $(error cxx support is TODO)
2478 %buildid targets="%(mainmmake)-%(arch)"
2480 #MM- %(mainmmake) : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2481 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2482 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2483 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2484 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2485 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2486 #MM- %(mainmmake)-kobj : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
2487 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
2488 #MM %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
2489 #MM- %(mainmmake)-kobj-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2490 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2491 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2492 #MM- %(mainmmake)-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-$(CPU)-quick \
2493 #MM %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT)-quick %(mainmmake)-$(ARCH)-quick \
2494 #MM %(mainmmake)-$(FAMILY)-quick %(mainmmake)-$(CPU)-quick
2496 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
2498 BD_OBJDIR$(BDID) := $(GENDIR)/%(maindir)/arch
2499 BD_LIBOBJDIR$(BDID) := $(GENDIR)/%(maindir)/linklib/arch
2500 BD_FILEOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files)))) $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(cxxfiles))))
2501 BD_LINKLIBOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibfiles))))
2502 BD_LINKLIBARCHOBJS$(BDID) := $(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibobjs)))
2503 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
2504 BD_OBJS$(BDID) := $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) $(BD_ASMOBJS$(BDID))
2505 BD_DEPS$(BDID) := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files)))) $(addsuffix .d,$(addprefix $(BD_LIBOBJDIR$(BDID))/,$(notdir %(linklibfiles))))
2507 ifneq (%(modulename),)
2508 BD_DEFLIBDEFSINC$(BDID) := -include $(GENDIR)/%(maindir)/include/%(modulename)_deflibdefs.h
2511 ifeq ($(TARGET),%(mainmmake)-%(arch)-quick)
2512 BD_TARGET := %(mainmmake)-%(arch)-quick
2514 BD_TARGET := %(mainmmake)-%(arch)
2518 ifeq ($(TARGET),$(BD_TARGET))
2519 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
2520 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(files)))
2521 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(linklibfiles)))
2522 vpath %.s $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2523 vpath %.S $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
2526 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID)) $(BD_LIBOBJDIR$(BDID))
2527 GLOB_MKDIRS += $(BD_OBJDIR$(BDID)) $(BD_LIBOBJDIR$(BDID))
2530 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
2533 %(mainmmake)-%(arch)-quick :: $(BD_OBJS$(BDID))
2535 ifeq ($(findstring %(compiler),host kernel target),)
2536 $(error unknown compiler %(compiler))
2538 ifneq (%(modulename),)
2539 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) $(BD_DEFLIBDEFSINC$(BDID))
2541 $(BD_FILEOBJS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
2543 ifeq (%(compiler),target)
2544 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(TARGET_CC) $(TARGET_SYSROOT)
2545 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
2546 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
2548 ifeq (%(compiler),host)
2549 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(HOST_CC)
2550 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
2551 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
2553 ifeq (%(compiler),kernel)
2554 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_SYSROOT)
2555 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_CFLAGS:=$(KERNEL_CFLAGS) $(TMP_CFLAGS)
2556 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
2557 $(BD_FILEOBJS$(BDID)) $(BD_DEPS$(BDID)) $(BD_LINKLIBOBJS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
2560 ifeq ($(TARGET),$(BD_TARGET))
2561 $(BD_LIBOBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2562 %compile_q cmd=$(TMP_CMD) opt=$(TMP_CFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2563 $(BD_OBJDIR$(BDID))/%.o : $(SRCDIR)/$(CURDIR)/%.c
2564 %compile_q cmd=$(TMP_CMD) opt=$(TMP_CFLAGS) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
2568 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags) $(BD_DEFLIBDEFSINC$(BDID))
2570 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
2572 ifeq ($(TARGET),$(BD_TARGET))
2573 $(BD_LIBOBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2574 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
2576 $(BD_OBJDIR$(BDID))/%.d : $(SRCDIR)/$(CURDIR)/%.c
2577 %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
2580 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
2582 ifeq ($(TARGET),$(BD_TARGET))
2583 $(BD_OBJDIR$(BDID))/%.o : %.s
2585 $(BD_OBJDIR$(BDID))/%.o : %.S
2589 %include_deps depstargets=$(BD_TARGET) deps=$(BD_DEPS$(BDID))
2591 #------------------------------------------------------------------------------
2594 #------------------------------------------------------------------------------
2595 # generate asm files from c files (for debugging purposes)
2598 @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
2599 @$(TARGET_CC) $(TARGET_SYSROOT) -S $(CFLAGS) $< -c -o $@
2601 #------------------------------------------------------------------------------
2604 #------------------------------------------------------------------------------
2605 # Copy files from one directory to another.
2607 %define copy_files_q mmake=/A files=$(FILES) src=. dst=/A
2609 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
2611 GLOB_MKDIRS += %(dst)
2617 $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC))/, $(file)) $(addprefix %(dst)/, $(file))))
2620 #------------------------------------------------------------------------------
2623 #------------------------------------------------------------------------------
2624 # Copy a directory recursively to another place, preserving the original
2625 # hierarchical structure
2627 # src: the source directory whose content will be copied.
2628 # dst: the directories where to copy src's content. If not existing, they will be made.
2629 # excludefiles: files which must not be copied. Path must be relative to src.
2631 %define copy_dir_recursive mmake=/A src=. dst=/A excludefiles=
2637 @cd $(SRCDIR)/$(CURDIR) && $(CPYDIRREC) -s %(src) -d %(dst) -e %(excludefiles)
2640 #------------------------------------------------------------------------------
2643 #------------------------------------------------------------------------------
2644 # Copy include files into the includes directories. There are currently
2645 # two include directories. One for building AROS $(AROS_INCLUDES) and one
2646 # for building tools that need to run on the host system $(GENINCDIR). The
2647 # $(GENINCDIR) path must not contain any references to the C runtime
2648 # library header files.
2650 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
2651 dir= compiler=target includedir=$(AROS_INCLUDES)
2653 ifeq ($(findstring %(compiler),host kernel target),)
2654 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
2659 $(eval TMP_DIRREMAIN := $$$(TMP_DIR))
2660 TMP_DIRFIRST := $(subst $(TMP_DIRREMAIN),,$(TMP_DIR))
2661 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),$(dir %(includes)))
2662 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,$(notdir %(includes)))
2663 ifeq ($(TMP_DIRFIRST),/)
2664 BD_INC_PATH := %(dir)/
2666 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
2669 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
2670 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
2673 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
2676 ifeq (%(compiler),target)
2679 BD_INCL_FILES2 := $(subst %(dir),%(includedir)/%(path),$(dir %(includes)))
2680 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,$(notdir %(includes)))
2682 BD_INCL_FILES2 := $(addprefix %(includedir)/%(path)/,%(includes))
2685 BD_INCL_FILES += $(BD_INCL_FILES2)
2687 $(BD_INCL_FILES2) : %(includedir)/%(path)/% : $(BD_INC_PATH)%
2692 %(mmake) : $(BD_INCL_FILES)
2696 $(BD_INCL_FILES) : | $(dir $(BD_INCL_FILES))
2697 GLOB_MKDIRS += $(dir $(BD_INCL_FILES))
2699 #------------------------------------------------------------------------------
2702 #------------------------------------------------------------------------------
2703 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
2704 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
2705 STUBS_MEM := $(addsuffix .o,$(STUBS))
2706 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
2707 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
2708 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
2710 #MM- linklibs : hidd-%(hidd)-stubs
2711 #MM- %(parenttarget): hidd-%(hidd)-stubs
2712 #MM hidd-%(hidd)-stubs : includes includes-copy
2713 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
2715 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
2718 $(STUBS_OBJ) : $(STUBS_SRC)
2719 %compile_q cmd="$(TARGET_CC) $(TARGET_SYSROOT)" opt="%(cflags)" iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
2721 $(STUBS_DEP) : $(STUBS_SRC)
2722 %mkdepend_q flags="%(dflags)"
2725 %mkdirs_q $(OBJDIR) $(AROS_LIB)
2729 -@$(RM) $(HIDD_LIB) $(OBJDIR)
2731 DEPS := $(DEPS) $(STUBS_DEP)
2734 #------------------------------------------------------------------------------
2737 #------------------------------------------------------------------------------
2738 # Build an imported source tree which uses the configure script from the
2739 # autoconf package. This rule will try to "integrate" the produced files as
2740 # much as possible in the AROS build, for example by putting libraries in the
2741 # standard library directory, includes in the standard include directory, and
2742 # so on. You can however override this behaviour.
2744 # As a special "bonus" for you, the PROGDIR environment variable is defined to
2745 # be %(bindir) (or its deduced value) when running "make install", and
2746 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
2747 # configure script some more parameters whose value depends upon the PROGDIR
2748 # env var, so that the program gets all its stuff installed in the proper place
2749 # when building it, but when running it from inside AROS it can also find that
2750 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
2751 # the configuration parameters set when running ./configure
2753 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
2754 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
2755 # to the name which has to follow it.
2759 # - mmake = the meta make target.
2760 # - package = name of the package to be built.
2761 # - srcdir = the location of the unpacked source code. Defaults
2762 # to $(SRCDIR)/$(CURDIR).
2763 # - prefix = the target directory. Must be an absolute path of the
2764 # host system. Defaults to $(AROS_CONTRIB).
2765 # - aros_prefix = set a path which is valid within the AROS filesystem.
2766 # Defaults to the value of the prefix option.
2767 # - extraoptions = additional options for the configure script.
2768 # - extracflags = additional flags to use with the C compiler.
2769 # - extracxxflags = additional flags to use with the C++ compiler.
2770 # - nix_dir_layout = if yes the binary will be stored in a bin subdirectory.
2771 # Defaults to the value of the nix argument.
2772 # - nix = enable u*nix path handling, i.e. a path like
2773 # /progdir//./file will be translated to
2774 # progdir:file during run-time. Defaults to no.
2775 # - compiler = target, host or kernel. Defaults to target.
2776 # - install_target = the command used for installing. Defaults to install. Leave
2777 # it empty if you want to suppress installing.
2778 # - preconfigure = a metatarget which is executed before configure is called.
2779 # - postconfigure = a metatarget which is executed after configure is called.
2780 # - postinstall = a metatarget which is executed after installing.
2781 # - install_env = set additional options for installing.
2782 # - use_build_env = if yes the configuration environment is used for
2783 # installing, too. Defaults to no.
2785 # The arguments aros_prefix, nix and nix_dir_layout are related. The logic is
2789 # --prefix = $(aros_prefix)
2790 # progdir = $(aros_prefix)/bin
2793 # --prefix = /PROGDIR
2794 # --bindir = /PROGDIR
2795 # --sbindir = /PROGDIR
2797 # --includedir = /INCLUDE
2798 # --oldincludedir = /INCLUDE
2800 # --prefix = $(aros_prefix)
2803 # progdir = $(aros_prefix)
2806 # bindir = $(prefix)
2807 # sbindir = $(prefix)
2808 # libdir = $(AROS_LIB)
2809 # includedir = $(AROS_INCLUDES)
2810 # oldincludedir = $(AROS_INCLUDES)
2814 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) \
2815 prefix= gendir= basedir=$(CURDIR) extraoptions= \
2816 extracflags="$(OPTIMIZATION_CFLAGS)" extracxxflags="$(OPTIMIZATION_CFLAGS)" \
2817 aros_prefix= nix_dir_layout= nix=no compiler=target crossbuild=no \
2818 install_target=install preconfigure= postconfigure= postinstall= \
2819 config_env_extra= install_env= use_build_env=no buildflags=yes gnuflags=yes
2822 %(mmake)-prefix := %(prefix)
2824 %(mmake)-prefix := $(AROS_CONTRIB)
2827 ifneq (%(aros_prefix),)
2828 %(mmake)-aros_prefix := %(aros_prefix)
2830 %(mmake)-aros_prefix := $(%(mmake)-prefix)
2836 %(mmake)-nix := $(BD_NIXFLAG)
2837 %(mmake)-volpfx := /
2838 %(mmake)-volsfx := /
2840 ifeq (%(nix_dir_layout),)
2841 %(mmake)-nix_dir_layout := yes
2844 %(mmake)-volsfx := :
2846 ifeq (%(nix_dir_layout),)
2847 %(mmake)-nix_dir_layout := no
2851 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
2853 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
2854 exec_prefix=$(%(mmake)-prefix) %(install_env)
2856 # Check if chosen compiler is valid
2857 ifeq ($(findstring %(compiler),host target kernel),)
2858 $(error unknown compiler %(compiler))
2861 # Set legacy 'host' variable based on chosen compiler
2862 ifeq (%(compiler),host)
2865 %(mmake)-pkgbasedir := $(HOSTGENDIR)
2867 %(mmake)-pkgbasedir := $(HOSTGENDIR)/%(basedir)
2872 %(mmake)-pkgbasedir := $(GENDIR)
2874 %(mmake)-pkgbasedir := $(GENDIR)/%(basedir)
2879 %(mmake)-pkgbasedir := %(gendir)
2881 %(mmake)-pkgbasedir := %(gendir)/%(basedir)
2886 %(mmake)-pkgdir := $(%(mmake)-pkgbasedir)
2888 %(mmake)-pkgdir := $(%(mmake)-pkgbasedir)/%(package)
2891 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
2892 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
2894 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
2895 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)/bin
2896 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2899 %(mmake)-config_opts := --prefix=/PROGDIR --bindir=/PROGDIR --sbindir=/PROGDIR \
2900 --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE
2902 %(mmake)-config_opts := --prefix=$(%(mmake)-aros_prefix)
2905 %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
2907 %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
2908 sbindir=$(%(mmake)-prefix) \
2909 libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
2910 oldincludedir=$(AROS_INCLUDES) %(install_env)
2913 ifneq ($(DEBUG),yes)
2914 %(mmake)-s_flag = -s
2917 # Set up build environment, and options for configure script
2918 ifeq (%(compiler),host)
2919 # NB: We need to pass in our crosstoolsdir, but cannot set CFLAGS since it
2920 # confused configure scripts. We also cannot pass it via _FOR_BUILD
2921 # since that won't get picked up during configure.
2922 # We also cannot pass in the compiler including std flags so we need to use
2923 # the "plain" host compiler.
2924 %(mmake)-cfg-env := %(config_env_extra) \
2926 CXXCPP="$(HOST_CPP)" \
2927 CC="$(HOST_DEF_CC) $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include" \
2928 CXX="$(HOST_CXX) $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include" \
2929 LDFLAGS="-L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS)" \
2930 TARGET_CC="$(KERNEL_CC) $(KERNEL_SYSROOT)" \
2931 TARGET_CFLAGS="$(KERNEL_CFLAGS) $(%(mmake)-s_flag)" \
2932 TARGET_CXX="$(KERNEL_CXX) $(KERNEL_SYSROOT)" \
2933 TARGET_CXXFLAGS="$(KERNEL_CXXFLAGS) $(%(mmake)-s_flag)" \
2934 TARGET_AS="$(TARGET_AS)" \
2935 OBJCOPY="$(OBJCOPY)" \
2936 TARGET_RANLIB="$(RANLIB)" \
2937 TARGET_STRIP="$(STRIP_PLAIN)" \
2938 TARGET_NM="$(NM_PLAIN)" \
2939 TARGET_OBJCOPY="$(TARGET_OBJCOPY)"
2941 ifeq (%(compiler),target)
2942 %(mmake)-cfg-env := %(config_env_extra) \
2943 PKG_CONFIG_LIBDIR="$(AROS_DEVELOPER)/lib/pkgconfig" \
2944 PKG_CONFIG_SYSROOT_DIR="$(AROSDIR)"
2945 %(mmake)-cfg-env += CPP="$(strip $(TARGET_CPP) $(TARGET_SYSROOT))" \
2946 CXXCPP="$(strip $(TARGET_CPP) $(TARGET_SYSROOT))" \
2947 CC="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
2948 CXX="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
2949 LD="$(strip $(TARGET_LD))"
2950 ifeq (%(crossbuild),yes)
2951 %(mmake)-cfg-env += CFLAGS="$(strip $(ISA_FLAGS) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) %(extracflags) $(%(mmake)-s_flag))" \
2952 CXXFLAGS="$(strip $(ISA_FLAGS) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) %(extracxxflags) $(%(mmake)-s_flag))"
2954 %(mmake)-cfg-env += CFLAGS="$(strip $(ISA_FLAGS) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) %(extracflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
2955 CXXFLAGS="$(strip $(ISA_FLAGS) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) %(extracxxflags) $(%(mmake)-nix) $(%(mmake)-s_flag))"
2957 %(mmake)-cfg-env += LDFLAGS="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
2958 CC_FOR_BUILD="$(strip $(HOST_DEF_CC))" \
2959 CFLAGS_FOR_BUILD="$(strip $(HOST_CFLAGS) $(%(mmake)-s_flag))" \
2960 CXX_FOR_BUILD="$(strip $(HOST_CXX))" \
2961 CXXFLAGS_FOR_BUILD="$(strip $(HOST_CXXFLAGS) $(%(mmake)-s_flag))" \
2962 LD_FOR_BUILD="$(strip $(HOST_LD))" \
2963 LDFLAGS_FOR_BUILD="$(strip $(HOST_LDFLAGS) $(%(mmake)-s_flag))" \
2964 CC_FOR_HOST="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
2965 CFLAGS_FOR_HOST="$(strip $(ISA_FLAGS) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) -L$(AROS_DEVELOPER)/lib %(extracflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
2966 CXX_FOR_HOST="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
2967 CXXFLAGS_FOR_HOST="$(strip $(ISA_FLAGS) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) -L$(AROS_DEVELOPER)/lib %(extracxxflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
2968 LD_FOR_HOST="$(strip $(TARGET_LD))" \
2969 LDFLAGS_FOR_HOST="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
2970 CC_FOR_TARGET="$(strip $(TARGET_CC) $(TARGET_SYSROOT))" \
2971 CFLAGS_FOR_TARGET="$(strip $(ISA_FLAGS) $(USER_INCLUDES) $(BASE_CFLAGS) $(USER_CFLAGS) -L$(AROS_DEVELOPER)/lib %(extracflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
2972 CXX_FOR_TARGET="$(strip $(TARGET_CXX) $(TARGET_SYSROOT))" \
2973 CXXFLAGS_FOR_TARGET="$(strip $(ISA_FLAGS) $(USER_INCLUDES) $(BASE_CXXFLAGS) $(USER_CXXFLAGS) -L$(AROS_DEVELOPER)/lib %(extracxxflags) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
2974 LD_FOR_TARGET="$(strip $(TARGET_LD))" \
2975 LDFLAGS_FOR_TARGET="$(strip -L$(AROS_DEVELOPER)/lib $(USER_LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag))" \
2976 AR="$(strip $(AR_PLAIN))" \
2977 AS="$(strip $(TARGET_AS))" \
2978 OBJCOPY="$(strip $(OBJCOPY))" \
2979 RANLIB="$(strip $(RANLIB))" \
2980 STRIP="$(strip $(STRIP_PLAIN))" \
2981 TARGET_CC="$(strip $(KERNEL_CC) $(KERNEL_SYSROOT))" \
2982 TARGET_CFLAGS="$(strip $(KERNEL_CFLAGS) $(%(mmake)-s_flag))" \
2983 TARGET_CXX="$(strip $(KERNEL_CXX) $(KERNEL_SYSROOT))" \
2984 TARGET_CXXFLAGS="$(strip $(KERNEL_CXXFLAGS) $(%(mmake)-s_flag))" \
2985 TARGET_AS="$(strip $(TARGET_AS))" \
2986 TARGET_RANLIB="$(strip $(RANLIB))" \
2987 TARGET_STRIP="$(strip $(STRIP_PLAIN))" \
2988 TARGET_NM="$(strip $(NM_PLAIN))"
2989 ifeq (%(buildflags),yes)
2990 %(mmake)-config_opts += --target=$(AROS_TARGET_CPU)-aros
2991 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)
2992 %(mmake)-config_opts += --host=$(AROS_TARGET_CPU)-aros
2994 ifeq (%(gnuflags),yes)
2995 %(mmake)-config_opts += --without-pic --disable-shared
2996 %(mmake)-config_opts += --disable-nls --without-x
2999 ifeq (%(compiler),kernel)
3000 %(mmake)-cfg-env := %(config_env_extra) \
3001 CPP="$(KERNEL_CPP)" \
3002 CXXCPP="$(KERNEL_CPP)" \
3003 CC="$(KERNEL_CC) $(KERNEL_SYSROOT)" \
3004 CFLAGS="$(KERNEL_CFLAGS) %(extracflags) $(%(mmake)-s_flag)" \
3005 CXX="$(KERNEL_CXX) $(KERNEL_SYSROOT)" \
3006 CXXFLAGS="$(KERNEL_CXXFLAGS) %(extracxxflags) $(%(mmake)-s_flag)" \
3008 CC_FOR_BUILD="$(HOST_DEF_CC)" \
3009 CFLAGS_FOR_BUILD="$(HOST_CFLAGS)" \
3010 CXX_FOR_BUILD="$(HOST_CXX)" \
3011 CXXFLAGS_FOR_BUILD="$(HOST_CXXFLAGS)" \
3012 RANLIB="$(RANLIB)" \
3013 TARGET_RANLIB="$(RANLIB)" \
3014 TARGET_STRIP="$(STRIP_PLAIN)" \
3015 TARGET_NM="$(NM_PLAIN)"
3016 ifeq (%(buildflags),yes)
3017 %(mmake)-config_opts += --target=$(AROS_TARGET_CPU)-aros
3018 %(mmake)-config_opts += --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH)
3019 %(mmake)-config_opts += --host=$(AROS_TARGET_CPU)-aros
3021 ifeq (%(gnuflags),yes)
3022 %(mmake)-config_opts += --without-pic --disable-shared
3023 %(mmake)-config_opts += --disable-nls --without-x
3027 ifeq (%(use_build_env),yes)
3028 BUILD_ENV := $(%(mmake)-cfg-env)
3031 ifneq ("$(wildcard %(srcdir)/Makefile)","")
3032 # in an ideal world, we would depend on the files in the source directory,
3033 # so we could copy them when they change. unfortunately filenames with
3034 # spaces causes problems with this
3035 $(%(mmake)-pkgdir)/.local-copy:
3036 %mkdirs_q $(%(mmake)-pkgdir)
3037 @$(ECHO) "Copying Local-Build Sources to \`$(patsubst $(TOP)/%,%,$(abspath $(%(mmake)-pkgdir)))'"
3038 @$(CP) -Rf "%(srcdir)/." $(%(mmake)-pkgdir)/ && $(TOUCH) $@
3040 $(%(mmake)-pkgdir)/.files-touched : $(%(mmake)-pkgdir)/.local-copy
3042 %(mmake)-cfg-srcdir=$(%(mmake)-pkgdir)
3044 %(mmake)-cfg-srcdir=%(srcdir)
3046 %(mmake)-make-env := -C $(%(mmake)-pkgdir)
3048 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3050 # When building for the host, we don't need to build the
3051 # linklibs - this is especially true when building the
3052 # crosstool toolchain on 'foreign' architectures (such as
3053 # building PPC on x86)
3055 #MM- %(mmake)-host : setup includes %(mmake)-quick
3056 #MM- %(mmake)-target : setup includes core-linklibs %(mmake)-quick
3057 #MM- %(mmake): %(mmake)-%(compiler)
3059 # Using -j1 in install_command may result in a warning but finally
3060 # it does its job. make install for gcc does not work reliably for -jN
3062 ifneq (%(install_target),)
3063 %(mmake)-install_command = \
3064 $(ECHO) "Installing from build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))" && \
3065 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
3066 $(%(mmake)-make-env) %(install_target) -j1
3068 %(mmake)-uninstall_command = \
3069 $(RM) $(%(mmake)-installflag) && \
3070 $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" \
3071 $(%(mmake)-install_opts) $(%(mmake)-make-env) uninstall
3073 %(mmake)-install_command := true
3074 %(mmake)-uninstall_command := true
3077 #MM- %(mmake)-quick : %(preconfigure) %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
3080 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3083 # NB : the make test for the targets being upto date generates a benign Error 1.
3085 $(%(mmake)-installflag) : $(%(mmake)-configflag)
3086 @$(IF) ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q $(%(mmake)-make-env); then \
3087 $(RM) $(%(mmake)-installflag) && \
3088 $(ECHO) "Performing build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))" && \
3089 $(BUILD_ENV) $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" $(%(mmake)-make-env) && \
3090 $(%(mmake)-install_command) && \
3091 $(TOUCH) $@ -r $^; \
3094 $(%(mmake)-pkgdir)/.files-touched:
3095 %mkdirs_q $(%(mmake)-pkgdir)
3096 @find %(srcdir) -exec $(TOUCH) -c -r $(%(mmake)-cfg-srcdir)/configure '{}' \; && \
3100 %(mmake)-uninstall :
3101 $(%(mmake)-uninstall_command)
3104 %(mmake)-configure : $(%(mmake)-configflag)
3106 $(%(mmake)-configflag) : TMP_SRCDIR := $(shell echo $(%(mmake)-cfg-srcdir) | sed 's/^\(.\):\//\/\1\//')
3107 $(%(mmake)-configflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
3109 %mkdirs_q $(%(mmake)-pkgdir)
3110 @$(ECHO) "Configuring build in $(subst $(TOP)/,,$(%(mmake)-pkgdir))"
3111 @cd $(%(mmake)-pkgdir) && \
3112 find . -name config.cache -exec $(RM) '{}' \; && \
3113 $(%(mmake)-cfg-env) $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) %(extraoptions) && \
3117 %(mmake)-clean : %(mmake)-uninstall
3118 @$(RM) $(%(mmake)-pkgdir)
3120 #------------------------------------------------------------------------------
3123 #------------------------------------------------------------------------------
3124 # Build an imported source tree which uses cmake
3128 # - mmake = the meta make target.
3129 # - package = name of the package to be built.
3130 # - srcdir = the location of the unpacked source code. Defaults
3131 # to $(SRCDIR)/$(CURDIR).
3132 # - prefix = the target directory. Must be an absolute path of the
3133 # host system. Defaults to $(AROS_CONTRIB).
3134 # - aros_prefix = set a path which is valid within the AROS filesystem.
3135 # Defaults to the value of the prefix option.
3136 # - extraoptions = additional options for the cmake script.
3137 # - installoptions = additional options for the install step.
3140 %define build_with_cmake mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) gendir= prefix= \
3141 aros_prefix= extraoptions= installoptions= maketarget= compiler=target \
3142 cflags=$(CFLAGS) cxxflags=$(CXXFLAGS) ldflags=$(LDFLAGS)
3145 %(mmake)-prefix := %(prefix)
3147 %(mmake)-prefix := $(AROS_CONTRIB)
3150 ifneq (%(aros_prefix),)
3151 %(mmake)-aros_prefix := %(aros_prefix)
3153 %(mmake)-aros_prefix := $(%(mmake)-prefix)
3156 ifeq (%(compiler),host)
3157 BD_LDFLAGS := -L$(CROSSTOOLSDIR)/lib $(USER_LDFLAGS)
3158 BD_CFLAGS := $(HOST_CFLAGS) -I$(CROSSTOOLSDIR)/include
3159 BD_CXXFLAGS := $(HOST_CXXFLAGS) -I$(CROSSTOOLSDIR)/include
3160 %(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)"
3162 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
3164 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
3167 BD_LDFLAGS := %(ldflags)
3168 BD_CFLAGS := %(cflags)
3169 BD_CXXFLAGS := %(cxxflags)
3170 %(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)"
3172 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
3174 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
3179 %(mmake)-pkgdir := %(gendir)/$(CURDIR)
3181 %(mmake)-pkgdir := %(gendir)/$(CURDIR)/%(package)
3185 %(mmake)-cmakeflag := $(%(mmake)-pkgdir)/.cmake
3186 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
3188 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
3190 #MM- %(mmake): setup includes core-linklibs %(mmake)-quick
3192 #MM- %(mmake)-quick : %(mmake)-cmake %(mmake)-build_and_install-quick
3195 %(mmake)-build_and_install-quick : $(%(mmake)-installflag)
3197 $(%(mmake)-installflag) : $(%(mmake)-cmakeflag)
3198 $(IF) ! $(MAKE) -q -C $(%(mmake)-pkgdir); then \
3199 $(RM) $(%(mmake)-installflag) && \
3200 $(MAKE) -C $(%(mmake)-pkgdir) %(maketarget) && \
3201 cd $(%(mmake)-pkgdir) && \
3202 cmake %(installoptions) -P cmake_install.cmake && \
3203 $(TOUCH) $@ -r $^; \
3206 $(%(mmake)-pkgdir)/.files-touched:
3207 %mkdirs_q $(%(mmake)-pkgdir)
3208 find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/CMakeLists.txt '{}' \; && \
3212 %(mmake)-cmake : $(%(mmake)-cmakeflag)
3214 $(%(mmake)-cmakeflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
3215 $(%(mmake)-cmakeflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
3217 %mkdirs_q $(%(mmake)-pkgdir)
3218 cd $(%(mmake)-pkgdir) && \
3219 $(RM) -Rf CMakeCache.txt CMakeFiles \; && \
3220 cmake $(%(mmake)-cmake_opts) %(extraoptions) $(TMP_SRCDIR) && \
3224 %(mmake)-clean : %(mmake)-uninstall
3225 @$(RM) $(%(mmake)-pkgdir)
3227 #------------------------------------------------------------------------------
3230 #------------------------------------------------------------------------------
3231 # Given an archive name, patches names and locations where to find them, fetch
3232 # the archive and the patches from any of those locations, unpack the archive
3233 # and then apply the patches.
3235 # Locations currently supported are http and ftp sites, plus local filesystem
3236 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
3237 # the fetch.sh script needs to be modified, since this macro relies on that script.
3241 # - mmake = mmaketarget
3242 # - archive_origins = list of locations where to find the archive. They are tried
3243 # in sequence, until the archive is found and fetching it
3244 # succeeded. If not specified, the current directory is assumed.
3245 # - archive = the archive name. Mandatory.
3246 # - suffixes = a list of suffixes to append to the the package name plus the
3247 # version. Each one of them is tried until a matching archive is
3248 # found. They are appended to patches and these are tried the
3249 # same way as packages are.
3250 # - location = the local directory where to put the fetched archive and patches.
3251 # If not specified, the directory specified by destination is used.
3252 # - destination = the directory to unpack the archive to.
3253 # If not specified, the current directory is assumed.
3254 # - patches_origins = list of locations where to find the patches. They are tried
3255 # in sequence, until a patch is found and fetching it
3256 # succeeded. If not specified, the current directory is assumed.
3257 # - patches_specs = list of "patch specs". A patch spec is of the form
3258 # patch_name[:[patch_subdir][:patch_opt]].
3260 # - patch_name = the name of the patch file
3261 # - patch_subdir = the directory within \destination\ where to
3263 # - patch_opt = any options to pass to the `patch' command
3264 # when applying the patch.
3266 # The patch_subdir and patch_opt fields are optional.
3268 %define fetch mmake=/A archive_origins=. archive=/A suffixes= location= destination=. \
3269 patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
3273 ifneq (%(location),)
3274 %(mmake)-location := %(location)
3276 %(mmake)-location := %(destination)
3281 $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
3282 -d %(destination) -po "%(patches_origins)" -p "%(patches_specs)"
3284 #------------------------------------------------------------------------------
3287 #------------------------------------------------------------------------------
3288 # This macro can aid in patch creation for fetched ports. It temporarily creates another
3289 # unpatched source tree and runs diff against this and a previously fetched and possibly
3290 # patched tree. Depending on what happens after patching during a normal build it might
3291 # give best results if the new patch is created directly after fetch.
3295 # - mmake = mmaketarget
3296 # - archive = archive base name
3297 # - srcdir = the top level directory the package is unpacked to, useful if
3298 # an archive unpacks to a directory other than its name suggests.
3299 # this should not be deeper than a single path element.
3300 # - suffixes = a list of suffixes to append to the the package name plus the
3301 # version. Each one of them is tried until a matching archive is
3303 # - destination = the directory to unpack the archive to.
3304 # - excludes = diff patterns to exclude files or directories from the patch
3306 %define create_patch mmake=/A archive=/A srcdir= suffixes="tar.bz2 tar.gz" destination=/A excludes=
3310 ifneq (%(excludes),)
3311 %(mmake)-exclude := -X ./exclude.patterns
3315 %(mmake)-srcdir := %(srcdir)
3317 %(mmake)-srcdir := %(archive)
3320 #MM- %(mmake) : %(mmake)-diff
3321 #MM- %(mmake)-quick : %(mmake)-diff
3325 @$(FETCH) -a %(archive) -s "%(suffixes)" -l $(PORTSSOURCEDIR) -d %(destination)/tmp ; \
3326 $(MV) %(destination)/$(%(mmake)-srcdir) %(destination)/tmp/$(%(mmake)-srcdir).aros ; \
3327 cd %(destination)/tmp ; \
3328 $(FOR) f in %(excludes) ; do \
3329 $(ECHO) $$f >> ./exclude.patterns ; \
3331 diff -ruN $(%(mmake)-exclude) \
3332 $(%(mmake)-srcdir) \
3333 $(%(mmake)-srcdir).aros \
3334 >$(SRCDIR)/$(CURDIR)/%(archive)-aros-new.diff ; \
3335 $(MV) %(destination)/tmp/$(%(mmake)-srcdir).aros %(destination)/$(%(mmake)-srcdir) ; \
3336 $(RM) %(destination)/tmp
3338 #------------------------------------------------------------------------------
3341 #------------------------------------------------------------------------------
3342 # Joins the features of %fetch and %build_with_configure.
3344 # If a patch is provided, it *must* be named the following way:
3346 # <package name>-<version number>-aros.diff
3348 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3349 # CD'ing into the archive's extracted directory.
3351 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3352 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3353 # to make that patch fully comprehensive.
3357 # - mmake = the meta make target.
3358 # - package = the GNU package name, sans version and archive format suffixes.
3359 # - subpackage = ???
3360 # - compiler = same meaning as the one for the %build_with_configure macro.
3361 # - install_target = same meaning as the one for the %build_with_configure macro.
3362 # - version = the package's version number, or otherwise any other version string.
3363 # It gets appended to the package name to form the basename of the archive.
3364 # - suffixes = a list of suffixes to apped to the the package name plus the
3365 # version. Each one of them is tried until a matching archive is found.
3366 # Defaults to "tar.bz2 tar.gz".
3367 # - srcdir = the top level directory the package is unpacked to (see create_patch).
3368 # - builddir = override the location we expect to run configure/make in.
3369 # - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
3370 # - patch = "yes" or "no", depending on whether a patch for this package needs to be
3371 # fetched or not. Default to no.
3372 # - patch_repo = same meaning as the one of the %fetch macro's %(patches_origins) argument
3373 # - prefix = same meaning as the one for the %build_with_configure macro.
3374 # - aros_prefix = same meaning as the one for the %build_with_configure macro.
3375 # - extraoptions = same meaning as the one for the %build_with_configure macro.
3376 # - extracflags = same meaning as the one for the %build_with_configure macro.
3377 # - extracxxflags = same meaning as the one for the %build_with_configure macro.
3378 # - preconfigure = same meaning as the one for the %build_with_configure macro.
3379 # - postconfigure = same meaning as the one for the %build_with_configure macro.
3380 # - postinstall = same meaning as the one for the %build_with_configure macro.
3381 # - install_env = same meaning as the one for the %build_with_configure macro.
3382 # - use_build_env = same meaning as the one for the %build_with_configure macro.
3383 # - nix = same meaning as the one for the %build_with_configure macro.
3384 # - nix_dir_layout = same meaning as the one for the %build_with_configure macro.
3385 # - create_pkg = create a distributable package of the compiled sources, defaults to no
3387 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target crossbuild=no install_target=install \
3388 version=/A suffixes="tar.bz2 tar.gz" srcdir= builddir= gendir= basedir=$(CURDIR) package_repo= patch=no patch_repo= \
3389 prefix= aros_prefix= preconfigure= postconfigure= postinstall= \
3390 extraoptions= extracflags="$(OPTIMIZATION_CFLAGS)" extracxxflags="$(OPTIMIZATION_CFLAGS)" \
3391 config_env_extra= install_env= use_build_env=no nix=no nix_dir_layout= create_pkg=no buildflags=yes gnuflags=yes
3393 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
3394 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
3395 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
3396 #MM- %(mmake)-create-patch : %(mmake)-%(subpackage)-create-patch
3398 %(mmake)-archbase := %(package)-%(version)
3400 ifeq (%(compiler),host)
3401 %(mmake)-portdir := $(HOSTDIR)/Ports/host/%(package)
3403 %(mmake)-portdir := $(PORTSDIR)/%(package)
3407 %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
3409 %(mmake)-prefix := %(prefix)
3412 ifneq (%(subpackage),)
3413 %(mmake)-%(subpackage)-archbase := %(package)-%(subpackage)-%(version)
3415 %(mmake)-%(subpackage)-archbase := %(package)-%(version)
3419 %(mmake)-%(subpackage)-srcdir := %(srcdir)
3421 %(mmake)-%(subpackage)-srcdir := $(%(mmake)-archbase)
3424 ifneq (%(builddir),)
3425 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)/%(builddir)
3427 %(mmake)-%(subpackage)-builddir := $(%(mmake)-%(subpackage)-srcdir)
3431 %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-f,-p1
3433 %(mmake)-%(subpackage)-patches_specs := ::
3436 %fetch mmake="%(mmake)-%(subpackage)-fetch" archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
3437 location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
3438 archive_origins=". %(package_repo)" \
3439 patches_specs=$(%(mmake)-%(subpackage)-patches_specs) patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
3441 %create_patch mmake="%(mmake)-%(subpackage)-create-patch" \
3442 archive=$(%(mmake)-%(subpackage)-archbase) \
3443 srcdir=$(%(mmake)-%(subpackage)-srcdir) \
3444 suffixes="%(suffixes)" \
3445 destination=$(%(mmake)-portdir)
3447 #MM- %(mmake) : %(mmake)-%(subpackage)
3449 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
3451 %(mmake)-%(subpackage)-package-basename := \
3452 $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
3454 ifneq (%(create_pkg),no)
3455 %(mmake)-%(subpackage)-package := $(%(mmake)-%(subpackage)-package-basename).tar.bz2
3458 %build_with_configure mmake="%(mmake)-%(subpackage)" package="%(package)" compiler="%(compiler)" crossbuild="%(crossbuild)" install_target="%(install_target)" \
3459 srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-builddir) gendir="%(gendir)" basedir="%(basedir)" \
3460 config_env_extra="%(config_env_extra)" install_env="%(install_env)" use_build_env="%(use_build_env)" \
3461 nix="%(nix)" nix_dir_layout="%(nix_dir_layout)" prefix=$(%(mmake)-prefix) \
3462 aros_prefix="%(aros_prefix)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
3463 %(mmake)-%(subpackage)-make-package" extraoptions="%(extraoptions)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)" buildflags=%(buildflags) gnuflags=%(gnuflags)
3465 .PHONY : %(mmake)-%(subpackage)-make-package %(mmake)-%(subpackage)-create-patch
3466 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
3469 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package)
3471 #There seems to be a bug, either with my clock or with make, 'cause it may happen
3472 #that $^ and $@ have exactly the same mtime, and in that case make tries
3473 #to rebuild $@ again, which would fail because the directory where
3474 #the package got installed would not exist anymore.
3475 #We work this around by using an if statement to manually check the mtimes.
3476 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
3477 @$(IF) $(TEST) $(%(mmake)-installflag) -nt $@ || ! $(TEST) -f $@; then \
3479 $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
3480 $(MKDIR) -p "$(DISTDIR)/Packages" ; \
3481 $(MKDIR) -p "$(%(mmake)-prefix)" ; \
3482 cd $(%(mmake)-%(subpackage)-package-dir) ; \
3483 tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
3484 bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
3487 #------------------------------------------------------------------------------
3490 #------------------------------------------------------------------------------
3491 # Joins the features of %fetch and %build_with_configure, taking advantage of
3492 # the naming scheme of GNU packages. GNU packages names are in the form
3494 # <package name>-<version number>.<archive format suffix>
3496 # If a patch is provided, it *must* be named the following way:
3498 # <package name>-<version number>-aros.diff
3500 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
3501 # CD'ing into the archive's extracted directory.
3503 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
3504 # the %fetch_and_build macro only accepts *one* patch for each package. It's up to you
3505 # to make that patch fully comprehensive.
3507 # NOTE: GNU packages are always compiled with *nix semantics turned on.
3511 # Arguments have the same meaning as the one for the %fetch_and_build macro, except:
3513 # - prefix = defaults to $(GNUDIR).
3514 # - aros_prefix = defaults to /GNU.
3516 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A crossbuild=no suffixes="tar.bz2 tar.gz" \
3517 srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
3518 aros_prefix=/GNU config_env_extra= preconfigure= postconfigure= postinstall= nix=yes \
3519 extraoptions= extracflags="$(OPTIMIZATION_CFLAGS)" extracxxflags="$(OPTIMIZATION_CFLAGS)"
3521 GNU_REPOSITORY := gnu://
3523 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
3524 crossbuild="%(crossbuild)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
3525 package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
3526 patch="%(patch)" patch_repo="%(patch_repo)" \
3527 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)" \
3528 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=%(nix)
3531 #------------------------------------------------------------------------------
3534 #------------------------------------------------------------------------------
3535 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
3536 # that the package is a "Developer" package, and as such it needs to be placed
3537 # under the $(AROS_DEVELOPER) directory, as a default.
3539 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu
3540 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
3541 # "mmake" argument, because the metatarget is implicitely defined as
3543 # #MM- development-%(package)
3545 %define fetch_and_build_gnu_development package=/A subpackage= version=/A crossbuild=no suffixes="tar.bz2 tar.gz" \
3546 srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPER) \
3547 aros_prefix=/Developer config_env_extra= preconfigure= postconfigure= postinstall= nix=yes \
3548 extraoptions= extracflags="$(OPTIMIZATION_CFLAGS)" extracxxflags="$(OPTIMIZATION_CFLAGS)"
3550 #MM- development : development-%(package)
3553 %fetch_and_build_gnu mmake="development-%(package)" package="%(package)" subpackage="%(subpackage)" \
3554 version="%(version)" crossbuild="%(crossbuild)" suffixes="%(suffixes)" srcdir="%(srcdir)" \
3555 package_repo="%(package_repo)" \
3556 patch="%(patch)" patch_repo="%(patch_repo)" \
3557 prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" extracflags="%(extracflags)" extracxxflags="%(extracxxflags)" \
3558 config_env_extra="%(config_env_extra)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="postinstall-%(package)-delete-la-files %(postinstall)" nix=%(nix)
3561 postinstall-%(package)-delete-la-files:
3562 $(RM) %(prefix)/lib/*.la
3565 #------------------------------------------------------------------------------
3567 # Builds a kickstart package in PKG format
3571 # - mmake = target name
3572 # - file = destination file name with path
3574 # Other arguments are self-explanatory
3576 %define make_package mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
3577 arch_classes= arch_devs= arch_handlers= arch_hidds= arch_libs= arch_res=
3579 PKG_CLASSES := $(addprefix $(AROS_CLASSES)/,$(addsuffix .class, %(classes)))
3580 PKG_DEVICES := $(addprefix $(AROS_DEVS)/,$(addsuffix .device, %(devs)))
3581 PKG_HANDLERS := $(addprefix $(AROS_FS)/,$(addsuffix -handler, %(handlers)))
3582 PKG_HIDD := $(addprefix $(AROS_DEVS)/Drivers/,$(addsuffix .hidd, %(hidds)))
3583 PKG_LIBS := $(addprefix $(AROS_LIBRARIES)/,$(addsuffix .library, %(libs)))
3584 PKG_RESOURCES := $(addprefix $(AROS_DEVS)/,$(addsuffix .resource, %(res)))
3586 PKG_CLASSES_ARCH := $(addprefix $(AROS_CLASSES_ARCH)/,$(addsuffix .class, %(arch_classes)))
3587 PKG_DEVICES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .device, %(arch_devs)))
3588 PKG_HANDLERS_ARCH := $(addprefix $(AROS_FS_ARCH)/,$(addsuffix -handler, %(arch_handlers)))
3589 PKG_HIDD_ARCH := $(addprefix $(AROS_DEVS_ARCH)/Drivers/,$(addsuffix .hidd, %(arch_hidds)))
3590 PKG_LIBRARIES_ARCH := $(addprefix $(AROS_LIBRARIES_ARCH)/,$(addsuffix .library, %(arch_libs)))
3591 PKG_RESOURCES_ARCH := $(addprefix $(AROS_DEVS_ARCH)/,$(addsuffix .resource, %(arch_res)))
3593 PKG_FILES := $(PKG_CLASSES) $(PKG_DEVICES) $(PKG_HANDLERS) $(PKG_HIDD) $(PKG_LIBS) $(PKG_RESOURCES) \
3594 $(PKG_CLASSES_ARCH) $(PKG_DEVICES_ARCH) $(PKG_HANDLERS_ARCH) $(PKG_HIDD_ARCH) $(PKG_LIBRARIES_ARCH) $(PKG_RESOURCES_ARCH)
3595 PKG_DIR := $(dir %(file))
3601 %(mmake)-quick : %(file)
3603 %(file): $(PKG_FILES) | $(PKG_DIR)
3604 @$(ECHO) Packaging $@...
3605 @$(SRCDIR)/tools/package/pkg c $@ $^
3607 %compress_file mmake="%(mmake)" file="%(file)"
3609 GLOB_MKDIRS += $(PKG_DIR)
3613 #------------------------------------------------------------------------------
3614 # Compresses %(file) with a gzip.
3615 # Good in conjunction with for example %build_prog
3617 %define compress_file mmake=/A file=/A
3619 #MM- %(mmake)-gz : %(mmake) %(mmake)-gz-quick
3622 %(mmake)-gz-quick : %(file).gz
3625 @$(ECHO) Compressing $(subst $(TARGETDIR)/,,$^)...
3630 #------------------------------------------------------------------------------
3631 # Links a kickstart module in ELF format
3632 # Arguments are similar to make_package
3634 %define link_kickstart mmake=/A file=/A classes= devs= handlers= hidds= libs= res= \
3635 startup= uselibs= ldflags=$(LDFLAGS) map= deps=
3637 KOBJ_CLASSES := $(addprefix $(KOBJSDIR)/, $(addsuffix _class.o, %(classes)))
3638 KOBJ_DEVICES := $(addprefix $(KOBJSDIR)/, $(addsuffix _device.o, %(devs)))
3639 KOBJ_HANDLERS := $(addprefix $(KOBJSDIR)/, $(addsuffix _handler.o, %(handlers)))
3640 KOBJ_HIDD := $(addprefix $(KOBJSDIR)/, $(addsuffix _hidd.o, %(hidds)))
3641 KOBJ_LIBS := $(addprefix $(KOBJSDIR)/, $(addsuffix _library.o, %(libs)))
3642 KOBJ_RES := $(addprefix $(KOBJSDIR)/, $(addsuffix _resource.o, %(res)))
3645 KOBJ_STARTUP := $(GENDIR)/$(RESIDENT_BEGIN).o
3647 KOBJ_STARTUP := %(startup)
3650 KOBJS := $(KOBJ_STARTUP) $(KOBJ_CLASSES) $(KOBJ_HANDLERS) $(KOBJ_LIBS) $(KOBJ_DEVICES) $(KOBJ_HIDD) $(KOBJ_RES)
3652 TMP_LDFLAGS := %(ldflags)
3654 # Make a list of the lib files this program depends on.
3655 # In LDFLAGS remove white space between -L and directory
3656 TMP_DIRS := $(subst -L ,-L,$(strip $(TMP_LDFLAGS)))
3657 # Filter out only the libdirs and remove -L
3658 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
3660 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
3661 # Add normal linklib path
3662 TMP_DIRS += $(AROS_LIB)/
3663 # add lib and .a to static linklib names
3664 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs)))
3665 # search for the linklibs in the given path, ignore ones not found
3666 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
3667 $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
3670 TMP_DIRS += $(dir %(file))
3672 TMP_LDFLAGS += $(GENMAP) %(map)
3673 TMP_DIRS += $(dir %(map))
3676 #MM %(mmake) : %(deps)
3682 %(mmake)-quick : %(file)
3684 %(file): KOBJS := $(KOBJS)
3685 %(file): LDFLAGS := $(TMP_LDFLAGS) $(NOSTARTUP_LDFLAGS) \
3686 -static -nosysbase -Wl,-Ur
3687 %(file): LDLIBS := $(addprefix -l, %(uselibs))
3688 %(file): $(KOBJS) $(DEPLIBS) | $(TMP_DIRS)
3689 @$(ECHO) "Kickstart $(subst $(TARGETDIR)/,,$@)..."
3690 @$(TARGET_CC) $(TARGET_SYSROOT) -o $@ $(KOBJS) $(LDFLAGS) $(LDLIBS)
3692 @$(STRIP) $@ --only-keep-debug -o $@.dbg
3696 %compress_file mmake="%(mmake)" file="%(file)"
3698 GLOB_MKDIRS += $(TMP_DIRS)