1 | ## |
---|
2 | ## $Id$ |
---|
3 | ## |
---|
4 | |
---|
5 | ## ------------------------------------------------------------------------- |
---|
6 | ## NOTE: This file is rather immature and has to be considered to be |
---|
7 | ## almost experimental. |
---|
8 | ## |
---|
9 | ## Expect frequent changes -- It deserves to be cleaned up :( |
---|
10 | ## ------------------------------------------------------------------------- |
---|
11 | |
---|
12 | ## The section below is based on make/compilers/gcc-target-default.cfg |
---|
13 | ## used in former versions of RTEMS. |
---|
14 | |
---|
15 | ## |
---|
16 | ## Set up the flags for the toolchains: |
---|
17 | ## |
---|
18 | ## We are considering 3 different building schemes here: |
---|
19 | ## * Using gcc's being able to accept -specs (aka gcc-2.8 building scheme) |
---|
20 | ## * Using gcc's not being able to accept -specs (aka gcc-2.7.2 building |
---|
21 | ## scheme) |
---|
22 | ## * Using third party toolchains (aka non-gcc building scheme) |
---|
23 | ## |
---|
24 | ## Automake conditionals in use: |
---|
25 | ## RTEMS_USE_GCC .. if we are using GCC |
---|
26 | |
---|
27 | ## NOTES: |
---|
28 | ## * The gcc-2.8 building scheme is the nominal building scheme and |
---|
29 | ## is actively supported. |
---|
30 | ## * The non-gcc building scheme requires manually setting up environment |
---|
31 | ## variables and is hardly tested at all |
---|
32 | |
---|
33 | ## CFLAGS_OPTIMIZE_V, CFLAGS_DEBUG_V, CFLAGS_PROFILE_V are the values we |
---|
34 | ## would want the corresponding macros to be set to. |
---|
35 | ## |
---|
36 | ## CFLAGS_OPTIMIZE, CFLAGS_DEBUG, CFLAGS_PROFILE are set by the |
---|
37 | ## 'VARIANT=<OPTIMIZE|DEBUG|PROFILE>' targets to their _V values. |
---|
38 | |
---|
39 | ## XCPPFLAGS, XCFLAGS, XASFLAGS |
---|
40 | ## are used to add flags from the shell |
---|
41 | ## cf. make.info ("Implicit rules/variables" for details) |
---|
42 | |
---|
43 | if RTEMS_USE_GCC |
---|
44 | ## All the stuff below is specific to gcc |
---|
45 | |
---|
46 | CFLAGS_DEFAULT=-g -Wall |
---|
47 | ## gcc >= 2.8.x |
---|
48 | GCCSPECS = $(GCC_SPECS) $(RTEMS_BSP_SPECS) |
---|
49 | else |
---|
50 | ## fall back to the old style compilers/*.cfg |
---|
51 | ## CONFIG.CC is supposed to be provided by <BSP>.cfg |
---|
52 | include $(CONFIG.CC) |
---|
53 | endif # RTEMS_USE_GCC |
---|
54 | |
---|
55 | DEFS = @DEFS@ |
---|
56 | |
---|
57 | CPPFLAGS = @CPPFLAGS@ $(CPU_DEFINES) \ |
---|
58 | $(DEFINES) $(XCPPFLAGS) $(CPPFLAGS_GCC) |
---|
59 | CFLAGS = $(CFLAGS_DEFAULT) $(CPU_CFLAGS) $(XCFLAGS) |
---|
60 | ASFLAGS = $(CPU_ASFLAGS) $(CPU_CFLAGS) $(XASFLAGS) |
---|
61 | |
---|
62 | ## FIXME: This doesn't seem to be correct |
---|
63 | # when debugging, optimize flag: typically empty |
---|
64 | # some compilers do allow optimization with their "-g" |
---|
65 | CFLAGS_DEBUG_OPTIMIZE_V=-g |
---|
66 | LDFLAGS_DEBUG_V = |
---|
67 | |
---|
68 | # profile flag; use gprof(1) |
---|
69 | CFLAGS_PROFILE_V=-pg |
---|
70 | LDFLAGS_PROFILE_V = |
---|
71 | |
---|
72 | # List of library paths without -L |
---|
73 | LD_PATHS= $(PROJECT_RELEASE)/lib |
---|
74 | |
---|
75 | # ld flag for incomplete link |
---|
76 | LDFLAGS_INCOMPLETE = -r |
---|
77 | |
---|
78 | # ld flags for profiling, debugging |
---|
79 | LDFLAGS=$(LDFLAGS_PROFILE) $(LDFLAGS_DEBUG) $(LD_PATHS:%=-L %) |
---|
80 | |
---|
81 | # |
---|
82 | # How to compile stuff into ${ARCH} subdirectory |
---|
83 | # |
---|
84 | |
---|
85 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
---|
86 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
---|
87 | CCLD = $(CC) |
---|
88 | LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ |
---|
89 | $(AM_LDFLAGS) $(LDFLAGS) -o $@ |
---|
90 | |
---|
91 | CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS) |
---|
92 | |
---|
93 | ${ARCH}/%.o: %.c |
---|
94 | ${COMPILE} -o $@ -c $< |
---|
95 | |
---|
96 | ${ARCH}/%.o: %.S |
---|
97 | ${CCASCOMPILE} -o $@ -c $< |
---|
98 | |
---|
99 | # Make foo.rel from foo.o |
---|
100 | ${ARCH}/%.rel: ${ARCH}/%.o |
---|
101 | ${make-rel} |
---|
102 | |
---|
103 | # Dependency files for use by gmake |
---|
104 | # NOTE: we don't put them into $(ARCH) |
---|
105 | # so that 'make clean' doesn't blow it away |
---|
106 | |
---|
107 | DEPEND=Depends-${ARCH} |
---|
108 | |
---|
109 | CLEAN_DEPEND=$(DEPEND).tmp |
---|
110 | CLOBBER_DEPEND=$(DEPEND) |
---|
111 | |
---|
112 | # We deliberately don't have anything depend on the |
---|
113 | # $(DEPEND) file; otherwise it will get rebuilt even |
---|
114 | # on 'make clean' |
---|
115 | # |
---|
116 | |
---|
117 | ## HACK: Specific to gcc |
---|
118 | ## FIXME: The approach below is known to be conceptionally broken. |
---|
119 | depend-am: $(C_FILES) $(CC_FILES) $(S_FILES) |
---|
120 | ## Use gcc -M to generate dependencies |
---|
121 | ## Replace foo.o with $(ARCH)/foo.o |
---|
122 | ## Replace $(ARCH) value with string $(ARCH) |
---|
123 | ## so that it will for debug and profile cases |
---|
124 | $(COMPILE) -M $^ | \ |
---|
125 | sed -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ |
---|
126 | -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp |
---|
127 | mv $(DEPEND).tmp $(DEPEND) |
---|
128 | depend: depend-am |
---|
129 | |
---|
130 | # pull in dependencies if they exist |
---|
131 | ifeq (${DEPEND},$(wildcard ${DEPEND})) |
---|
132 | include ${DEPEND} |
---|
133 | @ENDIF@ |
---|
134 | |
---|
135 | if RTEMS_USE_GCC |
---|
136 | ## gcc >= 2.8 |
---|
137 | define make-rel |
---|
138 | $(LINK) -qnolinkcmds -nostdlib -Wl,-r $(XLDFLAGS) $^ |
---|
139 | endef |
---|
140 | else |
---|
141 | ## non-gcc |
---|
142 | define make-rel |
---|
143 | $(LINK) $(XLDFLAGS) $^ |
---|
144 | endef |
---|
145 | endif |
---|
146 | |
---|
147 | ## ------------------------------------------------------------------------- |
---|
148 | |
---|
149 | ## translate VARIANT into VARIANT_V |
---|
150 | VARIANT = OPTIMIZE |
---|
151 | |
---|
152 | VARIANT_OPTIMIZE_V = OPTIMIZE |
---|
153 | VARIANT_DEBUG_V = DEBUG |
---|
154 | VARIANT_PROFILE_V = PROFILE |
---|
155 | VARIANT_optimize_V = OPTIMIZE |
---|
156 | VARIANT_debug_V = DEBUG |
---|
157 | VARIANT_profile_V = PROFILE |
---|
158 | |
---|
159 | VARIANT_V = $(VARIANT_$(VARIANT)_V) |
---|
160 | |
---|
161 | ## Setup the variant build subdirectory |
---|
162 | ARCH_OPTIMIZE_V = o-optimize |
---|
163 | ARCH_DEBUG_V = o-debug |
---|
164 | ARCH_PROFILE_V = o-profile |
---|
165 | |
---|
166 | ARCH__V = $(ARCH_OPTIMIZE_V) |
---|
167 | ARCH = $(ARCH_$(VARIANT_V)_V) |
---|
168 | |
---|
169 | ## Setup the library suffix |
---|
170 | LIBSUFFIX_OPTIMIZE_V = |
---|
171 | LIBSUFFIX_DEBUG_V = _g |
---|
172 | LIBSUFFIX_PROFILE_V = _p |
---|
173 | LIBSUFFIX__V = $(LIBSUFFIX_OPTIMIZE_V) |
---|
174 | |
---|
175 | LIB_VARIANT = $(LIBSUFFIX_$(VARIANT_V)_V) |
---|
176 | LIBSUFFIX_VA = $(LIB_VARIANT).a |
---|
177 | |
---|
178 | ## These are supposed to be set in make/custom/<bsp>.cfg |
---|
179 | ## CFLAGS_OPTIMIZE_V = |
---|
180 | ## CFLAGS_DEBUG_V = |
---|
181 | ## CFLAGS_PROFILE_V = |
---|
182 | CFLAGS__V = $(CFLAGS_OPTIMIZE_V) |
---|
183 | |
---|
184 | ## ------------------------------------------------------------------------ |
---|
185 | ## Setup hard-coded flags |
---|
186 | if RTEMS_USE_GCC |
---|
187 | ## gcc >= gcc-2.8 |
---|
188 | RTEMS_CFLAGS_OPTIMIZE_V = |
---|
189 | RTEMS_CFLAGS_DEBUG_V = -qrtems_debug -Wno-unused |
---|
190 | RTEMS_CFLAGS_PROFILE_V = |
---|
191 | |
---|
192 | ## non-gcc |
---|
193 | ## We can't guess what flags might be required here. |
---|
194 | ## Pass the values from the environment if you want to apply them. |
---|
195 | endif |
---|
196 | RTEMS_CFLAGS__V = $(RTEMS_CFLAGS_OPTIMIZE_V) |
---|
197 | |
---|
198 | ## ------------------------------------------------------------------------- |
---|
199 | |
---|
200 | CC = @CC@ $(GCCSPECS) |
---|
201 | CPP = @CPP@ $(GCCSPECS) |
---|
202 | |
---|
203 | ## |
---|
204 | AM_CPPFLAGS = $(RTEMS_CPPFLAGS) |
---|
205 | |
---|
206 | AM_CFLAGS = $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V) |
---|
207 | |
---|
208 | # AM_CFLAGS = $(RTEMS_BSP_CFLAGS) $(RTEMS_CFLAGS) |
---|
209 | AM_CCASFLAGS = $(RTEMS_BSP_CFLAGS) $(RTEMS_CPPFLAGS) $(RTEMS_ASFLAGS) |
---|