[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 | ## RTEMS_USE_GCC272 .. if using gcc and if requested not to apply |
---|
| 27 | ## gcc <= 2.7.2 incompatible rules |
---|
| 28 | |
---|
| 29 | ## NOTES: |
---|
| 30 | ## * The gcc-2.8 building scheme is the nominal building scheme and |
---|
| 31 | ## is actively supported. |
---|
| 32 | ## * The gcc-2.7.2 building scheme is not supported by all BSPs and |
---|
| 33 | ## is not extensively tested. |
---|
| 34 | ## * The non-gcc building scheme requires manually setting up environment |
---|
| 35 | ## variables and is hardly tested at all |
---|
| 36 | |
---|
| 37 | ## CFLAGS_OPTIMIZE_V, CFLAGS_DEBUG_V, CFLAGS_PROFILE_V are the values we |
---|
| 38 | ## would want the corresponding macros to be set to. |
---|
| 39 | ## |
---|
| 40 | ## CFLAGS_OPTIMIZE, CFLAGS_DEBUG, CFLAGS_PROFILE are set by the |
---|
| 41 | ## 'VARIANT=<OPTIMIZE|DEBUG|PROFILE>' targets to their _V values. |
---|
| 42 | |
---|
| 43 | ## XCPPFLAGS, XCFLAGS, XCXXFLAGS, XASFLAGS |
---|
| 44 | ## are used to add flags from the shell |
---|
| 45 | ## cf. make.info ("Implicit rules/variables" for details) |
---|
| 46 | |
---|
| 47 | if RTEMS_USE_GCC |
---|
| 48 | ## All the stuff below is specific to gcc |
---|
| 49 | |
---|
[83518713] | 50 | CFLAGS_DEFAULT=-g -Wall |
---|
[1ea70d78] | 51 | |
---|
| 52 | if RTEMS_USE_GCC272 |
---|
| 53 | ## gcc <= 2.7.2 |
---|
| 54 | RTEMS_CPPFLAGS = -isystem $(PROJECT_INCLUDE) |
---|
| 55 | |
---|
| 56 | # default location of Standard C Library |
---|
[560aae24] | 57 | LIBC_LIBC = `$(CC) $(CPU_CFLAGS) -print-file-name=libc.a $(GCCSED)` |
---|
| 58 | LIBC_LIBM = `$(CC) $(CPU_CFLAGS) -print-file-name=libm.a $(GCCSED)` |
---|
| 59 | LIBC_LIBGCC = `$(CC) $(CPU_CFLAGS) -print-libgcc-file-name $(GCCSED)` |
---|
[1ea70d78] | 60 | |
---|
| 61 | ### FIXME: False if using multilibbed RTEMS |
---|
| 62 | LINK_LIBS_RTEMS = $(PROJECT_RELEASE)/lib/librtemsall$(LIBSUFFIX_VA) |
---|
| 63 | |
---|
| 64 | LINK_LIBS_GCC272 = $(LINK_LIBS_RTEMS) $(LIBC_LIBC) $(LIBC_LIBGCC) |
---|
[560aae24] | 65 | GCCSPECS = |
---|
[1ea70d78] | 66 | else |
---|
| 67 | ## gcc >= 2.8.x |
---|
[560aae24] | 68 | GCCSPECS = $(GCC_SPECS) $(RTEMS_BSP_SPECS) |
---|
[1ea70d78] | 69 | endif |
---|
| 70 | else |
---|
| 71 | ## fall back to the old style compilers/*.cfg |
---|
| 72 | ## CONFIG.CC is supposed to be provided by <BSP>.cfg |
---|
| 73 | include $(CONFIG.CC) |
---|
| 74 | endif # RTEMS_USE_GCC |
---|
| 75 | |
---|
[03d5706] | 76 | DEFS = @DEFS@ |
---|
| 77 | |
---|
[bfba54e] | 78 | CPPFLAGS = @CPPFLAGS@ $(CPU_DEFINES) $(CPU_CFLAGS) \ |
---|
[1ea70d78] | 79 | $(DEFINES) $(XCPPFLAGS) $(CPPFLAGS_GCC) |
---|
| 80 | CFLAGS = $(CFLAGS_DEFAULT) $(XCFLAGS) |
---|
| 81 | CXXFLAGS = $(CFLAGS_DEFAULT) $(XCXXFLAGS) |
---|
| 82 | ASFLAGS = $(CPU_ASFLAGS) $(XASFLAGS) |
---|
| 83 | |
---|
| 84 | LINK_LIBS = $(LINK_LIBS_GCC272) $(LD_LIBS) |
---|
| 85 | |
---|
| 86 | ## FIXME: This doesn't seem to be correct |
---|
| 87 | # when debugging, optimize flag: typically empty |
---|
| 88 | # some compilers do allow optimization with their "-g" |
---|
| 89 | CFLAGS_DEBUG_OPTIMIZE_V=-g |
---|
| 90 | CXXFLAGS_DEBUG_OPTIMIZE_V=-g |
---|
| 91 | LDFLAGS_DEBUG_V = |
---|
| 92 | |
---|
| 93 | # profile flag; use gprof(1) |
---|
| 94 | CFLAGS_PROFILE_V=-pg |
---|
| 95 | CXXFLAGS_PROFILE_V=-pg |
---|
| 96 | LDFLAGS_PROFILE_V = |
---|
| 97 | |
---|
| 98 | # List of library paths without -L |
---|
| 99 | LD_PATHS= $(PROJECT_RELEASE)/lib |
---|
| 100 | |
---|
| 101 | # ld flag for incomplete link |
---|
| 102 | LDFLAGS_INCOMPLETE = -r |
---|
| 103 | |
---|
| 104 | # ld flags for profiling, debugging |
---|
| 105 | LDFLAGS=$(LDFLAGS_PROFILE) $(LDFLAGS_DEBUG) $(LD_PATHS:%=-L %) |
---|
| 106 | |
---|
| 107 | # |
---|
| 108 | # Client compiler and support tools |
---|
| 109 | # |
---|
| 110 | |
---|
| 111 | ARFLAGS=ruv |
---|
| 112 | |
---|
| 113 | # |
---|
| 114 | # How to compile stuff into ${ARCH} subdirectory |
---|
| 115 | # |
---|
| 116 | |
---|
[bfba54e] | 117 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
---|
| 118 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
---|
| 119 | |
---|
| 120 | CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ |
---|
| 121 | $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) |
---|
| 122 | |
---|
[1ea70d78] | 123 | ${ARCH}/%.o: %.c |
---|
[bfba54e] | 124 | ${COMPILE} -o $@ -c $< |
---|
[1ea70d78] | 125 | |
---|
| 126 | ${ARCH}/%.o: %.cc |
---|
[bfba54e] | 127 | ${CXXCOMPILE} -o $@ -c $< |
---|
[1ea70d78] | 128 | |
---|
| 129 | ${ARCH}/%.o: %.cpp |
---|
[bfba54e] | 130 | ${CXXCOMPILE} -o $@ -c $< |
---|
[1ea70d78] | 131 | |
---|
| 132 | ${ARCH}/%.o: %.cxx |
---|
[bfba54e] | 133 | ${CXXCOMPILE} -o $@ -c $< |
---|
[1ea70d78] | 134 | |
---|
| 135 | ${ARCH}/%.o: %.C |
---|
[bfba54e] | 136 | ${CXXCOMPILE} -o $@ -c $< |
---|
[1ea70d78] | 137 | |
---|
| 138 | ${ARCH}/%.o: %.S |
---|
| 139 | ${COMPILE.S} $(AM_CPPFLAGS) -DASM -o $@ $< |
---|
| 140 | |
---|
| 141 | # Make foo.rel from foo.o |
---|
| 142 | ${ARCH}/%.rel: ${ARCH}/%.o |
---|
| 143 | ${make-rel} |
---|
| 144 | |
---|
| 145 | # create $(ARCH)/pgm from pgm.sh |
---|
| 146 | ${ARCH}/%: %.sh |
---|
| 147 | $(RM) $@ |
---|
| 148 | $(CP) $< $@ |
---|
| 149 | $(CHMOD) +x $@ |
---|
| 150 | |
---|
| 151 | # Dependency files for use by gmake |
---|
| 152 | # NOTE: we don't put them into $(ARCH) |
---|
| 153 | # so that 'make clean' doesn't blow it away |
---|
| 154 | |
---|
| 155 | DEPEND=Depends-${ARCH} |
---|
| 156 | |
---|
| 157 | CLEAN_DEPEND=$(DEPEND).tmp |
---|
| 158 | CLOBBER_DEPEND=$(DEPEND) |
---|
| 159 | |
---|
| 160 | # We deliberately don't have anything depend on the |
---|
| 161 | # $(DEPEND) file; otherwise it will get rebuilt even |
---|
| 162 | # on 'make clean' |
---|
| 163 | # |
---|
| 164 | |
---|
| 165 | ## HACK: Specific to gcc |
---|
| 166 | ## FIXME: The approach below is known to be conceptionally broken. |
---|
| 167 | depend-am: $(C_FILES) $(CC_FILES) $(S_FILES) |
---|
| 168 | ## Use gcc -M to generate dependencies |
---|
| 169 | ## Replace foo.o with $(ARCH)/foo.o |
---|
| 170 | ## Replace $(ARCH) value with string $(ARCH) |
---|
| 171 | ## so that it will for debug and profile cases |
---|
[bfba54e] | 172 | $(COMPILE) $(AM_CPPFLAGS) $(AM_CFLAGS) -M $^ | \ |
---|
[1ea70d78] | 173 | sed -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ |
---|
| 174 | -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp |
---|
| 175 | mv $(DEPEND).tmp $(DEPEND) |
---|
| 176 | depend: depend-am |
---|
| 177 | |
---|
[372e4e2] | 178 | # pull in dependencies if they exist |
---|
| 179 | ifeq (${DEPEND},$(wildcard ${DEPEND})) |
---|
| 180 | include ${DEPEND} |
---|
| 181 | @ENDIF@ |
---|
| 182 | |
---|
| 183 | |
---|
[1ea70d78] | 184 | # spell out all the LINK_FILE's, rather than using -lbsp, so |
---|
| 185 | # that $(LINK_FILES) can be a dependency |
---|
| 186 | |
---|
| 187 | LINK_OBJS = \ |
---|
| 188 | $(OBJS) \ |
---|
| 189 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) |
---|
| 190 | |
---|
| 191 | LINK_FILES =\ |
---|
| 192 | $(START_FILE) \ |
---|
| 193 | $(OBJS) \ |
---|
| 194 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) \ |
---|
| 195 | $(PROJECT_RELEASE)/lib/librtemsall$(LIBSUFFIX_VA) |
---|
| 196 | |
---|
| 197 | if RTEMS_USE_GCC |
---|
| 198 | if RTEMS_USE_GCC272 |
---|
| 199 | define make-rel |
---|
| 200 | $(LD) $(LDFLAGS_INCOMPLETE) $(XLDFLAGS) -o $@ $^ |
---|
| 201 | endef |
---|
| 202 | else |
---|
| 203 | ## gcc >= 2.8 |
---|
| 204 | define make-rel |
---|
| 205 | $(LINK.c) $(AM_CFLAGS) $(AM_LDFLAGS) \ |
---|
| 206 | -qnolinkcmds -nostdlib -Wl,-r $(XLDFLAGS) -o $@ $^ |
---|
| 207 | endef |
---|
| 208 | endif |
---|
| 209 | else |
---|
| 210 | ## non-gcc |
---|
| 211 | define make-rel |
---|
| 212 | $(LINK.c) $(AM_CFLAGS) $(AM_LDFLAGS) \ |
---|
| 213 | $(XLDFLAGS) -o $@ $^ |
---|
| 214 | endef |
---|
| 215 | endif |
---|
| 216 | |
---|
| 217 | ## ------------------------------------------------------------------------- |
---|
| 218 | |
---|
| 219 | ## translate VARIANT into VARIANT_V |
---|
| 220 | VARIANT = OPTIMIZE |
---|
| 221 | |
---|
| 222 | VARIANT_OPTIMIZE_V = OPTIMIZE |
---|
| 223 | VARIANT_DEBUG_V = DEBUG |
---|
| 224 | VARIANT_PROFILE_V = PROFILE |
---|
| 225 | VARIANT_optimize_V = OPTIMIZE |
---|
| 226 | VARIANT_debug_V = DEBUG |
---|
| 227 | VARIANT_profile_V = PROFILE |
---|
| 228 | |
---|
| 229 | VARIANT_V = $(VARIANT_$(VARIANT)_V) |
---|
| 230 | |
---|
| 231 | ## Setup the variant build subdirectory |
---|
| 232 | ARCH_OPTIMIZE_V = o-optimize |
---|
| 233 | ARCH_DEBUG_V = o-debug |
---|
| 234 | ARCH_PROFILE_V = o-profile |
---|
| 235 | |
---|
| 236 | ARCH__V = $(ARCH_OPTIMIZE_V) |
---|
| 237 | ARCH = $(ARCH_$(VARIANT_V)_V) |
---|
| 238 | |
---|
| 239 | ## Setup the library suffix |
---|
| 240 | LIBSUFFIX_OPTIMIZE_V = |
---|
| 241 | LIBSUFFIX_DEBUG_V = _g |
---|
| 242 | LIBSUFFIX_PROFILE_V = _p |
---|
| 243 | LIBSUFFIX__V = $(LIBSUFFIX_OPTIMIZE_V) |
---|
| 244 | |
---|
| 245 | LIB_VARIANT = $(LIBSUFFIX_$(VARIANT_V)_V) |
---|
| 246 | LIBSUFFIX_VA = $(LIB_VARIANT).a |
---|
| 247 | |
---|
| 248 | ## These are supposed to be set in make/custom/<bsp>.cfg |
---|
| 249 | ## CFLAGS_OPTIMIZE_V = |
---|
| 250 | ## CFLAGS_DEBUG_V = |
---|
| 251 | ## CFLAGS_PROFILE_V = |
---|
| 252 | CFLAGS__V = $(CFLAGS_OPTIMIZE_V) |
---|
| 253 | |
---|
| 254 | ## ------------------------------------------------------------------------ |
---|
| 255 | ## Setup hard-coded flags |
---|
| 256 | if RTEMS_USE_GCC |
---|
| 257 | if RTEMS_USE_GCC272 |
---|
| 258 | ## gcc < gcc-2.8 |
---|
| 259 | RTEMS_CFLAGS_OPTIMIZE_V = |
---|
| 260 | RTEMS_CFLAGS_DEBUG_V = -Wno-unused |
---|
| 261 | RTEMS_CFLAGS_PROFILE_V = |
---|
| 262 | else |
---|
| 263 | ## gcc >= gcc-2.8 |
---|
| 264 | RTEMS_CFLAGS_OPTIMIZE_V = |
---|
| 265 | RTEMS_CFLAGS_DEBUG_V = -qrtems_debug -Wno-unused |
---|
| 266 | RTEMS_CFLAGS_PROFILE_V = |
---|
| 267 | endif |
---|
| 268 | ## non-gcc |
---|
| 269 | ## We can't guess what flags might be required here. |
---|
| 270 | ## Pass the values from the environment if you want to apply them. |
---|
| 271 | endif |
---|
| 272 | RTEMS_CFLAGS__V = $(RTEMS_CFLAGS_OPTIMIZE_V) |
---|
| 273 | |
---|
| 274 | ## ------------------------------------------------------------------------- |
---|
| 275 | |
---|
[509f8351] | 276 | CC = @CC@ $(GCCSPECS) |
---|
| 277 | CXX = @CXX@ $(GCCSPECS) |
---|
[560aae24] | 278 | CPP = @CPP@ $(GCCSPECS) |
---|
| 279 | |
---|
[4dc2e9a] | 280 | LD = @LD@ |
---|
[63b24d29] | 281 | OBJCOPY = @OBJCOPY@ |
---|
| 282 | NM = @NM@ |
---|
| 283 | SIZE = @SIZE@ |
---|
| 284 | STRIP = @STRIP@ |
---|
[1ea70d78] | 285 | |
---|
[bfba54e] | 286 | |
---|
[03d5706] | 287 | ## |
---|
[bfba54e] | 288 | AM_CPPFLAGS = $(RTEMS_CPPFLAGS) |
---|
[1ea70d78] | 289 | |
---|
[bfba54e] | 290 | AM_CFLAGS = $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V) |
---|
| 291 | AM_CXXFLAGS = $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V) |
---|