[7294718f] | 1 | ## |
---|
| 2 | ## $Id$ |
---|
| 3 | ## |
---|
[03d5706] | 4 | |
---|
| 5 | ## ------------------------------------------------------------------------- |
---|
[1ea70d78] | 6 | ## NOTE: This file is rather immature and has to be considered to be |
---|
| 7 | ## almost experimental. |
---|
[03d5706] | 8 | ## |
---|
[1ea70d78] | 9 | ## Expect frequent changes -- It deserves to be cleaned up :( |
---|
[03d5706] | 10 | ## ------------------------------------------------------------------------- |
---|
| 11 | |
---|
[1ea70d78] | 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, 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 |
---|
[560aae24] | 47 | GCCSPECS = $(GCC_SPECS) $(RTEMS_BSP_SPECS) |
---|
[1ea70d78] | 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 | |
---|
[03d5706] | 54 | DEFS = @DEFS@ |
---|
| 55 | |
---|
[baa8dd7c] | 56 | CPPFLAGS = @CPPFLAGS@ $(CPU_DEFINES) $(DEFINES) $(XCPPFLAGS) |
---|
| 57 | CFLAGS = @RTEMS_CFLAGS@ $(XCFLAGS) |
---|
| 58 | CXXFLAGS = @RTEMS_CXXFLAGS@ $(XCXXFLAGS) |
---|
[a34b245] | 59 | ASFLAGS = $(CPU_ASFLAGS) $(CPU_CFLAGS) $(XASFLAGS) |
---|
[1ea70d78] | 60 | |
---|
[978f59a] | 61 | LINK_LIBS = $(LD_LIBS) |
---|
[1ea70d78] | 62 | |
---|
| 63 | # |
---|
| 64 | # Client compiler and support tools |
---|
| 65 | # |
---|
| 66 | |
---|
| 67 | # |
---|
| 68 | # How to compile stuff into ${ARCH} subdirectory |
---|
| 69 | # |
---|
| 70 | |
---|
[bfba54e] | 71 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
---|
| 72 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
---|
[a34b245] | 73 | CCLD = $(CC) |
---|
| 74 | LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ |
---|
| 75 | $(AM_LDFLAGS) $(LDFLAGS) -o $@ |
---|
[bfba54e] | 76 | |
---|
| 77 | CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ |
---|
| 78 | $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) |
---|
[ba748523] | 79 | CXXLD = $(CXX) |
---|
[a34b245] | 80 | CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ |
---|
| 81 | $(AM_LDFLAGS) $(LDFLAGS) -o $@ |
---|
| 82 | |
---|
[29d82b25] | 83 | CCAS = $(CC) |
---|
| 84 | CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS) |
---|
| 85 | |
---|
| 86 | # OBSOLETE: Don't use |
---|
[a34b245] | 87 | AS = $(CC) |
---|
[ba748523] | 88 | ASCOMPILE = $(AS) $(AM_ASFLAGS) $(ASFLAGS) |
---|
[bfba54e] | 89 | |
---|
[1ea70d78] | 90 | ${ARCH}/%.o: %.c |
---|
[35b2275] | 91 | test -d $(ARCH) || mkdir $(ARCH) |
---|
[bfba54e] | 92 | ${COMPILE} -o $@ -c $< |
---|
[1ea70d78] | 93 | |
---|
| 94 | ${ARCH}/%.o: %.cc |
---|
[35b2275] | 95 | test -d $(ARCH) || mkdir $(ARCH) |
---|
[bfba54e] | 96 | ${CXXCOMPILE} -o $@ -c $< |
---|
[1ea70d78] | 97 | |
---|
| 98 | ${ARCH}/%.o: %.S |
---|
[35b2275] | 99 | test -d $(ARCH) || mkdir $(ARCH) |
---|
[29d82b25] | 100 | ${CCASCOMPILE} -DASM -o $@ -c $< |
---|
[1ea70d78] | 101 | |
---|
| 102 | # Dependency files for use by gmake |
---|
| 103 | # NOTE: we don't put them into $(ARCH) |
---|
| 104 | # so that 'make clean' doesn't blow it away |
---|
| 105 | |
---|
| 106 | DEPEND=Depends-${ARCH} |
---|
| 107 | |
---|
| 108 | CLEAN_DEPEND=$(DEPEND).tmp |
---|
| 109 | CLOBBER_DEPEND=$(DEPEND) |
---|
| 110 | |
---|
| 111 | # We deliberately don't have anything depend on the |
---|
| 112 | # $(DEPEND) file; otherwise it will get rebuilt even |
---|
| 113 | # on 'make clean' |
---|
| 114 | # |
---|
| 115 | |
---|
| 116 | ## HACK: Specific to gcc |
---|
| 117 | ## FIXME: The approach below is known to be conceptionally broken. |
---|
| 118 | depend-am: $(C_FILES) $(CC_FILES) $(S_FILES) |
---|
| 119 | ## Use gcc -M to generate dependencies |
---|
| 120 | ## Replace foo.o with $(ARCH)/foo.o |
---|
| 121 | ## Replace $(ARCH) value with string $(ARCH) |
---|
| 122 | ## so that it will for debug and profile cases |
---|
[ba748523] | 123 | $(COMPILE) -M $^ | \ |
---|
[1ea70d78] | 124 | sed -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ |
---|
| 125 | -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp |
---|
| 126 | mv $(DEPEND).tmp $(DEPEND) |
---|
| 127 | depend: depend-am |
---|
| 128 | |
---|
[372e4e2] | 129 | # pull in dependencies if they exist |
---|
| 130 | ifeq (${DEPEND},$(wildcard ${DEPEND})) |
---|
| 131 | include ${DEPEND} |
---|
| 132 | @ENDIF@ |
---|
| 133 | |
---|
| 134 | |
---|
[1ea70d78] | 135 | # spell out all the LINK_FILE's, rather than using -lbsp, so |
---|
| 136 | # that $(LINK_FILES) can be a dependency |
---|
| 137 | |
---|
| 138 | LINK_OBJS = \ |
---|
| 139 | $(OBJS) \ |
---|
| 140 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) |
---|
| 141 | |
---|
| 142 | LINK_FILES =\ |
---|
| 143 | $(START_FILE) \ |
---|
| 144 | $(OBJS) \ |
---|
[c274328b] | 145 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) |
---|
| 146 | |
---|
[1ea70d78] | 147 | if RTEMS_USE_GCC |
---|
| 148 | ## gcc >= 2.8 |
---|
| 149 | define make-rel |
---|
[a34b245] | 150 | $(LINK) -qnolinkcmds -nostdlib -Wl,-r $(XLDFLAGS) $^ |
---|
[1ea70d78] | 151 | endef |
---|
| 152 | else |
---|
| 153 | ## non-gcc |
---|
| 154 | define make-rel |
---|
[a34b245] | 155 | $(LINK) $(XLDFLAGS) $^ |
---|
[1ea70d78] | 156 | endef |
---|
| 157 | endif |
---|
| 158 | |
---|
| 159 | ## ------------------------------------------------------------------------- |
---|
| 160 | |
---|
| 161 | ## translate VARIANT into VARIANT_V |
---|
| 162 | VARIANT = OPTIMIZE |
---|
| 163 | |
---|
| 164 | VARIANT_OPTIMIZE_V = OPTIMIZE |
---|
| 165 | VARIANT_DEBUG_V = DEBUG |
---|
| 166 | VARIANT_PROFILE_V = PROFILE |
---|
| 167 | VARIANT_optimize_V = OPTIMIZE |
---|
| 168 | VARIANT_debug_V = DEBUG |
---|
| 169 | VARIANT_profile_V = PROFILE |
---|
| 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 | ARCH_PROFILE_V = o-profile |
---|
| 177 | |
---|
| 178 | ARCH__V = $(ARCH_OPTIMIZE_V) |
---|
| 179 | ARCH = $(ARCH_$(VARIANT_V)_V) |
---|
| 180 | |
---|
| 181 | ## Setup the library suffix |
---|
| 182 | LIBSUFFIX_OPTIMIZE_V = |
---|
| 183 | LIBSUFFIX_DEBUG_V = _g |
---|
| 184 | LIBSUFFIX_PROFILE_V = _p |
---|
| 185 | LIBSUFFIX__V = $(LIBSUFFIX_OPTIMIZE_V) |
---|
| 186 | |
---|
| 187 | LIB_VARIANT = $(LIBSUFFIX_$(VARIANT_V)_V) |
---|
| 188 | LIBSUFFIX_VA = $(LIB_VARIANT).a |
---|
| 189 | |
---|
| 190 | ## These are supposed to be set in make/custom/<bsp>.cfg |
---|
[f04c916] | 191 | CPU_CFLAGS = @CPU_CFLAGS@ |
---|
| 192 | CFLAGS_OPTIMIZE_V = @CFLAGS_OPTIMIZE_V@ |
---|
| 193 | CFLAGS_DEBUG_V = @CFLAGS_DEBUG_V@ |
---|
| 194 | CFLAGS_PROFILE_V = @CFLAGS_PROFILE_V@ |
---|
[1ea70d78] | 195 | CFLAGS__V = $(CFLAGS_OPTIMIZE_V) |
---|
| 196 | |
---|
| 197 | ## ------------------------------------------------------------------------ |
---|
| 198 | ## Setup hard-coded flags |
---|
| 199 | if RTEMS_USE_GCC |
---|
| 200 | ## gcc >= gcc-2.8 |
---|
| 201 | RTEMS_CFLAGS_OPTIMIZE_V = |
---|
| 202 | RTEMS_CFLAGS_DEBUG_V = -qrtems_debug -Wno-unused |
---|
[29d82b25] | 203 | RTEMS_CFLAGS_PROFILE_V = -pg |
---|
[978f59a] | 204 | |
---|
[1ea70d78] | 205 | ## non-gcc |
---|
| 206 | ## We can't guess what flags might be required here. |
---|
| 207 | ## Pass the values from the environment if you want to apply them. |
---|
| 208 | endif |
---|
| 209 | RTEMS_CFLAGS__V = $(RTEMS_CFLAGS_OPTIMIZE_V) |
---|
| 210 | |
---|
| 211 | ## ------------------------------------------------------------------------- |
---|
| 212 | |
---|
[509f8351] | 213 | CC = @CC@ $(GCCSPECS) |
---|
| 214 | CXX = @CXX@ $(GCCSPECS) |
---|
[560aae24] | 215 | CPP = @CPP@ $(GCCSPECS) |
---|
| 216 | |
---|
[4dc2e9a] | 217 | LD = @LD@ |
---|
[63b24d29] | 218 | OBJCOPY = @OBJCOPY@ |
---|
| 219 | NM = @NM@ |
---|
| 220 | SIZE = @SIZE@ |
---|
| 221 | STRIP = @STRIP@ |
---|
[1ea70d78] | 222 | |
---|
[03d5706] | 223 | ## |
---|
[bfba54e] | 224 | AM_CPPFLAGS = $(RTEMS_CPPFLAGS) |
---|
[baa8dd7c] | 225 | AM_CFLAGS = |
---|
| 226 | AM_CXXFLAGS = |
---|
| 227 | AM_CCASFLAGS = $(CPU_CFLAGS) $(RTEMS_CPPFLAGS) $(RTEMS_CCASFLAGS) |
---|