[bffb938] | 1 | # |
---|
[c2c9c7e] | 2 | # Shared compiler for all GNU tools configurations |
---|
| 3 | # |
---|
| 4 | # $Id$ |
---|
[bffb938] | 5 | # |
---|
| 6 | |
---|
| 7 | ## |
---|
[888622c4] | 8 | # CFLAGS_OPTIMIZE_V, CFLAGS_DEBUG_V are the values we |
---|
[bffb938] | 9 | # would want the corresponding macros to be set to. |
---|
| 10 | # |
---|
[888622c4] | 11 | # CFLAGS_OPTIMIZE, CFLAGS_DEBUG are set in the leaf |
---|
| 12 | # Makefiles by the 'debug:' targets to their _V values. |
---|
[bffb938] | 13 | # |
---|
| 14 | |
---|
| 15 | # default flags |
---|
[a110b68] | 16 | # XCPPFLAGS, XCFLAGS, XCXXFLAGS, XASFLAGS |
---|
| 17 | # are used to add flags from the shell |
---|
| 18 | # cf. make.info ("Implicit rules/variables" for details) |
---|
| 19 | |
---|
[4d20133] | 20 | # NOTE: Should these go to CPPFLAGS ? |
---|
[65e6b542] | 21 | CFLAGS_DEFAULT=-g -Wall |
---|
[4d20133] | 22 | |
---|
| 23 | # NOTE: CPU_CFLAGS should probably be renamed to CPU_CPPFLAGS |
---|
| 24 | # NOTE: CPU_DEFINES should probably be merged with CPU_CFLAGS |
---|
[9608320] | 25 | CPPFLAGS += $(CPU_DEFINES) $(CPU_CFLAGS) $(DEFINES) $(XCPPFLAGS) |
---|
[4d20133] | 26 | CFLAGS = $(CFLAGS_DEFAULT) $(XCFLAGS) |
---|
| 27 | CXXFLAGS = $(CFLAGS_DEFAULT) $(XCXXFLAGS) |
---|
[a110b68] | 28 | ASFLAGS = $(CPU_ASFLAGS) $(XASFLAGS) |
---|
[bffb938] | 29 | |
---|
[4cc89bd] | 30 | # NOTE: GCCSPECS probably belongs to CPPFLAGS |
---|
| 31 | # Unfortunately, many custom/*.cfg files do not pass CPPFLAGS |
---|
| 32 | # to their gcc-2.8 make-exe rules |
---|
| 33 | GCCSPECS = -B$(PROJECT_RELEASE)/lib/ -specs bsp_specs -qrtems |
---|
| 34 | |
---|
| 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; |
---|
[ac61209b] | 47 | CFLAGS_DEBUG_V+=-Wno-unused |
---|
[8ef3818] | 48 | CXXFLAGS_DEBUG_V+= |
---|
[bffb938] | 49 | |
---|
[a858910] | 50 | CFLAGS_DEBUG_V+=-qrtems_debug |
---|
[8ef3818] | 51 | CXXFLAGS_DEBUG_V+=-qrtems_debug |
---|
[a858910] | 52 | |
---|
[8ef3818] | 53 | # when debugging, optimize flag: typically empty |
---|
| 54 | # some compilers do allow optimization with their "-g" |
---|
[c2646c8] | 55 | CFLAGS_OPTIMIZE_V+=-g |
---|
| 56 | CXXFLAGS_OPTIMIZE_V+=-g |
---|
[8ef3818] | 57 | |
---|
[df49c60] | 58 | ifndef AUTOMAKE |
---|
[c2646c8] | 59 | CFLAGS_$(VARIANT) =$(CFLAGS_$(VARIANT)_V) |
---|
| 60 | CXXFLAGS_$(VARIANT)=$(CXXFLAGS_$(VARIANT)_V) |
---|
[df49c60] | 61 | endif |
---|
[bffb938] | 62 | |
---|
[df49c60] | 63 | ifndef AUTOMAKE |
---|
[888622c4] | 64 | CFLAGS += $(CFLAGS_OPTIMIZE) $(CFLAGS_DEBUG) |
---|
| 65 | CXXFLAGS += $(CXXFLAGS_OPTIMIZE) $(CXXFLAGS_DEBUG) |
---|
[df49c60] | 66 | endif |
---|
[bffb938] | 67 | |
---|
| 68 | # List of library paths without -L |
---|
| 69 | LD_PATHS= $(PROJECT_RELEASE)/lib |
---|
| 70 | |
---|
| 71 | # libraries you want EVERYONE to link with |
---|
| 72 | #LD_LIBS= |
---|
| 73 | |
---|
| 74 | # ld flag to ensure pure-text |
---|
| 75 | #LDFLAGS_MUST_BE_PURE_V = |
---|
| 76 | |
---|
| 77 | # ld flag for [un]shared objects |
---|
| 78 | #LDFLAGS_STATIC_LIBRARIES_V = |
---|
| 79 | #LDFLAGS_SHARED_LIBRARIES_V = |
---|
| 80 | |
---|
| 81 | # ld flag for incomplete link |
---|
| 82 | LDFLAGS_INCOMPLETE = -r |
---|
| 83 | |
---|
| 84 | # Special linker options when building lib.so |
---|
| 85 | LDFLAGS_DYNAMIC_V = ?? |
---|
| 86 | |
---|
| 87 | # Some dynamic linking systems want the preferred name recorded in the binary |
---|
| 88 | # ref: src/libxil/Makefile |
---|
| 89 | LDFLAGS_DYNAMIC_LIBNAME_V = -h $(DYNAMIC_VERSION_LIBNAME) |
---|
| 90 | |
---|
| 91 | # ld flags for profiling, debugging |
---|
[ccf2cfd] | 92 | LDFLAGS_DEBUG_V = -qrtems_debug |
---|
[bffb938] | 93 | |
---|
[888622c4] | 94 | LDFLAGS=$(LDFLAGS_DEBUG) $(LD_PATHS:%=-L %) |
---|
[bffb938] | 95 | |
---|
| 96 | # |
---|
| 97 | # Stuff to clean and clobber for the compiler and its tools |
---|
| 98 | # |
---|
| 99 | |
---|
| 100 | CLEAN_CC = a.out *.o *.BAK |
---|
| 101 | CLOBBER_CC = |
---|
| 102 | |
---|
| 103 | # |
---|
| 104 | # Client compiler and support tools |
---|
| 105 | # |
---|
| 106 | |
---|
| 107 | # CPP command to write file to standard output |
---|
[93f79c0f] | 108 | CPP=$(CC) -E -w -Wp,-$$ |
---|
[bffb938] | 109 | |
---|
| 110 | # egrep regexp to ignore symbol table entries in ar archives. |
---|
| 111 | # Only used to make sure we skip them when coalescing libraries. |
---|
| 112 | # skip __.SYMDEF and empty names (maybe bug in ranlib??). |
---|
| 113 | AR_SYMBOL_TABLE="HIGHLY-UNLIKELY-TO-CONFLICT" |
---|
| 114 | ARFLAGS=ruv |
---|
| 115 | |
---|
| 116 | # |
---|
| 117 | # How to compile stuff into ${ARCH} subdirectory |
---|
| 118 | # |
---|
| 119 | |
---|
| 120 | ${ARCH}/%.o: %.c |
---|
[9608320] | 121 | ${COMPILE.c} $(AM_CPPFLAGS) $(AM_CFLAGS) -o $@ $< |
---|
[bffb938] | 122 | |
---|
| 123 | ${ARCH}/%.o: %.cc |
---|
[9608320] | 124 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
[bffb938] | 125 | |
---|
[07001360] | 126 | ${ARCH}/%.o: %.cpp |
---|
[9608320] | 127 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
[07001360] | 128 | |
---|
| 129 | ${ARCH}/%.o: %.cxx |
---|
[9608320] | 130 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
[07001360] | 131 | |
---|
| 132 | ${ARCH}/%.o: %.C |
---|
[9608320] | 133 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
[07001360] | 134 | |
---|
[0162910] | 135 | ${ARCH}/%.o: %.S |
---|
[9608320] | 136 | ${COMPILE.S} $(AM_CPPFLAGS) -DASM -o $@ $< |
---|
[4d20133] | 137 | |
---|
[bffb938] | 138 | # Make foo.rel from foo.o |
---|
| 139 | ${ARCH}/%.rel: ${ARCH}/%.o |
---|
[df49c60] | 140 | ${make-rel} |
---|
[bffb938] | 141 | |
---|
| 142 | # create $(ARCH)/pgm from pgm.sh |
---|
[5b8c1b7] | 143 | ${ARCH}/%: %.sh |
---|
[bffb938] | 144 | $(RM) $@ |
---|
| 145 | $(CP) $< $@ |
---|
| 146 | $(CHMOD) +x $@ |
---|
| 147 | |
---|
| 148 | # Dependency files for use by gmake |
---|
[d6c83529] | 149 | # NOTE: we don't put them into $(ARCH) |
---|
[bffb938] | 150 | # so that 'make clean' doesn't blow it away |
---|
| 151 | |
---|
[d6c83529] | 152 | DEPEND=Depends-${ARCH} |
---|
[bffb938] | 153 | |
---|
| 154 | CLEAN_DEPEND=$(DEPEND).tmp |
---|
| 155 | CLOBBER_DEPEND=$(DEPEND) |
---|
| 156 | |
---|
| 157 | # We deliberately don't have anything depend on the |
---|
| 158 | # $(DEPEND) file; otherwise it will get rebuilt even |
---|
| 159 | # on 'make clean' |
---|
| 160 | # |
---|
| 161 | |
---|
[9f4868c] | 162 | depend-am: $(C_FILES) $(CC_FILES) $(S_FILES) |
---|
[bffb938] | 163 | ifneq ($(words $(C_FILES) $(CC_FILES) $(S_FILES)), 0) |
---|
| 164 | # Use gcc -M to generate dependencies |
---|
| 165 | # Replace foo.o with $(ARCH)/foo.o |
---|
| 166 | # Replace $(ARCH) value with string $(ARCH) |
---|
[888622c4] | 167 | # so that it will for debug cases |
---|
[df49c60] | 168 | $(COMPILE.c) $(AM_CPPFLAGS) $(AM_CFLAGS) -M $^ | \ |
---|
[bffb938] | 169 | $(SED) -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ |
---|
| 170 | -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp |
---|
| 171 | $(MV) $(DEPEND).tmp $(DEPEND) |
---|
| 172 | endif |
---|
[9f4868c] | 173 | depend: depend-am |
---|
[bffb938] | 174 | |
---|
| 175 | # spell out all the LINK_FILE's, rather than using -lbsp, so |
---|
| 176 | # that $(LINK_FILES) can be a dependency |
---|
| 177 | |
---|
| 178 | # Start file must be one of |
---|
| 179 | # $(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).o |
---|
| 180 | # $(PROJECT_RELEASE)/lib/asmiface$(LIB_VARIANT).o |
---|
| 181 | # It defaults to start.o, but an app can override it. |
---|
| 182 | |
---|
| 183 | ifeq ($(START_BASE),) |
---|
| 184 | START_FILE= |
---|
| 185 | else |
---|
| 186 | START_FILE=$(PROJECT_RELEASE)/lib/$(START_BASE)$(LIB_VARIANT).o |
---|
| 187 | endif |
---|
| 188 | |
---|
[98100d2] | 189 | # |
---|
| 190 | # NOTE: a rule to link an rtems' application should look similar to this |
---|
| 191 | # (cf. "make-exe" in make/custom/*.cfg): |
---|
| 192 | # |
---|
| 193 | # gcc28: |
---|
| 194 | # $(PGM): $(LINK_FILES) |
---|
[30cde042] | 195 | # $(CC) $(CFLAGS) -o $@ $(LINK_OBJS) $(LINK_LIBS) |
---|
[98100d2] | 196 | # |
---|
| 197 | |
---|
| 198 | LINK_OBJS =\ |
---|
[bffb938] | 199 | $(CONSTRUCTOR) \ |
---|
| 200 | $(OBJS) \ |
---|
[3a8915e] | 201 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) |
---|
[bffb938] | 202 | |
---|
[98100d2] | 203 | LINK_FILES =\ |
---|
[bffb938] | 204 | $(START_FILE) \ |
---|
[98100d2] | 205 | $(CONSTRUCTOR) \ |
---|
| 206 | $(OBJS) \ |
---|
| 207 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) \ |
---|
[6703f877] | 208 | $(PROJECT_RELEASE)/lib/librtemsbsp$(LIBSUFFIX_VA) \ |
---|
[88f60e26] | 209 | $(PROJECT_RELEASE)/lib/librtemscpu$(LIBSUFFIX_VA) |
---|
[98100d2] | 210 | |
---|
| 211 | LINK_LIBS += $(LD_LIBS) |
---|
[bffb938] | 212 | |
---|
| 213 | # |
---|
| 214 | # Allow user to override link commands (to build a prom image, perhaps) |
---|
| 215 | # |
---|
| 216 | ifndef LINKCMDS |
---|
| 217 | LINKCMDS=$(PROJECT_RELEASE)/lib/linkcmds |
---|
| 218 | endif |
---|
| 219 | |
---|
| 220 | define make-rel |
---|
[ccf2cfd] | 221 | $(LINK.c) $(CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) \ |
---|
[df49c60] | 222 | -qnolinkcmds -nostdlib -Wl,-r $(XLDFLAGS) -o $@ $^ |
---|
| 223 | endef |
---|