[bffb938] | 1 | # |
---|
[c2c9c7e] | 2 | # Shared compiler for all GNU tools configurations |
---|
[bffb938] | 3 | # |
---|
| 4 | |
---|
| 5 | ## |
---|
[0707bd20] | 6 | # CFLAGS_OPTIMIZE_V, CFLAGS_DEBUG_V are the values we |
---|
[bffb938] | 7 | # would want the corresponding macros to be set to. |
---|
| 8 | # |
---|
[0707bd20] | 9 | # CFLAGS_OPTIMIZE, CFLAGS_DEBUG are set in the leaf |
---|
| 10 | # Makefiles by the 'debug:' targets to their _V values. |
---|
[bffb938] | 11 | # |
---|
| 12 | |
---|
| 13 | # default flags |
---|
[a110b68] | 14 | # XCPPFLAGS, XCFLAGS, XCXXFLAGS, XASFLAGS |
---|
| 15 | # are used to add flags from the shell |
---|
| 16 | # cf. make.info ("Implicit rules/variables" for details) |
---|
| 17 | |
---|
[4d20133] | 18 | # NOTE: Should these go to CPPFLAGS ? |
---|
[3e132a8] | 19 | CFLAGS_DEFAULT=-Wall |
---|
[4d20133] | 20 | |
---|
| 21 | # NOTE: CPU_CFLAGS should probably be renamed to CPU_CPPFLAGS |
---|
| 22 | # NOTE: CPU_DEFINES should probably be merged with CPU_CFLAGS |
---|
[9608320] | 23 | CPPFLAGS += $(CPU_DEFINES) $(CPU_CFLAGS) $(DEFINES) $(XCPPFLAGS) |
---|
[4d20133] | 24 | CFLAGS = $(CFLAGS_DEFAULT) $(XCFLAGS) |
---|
| 25 | CXXFLAGS = $(CFLAGS_DEFAULT) $(XCXXFLAGS) |
---|
[a110b68] | 26 | ASFLAGS = $(CPU_ASFLAGS) $(XASFLAGS) |
---|
[bffb938] | 27 | |
---|
[4cc89bd] | 28 | # NOTE: GCCSPECS probably belongs to CPPFLAGS |
---|
[df413e9] | 29 | GCCSPECS_OPTIMIZE_V = |
---|
[baa60b5e] | 30 | GCCSPECS_DEBUG_V = |
---|
[df413e9] | 31 | |
---|
| 32 | GCCSPECS = -B$(PROJECT_RELEASE)/lib/ -specs bsp_specs -qrtems |
---|
| 33 | GCCSPECS += $(GCCSPECS_$(VARIANT_V)_V) |
---|
| 34 | |
---|
[4cc89bd] | 35 | CC += $(GCCSPECS) |
---|
| 36 | CXX += $(GCCSPECS) |
---|
| 37 | |
---|
[72f9937b] | 38 | CPPFLAGS += |
---|
[bffb938] | 39 | |
---|
| 40 | # Define this to yes if C++ is included in the development environment. |
---|
| 41 | # This requires that at least the GNU C++ compiler and libg++ be installed. |
---|
[d6c83529] | 42 | ifeq ($(HAS_CPLUSPLUS),yes) |
---|
[bffb938] | 43 | CPLUS_LD_LIBS += $(PROJECT_RELEASE)/lib/librtems++$(LIBSUFFIX_VA) |
---|
| 44 | endif |
---|
| 45 | |
---|
[98100d2] | 46 | # debug flag; |
---|
[83a2fad] | 47 | CFLAGS_DEBUG_V ?= -O0 -g |
---|
[98db96e] | 48 | CXXFLAGS_DEBUG_V ?= $(CFLAGS_DEBUG_V) |
---|
[a858910] | 49 | |
---|
[8ef3818] | 50 | # when debugging, optimize flag: typically empty |
---|
| 51 | # some compilers do allow optimization with their "-g" |
---|
[83a2fad] | 52 | CFLAGS_OPTIMIZE_V ?= -O2 -g |
---|
[98db96e] | 53 | CXXFLAGS_OPTIMIZE_V ?= $(CFLAGS_OPTIMIZE_V) |
---|
[8ef3818] | 54 | |
---|
[df49c60] | 55 | ifndef AUTOMAKE |
---|
[f67eee1] | 56 | CPPFLAGS_$(VARIANT)=$(CPPFLAGS_$(VARIANT)_V) |
---|
[db28d621] | 57 | CFLAGS_$(VARIANT) =$(CFLAGS_$(VARIANT)_V) |
---|
| 58 | CXXFLAGS_$(VARIANT)=$(CXXFLAGS_$(VARIANT)_V) |
---|
[df49c60] | 59 | endif |
---|
[bffb938] | 60 | |
---|
[df49c60] | 61 | ifndef AUTOMAKE |
---|
[f67eee1] | 62 | CPPFLAGS += $(CPPFLAGS_OPTIMIZE) $(CPPFLAGS_DEBUG) |
---|
[0707bd20] | 63 | CFLAGS += $(CFLAGS_OPTIMIZE) $(CFLAGS_DEBUG) |
---|
| 64 | CXXFLAGS += $(CXXFLAGS_OPTIMIZE) $(CXXFLAGS_DEBUG) |
---|
[df49c60] | 65 | endif |
---|
[bffb938] | 66 | |
---|
| 67 | # List of library paths without -L |
---|
| 68 | LD_PATHS= $(PROJECT_RELEASE)/lib |
---|
| 69 | |
---|
| 70 | # ld flag for incomplete link |
---|
| 71 | LDFLAGS_INCOMPLETE = -r |
---|
| 72 | |
---|
[0707bd20] | 73 | # LDFLAGS=$(LDFLAGS_DEBUG) $(LD_PATHS:%=-L%) |
---|
[e59d23ad] | 74 | LDFLAGS += $(LDFLAGS_DEBUG) |
---|
[bffb938] | 75 | |
---|
| 76 | # |
---|
| 77 | # Stuff to clean and clobber for the compiler and its tools |
---|
| 78 | # |
---|
| 79 | |
---|
| 80 | CLEAN_CC = a.out *.o *.BAK |
---|
| 81 | CLOBBER_CC = |
---|
| 82 | |
---|
| 83 | # |
---|
| 84 | # Client compiler and support tools |
---|
| 85 | # |
---|
| 86 | |
---|
[53a27c2] | 87 | # CPP command to write file to standard output with warnings suppressed |
---|
| 88 | CPP=$(CC) -E -w |
---|
[bffb938] | 89 | |
---|
| 90 | # egrep regexp to ignore symbol table entries in ar archives. |
---|
| 91 | # Only used to make sure we skip them when coalescing libraries. |
---|
| 92 | # skip __.SYMDEF and empty names (maybe bug in ranlib??). |
---|
| 93 | AR_SYMBOL_TABLE="HIGHLY-UNLIKELY-TO-CONFLICT" |
---|
| 94 | ARFLAGS=ruv |
---|
| 95 | |
---|
| 96 | # |
---|
| 97 | # How to compile stuff into ${ARCH} subdirectory |
---|
| 98 | # |
---|
| 99 | |
---|
| 100 | ${ARCH}/%.o: %.c |
---|
[9608320] | 101 | ${COMPILE.c} $(AM_CPPFLAGS) $(AM_CFLAGS) -o $@ $< |
---|
[bffb938] | 102 | |
---|
| 103 | ${ARCH}/%.o: %.cc |
---|
[9608320] | 104 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
[bffb938] | 105 | |
---|
[07001360] | 106 | ${ARCH}/%.o: %.cpp |
---|
[9608320] | 107 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
[07001360] | 108 | |
---|
| 109 | ${ARCH}/%.o: %.cxx |
---|
[9608320] | 110 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
[07001360] | 111 | |
---|
| 112 | ${ARCH}/%.o: %.C |
---|
[9608320] | 113 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
[07001360] | 114 | |
---|
[0162910] | 115 | ${ARCH}/%.o: %.S |
---|
[9608320] | 116 | ${COMPILE.S} $(AM_CPPFLAGS) -DASM -o $@ $< |
---|
[4d20133] | 117 | |
---|
[bffb938] | 118 | # Make foo.rel from foo.o |
---|
| 119 | ${ARCH}/%.rel: ${ARCH}/%.o |
---|
[df49c60] | 120 | ${make-rel} |
---|
[bffb938] | 121 | |
---|
| 122 | # create $(ARCH)/pgm from pgm.sh |
---|
[5b8c1b7] | 123 | ${ARCH}/%: %.sh |
---|
[bffb938] | 124 | $(RM) $@ |
---|
| 125 | $(CP) $< $@ |
---|
| 126 | $(CHMOD) +x $@ |
---|
| 127 | |
---|
| 128 | # Dependency files for use by gmake |
---|
[d6c83529] | 129 | # NOTE: we don't put them into $(ARCH) |
---|
[bffb938] | 130 | # so that 'make clean' doesn't blow it away |
---|
| 131 | |
---|
[d6c83529] | 132 | DEPEND=Depends-${ARCH} |
---|
[bffb938] | 133 | |
---|
| 134 | CLEAN_DEPEND=$(DEPEND).tmp |
---|
| 135 | CLOBBER_DEPEND=$(DEPEND) |
---|
| 136 | |
---|
| 137 | # We deliberately don't have anything depend on the |
---|
| 138 | # $(DEPEND) file; otherwise it will get rebuilt even |
---|
| 139 | # on 'make clean' |
---|
| 140 | # |
---|
| 141 | |
---|
[9f4868c] | 142 | depend-am: $(C_FILES) $(CC_FILES) $(S_FILES) |
---|
[bffb938] | 143 | ifneq ($(words $(C_FILES) $(CC_FILES) $(S_FILES)), 0) |
---|
| 144 | # Use gcc -M to generate dependencies |
---|
| 145 | # Replace foo.o with $(ARCH)/foo.o |
---|
| 146 | # Replace $(ARCH) value with string $(ARCH) |
---|
[0707bd20] | 147 | # so that it will for debug cases |
---|
[df49c60] | 148 | $(COMPILE.c) $(AM_CPPFLAGS) $(AM_CFLAGS) -M $^ | \ |
---|
[bffb938] | 149 | $(SED) -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ |
---|
| 150 | -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp |
---|
| 151 | $(MV) $(DEPEND).tmp $(DEPEND) |
---|
| 152 | endif |
---|
[9f4868c] | 153 | depend: depend-am |
---|
[bffb938] | 154 | |
---|
| 155 | # spell out all the LINK_FILE's, rather than using -lbsp, so |
---|
| 156 | # that $(LINK_FILES) can be a dependency |
---|
| 157 | |
---|
[98100d2] | 158 | # |
---|
| 159 | # NOTE: a rule to link an rtems' application should look similar to this |
---|
| 160 | # (cf. "make-exe" in make/custom/*.cfg): |
---|
| 161 | # |
---|
| 162 | # gcc28: |
---|
| 163 | # $(PGM): $(LINK_FILES) |
---|
[30cde042] | 164 | # $(CC) $(CFLAGS) -o $@ $(LINK_OBJS) $(LINK_LIBS) |
---|
[98100d2] | 165 | # |
---|
| 166 | |
---|
| 167 | LINK_OBJS =\ |
---|
[bffb938] | 168 | $(CONSTRUCTOR) \ |
---|
[5fa9b70] | 169 | $(OBJS) |
---|
[bffb938] | 170 | |
---|
[98100d2] | 171 | LINK_FILES =\ |
---|
| 172 | $(CONSTRUCTOR) \ |
---|
| 173 | $(OBJS) \ |
---|
[6703f877] | 174 | $(PROJECT_RELEASE)/lib/librtemsbsp$(LIBSUFFIX_VA) \ |
---|
[88f60e26] | 175 | $(PROJECT_RELEASE)/lib/librtemscpu$(LIBSUFFIX_VA) |
---|
[98100d2] | 176 | |
---|
| 177 | LINK_LIBS += $(LD_LIBS) |
---|
[bffb938] | 178 | |
---|
| 179 | # |
---|
| 180 | # Allow user to override link commands (to build a prom image, perhaps) |
---|
| 181 | # |
---|
| 182 | ifndef LINKCMDS |
---|
| 183 | LINKCMDS=$(PROJECT_RELEASE)/lib/linkcmds |
---|
| 184 | endif |
---|
| 185 | |
---|
| 186 | define make-rel |
---|
[ccf2cfd] | 187 | $(LINK.c) $(CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) \ |
---|
[df49c60] | 188 | -qnolinkcmds -nostdlib -Wl,-r $(XLDFLAGS) -o $@ $^ |
---|
| 189 | endef |
---|