1#
2# Addresses of things unless overridden
3#
4
5ifeq ($(strip ${CFG_UNCACHED}),1)
6  CFG_TEXT_START ?= 0xBFC00000
7  CFG_DATA_START ?= 0xA1F00000
8  CFG_ROM_START  ?= 0xBFC00000
9else
10  CFG_TEXT_START ?= 0x9FC00000
11  CFG_DATA_START ?= 0x81F00000
12  CFG_ROM_START  ?= 0xBFC00000
13endif
14
15#
16# BOOTRAM mode (runs from ROM vector assuming ROM is writable)
17# implies no relocation.
18#
19
20ifeq ($(strip ${CFG_BOOTRAM}),1)
21  CFG_RELOC = 0
22endif
23
24
25#
26# Basic compiler options and preprocessor flags.  By placing
27# these in "CFLAGS" they will be applied to both CFE and ZipStart
28#
29# There are three macros with flags:
30#
31#  CFLAGS -- flags common to everything we build
32#  ZIPSTART_CFLAGS - flags unique to ZIPSTART
33#  CFE_CFLAGS - flags unique to CFE
34#
35
36CFLAGS += -g -c  -ffreestanding 
37CFLAGS += -O1 -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes 
38
39ZIPSTART_CFLAGS += -D_ZIPSTART_
40
41#
42# Tools locations
43#
44TOOLPREFIX ?= sb1-elf-
45GCC        ?= $(TOOLS)$(TOOLPREFIX)gcc
46GCPP       ?= $(TOOLS)$(TOOLPREFIX)cpp
47GLD        ?= $(TOOLS)$(TOOLPREFIX)ld
48GAR        ?= $(TOOLS)$(TOOLPREFIX)ar
49OBJDUMP    ?= $(TOOLS)$(TOOLPREFIX)objdump
50OBJCOPY    ?= $(TOOLS)$(TOOLPREFIX)objcopy
51RANLIB     ?= $(TOOLS)$(TOOLPREFIX)ranlib
52
53#
54# Check for 64-bit mode.  ZipStart is always built as 32-bit, so 
55# this one only goes in CFE_CFLAGS
56#
57
58ifeq ($(strip ${CFG_MLONG64}),1)
59  CFE_CFLAGS += -mlong64 -D__long64
60endif
61
62#
63# Determine parameters for the linker script, which is generated
64# using the C preprocessor.
65#
66# Supported combinations:
67#
68#  CFG_RAMAPP   CFG_UNCACHED   CFG_RELOC   Description
69#    Yes        YesOrNo        MustBeNo    CFE as a separate "application"
70#    No         YesOrNo        Yes         CFE relocates to RAM as firmware
71#    No         YesOrNo        No          CFE runs from flash as firmware
72#
73
74CFE_LDSCRIPT = ./cfe.lds
75ZIPSTART_LDSCRIPT = ./zipstart.lds
76ZIPSTART_LDSCRIPT_TEMPLATE = ${ARCH_SRC}/zipstart_ldscript.template
77
78ifeq ($(strip ${CFG_RELOC}),1)
79  CFE_LDFLAGS += -Bshareable -Bsymbolic 
80  CFE_LDFLAGS += --no-undefined
81  CFE_LDFLAGS += --script $(CFE_LDSCRIPT)
82  CFE_LDSCRIPT_TEMPLATE = ${ARCH_SRC}/cfe_ldscript.svr4pic
83  OCBINFLAGS += -R .dynstr -R .hash -R .compact_rel
84else
85  CFE_LDFLAGS += -g --script $(CFE_LDSCRIPT)
86  CFE_LDSCRIPT_TEMPLATE = ${ARCH_SRC}/cfe_ldscript.template
87endif
88
89ifeq ($(strip ${CFG_UNCACHED}),1)
90  GENLDFLAGS += -DCFG_RUNFROMKSEG0=0
91else
92  GENLDFLAGS += -DCFG_RUNFROMKSEG0=1
93endif
94
95ifeq ($(strip ${CFG_ZIPSTART}),1)
96   GENLDFLAGS += -DCFG_ZIPSTART=1
97endif
98
99ifeq ($(strip ${CFG_RAMAPP}),1)
100   GENLDFLAGS += -DCFG_RAMAPP=1
101else 
102  #
103  # RELOC=0 is used for no relocation (run in place)
104  #
105  ifeq ($(strip ${CFG_RELOC}),0)
106    ifeq ($(strip ${CFG_BOOTRAM}),1)
107      GENLDFLAGS += -DCFG_BOOTRAM=1
108    else
109      GENLDFLAGS += -DCFG_BOOTRAM=0
110    endif
111  endif
112  #
113  # RELOC=1 is "SVR4 PIC"
114  #
115  ifeq ($(strip ${CFG_RELOC}),1)
116    CFLAGS += -G0 -fpic -mabicalls -Wa,-KPIC 
117    GENLDFLAGS += -DCFG_RELOC=1
118    CFG_TEXT_START = 0x9FC00000
119    CFG_DATA_START = 0x81F00000
120    CFG_ROM_START  = 0xBFC00000
121  endif
122  #
123  # RELOC=STATIC is "move to static location"
124  #
125endif
126
127#
128# Add GENLDFLAGS to CFLAGS (we need this stuff in the C code as well)
129#
130
131CFLAGS += ${GENLDFLAGS}
132
133#
134# Determine target endianness.  We use this switch everywhere,
135# in the C compiler, linker, and assembler, and for both CFE
136# and ZipStart.
137#
138
139ifeq ($(strip ${CFG_LITTLE}),1)
140  ENDIAN = -EL
141else
142  ENDIAN = -EB
143endif
144
145#
146# Add the text/data/ROM addresses to the GENLDFLAGS so they
147# will make it into the linker script.
148#
149
150GENLDFLAGS += -DCFE_ROM_START=${CFG_ROM_START} 
151GENLDFLAGS += -DCFE_TEXT_START=${CFG_TEXT_START} 
152GENLDFLAGS += -DCFE_DATA_START=${CFG_DATA_START} 
153
154