New mmake target for easy patch creation out of downloaded ports sources.
[AROS.git] / config / make.tmpl
blob668bc3032fdebd7b320eb47105dccefd273b3ac2
1 #############################################################################
2 #############################################################################
3 ##                                                                         ##
4 ## Here are the mmakefile macros that are used as commands in the body     ##
5 ## of a make rule.                                                         ##
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.    ##
8 ##                                                                         ##
9 #############################################################################
10 #############################################################################
12 #------------------------------------------------------------------------------
13 # Compile the file %(from) to %(to) with %(cmd). Write any errors to %(err)
14 # and use the options in %(opt). Use %(iquote) and %(iquote_end) for supplying -iquote or -I- flags
15 %define compile_q cmd="$(TARGET_CC) $(TARGET_CFLAGS)" opt=$(CFLAGS) from=$< to=$@ iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
16         @$(ECHO) "Compiling %(from)"
17         @$(IF) %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -c %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
18             $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
19                 $(ECHO) "%(from): %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -c %(from) -o %(to)" >> $(GENDIR)/errors ; \
20                 tee < $(GENDIR)/cerrors -a $(GENDIR)/errors ; \
21             else \
22                 $(NOP) ; \
23             fi ; \
24         else \
25             $(ECHO) "Compile failed: %(cmd) %(iquote) $(dir %(from)) %(iquote) $(SRCDIR)/$(CURDIR) %(iquote) . %(iquote_end) %(opt) -c %(from) -o %(to)" 1>&2 ; \
26             tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
27             exit 1 ; \
28         fi
29 %end
30 #------------------------------------------------------------------------------
33 #------------------------------------------------------------------------------
34 # Assemble the file %(from) to %(to) with %(cmd) with the options in %(opt).
35 %define assemble_q cmd=$(CC) opt=$(AFLAGS) from=$< to=$@
36         @$(ECHO) "Assembling $(notdir %(from))..."
37         @$(IF) %(cmd) %(opt) %(from) -o %(to) > $(GENDIR)/cerrors 2>&1 ; then \
38             $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
39                 $(ECHO) "$(notdir %(from)): %(cmd) %(opt) %(from) -o %(to)" >> $(GENDIR)/errors ; \
40                 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
41             else \
42                 $(NOP) ; \
43             fi ; \
44         else \
45             $(ECHO) "Assemble failed: %(cmd) %(opt) %(from) -o %(to)" 1>&2 ; \
46             tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
47             exit 1 ; \
48         fi
49 %end
50 #-------------------------------------------------------------------------
53 #------------------------------------------------------------------------------
54 # Link a specified number of objects to an executable
55 %define link_q cmd=$(AROS_CC) opt=$(LDFLAGS) from=$< to=$@ libs=$(LIBS) strip=$(STRIP)
56         @$(ECHO) "Linking %(to)..."
57         @$(IF) %(cmd) %(opt) %(from) -o %(to) %(libs) 2>&1 > $(GENDIR)/cerrors 2>&1 ; then \
58                 $(IF) $(TEST) -s $(GENDIR)/cerrors ; then \
59                                 $(ECHO) "%(to): %(cmd) %(opt) %(from) -o %(to) %(libs)" >> $(GENDIR)/errors ; \
60                                 $(CAT) $(GENDIR)/cerrors >> $(GENDIR)/errors ; \
61                 else \
62                         $(NOP) ; \
63                 fi ; \
64         else \
65             $(ECHO) "Link failed: %(cmd) %(opt) %(from) -o %(to) %(libs)" 1>&2 ; \
66             tee < $(GENDIR)/cerrors -a $(GENDIR)/errors 1>&2 ; \
67             exit 1 ; \
68         fi; \
69         %(strip) %(to)
70 %end
71 #------------------------------------------------------------------------------
74 #-------------------------------------------------------------------------
75 # Link a module based upon a number of arguments and the standard $(LIBS)
76 # and $(DEPLIBS) make variables.
78 %define link_module_q err="$(notdir $@).err" objs=/A endtag= module=$(MODULE) ldflags=$(LDFLAGS) libs=$(LIBS) objdir=$(OBJDIR)
79         @$(ECHO) "Building $(notdir $@) ..."
80         @if $(AROS_CC) $(NOSTARTUP_LDFLAGS) %(ldflags) \
81             $(GENMAP) %(objdir)/%(module).map \
82             %(objs) %(libs) %(endtag) \
83             -o $@ 2>&1 > %(objdir)/%(err); \
84         then \
85             cat %(objdir)/%(err); \
86         else \
87             cat %(objdir)/%(err); \
88             exit 1; \
89         fi
91         @if $(TEST) ! -s %(objdir)/%(err) ; then $(RM) %(objdir)/%(err) ; fi
92         @$(STRIP) $@
93 %end
94 #------------------------------------------------------------------------------
97 #------------------------------------------------------------------------------
98 # Create the library
99 %define mklib_q ar=$(AR) ranlib=$(RANLIB) to=$@ from=$(OBJS)
100         @$(ECHO) "Creating library %(to)..."
101         @%(ar) %(to) %(from)
102         @%(ranlib) %(to)
103 %end
104 #------------------------------------------------------------------------------
107 #------------------------------------------------------------------------------
108 # Create the dependency file %(to) for %(from)
109 %define mkdepend_q flags=$(CFLAGS) from=$< to=$@ cc=$(AROS_CC)
110         %mkdir_q dir="$(dir %(to))"
111         @$(ECHO) "Makedepend $(CURDIR)/$(notdir %(from))..."
112         @AROS_CC="%(cc)" $(MKDEPEND) %(flags) -I$(SRCDIR)/$(CURDIR) %(from) -o %(to)
113 %end
114 #------------------------------------------------------------------------------
117 #------------------------------------------------------------------------------
118 # Create one directory without any output
119 %define mkdir_q dir=.
120         @$(IF) $(TEST) ! -d %(dir) ; then $(MKDIR) %(dir) ; else $(NOP) ; fi
121 %end
122 #------------------------------------------------------------------------------
125 #------------------------------------------------------------------------------
126 # Create several directories without any output
127 %define mkdirs_q dirs=/M
128         @$(FOR) dir in %(dirs) ; do \
129             $(IF) $(TEST) ! -d $$dir ; then $(MKDIR) $$dir ; else $(NOP) ; fi ; \
130         done
131 %end
132 #------------------------------------------------------------------------------
135 #############################################################################
136 #############################################################################
137 ##                                                                         ##
138 ## Here are the mmakefile macros that are used to do certain tasks in a    ##
139 ## mmakefile. They consist of one or more full makefile rules.             ##
140 ## In general the files generated in these macros are also defined as      ##
141 ## make targets so that they can be used as a dependency in other rules    ##
142 ##                                                                         ##
143 #############################################################################
144 #############################################################################
146 #------------------------------------------------------------------------------
147 # Generate a unique id for each of the %build... rules
148 %define buildid targets=/A
149 BDID := $(BDID)_
150 ifneq ($(filter $(TARGET),%(targets)),)
151 BDTARGETID := $(BDID)
152 endif
153 %end
154 #------------------------------------------------------------------------------
157 #------------------------------------------------------------------------------
158 # Copy file %(from) to %(to) in a makefile rule
159 %define rule_copy from=/A to=/A
160 %(to) : %(from)
161         @$(CP) $< $@
162 %end
163 #------------------------------------------------------------------------------
166 #------------------------------------------------------------------------------
167 # Copy the files %(files) to %(targetdir). For each file in %(files),
168 # %(srcdir)/file is copied to %(targetdir)/file. The targetdir and the
169 # appropriate subdirs are not generated by this rule so they have to be
170 # present.
171 %define rule_copy_multi files=/A targetdir=/A srcdir=.
173 $(addprefix %(targetdir)/,%(files)) : %(targetdir)/% : %(srcdir)/%
174         @$(CP) $< $@
175 %end
176 #------------------------------------------------------------------------------
179 #------------------------------------------------------------------------------
180 # Copy the files %(files) to %(targetdir). For each file in %(files),
181 # %(srcdir)/file is copied to %(targetdir)/file if these files are different.
182 # %(stampfile) is used to keep track of when the last time the comparison has
183 # been done. The targetdir and the appropriate subdirs are not generated by 
184 # this rule so they have to be present.
185 %define rule_copy_diff_multi files=/A targetdir=/A srcdir=. \
186     stampfile=$(TMP_SRCDIR)/.copy_stamp
188 TMP_SRCDIR := %(srcdir)
190 $(addprefix %(targetdir)/,%(files)) : | %(stampfile)
192 %(stampfile) : COPYSRCDIR := %(srcdir)
193 %(stampfile) : TGTDIR := %(targetdir)
194 %(stampfile) : FILES := %(files)
195 %(stampfile) : $(addprefix %(srcdir)/,%(files))
196         @for f in $(FILES); do \
197              $(IF) ! $(CMP) -s $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; then \
198                  $(CP) $(COPYSRCDIR)/$$f $(TGTDIR)/$$f ; \
199              fi ; \
200         done
201         @$(TOUCH) $@
202 %end
203 #------------------------------------------------------------------------------
206 #------------------------------------------------------------------------------
207 # Will join all the files in %(from) to %(to). When text is specified it will
208 # be displayed.
209 # Restriction: at the moment when using a non-empty target dir %(from) may
210 # not have 
211 %define rule_join to=/A from=/A text=
213 %(to) : %(from)
214 ifneq (%(text),)
215         @$(ECHO) %(text)
216 endif
217         @$(CAT) $^ >$@
218 %end
219 #------------------------------------------------------------------------------
222 #------------------------------------------------------------------------------
223 # Include the dependency files and add some internal rules
224 # When depstargets is provided the depencies will only be included when one of
225 # these targets is the $(TARGET). Otherwise the dependencies will only be
226 # included when the $(TARGET) is not for setup or clean 
227 %define include_deps deps=$(DEPS)/M  depstargets=
228 ifneq (%(deps),)
229   ifneq (%(depstargets),)
230     ifneq ($(findstring $(TARGET),%(depstargets)),)
231       -include %(deps)
232     endif
233   else
234     ifeq (,$(filter clean% %clean %clean% setup% includes% %setup,$(TARGET)))
235       -include %(deps)
236     endif
237   endif
238 endif
239 %end
240 #------------------------------------------------------------------------------
243 #------------------------------------------------------------------------------
244 # Create the directories %(dirs). The creation will be done by adding rules to
245 # the %(setuptarget) make target with setup as the default. 
246 %define rule_makedirs dirs=/A setuptarget=setup
248 %(setuptarget) :: %(dirs)
250 GLOB_MKDIRS += %(dirs)
252 %end
253 #------------------------------------------------------------------------------
256 #------------------------------------------------------------------------------
257 # Generate a rule to compile a C source file to an object file and generate
258 # the dependency file. Basename may contain a directory part, then the source
259 # file has to be in that directory. The generated file will be put in the
260 # object directory without the directory.
261 # options
262 # - basename: the basename of the file to compile. Use % for a wildcard rule
263 # - cflags (default $(CFLAGS)): the C flags to use for compilation
264 # - dflags: the flags used during creation of dependency file. If not specified
265 #   the same value as cflags will be used
266 # - targetdir: the directory to put the .o file and the .d file. By default
267 #   it is put in the same directory as the .c file
268 %define rule_compile basename=/A cflags=$(CFLAGS) dflags= targetdir= compiler=target nix=no
270 ifeq (%(targetdir),)
271   TMP_TARGETBASE := %(basename)
272 else
273   TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
274 endif
276 ifeq ($(findstring %(compiler),host kernel target),)
277   $(error unknown compiler %(compiler))
278 endif
279 ifeq (%(compiler),target)
280 $(TMP_TARGETBASE).o : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
281 $(TMP_TARGETBASE).d : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
282 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
283 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
284 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
285 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
286 endif
287 ifeq (%(compiler),host)
288 $(TMP_TARGETBASE).o : TMP_CMD:=$(HOST_CC)
289 $(TMP_TARGETBASE).d : TMP_CMD:=$(HOST_CC)
290 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(HOST_IQUOTE)
291 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(HOST_IQUOTE)
292 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
293 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
294 endif
295 ifeq (%(compiler),kernel)
296 $(TMP_TARGETBASE).o : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
297 $(TMP_TARGETBASE).d : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
298 $(TMP_TARGETBASE).o : TMP_IQUOTE:=$(KERNEL_IQUOTE)
299 $(TMP_TARGETBASE).d : TMP_IQUOTE:=$(KERNEL_IQUOTE)
300 $(TMP_TARGETBASE).o : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
301 $(TMP_TARGETBASE).d : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
302 endif
304 ifeq (%(nix),yes)
305   $(TMP_TARGETBASE).o : CFLAGS := -nix %(cflags)
306 else
307   $(TMP_TARGETBASE).o : CFLAGS := %(cflags)
308 endif
309 $(TMP_TARGETBASE).o : %(basename).c
310         %compile_q cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
312 ifeq (%(dflags),)
313   ifeq (%(nix),yes)
314     $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(cflags)
315   else
316     $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(cflags)
317   endif
318 else
319   ifeq (%(nix),yes)
320     $(TMP_TARGETBASE).d : TMP_DFLAGS:=-nix %(dflags)
321   else
322     $(TMP_TARGETBASE).d : TMP_DFLAGS:=%(dflags)
323   endif
324 endif
325 $(TMP_TARGETBASE).d : %(basename).c
326         %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
327 %end
328 #------------------------------------------------------------------------------
331 #------------------------------------------------------------------------------
332 # Generate a rule to compile multiple C source files to an object file and
333 # generate the corresponding dependency files. The generated file will be put
334 # in the object directory without the directory part of the source file.
335 # options
336 # - basenames: the basenames of the files to compile. The names may include
337 #   relative or absolute path names. No wildcard is allowed
338 # - cflags (default $(CFLAGS)): the C flags to use for compilation
339 # - dflags: the flags used during creation of dependency file. If not specified
340 #   the same value as cflags will be used
341 # - targetdir: the directory to put the .o file and the .d file. By default
342 #   it is put in the same directory as the .c file. When targetdir is not
343 #   empty, path names will be stripped from the file names so that all files
344 #   are in that dir and not in subdirectories.
345 # - compiler (default target): compiler to use, target, kernel or host
346 %define rule_compile_multi basenames=/A cflags=$(CFLAGS) dflags= targetdir= \
347     compiler=target
349 ifeq (%(targetdir),)
350 TMP_TARGETS := $(addsuffix .o,%(basenames))
351 TMP_DTARGETS := $(addsuffix .d,%(basenames))
352 TMP_WILDCARD := %
353 else
354 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
355 TMP_DTARGETS := $(addsuffix .d,$(addprefix %(targetdir)/,$(notdir %(basenames))))
356 TMP_WILDCARD := %(targetdir)/%
358 # Be sure that all .c files are generated
359 $(TMP_TARGETS) $(TMP_DTARGETS) : | $(addsuffix .c,%(basenames))
361 # Be sure that all .c files are found
362 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
363 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
364 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
365 ifneq ($(TMP_DIRS),)
366     TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
367     vpath %.c $(TMP_DIRS)
368 endif
370 endif
372 ifeq ($(findstring %(compiler),host kernel target),)
373   $(error unknown compiler %(compiler))
374 endif
375 ifeq (%(compiler),target)
376 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
377 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
378 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
379 endif
380 ifeq (%(compiler),host)
381 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(HOST_CC)
382 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(HOST_IQUOTE)
383 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
384 endif
385 ifeq (%(compiler),kernel)
386 $(TMP_TARGETS) $(TMP_DTARGETS) : CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
387 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
388 $(TMP_TARGETS) $(TMP_DTARGETS) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
389 endif
391 $(TMP_TARGETS) : CFLAGS := %(cflags)
392 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %.c
393         %compile_q cmd=$(CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
395 ifeq (%(dflags),)
396 $(TMP_DTARGETS) : DFLAGS:=%(cflags)
397 else
398 $(TMP_DTARGETS) : DFLAGS:=%(dflags)
399 endif
400 $(TMP_DTARGETS) : $(TMP_WILDCARD).d : %.c
401         %mkdepend_q cc=$(CMD) flags=$(DFLAGS)
402 %end
403 #------------------------------------------------------------------------------
406 #------------------------------------------------------------------------------
407 # Make an alias from one arch specific build to another arch.
408 # arguments:
409 # - mainmmake: the mmake of the module in the main tree
410 # - arch: the current arch
411 # - alias: the alias to which this should point
412 %define rule_archalias mainmmake=\A arch=\A alias=\A
414 #MM- %(mainmmake)-%(arch) : %(mainmmake)-%(alias)
415 %end
416 #------------------------------------------------------------------------------
419 #------------------------------------------------------------------------------
420 # Generate a rule to compile a C source file to a shared object file with a
421 # .so suffix. Basename may contain a directory part, then the source
422 # file has to be in that directory. The generated file will be put in the
423 # object directory without the directory.
424 # options
425 # - basename: the basename of the file to compile. Use % for a wildcard rule
426 # - cflags (default $(CFLAGS)): the C flags to use for compilation
427 # - targetdir: the directory to put the .o file and the .d file. By default
428 #   it is put in the same directory as the .c file
429 %define rule_compile_shared basename=/A cflags=$(CFLAGS) targetdir= compiler=target
431 ifeq (%(targetdir),)
432   TMP_TARGETBASE := %(basename)
433 else
434   TMP_TARGETBASE := %(targetdir)/$(notdir %(basename))
435 endif
437 ifeq ($(findstring %(compiler),host kernel target),)
438   $(error unknown compiler %(compiler))
439 endif
440 ifeq (%(compiler),target)
441 $(TMP_TARGETBASE).so : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
442 $(TMP_TARGETBASE).so : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
443 $(TMP_TARGETBASE).so : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
444 endif
445 ifeq (%(compiler),host)
446 $(TMP_TARGETBASE).so : TMP_CMD:=$(HOST_CC)
447 $(TMP_TARGETBASE).so : TMP_IQUOTE:=$(HOST_IQUOTE)
448 $(TMP_TARGETBASE).so : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
449 endif
450 ifeq (%(compiler),kernel)
451 $(TMP_TARGETBASE).so : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
452 $(TMP_TARGETBASE).so : TMP_IQUOTE:=$(KERNEL_IQUOTE)
453 $(TMP_TARGETBASE).so : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
454 endif
456 $(TMP_TARGETBASE).so : %(basename).c
457         %compile_q opt="$(SHARED_CFLAGS) %(cflags)" cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
458 %end
459 #------------------------------------------------------------------------------
462 #------------------------------------------------------------------------------
463 # Generate a rule to assemble a source file to an object file. Basename may
464 # contain a directory part, then the source file has to be in that directory.
465 # The generated file will be put in the object directory without the directory.
466 # options
467 # - basename: the basename of the file to compile. Use % for a wildcard rule
468 # - flags (default $(AFLAGS)): the asm flags to use for assembling
469 # - targetdir: the directory to put the .o file in. By default it is put in the
470 #   same directory as the .s file
471 %define rule_assemble basename=/A aflags=$(AFLAGS) targetdir=
473 ifeq (%(targetdir),)
474 %(basename).o : AFLAGS := %(aflags)
475 %(basename).o : %(basename).s
476         %assemble_q
477 %(basename).o : %(basename).S
478         %assemble_q
480 else
481 %(targetdir)/$(notdir %(basename)).o : AFLAGS := %(aflags)
482 %(targetdir)/$(notdir %(basename)).o : %(basename).s
483         %assemble_q
484 %(targetdir)/$(notdir %(basename)).o : %(basename).S
485         %assemble_q
487 endif
488 %end
489 #------------------------------------------------------------------------------
492 #------------------------------------------------------------------------------
493 # Generate a rule to assemble multiple source files to an object file. The
494 # generated file will be put in the object directory with the directory part
495 # of the source file stripped off.
496 # options
497 # - basenames: the basenames of the files to compile. The names may include
498 #   relative or absolute path names. No wildcard is allowed
499 # - aflags (default $(AFLAGS)): the flags to use for assembly
500 # - targetdir: the directory to put the .o file and the .d file. By default
501 #   it is put in the same directory as the .c file. When targetdir is not
502 #   empty, path names will be stripped from the file names so that all files
503 #   are in that dir and not in subdirectories.
504 %define rule_assemble_multi basenames=/A aflags=$(AFLAGS) targetdir= suffix=.s compiler=target
506 ifeq (%(targetdir),)
507 TMP_TARGETS := $(addsuffix .o,%(basenames))
508 TMP_WILDCARD := %
509 else
510 TMP_TARGETS := $(addsuffix .o,$(addprefix %(targetdir)/,$(notdir %(basenames))))
511 TMP_WILDCARD := %(targetdir)/%
513 # Be sure that all .s files are generated
514 $(TMP_TARGETS) : | $(addsuffix %(suffix),%(basenames))
516 # Be sure that all .c files are found
517 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
518 TMP_BASEDIRS := $(shell echo $(sort $(dir %(basenames))) | sed 's/\(.\):\//\/\1\//g')
519 TMP_DIRS := $(foreach dir, $(TMP_BASEDIRS), $(if $(filter /%,$(dir)),$(dir),$(TMP_SRCDIR)/$(CURDIR)/$(dir)))
520 ifneq ($(TMP_DIRS),)
521     TMP_DIRS := $(shell echo $(TMP_DIRS) | sed 's/\(.\):\//\/\1\//g')
522     vpath %%(suffix) $(TMP_DIRS)
523 endif
525 endif
527 ifeq ($(findstring %(compiler),host kernel target),)
528   $(error unknown compiler %(compiler))
529 endif
530 ifeq (%(compiler),target)
531 $(TMP_TARGETS) : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
532 endif
533 ifeq (%(compiler),host)
534 $(TMP_TARGETS) : TMP_CMD:=$(HOST_CC)
535 endif
536 ifeq (%(compiler),kernel)
537 $(TMP_TARGETS) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
538 endif
540 $(TMP_TARGETS) : AFLAGS := %(aflags)
541 $(TMP_TARGETS) : $(TMP_WILDCARD).o : %%(suffix)
542         %assemble_q cmd=$(TMP_CMD) opt=$(AFLAGS)
543 %end
544 #------------------------------------------------------------------------------
547 #------------------------------------------------------------------------------
548 # Link %(objs) to %(prog) using the libraries in %(uselibs)
549 %define rule_link_prog prog=/A objs=/A ldflags=$(LDFLAGS) uselibs= \
550     usehostlibs= usestartup=yes detach=no nix=no linker=target
552 TMP_EXTRA_LDFLAGS := 
553 ifeq (%(nix),yes)
554     TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
555 endif
556 ifeq (%(usestartup),no)
557     TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
558 endif
559 ifeq (%(detach),yes)
560     TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
561 endif
563 # Make a list of the lib files this program depends on.
564 ifneq (%(uselibs),)
565 # In LDFLAGS remove white space between -L and directory
566 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
567 # Filter out only the libdirs and remove -L
568 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
569 # Add trailing /
570 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
571 # Add normal linklib path
572 TMP_DIRS += $(LIBDIR)/
573 # add lib and .a to static linklib names
574 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) libinit autoinit))
575 # search for the linklibs in the given path, ignore ones not found
576 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
577     $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
579 else
580 TMP_DEPLIBS :=
581 endif
583 ifeq (%(linker),target)
584 %(prog) : CMD:=$(TARGET_CC)
585 %(prog) : STRIPCMD:=$(TARGET_STRIP)
586 endif
587 ifeq (%(linker),host)
588 %(prog) : CMD:=$(HOST_CC)
589 %(prog) : STRIPCMD:=$(HOST_STRIP)
590 endif
591 ifeq (%(linker),kernel)
592 %(prog) : CMD:=$(KERNEL_CC) $(KERNEL_LDFLAGS)
593 %(prog) : STRIPCMD:=$(ECHO) >/dev/null
594 endif
596 %(prog) : OBJS := %(objs)
597 %(prog) : LDFLAGS := %(ldflags) $(TMP_EXTRA_LDFLAGS)
598 %(prog) : LIBS := $(addprefix -l,%(uselibs)) $(addprefix -l,%(usehostlibs))
599 %(prog) : %(objs) $(TMP_DEPLIBS)
600         %link_q from=$(OBJS) opt=$(LDFLAGS) libs=$(LIBS) cmd=$(CMD) strip=$(STRIPCMD)
601 %end
602 #------------------------------------------------------------------------------
605 #------------------------------------------------------------------------------
606 # Link %(progs) from object in %(objdir) to executables in %(targetdir) using
607 # the AROS libraries in %(uselibs) and the host libraries in %(usehostlibs)
608 %define rule_link_progs progs=/A targetdir=$(AROSDIR)/$(CURDIR) nix=%(nix) \
609     objdir=$(GENDIR)/$(CURDIR) ldflags=$(LDFLAGS) uselibs= usehostlibs= \
610     usestartup=yes detach=no
612 TMP_EXTRA_LDFLAGS := 
613 ifeq (%(nix),yes)
614     TMP_EXTRA_LDFLAGS += $(NIX_LDFLAGS)
615 endif
616 ifeq (%(usestartup),no)
617     TMP_EXTRA_LDFLAGS += $(NOSTARTUP_LDFLAGS)
618 endif
619 ifeq (%(detach),yes)
620     TMP_EXTRA_LDFLAGS += $(DETACH_LDFLAGS)
621 endif
623 # Make a list of the lib files the programs depend on.
624 ifneq (%(uselibs),)
625 # In LDFLAGS remove white space between -L and directory
626 TMP_DIRS := $(subst -L ,-L,$(strip %(ldflags)))
627 # Filter out only the libdirs and remove -L
628 TMP_DIRS := $(patsubst -L%,%,$(filter -L%,$(TMP_DIRS)))
629 # Add trailing /
630 TMP_DIRS := $(subst //,/,$(addsuffix /,$(TMP_DIRS)))
631 # Add normal linklib path
632 TMP_DIRS += $(LIBDIR)/lib/
633 # add lib and .a to static linklib names
634 TMP_LIBS := $(addprefix lib,$(addsuffix .a,%(uselibs) libinit autoinit))
635 # search for the linklibs in the given path, ignore ones not found
636 TMP_DEPLIBS := $(foreach lib,$(TMP_LIBS), \
637     $(firstword $(wildcard $(addsuffix $(lib),$(TMP_DIRS)))) \
639 else
640 TMP_DEPLIBS :=
641 endif
643 $(addprefix %(targetdir)/,%(progs)) : LDFLAGS:= %(ldflags) $(TMP_EXTRA_LDFLAGS)
644 $(addprefix %(targetdir)/,%(progs)) : LIBS:= $(addprefix -l,%(uselibs)) $(addprefix -l,%(usehostlibs))
645 $(addprefix %(targetdir)/,%(progs)) : %(targetdir)/% : %(objdir)/%.o $(TMP_DEPLIBS)
646         %link_q from=$< opt=$(LDFLAGS) libs=$(LIBS)
647 %end
648 #------------------------------------------------------------------------------
651 #------------------------------------------------------------------------------
652 # Link the %(objs) to the library %(libdir)/lib%(libname).a
653 %define rule_link_linklib libname=/A objs=/A libdir=$(LIBDIR)
655 %(libdir)/lib%(libname).a : %(objs)
656         %mklib_q from=$^
657 %end
658 #------------------------------------------------------------------------------
661 #------------------------------------------------------------------------------
662 # Link the %(objs) to the library %(libdir)/lib%(libname).so
663 %define rule_link_shlib libname=/A objs=/A libdir=$(LIBDIR)
665 %(libdir)/lib%(libname).so : %(objs)
666         @$(SHARED_LD) $(SHARED_LDFLAGS) -o $@ $^
667 %end
668 #------------------------------------------------------------------------------
671 #------------------------------------------------------------------------------
672 # Link the %(objs) and %(endobj) to %(module) with errors in %(err) and using
673 # the libraries in %(uselibs) and the host libraries in %(usehostlibs)
674 # The -noarosc flag is added so that modules are not linked with arosc.library
675 # (see /config/specs.in file)
676 %define rule_linkmodule module=/A objs=/A endobj=/A err=/A objdir=$(OBJDIR) \
677     uselibs= usehostlibs=
679 %(module) : OBJS := %(objs)
680 %(module) : ENDTAG := %(endobj)
681 %(module) : ERR := %(err)
682 %(module) : OBJDIR := %(objdir)
683 %(module) : LIBS := $(addprefix -l,%(uselibs)) -lautoinit -llibinit -L/usr/lib $(addprefix -l,%(usehostlibs))
684 %(module) : %(objs) %(endobj) $(addprefix $(LIBDIR)/lib,$(addsuffix .a,%(uselibs) libinit autoinit))
685         %link_module_q err=$(ERR) endtag=$(ENDTAG) objs=$(OBJS) libs=$(LIBS) objdir=$(OBJDIR) ldflags="$(LDFLAGS) -noarosc"
687 %end
688 #------------------------------------------------------------------------------
691 #------------------------------------------------------------------------------
692 # Generate the libdefs.h include file for a module.
693 %define rule_genmodule_genlibdefs modname=/A modtype=/A modsuffix= conffile= targetdir=
695 TMP_TARGET := %(modname)_libdefs.h
696 TMP_DEPS := $(GENMODULE)
697 TMP_OPTS := 
698 ifneq (%(conffile),)
699     TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
700     TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
701 else
702     TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
703     TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
704 endif
705 ifneq (%(modsuffix),)
706     TMP_OPTS += -s %(modsuffix)
707 endif
708 ifneq (%(targetdir),)
709     TMP_OPTS += -d %(targetdir)
710     TMP_TARGET := %(targetdir)/$(TMP_TARGET)
711 endif
713 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
714 $(TMP_TARGET) : MODNAME := %(modname)
715 $(TMP_TARGET) : MODTYPE := %(modtype)
716 $(TMP_TARGET) : $(TMP_DEPS)
717         @$(ECHO) "Generating $(notdir $@)"
718         @$(GENMODULE) $(OPTS) writelibdefs $(MODNAME) $(MODTYPE)
719 %end
720 #------------------------------------------------------------------------------
723 #------------------------------------------------------------------------------
724 # Generate a Makefile.%(modname) with the genmodule program and include this
725 # generated file in this Makefile
726 %define rule_genmodule_makefile modname=/A modtype=/A modsuffix= conffile= \
727     targetdir=
729 TMP_TARGET := Makefile.%(modname)
730 TMP_DEPS := $(GENMODULE)
731 TMP_OPTS := 
732 ifneq (%(conffile),)
733     TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
734     TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
735 else
736     TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
737     TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
738 endif
739 ifneq (%(modsuffix),)
740     TMP_OPTS += -s %(modsuffix)
741 endif
742 ifneq (%(targetdir),)
743     TMP_OPTS += -d %(targetdir)
744     TMP_TARGET := %(targetdir)/$(TMP_TARGET)
745 endif
747 $(TMP_TARGET) : OPTS := $(TMP_OPTS)
748 $(TMP_TARGET) : MODNAME := %(modname)
749 $(TMP_TARGET) : MODTYPE := %(modtype)
750 $(TMP_TARGET) : $(TMP_DEPS)
751         @$(GENMODULE) $(OPTS) writemakefile $(MODNAME) $(MODTYPE)
752 %end
753 #------------------------------------------------------------------------------
756 #------------------------------------------------------------------------------
757 # Generate the support files for compiling a module. This includes include
758 # files and source files. This rule has to be preceeded by
759 # %rule_genmodule_makefile
760 %define rule_genmodule_files modname=/A modtype=/A modsuffix= targetdir= \
761     conffile=
763 TMP_TARGETS := $(%(modname)_STARTFILES) $(%(modname)_ENDFILES) \
764                $(%(modname)_LINKLIBFILES)
765 TMP_TARGETS := $(addsuffix .c,$(TMP_TARGETS)) $(addsuffix .S, $(%(modname)_LINKLIBAFILES))
767 TMP_DEPS := $(GENMODULE)
768 TMP_OPTS :=
770 ifneq (%(conffile),)
771     TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
772     TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
773 else
774     TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
775     TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
776 endif
777 ifneq (%(modsuffix),)
778     TMP_OPTS += -s %(modsuffix)
779 endif
780 ifneq (%(targetdir),)
781     TMP_OPTS += -d %(targetdir)
782     TMP_TARGETDIR := $(shell echo %(targetdir) | sed 's/^\(.\):\//\/\1\//')
783     TMP_TARGETS := $(addprefix $(TMP_TARGETDIR)/,$(TMP_TARGETS))
784 endif
786 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
787 $(TMP_TARGETS) : MODNAME := %(modname)
788 $(TMP_TARGETS) : MODTYPE := %(modtype)
789 $(TMP_TARGETS) : $(TMP_DEPS)
790         @$(ECHO) "Generating support files for module $(MODNAME$(BDID))"
791 ifneq (%(conffile),lib.conf)
792         @$(IF) $(TEST) -f lib.conf; then \
793           $(ECHO) "WARNING !!! $(CURDIR)/lib.conf may probably be removed"; \
794         fi
795 endif
796         @$(IF) $(TEST) -f libdefs.h; then \
797           $(ECHO) "WARNING !!! $(CURDIR)/libdefs.h may probably be removed"; \
798         fi
799         @$(GENMODULE) $(OPTS) writefiles $(MODNAME) $(MODTYPE)
800 %end
801 #------------------------------------------------------------------------------
804 #------------------------------------------------------------------------------
805 # Generate the support files for compiling a module. This includes include
806 # files and source files.
807 %define rule_genmodule_includes modname=/A modtype=/A modsuffix= \
808     targetdir= conffile=
810 ifneq ($(%(modname)_INCLUDES),)
811 TMP_TARGETS := $(%(modname)_INCLUDES)
813 TMP_DEPS := $(GENMODULE)
814 TMP_OPTS :=
816 ifneq (%(conffile),)
817     TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(conffile)
818     TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(conffile)
819 else
820     TMP_OPTS += -c $(SRCDIR)/$(CURDIR)/%(modname).conf
821     TMP_DEPS += $(SRCDIR)/$(CURDIR)/%(modname).conf
822 endif
823 ifneq (%(modsuffix),)
824     TMP_OPTS += -s %(modsuffix)
825 endif
826 ifneq (%(targetdir),)
827     TMP_OPTS += -d %(targetdir)
828     TMP_TARGETS := $(addprefix %(targetdir)/,$(TMP_TARGETS))
829 endif
831 $(TMP_TARGETS) : OPTS := $(TMP_OPTS)
832 $(TMP_TARGETS) : MODNAME := %(modname)
833 $(TMP_TARGETS) : MODTYPE := %(modtype)
834 $(TMP_TARGETS) : $(TMP_DEPS)
835         @$(ECHO) "Generating include files"
836         @$(GENMODULE) $(OPTS) writeincludes $(MODNAME) $(MODTYPE)
837 endif
838 %end
839 #------------------------------------------------------------------------------
842 #------------------------------------------------------------------------------
843 # Common rules for all makefiles
844 %define common
845 # Delete generated makefiles
847 clean ::
848         @$(RM) $(TOP)/$(CURDIR)/mmakefile $(TOP)/$(CURDIR)/mmakefile.bak
850 include $(SRCDIR)/config/make.tail
852 BDID := $(BDTARGETID)
853 %end
854 #------------------------------------------------------------------------------
855       
857 #############################################################################
858 #############################################################################
859 ##                                                                         ##
860 ## Here are the mmakefile build macros. These are macros that takes care   ##
861 ## of everything to go from the sources to the generated target. Also all  ##
862 ## intermediate files and directories that are needed are created by these ##
863 ## rules.                                                                  ##
864 ##                                                                         ##
865 #############################################################################
866 #############################################################################
868 #------------------------------------------------------------------------------
869 # Build a program
870 %define build_prog mmake=/A progname=/A files=$(BD_PROGNAME) asmfiles= \
871     objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
872     cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
873     aflags=$(AFLAGS) uselibs= usehostlibs= usestartup=yes detach=no nix=no \
874     compiler=target srcdir=
876 .PHONY : %(mmake)
878 BD_PROGNAME  := %(progname)
879 BD_OBJDIR    := %(objdir)
880 BD_TARGETDIR := %(targetdir)
882 BD_FILES     := %(files)
883 BD_ASMFILES  := %(asmfiles)
885 BD_ARCHOBJS   := $(wildcard $(BD_OBJDIR)/arch/*.o)
886 BD_ARCHFILES  := $(basename $(notdir $(BD_ARCHOBJS)))
887 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
889 BD_OBJS      := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_NARCHFILES) $(BD_ASMFILES)))
890 BD_DEPS      := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_NARCHFILES)))
892 BD_CFLAGS    := %(cflags)
893 BD_AFLAGS    := %(aflags)
894 BD_DFLAGS    := %(dflags)
895 BD_LDFLAGS   := %(ldflags)
898 %(mmake)-quick : %(mmake)
900 #MM %(mmake) : includes-generate-deps linklibs-core
901 %(mmake) : $(BD_TARGETDIR)/$(BD_PROGNAME)
903 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
904 %rule_compile basename=%(srcdir)% targetdir=$(BD_OBJDIR) \
905     cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) compiler=%(compiler)
906 %rule_assemble_multi basenames=$(BD_ASMFILES) targetdir=$(BD_OBJDIR) \
907     aflags=$(BD_AFLAGS) compiler=%(compiler)
909 %rule_link_prog prog=$(BD_TARGETDIR)/$(BD_PROGNAME) \
910     objs="$(BD_OBJS) $(BD_ARCHOBJS) $(USER_OBJS)" ldflags=$(BD_LDFLAGS) \
911     uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
912     usestartup="%(usestartup)" detach="%(detach)" nix="%(nix)" \
913     linker=%(compiler)
915 endif
917 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
919 $(BD_OBJS) $(BD_DEPS) : | $(BD_OBJDIR)
920 $(BD_TARGETDIR)/$(BD_PROGNAME) : | $(BD_TARGETDIR)
921 GLOB_MKDIRS += $(BD_OBJDIR) $(BD_TARGETDIR)
923 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_TARGETDIR)/$(BD_PROGNAME) $(BD_DEPS)
925 %(mmake)-clean ::
926         @$(ECHO) "Cleaning up for metatarget %(mmake)"
927         @$(RM) $(FILES)
929 %end
930 #------------------------------------------------------------------------------
933 #------------------------------------------------------------------------------
934 # Build programs, for every C file an executable will be built with the same
935 # name as the C file
936 %define build_progs mmake=/A files=/A nix=no \
937     objdir=$(GENDIR)/$(CURDIR) targetdir=$(AROSDIR)/$(CURDIR) \
938     cflags=$(CFLAGS) dflags=$(BD_CFLAGS) ldflags=$(LDFLAGS) \
939     uselibs= usehostlibs= usestartup=yes detach=no
941 .PHONY : %(mmake)
943 BD_OBJDIR    := %(objdir)
944 BD_TARGETDIR := %(targetdir)
946 BD_FILES     := %(files)
947 BD_OBJS      := $(addsuffix .o,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
948 BD_DEPS      := $(addsuffix .d,$(addprefix $(BD_OBJDIR)/,$(BD_FILES)))
949 BD_EXES      := $(addprefix $(BD_TARGETDIR)/,$(BD_FILES))
951 BD_CFLAGS    := %(cflags)
952 BD_DFLAGS    := %(dflags)
953 BD_LDFLAGS   := %(ldflags)
956 %(mmake)-quick : %(mmake)
958 #MM %(mmake) : includes-generate-deps
959 %(mmake) : $(BD_EXES)
961 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-quick),)
962 %rule_compile basename=% targetdir=$(BD_OBJDIR) nix=%(nix) \
963     cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
965 %rule_link_progs progs=$(BD_FILES) nix=%(nix) \
966     targetdir=$(BD_TARGETDIR) objdir=$(BD_OBJDIR) \
967     ldflags=$(BD_LDFLAGS) \
968     uselibs="%(uselibs)" usehostlibs="%(usehostlibs)" \
969     usestartup="%(usestartup)" detach="%(detach)"
971 endif
973 %include_deps depstargets="%(mmake) %(mmake)-quick" deps=$(BD_DEPS)
975 $(addprefix $(BD_TARGETDIR)/,$(BD_FILES)) : | $(BD_TARGETDIR)
976 $(BD_DEPS) $(BD_OBJS) : | $(BD_OBJDIR)
977 GLOB_MKDIRS += $(BD_TARGETDIR) $(BD_OBJDIR)
979 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_EXES) $(BD_DEPS)
981 %(mmake)-clean ::
982         @$(ECHO) "Cleaning up for metatarget %(mmake)"
983         @$(RM) $(FILES)
985 %end
986 #------------------------------------------------------------------------------
989 #------------------------------------------------------------------------------
990 # Build a module.
991 # This is a bare version: It just compiles and links the given files. It is
992 # assumed that all needed boiler plate code is in the files. This should only
993 # be used for compiling external code. For AROS code use %build_module
994 %define build_module_simple mmake=/A modname=/A modtype=/A \
995     files="$(basename $(call WILDCARD, *.c))" \
996     cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
997     objdir=$(OBJDIR) moduledir= \
998     uselibs= usehostlibs= compiler=target
1000 # Define metamake targets and their dependencies
1001 #MM %(mmake) : core-linklibs includes-generate-deps
1002 #MM %(mmake)-kobj : core-linklibs includes-generate-deps
1003 #MM %(mmake)-quick
1004 #MM %(mmake)-clean
1006 BD_ALLTARGETS := %(mmake) %(mmake)-clean %(mmake)-quick %(mmake)-kobj
1008 .PHONY : $(BD_ALLTARGETS)
1010 ifeq (%(modname),)
1011 $(error using %build_module_simple: modname may not be empty)
1012 endif
1013 ifeq (%(modtype),)
1014 $(error using %build_module_simple: $(MODTYPE) has to be defined with the type of the module)
1015 endif
1017 # Default values for variables and arguments
1018 BD_DEFLINKLIBNAME := %(modname)
1019 BD_DEFDFLAGS := %(cflags)
1020 OBJDIR ?= $(GENDIR)/$(CURDIR)
1021 BD_MODDIR := %(moduledir)
1022 ifeq ($(BD_MODDIR),)
1023   ifeq (%(modtype),library)
1024     BD_MODDIR  := $(AROS_LIBS)
1025   endif
1026   ifeq (%(modtype),gadget)
1027     BD_MODDIR  := $(AROS_GADGETS)
1028   endif
1029   ifeq (%(modtype),datatype)
1030     BD_MODDIR  := $(AROS_DATATYPES)
1031   endif
1032   ifeq (%(modtype),handler)
1033     BD_MODDIR  := $(AROS_FS)
1034   endif
1035   ifeq (%(modtype),device)
1036     BD_MODDIR  := $(AROS_DEVS)
1037   endif
1038   ifeq (%(modtype),resource)
1039     BD_MODDIR  := $(AROS_RESOURCES)
1040   endif
1041   ifeq (%(modtype),mui)
1042     BD_MODDIR  := $(AROS_CLASSES)/Zune
1043   endif
1044   ifeq (%(modtype),mcc)
1045     BD_MODDIR  := $(AROS_CLASSES)/Zune
1046   endif
1047   ifeq (%(modtype),mcp)
1048     BD_MODDIR  := $(AROS_CLASSES)/Zune
1049   endif
1050   ifeq (%(modtype),usbclass)
1051     BD_MODDIR  := $(AROS_CLASSES)/USB
1052   endif
1053   ifeq (%(modtype),hidd)
1054     BD_MODDIR  := $(AROS_DRIVERS)
1055   endif
1056 endif
1057 ifeq ($(BD_MODDIR),)
1058   $(error Don't know where to put the file for modtype %(modtype). Specify moduledir=)
1059 endif
1061 BD_ARCHOBJS   := $(wildcard %(objdir)/arch/*.o)
1062 BD_ARCHFILES  := $(basename $(notdir $(BD_ARCHOBJS)))
1063 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),%(files))
1065 %rule_compile_multi \
1066     basenames="$(BD_NARCHFILES)" targetdir="%(objdir)" \
1067     cflags="%(cflags)" dflags="%(dflags)" \
1068     compiler=%(compiler)
1070 BD_MODULE := $(BD_MODDIR)/%(modname).%(modtype)
1071 BD_KOBJ := $(KOBJSDIR)/%(modname)_%(modtype).o
1073 %(mmake)-quick : %(mmake)
1074 %(mmake) : $(BD_MODULE)
1075 %(mmake)-kobj : $(BD_KOBJ)
1077 # The module is linked from all the compiled .o files
1078 BD_OBJS       := $(BD_ARCHOBJS) $(addprefix %(objdir)/, $(addsuffix .o,$(notdir $(BD_NARCHFILES))))
1079 %rule_linkmodule module=$(BD_MODULE) objs=$(BD_OBJS) \
1080                  endobj= err=%(modname).err objdir=%(objdir) \
1081                  uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1083 # Link kernel object file
1084 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1086 # Make these symbols local
1087 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1088             UtilityBase ExpansionBase KeymapBase KernelBase
1090 BD_SYMBOLS := $(BD_KBASE)
1092 BD_KLIB := hiddgraphicsstubs hiddstubs amiga arossupport rom arosm autoinit libinit
1093 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1094 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1095 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
1096 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1097         @$(ECHO) "Linking $@"
1098         @$(AROS_LD) -Ur -o $@ $^ -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1099         @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^libraryset_.*$$/) {print "-L " $$3;}'`
1102 ## Dependency fine-tuning
1104 BD_DEPS       := $(addprefix %(objdir)/, $(addsuffix .d,%(files)))
1105 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj" deps=$(BD_DEPS)
1107 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1108 $(BD_MODULE) : | $(BD_MODDIR)
1109 $(BD_KOBJ) : | $(KOBJSDIR)
1110 GLOB_MKDIRS += %(objdir) $(BD_MODDIR) $(KOBJSDIR)
1112 %(mmake)-clean : FILES := $(BD_OBJS) $(BD_MODULE) $(BD_KOBJ) $(BD_DEPS)
1113 %(mmake)-clean ::
1114         @$(ECHO) "Cleaning up for module %(modname)"
1115         @$(RM) $(FILES)
1116 %end
1117 #------------------------------------------------------------------------------
1120 #------------------------------------------------------------------------------
1121 # Build a module
1122 # Explanation of this macro is done in the developer's manual
1123 %define build_module mmake=/A modname=/A modtype=/A modsuffix= \
1124   conffile= files="$(basename $(call WILDCARD, *.c))" \
1125   linklibfiles= linklibobjs= cflags=$(CFLAGS) dflags=$(BD_DEFDFLAGS) \
1126   objdir=$(OBJDIR) moduledir=$(BD_DEFMODDIR) prefix=$(AROSDIR) \
1127   linklibname=$(BD_DEFLINKLIBNAME) uselibs= usehostlibs= \
1128   compiler=target
1130 # Define metamake targets and their dependencies
1131 #MM- includes-all : %(mmake)-includes
1132 #MM %(mmake) : %(mmake)-includes core-linklibs
1133 #MM %(mmake)-kobj : %(mmake)-includes core-linklibs
1134 #MM %(mmake)-kobj-quick : %(mmake)-includes-quick
1135 #MM %(mmake)-linklib : %(mmake)-includes
1136 #MM %(mmake)-quick : %(mmake)-includes-quick
1137 #MM %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1138 #MM     includes-generate-deps
1139 #MM %(mmake)-includes-quick
1140 #MM %(mmake)-includes-dirs
1141 #MM %(mmake)-makefile
1142 #MM %(mmake)-clean
1144 # All MetaMake targets defined by this macro
1145 BD_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-includes \
1146     %(mmake)-includes-quick %(mmake)-includes-dirs %(mmake)-clean \
1147     %(mmake)-kobj %(mmake)-kobj-quick %(mmake)-linklib
1149 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1151 ifeq (%(modname),)
1152 $(error using %build_module: modname may not be empty)
1153 endif
1154 ifeq (%(modtype),)
1155 $(error using %build_module: $(MODTYPE) has to be defined with the type of the module)
1156 endif
1158 # Default values for variables and arguments
1159 BD_DEFLINKLIBNAME := %(modname)
1160 BD_DEFDFLAGS := %(cflags)
1161 OBJDIR ?= $(GENDIR)/$(CURDIR)
1163 ## Create genmodule include Makefile for the module
1165 %(mmake)-makefile : %(objdir)/Makefile.%(modname)
1167 %rule_genmodule_makefile \
1168     modname=%(modname) modtype=%(modtype) \
1169     modsuffix=%(modsuffix) targetdir=%(objdir) \
1170     conffile=%(conffile)
1172 %(objdir)/Makefile.%(modname) : | %(objdir)
1174 GLOB_MKDIRS += %(objdir)
1176 # Do not parse these statements if metatarget is not appropriate
1177 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1179 include %(objdir)/Makefile.%(modname)
1181 BD_DEFMODDIR := $(%(modname)_MODDIR)
1184 ## include files generation
1186 BD_INCDIR    := %(prefix)/$(AROS_DIR_INCLUDE)
1187 BD_LIBDEFSINC := %(objdir)/include/%(modname)_libdefs.h
1188 BD_DEFLIBDEFSINC := %(objdir)/include/%(modname)_deflibdefs.h
1190 %(mmake)-includes-quick : %(mmake)-includes
1191 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1192     $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1193     $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1195 ifneq ($(%(modname)_INCLUDES),)
1196 %rule_genmodule_includes modname=%(modname) modtype=%(modtype) \
1197                          modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1198                          conffile=%(conffile)
1200 %rule_copy_diff_multi \
1201     files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(GENINCDIR) \
1202     stampfile=%(objdir)/%(modname)_geninc
1204 %rule_copy_diff_multi \
1205     files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(BD_INCDIR) \
1206     stampfile=%(objdir)/%(modname)_incs
1208 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1210 TMP%(modname)_INCDIRS := \
1211     %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1212     $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1213     $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1214 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget=%(mmake)-includes-dirs
1216 endif
1218 %rule_genmodule_genlibdefs modname=%(modname) modtype=%(modtype) \
1219                            modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1220                            conffile=%(conffile)
1222 $(BD_DEFLIBDEFSINC) : FILENAME := $(BD_LIBDEFSINC)
1223 $(BD_DEFLIBDEFSINC) :
1224         @$(ECHO) "generating $@"
1225         @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1227 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) : | %(objdir)/include
1228 GLOB_MKDIRS += %(objdir)/include
1230 ## Extra genmodule src files generation
1231 ## 
1232 %rule_genmodule_files modname=%(modname) modtype=%(modtype) \
1233                       modsuffix=%(modsuffix) targetdir=%(objdir) \
1234                       conffile=%(conffile)
1236 ## Compilation
1238 BD_FILES      := %(files)
1239 BD_FDIRS      := $(sort $(dir $(BD_FILES)))
1240 BD_STARTFILES := $(addprefix %(objdir)/,$(%(modname)_STARTFILES))
1241 BD_ENDFILES   := $(addprefix %(objdir)/,$(%(modname)_ENDFILES))
1243 BD_ARCHOBJS   := $(wildcard %(objdir)/arch/*.o)
1244 BD_ARCHFILES  := $(basename $(notdir $(BD_ARCHOBJS)))
1245 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1247 BD_CFLAGS     := %(cflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1248 BD_DFLAGS     := %(dflags) -I%(objdir)/include -include $(BD_DEFLIBDEFSINC)
1250 BD_LINKLIBCFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBFILES))
1251 BD_LINKLIBAFILES := $(addprefix %(objdir)/,$(%(modname)_LINKLIBAFILES))
1252 ifeq ($(strip $(%(modname)_LINKLIBFILES) %(linklibfiles)),)
1253     BD_LINKLIB :=
1254 else
1255     BD_LINKLIB := %(prefix)/$(AROS_DIR_LIB)/lib%(linklibname).a
1256 endif
1257 BD_LINKLIBFILES := $(BD_LINKLIBCFILES) $(BD_LINKLIBAFILES)
1259 BD_CCFILES := $(BD_NARCHFILES) %(linklibfiles)
1260 BD_TARGETCCFILES := $(BD_STARTFILES) $(BD_ENDFILES) $(BD_LINKLIBCFILES) 
1262 %rule_compile_multi \
1263     basenames=$(BD_CCFILES) targetdir=%(objdir) \
1264     cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS) \
1265     compiler=%(compiler)
1266 %rule_compile_multi \
1267     basenames=$(BD_TARGETCCFILES) targetdir=%(objdir) \
1268     cflags="$(BD_CFLAGS) -D__AROS__" dflags=$(BD_DFLAGS) \
1269     compiler=%(compiler)
1271 ifneq ($(BD_LINKLIBAFILES),)
1272 %rule_assemble_multi \
1273     basenames=$(BD_LINKLIBAFILES) targetdir=%(objdir) suffix=.S
1274 endif
1276 ## Linking
1278 ifeq (%(modsuffix),)
1279 BD_MODULE    := %(prefix)/%(moduledir)/%(modname).%(modtype)
1280 BD_KOBJ      := $(KOBJSDIR)/%(modname)_%(modtype).o
1281 else
1282 BD_MODULE    := %(prefix)/%(moduledir)/%(modname).%(modsuffix)
1283 BD_KOBJ      := $(KOBJSDIR)/%(modname)_%(modsuffix).o
1284 endif
1286 %(mmake)-quick : %(mmake)
1287 %(mmake) : $(BD_MODULE) $(BD_LINKLIB)
1288 %(mmake)-kobj : $(BD_KOBJ) $(BD_LINKLIB)
1289 %(mmake)-kobj-quick : $(BD_KOBJ) $(BD_LINKLIB)
1290 %(mmake)-linklib : $(BD_LINKLIB)
1292 BD_OBJS       := $(addsuffix .o,$(BD_STARTFILES)) $(BD_ARCHOBJS) \
1293                  $(addsuffix .o, $(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES))))
1294 BD_STARTOBJS  := $(addsuffix .o,$(addprefix $(GENDIR)/,$(RESIDENT_BEGIN)))
1295 BD_ENDOBJS    := $(addsuffix .o,$(BD_ENDFILES))
1296 BD_LINKLIBOBJS:= $(addsuffix .o,$(addprefix %(objdir)/,$(notdir %(linklibfiles))) $(BD_LINKLIBFILES)) \
1297                  %(linklibobjs)
1299 # The module is linked from all the compiled .o files
1300 %rule_linkmodule module=$(BD_MODULE) objs="$(BD_STARTOBJS) $(BD_OBJS)" \
1301                  endobj=$(BD_ENDOBJS) err=%(modname).err objdir=%(objdir) \
1302                  uselibs="%(uselibs)" usehostlibs="%(usehostlibs)"
1304 # Link static lib
1305 ifneq ($(BD_LINKLIB),)
1306 %rule_link_linklib libname=%(linklibname) objs=$(BD_LINKLIBOBJS) libdir=%(prefix)/$(AROS_DIR_LIB)
1308 $(BD_LINKLIB) : | %(prefix)/$(AROS_DIR_LIB)
1309 GLOB_MKDIRS += %(prefix)/$(AROS_DIR_LIB)
1310 endif
1312 # Link kernel object file
1313 BD_KAUTOLIB := dos intuition layers graphics oop utility expansion keymap
1315 # Make these symbols local
1316 BD_KBASE := DOSBase IntuitionBase LayersBase GfxBase OOPBase \
1317             UtilityBase ExpansionBase KeymapBase KernelBase
1319 BD_SYMBOLS := $(BD_KBASE)
1321 BD_KLIB := hiddgraphicsstubs hiddstubs amiga arossupport rom arosm autoinit libinit
1322 BD_KOBJ_LIBS := $(filter-out $(BD_KLIB),%(uselibs)) $(BD_KAUTOLIB)
1323 $(BD_KOBJ) : LINKLIBS:=$(BD_KOBJ_LIBS)
1324 $(BD_KOBJ) : FILTBASES:=$(addprefix -L ,$(BD_SYMBOLS))
1325 $(BD_KOBJ) : $(BD_OBJS) $(BD_ENDOBJS)
1326         @$(ECHO) "Linking $@"
1327         @$(AROS_LD) -Ur -o $@ $^ -L$(AROS_LIB) $(addprefix -l,$(LINKLIBS))
1328         @$(OBJCOPY) $@ $(FILTBASES) `$(NM_PLAIN) $@ | $(AWK) '($$3 ~ /^__.*_(LIST|END)__\r?$$/) || ($$3 ~ /^libraryset_.*$$/) {print "-L " $$3;}'`
1330 ## Dependency fine-tuning
1332 BD_DEPS := $(addsuffix .d,$(addprefix %(objdir)/,$(notdir $(BD_CCFILES) $(BD_TARGETCCFILES))))
1333 %include_deps depstargets="%(mmake) %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick" deps=$(BD_DEPS)
1335 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1336 $(BD_MODULE) : | %(prefix)/%(moduledir)
1337 $(BD_KOBJ) : | $(KOBJSDIR)
1338 GLOB_MKDIRS += %(objdir) %(prefix)/%(moduledir) $(KOBJSDIR)
1340 # Some include files need to be generated before the .c can be parsed.
1341 ifneq ($(filter $(TARGET),%(mmake) %(mmake)-includes %(mmake)-quick %(mmake)-kobj %(mmake)-kobj-quick),) # Only for this target these deps are wanted
1343 BD_DFILE_DEPS := $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) \
1344     $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES))
1345 $(BD_DEPS) : $(BD_DFILE_DEPS)
1346 endif
1348 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) \
1349     $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
1350     %(objdir)/Makefile.%(modname) \
1351     $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
1352     $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1353     $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1354     %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
1355     $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
1356     $(BD_DEFLIBDEFSINC) $(addsuffix .c,$(BD_STARTFILES) $(BD_ENDFILES)) \
1357     $(BD_ENDOBJS)
1358 %(mmake)-clean : FILES := $(BD_TOCLEAN)
1359 %(mmake)-clean ::
1360         @$(ECHO) "Cleaning up for module %(modname)"
1361         @$(RM) $(FILES)
1363 endif # $(TARGET) in $(BD_ALLTARGETS)
1364 %end
1365 #------------------------------------------------------------------------------
1368 #------------------------------------------------------------------------------
1369 # Build a module skeleton
1370 # This is a stripped-down version of build_module, it only creates include files,
1371 # but no actual object. This is used when for plugins or classes with the same
1372 # API, but no actual implementation here.
1373 %define build_module_skeleton mmake=/A modname=/A modtype=/A modsuffix= \
1374   conffile= \
1375   objdir=$(OBJDIR) prefix=$(AROSDIR)
1377 # Define metamake targets and their dependencies
1378 #MM- includes-all : %(mmake)-includes
1379 #MM %(mmake) : %(mmake)-includes core-linklibs
1380 #MM %(mmake)-kobj : %(mmake)-includes core-linklibs
1381 #MM %(mmake)-linklib : %(mmake)-includes
1382 #MM %(mmake)-quick : %(mmake)-includes-quick
1383 #MM %(mmake)-includes : %(mmake)-makefile %(mmake)-includes-dirs \
1384 #MM     includes-generate-deps
1385 #MM %(mmake)-includes-quick
1386 #MM %(mmake)-includes-dirs
1387 #MM %(mmake)-makefile
1388 #MM %(mmake)-clean
1390 # All MetaMake targets defined by this macro
1391 BD_ALLTARGETS := %(mmake) %(mmake)-quick %(mmake)-includes \
1392     %(mmake)-includes-quick %(mmake)-includes-dirs %(mmake)-clean \
1393     %(mmake)-kobj
1395 .PHONY : $(BD_ALLTARGETS) %(mmake)-makefile
1397 ifeq (%(modname),)
1398 $(error using %build_module_skeleton: modname may not be empty)
1399 endif
1400 ifeq (%(modtype),)
1401 $(error using %build_module_skeleton: $(MODTYPE) has to be defined with the type of the module)
1402 endif
1404 # Default values for variables and arguments
1405 BD_DEFLINKLIBNAME := %(modname)
1406 BD_DEFDFLAGS := %(cflags)
1407 OBJDIR ?= $(GENDIR)/$(CURDIR)
1409 ## Create genmodule include Makefile for the module
1411 %(mmake)-makefile : %(objdir)/Makefile.%(modname)
1413 %rule_genmodule_makefile \
1414     modname=%(modname) modtype=%(modtype) \
1415     modsuffix=%(modsuffix) targetdir=%(objdir) \
1416     conffile=%(conffile)
1418 %(objdir)/Makefile.%(modname) : | %(objdir)
1420 GLOB_MKDIRS += %(objdir)
1422 # Do not parse these statements if metatarget is not appropriate
1423 ifneq ($(filter $(TARGET),$(BD_ALLTARGETS)),)
1425 include %(objdir)/Makefile.%(modname)
1427 BD_DEFMODDIR := $(%(modname)_MODDIR)
1430 ## include files generation
1432 BD_INCDIR    := %(prefix)/$(AROS_DIR_INCLUDE)
1433 BD_LIBDEFSINC := %(objdir)/include/%(modname)_libdefs.h
1434 BD_DEFLIBDEFSINC := %(objdir)/include/%(modname)_deflibdefs.h
1436 %(mmake)-includes-quick : %(mmake)-includes
1437 %(mmake)-includes : $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1438     $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1439     $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC)
1441 ifneq ($(%(modname)_INCLUDES),)
1442 %rule_genmodule_includes modname=%(modname) modtype=%(modtype) \
1443                          modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1444                          conffile=%(conffile)
1446 %rule_copy_diff_multi \
1447     files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(GENINCDIR) \
1448     stampfile=%(objdir)/%(modname)_geninc
1450 %rule_copy_diff_multi \
1451     files=$(%(modname)_INCLUDES) srcdir=%(objdir)/include targetdir=$(BD_INCDIR) \
1452     stampfile=%(objdir)/%(modname)_incs
1454 BD_INCDIRS := $(filter-out ./,$(sort $(dir $(%(modname)_INCLUDES))))
1456 TMP%(modname)_INCDIRS := \
1457     %(objdir)/include $(addprefix %(objdir)/include/,$(BD_INCDIRS)) \
1458     $(GENINCDIR) $(addprefix $(GENINCDIR)/,$(BD_INCDIRS)) \
1459     $(BD_INCDIR) $(addprefix $(BD_INCDIR)/,$(BD_INCDIRS))
1460 %rule_makedirs dirs=$(TMP%(modname)_INCDIRS) setuptarget=%(mmake)-includes-dirs
1462 endif
1464 %rule_genmodule_genlibdefs modname=%(modname) modtype=%(modtype) \
1465                            modsuffix=%(modsuffix) targetdir=%(objdir)/include \
1466                            conffile=%(conffile)
1468 $(BD_DEFLIBDEFSINC) : FILENAME := $(BD_LIBDEFSINC)
1469 $(BD_DEFLIBDEFSINC) :
1470         @$(ECHO) "generating $@"
1471         @$(ECHO) "#define LC_LIBDEFS_FILE \"$(FILENAME)\"" >$@
1473 $(BD_LIBDEFSINC) $(BD_DEFLIBDEFSINC) : | %(objdir)/include
1474 GLOB_MKDIRS += %(objdir)/include
1476 ## Extra genmodule src files generation
1477 ## 
1478 %rule_genmodule_files modname=%(modname) modtype=%(modtype) \
1479                       modsuffix=%(modsuffix) targetdir=%(objdir) \
1480                       conffile=%(conffile)
1482 BD_TOCLEAN := $(BD_OBJS) $(BD_DEPS) \
1483     $(BD_MODULE) $(BD_LINKLIB) $(BD_KOBJ) \
1484     %(objdir)/Makefile.%(modname) \
1485     $(addprefix %(objdir)/include/,$(%(modname)_INCLUDES)) \
1486     $(addprefix $(GENINCDIR)/,$(%(modname)_INCLUDES)) \
1487     $(addprefix $(BD_INCDIR)/,$(%(modname)_INCLUDES)) \
1488     %(objdir)/%(modname)_geninc %(objdir)/%(modname)_incs \
1489     $(addsuffix .c,$(BD_LINKLIBFILES)) $(BD_LINKLIBOBJS) $(BD_LIBDEFSINC) \
1490     $(BD_DEFLIBDEFSINC)
1491 %(mmake)-clean : FILES := $(BD_TOCLEAN)
1492 %(mmake)-clean ::
1493         @$(ECHO) "Cleaning up for module %(modname)"
1494         @$(RM) $(FILES)
1496 endif # $(TARGET) in $(BD_ALLTARGETS)
1497 %end
1498 #------------------------------------------------------------------------------
1501 #------------------------------------------------------------------------------
1502 # Build a linklib.
1503 # - mmake is the mmaketarget
1504 # - libname is the baselibname e.g. lib%(libname).a will be created
1505 # - files are the C source files to include in the lib. The list of files
1506 #   has to be given without the .c suffix
1507 # - asmfiles are the asm files to include in the lib. The list of files has to
1508 #   be given without the .s suffix
1509 # - objs additional object to link into the linklib. The objects have to be
1510 #   given with full absolute path and the .o suffix.
1511 # - cflags are the flags to compile the source (default $(CFLAGS))
1512 # - dflags are the flags use during makedepend (default equal to cflags)
1513 # - aflags are the flags use during assembling (default $(AFLAGS))
1514 # - objdir is where the .o are generated
1515 # - libdir is the directory where the linklib will be placed (default $(LIBDIR))
1516 %define build_linklib mmake=/A libname=/A \
1517   files="$(basename $(call WILDCARD, *.c))" asmfiles=  objs= \
1518   cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) objdir=$(OBJDIR) libdir=$(LIBDIR)
1520 # assign and generate the local variables used in this macro
1521 OBJDIR        ?= $(GENDIR)/$(CURDIR)
1523 BD_FILES      := %(files)
1524 BD_ASMFILES   := %(asmfiles)
1526 BD_ARCHOBJS   := $(wildcard %(objdir)/arch/*.o)
1527 BD_ARCHFILES  := $(basename $(notdir $(BD_ARCHOBJS)))
1528 BD_NARCHFILES := $(filter-out $(BD_ARCHFILES),$(BD_FILES))
1530 BD_OBJS       := $(BD_ARCHOBJS) \
1531                  $(addsuffix .o,$(addprefix %(objdir)/,$(notdir $(BD_NARCHFILES) $(BD_ASMFILES)))) \
1532                  %(objs)
1533 BD_DEPS       := $(patsubst %.o,%.d,$(BD_OBJS))
1535 BD_CFLAGS     := %(cflags)
1536 ifeq (%(dflags),)
1537 BD_DFLAGS     := $(BD_CFLAGS)
1538 else
1539 BD_DFLAGS     := %(dflags)
1540 endif
1541 BD_AFLAGS     := %(aflags)
1543 BD_LINKLIB    := %(libdir)/lib%(libname).a
1545 .PHONY : %(mmake) %(mmake)-clean
1547 #MM %(mmake) : includes-generate-deps
1548 %(mmake) : $(BD_LINKLIB)
1551 %(mmake)-clean ::
1552         @$(RM) $(BD_OBJS) $(BD_DEPS)
1554 ifeq ($(TARGET),%(mmake))
1555 ifneq ($(dir $(BD_FILES)),./)
1556 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
1557 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir $(BD_FILES)))
1558 endif
1560 %rule_compile basename=% targetdir=%(objdir) \
1561               cflags=$(BD_CFLAGS) dflags=$(BD_DFLAGS)
1562 %rule_assemble basename=% targetdir=%(objdir) \
1563               aflags=$(BD_AFLAGS)
1564 endif
1566 %rule_link_linklib libname=%(libname) objs=$(BD_OBJS) libdir=%(libdir)
1568 %include_deps depstargets=%(mmake) deps=$(BD_DEPS)
1570 $(BD_OBJS) $(BD_DEPS) : | %(objdir)
1571 $(BD_LINKLIB) : | %(libdir)
1572 GLOB_MKDIRS += %(objdir) %(libdir)
1574 %end
1575 #------------------------------------------------------------------------------
1578 #------------------------------------------------------------------------------
1579 # Build catalogs.
1580 # - mmake is the mmaketarget
1581 # - catalogs is the list of catalogs, without the .ct suffix (default *.ct)
1582 # - description is the catalog description file (.cd), without the .ct suffix (default *.cd)
1583 # - subdir is the destination subdirectory of the catalogs
1584 # - name is the name of the destination catalog, without the .catalog suffix
1585 # - source is the path to the generated source code file
1586 # - dir is the base destination directory (default $(AROS_CATALOGS))
1587 # - sourcedescription is the path to the FlexCat's source description file, without the .sd suffix
1588 # - srcdir is the directory in which the *.cd and *.ct files are searched
1590 %define build_catalogs mmake=/A name=/A subdir=/A \
1591  catalogs= source="../strings.h" description= dir=$(AROS_CATALOGS) \
1592  sourcedescription="$(TOOLDIR)/C_h_orig" srcdir="$(SRCDIR)/$(CURDIR)"
1594 ifeq (%(description),)
1595 BD_DESC := $(basename $(wildcard %(srcdir)/*.cd))
1596 else
1597 BD_DESC := %(description)
1598 endif
1600 ifeq (%(catalogs),)
1601 BD_LNGS := $(basename $(notdir $(call WILDCARD, %(srcdir)/*.ct)))
1602 else
1603 BD_LNGS := %(catalogs)
1604 endif
1606 BD_OBJS := $(addsuffix /%(subdir)/%(name).catalog, $(addprefix %(dir)/, $(BD_LNGS)))
1607 BD_DIRS := $(addsuffix /%(subdir), $(addprefix %(dir)/, $(BD_LNGS))) $(dir %(source))
1610 %(mmake) : $(BD_OBJS) %(source)
1612 $(BD_OBJS) : | $(BD_DIRS)
1613 GLOB_MKDIRS += $(BD_DIRS)
1615 %(dir)/%/%(subdir)/%(name).catalog : %(srcdir)/%.ct $(BD_DESC).cd
1616         @$(ECHO) "Creating %(name) catalog for language $*."
1617         @$(FLEXCAT) $(BD_DESC).cd $< CATALOG=%(dir)/$*/%(subdir)/%(name).catalog || [ $$? -lt 10 ]
1619 ifneq (%(source),)
1620 %(source) : TMP_SOURCEDESCRIPTION := $(shell echo %(sourcedescription) | sed 's/^\(.\):\//\/\1\//')
1621 %(source) : $(BD_DESC).cd | $(dir %(source))
1622         @$(ECHO) "Creating %(name) catalog source file %(source)"
1623         @$(FLEXCAT) $(BD_DESC).cd %(source)=$(TMP_SOURCEDESCRIPTION).sd
1624 endif
1627 %(mmake)-clean ::
1628         $(RM) $(BD_OBJS) %(source)
1630 .PHONY: %(mmake) %(mmake)-clean
1632 %end
1633 #-----------------------------------------------------------------------------
1636 #-----------------------------------------------------------------------------
1637 # Build icons.
1638 # - mmake is the mmaketarget
1639 # - icons is a list of icon base names (ie. without the .info suffix)
1640 # - dir is the destination directory
1641 # - srcdir is where *.png and *.info.src are searched
1642 #-----------------------------------------------------------------------------
1644 %define build_icons mmake=/A icons=/A dir=/A srcdir="$(SRCDIR)/$(CURDIR)" image=
1646 BD_OBJS := $(addprefix  %(dir)/, $(addsuffix .info,%(icons)))
1649 %(mmake) : $(BD_OBJS)
1651 ifeq (%(image),)
1653 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%.png
1654         @$(ECHO) Creating $(notdir $@)...
1655         @$(ILBMTOICON) $+ $@
1657 else
1659 %(dir)/%.info : %(srcdir)/%.info.src %(srcdir)/%(image)
1660         @$(ECHO) Creating $(notdir $@)...
1661         @$(ILBMTOICON) $+ $@
1663 endif
1665 $(BD_OBJS) : | %(dir)
1666 GLOB_MKDIRS += %(dir)
1668 %(mmake)-clean : FILES := $(BD_OBJS)
1670 %(mmake)-clean ::
1671         @$(RM) $(FILES)
1673 .PHONY: %(mmake) %(mmake)-clean
1675 %end
1676 #-----------------------------------------------------------------------------
1679 #------------------------------------------------------------------------------
1680 # Compile files for an arch-specific replacement of code for a module
1681 # - files: the basenames of the C files to compile.
1682 # - asmfiles: the basenames of the asm files to assemble.
1683 # - mainmmake: the mmake of the module in the main directory to compile these
1684 #   arch specific files for.
1685 # - maindir: the object directory for the main module
1686 # - arch: the arch for which to compile these files. It can have the form
1687 #   of ARCH, CPU or ARCH-CPU, e.g. linux, i386 or linux-i386
1688 # - cflags (default $(CFLAGS)): the C flags to use for compilation
1689 # - dflags: the flags used during creation of dependency file. If not specified
1690 #   the same value as cflags will be used
1691 # - aflags: the flags used during assembling
1692 # - compiler: (host, kernel or target) specifies which compiler to use. By default
1693 #   the target compiler is used
1694 %define build_archspecific files= asmfiles= mainmmake=/A maindir=/A arch=/A \
1695 cflags=$(CFLAGS) dflags= aflags=$(AFLAGS) compiler=target modulename=
1697 ifeq (%(files) %(asmfiles),)
1698   $(error no files or asmfiles given)
1699 endif
1701 %buildid targets="%(mainmmake)-%(arch)"
1703 #MM- %(mainmmake) :         %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1704 #MM                         %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1705 #MM                         %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1706 #MM- %(mainmmake)-linklib : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1707 #MM                         %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1708 #MM                         %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1709 #MM- %(mainmmake)-kobj :    %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1710 #MM                         %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1711 #MM                         %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1712 #MM- %(mainmmake)-kobj-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1713 #MM                         %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1714 #MM                         %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1715 #MM- %(mainmmake)-quick : %(mainmmake)-$(ARCH)-$(CPU)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH)-$(CPU) \
1716 #MM                         %(mainmmake)-$(ARCH)-$(AROS_TARGET_VARIANT) %(mainmmake)-$(ARCH) \
1717 #MM                         %(mainmmake)-$(FAMILY) %(mainmmake)-$(CPU)
1719 #MM %(mainmmake)-%(arch) : %(mainmmake)-includes
1721 ifeq (%(arch),)
1722   $(error argument arch has to be non empty for the rule_compile_archspecific macro)
1723 endif
1725 BD_OBJDIR$(BDID)  := $(GENDIR)/%(maindir)/arch
1726 BD_COBJS$(BDID)   := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1727 BD_ASMOBJS$(BDID) := $(addsuffix .o,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(asmfiles))))
1728 BD_OBJS$(BDID)    := $(BD_COBJS$(BDID)) $(BD_ASMOBJS$(BDID))
1729 BD_DEPS$(BDID)    := $(addsuffix .d,$(addprefix $(BD_OBJDIR$(BDID))/,$(notdir %(files))))
1731 ifeq ($(TARGET),%(mainmmake)-%(arch))
1732 TMP_SRCDIR := $(shell echo $(SRCDIR) | sed 's/^\(.\):\//\/\1\//')
1733 vpath %.c $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(files)))
1734 vpath %.s $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
1735 vpath %.S $(addprefix $(TMP_SRCDIR)/$(CURDIR)/,$(dir %(asmfiles)))
1736 endif
1738 $(BD_OBJS$(BDID)) : | $(BD_OBJDIR$(BDID))
1739 GLOB_MKDIRS += $(BD_OBJDIR$(BDID))
1742 %(mainmmake)-%(arch) :: $(BD_OBJS$(BDID))
1744 ifeq ($(findstring %(compiler),host kernel target),)
1745   $(error unknown compiler %(compiler))
1746 endif
1747 ifeq (%(compiler),target)
1748 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(TARGET_CC) $(TARGET_CFLAGS)
1749 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(CFLAGS_IQUOTE)
1750 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(CFLAGS_IQUOTE_END)
1751 endif
1752 ifeq (%(compiler),host)
1753 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(HOST_CC)
1754 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(HOST_IQUOTE)
1755 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(HOST_IQUOTE_END)
1756 endif
1757 ifeq (%(compiler),kernel)
1758 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_CMD:=$(KERNEL_CC) $(KERNEL_CFLAGS)
1759 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE:=$(KERNEL_IQUOTE)
1760 $(BD_COBJS$(BDID)) $(BD_DEPS$(BDID)) : TMP_IQUOTE_END:=$(KERNEL_IQUOTE_END)
1761 endif
1762 ifneq (%(modulename),)
1763 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags) -I$(GENDIR)/%(maindir) \
1764                      -include $(GENDIR)/%(maindir)/include/%(modulename)_deflibdefs.h
1765 else
1766 $(BD_COBJS$(BDID)) : TMP_CFLAGS:=%(cflags)
1767 endif
1768 ifeq ($(TARGET),%(mainmmake)-%(arch))
1769 $(BD_OBJDIR$(BDID))/%.o : %.c
1770         %compile_q opt=$(TMP_CFLAGS) cmd=$(TMP_CMD) iquote=$(TMP_IQUOTE) iquote_end=$(TMP_IQUOTE_END)
1771 endif
1773 ifeq (%(dflags),)
1774 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(cflags)
1775 else
1776 $(BD_DEPS$(BDID)) : TMP_DFLAGS:=%(dflags)
1777 endif
1778 ifeq ($(TARGET),%(mainmmake)-%(arch))
1779 $(BD_OBJDIR$(BDID))/%.d : %.c
1780         %mkdepend_q cc=$(TMP_CMD) flags=$(TMP_DFLAGS)
1781 endif
1783 $(BD_ASMOBJS$(BDID)) : AFLAGS:=%(aflags)
1785 ifeq ($(TARGET),%(mainmmake)-%(arch))
1786 $(BD_OBJDIR$(BDID))/%.o : %.s
1787         %assemble_q opt=$(AFLAGS)
1788 $(BD_OBJDIR$(BDID))/%.o : %.S
1789         %assemble_q opt=$(AFLAGS)
1790 endif
1792 %include_deps depstargets=%(mainmmake)-%(arch) deps=$(BD_DEPS$(BDID))
1793 %end
1794 #------------------------------------------------------------------------------
1797 #------------------------------------------------------------------------------
1798 # generate asm files from c files (for debugging purposes)
1799 %define ctoasm_q
1800 %.s : %.c
1801         @$(ECHO) "Generating $(CURDIR)/$(notdir $@)..."
1802         @$(TARGET_CC) -S $(CFLAGS) $(TARGET_CFLAGS) $< -c -o $@
1803 %end
1804 #------------------------------------------------------------------------------
1807 #------------------------------------------------------------------------------
1808 # Copy files from one directory to another.
1810 %define copy_files_q mmake=/A files=$(FILES) src=. dst=/A
1812 %(mmake)_SRC := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
1814 GLOB_MKDIRS += %(dst)
1816 .PHONY : %(mmake)
1819 %(mmake) : | %(dst) 
1820         $(foreach file, %(files), $(shell $(CP) $(addprefix $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC))/, $(file)) $(addprefix %(dst)/, $(file))))
1822 %end
1823 #------------------------------------------------------------------------------
1826 #------------------------------------------------------------------------------
1827 # Copy a directory recursively to another place, preserving the original 
1828 # hierarchical structure
1830 # src: the source directory whose content will be copied
1831 # dst: the directory where to copy src's content. If not existing, it will be made.
1833 %define copy_dir_recursive mmake=/A src=. dst=/A excludefiles=
1835 %(mmake)_SRC   := $(shell echo %(src) | sed 's/^\(.\):\//\/\1\//')
1836 %(mmake)_FILES := $(shell cd $(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC)); find . -path '*/CVS' -prune -o -path '*/.svn' -prune -o -name .cvsignore -prune -o -name mmakefile -prune -o -name mmakefile.src -prune $(%(mmake)_FILTER) -o -type f -print)
1837 %(mmake)_DIRS  := $(sort $(dir $(%(mmake)_FILES)))
1839 %(mmake)_EXCLUDEFILES := $(addprefix ./,%(excludefiles))
1840 %(mmake)_FILES := $(filter-out $(%(mmake)_EXCLUDEFILES),$(%(mmake)_FILES))
1842 GLOB_MKDIRS += $(GENDIR)/$(CURDIR)
1844 .PHONY : %(mmake)
1847 %(mmake): | $(GENDIR)/$(CURDIR)
1848         @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak";        \
1849         $(ECHO) "all: $(addprefix \$$(DST)/,$(%(mmake)_FILES))" > $$m 
1850         @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak";    \
1851         for d in $(%(mmake)_DIRS); do                      \
1852             $(ECHO) "\$$(DST)/$$d: ; $(MKDIR) \$$@" >> $$m;  \
1853         done
1854         @m="$(GENDIR)/$(CURDIR)/%(mmake)-auxiliary.mak";                           \
1855         for f in $(%(mmake)_FILES); do                                            \
1856             $(ECHO) "\$$(DST)/$$f: \$$(SRC)/$$f | \$$(dir \$$(DST)/$$f); $(CP) \$$< \$$@" >> $$m; \
1857         done;  \
1858         for dst in %(dst); do \
1859             $(MAKE) -f $$m DST=$$dst SRC=$(if $(filter /%,$(%(mmake)_SRC)),$(%(mmake)_SRC),$(SRCDIR)/$(CURDIR)/$(%(mmake)_SRC)) all; \
1860         done
1862 %end
1863 #------------------------------------------------------------------------------
1866 #------------------------------------------------------------------------------
1867 #   Copy include files into the includes directories. There are currently
1868 #   two include directories. One for building AROS $(AROS_INCLUDES) and one
1869 #   for building tools that need to run on the host system $(GENINCDIR). The
1870 #   $(GENINCDIR) path must not contain any references to the C runtime
1871 #   library header files.
1873 %define copy_includes mmake=includes-copy includes=$(INCLUDE_FILES) path=. \
1874     dir= compiler=target
1876 ifeq ($(findstring %(compiler),host kernel target),)
1877 $(error %copy_includes: compiler argument (%(compiler)) has to be host, kernel or target)
1878 endif
1880 ifneq (%(dir),)
1881 BD_INCL_FILES := $(subst %(dir),$(GENINCDIR)/%(path),%(includes))
1882 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/%(dir)/
1883 else
1884 BD_INCL_FILES := $(addprefix $(GENINCDIR)/%(path)/,%(includes))
1885 BD_INC_PATH := $(SRCDIR)/$(CURDIR)/
1886 endif
1888 $(BD_INCL_FILES) : $(GENINCDIR)/%(path)/% : $(BD_INC_PATH)%
1889         @$(CP) $< $@
1892 ifeq (%(compiler),target)
1894 ifneq (%(dir),)
1895 BD_INCL_FILES2 := $(subst %(dir),$(AROS_INCLUDES)/%(path),%(includes))
1896 else
1897 BD_INCL_FILES2 := $(addprefix $(AROS_INCLUDES)/%(path)/,%(includes))
1898 endif
1900 BD_INCL_FILES += $(BD_INCL_FILES2)
1902 $(BD_INCL_FILES2) : $(AROS_INCLUDES)/%(path)/% : $(BD_INC_PATH)%
1903         @$(CP) $< $@
1904 endif
1907 %(mmake) : $(BD_INCL_FILES)
1909 .PHONY: %(mmake)
1911 $(BD_INCL_FILES) : | $(dir $(BD_INCL_FILES))
1912 GLOB_MKDIRS += $(dir $(BD_INCL_FILES))
1913 %end
1914 #------------------------------------------------------------------------------
1917 #------------------------------------------------------------------------------
1918 %define make_hidd_stubs hidd=/A cflags=$(CFLAGS) dflags=$(CFLAGS) parenttarget=linklibs
1919 STUBS_SRC := $(addprefix $(SRCDIR)/$(CURDIR)/,$(addsuffix .c,$(STUBS)))
1920 STUBS_MEM := $(addsuffix .o,$(STUBS))
1921 STUBS_OBJ := $(addprefix $(OBJDIR)/,$(STUBS_MEM))
1922 STUBS_DEP := $(addprefix $(OBJDIR)/,$(addsuffix .d,$(STUBS)))
1923 HIDD_LIB := $(AROS_LIB)/libhiddstubs.a
1925 #MM- linklibs : hidd-%(hidd)-stubs
1926 #MM- %(parenttarget): hidd-%(hidd)-stubs
1927 #MM hidd-%(hidd)-stubs : includes includes-copy
1928 hidd-%(hidd)-stubs : setup $(HIDD_LIB)($(STUBS_MEM))
1930 $(HIDD_LIB)($(STUBS_MEM)) : $(STUBS_OBJ)
1931         %mklib_q from=$^
1933 $(STUBS_OBJ) : $(STUBS_SRC) 
1934         %compile_q cmd="$(TARGET_CC) $(TARGET_CFLAGS)" opt=%(cflags) iquote=$(CFLAGS_IQUOTE) iquote_end=$(CFLAGS_IQUOTE_END)
1936 $(STUBS_DEP) : $(STUBS_SRC)
1937         %mkdepend_q flags=%(dflags)
1939 setup ::
1940         %mkdirs_q $(OBJDIR) $(LIBDIR)
1943 clean ::
1944         -@$(RM) $(HIDD_LIB) $(OBJDIR)
1946 DEPS := $(DEPS) $(STUBS_DEP)
1948 %end
1949 #------------------------------------------------------------------------------
1952 #------------------------------------------------------------------------------
1953 # Build an imported source tree which uses the configure script from the
1954 # autoconf package.  This rule will try to "integrate" the produced files as
1955 # much as possible in the AROS build, for example by putting libraries in the
1956 # standard library directory, includes in the standard include directory, and
1957 # so on. You can however override this behaviour.
1959 # As a special "bonus" for you, the PROGDIR environment variable is defined to
1960 # be %(bindir) (or its deduced value) when running "make install", and
1961 # "PROGDIR:" when running "make" alone; you can use this feature to pass the
1962 # configure script some more parameters whose value depends upon the PROGDIR
1963 # env var, so that the program gets all its stuff installed in the proper place
1964 # when building it, but when running it from inside AROS it can also find that
1965 # stuff by simply opening PROGDIR:, which it will do automatically if it uses
1966 # the configuration parameters set when running ./configure
1968 # *NOTICE*: DO NOT put a trailing '/' (slash) after $PROGDIR, as the variable
1969 # already contains either a '/' (slash) or a ':' (colon), thus simply attach it
1970 # to the name which has to follow it.
1973 %define build_with_configure mmake=/A package= srcdir=$(SRCDIR)/$(CURDIR) prefix= \
1974     aros_prefix= extraoptions= nix_dir_layout= nix=no compiler=target \
1975     install_target=install preconfigure= postconfigure= postinstall= \
1976     install_env=
1978 ifneq (%(prefix),)
1979     %(mmake)-prefix := %(prefix)
1980 else
1981     %(mmake)-prefix := $(AROS_CONTRIB)
1982 endif
1984 ifneq (%(aros_prefix),)
1985     %(mmake)-aros_prefix := %(aros_prefix)
1986 else
1987     %(mmake)-aros_prefix := $(%(mmake)-prefix)
1988 endif
1990 ifeq (%(nix),yes)
1991     %(mmake)-nix    := -nix
1992     %(mmake)-volpfx := /
1993     %(mmake)-volsfx := /
1994     
1995     ifeq (%(nix_dir_layout),)
1996         %(mmake)-nix_dir_layout := yes
1997     endif
1998 else
1999     %(mmake)-volsfx := :
2000     
2001     ifeq (%(nix_dir_layout),)
2002         %(mmake)-nix_dir_layout := no
2003     endif
2004 endif
2006 %(mmake)-volfunc = $(%(mmake)-volpfx)$(notdir $1)$(%(mmake)-volsfx)
2008 %(mmake)-install_opts := prefix=$(%(mmake)-prefix) \
2009         exec_prefix=$(%(mmake)-prefix) %(install_env)
2011 # Check if chosen compiler is valid
2012 ifeq ($(findstring %(compiler),host target kernel),)
2013   $(error unknown compiler %(compiler))
2014 endif
2016 # Set legacy 'host' variable based on chosen compiler
2017 ifeq (%(compiler),host)
2018     host := yes
2019         ifeq (%(package),)
2020                 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)
2021         else
2022                 %(mmake)-pkgdir := $(HOSTGENDIR)/$(CURDIR)/%(package)
2023         endif
2024 else
2025     host := no
2026         ifeq (%(package),)
2027                 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)
2028         else
2029                 %(mmake)-pkgdir := $(GENDIR)/$(CURDIR)/%(package)
2030         endif
2031 endif
2033 %(mmake)-configflag := $(%(mmake)-pkgdir)/.configured
2034 %(mmake)-installflag := $(%(mmake)-pkgdir)/.installed
2036 ifeq ($(filter yes, $(%(mmake)-nix_dir_layout) $(host)),yes)
2037     %(mmake)-PROGDIR      := $(%(mmake)-aros_prefix)/bin
2038     %(mmake)-config_opts  := --prefix=$(%(mmake)-aros_prefix)
2039 else
2040     ifeq (%(nix),yes)
2041         %(mmake)-config_opts := --prefix=/PROGDIR  --bindir=/PROGDIR --sbindir=/PROGDIR \
2042         --libdir=/LIB --includedir=/INCLUDE --oldincludedir=/INCLUDE   
2043     else
2044         %(mmake)-config_opts  := --prefix=$(%(mmake)-aros_prefix)
2045     endif
2047     %(mmake)-PROGDIR := $(%(mmake)-aros_prefix)
2048     
2049     %(mmake)-install_opts := bindir=$(%(mmake)-prefix) \
2050         sbindir=$(%(mmake)-prefix) \
2051         libdir=$(AROS_LIB) includedir=$(AROS_INCLUDES) \
2052         oldincludedir=$(AROS_INCLUDES) %(install_env)
2053 endif
2056 .PHONY : %(mmake) %(mmake)-clean %(mmake)-build_and_install-quick
2058 #MM- %(mmake) : setup includes linklibs-core %(mmake)-quick
2060 # Using -j1 in install_command may result in a warning but finally
2061 # it does its job. make install for gcc does not work reliable for -jN
2062 # where N > 1.
2063 ifneq (%(install_target),)
2064     %(mmake)-install_command = \
2065         $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2066         -C $(%(mmake)-pkgdir) %(install_target) -j1 && \
2067         $(TOUCH) $(%(mmake)-installflag)
2069     %(mmake)-uninstall_command = \
2070     $(RM) $(%(mmake)-installflag) && \
2071     $(MAKE) PROGDIR="$(%(mmake)-PROGDIR)/" $(%(mmake)-install_opts) \
2072     -C $(%(mmake)-pkgdir) uninstall
2073 else
2074     %(mmake)-install_command   := true
2075     %(mmake)-uninstall_command := true
2076 endif
2078 #MM- %(mmake)-quick : %(preconfigure) %(mmake)-configure %(postconfigure) %(mmake)-build_and_install-quick %(postinstall)
2081 %(mmake)-build_and_install-quick :  $(%(mmake)-configflag)
2082         if ! $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -q -C $(%(mmake)-pkgdir); then \
2083             $(RM)  $(%(mmake)-installflag) && \
2084             $(MAKE) PROGDIR="$(call %(mmake)-volfunc, PROGDIR)" -C $(%(mmake)-pkgdir) && \
2085             $(%(mmake)-install_command); \
2086         fi
2088 $(%(mmake)-pkgdir)/.files-touched:
2089         %mkdirs_q $(%(mmake)-pkgdir)
2090         find %(srcdir) -exec $(TOUCH) -c -r %(srcdir)/configure '{}' \; && \
2091         $(TOUCH) $@
2094 %(mmake)-uninstall :
2095         $(%(mmake)-uninstall_command)
2097 ifneq ($(DEBUG),yes)
2098     %(mmake)-s_flag = -s
2099 endif
2102 %(mmake)-configure : $(%(mmake)-configflag)
2104 $(%(mmake)-configflag) : TMP_SRCDIR := $(shell echo %(srcdir) | sed 's/^\(.\):\//\/\1\//')
2105 ifeq (%(compiler),host)
2106 $(%(mmake)-configflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2107         $(RM) $@ 
2108         %mkdirs_q $(%(mmake)-pkgdir)
2109         cd $(%(mmake)-pkgdir) && \
2110         find . -name config.cache -exec $(RM) '{}' \; && \
2111         CC="$(HOST_CC) $(HOST_CFLAGS)" \
2112             TARGET_CC="$(KERNEL_CC) $(KERNEL_CFLAGS) $(%(mmake)-s_flag)" \
2113             TARGET_AS="$(TARGET_AS)" OBJCOPY="$(OBJCOPY)" \
2114             $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) %(extraoptions) \
2115             --target=$(AROS_TARGET_CPU)-aros && \
2116             $(TOUCH) $@
2117 endif
2118 ifeq (%(compiler),target)
2119 $(%(mmake)-configflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2120         $(RM) $@
2121         %mkdirs_q $(%(mmake)-pkgdir)
2122         cd $(%(mmake)-pkgdir) && \
2123         find . -name config.cache -exec $(RM) '{}' \; && \
2124         CC="$(TARGET_CC) $(TARGET_CFLAGS) $(LDFLAGS) $(%(mmake)-nix) $(%(mmake)-s_flag)" \
2125             AS="$(TARGET_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)" \
2126             $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) %(extraoptions) \
2127             --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH) \
2128             --host=$(AROS_TARGET_CPU)-aros \
2129             --target=$(AROS_TARGET_CPU)-aros \
2130             --disable-nls \
2131             --without-x --without-pic --disable-shared && \
2132             $(TOUCH) $@
2133 endif
2134 ifeq (%(compiler),kernel)
2135 $(%(mmake)-configflag) : $(%(mmake)-pkgdir)/.files-touched $(TOP)/$(CURDIR)/mmakefile
2136         $(RM) $@
2137         %mkdirs_q $(%(mmake)-pkgdir)
2138         cd $(%(mmake)-pkgdir) && \
2139         find . -name config.cache -exec $(RM) '{}' \; && \
2140         CC="$(KERNEL_CC) $(KERNEL_CFLAGS) $(%(mmake)-s_flag)" \
2141             AS="$(TARGET_AS)" CC_FOR_BUILD="$(HOST_CC)" RANLIB="$(RANLIB)" \
2142             $(TMP_SRCDIR)/configure $(%(mmake)-config_opts) %(extraoptions) \
2143             --build=$(AROS_HOST_CPU)-$(AROS_HOST_ARCH) \
2144             --host=$(AROS_TARGET_CPU)-aros \
2145             --target=$(AROS_TARGET_CPU)-aros --disable-nls \
2146             --without-x --without-pic --disable-shared && \
2147             $(TOUCH) $@
2148 endif
2149         
2151 %(mmake)-clean : %(mmake)-uninstall
2152         @$(RM) $(%(mmake)-pkgdir)
2153 %end
2154 #------------------------------------------------------------------------------
2157 #------------------------------------------------------------------------------
2158 # Given an archive name, patches names and locations where to find them, fetch
2159 # the archive and the patches from any of those locations, unpack the archive
2160 # and then apply the patches.
2162 # Locations currently supported are http and ftp sites, plus local filesystem
2163 # directories. Supported archives are .tar.bz2 and .tar.gz. To modify this,
2164 # the fetch.sh script needs to be modified, since this macro relies on that script.
2166 # Arguments:
2168 #     - mmake           = mmaketarget
2169 #     - archive_origins = list of locations where to find the archive. They are tried
2170 #                         in sequence, until the archive is found and fetching it 
2171 #                         succeeded. If not specified, the current directory is assumed.
2172 #     - archive         = the archive name. Mandatory.
2173 #     - suffixes        = a list of suffixes to append to the the package name plus the
2174 #                         version. Each one of them is tried until a matching archive is
2175 #                         found. They are appended to patches and these are tried the
2176 #                         same way as packages are.
2177 #     - location        = the local directory where to put the fetched archive and patches.
2178 #                         If not specified, the directory specified by destination is used.
2179 #     - destination     = the directory to unpack the archive to.
2180 #                         If not specified, the current directory is assumed.
2181 #     - patches_origins = list of locations where to find the patches. They are tried
2182 #                         in sequence, until a patch is found and fetching it 
2183 #                         succeeded. If not specified, the current directory is assumed.
2184 #     - patches_specs   = list of "patch specs". A patch spec is of the form
2185 #                         patch_name[:[patch_subdir][:patch_opt]].
2187 #                             - patch_name   = the name of the patch file
2188 #                             - patch_subdir = the directory within \destination\ where to
2189 #                                              apply the patch.
2190 #                             - patch_opt    = any options to pass to the `patch' command
2191 #                                              when applying the patch.
2192 #                         
2193 #                         The patch_subdir and patch_opt fields are optional.
2195 %define fetch mmake=/A archive_origins=. archive=/A suffixes= location= destination=. \
2196     patches_origins=$(SRCDIR)/$(CURDIR) patches_specs=::
2198 .PHONY: %(mmake)
2200 ifneq (%(location),)
2201     %(mmake)-location := %(location)
2202 else
2203     %(mmake)-location := %(destination)
2204 endif
2207 %(mmake) :
2208         $(FETCH) -ao "%(archive_origins)" -a %(archive) -s "%(suffixes)" -l $(%(mmake)-location) \
2209         -d %(destination) -po "%(patches_origins)" -p %(patches_specs)
2210 %end
2211 #------------------------------------------------------------------------------
2214 #------------------------------------------------------------------------------
2215 # Joins the features of %fetch and %build_with_configure, taking advantage of
2216 # the naming scheme of GNU packages. GNU packages names are in the form
2218 #     <package name>-<version number>.<archive format suffix>
2220 # If a patch is provided, it *must* be named the following way:
2222 #    <package name>-<version number>-aros.diff
2224 # Moreover, it *must* be appliable with the -p1 option of the `patch' command after
2225 # CD'ing into the archive's extracted directory.
2227 # Note that whilst the %fetch macro accepts a list of patches for any given archive,
2228 # the %fetch_and_build macro only accept *one* patch for each package. It's up to you
2229 # to make that patch fully comprehensive.
2231 # NOTE: GNU packages are always compiled with *nix semantics turned on.
2233 # Arguments:
2235 #    - mmake        = the meta make target, as would be supplied to the %build_with_configure
2236 #                     macro.
2237 #    - package      = the GNU package name, sans version and archive format suffixes.
2238 #    - version      = the package's version number, or otherwise any other version string.
2239 #                     It gets appended to the package name to form the basename of the archive.
2240 #    - suffixes     = a list of suffixes to apped to the the package name plus the
2241 #                     version. Each one of them is tried until a matching archive is found.
2242 #                     Defaults to "tar.bz2 tar.gz".
2243 #    - destination  = same meaning as the one for the %fetch macro
2244 #    - location     = same meaning as the one for the %fetch macro
2245 #    - package_repo = same meaning as the one of the %fetch macro's %(archive_origins) argument
2246 #    - patch        = "yes" or "no", depending on whether a patch for this package needs to be
2247 #                     fetched or not
2248 #    - patch_repo   = same meaning as the one of the %fetch macro's %(patches_origins) argument
2249 #    - prefix       = same meaning as the one for the %build_with_configure macro. Defaults to
2250 #                     $(GNUDIR).
2251 #    - aros_prefix  = same meaning as the one for the %build_with_configure macro. Defaults to
2252 #                     /GNU.
2253 #    - extraoptions = same meaning as the one for the %build_with_configure macro.
2254 #    - postinstall  = same meaning as the one for the %build_with_configure macro.
2255 #    - create_pkg   = create a distributable package of the compiled sources, defaults to no
2257 %define fetch_and_build mmake=/A package=/A subpackage= compiler=target version=/A suffixes="tar.bz2 tar.gz" \
2258     srcdir= package_repo= patch=no patch_repo= prefix= aros_prefix= extraoptions= \
2259     preconfigure= postconfigure= postinstall= nix=no nix_dir_layout= create_pkg=no
2261 #MM- %(mmake)-quick : %(mmake)-%(subpackage)-quick
2262 #MM- %(mmake)-%(subpackage)-quick : %(mmake)-%(subpackage)-fetch
2263 #MM- %(mmake)-fetch : %(mmake)-%(subpackage)-fetch
2264 #MM- %(mmake)-create-patch : %(mmake)-%(subpackage)-create-patch
2266 %(mmake)-archbase  := %(package)-%(version)
2268 ifeq (%(compiler),host)
2269     %(mmake)-portdir  := $(HOSTDIR)/Ports/%(package)
2270 else
2271     %(mmake)-portdir  := $(PORTSDIR)/%(package)
2272 endif
2274 ifeq (%(prefix),)
2275     %(mmake)-prefix := $(CONTRIB_DIR)/%(package)
2276 else
2277     %(mmake)-prefix := %(prefix)
2278 endif
2280 ifneq (%(subpackage),)
2281     %(mmake)-%(subpackage)-archbase  := %(package)-%(subpackage)-%(version)
2282 else
2283     %(mmake)-%(subpackage)-archbase  := %(package)-%(version)
2284 endif
2286 ifneq (%(srcdir),)
2287     %(mmake)-%(subpackage)-srcdir  := %(srcdir)
2288 else
2289     %(mmake)-%(subpackage)-srcdir  := $(%(mmake)-archbase)
2290 endif
2292 ifeq (%(patch),yes)
2293     %(mmake)-%(subpackage)-patches_specs := $(%(mmake)-%(subpackage)-archbase)-aros.diff:$(%(mmake)-%(subpackage)-srcdir):-p1    
2294 else
2295     %(mmake)-%(subpackage)-patches_specs := ::
2296 endif
2298 %fetch mmake=%(mmake)-%(subpackage)-fetch archive=$(%(mmake)-%(subpackage)-archbase) suffixes="%(suffixes)" \
2299     location=$(PORTSSOURCEDIR) destination=$(%(mmake)-portdir) \
2300     archive_origins=". %(package_repo)" \
2301     patches_specs="$(%(mmake)-%(subpackage)-patches_specs)" patches_origins="$(SRCDIR)/$(CURDIR) %(patch_repo)"
2303 #MM- %(mmake) : %(mmake)-%(subpackage)
2305 # If you did some changes to the unpacked sources, call the target below
2306 # to easily create a new patch.
2308 %(mmake)-%(subpackage)-create-patch :
2309         @$(FETCH) -a $(%(mmake)-%(subpackage)-archbase) -s "%(suffixes)" -l $(PORTSSOURCEDIR) -d $(%(mmake)-portdir)/tmp ; \
2310         mv $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase) $(%(mmake)-portdir)/tmp/$(%(mmake)-%(subpackage)-archbase).aros ; \
2311         cd $(%(mmake)-portdir)/tmp ; \
2312         diff -ruN \
2313             $(%(mmake)-%(subpackage)-archbase) \
2314             $(%(mmake)-%(subpackage)-archbase).aros \
2315             >$(SRCDIR)/$(CURDIR)/$(%(mmake)-%(subpackage)-archbase)-aros-new.diff ; \
2316         mv $(%(mmake)-portdir)/tmp/$(%(mmake)-%(subpackage)-archbase).aros $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase) ; \
2317         $(RM) $(%(mmake)-portdir)/tmp
2319 %(mmake)-%(subpackage)-package-dir := $(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-archbase)
2321 %(mmake)-%(subpackage)-package-basename := \
2322     $(DISTDIR)/Packages/$(%(mmake)-%(subpackage)-archbase)-aros.$(AROS_TARGET_CPU)
2324 ifneq (%(create_pkg),no)
2325     %(mmake)-%(subpackage)-package := $(%(mmake)-%(subpackage)-package-basename).tar.bz2
2326 endif
2328 %build_with_configure mmake=%(mmake)-%(subpackage) package=%(package) compiler=%(compiler) \
2329      srcdir=$(%(mmake)-portdir)/$(%(mmake)-%(subpackage)-srcdir) \
2330      nix=%(nix) nix_dir_layout=%(nix_dir_layout) prefix="$(%(mmake)-prefix)" \
2331      aros_prefix="%(aros_prefix)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall) \
2332      %(mmake)-%(subpackage)-make-package"  extraoptions="%(extraoptions)"
2334 .PHONY : %(mmake)-%(subpackage)-make-package %(mmake)-%(subpackage)-create-patch
2335 #MM %(mmake)-%(subpackage)-make-package : %(mmake)-%(subpackage)-quick
2338 %(mmake)-%(subpackage)-make-package : $(%(mmake)-%(subpackage)-package)
2340 #There seems to be a bug, either with my clock or with make, 'cause it may happen
2341 #that $^ and $@ have exactly the same mtime, and in that case make tries
2342 #to rebuild $@ again, which would fail because the directory where
2343 #the package got installed would not exist anymore. 
2344 #We work this around by using an if statement to manually check the mtimes.
2345 $(%(mmake)-%(subpackage)-package-basename).tar.bz2 :
2346         @$(IF) test $(%(mmake)-installflag) -nt $@ || ! test -f $@; then \
2347         $(RM) $@ ; \
2348         $(ECHO) "Building \`$(%(mmake)-%(subpackage)-package-basename).tar.bz2'" ; \
2349         mkdir -p "$(DISTDIR)/Packages" ; \
2350         mkdir -p "$(%(mmake)-prefix)" ; \
2351         cd $(%(mmake)-%(subpackage)-package-dir) ; \
2352         tar -cvf $(%(mmake)-%(subpackage)-package-basename).tar * ; \
2353         bzip2 -9 -f $(%(mmake)-%(subpackage)-package-basename).tar ; \
2354     fi
2355 %end
2356 #------------------------------------------------------------------------------
2359 #------------------------------------------------------------------------------
2360 %define fetch_and_build_gnu mmake=/A package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2361     srcdir= package_repo= patch=no patch_repo= prefix=$(GNUDIR) \
2362     aros_prefix=/GNU extraoptions= preconfigure= postconfigure= postinstall= 
2364 GNU_REPOSITORY := gnu://
2366 %fetch_and_build mmake="%(mmake)" package="%(package)" subpackage="%(subpackage)" version="%(version)" \
2367     suffixes="%(suffixes)" srcdir="%(srcdir)" \
2368     package_repo="%(package_repo) $(GNU_REPOSITORY)%(package)" \
2369     patch="%(patch)" patch_repo="%(patch_repo)" \
2370     prefix="%(prefix)" aros_prefix="%(aros_prefix)" extraoptions="%(extraoptions)" \
2371     preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" nix=yes
2373 %end
2374 #------------------------------------------------------------------------------
2377 #------------------------------------------------------------------------------
2378 # Same job as the one of %fetch_and_build_gnu, except that this one assumes
2379 # that the package is a "Development" package, and as such it needs to be placed
2380 # under the $(AROS_DEVELOPMENT) directory, as a default. 
2382 # All the arguments have the same meaning as the ones of the %fetch_and_build_gnu 
2383 # macro, but notice that %fetch_and_build_gnu_development *doesn't* have a
2384 # "mmake" argument, because the metatarget is implicitely defined as
2386 #     #MM- development-%(package)
2388 %define fetch_and_build_gnu_development package=/A subpackage= version=/A suffixes="tar.bz2 tar.gz" \
2389     srcdir= package_repo= patch=no patch_repo= prefix=$(AROS_DEVELOPMENT) \
2390     aros_prefix=/Development preconfigure= postconfigure= postinstall=  extraoptions= 
2392 #MM- development : development-%(package)
2395 %fetch_and_build_gnu mmake=development-%(package) package=%(package) subpackage="%(subpackage)" \
2396    version=%(version) suffixes="%(suffixes)" srcdir="%(srcdir)"  \
2397    package_repo="%(package_repo)" patch="%(patch)" patch_repo="%(patch_repo)" prefix=%(prefix) \
2398    aros_prefix="%(aros_prefix)" preconfigure="%(preconfigure)" postconfigure="%(postconfigure)" postinstall="%(postinstall)" \
2399    extraoptions="%(extraoptions)"
2400     
2401 %end
2402 #------------------------------------------------------------------------------