1 #=============================================================================
5 # Generic rules for inclusion by all package makefiles.
7 #=============================================================================
8 #####ECOSGPLCOPYRIGHTBEGIN####
9 ## -------------------------------------------
10 ## This file is part of eCos, the Embedded Configurable Operating System.
11 ## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
13 ## eCos is free software; you can redistribute it and/or modify it under
14 ## the terms of the GNU General Public License as published by the Free
15 ## Software Foundation; either version 2 or (at your option) any later version.
17 ## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18 ## WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 ## You should have received a copy of the GNU General Public License along
23 ## with eCos; if not, write to the Free Software Foundation, Inc.,
24 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 ## As a special exception, if other files instantiate templates or use macros
27 ## or inline functions from this file, or you compile this file and link it
28 ## with other works to produce a work based on this file, this file does not
29 ## by itself cause the resulting work to be covered by the GNU General Public
30 ## License. However the source code for this file must still be made available
31 ## in accordance with section (3) of the GNU General Public License.
33 ## This exception does not invalidate any other reasons why a work based on
34 ## this file might be covered by the GNU General Public License.
36 ## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37 ## at http://sources.redhat.com/ecos/ecos-license/
38 ## -------------------------------------------
39 #####ECOSGPLCOPYRIGHTEND####
40 #=============================================================================
41 #####DESCRIPTIONBEGIN####
46 # Purpose: Generic rules for inclusion by all package makefiles
49 #####DESCRIPTIONEND####
50 #=============================================================================
52 # FIXME: This definition belongs in the top-level makefile.
55 .PHONY: default build clean tests headers mlt_headers
57 # include any dependency rules generated previously
58 ifneq ($(wildcard *.deps),)
59 include $(wildcard *.deps)
62 # GCC since 2.95 does -finit-priority by default so remove it from old HALs
63 CFLAGS := $(subst -finit-priority,,$(CFLAGS))
65 # -fvtable-gc is known to be broken in all recent GCC.
66 CFLAGS := $(subst -fvtable-gc,,$(CFLAGS))
68 # To support more recent GCC whilst preserving existing behaviour, we need
69 # to increase the inlining limit globally from the default 600. Note this
70 # will break GCC 2.95 based tools and earlier. You must use "make OLDGCC=1"
73 CFLAGS := -finline-limit=7000 $(CFLAGS)
76 # Separate C++ flags out from C flags.
77 ACTUAL_CFLAGS = $(CFLAGS)
78 ACTUAL_CFLAGS := $(subst -fno-rtti,,$(ACTUAL_CFLAGS))
79 ACTUAL_CFLAGS := $(subst -frtti,,$(ACTUAL_CFLAGS))
80 ACTUAL_CFLAGS := $(subst -Woverloaded-virtual,,$(ACTUAL_CFLAGS))
81 ACTUAL_CFLAGS := $(subst -fvtable-gc,,$(ACTUAL_CFLAGS))
83 ACTUAL_CXXFLAGS = $(subst -Wstrict-prototypes,,$(CFLAGS))
85 # pattern matching rules to generate a library object from source code
86 # object filenames are prefixed to avoid name clashes
87 # a single dependency rule is generated (file extension = ".o.d")
90 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
94 $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
95 @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.o.d=.tmp) > $@
100 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
104 $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
105 @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.o.d=.tmp) > $@
109 ifeq ($(HOST),CYGWIN)
110 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
114 $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
115 @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.o.d=.tmp) > $@
119 ifeq ($(HOST),CYGWIN)
120 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
124 $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $<
125 @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.o.d=.tmp) > $@
128 # pattern matching rules to generate a test object from source code
129 # object filenames are not prefixed
130 # a single dependency rule is generated (file extension = ".d")
132 ifeq ($(HOST),CYGWIN)
133 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
137 $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
138 @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@
142 ifeq ($(HOST),CYGWIN)
143 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
147 $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
148 @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@
152 ifeq ($(HOST),CYGWIN)
153 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
157 $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
158 @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@
162 ifeq ($(HOST),CYGWIN)
163 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
167 $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
168 @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@
171 # rule to generate a test executable from object code
172 $(PREFIX)/tests/$(PACKAGE)/%$(EXEEXT): %.d $(wildcard $(PREFIX)/lib/target.ld) $(wildcard $(PREFIX)/lib/*.[ao])
173 ifeq ($(HOST),CYGWIN)
174 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
178 ifneq ($(IGNORE_LINK_ERRORS),)
179 -$(CC) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(<:.d=.o) $(LDFLAGS)
181 $(CC) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(<:.d=.o) $(LDFLAGS)
184 # rule to generate all tests and create a dependency file "tests.deps" by
185 # concatenating the individual dependency rule files (file extension = ".d")
186 # generated during compilation
189 TESTS := $(TESTS:.cpp=)
190 TESTS := $(TESTS:.cxx=)
191 TESTS := $(TESTS:.c=)
192 TESTS := $(TESTS:.S=)
193 tests.stamp: $(foreach target,$(TESTS),$(target).d $(PREFIX)/tests/$(PACKAGE)/$(target)$(EXEEXT))
194 ifneq ($(strip $(TESTS)),)
195 @cat $(TESTS:%=%.d) > $(@:.stamp=.deps)
199 # rule to clean the build tree
201 @find . -type f -print | grep -v makefile | xargs rm -f
203 # rule to copy MLT files
204 mlt_headers: $(foreach x,$(MLT),$(PREFIX)/include/pkgconf/$(notdir $x))
206 $(foreach x,$(MLT),$(PREFIX)/include/pkgconf/$(notdir $x)): $(MLT)
207 @cp $(dir $<)/$(notdir $@) $(PREFIX)/include/pkgconf
208 @chmod u+w $(PREFIX)/include/pkgconf/$(notdir $@)