bootloader: bumped the version to 2.1
[nios2ecos.git] / packages / pkgconf / rules.mak
blob700c7f4eae72e257b968da7074cff8b7983d0b54
1 #=============================================================================
3 # rules.mak
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
20 ## for more details.
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####
43 # Author(s): jld
44 # Contributors: bartv
45 # Date: 1999-11-04
46 # Purpose: Generic rules for inclusion by all package makefiles
47 # Description:
49 #####DESCRIPTIONEND####
50 #=============================================================================
52 # FIXME: This definition belongs in the top-level makefile.
53 export HOST_CC := gcc
55 .PHONY: default build clean tests headers mlt_headers
57 # include any dependency rules generated previously
58 ifneq ($(wildcard *.deps),)
59 include $(wildcard *.deps)
60 endif
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"
71 # to avoid this.
72 ifneq ($(OLDGCC),1)
73 CFLAGS := -finline-limit=7000 $(CFLAGS)
74 endif
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")
88 %.o.d : %.c
89 ifeq ($(HOST),CYGWIN)
90 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
91 else
92 @mkdir -p $(dir $@)
93 endif
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) > $@
96 @rm $(@:.o.d=.tmp)
98 %.o.d : %.cxx
99 ifeq ($(HOST),CYGWIN)
100 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
101 else
102 @mkdir -p $(dir $@)
103 endif
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) > $@
106 @rm $(@:.o.d=.tmp)
108 %.o.d : %.cpp
109 ifeq ($(HOST),CYGWIN)
110 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
111 else
112 @mkdir -p $(dir $@)
113 endif
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) > $@
116 @rm $(@:.o.d=.tmp)
118 %.o.d : %.S
119 ifeq ($(HOST),CYGWIN)
120 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
121 else
122 @mkdir -p $(dir $@)
123 endif
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) > $@
126 @rm $(@:.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")
131 %.d : %.c
132 ifeq ($(HOST),CYGWIN)
133 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
134 else
135 @mkdir -p $(dir $@)
136 endif
137 $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
138 @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@
139 @rm $(@:.d=.tmp)
141 %.d : %.cxx
142 ifeq ($(HOST),CYGWIN)
143 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
144 else
145 @mkdir -p $(dir $@)
146 endif
147 $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
148 @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@
149 @rm $(@:.d=.tmp)
151 %.d : %.cpp
152 ifeq ($(HOST),CYGWIN)
153 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
154 else
155 @mkdir -p $(dir $@)
156 endif
157 $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
158 @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@
159 @rm $(@:.d=.tmp)
161 %.d : %.S
162 ifeq ($(HOST),CYGWIN)
163 @mkdir -p `cygpath -w "$(dir $@)" | sed "s@\\\\\\\\@/@g"`
164 else
165 @mkdir -p $(dir $@)
166 endif
167 $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $<
168 @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@
169 @rm $(@:.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"`
175 else
176 @mkdir -p $(dir $@)
177 endif
178 ifneq ($(IGNORE_LINK_ERRORS),)
179 -$(CC) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(<:.d=.o) $(LDFLAGS)
180 else
181 $(CC) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(<:.d=.o) $(LDFLAGS)
182 endif
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
187 tests: tests.stamp
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)
196 endif
197 @touch $@
199 # rule to clean the build tree
200 clean:
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 $@)
210 # end of file