[bffb938] | 1 | # |
---|
| 2 | # |
---|
| 3 | |
---|
| 4 | CPPFLAGS=$(CFLAGS) $(XCPPFLAGS) |
---|
| 5 | |
---|
| 6 | CPLUS_CPPFLAGS=$(CFLAGS) $(XCPPFLAGS) |
---|
| 7 | |
---|
| 8 | ## |
---|
| 9 | # CFLAGS_OPTIMIZE_V, CFLAGS_DEBUG_V, CFLAGS_PROFILE_V are the values we |
---|
| 10 | # would want the corresponding macros to be set to. |
---|
| 11 | # |
---|
| 12 | # CFLAGS_OPTIMIZE, CFLAGS_DEBUG, CFLAGS_PROFILE are set in the leaf |
---|
| 13 | # Makefiles by the 'debug:' and 'profile:' targets to their _V values. |
---|
| 14 | # |
---|
| 15 | |
---|
| 16 | # default flags |
---|
| 17 | |
---|
| 18 | # We only include the header files for KA9Q if it is enabled. |
---|
| 19 | INCLUDE_KA9Q_yes_V = -I$(PROJECT_INCLUDE)/ka9q |
---|
| 20 | INCLUDE_KA9Q = $(INCLUDE_KA9Q_$(HAS_KA9Q)_V) |
---|
| 21 | |
---|
| 22 | ifeq ($(RTEMS_USE_GCC272),yes) |
---|
| 23 | # Ask gcc where it finds its own include files |
---|
| 24 | GCC_INCLUDE=$(shell $(CC) $(CPU_CFLAGS) -print-file-name=include) |
---|
| 25 | |
---|
| 26 | CFLAGS_DEFAULT = $(CPU_DEFINES) $(CPU_CFLAGS) -Wall -ansi -fasm -g \ |
---|
| 27 | -nostdinc -I$(PROJECT_INCLUDE) \ |
---|
| 28 | $(INCLUDE_KA9Q) \ |
---|
| 29 | -I$(RTEMS_LIBC_DIR)/include -I$(GCC_INCLUDE) $(DEFINES) |
---|
| 30 | |
---|
| 31 | ASMFLAGS=$(CPU_DEFINES) $(CPU_CFLAGS) -g \ |
---|
| 32 | -nostdinc -I$(PROJECT_INCLUDE) \ |
---|
| 33 | -I$(RTEMS_LIBC_DIR)/include -I$(GCC_INCLUDE) $(DEFINES) |
---|
| 34 | |
---|
| 35 | # default location of Standard C Library |
---|
| 36 | ifndef LIBC_LIBC |
---|
| 37 | LIBC_LIBC=$(RTEMS_LIBC_DIR)/lib/libc.a |
---|
| 38 | endif |
---|
| 39 | |
---|
| 40 | ifndef LIBC_LIBM |
---|
| 41 | LIBC_LIBM=$(RTEMS_LIBC_DIR)/lib/libm.a |
---|
| 42 | endif |
---|
| 43 | |
---|
| 44 | else |
---|
| 45 | CFLAGS_DEFAULT = $(CPU_DEFINES) $(CPU_CFLAGS) -Wall -ansi -fasm -g \ |
---|
| 46 | -B$(PROJECT_RELEASE)/lib/ -specs bsp_specs -qrtems \ |
---|
| 47 | $(INCLUDE_KA9Q) $(DEFINES) |
---|
| 48 | |
---|
| 49 | ASMFLAGS=$(CPU_DEFINES) $(CPU_CFLAGS) -g -I$(srcdir) \ |
---|
| 50 | -B$(PROJECT_RELEASE)/lib/ -specs bsp_specs -qrtems $(DEFINES) |
---|
| 51 | |
---|
| 52 | # default location of Standard C Library |
---|
| 53 | ifndef LIBC_LIBC |
---|
| 54 | LIBC_LIBC=$(shell $(CC) $(CPU_CFLAGS) -print-file-name=libc.a) |
---|
| 55 | endif |
---|
| 56 | |
---|
| 57 | ifndef LIBC_LIBM |
---|
| 58 | LIBC_LIBM=$(shell $(CC) $(CPU_CFLAGS) -print-file-name=libm.a) |
---|
| 59 | endif |
---|
| 60 | endif |
---|
| 61 | |
---|
| 62 | # Define this to yes if C++ is included in the development environment. |
---|
| 63 | # This requires that at least the GNU C++ compiler and libg++ be installed. |
---|
| 64 | ifeq ($(RTEMS_HAS_CPLUSPLUS),yes) |
---|
| 65 | HAS_CPLUSPLUS=yes |
---|
| 66 | CPLUS_LD_LIBS += $(PROJECT_RELEASE)/lib/librtems++$(LIBSUFFIX_VA) |
---|
| 67 | else |
---|
| 68 | HAS_CPLUSPLUS=no |
---|
| 69 | endif |
---|
| 70 | |
---|
| 71 | # debug flag; typically -g |
---|
| 72 | CFLAGS_DEBUG_V+=-g -Wno-unused |
---|
| 73 | |
---|
| 74 | # when debugging, optimize flag: typically empty |
---|
| 75 | # some compilers do allow optimization with their "-g" |
---|
| 76 | #CFLAGS_DEBUG_OPTIMIZE_V= |
---|
| 77 | |
---|
| 78 | # profile flag; use gprof(1) |
---|
| 79 | CFLAGS_PROFILE_V=-pg |
---|
| 80 | |
---|
| 81 | # default is to optimize |
---|
| 82 | CFLAGS_OPTIMIZE=$(CFLAGS_OPTIMIZE_V) |
---|
| 83 | |
---|
| 84 | # dynamic libraries |
---|
| 85 | CFLAGS_DYNAMIC_V=-fpic |
---|
| 86 | #ASFLAGS_DYNAMIC_V= |
---|
| 87 | |
---|
| 88 | CFLAGS=$(CFLAGS_DEFAULT) $(CFLAGS_OPTIMIZE) $(CFLAGS_DEBUG) $(CFLAGS_PROFILE) |
---|
| 89 | |
---|
| 90 | # List of library paths without -L |
---|
| 91 | LD_PATHS= $(PROJECT_RELEASE)/lib |
---|
| 92 | |
---|
| 93 | # libraries you want EVERYONE to link with |
---|
| 94 | #LD_LIBS= |
---|
| 95 | |
---|
| 96 | # ld flag to ensure pure-text |
---|
| 97 | #LDFLAGS_MUST_BE_PURE_V = |
---|
| 98 | |
---|
| 99 | # ld flag for [un]shared objects |
---|
| 100 | #LDFLAGS_STATIC_LIBRARIES_V = |
---|
| 101 | #LDFLAGS_SHARED_LIBRARIES_V = |
---|
| 102 | |
---|
| 103 | # ld flag for incomplete link |
---|
| 104 | LDFLAGS_INCOMPLETE = -r |
---|
| 105 | |
---|
| 106 | # Special linker options when building lib.so |
---|
| 107 | LDFLAGS_DYNAMIC_V = ?? |
---|
| 108 | |
---|
| 109 | # Some dynamic linking systems want the preferred name recorded in the binary |
---|
| 110 | # ref: src/libxil/Makefile |
---|
| 111 | LDFLAGS_DYNAMIC_LIBNAME_V = -h $(DYNAMIC_VERSION_LIBNAME) |
---|
| 112 | |
---|
| 113 | # ld flags for profiling, debugging |
---|
| 114 | LDFLAGS_PROFILE_V = |
---|
| 115 | LDFLAGS_DEBUG_V = |
---|
| 116 | |
---|
| 117 | LDFLAGS=$(LDFLAGS_PROFILE) $(LDFLAGS_DEBUG) $(LD_PATHS:%=-L %) |
---|
| 118 | |
---|
| 119 | # |
---|
| 120 | # Stuff to clean and clobber for the compiler and its tools |
---|
| 121 | # |
---|
| 122 | |
---|
| 123 | CLEAN_CC = a.out *.o *.BAK |
---|
| 124 | CLOBBER_CC = |
---|
| 125 | |
---|
| 126 | # |
---|
| 127 | # Client compiler and support tools |
---|
| 128 | # |
---|
| 129 | |
---|
| 130 | # CPP command to write file to standard output |
---|
| 131 | CPP=$(CC) -E |
---|
| 132 | |
---|
| 133 | # flags set by cc when running cpp |
---|
| 134 | CPP_CC_FLAGS=-D__STDC__ |
---|
| 135 | |
---|
| 136 | ASFLAGS= |
---|
| 137 | ASM4FLAGS := -I $(PROJECT_INCLUDE) |
---|
| 138 | |
---|
| 139 | # egrep regexp to ignore symbol table entries in ar archives. |
---|
| 140 | # Only used to make sure we skip them when coalescing libraries. |
---|
| 141 | # skip __.SYMDEF and empty names (maybe bug in ranlib??). |
---|
| 142 | AR_SYMBOL_TABLE="HIGHLY-UNLIKELY-TO-CONFLICT" |
---|
| 143 | ARFLAGS=ruv |
---|
| 144 | |
---|
| 145 | # |
---|
| 146 | # Command to convert a normal archive to one searchable by $(LD) |
---|
| 147 | # Not needed on SVR4 |
---|
| 148 | # |
---|
| 149 | |
---|
| 150 | MKLIB=echo library is complete: |
---|
| 151 | |
---|
| 152 | # |
---|
| 153 | # How to compile stuff into ${ARCH} subdirectory |
---|
| 154 | # |
---|
| 155 | # NOTE: we override COMPILE.c |
---|
| 156 | # |
---|
| 157 | # NOTE: Remove -pipe if it causes you problems. Using it can decrease |
---|
| 158 | # compile time. |
---|
| 159 | # |
---|
| 160 | |
---|
| 161 | COMPILE.c=$(CC) $(CFLAGS) $(XCFLAGS) -c |
---|
| 162 | |
---|
| 163 | ${ARCH}/%.o: %.c |
---|
| 164 | ${COMPILE.c} -pipe -o $@ $< |
---|
| 165 | |
---|
| 166 | ${ARCH}/%.o: %.cc |
---|
| 167 | ${COMPILE.c} -pipe -o $@ $< |
---|
| 168 | |
---|
| 169 | ${ARCH}/%.o: %.S |
---|
| 170 | ${COMPILE.c} -pipe -DASM -o $@ $< |
---|
| 171 | |
---|
| 172 | # strip out C++ style comments. |
---|
| 173 | ${ARCH}/%.o: %.s |
---|
| 174 | sed -e 's/\/\/.*$$//' < $< | \ |
---|
| 175 | $(CPP) $(ASMFLAGS) -I. -I$(srcdir) -DASM - >$(ARCH)/$*.i |
---|
| 176 | $(AS) $(ASFLAGS) -o $@ $(ARCH)/$*.i |
---|
| 177 | |
---|
| 178 | # $(CPP) $(CPPFLAGS) -DASM - < $< >$(ARCH)/$*.i |
---|
| 179 | # $(AS) $(ASFLAGS) -o $@ $(ARCH)/$*.i |
---|
| 180 | # $(RM) $(ARCH)/$*.i |
---|
| 181 | |
---|
| 182 | # Specify our own default rule for this to prevent having CFLAGS and |
---|
| 183 | # CPPFLAGS being passed to linker |
---|
| 184 | ${ARCH}/%: ${ARCH}/%.o |
---|
| 185 | ${CC} ${LDFLAGS} -o $@ $@.o ${LD_LIBS} |
---|
| 186 | |
---|
| 187 | # Make foo.rel from foo.o |
---|
| 188 | ${ARCH}/%.rel: ${ARCH}/%.o |
---|
| 189 | ${LD} $(LDFLAGS_INCOMPLETE) -o $@ $^ |
---|
| 190 | |
---|
| 191 | # create $(ARCH)/pgm from pgm.sh |
---|
| 192 | ${ARCH}/%: %.sh |
---|
| 193 | $(RM) $@ |
---|
| 194 | $(CP) $< $@ |
---|
| 195 | $(CHMOD) +x $@ |
---|
| 196 | |
---|
| 197 | # Dependency files for use by gmake |
---|
| 198 | # NOTE: we don't put in $(TARGET_ARCH) |
---|
| 199 | # so that 'make clean' doesn't blow it away |
---|
| 200 | |
---|
| 201 | DEPEND=Depends-$(TARGET_ARCH:o-%=%) |
---|
| 202 | |
---|
| 203 | CLEAN_DEPEND=$(DEPEND).tmp |
---|
| 204 | CLOBBER_DEPEND=$(DEPEND) |
---|
| 205 | |
---|
| 206 | # We deliberately don't have anything depend on the |
---|
| 207 | # $(DEPEND) file; otherwise it will get rebuilt even |
---|
| 208 | # on 'make clean' |
---|
| 209 | # |
---|
| 210 | |
---|
| 211 | depend: $(C_FILES) $(CC_FILES) $(S_FILES) |
---|
| 212 | ifneq ($(words $(C_FILES) $(CC_FILES) $(S_FILES)), 0) |
---|
| 213 | # Use gcc -M to generate dependencies |
---|
| 214 | # Replace foo.o with $(ARCH)/foo.o |
---|
| 215 | # Replace $(ARCH) value with string $(ARCH) |
---|
| 216 | # so that it will for debug and profile cases |
---|
| 217 | $(COMPILE.c) -M $^ | \ |
---|
| 218 | $(SED) -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ |
---|
| 219 | -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp |
---|
| 220 | $(MV) $(DEPEND).tmp $(DEPEND) |
---|
| 221 | endif |
---|
| 222 | |
---|
| 223 | |
---|
| 224 | # List (possibly empty) of required managers |
---|
| 225 | # We require: |
---|
| 226 | # region -- used by lib/libcsupport for malloc() |
---|
| 227 | # ext -- used by libc for libc reentrancy hooks |
---|
| 228 | |
---|
| 229 | MANAGERS_REQUIRED=region ext sem |
---|
| 230 | |
---|
| 231 | # Create a RTEMS executable based on MANAGERS which was set in |
---|
| 232 | # app's Makefile |
---|
| 233 | |
---|
| 234 | MANAGERS_NOT_WANTED=$(filter-out $(MANAGERS), $(MANAGER_LIST)) |
---|
| 235 | MANAGERS_NOT_WANTED:=$(filter-out $(MANAGERS_REQUIRED), $(MANAGERS_NOT_WANTED)) |
---|
| 236 | |
---|
| 237 | # spell out all the LINK_FILE's, rather than using -lbsp, so |
---|
| 238 | # that $(LINK_FILES) can be a dependency |
---|
| 239 | |
---|
| 240 | # Start file must be one of |
---|
| 241 | # $(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).o |
---|
| 242 | # $(PROJECT_RELEASE)/lib/asmiface$(LIB_VARIANT).o |
---|
| 243 | # It defaults to start.o, but an app can override it. |
---|
| 244 | |
---|
| 245 | ifeq ($(START_BASE),) |
---|
| 246 | START_FILE= |
---|
| 247 | else |
---|
| 248 | START_FILE=$(PROJECT_RELEASE)/lib/$(START_BASE)$(LIB_VARIANT).o |
---|
| 249 | endif |
---|
| 250 | |
---|
| 251 | CONSTRUCTOR= |
---|
| 252 | |
---|
| 253 | LIBC_LOW= |
---|
| 254 | |
---|
| 255 | LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) |
---|
| 256 | |
---|
| 257 | LINK_OBJS=\ |
---|
| 258 | $(CONSTRUCTOR) \ |
---|
| 259 | $(OBJS) \ |
---|
| 260 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) \ |
---|
| 261 | $(LD_LIBS) \ |
---|
| 262 | $(PROJECT_RELEASE)/lib/libtest$(LIBSUFFIX_VA) |
---|
| 263 | |
---|
| 264 | LINK_LIBS=\ |
---|
| 265 | $(LD_LIBS) \ |
---|
| 266 | $(LIBC_EXTRA_LIBS) \ |
---|
| 267 | $(PROJECT_RELEASE)/lib/librtemsall$(LIBSUFFIX_VA) \ |
---|
| 268 | $(LIBC_LIBM) $(LIBC_LIBC) $(LIBGCC) |
---|
| 269 | |
---|
| 270 | LINK_FILES=\ |
---|
| 271 | $(START_FILE) \ |
---|
| 272 | $(LINK_OBJS) \ |
---|
| 273 | $(LINK_LIBS) |
---|
| 274 | |
---|
| 275 | # |
---|
| 276 | # Allow user to override link commands (to build a prom image, perhaps) |
---|
| 277 | # |
---|
| 278 | ifndef LINKCMDS |
---|
| 279 | LINKCMDS=$(PROJECT_RELEASE)/lib/linkcmds |
---|
| 280 | endif |
---|
| 281 | |
---|
| 282 | |
---|
| 283 | define make-rel |
---|
| 284 | $(LD) $(LDFLAGS_INCOMPLETE) $(XLDFLAGS) -o $@ $(OBJS) |
---|
| 285 | endef |
---|