3 # Arch specific settings
\r
5 include $(ROOTDIR)/$(ARCH_PATH-y)/scripts/gcc.mk
\r
9 HOST := $(shell uname)
\r
12 # If we are using codesourcery and cygwin..
\r
13 ifneq ($(findstring CYGWIN,$(UNAME)),)
\r
14 cygpath:= $(shell cygpath -m $(shell which cygpath))
\r
15 export CYGPATH=$(cygpath)
\r
19 gcc_version = $(shell ${CROSS_COMPILE}gcc --version | gawk -v VER=$(1) '{ if( VER >= strtonum(gensub(/\./,"","g",$$3)) ) print "y";exit }' )
\r
20 GCC_V430 = $(call gcc_version,430)
\r
21 GCC_V340 = $(call gcc_version,340)
\r
23 # ---------------------------------------------------------------------------
\r
25 # CCFLAGS - compile flags
\r
27 CC = $(CROSS_COMPILE)gcc
\r
28 cflags-$(CFG_OPT_RELEASE) += -O3
\r
29 cflags-$(CFG_OPT_DEBUG) += -g -O0
\r
30 cflags-$(CFG_OPT_SIZE) += -g -Os
\r
33 # Remove sections if needed.. may be problems with other compilers here.
\r
34 #cflags-y += -ffunction-sections
\r
36 ifneq ($(filter -O2 -O3 -O1,$(cflags-y)),)
\r
37 cflags-y += -fno-schedule-insns -fno-schedule-insns2
\r
40 #cflags-y += -fno-common
\r
41 cflags-y += -std=gnu99
\r
43 # Generate dependencies
\r
48 cflags-$(GCC_V340)+= -Wextra
\r
49 cflags-$(GCC_V430)+= -Wconversion
\r
50 #cflags-y += -pedantic
\r
53 cflags-y += -fno-strict-aliasing # Use restict keyword instead.
\r
54 cflags-y += -fno-builtin
\r
57 cflags-$(CFG_GCOV) += -fprofile-arcs
\r
58 cflags-$(CFG_GCOV) += -ftest-coverage
\r
60 # Get machine cflags
\r
61 #cflags-y += $(cflags-$(ARCH))
\r
63 CFLAGS = $(cflags-y) $(cflags-yy)
\r
67 # ---------------------------------------------------------------------------
\r
72 CPP_ASM_FLAGS = -x assembler-with-cpp
\r
76 space = $(empty) $(empty)
\r
79 # Libs related to GCC(libgcc.a, libgcov.a) is located under
\r
80 # lib/gcc/<machine>/<version>/<multilib>
\r
81 # Libs related to the library (libc.a,libm.a,etc) are under:
\r
82 # <machine>/lib/<multilib>
\r
84 # Can't remember why haven't I just used gcc to link instead of ld? (it should
\r
85 # figure out the things below by itself)
\r
87 # It seems some versions of make want "\=" and some "="
\r
88 # "=" - msys cpmake on windows 7
\r
89 gcc_lib_path := "$(subst /libgcc.a,,$(shell $(CC) $(CFLAGS) --print-libgcc-file-name))"
\r
90 gcc_lib_path := $(subst \libgcc.a,,$(gcc_lib_path))
\r
91 lib_lib_path := "$(subst /libc.a,,$(shell $(CC) $(CFLAGS) --print-file-name=libc.a))"
\r
92 lib_lib_path := $(subst \libc.a,,$(lib_lib_path))
\r
93 text_chunk := $(subst \,/,$(shell touch gcc_path_probe.c; $(CC) -v -c gcc_path_probe.c &> gcc_path_probe.tmp;gawk -f $(TOPDIR)/scripts/gcc_getinclude.awk gcc_path_probe.tmp))
\r
94 cc_inc_path := $(realpath $(text_chunk))
\r
95 libpath-y += -L$(lib_lib_path)
\r
96 libpath-y += -L$(gcc_lib_path)
\r
98 # ---------------------------------------------------------------------------
\r
101 # LDFLAGS - linker flags
\r
102 # LDOUT - How to Generate linker output file
\r
103 # LDMAPFILE - How to generate mapfile
\r
104 # ldcmdfile-y - link cmd file
\r
105 # libpath-y - lib paths
\r
106 # libitem-y - the libs with path
\r
107 # lib-y - the libs, without path
\r
110 LD = $(CROSS_COMPILE)ld
\r
118 # Don't use a map file if we are compiling for native target.
\r
119 ifneq ($(CROSS_COMPILE),)
\r
120 LDFLAGS += -Map $(subst .$(TE),.map, $@)
\r
123 lib-$(CFG_GCOV) += -lgcov
\r
125 libitem-y += $(libitem-yy)
\r
127 LD_START_GRP = --start-group
\r
128 LD_END_GRP = --end-group
\r
130 #LDFLAGS += --gc-section
\r
132 # ---------------------------------------------------------------------------
\r
135 # ASFLAGS - assembler flags
\r
136 # ASOUT - how to generate output file
\r
138 AS = $(CROSS_COMPILE)as
\r
140 ASFLAGS += --gdwarf2
\r
143 # ---------------------------------------------------------------------------
\r
146 #DDUMP = $(Q)$(COMPILER_ROOT)/$(cross_machine-y)-objcopy
\r
147 #DDUMP_FLAGS = -O srec
\r
148 OBJCOPY = $(CROSS_COMPILE)objcopy
\r
150 # ---------------------------------------------------------------------------
\r
153 # AROUT - archiver flags
\r
155 AR = $(CROSS_COMPILE)ar
\r
160 define do-memory-footprint
\r
161 @$(CROSS_COMPILE)objdump -h $@ | gawk -f $(ROOTDIR)/scripts/hc1x_memory.awk
\r
164 define do-memory-footprint
\r
165 @gawk --non-decimal-data -f $(ROOTDIR)/scripts/memory_footprint_gcc.awk $(subst .elf,.map,$@)
\r