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 | ## gcc >= 2.8.x |
---|
46 | GCCSPECS = $(GCC_SPECS) |
---|
47 | else |
---|
48 | ## fall back to the old style compilers/*.cfg |
---|
49 | ## CONFIG.CC is supposed to be provided by <BSP>.cfg |
---|
50 | include $(CONFIG.CC) |
---|
51 | endif # RTEMS_USE_GCC |
---|
52 | |
---|
53 | DEFS = @DEFS@ |
---|
54 | |
---|
55 | CPPFLAGS = @CPPFLAGS@ $(CPU_DEFINES) $(DEFINES) $(XCPPFLAGS) |
---|
56 | CFLAGS = @RTEMS_CFLAGS@ $(XCFLAGS) |
---|
57 | ASFLAGS = $(CPU_ASFLAGS) $(CPU_CFLAGS) $(XASFLAGS) |
---|
58 | |
---|
59 | # |
---|
60 | # How to compile stuff into ${ARCH} subdirectory |
---|
61 | # |
---|
62 | |
---|
63 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
---|
64 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
---|
65 | CCLD = $(CC) |
---|
66 | |
---|
67 | CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS) |
---|
68 | |
---|
69 | ${ARCH}/%.$(OBJEXT): %.c |
---|
70 | ${COMPILE} -o $@ -c $< |
---|
71 | |
---|
72 | ${ARCH}/%.$(OBJEXT): %.S |
---|
73 | ${CCASCOMPILE} -o $@ -c $< |
---|
74 | |
---|
75 | # Make foo.rel from foo.$(OBJEXT) |
---|
76 | ${ARCH}/%.rel: ${ARCH}/%.$(OBJEXT) |
---|
77 | ${make-rel} |
---|
78 | |
---|
79 | # Dependency files for use by gmake |
---|
80 | # NOTE: we don't put them into $(ARCH) |
---|
81 | # so that 'make clean' doesn't blow it away |
---|
82 | |
---|
83 | DEPEND=Depends-${ARCH} |
---|
84 | |
---|
85 | CLEAN_DEPEND=$(DEPEND).tmp |
---|
86 | CLOBBER_DEPEND=$(DEPEND) |
---|
87 | |
---|
88 | # We deliberately don't have anything depend on the |
---|
89 | # $(DEPEND) file; otherwise it will get rebuilt even |
---|
90 | # on 'make clean' |
---|
91 | # |
---|
92 | |
---|
93 | ## HACK: Specific to gcc |
---|
94 | ## FIXME: The approach below is known to be conceptionally broken. |
---|
95 | depend-am: $(C_FILES) $(CC_FILES) $(S_FILES) |
---|
96 | ## Use gcc -M to generate dependencies |
---|
97 | ## Replace foo.$(OBJEXT) with $(ARCH)/foo.$(OBJEXT) |
---|
98 | ## Replace $(ARCH) value with string $(ARCH) |
---|
99 | ## so that it will for debug and profile cases |
---|
100 | $(COMPILE) -M $^ | \ |
---|
101 | sed -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ |
---|
102 | -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp |
---|
103 | mv $(DEPEND).tmp $(DEPEND) |
---|
104 | depend: depend-am |
---|
105 | |
---|
106 | # pull in dependencies if they exist |
---|
107 | ifeq (${DEPEND},$(wildcard ${DEPEND})) |
---|
108 | include ${DEPEND} |
---|
109 | @ENDIF@ |
---|
110 | |
---|
111 | ## ------------------------------------------------------------------------- |
---|
112 | |
---|
113 | ## translate VARIANT into VARIANT_V |
---|
114 | VARIANT = OPTIMIZE |
---|
115 | |
---|
116 | VARIANT_OPTIMIZE_V = OPTIMIZE |
---|
117 | VARIANT_DEBUG_V = DEBUG |
---|
118 | VARIANT_PROFILE_V = PROFILE |
---|
119 | VARIANT_optimize_V = OPTIMIZE |
---|
120 | VARIANT_debug_V = DEBUG |
---|
121 | VARIANT_profile_V = PROFILE |
---|
122 | |
---|
123 | VARIANT_V = $(VARIANT_$(VARIANT)_V) |
---|
124 | |
---|
125 | ## Setup the variant build subdirectory |
---|
126 | ARCH_OPTIMIZE_V = o-optimize |
---|
127 | ARCH_DEBUG_V = o-debug |
---|
128 | ARCH_PROFILE_V = o-profile |
---|
129 | |
---|
130 | ARCH__V = $(ARCH_OPTIMIZE_V) |
---|
131 | ARCH = $(ARCH_$(VARIANT_V)_V) |
---|
132 | |
---|
133 | ## Setup the library suffix |
---|
134 | LIBSUFFIX_OPTIMIZE_V = |
---|
135 | LIBSUFFIX_DEBUG_V = _g |
---|
136 | LIBSUFFIX_PROFILE_V = _p |
---|
137 | LIBSUFFIX__V = $(LIBSUFFIX_OPTIMIZE_V) |
---|
138 | |
---|
139 | LIB_VARIANT = $(LIBSUFFIX_$(VARIANT_V)_V) |
---|
140 | LIBSUFFIX_VA = $(LIB_VARIANT).a |
---|
141 | |
---|
142 | ## These are supposed to be set in make/custom/<bsp>.cfg |
---|
143 | CPU_CFLAGS = @CPU_CFLAGS@ |
---|
144 | CFLAGS_OPTIMIZE_V = @CFLAGS_OPTIMIZE_V@ |
---|
145 | CFLAGS_DEBUG_V = @CFLAGS_DEBUG_V@ |
---|
146 | CFLAGS_PROFILE_V = @CFLAGS_PROFILE_V@ |
---|
147 | CFLAGS__V = $(CFLAGS_OPTIMIZE_V) |
---|
148 | |
---|
149 | ## ------------------------------------------------------------------------ |
---|
150 | ## Setup hard-coded flags |
---|
151 | if RTEMS_USE_GCC |
---|
152 | ## gcc >= gcc-2.8 |
---|
153 | RTEMS_CFLAGS_OPTIMIZE_V = |
---|
154 | RTEMS_CFLAGS_DEBUG_V = -Wno-unused |
---|
155 | RTEMS_CFLAGS_PROFILE_V = -pg |
---|
156 | |
---|
157 | ## non-gcc |
---|
158 | ## We can't guess what flags might be required here. |
---|
159 | ## Pass the values from the environment if you want to apply them. |
---|
160 | endif |
---|
161 | RTEMS_CFLAGS__V = $(RTEMS_CFLAGS_OPTIMIZE_V) |
---|
162 | |
---|
163 | ## ------------------------------------------------------------------------- |
---|
164 | |
---|
165 | CC = @CC@ $(GCCSPECS) |
---|
166 | CPP = @CPP@ $(GCCSPECS) |
---|
167 | |
---|
168 | ## |
---|
169 | AM_CPPFLAGS = $(RTEMS_CPPFLAGS) |
---|
170 | AM_CFLAGS = |
---|
171 | AM_CCASFLAGS = $(RTEMS_BSP_CFLAGS) $(RTEMS_CPPFLAGS) $(RTEMS_ASFLAGS) |
---|