[cce81a7] | 1 | # |
---|
| 2 | # $Id$ |
---|
| 3 | # |
---|
| 4 | # gcc 2.6.x native compiler |
---|
| 5 | # Compiler (and tools) configuration |
---|
| 6 | # |
---|
| 7 | |
---|
| 8 | # Additional target names (other than debug, profile) |
---|
| 9 | TARGET_VARIANTS += |
---|
| 10 | |
---|
| 11 | # |
---|
| 12 | # Pre-processor defines. |
---|
| 13 | # Local tailoring (on the command line) can be done by setting XCPPFLAGS |
---|
| 14 | # which is never set in the Makefile's |
---|
| 15 | # |
---|
| 16 | |
---|
| 17 | CPPFLAGS=$(XCPPFLAGS) $(DEFINES) |
---|
| 18 | |
---|
| 19 | # |
---|
| 20 | # Local tailoring (on the command line) can be done by setting CFLAGS |
---|
| 21 | # which is never set in the Makefile's |
---|
| 22 | # |
---|
| 23 | |
---|
| 24 | # |
---|
| 25 | # CFLAGS_OPTIMIZE_V, CFLAGS_DEBUG_V, CFLAGS_PROFILE_V are the values we |
---|
| 26 | # would want the corresponding macros to be set to. |
---|
| 27 | # |
---|
| 28 | # CFLAGS_OPTIMIZE, CFLAGS_DEBUG, CFLAGS_PROFILE are set in the leaf |
---|
| 29 | # Makefiles by the 'debug:' and 'profile:' targets to their _V values. |
---|
| 30 | # |
---|
| 31 | |
---|
| 32 | # default flags |
---|
| 33 | |
---|
| 34 | CFLAGS_DEFAULT = @CC_CFLAGS_DEFAULT@ |
---|
| 35 | |
---|
| 36 | # Under MS-DOS do not use pipes |
---|
| 37 | # It turns out the pipes don't work with some non-gas assemblers either. :( |
---|
| 38 | # ifneq ($(RTEMS_HOST),msdos) |
---|
| 39 | # # CFLAGS_DEFAULT += -pipe |
---|
| 40 | # CFLAGS_DEFAULT += |
---|
| 41 | # endif |
---|
| 42 | |
---|
| 43 | # Additional target names (other than debug, profile) |
---|
| 44 | |
---|
| 45 | # optimize flag: typically -0, could use -O4 or -fast |
---|
| 46 | # -O4 is ok for RTEMS |
---|
| 47 | CFLAGS_OPTIMIZE_V=-O |
---|
| 48 | |
---|
| 49 | # debug flag; typically -g |
---|
| 50 | CFLAGS_DEBUG_V=@CC_CFLAGS_DEBUG_V@ |
---|
| 51 | |
---|
| 52 | # when debugging, optimize flag: typically empty |
---|
| 53 | # some compilers do allow optimization with their "-g" |
---|
| 54 | CFLAGS_DEBUG_OPTIMIZE_V= |
---|
| 55 | |
---|
| 56 | # profile flag; use gprof(1) |
---|
[946b3cb] | 57 | CFLAGS_PROFILE_V=@CC_CFLAGS_PROFILE_V@ |
---|
[cce81a7] | 58 | |
---|
| 59 | # default is to optimize |
---|
| 60 | CFLAGS_OPTIMIZE=$(CFLAGS_OPTIMIZE_V) |
---|
| 61 | |
---|
| 62 | # dynamic libraries |
---|
| 63 | CFLAGS_DYNAMIC_V=-fpic |
---|
| 64 | ASFLAGS_DYNAMIC_V= |
---|
| 65 | |
---|
| 66 | # XCFLAGS are now local flags to avoid conflict with cygnus configure |
---|
| 67 | XCFLAGS=$(CFLAGS_OPTIMIZE) $(CFLAGS_DEBUG) $(CFLAGS_PROFILE) \ |
---|
| 68 | $(CFLAGS_DEFAULT) |
---|
| 69 | |
---|
| 70 | # List of library paths without -L |
---|
| 71 | LD_PATHS= |
---|
| 72 | |
---|
| 73 | # libraries you want EVERYONE to link with |
---|
| 74 | LD_LIBS= |
---|
| 75 | |
---|
| 76 | # ld flag to ensure pure-text |
---|
| 77 | LDFLAGS_MUST_BE_PURE_V = |
---|
| 78 | |
---|
| 79 | # ld flag for [un]shared objects |
---|
| 80 | LDFLAGS_STATIC_LIBRARIES_V = |
---|
| 81 | LDFLAGS_SHARED_LIBRARIES_V = |
---|
| 82 | |
---|
| 83 | # ld flag for incomplete link |
---|
| 84 | LDFLAGS_INCOMPLETE = -r |
---|
| 85 | |
---|
| 86 | # Special linker options when building lib.so |
---|
| 87 | LDFLAGS_DYNAMIC_V = ?? |
---|
| 88 | |
---|
| 89 | # Some dynamic linking systems want the preferred name recorded in the binary |
---|
| 90 | # ref: src/libxil/Makefile |
---|
| 91 | LDFLAGS_DYNAMIC_LIBNAME_V = -h $(DYNAMIC_VERSION_LIBNAME) |
---|
| 92 | |
---|
| 93 | # ld flags for profiling, debugging |
---|
[946b3cb] | 94 | LDFLAGS_PROFILE_V = @CC_LDFLAGS_PROFILE_V@ |
---|
[cce81a7] | 95 | LDFLAGS_DEBUG_V = |
---|
| 96 | |
---|
| 97 | LDFLAGS=$(LDFLAGS_PROFILE) $(LDFLAGS_DEBUG) $(LD_PATHS:%=-L %) |
---|
| 98 | |
---|
| 99 | # |
---|
| 100 | # Stuff to clean and clobber for the compiler and its tools |
---|
| 101 | # |
---|
| 102 | |
---|
| 103 | CLEAN_CC = a.out *.o *.BAK |
---|
| 104 | CLOBBER_CC = |
---|
| 105 | |
---|
| 106 | # |
---|
| 107 | # Client compiler and support tools |
---|
| 108 | # |
---|
| 109 | |
---|
| 110 | # CC_FOR_BUILD=gcc -O |
---|
| 111 | # override CC=$(CC_FOR_BUILD) |
---|
| 112 | |
---|
| 113 | CC=@CC@ |
---|
| 114 | |
---|
| 115 | # CPP command to write file to standard output |
---|
| 116 | CPP=$(CC) -E |
---|
| 117 | |
---|
| 118 | # flags set by cc when running cpp |
---|
| 119 | CPP_CC_FLAGS=-D__STDC__ |
---|
| 120 | |
---|
| 121 | # egrep regexp to ignore symbol table entries in ar archives. |
---|
| 122 | # Only used to make sure we skip them when coalescing libraries. |
---|
| 123 | # skip __.SYMDEF and empty names (maybe bug in ranlib??). |
---|
| 124 | AR_SYMBOL_TABLE="HIGHLY-UNLIKELY-TO-CONFLICT" |
---|
| 125 | ARFLAGS=ruv |
---|
| 126 | |
---|
| 127 | # |
---|
| 128 | # Command to convert a normal archive to one searchable by $(LD) |
---|
| 129 | # Not needed on SVR4 |
---|
| 130 | # FIXME: Should be handled by autoconf. Doesn't matter, because |
---|
| 131 | # rtems doesn't have any host-libraries until now. |
---|
| 132 | # |
---|
| 133 | |
---|
| 134 | MKLIB=echo library is complete: |
---|
| 135 | |
---|
| 136 | # |
---|
| 137 | # How to compile stuff into ${ARCH} subdirectory |
---|
| 138 | # |
---|
| 139 | # NOTE: we override COMPILE.c |
---|
| 140 | # |
---|
| 141 | |
---|
| 142 | COMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) $(XCFLAGS) -c |
---|
| 143 | |
---|
| 144 | ${ARCH}/%.o: %.c |
---|
| 145 | ${COMPILE.c} -o $@ $< |
---|
| 146 | |
---|
| 147 | ${ARCH}/%.o: %.cc |
---|
| 148 | ${COMPILE.c} -o $@ $< |
---|
| 149 | |
---|
| 150 | # assembly runs gasp |
---|
| 151 | ${ARCH}/%.o: %.s |
---|
| 152 | $(CPP) ${CPPFLAGS} $< | $(SED) 's/% /%/g' | $(SED) 's/^#.*//' >$(ARCH)/$*.i |
---|
| 153 | $(AS) -o $@ $(ARCH)/$*.i |
---|
| 154 | $(RM) $(ARCH)/$*.i |
---|
| 155 | |
---|
| 156 | # Link host applications. |
---|
| 157 | define make-exe |
---|
| 158 | ${CC} ${LDFLAGS} -o $@ $^ ${LD_LIBS} |
---|
| 159 | endef |
---|
| 160 | |
---|
| 161 | # Specify our own default rule for this to prevent having CFLAGS and |
---|
| 162 | # CPPFLAGS being passed to linker |
---|
| 163 | # |
---|
| 164 | # NOTE: This rule is only used as fallback for host-tool makefiles |
---|
| 165 | # which don't provide their own rule |
---|
| 166 | ${ARCH}/%$(EXEEXT): ${ARCH}/%.o |
---|
| 167 | $(make-exe) |
---|
| 168 | |
---|
| 169 | # create $(ARCH)/pgm from pgm.sh |
---|
| 170 | ${ARCH}/%: %.sh |
---|
| 171 | $(RM) $@ |
---|
| 172 | $(CP) $< $@ |
---|
| 173 | $(CHMOD) +x $@ |
---|
| 174 | |
---|
| 175 | # Dependency files for use by gmake |
---|
| 176 | # NOTE: we don't put in $(TARGET_ARCH) |
---|
| 177 | # so that 'make clean' doesn't blow it away |
---|
| 178 | |
---|
| 179 | DEPEND=Depends-$(TARGET_ARCH:o-%=%) |
---|
| 180 | |
---|
| 181 | CLEAN_DEPEND=$(DEPEND).tmp |
---|
| 182 | CLOBBER_DEPEND=$(DEPEND) |
---|
| 183 | |
---|
| 184 | # We deliberately don't have anything depend on the |
---|
| 185 | # $(DEPEND) file; otherwise it will get rebuilt even |
---|
| 186 | # on 'make clean' |
---|
| 187 | # |
---|
| 188 | |
---|
| 189 | depend: $(C_FILES) $(CC_FILES) $(S_FILES) |
---|
| 190 | ifneq ($(words $(C_FILES) $(CC_FILES) $(S_FILES)), 0) |
---|
| 191 | # Use gcc -M to generate dependencies |
---|
| 192 | # Replace foo.o with $(ARCH)/foo.o |
---|
| 193 | # Replace $(ARCH) value with string $(ARCH) |
---|
| 194 | # so that it will for debug and profile cases |
---|
| 195 | $(COMPILE.c) -M $^ | \ |
---|
| 196 | $(SED) -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ |
---|
| 197 | -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp |
---|
| 198 | $(MV) $(DEPEND).tmp $(DEPEND) |
---|
| 199 | endif |
---|
| 200 | |
---|
| 201 | define make-rel |
---|
| 202 | $(LD) $(LDFLAGS_INCOMPLETE) $(XLDFLAGS) -o $@ $(OBJS) |
---|
| 203 | endef |
---|