]> rtime.felk.cvut.cz Git - l4.git/blob - l4/mk/binary.inc
update
[l4.git] / l4 / mk / binary.inc
1 # -*- Makefile -*-
2 # vim:set ft=make:
3 #
4 # DROPS (Dresden Realtime OPerating System) Component
5 #
6 # Makefile-Include for compiling templates (prog.mk, lib.mk)
7
8 # Makefile-Include for binary and lib directories
9 # Definitions for building the Makefile.inc, building dependencies,
10 # compiler configuration.
11 #
12 # If SYSTEM is defined and we do not clean, we generate Makefile.inc. This file
13 # holds the dependencies of the targets. Is also contains the definitions of
14 # variables holding the objects of the related targets. In a multiple
15 # architecture makefile, Makefile.inc will be built in arch-specific subdirs, 
16 # like the other components built.
17 #
18 # Most compiler- and linker-flag variables are defined in such a way that
19 # using them in the rule will expand all the target- and
20 # architecture-specific definitions.
21 #
22 # The relink-rule is defined in this file.
23 #
24 # The dependencies for compiling files are defined here, the dep-files are
25 # generated with names .(source-file).d for .c, .cc and .S-files.
26 #
27 # Clean-rules are defined here.
28 #
29
30 $(GENERAL_D_LOC): $(L4DIR)/mk/binary.inc $(L4DIR)/mk/modes.inc
31
32 # our default Makefile-name in the OBJ-Subdirs
33 BID_OBJ_Makefile ?= Makefile
34
35 ifeq ($(SYSTEM),) # if we have no system yet, build the subdirs
36 #################################################################
37 #
38 # we have NO system defined in $(SYSTEM), we are in the src/ dir
39 #
40 #################################################################
41
42 # our default systems
43 SYSTEMS ?= x86-l4f amd64-l4f arm-l4f ppc32-l4f
44
45 BID_MISSING_PKGS := \
46    $(strip $(if $(DEPENDS_PKGS), \
47              $(strip $(foreach i,$(DEPENDS_PKGS),            \
48                        $(if $(strip $(wildcard $(L4DIR)/pkg/$(i))   \
49                          $(wildcard $(OBJ_BASE)/pc/$(i).pc)),,$(i))))))
50
51 ifneq ($(BID_MISSING_PKGS),)
52   # clear SYSTEMS to prevent building anything
53   SYSTEMS =
54   text := $(shell echo -e "\033[32mPackage dependencies missing: \033[1m$(BID_MISSING_PKGS)\033[22m; skipping directory '$(SRC_DIR)'.\033[0m")
55   $(if $(BID_FAIL_ON_MISSING),$(error $(text)), $(info $(text)))
56 endif
57
58 # intersection with BUILD_SYSTEMS
59
60 # filter the systems from the local SYSTEMS variable ($2), that match
61 # the build-architecture.
62 # args: $(1) - build architecture (one from BUILD_SYSTEMS)
63 #       $(2) - SYSTEMS
64 # 1. check, if both systems are the same (optionally reduced by the CPU)
65 # 2. check, if at least the arch matches (and optionally the cpu)
66 FILTER_SYSTEM = $(shell echo $(2)|$(AWKP) '\
67                         BEGIN{m=s="$(1)";sub("_[^-]*","",m)}\
68                         {for(i=1;i<=NF;i++){\
69                                 if(m==$$i||s==$$i){print s}else\
70                                 if(index(m,$$i)==1||index(s,$$i)==1)\
71                                         {t=s;sub("-.*","",t);print t}}}')
72
73 # print that system of the SYSTEMS variable that actually matched with
74 # $(BUILD_SYSTEMS) to the given system
75 # args: $(1) - build architecture (SYSTEM)
76 #       $(2) - SYSTEMS
77 # + do nearly the same as in FILTER_SYSTEM, but additionally check if
78 #   the resulting system matches $(1). If so, print the according pattern from
79 #   SYSTEMS and exit
80 BID_ORIG_SYSTEM = $(shell echo $(2)|$(AWKP) '\
81                     BEGIN{m=s="$(1)";sub("_[^-]*","",m)}\
82                     {for(i=1;i<=NF;i++){\
83                         if(m==$$i||s==$$i){if(s=="$(1)"){print $$i;exit}};\
84                         if(index(m,$$i)==1||index(s,$$i)==1)\
85                             {t=s;sub("-.*","",t);\
86                              if(t=="$(1)"){print $$i;exit}}}}')
87
88 ifeq ($(ROLE),idl.mk)
89 TARGET_SYSTEMS := $(sort $(foreach sys,$(sort \
90         $(shell echo $(BUILD_SYSTEMS)|$(SED) -e 's/_[^- ]*\(-\{0,1\}\)/\1/g')), \
91         $(call FILTER_SYSTEM,$(sys),$(SYSTEMS))))
92 else
93 TARGET_SYSTEMS := $(sort $(foreach sys,$(BUILD_SYSTEMS),\
94                         $(call FILTER_SYSTEM,$(sys),$(SYSTEMS))))
95 endif
96
97 DIR_FROM_SUB = $(firstword $(addprefix ../,$(patsubst /%,,$(1))) $(1))
98 SYSTEM_TO_ARCH = $(shell echo $(1)|$(SED) -e 's/[_-].*//')
99 SYSTEM_TO_CPU = $(shell echo $(1)|$(SED) -ne 's/[^-_]*_\([^-]*\).*/\1/p')
100 SYSTEM_TO_L4API = $(shell echo $(1)|$(SED) -ne 's/.*-\(.*\)/\1/p')
101
102 $(foreach sys,$(TARGET_SYSTEMS),$(OBJ_DIR)/OBJ-$(sys)/$(BID_OBJ_Makefile)):$(OBJ_DIR)/OBJ-%/$(BID_OBJ_Makefile):$(OBJ_DIR)/.general.d
103         @install -d $(dir $@)
104         @echo 'L4DIR=$(L4DIR_ABS)'>$@
105         @echo 'OBJ_BASE=$(OBJ_BASE)'>>$@
106         @echo 'OBJ_DIR=$(OBJ_DIR)'>>$@
107         @echo 'SRC_DIR=$(SRC_DIR)'>>$@
108         @echo 'PKGDIR=$(PKGDIR_ABS)'>>$@
109         @echo 'PKGDIR_ABS=$(PKGDIR_ABS)'>>$@
110         @echo 'PKGDIR_OBJ=$(PKGDIR_OBJ)'>>$@
111         @echo 'MAKECONFLOCAL=$(SRC_DIR)/Makeconf.local'>>$@
112         @echo 'OSYSTEM=$(call BID_ORIG_SYSTEM,$*,$(SYSTEMS))'>>$@
113         @echo 'SYSTEM=$*'>>$@
114         @echo 'ARCH=$(call SYSTEM_TO_ARCH,$*)'>>$@
115         @echo 'CPU=$(call SYSTEM_TO_CPU,$*)'>>$@
116         @echo 'L4API=$(call SYSTEM_TO_L4API,$*)'>>$@
117         @echo 'vpath %.c $(VPATH_SRC_BASE)'>>$@
118         @echo 'vpath %.cc $(VPATH_SRC_BASE)'>>$@
119         @echo 'vpath %.cpp $(VPATH_SRC_BASE)'>>$@
120         @echo 'vpath %.S $(VPATH_SRC_BASE)'>>$@
121         @echo 'vpath %.y $(VPATH_SRC_BASE)'>>$@
122         @echo 'vpath %.l $(VPATH_SRC_BASE)'>>$@
123         @echo 'vpath %.ld $(VPATH_SRC_BASE)'>>$@
124         @echo 'vpath %.dpe $(VPATH_SRC_BASE)'>>$@
125         @echo '.general.d: $(SRC_DIR)/$(if $(wildcard Make.rules),Make.rules,Makefile)'>>$@
126         @echo 'include $(SRC_DIR)/$(if $(wildcard Make.rules),Make.rules,Makefile)'>>$@
127         @echo 'include $$(L4DIR)/mk/$(ROLE)'>>$@
128
129 install relink scrub:: $(foreach arch,$(TARGET_SYSTEMS),\
130                                           $(OBJ_DIR)/OBJ-$(arch)/$(BID_OBJ_Makefile))
131         $(if $(TARGET_SYSTEMS),  $(VERBOSE)set -e ; \
132             for d in $(TARGET_SYSTEMS) ; do \
133                 PWD=$OBJ-$$d $(MAKE) -C $(OBJ_DIR)/OBJ-$$d -f $(BID_OBJ_Makefile) \
134                         $@ ; done )
135
136 .PHONY: pre-obj
137 pre-obj::
138
139 all:: $(foreach arch,$(TARGET_SYSTEMS), $(OBJ_DIR)/OBJ-$(arch))
140 .PHONY: $(foreach arch,$(TARGET_SYSTEMS), $(OBJ_DIR)/OBJ-$(arch))
141 $(foreach arch,$(TARGET_SYSTEMS), $(OBJ_DIR)/OBJ-$(arch)):%:%/$(BID_OBJ_Makefile) pre-obj
142         $(VERBOSE)PWD=$@ $(MAKE) $(PL_j) -C $@ -f $(BID_OBJ_Makefile)
143
144
145 foreach_objdir = $(if $(wildcard $(OBJ_DIR)/OBJ-*), $(VERBOSE)set -e ; \
146                      for d in $(wildcard $(OBJ_DIR)/OBJ-*) ; do \
147                        PWD=$$d $(MAKE) -C $$d -f $(BID_OBJ_Makefile) $(1); \
148                      done, @true)
149
150 %.i %.s.i:: export DO_SHOW_RESULT_FILE=y
151 %.i %.s.i::
152         $(call foreach_objdir,$@)
153
154 clean disasm::
155         $(call foreach_objdir,$@)
156
157 cleanall::
158         $(VERBOSE)$(RM) -r $(wildcard $(OBJ_DIR))
159
160 .PHONY: $(TARGET_SYSTEMS)
161
162 else
163 ###############################################################
164 #
165 # we have a system defined in $(SYSTEM), we are in an OBJ- dir
166 #
167 ###############################################################
168
169 all::           $(TARGET)
170
171 disasm: $(TARGET)
172         $(call DISASM_CMD,$(if $(DABIN),$(DABIN),$<))
173
174 expand_libdir_noexc     = $(foreach i,$(1),$(i)/noexc $(i))
175 expand_libdir_reentrant = $(foreach i,$(1),$(i)/r $(i))
176
177 ifneq ($(CONFIG_USE_DROPS_STDDIR),)
178 L4INCDIR ?=     $(addprefix $(OBJ_BASE)/include/$(ARCH)/,$(L4API)) \
179                 $(addprefix $(OBJ_BASE)/include/,$(L4API)) \
180                 $(OBJ_BASE)/include/$(ARCH) \
181                 $(OBJ_BASE)/include \
182                 $(if $(USE_DICE),$(DICE_INCDIR),) \
183                 $(addprefix $(DROPS_STDDIR)/include/$(ARCH)/,$(L4API)) \
184                 $(addprefix $(DROPS_STDDIR)/include/,$(L4API)) \
185                 $(DROPS_STDDIR)/include/$(ARCH) \
186                 $(DROPS_STDDIR)/include
187
188 L4LIBDIR ?=     $(addprefix $(OBJ_BASE)/lib/$(ARCH)_$(CPU)/,$(L4API)) \
189                 $(OBJ_BASE)/lib/$(ARCH)_$(CPU) \
190                 $(OBJ_BASE)/lib \
191                 $(addprefix $(DROPS_STDDIR)/lib/$(ARCH)_$(CPU)/,$(L4API)) \
192                 $(DROPS_STDDIR)/lib/$(ARCH)_$(CPU) \
193                 $(DROPS_STDDIR)/lib
194
195 else
196
197 L4INCDIR ?=     $(addprefix $(OBJ_BASE)/include/$(ARCH)/,$(L4API)) \
198                 $(addprefix $(OBJ_BASE)/include/,$(L4API)) \
199                 $(OBJ_BASE)/include/$(ARCH) \
200                 $(OBJ_BASE)/include \
201                 $(if $(USE_DICE),$(DICE_INCDIR),)
202
203 L4LIBDIR ?=     $(addprefix $(OBJ_BASE)/lib/$(ARCH)_$(CPU)/,$(L4API)) \
204                 $(OBJ_BASE)/lib/$(ARCH)_$(CPU) \
205                 $(OBJ_BASE)/lib
206 endif
207
208 L4LIBDIR_R-y  = $(call expand_libdir_reentrant, $(L4LIBDIR))
209 L4LIBDIR_R-n  = $(L4LIBDIR)
210 L4LIBDIR_NOEXC= $(call expand_libdir_noexc,$(L4LIBDIR_R-$(L4_MULTITHREADED)))
211
212 #
213 # Variables Section
214 #
215 # There is a hierarchy on defining variables depending on the targets they
216 # refer to: Most standard-Make Variables are supported. This includes
217 # LDFLAGS       - options for ld, defined in prog.mk and lib.mk
218 # CPPFLAGS      - options for the c preprocessor, included in CFLAGS
219 # CFLAGS        - options for the c compiler
220 # CXXFLAGS      - options for the c++ compiler
221 # ASFLAGS       - options for the assembler
222 #
223 # Addtitionally, the following varibales are supported:
224 # SRC_C, SRC_CC, SRC_S - .c, .cc, .S source files
225 # CRT0, CRTN    - startup and finish code
226 # LIBS          - additional libs to link (with -l), including paths (-L)
227 # IDL           - interface definition files
228 # TARGET        - targets to ge built
229 #
230 # These variables will be used for all operations with the corresponding
231 # file types. More specific description is possible by using variables with
232 # added specifications. These specifications include a referred element and
233 # the architecture, both optional but in this order, separated by
234 # underscores. The referred element for CPPFLAGS, CFLAGS, CXXFLAGS and
235 # ASFLAGS is the source file. For the other variables, it is one of the
236 # target files. The TARGET variable can only be postfixed by an
237 # architecture.
238 # The specific variables will be used for the target and the referred element
239 # given in the name, additionally to the more general ones.
240 #
241 # Example for a valid specifications:
242 # SRC_C_libxverbose.a = verbose.c   - ar's verbose.o into libxverbose.a, but
243 #                                     not in other libs in the TARGET var.
244
245 include $(L4DIR)/mk/modes.inc
246
247 # select the variable specified in $(1) from the current architecture and
248 # mode. Fall back to "all" architecture if no specific version exists.
249 BID_mode_var= $(if $($(1)_$(ARCH)_$(MODE)),$($(1)_$(ARCH)_$(MODE)),$($(1)_all_$(MODE)))
250
251 BID_SUPPORTED ?= $(call BID_mode_var,BID_SUPPORTED)
252 ifneq ($(BID_SUPPORTED),y)
253 $(error Mode "$(MODE)" is not supported for CPU architecture "$(ARCH)")
254 endif
255
256 LIBCINCDIR    ?= $(call BID_mode_var,LIBCINCDIR)
257 LIBCLIBDIR    ?= $(call BID_mode_var,LIBCLIBDIR)
258 L4_LIBS       ?= $(call BID_mode_var,L4_LIBS)
259 CRT0          ?= $(call BID_mode_var,CRT0)
260 CRTP          ?= $(if $(filter $(CRT0_DEFAULT),$(CRT0)),$(CRTP_DEFAULT),$(CRT0))
261 CRTN          ?= $(call BID_mode_var,CRTN)
262 LDSCRIPT      ?= $(call BID_mode_var,LDSCRIPT)
263 LDFLAGS       += $(call BID_mode_var,LDFLAGS)
264 REQUIRES_LIBS += $(REQUIRES_LIBS_$(ARCH)) $(call BID_mode_var,REQUIRES_LIBS)
265
266 # we do not need to put our FLAG-definitions into a special file if we can
267 # use the target to parameterize it and if it needs not to appear in the deps 
268 #CRT0   =  $(word 1, $(CRT0_$@_$(OSYSTEM)) $(CRT0_$@) $(CRT0_$(OSYSTEM)))
269 #CRTN   =  $(word 1, $(CRTN_$@_$(OSYSTEM)) $(CRTN_$@) $(CRTN_$(OSYSTEM)))
270 LIBS    += $(strip $(LIBS_$(OSYSTEM)) $(LIBS_$@) $(LIBS_$@_$(OSYSTEM)))
271 LIBS    += $(REQUIRES_LIBS_LIST)
272
273 LDFLAGS += $(strip $(LDFLAGS_$(OSYSTEM)) $(LDFLAGS_$@) $(LDFLAGS_$@_$(OSYSTEM)))
274
275 # ---------------------------------
276
277 BID_MISSING_LIBS :=
278
279 # call pkg-config, returns __PKGCONFIG_FAILED__ if the call failed
280 # 1: OBJ_BASE
281 # 2: parameters to pkg-config
282 # 3: list of packages
283 # use L4_BID_PKG_CONFIG because of export-defs, the function is copied
284 L4_BID_PKG_CONFIG = $(PKG_CONFIG)
285 BID_PKG_CONFIG = $(if $(strip $(3)),                                     \
286                    $(shell PKG_CONFIG_LIBDIR=$(1)/pc                     \
287                            PKG_CONFIG_PATH= $(L4_BID_PKG_CONFIG)         \
288                            --define-variable=incdir=$(1)/include/contrib \
289                            $(2) $(3) || echo __PKGCONFIG_FAILED__))
290
291 BID_PKG_CONFIG_FAILED = $(findstring __PKGCONFIG_FAILED__,$(1))
292
293 ifeq ($(BID_MISSING_PKGS),)
294  ifneq ($(SYSTEM),)
295   ifneq ($(REQUIRES_LIBS),)
296    REQUIRES_LIBS_LIST := $(strip $(call BID_PKG_CONFIG,$(OBJ_BASE),--libs,$(REQUIRES_LIBS)))
297    # error handling
298    ifneq ($(call BID_PKG_CONFIG_FAILED,$(REQUIRES_LIBS_LIST)),)
299     BID_MISSING_PKGS := $(strip $(foreach i,$(REQUIRES_LIBS), \
300                           $(if $(filter __PKGCONFIG_FAILED__,$(call BID_PKG_CONFIG,$(OBJ_BASE),--print-errors,$(i))),$(i))))
301     text := $(shell echo -e "\033[31mLibrary dependencies missing: \033[1m$(BID_MISSING_PKGS)\033[22m in directory '$(SRC_DIR)'; aborting.\033[0m")
302     $(if $(BID_MISSING_PKGS),$(info $(text)),$(error $(text)))
303    endif
304
305    # some sanity check
306    ifneq ($(filter libl4re-vfs,$(REQUIRES_LIBS)),)
307      $(error Never include 'libl4re-vfs'!)
308    endif
309   endif
310
311   BID_PKG_CONFIG_CFLAGS := $(call BID_PKG_CONFIG,$(OBJ_BASE),--cflags, $(REQUIRES_CFLAGS) $(REQUIRES_LIBS))
312
313   # error handling
314   ifneq ($(call BID_PKG_CONFIG_FAILED,$(BID_PKG_CONFIG_CFLAGS)),)
315    BID_MISSING_PKGS := $(strip $(foreach i,$(REQUIRES_CFLAGS) $(REQUIRES_LIBS), \
316                           $(if $(filter __PKGCONFIG_FAILED__,$(call BID_PKG_CONFIG,$(OBJ_BASE),--print-errors,$(i))),$(i))))
317    text := $(shell echo -e "\033[31mCflags dependencies missing: \033[1m$(BID_MISSING_PKGS)\033[22m in directory '$(SRC_DIR)'; aborting.\033[0m")
318    $(error $(text))
319   endif
320  endif # SYSTEM
321 endif
322
323 # -----------------------
324
325 # May 2007: force somewhat old hash-style as some(!, independant of the
326 #           actual version) ld now use an other format, no uclibc upstream fix
327 #           available yet, until available, we need:
328 ifeq ($(LD_HAS_HASH_STYLE_OPTION),y)
329 ifneq ($(HOST_LINK),1)
330 LDFLAGS += --hash-style=sysv
331 endif
332 endif
333
334 OPTS    ?= -g -O2 -fno-strict-aliasing
335 WARNINGS?= -Wextra -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(WARNINGS_$@)
336
337 ifeq ($(MODE),host)
338 # never cross compile in host mode
339 SYSTEM_TARGET = 
340 CC            = $(HOST_CC)
341 CXX           = $(HOST_CXX)
342 else
343 # no architecture specific flags in host mode
344 LDFLAGS += $(LDFLAGS_$(ARCH))
345 OPTS    += $(CARCHFLAGS_$(ARCH)) $(CARCHFLAGS_$(ARCH)_$(CPU))
346 endif
347
348 # no link address if build a lib or we're compiling a host program and using
349 # the host linker scripts
350 ifeq ($(ROLE),lib.mk)
351 NO_DEFAULT_RELOC := y
352 endif
353 ifneq ($(HOST_LINK),)
354 NO_DEFAULT_RELOC := y
355 endif
356
357 default_reloc_base = $(firstword $(DEFAULT_RELOC_$(1)) \
358                                  $(DEFAULT_RELOC_$(ARCH)) \
359                                  $(DEFAULT_RELOC) \
360                                  $(if $(NO_DEFAULT_RELOC),,0x01000000))
361 default_reloc = $(if $(call default_reloc_base,$(1)),\
362                      $(if $(RELOC_PHYS), \
363                           $(shell printf "0x%x" $$(($(RAM_BASE) + $(call default_reloc_base,$(1))))), \
364                           $(call default_reloc_base,$(1))))
365
366 # can be overwritten to get the old mode
367 CFLAGS_C99 ?= -std=gnu99
368
369 $(CLIENTIDL:.idl=-client.o): CFLAGS += -ffunction-sections
370 CFLAGS  += $(if $(CONFIG_BID_GCC_OMIT_FP),-fomit-frame-pointer,)
371 CFLAGS  += $(CFLAGS_$(OSYSTEM)) $(CFLAGS_$(<F)) $(CFLAGS_$(<D)) $(CFLAGS_$(<F)_$(OSYSTEM))
372 CFLAGS  += $(CFLAGS_$(L4API))
373 CFLAGS  += $(OPTS) $(WARNINGS)
374 CFLAGS  += -fno-common
375 CFLAGS  += $(CFLAGS_C99)
376 ifneq ($(MODE),host)
377 CFLAGS  += $(GCCNOSTACKPROTOPT)
378 endif
379 DEFINES-$(L4_MULTITHREADED) += -DL4_THREAD_SAFE
380 DEFINES += $(DEFINES_$(OSYSTEM)) $(DEFINES_$(<F)) $(DEFINES_$(<D)) $(DEFINES_$(<F)_$(OSYSTEM))
381 DEFINES += -DSYSTEM_$(subst -,_,$(SYSTEM)) -DARCH_$(ARCH) -DCPUTYPE_$(CPU) -DL4API_$(L4API)
382 DEFINES += $(DEFINES-y)
383 DEFINES += -D_GNU_SOURCE
384 ifdef DEBUG
385 ifeq (,$(filter 0 n N, $(DEBUG)))
386 DEFINES += -DDEBUG
387 endif
388 endif
389
390 CPPFLAGS-DEBUG_MODE = \
391     $(addprefix -include, $(OBJ_BASE)/include/$(ARCH)/l4/sys/kdebug.h) \
392     $(addprefix -include, $(wildcard $(if $(L4API),$(OBJ_BASE)/include/$(ARCH)/$(L4API)/l4/sys/ktrace.h) \
393                                      $(OBJ_BASE)/include/$(ARCH)/l4/sys/ktrace.h)) \
394     -include $(OBJ_BASE)/include/l4/util/kprintf.h \
395     $(if $(L4API),-include $(OBJ_BASE)/include/l4/sys/debugger.h)
396
397 CPPFLAGS+= $(CPPFLAGS_$(OSYSTEM)) $(CPPFLAGS_$(<F)) $(CPPFLAGS_$(<D)) $(CPPFLAGS_$(<F)_$(OSYSTEM))
398 CPPFLAGS+= $(DEFINES)
399 CPPFLAGS+= $(addprefix -I, $(PRIVATE_INCDIR) $(PRIVATE_INCDIR_$(OSYSTEM)) $(PRIVATE_INCDIR_$@) $(PRIVATE_INCDIR_$@_$(OSYSTEM)))
400 CPPFLAGS+= $(if $(CONTRIB_INCDIR),$(addprefix -I$(OBJ_BASE)/include/contrib/,$(CONTRIB_INCDIR)))
401 CPPFLAGS+= $(BID_PKG_CONFIG_CFLAGS)
402 CPPFLAGS+= $(if $(CLIENTIDL)$(SERVERIDL)$(addprefix CLIENTIDL_,$(TARGET))$(addprefix SERVERIDL_,$(TARGET)),$(addprefix -I, $(IDL_PATH)))
403 ifneq ($(MODE),host)
404 CPPFLAGS+= $(addprefix -I, $(L4INCDIR))
405 endif
406 CPPFLAGS+= $(if $(DEBUG_MODE),$(CPPFLAGS-DEBUG_MODE))
407 CPPFLAGS+= $(if $(filter $(L4_MULTITHREADED),y),-DL4_THREAD_SAFE)
408 CPPFLAGS+= $(LIBCINCDIR)
409
410 CXXFLAGS_NOEXC = -DL4_NO_RTTI -fno-rtti -fno-exceptions
411 CXXFLAGS-$(BID_INT_NOEXC) = $(CXXFLAGS_NOEXC)
412
413 CXXFLAGS+= $(if $(CONFIG_BID_GCC_OMIT_FP),-fomit-frame-pointer,)
414 CXXFLAGS+= $(CXXFLAGS_$(OSYSTEM))
415 CXXFLAGS+= $(CXXFLAGS_$(@:.o=.cc))  $(CXXFLAGS_$(@:.o=.cc)_$(OSYSTEM))
416 CXXFLAGS+= $(CXXFLAGS_$(@:.o=.cpp)) $(CXXFLAGS_$(@:.o=.cpp)_$(OSYSTEM))
417 CXXFLAGS+= $(OPTS) $(filter-out -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wno-pointer-sign,$(WARNINGS))
418 CXXFLAGS+= $(CXXFLAGS-y)
419 CXXFLAGS+= -fno-common
420 ifneq ($(MODE),host)
421 CXXFLAGS+= $(GCCNOSTACKPROTOPT)
422 endif
423
424 PICFLAGS = -fPIC -U__PIC__ -D__PIC__=1
425
426 ASFLAGS += $(ASFLAGS_$(ARCH)) $(ASFLAGS_$(@:.o=.S)) $(ASFLAGS_$(@:.o=.S)_$(OSYSTEM))
427 OBJS    += $(strip $(OBJS_$(OSYSTEM)) $(OBJS_$@) $(OBJS_$@_$(OSYSTEM)))
428 ALLOBJS  = $(OBJS) $(foreach target,$(TARGET) $(TARGET_$(OSYSTEM)),\
429                              $(OBJS_$(target)) $(OBJS_$(target)_$(OSYSTEM)))
430 ALLDPI = $(sort $(foreach obj,$(ALLOBJS),$(patsubst %.dpe,%.dpi,\
431                 $(DPE_$(obj:.o=.c)))))
432
433 # implementation of $(CLIENTIDL) and $(SERVERIDL)
434 IDL_TYPE   ?= dice
435 IDL_PKGDIR ?= $(PKGDIR_OBJ)
436 IDL_PATH   ?= $(addsuffix /idl/OBJ-$(ARCH)-$(L4API),$(IDL_PKGDIR))
437 ifneq ($(IDL_TYPE), dice)
438 ifneq ($(IDL_TYPE), corba)
439 $(error IDL_TYPE "$(IDL_TYPE)" not supported.)
440 endif
441 endif
442
443 # A function to deliver the source files generated from IDL-files and
444 # that should be linked to a given target. Used by "targetobjs" to write
445 # the target-objects and in the "Makefile.inc:"-rule to write the IDL_SRC_C-
446 # variables
447 # arg: 1 - target
448 IDL_SRC_Cfn = $(CLIENTIDL:.idl=-client.c) $(SERVERIDL:.idl=-server.c)   \
449               $(foreach inter, $(OSYSTEM) $(1) $(1)_$(OSYSTEM),         \
450                         $(CLIENTIDL_$(inter):.idl=-client.c)            \
451                         $(SERVERIDL_$(inter):.idl=-server.c))
452 IDL_SRC_CCfn = $(CLIENTIDL:.idl=-client.cc) $(SERVERIDL:.idl=-server.cc) \
453               $(foreach inter, $(OSYSTEM) $(1) $(1)_$(OSYSTEM),         \
454                         $(CLIENTIDL_$(inter):.idl=-client.cc)           \
455                         $(SERVERIDL_$(inter):.idl=-server.cc))
456
457 # *all* CLIENTIDLs/SERVERIDLs
458 # needed for the test if we should include the IDL-Path into vpath
459 IDL_ALLCLIENTIDL = $(CLIENTIDL) $(CLIENTIDL_$(OSYSTEM))                 \
460                    $(foreach target,$(TARGET) $(TARGET_$(OSYSTEM)),     \
461                       $(CLIENTIDL_$(target)) $(CLIENTIDL_$(target)_$(OSYSTEM)))
462 IDL_ALLSERVERIDL = $(SERVERIDL) $(SERVERIDL_$(OSYSTEM))                 \
463                    $(foreach target,$(TARGET) $(TARGET_$(OSYSTEM)),     \
464                       $(SERVERIDL_$(target)) $(SERVERIDL_$(target)_$(OSYSTEM)))
465
466 ifneq ($(IDL_ALLCLIENTIDL),)
467 vpath %-client.c $(IDL_PATH)
468 vpath %-client.cc $(IDL_PATH)
469 endif
470 ifneq ($(IDL_ALLSERVERIDL),)
471 vpath %-server.c $(IDL_PATH)
472 vpath %-server.cc $(IDL_PATH)
473 endif
474
475 # generic targetobjs
476 # arg: 1 - target
477 #      2 - infix between the basename and the .o
478 #      3 - additional infix before .o in case of .cc files
479 targetobjs_gen = $(SRC_C:.c=$(2).o) $(SRC_S:.S=$(2).o)                  \
480                  $(SRC_CC:.cc=$(2)$(3).o)                               \
481                  $(foreach inter, $(OSYSTEM) $(1) $(1)_$(OSYSTEM),      \
482                      $(SRC_C_$(inter):.c=$(2).o)                        \
483                      $(SRC_S_$(inter):.S=$(2).o)                        \
484                      $(SRC_CC_$(inter):.cc=$(2)$(3).o))                 \
485                  $(patsubst %.c,%$(2).o,$(call IDL_SRC_Cfn,$(1)))
486
487 # a helper function to generate the object-files for a given target
488 # arg: 1 - target
489 #      2 - infix between the basename and the .o
490 targetobjs   = $(call targetobjs_gen,$(1),$(2),)
491
492 # special version of targetobjs that shares objects between exception and
493 # non-exception cases, we just need two versions for C++ files
494 # arg: 1 - target
495 #      2 - infix between the basename and the .o or .ne.o
496 targetobjs_ne = $(call targetobjs_gen,$(1),$(2),.ne)
497
498 # The directories our object files will go into. These dirs will be created
499 # on generation of Makefile.inc in the OBJ- dirs.
500 OBJDIRS = $(strip $(sort $(filter-out ./,$(dir                          \
501                 $(foreach t,$(TARGET_STANDARD),                         \
502                         $(call targetobjs,$(t),))                       \
503                 $(foreach t,$(TARGET_STANDARD_NE),                      \
504                         $(call targetobjs,$(t),.ne))                    \
505                 $(foreach t,$(TARGET_SHARED),                           \
506                         $(call targetobjs,$(t),))                       \
507                 $(foreach t,$(TARGET_SHARED_NE),                        \
508                         $(call targetobjs,$(t),.ne))                    \
509                 $(foreach t,$(PROFILE),                                 \
510                         $(call targetobjs,$(t),.pr))                    \
511                 $(foreach t,$(TARGET_PROFILE_PIC) $(TARGET_PROFILE_SHARED),\
512                 $(call targetobjs,$(t),.pr.s))))))
513
514 # The include file for the Makefile. This file contains definitions and
515 # dependencies which are dynamically generated. Unfortunately, make does
516 # not support variable declarations using the foreach function. Same
517 # for rules.
518 $(BID_OBJ_Makefile).inc: .general.d
519         @$(BUILD_MESSAGE)
520         @$(ECHO) "# automatically generated, do not edit!" >$@_
521         # write helper variables containing the IDL-C-Sources
522         @$(ECHO) -en '$(strip $(foreach target,$(TARGET),               \
523                 \nIDL_SRC_C_$(target)=$(call IDL_SRC_Cfn,$(target))))'>>$@_
524         # and add them to SRC_C
525         @$(ECHO) -en '$(strip $(foreach target,$(TARGET),               \
526                 \nSRC_C_$(target) += $$(IDL_SRC_C_$(target))))'>>$@_
527         # but set the variables empty for the current rule
528         @$(ECHO) -en '$(strip $(foreach target,$(TARGET),               \
529                 \n$(BID_OBJ_Makefile).inc: IDL_SRC_C_$(target)=))'>>$@_
530         # write helper variables containing the IDL-C++-Sources
531         @$(ECHO) -en '$(strip $(foreach target,$(TARGET),               \
532                 \nIDL_SRC_CC_$(target)=$(call IDL_SRC_CCfn,$(target))))'>>$@_
533         # and add them to SRC_CC
534         @$(ECHO) -en '$(strip $(foreach target,$(TARGET),               \
535                 \nSRC_CC_$(target) += $$(IDL_SRC_CC_$(target))))'>>$@_
536         # but set the variables empty for the current rule
537         @$(ECHO) -en '$(strip $(foreach target,$(TARGET),               \
538                 \n$(BID_OBJ_Makefile).inc: IDL_SRC_CC_$(target)=))'>>$@_
539         # write the object declaration variables
540         # TARGET_{STANDARD, PIC, SHARED, STANDARD_NE, SHARED_NE}
541         #    contain the appropriate targets
542         # TARGET_PROFILE_{STANDARD, PIC, SHARED} as well
543         @$(ECHO) -en '$(strip $(foreach target,$(TARGET_STANDARD),      \
544                 \nOBJS_$(target) += $(call targetobjs,$(target),)))' >>$@_
545         @$(ECHO) -en '$(strip $(foreach target,$(TARGET_STANDARD_NE),   \
546                 \nOBJS_$(target) += $(call targetobjs_ne,$(target),)))' >>$@_
547         @$(ECHO) -en '$(strip $(foreach target,$(TARGET_PIC) $(TARGET_SHARED), \
548                 \nOBJS_$(target) += $(call targetobjs,$(target),.s)))' >>$@_
549         @$(ECHO) -en '$(strip $(foreach target,$(TARGET_PIC_NE) $(TARGET_SHARED_NE), \
550                 \nOBJS_$(target) += $(call targetobjs_ne,$(target),.s) \
551                 \nLINK_WITH_NOEXC_LIBS_$(target) = y))' >>$@_
552         @$(ECHO) -en '$(strip $(foreach target,$(TARGET_PROFILE),       \
553                 \nOBJS_$(target) += $(call targetobjs,$(target),.pr)))' >>$@_
554         @$(ECHO) -e '$(strip $(foreach target,$(TARGET_PROFILE_PIC) $(TARGET_PROFILE_SHARED),           \
555                 \nOBJS_$(target) += $(call targetobjs,$(target),.pr.s)))' >>$@_
556         #
557         # write the dpe-dependencies
558         @$(ECHO) -e '$(foreach obj,$(sort                               \
559                 $(foreach t,$(TARGET_STANDARD),$(call targetobjs,$t))   \
560                 $(foreach t,$(TARGET_PIC) $(TARGET_SHARED),             \
561                         $(call targetobjs,$t,.s))                       \
562                 $(foreach t,$(TARGET_PROFILE),$(call targetobjs,$t,.pr)) \
563                 $(foreach t,$(TARGET_PROFILE_PIC) $(TARGET_PROFILE_SHARED),\
564                         $(call targetobjs,$t,.pr.s))),$(strip           \
565                 $(addprefix \n$(obj): ,$(patsubst %.dpe,%.dpi,          \
566                 $(DPE_$(obj:.o=.c)) $(DPE_$(obj:.o=.cc))                \
567                 $(DPE_$(obj:.s.o=.c)) $(DPE_$(obj:.s.o=.cc))            \
568                 $(DPE_$(obj:.pr.o=.c)) $(DPE_$(obj:.pr.o=.cc))          \
569                 $(DPE_$(obj:.pr.s.o=.c)) $(DPE_$(obj:.pr.s.o=.cc))      \
570                 ))))' >>$@_
571         #
572         # create the object-dirs
573         @$(if $(OBJDIRS), $(VERBOSE)set -e; for d in $(OBJDIRS); do     \
574                 [ -d "$$d" ] || $(MKDIR) $$d; done )
575         @[ -d "noexc" ] || $(MKDIR) noexc
576         @[ -d "r" ] || $(MKDIR) r
577
578         #
579         # write the object-dependencies for the targets
580         @$(ECHO) -e '$(foreach target,$(TARGET),$(strip\
581                   \n$(target): $$(OBJS_$(target)) ))' >> $@_
582         # make the target dependent on '.general.d'
583         @$(ECHO) -e '$(foreach target,$(TARGET),$(strip                 \
584                   \n$$(OBJS_$(target)): .general.d))'                   \
585                 >> $@_
586         # Using LDSO does not need a RELOC address, so omit the following in
587         # this case
588 ifneq ($(MODE),shared)
589         # in case of a binary, write the link address
590         # the dependency to the static file: If DEFAULT_RELOC is set,
591         # all targets are made dependent on the STATIC file
592         # (defined in Makeconf).
593         # If DEFAULT_RELOC_xxx is set, xxx is made dependent on the
594         # STATIC file.
595 ifneq ($(strip $(foreach target,$(TARGET), $(call default_reloc,$(target)))),)
596 ifneq ($(filter l4linux host,$(MODE)),)
597         $(error DEFAULT_RELOC must not be set if MODE is l4linux or host)
598 endif
599         # the relocatable binaries depend on Makefile.inc
600         @$(ECHO) -e '\n$(strip                                           \
601                 $(foreach target, $(TARGET),                             \
602                         $(if $(call default_reloc,$(target)),$(target))) \
603                 : $@)' >>$@_
604 ifneq ($(wildcard $(STATICFILE)),)
605         # Makefile.inc depends on STATIC
606         @$(ECHO) -e '\n$@: $(firstword $(wildcard $(STATICFILE)))' >>$@_
607         # we find out the relocation address here.
608         @$(ECHO) -e '$(foreach target, $(TARGET),$(strip                \
609                 \nLDFLAGS_$(target)+= -Ttext=$(firstword                \
610                         $(shell $(AWKP) -v prog=$(target)               \
611                                 "/^[^\#]/{if(\$$2==prog){print $$1; exit}}" \
612                                 < $(firstword $(wildcard $(STATICFILE)))) \
613                         $(call default_reloc,$(target)))))'     \
614                 >>$@_
615         # and the dummy-rule to rebuild myself if STATIC disappears
616         @$(ECHO) -e '\n$(firstword $(wildcard $(STATICFILE))): ' >>$@_
617 else
618         # STATIC does not exist. rebuild myself if STATIC appears
619         @$(ECHO) -e '\n$$(if $$(wildcard $(STATICFILE)), $@: FORCE)'    \
620                 >>$@_
621         # we find out the relocation address here.
622         @$(ECHO) -e '$(foreach target, $(TARGET),$(strip                \
623                 \nLDFLAGS_$(target)+= -Ttext=$(firstword                \
624                         $(call default_reloc,$(target)))))'     \
625                 >>$@_
626 endif # STATIC file
627 endif
628 endif # MODE != shared
629         @mv $@_ $@
630
631 ifeq ($(filter scrub help,$(MAKECMDGOALS)),)
632 -include $(BID_OBJ_Makefile).inc
633 endif
634
635 #
636 # Rules Section
637 #
638
639 # the default target "all" ensures building of the targets. When multiple
640 # architectures are used, the targets are build in subdirs.
641
642 # the relink-rule: make the TARGETs phony. Specification of build-targets 
643 # in MAKECMDGOALS is not allowed. Possibility: TARGET=
644 #
645 ifneq ($(filter relink,$(MAKECMDGOALS)),)
646 .PHONY: $(TARGET)
647 relink: all
648 endif
649
650
651
652 ###
653 #
654 # Compilation rules with dependency-generation
655 #
656 # If we have ld.so, we use it to create our dependencies (see MAKEDEP
657 # definition). Otherwise, we fall back to whatever we need. For
658 # compilation with gcc, this is using "-MD" and postprocessing the
659 # generated files.
660
661 ifeq ($(CONFIG_HAVE_LDSO),)
662 LIBDEPS = $(foreach file, \
663                     $(patsubst -l%,lib%.a,$(filter-out -L%,$(LDFLAGS))) \
664                     $(patsubst -l%,lib%.so,$(filter-out -L%,$(LDFLAGS))),\
665                     $(word 1, $(foreach dir, \
666                            $(patsubst -L%,%,\
667                            $(filter -L%,$(LDFLAGS) $(L4ALL_LIBDIR))),\
668                       $(wildcard $(dir)/$(file)))))
669
670 DEPEND_EXTEND_CMD = $(AWKP) '                   \
671 /^[^:]*: ..*/{                                  \
672         while(sub("\\\\$$","")){                \
673                 getline nextline ;              \
674                 $$0=$$0 " " nextline            \
675         }                                       \
676         split($$0,field,": ");                  \
677         sub("^$(*F).o","$*.s $*.i $@",field[1]);        \
678         nr=split(field[2],deps) ;               \
679         for(i=1;i<=nr;){                        \
680           printf("ifeq ($$(shell test y \\\n"); \
681           for(j=0; j<100 && i+j<=nr; j++){      \
682             printf("-a -r %s \\\n", deps[i+j]); \
683           }                                     \
684           printf("&& echo y),)");               \
685           printf("\n%s: FORCE\nelse\n%s: $(BID_OBJ_Makefile) \\\n",     \
686                 field[1],field[1]);             \
687           for(j=0; j<100 && i+j<=nr; j++){      \
688             printf("%s \\\n",deps[i+j]);        \
689           }                                     \
690           printf("\nendif\n");                  \
691           i+=j;                                 \
692         }                                       \
693 }'
694 DEPEND_EXTEND_FUNC = ( $(DEPEND_EXTEND_CMD) < $(1) > $(2).new && rm -f $(1) && mv $(2).new $(2) ) || ( rm -f $(1) $(2).new $(2) ; $(DEPEND_IGNORE_ERRORS) )
695 DEPEND_FLAG = -MD
696
697 .PHONY: FORCE
698 endif # CONFIG_HAVE_LDSO empty
699
700 %.o:    %.cc
701         @$(COMP_MESSAGE)
702         $(VERBOSE)$(call MAKEDEP,$(INT_CXX_NAME)) $(CXX) -c $(DEPEND_FLAG) $(CPPFLAGS) $(CXXFLAGS) $(call absfilename,$<) -o $@
703         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
704
705 %.ne.o: %.cc
706         @$(COMP_MESSAGE)
707         $(VERBOSE)$(call MAKEDEP,$(INT_CXX_NAME)) $(CXX) -c $(DEPEND_FLAG) $(CPPFLAGS) $(CXXFLAGS_NOEXC) $(CXXFLAGS) $(call absfilename,$<) -o $@
708         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
709
710 %.s.o:  %.cc
711         @$(COMP_MESSAGE)
712         $(VERBOSE)$(call MAKEDEP,$(INT_CXX_NAME)) $(CXX) -c $(DEPEND_FLAG) $(CPPFLAGS) $(CXXFLAGS) $(PICFLAGS) $(call absfilename,$<) -o $@
713         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
714
715 %.s.ne.o: %.cc
716         @$(COMP_MESSAGE)
717         $(VERBOSE)$(call MAKEDEP,$(INT_CXX_NAME)) $(CXX) -c $(DEPEND_FLAG) $(CPPFLAGS) $(CXXFLAGS_NOEXC) $(CXXFLAGS) $(PICFLAGS) $(call absfilename,$<) -o $@
718         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
719
720 %.pr.o: %.cc
721         @$(COMP_MESSAGE)
722         $(VERBOSE)$(call MAKEDEP,$(INT_CXX_NAME)) $(CXX) -c $(DEPEND_FLAG) $(CPPFLAGS) $(CXXFLAGS) -DPROFILE -pg $(call absfilename,$<) -o $@
723         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
724
725 %.pr.s.o: %.cc
726         @$(COMP_MESSAGE)
727         $(VERBOSE)$(call MAKEDEP,$(INT_CXX_NAME)) $(CXX) -c $(DEPEND_FLAG) $(CPPFLAGS) $(CXXFLAGS) $(PICFLAGS) -DPROFILE -pg $(call absfilename,$<) -o $@
728         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
729
730 %.o:    %.cpp
731         @$(COMP_MESSAGE)
732         $(VERBOSE)$(call MAKEDEP,$(INT_CXX_NAME)) $(CXX) -c $(DEPEND_FLAG) $(CPPFLAGS) $(CXXFLAGS) $(call absfilename,$<) -o $@
733         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
734
735 %.s.o:  %.cpp
736         @$(COMP_MESSAGE)
737         $(VERBOSE)$(call MAKEDEP,$(INT_CXX_NAME)) $(CXX) -c $(DEPEND_FLAG) $(CPPFLAGS) $(CXXFLAGS) $(PICFLAGS) $(call absfilename,$<) -o $@
738         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
739
740 %.pr.o: %.cpp
741         @$(COMP_MESSAGE)
742         $(VERBOSE)$(call MAKEDEP,$(INT_CXX_NAME)) $(CXX) -c $(DEPEND_FLAG) $(CPPFLAGS) $(CXXFLAGS) -DPROFILE -pg $(call absfilename,$<) -o $@
743         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
744
745 %.pr.s.o: %.cpp
746         @$(COMP_MESSAGE)
747         $(VERBOSE)$(call MAKEDEP,$(INT_CXX_NAME)) $(CXX) -c $(DEPEND_FLAG) $(CPPFLAGS) $(CXXFLAGS) $(PICFLAGS) -DPROFILE -pg $(call absfilename,$<) -o $@
748         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
749
750 %.o:    %.c
751         @$(COMP_MESSAGE)
752         $(VERBOSE)$(call MAKEDEP,$(INT_CPP_NAME)) $(CC) -c $(DEPEND_FLAG) $(CPPFLAGS) $(CFLAGS) $(call absfilename,$<) -o $@
753         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
754
755 %.s.o:  %.c
756         @$(COMP_MESSAGE)
757         $(VERBOSE)$(call MAKEDEP,$(INT_CPP_NAME)) $(CC) -c $(DEPEND_FLAG) $(CPPFLAGS) $(CFLAGS) $(PICFLAGS) $(call absfilename,$<) -o $@
758         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
759
760 %.pr.o: %.c
761         @$(COMP_PR_MESSAGE)
762         $(VERBOSE)$(call MAKEDEP,$(INT_CPP_NAME)) $(CC) -c $(DEPEND_FLAG) $(CPPFLAGS) $(CFLAGS) -DPROFILE -pg $(call absfilename,$<) -o $@
763         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
764
765 %.pr.s.o: %.c
766         @$(COMP_PR_MESSAGE)
767         $(VERBOSE)$(call MAKEDEP,$(INT_CPP_NAME)) $(CC) -c $(DEPEND_FLAG) $(CPPFLAGS) $(CFLAGS) $(PICFLAGS) -DPROFILE -pg $(call absfilename,$<) -o $@
768         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
769
770 %.o:    %.S
771         @$(COMP_MESSAGE)
772         $(VERBOSE)$(call MAKEDEP,$(INT_CPP_NAME)) $(CC) -c $(DEPEND_FLAG) $(CPPFLAGS) $(ASFLAGS) $(call absfilename,$<) -o $@
773         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
774
775 %.s.o:  %.S
776         @$(COMP_MESSAGE)
777         $(VERBOSE)$(call MAKEDEP,$(INT_CPP_NAME)) $(CC) -c $(DEPEND_FLAG) $(CPPFLAGS) $(ASFLAGS) $(PICFLAGS) $(call absfilename,$<) -o $@
778         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
779
780 %.pr.o: %.S
781         @$(COMP_MESSAGE)
782         $(VERBOSE)$(call MAKEDEP,$(INT_CPP_NAME)) $(CC) -c $(DEPEND_FLAG) $(CPPFLAGS) $(ASFLAGS) -DPROFILE -pg $(call absfilename,$<) -o $@
783         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
784
785 %.pr.s.o: %.S
786         @$(COMP_MESSAGE)
787         $(VERBOSE)$(call MAKEDEP,$(INT_CPP_NAME)) $(CC) -c $(DEPEND_FLAG) $(CPPFLAGS) $(ASFLAGS) $(PICFLAGS) -DPROFILE -pg $(call absfilename,$<) -o $@
788         $(DEPEND_VERBOSE)$(call DEPEND_EXTEND_FUNC, $(*F).d, $(dir $@).$(notdir $@).d)
789
790 %.c:    %.y
791         @$(GEN_MESSAGE)
792         $(VERBOSE)$(CONFIG_YACC) $(YFLAGS) $(call absfilename,$<)
793         $(VERBOSE)mv -f y.tab.c $@
794         $(VERBOSE)if [ -f y.tab.h ]; then mv -f y.tab.h $(@:.c=.h); fi
795
796 %.c:    %.l
797         @$(COMP_MESSAGE)
798         $(VERBOSE)$(CONFIG_LEX) -o$@ $(call absfilename,$<)
799
800 %.i:    %.c FORCE
801         @$(COMP_MESSAGE)
802         $(VERBOSE)$(CC) -E -H -dD $(CPPFLAGS) $(CFLAGS) $(call absfilename,$<) -o $@
803         $(VERBOSE)$(INDENT) -o $@ $@
804         $(VERBOSE)$(if $(DO_SHOW_RESULT_FILE),$(PAGER) $@)
805
806 %.s.i:  %.c FORCE
807         @$(COMP_MESSAGE)
808         $(VERBOSE)$(CC) -E -H -dD $(CPPFLAGS) $(CFLAGS) $(PICFLAGS) $(call absfilename,$<) -o $@
809         $(VERBOSE)$(INDENT) -o $@ $@
810         $(VERBOSE)$(if $(DO_SHOW_RESULT_FILE),$(PAGER) $@)
811
812 %.i:    %.cc FORCE
813         @$(COMP_MESSAGE)
814         $(VERBOSE)$(CXX) -E -H -dD $(CPPFLAGS) $(CXXFLAGS) $(call absfilename,$<) -o $@
815         $(VERBOSE)$(INDENT) -sob -o $@ $@
816         $(VERBOSE)$(if $(DO_SHOW_RESULT_FILE),$(PAGER) $@)
817
818 %.s.i:  %.cc FORCE
819         @$(COMP_MESSAGE)
820         $(VERBOSE)$(CXX) -E -H -dD $(CPPFLAGS) $(CXXFLAGS) $(PICFLAGS) $(call absfilename,$<) -o $@
821         $(VERBOSE)$(INDENT) -sob -o $@ $@
822         $(VERBOSE)$(if $(DO_SHOW_RESULT_FILE),$(PAGER) $@)
823
824 %.i:    %.cpp FORCE
825         @$(COMP_MESSAGE)
826         $(VERBOSE)$(CXX) -E -H -dD $(CPPFLAGS) $(CXXFLAGS) $(call absfilename,$<) -o $@
827         $(VERBOSE)$(INDENT) -sob -o $@ $@
828         $(VERBOSE)$(if $(DO_SHOW_RESULT_FILE),$(PAGER) $@)
829
830 %.i:    %.S FORCE
831         @$(COMP_MESSAGE)
832         $(VERBOSE)$(CC) -E -H -dD $(CPPFLAGS) $(ASFLAGS) $(call absfilename,$<) -o $@
833         $(VERBOSE)$(INDENT) -sob -o $@ $@
834         $(VERBOSE)$(if $(DO_SHOW_RESULT_FILE),$(PAGER) $@)
835
836 %.S:    %.c FORCE
837         @$(COMP_MESSAGE)
838         $(VERBOSE)$(CC) -S $(CFLAGS) $(CPPFLAGS) $(call absfilename,$<) -fverbose-asm -o $@
839
840 %.S:    %.cc FORCE
841         @$(COMP_MESSAGE)
842         $(VERBOSE)$(CXX) -S $(CXXFLAGS) $(CPPFLAGS) $(call absfilename,$<) -fverbose-asm -o $@
843
844 %.S:    %.cpp FORCE
845         @$(COMP_MESSAGE)
846         $(VERBOSE)$(CXX) -S $(CXXFLAGS) $(CPPFLAGS) $(call absfilename,$<) -fverbose-asm -o $@
847
848 %.dpi:  %.dpe
849         @$(GEN_MESSAGE)
850         $(VERBOSE)$(call MAKEDEP,perl) $(GEN_DOPECODE) $< >$@
851
852 DEPS    += $(foreach file,$(ALLOBJS), $(dir $(file)).$(notdir $(file)).d)
853 DEPS    += $(foreach file,$(ALLDPI), $(dir $(file)).$(notdir $(file)).d)
854
855 # Common clean Rules
856
857 clean cleanall::
858         $(VERBOSE)$(RM) $(strip $(filter-out $(KEEP_ON_CLEAN),\
859                 $(wildcard *.dpi) $(wildcard *.o) $(wildcard *.i) \
860                 $(wildcard *.S) $(ALLOBJS) $(DEL_ON_CLEAN)))
861
862 # clean: delete all temporary editor files, objects, binaries
863 #        and most generated files
864 cleanall::
865         $(VERBOSE)$(RM) $(TARGET) $(wildcard .*.d) $(wildcard $(BID_OBJ_Makefile).inc)
866
867 .PHONY: scrub clean cleanall disasm
868
869 endif   # $(SYSTEM) is defined
870
871 # General rules
872
873 # scrub: delete temporary editor files and stuff like this
874 #        can be extended by lokals
875 scrub cleanall::
876         $(VERBOSE)$(SCRUB)
877