1 | # |
---|
2 | # Shared compiler for all GNU tools configurations |
---|
3 | # |
---|
4 | # $Id$ |
---|
5 | # |
---|
6 | |
---|
7 | ## |
---|
8 | # CFLAGS_OPTIMIZE_V, CFLAGS_DEBUG_V are the values we |
---|
9 | # would want the corresponding macros to be set to. |
---|
10 | # |
---|
11 | # CFLAGS_OPTIMIZE, CFLAGS_DEBUG are set in the leaf |
---|
12 | # Makefiles by the 'debug:' targets to their _V values. |
---|
13 | # |
---|
14 | |
---|
15 | # default flags |
---|
16 | # XCPPFLAGS, XCFLAGS, XCXXFLAGS, XASFLAGS |
---|
17 | # are used to add flags from the shell |
---|
18 | # cf. make.info ("Implicit rules/variables" for details) |
---|
19 | |
---|
20 | # NOTE: Should these go to CPPFLAGS ? |
---|
21 | CFLAGS_DEFAULT=-g -Wall |
---|
22 | |
---|
23 | # NOTE: CPU_CFLAGS should probably be renamed to CPU_CPPFLAGS |
---|
24 | # NOTE: CPU_DEFINES should probably be merged with CPU_CFLAGS |
---|
25 | CPPFLAGS += $(CPU_DEFINES) $(CPU_CFLAGS) $(DEFINES) $(XCPPFLAGS) |
---|
26 | CFLAGS = $(CFLAGS_DEFAULT) $(XCFLAGS) |
---|
27 | CXXFLAGS = $(CFLAGS_DEFAULT) $(XCXXFLAGS) |
---|
28 | ASFLAGS = $(CPU_ASFLAGS) $(XASFLAGS) |
---|
29 | |
---|
30 | # NOTE: GCCSPECS probably belongs to CPPFLAGS |
---|
31 | # Unfortunately, many custom/*.cfg files do not pass CPPFLAGS |
---|
32 | # to their gcc-2.8 make-exe rules |
---|
33 | GCCSPECS = -B$(PROJECT_RELEASE)/lib/ -specs bsp_specs -qrtems |
---|
34 | |
---|
35 | CC += $(GCCSPECS) |
---|
36 | CXX += $(GCCSPECS) |
---|
37 | |
---|
38 | CPPFLAGS += |
---|
39 | |
---|
40 | # Define this to yes if C++ is included in the development environment. |
---|
41 | # This requires that at least the GNU C++ compiler and libg++ be installed. |
---|
42 | ifeq ($(HAS_CPLUSPLUS),yes) |
---|
43 | CPLUS_LD_LIBS += $(PROJECT_RELEASE)/lib/librtems++$(LIBSUFFIX_VA) |
---|
44 | endif |
---|
45 | |
---|
46 | # debug flag; |
---|
47 | CFLAGS_DEBUG_V+=-Wno-unused |
---|
48 | CXXFLAGS_DEBUG_V+= |
---|
49 | |
---|
50 | CFLAGS_DEBUG_V+=-qrtems_debug |
---|
51 | CXXFLAGS_DEBUG_V+=-qrtems_debug |
---|
52 | |
---|
53 | # when debugging, optimize flag: typically empty |
---|
54 | # some compilers do allow optimization with their "-g" |
---|
55 | CFLAGS_OPTIMIZE_V+=-g |
---|
56 | CXXFLAGS_OPTIMIZE_V+=-g |
---|
57 | |
---|
58 | ifndef AUTOMAKE |
---|
59 | CFLAGS_$(VARIANT) =$(CFLAGS_$(VARIANT)_V) |
---|
60 | CXXFLAGS_$(VARIANT)=$(CXXFLAGS_$(VARIANT)_V) |
---|
61 | endif |
---|
62 | |
---|
63 | ifndef AUTOMAKE |
---|
64 | CFLAGS += $(CFLAGS_OPTIMIZE) $(CFLAGS_DEBUG) |
---|
65 | CXXFLAGS += $(CXXFLAGS_OPTIMIZE) $(CXXFLAGS_DEBUG) |
---|
66 | endif |
---|
67 | |
---|
68 | # List of library paths without -L |
---|
69 | LD_PATHS= $(PROJECT_RELEASE)/lib |
---|
70 | |
---|
71 | # libraries you want EVERYONE to link with |
---|
72 | #LD_LIBS= |
---|
73 | |
---|
74 | # ld flag to ensure pure-text |
---|
75 | #LDFLAGS_MUST_BE_PURE_V = |
---|
76 | |
---|
77 | # ld flag for [un]shared objects |
---|
78 | #LDFLAGS_STATIC_LIBRARIES_V = |
---|
79 | #LDFLAGS_SHARED_LIBRARIES_V = |
---|
80 | |
---|
81 | # ld flag for incomplete link |
---|
82 | LDFLAGS_INCOMPLETE = -r |
---|
83 | |
---|
84 | # Special linker options when building lib.so |
---|
85 | LDFLAGS_DYNAMIC_V = ?? |
---|
86 | |
---|
87 | # Some dynamic linking systems want the preferred name recorded in the binary |
---|
88 | # ref: src/libxil/Makefile |
---|
89 | LDFLAGS_DYNAMIC_LIBNAME_V = -h $(DYNAMIC_VERSION_LIBNAME) |
---|
90 | |
---|
91 | # ld flags for profiling, debugging |
---|
92 | LDFLAGS_DEBUG_V = -qrtems_debug |
---|
93 | |
---|
94 | LDFLAGS=$(LDFLAGS_DEBUG) $(LD_PATHS:%=-L %) |
---|
95 | |
---|
96 | # |
---|
97 | # Stuff to clean and clobber for the compiler and its tools |
---|
98 | # |
---|
99 | |
---|
100 | CLEAN_CC = a.out *.o *.BAK |
---|
101 | CLOBBER_CC = |
---|
102 | |
---|
103 | # |
---|
104 | # Client compiler and support tools |
---|
105 | # |
---|
106 | |
---|
107 | # CPP command to write file to standard output |
---|
108 | CPP=$(CC) -E -w -Wp,-$$ |
---|
109 | |
---|
110 | # egrep regexp to ignore symbol table entries in ar archives. |
---|
111 | # Only used to make sure we skip them when coalescing libraries. |
---|
112 | # skip __.SYMDEF and empty names (maybe bug in ranlib??). |
---|
113 | AR_SYMBOL_TABLE="HIGHLY-UNLIKELY-TO-CONFLICT" |
---|
114 | ARFLAGS=ruv |
---|
115 | |
---|
116 | # |
---|
117 | # How to compile stuff into ${ARCH} subdirectory |
---|
118 | # |
---|
119 | |
---|
120 | ${ARCH}/%.o: %.c |
---|
121 | ${COMPILE.c} $(AM_CPPFLAGS) $(AM_CFLAGS) -o $@ $< |
---|
122 | |
---|
123 | ${ARCH}/%.o: %.cc |
---|
124 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
125 | |
---|
126 | ${ARCH}/%.o: %.cpp |
---|
127 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
128 | |
---|
129 | ${ARCH}/%.o: %.cxx |
---|
130 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
131 | |
---|
132 | ${ARCH}/%.o: %.C |
---|
133 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
134 | |
---|
135 | ${ARCH}/%.o: %.S |
---|
136 | ${COMPILE.S} $(AM_CPPFLAGS) -DASM -o $@ $< |
---|
137 | |
---|
138 | # Make foo.rel from foo.o |
---|
139 | ${ARCH}/%.rel: ${ARCH}/%.o |
---|
140 | ${make-rel} |
---|
141 | |
---|
142 | # create $(ARCH)/pgm from pgm.sh |
---|
143 | ${ARCH}/%: %.sh |
---|
144 | $(RM) $@ |
---|
145 | $(CP) $< $@ |
---|
146 | $(CHMOD) +x $@ |
---|
147 | |
---|
148 | # Dependency files for use by gmake |
---|
149 | # NOTE: we don't put them into $(ARCH) |
---|
150 | # so that 'make clean' doesn't blow it away |
---|
151 | |
---|
152 | DEPEND=Depends-${ARCH} |
---|
153 | |
---|
154 | CLEAN_DEPEND=$(DEPEND).tmp |
---|
155 | CLOBBER_DEPEND=$(DEPEND) |
---|
156 | |
---|
157 | # We deliberately don't have anything depend on the |
---|
158 | # $(DEPEND) file; otherwise it will get rebuilt even |
---|
159 | # on 'make clean' |
---|
160 | # |
---|
161 | |
---|
162 | depend-am: $(C_FILES) $(CC_FILES) $(S_FILES) |
---|
163 | ifneq ($(words $(C_FILES) $(CC_FILES) $(S_FILES)), 0) |
---|
164 | # Use gcc -M to generate dependencies |
---|
165 | # Replace foo.o with $(ARCH)/foo.o |
---|
166 | # Replace $(ARCH) value with string $(ARCH) |
---|
167 | # so that it will for debug cases |
---|
168 | $(COMPILE.c) $(AM_CPPFLAGS) $(AM_CFLAGS) -M $^ | \ |
---|
169 | $(SED) -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ |
---|
170 | -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp |
---|
171 | $(MV) $(DEPEND).tmp $(DEPEND) |
---|
172 | endif |
---|
173 | depend: depend-am |
---|
174 | |
---|
175 | # spell out all the LINK_FILE's, rather than using -lbsp, so |
---|
176 | # that $(LINK_FILES) can be a dependency |
---|
177 | |
---|
178 | # Start file must be one of |
---|
179 | # $(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).o |
---|
180 | # $(PROJECT_RELEASE)/lib/asmiface$(LIB_VARIANT).o |
---|
181 | # It defaults to start.o, but an app can override it. |
---|
182 | |
---|
183 | ifeq ($(START_BASE),) |
---|
184 | START_FILE= |
---|
185 | else |
---|
186 | START_FILE=$(PROJECT_RELEASE)/lib/$(START_BASE)$(LIB_VARIANT).o |
---|
187 | endif |
---|
188 | |
---|
189 | # |
---|
190 | # NOTE: a rule to link an rtems' application should look similar to this |
---|
191 | # (cf. "make-exe" in make/custom/*.cfg): |
---|
192 | # |
---|
193 | # gcc28: |
---|
194 | # $(PGM): $(LINK_FILES) |
---|
195 | # $(CC) $(CFLAGS) -o $@ $(LINK_OBJS) $(LINK_LIBS) |
---|
196 | # |
---|
197 | |
---|
198 | LINK_OBJS =\ |
---|
199 | $(CONSTRUCTOR) \ |
---|
200 | $(OBJS) \ |
---|
201 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) |
---|
202 | |
---|
203 | LINK_FILES =\ |
---|
204 | $(START_FILE) \ |
---|
205 | $(CONSTRUCTOR) \ |
---|
206 | $(OBJS) \ |
---|
207 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) \ |
---|
208 | $(PROJECT_RELEASE)/lib/librtemsbsp$(LIBSUFFIX_VA) \ |
---|
209 | $(PROJECT_RELEASE)/lib/librtemscpu$(LIBSUFFIX_VA) |
---|
210 | |
---|
211 | LINK_LIBS += $(LD_LIBS) |
---|
212 | |
---|
213 | # |
---|
214 | # Allow user to override link commands (to build a prom image, perhaps) |
---|
215 | # |
---|
216 | ifndef LINKCMDS |
---|
217 | LINKCMDS=$(PROJECT_RELEASE)/lib/linkcmds |
---|
218 | endif |
---|
219 | |
---|
220 | define make-rel |
---|
221 | $(LINK.c) $(CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) \ |
---|
222 | -qnolinkcmds -nostdlib -Wl,-r $(XLDFLAGS) -o $@ $^ |
---|
223 | endef |
---|