[bffb938] | 1 | # |
---|
| 2 | # $Id$ |
---|
| 3 | # |
---|
| 4 | # gcc 2.6.x compiler for a "native" nocpu/nobsp system |
---|
| 5 | # Compiler (and tools) configuration |
---|
| 6 | # |
---|
| 7 | |
---|
| 8 | # Prefix on the installed GNU tools |
---|
| 9 | # Just use the native tools |
---|
| 10 | GNU_TOOLS_PREFIX= |
---|
| 11 | |
---|
| 12 | # Additional target names (other than debug, profile) |
---|
| 13 | TARGET_VARIANTS += |
---|
| 14 | |
---|
| 15 | # |
---|
| 16 | # Pre-processor defines using the target options header file. |
---|
| 17 | # |
---|
| 18 | # Local tailoring (on the command line) can be done by setting XCFLAGS |
---|
| 19 | # or XCPPFLAGS -- neither of which are never set in the Makefile's |
---|
| 20 | # |
---|
| 21 | |
---|
| 22 | CPPFLAGS=$(CFLAGS) $(XCPPFLAGS) $(DEFINES) |
---|
| 23 | |
---|
| 24 | CPLUS_CPPFLAGS=$(CFLAGS) $(XCPPFLAGS) $(DEFINES) |
---|
| 25 | |
---|
| 26 | # This section makes the target dependent options file. |
---|
| 27 | |
---|
| 28 | # NDEBUG (C library) |
---|
| 29 | # if defined asserts do not generate code. This is commonly used |
---|
| 30 | # as a command line option. |
---|
| 31 | # |
---|
| 32 | # RTEMS_TEST_NO_PAUSE (RTEMS tests) |
---|
| 33 | # do not pause between screens of output in the rtems tests |
---|
| 34 | # |
---|
| 35 | # NO_TABLE_MOVE (SPARC PORT) |
---|
| 36 | # do not have a second trap table -- use the BSP's |
---|
| 37 | # |
---|
| 38 | # STACK_CHECKER_ON (RTEMS support code) |
---|
| 39 | # If defined, stack bounds checking is enabled. |
---|
| 40 | # |
---|
| 41 | # RTEMS_DEBUG (RTEMS) |
---|
| 42 | # If defined, debug checks in RTEMS and support library code are enabled. |
---|
| 43 | |
---|
| 44 | define make-target-options |
---|
| 45 | echo "/* #define NDEBUG 1 */ " >>$@ |
---|
| 46 | echo "#define RTEMS_TEST_NO_PAUSE 1" >>$@ |
---|
| 47 | echo "/* #define STACK_CHECKER_ON 1 */" >>$@ |
---|
| 48 | echo "/* #define RTEMS_DEBUG 1 */" >>$@ |
---|
| 49 | endef |
---|
| 50 | |
---|
| 51 | # |
---|
| 52 | # Local tailoring (on the command line) can be done by setting XCFLAGS |
---|
| 53 | # which is never set in the Makefile's |
---|
| 54 | # |
---|
| 55 | |
---|
| 56 | # |
---|
| 57 | # CFLAGS_OPTIMIZE_V, CFLAGS_DEBUG_V, CFLAGS_PROFILE_V are the values we |
---|
| 58 | # would want the corresponding macros to be set to. |
---|
| 59 | # |
---|
| 60 | # CFLAGS_OPTIMIZE, CFLAGS_DEBUG, CFLAGS_PROFILE are set in the leaf |
---|
| 61 | # Makefiles by the 'debug:' and 'profile:' targets to their _V values. |
---|
| 62 | # |
---|
| 63 | |
---|
| 64 | # default flags |
---|
| 65 | |
---|
| 66 | # |
---|
| 67 | # This contains the compiler options necessary to select the CPU model |
---|
| 68 | # and (hopefully) optimize for it. |
---|
| 69 | # |
---|
| 70 | CPU_CFLAGS = |
---|
| 71 | |
---|
[65e6b542] | 72 | CFLAGS_DEFAULT = $(CPU_CFLAGS) -Wall |
---|
[bffb938] | 73 | |
---|
| 74 | # optimize flag: typically -0, could use -O4 or -fast |
---|
| 75 | # -O4 is ok for RTEMS |
---|
| 76 | CFLAGS_OPTIMIZE_V=-O4 -fomit-frame-pointer |
---|
| 77 | |
---|
| 78 | # debug flag; typically -g |
---|
[5d1ea96] | 79 | CFLAGS_DEBUG_V=-g -Wno-unused |
---|
[bffb938] | 80 | |
---|
| 81 | # profile flag; use gprof(1) |
---|
| 82 | CFLAGS_PROFILE_V=-pg |
---|
| 83 | |
---|
| 84 | # default is to optimize |
---|
| 85 | CFLAGS_OPTIMIZE=$(CFLAGS_OPTIMIZE_V) |
---|
| 86 | |
---|
| 87 | # dynamic libraries |
---|
| 88 | CFLAGS_DYNAMIC_V=-fpic |
---|
[a110b68] | 89 | # ASFLAGS_DYNAMIC_V= |
---|
[bffb938] | 90 | |
---|
[a5cb673] | 91 | CFLAGS=$(CFLAGS_DEFAULT) $(CFLAGS_OPTIMIZE) $(CFLAGS_DEBUG) $(CFLAGS_PROFILE) \ |
---|
[bffb938] | 92 | -I $(PROJECT_INCLUDE) |
---|
| 93 | |
---|
| 94 | # List of library paths without -L |
---|
| 95 | LD_PATHS= $(PROJECT_RELEASE)/lib |
---|
| 96 | |
---|
| 97 | # libraries you want EVERYONE to link with |
---|
| 98 | LD_LIBS= |
---|
| 99 | |
---|
| 100 | # ld flag to ensure pure-text |
---|
| 101 | LDFLAGS_MUST_BE_PURE_V = |
---|
| 102 | |
---|
| 103 | # ld flag for [un]shared objects |
---|
| 104 | LDFLAGS_STATIC_LIBRARIES_V = |
---|
| 105 | LDFLAGS_SHARED_LIBRARIES_V = |
---|
| 106 | |
---|
| 107 | # ld flag for incomplete link |
---|
| 108 | LDFLAGS_INCOMPLETE = -r |
---|
| 109 | |
---|
| 110 | # Special linker options when building lib.so |
---|
| 111 | LDFLAGS_DYNAMIC_V = ?? |
---|
| 112 | |
---|
| 113 | # Some dynamic linking systems want the preferred name recorded in the binary |
---|
| 114 | # ref: src/libxil/Makefile |
---|
| 115 | LDFLAGS_DYNAMIC_LIBNAME_V = -h $(DYNAMIC_VERSION_LIBNAME) |
---|
| 116 | |
---|
| 117 | # ld flags for profiling, debugging |
---|
| 118 | LDFLAGS_PROFILE_V = |
---|
| 119 | LDFLAGS_DEBUG_V = |
---|
| 120 | |
---|
| 121 | LDFLAGS=$(LDFLAGS_PROFILE) $(LDFLAGS_DEBUG) $(LD_PATHS:%=-L %) |
---|
| 122 | |
---|
| 123 | # |
---|
| 124 | # Stuff to clean and clobber for the compiler and its tools |
---|
| 125 | # |
---|
| 126 | |
---|
| 127 | CLEAN_CC = a.out *.o *.BAK |
---|
| 128 | CLOBBER_CC = |
---|
| 129 | |
---|
| 130 | # |
---|
| 131 | # Client compiler and support tools |
---|
| 132 | # |
---|
| 133 | |
---|
| 134 | CC=gcc |
---|
| 135 | CXX=$(CC) |
---|
| 136 | CCC=$(CXX) |
---|
| 137 | |
---|
| 138 | # CPP command to write file to standard output |
---|
| 139 | CPP=$(CC) -E |
---|
| 140 | |
---|
| 141 | AS=as |
---|
| 142 | ASPP=ERROR_NO_ASPP |
---|
| 143 | |
---|
| 144 | ASFLAGS= |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | # NOTE: should never use full path .. but there is no guarantee ld, etc |
---|
| 148 | # will be in the same directory as gcc.. so hope they are in the path |
---|
| 149 | # Don't do this on a real target!!! |
---|
| 150 | LD=ld |
---|
| 151 | NM=nm |
---|
| 152 | AR=ar |
---|
| 153 | # egrep regexp to ignore symbol table entries in ar archives. |
---|
| 154 | # Only used to make sure we skip them when coalescing libraries. |
---|
| 155 | # skip __.SYMDEF and empty names (maybe bug in ranlib??). |
---|
| 156 | AR_SYMBOL_TABLE="HIGHLY-UNLIKELY-TO-CONFLICT" |
---|
| 157 | ARFLAGS=ruv |
---|
| 158 | |
---|
| 159 | # NOTE: see comment on ld, nm, ar |
---|
| 160 | SIZE=size |
---|
| 161 | |
---|
| 162 | # |
---|
| 163 | # Command to convert a normal archive to one searchable by $(LD) |
---|
| 164 | # Not needed on SVR4 |
---|
| 165 | # |
---|
| 166 | |
---|
| 167 | MKLIB=echo library is complete: |
---|
| 168 | |
---|
| 169 | # |
---|
| 170 | # How to compile stuff into ${ARCH} subdirectory |
---|
| 171 | # |
---|
| 172 | # NOTE: we override COMPILE.c |
---|
| 173 | # |
---|
| 174 | |
---|
| 175 | COMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) $(XCFLAGS) -c |
---|
| 176 | |
---|
| 177 | ${ARCH}/%.o: %.c |
---|
| 178 | ${COMPILE.c} -o $@ $< |
---|
| 179 | |
---|
| 180 | ${ARCH}/%.o: %.cc |
---|
| 181 | ${COMPILE.c} -o $@ $< |
---|
| 182 | |
---|
| 183 | ${ARCH}/%.o: %.S |
---|
| 184 | ${COMPILE.c} -DASM -o $@ $< |
---|
| 185 | |
---|
| 186 | ${ARCH}/%.o: %.s |
---|
| 187 | $(CPP) $(CPPFLAGS) - <$*.s >$(ARCH)/$*.i |
---|
| 188 | $(AS) $(ASFLAGS) -o $@ $(ARCH)/$*.i |
---|
| 189 | # $(RM) $(ARCH)/$*.i |
---|
| 190 | |
---|
| 191 | # Specify our own default rule for this to prevent having CFLAGS and |
---|
| 192 | # CPPFLAGS being passed to linker |
---|
| 193 | ${ARCH}/%: ${ARCH}/%.o |
---|
| 194 | ${CC} ${LDFLAGS} -o $@ $@.o ${LD_LIBS} |
---|
| 195 | |
---|
| 196 | # Make foo.rel from foo.o |
---|
| 197 | ${ARCH}/%.rel: ${ARCH}/%.o |
---|
| 198 | ${LD} $(LDFLAGS_INCOMPLETE) -o $@ $^ |
---|
| 199 | |
---|
| 200 | # create $(ARCH)/pgm from pgm.sh |
---|
| 201 | ${ARCH}/%: %.sh |
---|
| 202 | $(RM) $@ |
---|
| 203 | $(CP) $< $@ |
---|
| 204 | $(CHMOD) +x $@ |
---|
| 205 | |
---|
| 206 | # Dependency files for use by gmake |
---|
[df49c60] | 207 | # NOTE: we don't put them into $(ARCH) |
---|
[bffb938] | 208 | # so that 'make clean' doesn't blow it away |
---|
| 209 | |
---|
[df49c60] | 210 | DEPEND=Depends-${ARCH} |
---|
[bffb938] | 211 | |
---|
| 212 | CLEAN_DEPEND=$(DEPEND).tmp |
---|
| 213 | CLOBBER_DEPEND=$(DEPEND) |
---|
| 214 | |
---|
| 215 | # We deliberately don't have anything depend on the |
---|
| 216 | # $(DEPEND) file; otherwise it will get rebuilt even |
---|
| 217 | # on 'make clean' |
---|
| 218 | # |
---|
| 219 | |
---|
| 220 | depend: $(C_FILES) $(CC_FILES) $(S_FILES) |
---|
| 221 | ifneq ($(words $(C_FILES) $(CC_FILES) $(S_FILES)), 0) |
---|
| 222 | # Use gcc -M to generate dependencies |
---|
| 223 | # Replace foo.o with $(ARCH)/foo.o |
---|
| 224 | # Replace $(ARCH) value with string $(ARCH) |
---|
| 225 | # so that it will for debug and profile cases |
---|
| 226 | $(COMPILE.c) -M $^ | \ |
---|
| 227 | $(SED) -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ |
---|
| 228 | -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp |
---|
| 229 | $(MV) $(DEPEND).tmp $(DEPEND) |
---|
| 230 | endif |
---|
| 231 | |
---|
| 232 | |
---|
| 233 | # List (possibly empty) of required managers |
---|
| 234 | # We require: |
---|
| 235 | # region -- used by lib/libcsupport for malloc() |
---|
| 236 | # ext -- used by libc for libc reentrancy hooks |
---|
| 237 | |
---|
| 238 | MANAGERS_REQUIRED=region ext sem |
---|
| 239 | |
---|
| 240 | # Create a RTEMS executable based on MANAGERS which was set in |
---|
| 241 | # app's Makefile |
---|
| 242 | |
---|
| 243 | MANAGERS_NOT_WANTED=$(filter-out $(MANAGERS), $(MANAGER_LIST)) |
---|
| 244 | MANAGERS_NOT_WANTED:=$(filter-out $(MANAGERS_REQUIRED), $(MANAGERS_NOT_WANTED)) |
---|
| 245 | |
---|
| 246 | # spell out all the LINK_FILE's, rather than using -lbsp, so |
---|
| 247 | # that $(LINK_FILES) can be a dependency |
---|
| 248 | |
---|
| 249 | # Start file must be one of |
---|
| 250 | # $(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).o |
---|
| 251 | # $(PROJECT_RELEASE)/lib/asmiface$(LIB_VARIANT).o |
---|
| 252 | # It defaults to start.o, but an app can override it. |
---|
| 253 | |
---|
| 254 | # Note: Normally RTEMS provides a start file... |
---|
| 255 | START_FILE= |
---|
| 256 | |
---|
| 257 | CONSTRUCTOR= |
---|
| 258 | |
---|
[98100d2] | 259 | LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name $(GCCSED)) |
---|
[bffb938] | 260 | |
---|
| 261 | LINK_FILES= $(START_FILE) \ |
---|
| 262 | $(CONSTRUCTOR) \ |
---|
| 263 | $(OBJS) \ |
---|
| 264 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) \ |
---|
| 265 | $(LD_LIBS) \ |
---|
| 266 | $(LIBC_EXTRA_LIBS) \ |
---|
| 267 | $(PROJECT_RELEASE)/lib/libtest$(LIBSUFFIX_VA) \ |
---|
[88f60e26] | 268 | $(PROJECT_RELEASE)/lib/librtemsbsp$(LIBSUFFIX_VA) \ |
---|
| 269 | $(PROJECT_RELEASE)/lib/librtemscpu$(LIBSUFFIX_VA) \ |
---|
[bffb938] | 270 | $(LIBC_LIBM) $(LIBC_LIBC) $(LIBGCC) |
---|
| 271 | |
---|
| 272 | # Here is the rule to actually build a $(ARCH)/foo.exe |
---|
| 273 | # It also builds $(ARCH)/foo.sr and $(ARCH)/foo.nm |
---|
| 274 | # Usage ref: src/tests/sptest/sp1/Makefile |
---|
| 275 | |
---|
| 276 | # On Solaris at least you need to had /usr/ucblib/libucb.a |
---|
| 277 | |
---|
| 278 | define make-exe |
---|
| 279 | $(CC) -o $(basename $@).exe $(LINK_FILES) -lc -lm |
---|
| 280 | $(NM) -n $(basename $@).exe > $(basename $@).num |
---|
| 281 | $(SIZE) $(basename $@).exe |
---|
| 282 | endef |
---|
| 283 | |
---|
| 284 | define make-rel |
---|
| 285 | $(LD) $(LDFLAGS_INCOMPLETE) $(XLDFLAGS) -o $@ $(OBJS) |
---|
| 286 | endef |
---|