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