[11a26b9] | 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 are the values we |
---|
| 34 | ## would want the corresponding macros to be set to. |
---|
| 35 | ## |
---|
| 36 | ## CFLAGS_OPTIMIZE, CFLAGS_DEBUG are set by the |
---|
| 37 | ## 'VARIANT=<OPTIMIZE|DEBUG>' targets to their _V values. |
---|
| 38 | |
---|
| 39 | ## XCPPFLAGS, XCFLAGS, XCXXFLAGS, 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 | ## gcc >= 2.8.x |
---|
| 47 | GCCSPECS = $(GCC_SPECS) $(RTEMS_BSP_SPECS) |
---|
| 48 | else |
---|
| 49 | ## fall back to the old style compilers/*.cfg |
---|
| 50 | ## CONFIG.CC is supposed to be provided by <BSP>.cfg |
---|
| 51 | include $(CONFIG.CC) |
---|
| 52 | endif # RTEMS_USE_GCC |
---|
| 53 | |
---|
| 54 | DEFS = @DEFS@ |
---|
| 55 | |
---|
| 56 | CPPFLAGS = @CPPFLAGS@ $(CPU_DEFINES) $(DEFINES) $(XCPPFLAGS) |
---|
| 57 | CFLAGS = @RTEMS_CFLAGS@ $(XCFLAGS) |
---|
| 58 | ## FIXME: This should be correct, but is not supported, yet |
---|
| 59 | # CXXFLAGS = @RTEMS_CXXFLAGS@ $(XCXXFLAGS) |
---|
| 60 | ## Fall back to using RTEMS_CFLAGS for C++ |
---|
| 61 | CXXFLAGS = @RTEMS_CFLAGS@ $(XCXXFLAGS) |
---|
| 62 | ASFLAGS = $(CPU_ASFLAGS) $(CPU_CFLAGS) $(XASFLAGS) |
---|
| 63 | |
---|
| 64 | LINK_LIBS = $(LD_LIBS) |
---|
| 65 | |
---|
| 66 | # |
---|
| 67 | # Client compiler and support tools |
---|
| 68 | # |
---|
| 69 | |
---|
| 70 | # |
---|
| 71 | # How to compile stuff into ${ARCH} subdirectory |
---|
| 72 | # |
---|
| 73 | |
---|
| 74 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
---|
| 75 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
---|
| 76 | CCLD = $(CC) |
---|
| 77 | LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ |
---|
| 78 | $(AM_LDFLAGS) $(LDFLAGS) -o $@ |
---|
| 79 | |
---|
| 80 | CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ |
---|
| 81 | $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) |
---|
| 82 | CXXLD = $(CXX) |
---|
| 83 | CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ |
---|
| 84 | $(AM_LDFLAGS) $(LDFLAGS) -o $@ |
---|
| 85 | |
---|
| 86 | CCAS = $(CC) |
---|
| 87 | CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS) |
---|
| 88 | |
---|
| 89 | # OBSOLETE: Don't use |
---|
| 90 | AS = $(CC) |
---|
| 91 | ASCOMPILE = $(AS) $(AM_ASFLAGS) $(ASFLAGS) |
---|
| 92 | |
---|
[306a66e] | 93 | ${ARCH}/%.o: %.c $(ARCH)/$(dirstamp) |
---|
[11a26b9] | 94 | ${COMPILE} -o $@ -c $< |
---|
| 95 | |
---|
[306a66e] | 96 | ${ARCH}/%.o: %.cc $(ARCH)/$(dirstamp) |
---|
[11a26b9] | 97 | ${CXXCOMPILE} -o $@ -c $< |
---|
| 98 | |
---|
[306a66e] | 99 | ${ARCH}/%.o: %.S $(ARCH)/$(dirstamp) |
---|
[11a26b9] | 100 | ${CCASCOMPILE} -DASM -o $@ -c $< |
---|
| 101 | |
---|
[306a66e] | 102 | ${ARCH}/$(dirstamp): |
---|
[14348a00] | 103 | @$(mkdir_p) $(ARCH) |
---|
[306a66e] | 104 | @: > $(ARCH)/$(dirstamp) |
---|
| 105 | |
---|
[11a26b9] | 106 | # Dependency files for use by gmake |
---|
| 107 | # NOTE: we don't put them into $(ARCH) |
---|
| 108 | # so that 'make clean' doesn't blow it away |
---|
| 109 | |
---|
| 110 | DEPEND=Depends-${ARCH} |
---|
| 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 | if RTEMS_USE_GCC |
---|
| 118 | ## HACK: Specific to gcc |
---|
| 119 | ## FIXME: The approach below is known to be conceptionally broken. |
---|
| 120 | depend-gcc: $(C_FILES) $(CC_FILES) $(S_FILES) |
---|
| 121 | ## Use gcc -M to generate dependencies |
---|
| 122 | ## Replace foo.o with $(ARCH)/foo.o |
---|
| 123 | ## Replace $(ARCH) value with string $(ARCH) |
---|
| 124 | ## so that it will for debug cases |
---|
| 125 | $(COMPILE) -M $^ | \ |
---|
| 126 | sed -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ |
---|
| 127 | -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp |
---|
| 128 | mv $(DEPEND).tmp $(DEPEND) |
---|
| 129 | |
---|
| 130 | # pull in dependencies if they exist |
---|
| 131 | ifeq (${DEPEND},$(wildcard ${DEPEND})) |
---|
| 132 | include ${DEPEND} |
---|
| 133 | @ENDIF@ |
---|
| 134 | endif |
---|
| 135 | depend: depend-am |
---|
| 136 | |
---|
| 137 | # spell out all the LINK_FILE's, rather than using -lbsp, so |
---|
| 138 | # that $(LINK_FILES) can be a dependency |
---|
| 139 | |
---|
| 140 | LINK_OBJS = \ |
---|
| 141 | $(OBJS) \ |
---|
[e90cff96] | 142 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%$(LIB_VARIANT).rel) |
---|
[11a26b9] | 143 | |
---|
| 144 | LINK_FILES =\ |
---|
| 145 | $(START_FILE) \ |
---|
| 146 | $(OBJS) \ |
---|
[e90cff96] | 147 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%$(LIB_VARIANT).rel) |
---|
[11a26b9] | 148 | |
---|
| 149 | if RTEMS_USE_GCC |
---|
| 150 | ## gcc >= 2.8 |
---|
| 151 | define make-rel |
---|
| 152 | $(LINK) -qnolinkcmds -nostdlib -Wl,-r $(XLDFLAGS) $^ |
---|
| 153 | endef |
---|
| 154 | else |
---|
| 155 | ## non-gcc |
---|
| 156 | define make-rel |
---|
| 157 | $(LINK) $(XLDFLAGS) $^ |
---|
| 158 | endef |
---|
| 159 | endif |
---|
| 160 | |
---|
| 161 | ## ------------------------------------------------------------------------- |
---|
| 162 | |
---|
| 163 | ## translate VARIANT into VARIANT_V |
---|
| 164 | VARIANT = OPTIMIZE |
---|
| 165 | |
---|
| 166 | VARIANT_OPTIMIZE_V = OPTIMIZE |
---|
| 167 | VARIANT_DEBUG_V = DEBUG |
---|
| 168 | VARIANT_optimize_V = OPTIMIZE |
---|
| 169 | VARIANT_debug_V = DEBUG |
---|
| 170 | |
---|
| 171 | VARIANT_V = $(VARIANT_$(VARIANT)_V) |
---|
| 172 | |
---|
| 173 | ## Setup the variant build subdirectory |
---|
| 174 | ARCH_OPTIMIZE_V = o-optimize |
---|
| 175 | ARCH_DEBUG_V = o-debug |
---|
| 176 | |
---|
| 177 | ARCH__V = $(ARCH_OPTIMIZE_V) |
---|
| 178 | ARCH = $(ARCH_$(VARIANT_V)_V) |
---|
| 179 | |
---|
| 180 | ## Setup the library suffix |
---|
| 181 | LIBSUFFIX_OPTIMIZE_V = |
---|
| 182 | LIBSUFFIX_DEBUG_V = _g |
---|
| 183 | LIBSUFFIX__V = $(LIBSUFFIX_OPTIMIZE_V) |
---|
| 184 | |
---|
| 185 | LIB_VARIANT = $(LIBSUFFIX_$(VARIANT_V)_V) |
---|
| 186 | |
---|
| 187 | ## These are supposed to be set in make/custom/<bsp>.cfg |
---|
| 188 | CPU_CFLAGS = @CPU_CFLAGS@ |
---|
| 189 | CFLAGS_OPTIMIZE_V = @CFLAGS_OPTIMIZE_V@ |
---|
| 190 | CFLAGS_DEBUG_V = @CFLAGS_DEBUG_V@ |
---|
| 191 | CFLAGS__V = $(CFLAGS_OPTIMIZE_V) |
---|
| 192 | |
---|
| 193 | ## ------------------------------------------------------------------------ |
---|
| 194 | ## Setup hard-coded flags |
---|
| 195 | if RTEMS_USE_GCC |
---|
| 196 | ## gcc >= gcc-2.8 |
---|
| 197 | RTEMS_CFLAGS_OPTIMIZE_V = |
---|
| 198 | RTEMS_CFLAGS_DEBUG_V = -qrtems_debug -Wno-unused |
---|
| 199 | |
---|
| 200 | ## non-gcc |
---|
| 201 | ## We can't guess what flags might be required here. |
---|
| 202 | ## Pass the values from the environment if you want to apply them. |
---|
| 203 | endif |
---|
| 204 | RTEMS_CFLAGS__V = $(RTEMS_CFLAGS_OPTIMIZE_V) |
---|
| 205 | |
---|
| 206 | ## ------------------------------------------------------------------------- |
---|
| 207 | |
---|
| 208 | CC = @CC@ $(GCCSPECS) |
---|
| 209 | CXX = @CXX@ $(GCCSPECS) |
---|
| 210 | CPP = @CPP@ $(GCCSPECS) |
---|
| 211 | |
---|
| 212 | LD = @LD@ |
---|
| 213 | OBJCOPY = @OBJCOPY@ |
---|
| 214 | NM = @NM@ |
---|
| 215 | SIZE = @SIZE@ |
---|
| 216 | STRIP = @STRIP@ |
---|
| 217 | |
---|
| 218 | ## |
---|
| 219 | AM_CPPFLAGS = $(RTEMS_CPPFLAGS) |
---|
| 220 | AM_CFLAGS = |
---|
| 221 | AM_CXXFLAGS = |
---|
| 222 | AM_CCASFLAGS = $(CPU_CFLAGS) $(RTEMS_CPPFLAGS) $(RTEMS_CCASFLAGS) |
---|
| 223 | |
---|
| 224 | clean-local: |
---|
| 225 | $(RM) -r o-optimize o-debug $(CLEANDIRS) |
---|
| 226 | $(RM) Depends-o-optimize.tmp Depends-o-debug.tmp |
---|