[9ea3832c] | 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 | |
---|
[d46ec86] | 33 | ## CFLAGS_OPTIMIZE_V, CFLAGS_DEBUG_V are the values we |
---|
[9ea3832c] | 34 | ## would want the corresponding macros to be set to. |
---|
| 35 | ## |
---|
[d46ec86] | 36 | ## CFLAGS_OPTIMIZE, CFLAGS_DEBUG are set by the |
---|
| 37 | ## 'VARIANT=<OPTIMIZE|DEBUG>' targets to their _V values. |
---|
[9ea3832c] | 38 | |
---|
[5261406] | 39 | ## XCPPFLAGS, XCFLAGS, XASFLAGS |
---|
[9ea3832c] | 40 | ## are used to add flags from the shell |
---|
| 41 | ## cf. make.info ("Implicit rules/variables" for details) |
---|
| 42 | |
---|
| 43 | DEFS = @DEFS@ |
---|
| 44 | |
---|
[baa8dd7c] | 45 | CPPFLAGS = @CPPFLAGS@ $(CPU_DEFINES) $(DEFINES) $(XCPPFLAGS) |
---|
| 46 | CFLAGS = @RTEMS_CFLAGS@ $(XCFLAGS) |
---|
[9ea3832c] | 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 | |
---|
[5261406] | 57 | CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS) |
---|
[9ea3832c] | 58 | |
---|
[5ef82f97] | 59 | ${ARCH}/%.$(OBJEXT): %.c $(ARCH)/$(dirstamp) |
---|
[9ea3832c] | 60 | ${COMPILE} -o $@ -c $< |
---|
| 61 | |
---|
[5ef82f97] | 62 | ${ARCH}/%.$(OBJEXT): %.S $(ARCH)/$(dirstamp) |
---|
[5261406] | 63 | ${CCASCOMPILE} -o $@ -c $< |
---|
[9ea3832c] | 64 | |
---|
[c3efdb3] | 65 | # Make foo.rel from foo.$(OBJEXT) |
---|
| 66 | ${ARCH}/%.rel: ${ARCH}/%.$(OBJEXT) |
---|
[9ea3832c] | 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 | |
---|
[b9184faa] | 80 | if RTEMS_USE_GCC |
---|
[9ea3832c] | 81 | ## HACK: Specific to gcc |
---|
| 82 | ## FIXME: The approach below is known to be conceptionally broken. |
---|
[b9184faa] | 83 | depend-gcc: $(C_FILES) $(CC_FILES) $(S_FILES) |
---|
[9ea3832c] | 84 | ## Use gcc -M to generate dependencies |
---|
[c3efdb3] | 85 | ## Replace foo.$(OBJEXT) with $(ARCH)/foo.$(OBJEXT) |
---|
[9ea3832c] | 86 | ## Replace $(ARCH) value with string $(ARCH) |
---|
[d46ec86] | 87 | ## so that it will for debug cases |
---|
[9ea3832c] | 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@ |
---|
[b9184faa] | 97 | endif |
---|
| 98 | depend: depend-gcc |
---|
[9ea3832c] | 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_optimize_V = OPTIMIZE |
---|
| 108 | VARIANT_debug_V = DEBUG |
---|
| 109 | |
---|
| 110 | VARIANT_V = $(VARIANT_$(VARIANT)_V) |
---|
| 111 | |
---|
| 112 | ## Setup the variant build subdirectory |
---|
| 113 | ARCH_OPTIMIZE_V = o-optimize |
---|
| 114 | ARCH_DEBUG_V = o-debug |
---|
| 115 | |
---|
| 116 | ARCH__V = $(ARCH_OPTIMIZE_V) |
---|
| 117 | ARCH = $(ARCH_$(VARIANT_V)_V) |
---|
| 118 | |
---|
[5ef82f97] | 119 | ${ARCH}/$(dirstamp): |
---|
[a953fa1] | 120 | @$(mkdir_p) $(ARCH) |
---|
[5ef82f97] | 121 | @: > $(ARCH)/$(dirstamp) |
---|
[b9184faa] | 122 | |
---|
[9ea3832c] | 123 | ## Setup the library suffix |
---|
| 124 | LIBSUFFIX_OPTIMIZE_V = |
---|
| 125 | LIBSUFFIX_DEBUG_V = _g |
---|
| 126 | LIBSUFFIX__V = $(LIBSUFFIX_OPTIMIZE_V) |
---|
| 127 | |
---|
| 128 | LIB_VARIANT = $(LIBSUFFIX_$(VARIANT_V)_V) |
---|
| 129 | |
---|
| 130 | ## These are supposed to be set in make/custom/<bsp>.cfg |
---|
[8e4cd5a] | 131 | CPU_CFLAGS = @CPU_CFLAGS@ |
---|
| 132 | CFLAGS_OPTIMIZE_V = @CFLAGS_OPTIMIZE_V@ |
---|
| 133 | CFLAGS_DEBUG_V = @CFLAGS_DEBUG_V@ |
---|
[9ea3832c] | 134 | CFLAGS__V = $(CFLAGS_OPTIMIZE_V) |
---|
| 135 | |
---|
| 136 | ## ------------------------------------------------------------------------ |
---|
| 137 | ## Setup hard-coded flags |
---|
| 138 | if RTEMS_USE_GCC |
---|
| 139 | ## gcc >= gcc-2.8 |
---|
| 140 | RTEMS_CFLAGS_OPTIMIZE_V = |
---|
[14620166] | 141 | RTEMS_CFLAGS_DEBUG_V = -Wno-unused |
---|
[9ea3832c] | 142 | |
---|
| 143 | ## non-gcc |
---|
| 144 | ## We can't guess what flags might be required here. |
---|
| 145 | ## Pass the values from the environment if you want to apply them. |
---|
| 146 | endif |
---|
| 147 | RTEMS_CFLAGS__V = $(RTEMS_CFLAGS_OPTIMIZE_V) |
---|
| 148 | |
---|
| 149 | ## ------------------------------------------------------------------------- |
---|
| 150 | AM_CPPFLAGS = $(RTEMS_CPPFLAGS) |
---|
[baa8dd7c] | 151 | AM_CFLAGS = |
---|
[28ed8f3] | 152 | AM_CCASFLAGS = $(RTEMS_CPPFLAGS) $(RTEMS_ASFLAGS) |
---|