1
2#
3# CFE's version number
4#
5
6include ${TOP}/main/cfe_version.mk
7
8#
9# Default values for certain parameters
10#
11
12CFG_MLONG64 ?= 0
13CFG_LITTLE  ?= 0
14CFG_RELOC ?= 0
15CFG_UNCACHED ?= 0
16CFG_BOOTRAM ?= 0
17CFG_PCI ?= 1
18CFG_LDT ?= 1
19CFG_LDT_REV_017 ?= 0
20CFG_PCIDEVICE ?= 0 
21CFG_DOWNLOAD ?= 0
22CFG_USB ?= 0
23CFG_MSYS ?= 0
24CFG_ZLIB ?= 0
25CFG_VGACONSOLE ?= 0
26CFG_BIENDIAN ?= 0
27CFG_RAMAPP ?= 0
28CFG_USB ?= 0
29CFG_ZIPSTART ?= 0
30CFG_ZIPPED_CFE ?= 1
31
32#
33# Override some settings based on the value of CFG_RELOC.
34#
35# 'STATIC' relocation means no biendian, no bootram, ZIPstart
36# '1' is SVR4 Relocation,  no RAMAPP, no BOOTRAM
37# '0' (no relocation) : no changes
38#
39
40ifeq ($(strip ${CFG_RELOC}),1)
41  CFG_RAMAPP = 0
42  CFG_BOOTRAM = 0
43endif
44
45ifeq ($(strip ${CFG_RELOC}),STATIC)
46  CFG_RAMAPP = 0
47  CFG_BIENDIAN = 0
48  CFG_BOOTRAM = 0
49  CFG_ZIPSTART = 1
50  CFE_CFLAGS += -DCFG_ZIPSTART=1
51endif
52
53ifeq ($(strip ${CFG_PCIDEVICE}),1)
54CFLAGS += -DCFG_PCIDEVICE=1
55endif
56#
57# Default goal.
58#
59
60all : ALL
61
62#
63# Paths to other parts of the firmware.  Everything's relative to ${TOP}
64# so that you can actually do a build anywhere you want.
65#
66
67ARCH_TOP   = ${TOP}/arch/${ARCH}
68ARCH_SRC   = ${ARCH_TOP}/common/src
69ARCH_INC   = ${ARCH_TOP}/common/include
70CPU_SRC    = ${ARCH_TOP}/cpu/${CPU}/src
71CPU_INC    = ${ARCH_TOP}/cpu/${CPU}/include
72MAIN_SRC   = ${TOP}/main
73MAIN_INC   = ${TOP}/include
74
75#
76# We have an optional "chipset" directory that goes under
77# "arch".  Include that if requested.
78#
79
80ifneq ("$(strip ${CHIPSET})","")
81CHIPSET_SRC  = ${ARCH_TOP}/chipset/${CHIPSET}/src
82CHIPSET_INC  = ${ARCH_TOP}/chipset/${CHIPSET}/include
83endif
84
85#
86# It's actually optional to have a 'board'
87# directory.  If you don't specify BOARD,
88# don't include the files.
89#
90
91ifneq ("$(strip ${BOARD})","")
92  BOARD_SRC  = ${ARCH_TOP}/board/${BOARD}/src
93  BOARD_INC  = ${ARCH_TOP}/board/${BOARD}/include
94endif
95
96#
97# Preprocessor defines for CFE's version number
98#
99
100VDEF = -DCFE_VER_MAJ=${CFE_VER_MAJ} -DCFE_VER_MIN=${CFE_VER_MIN} -DCFE_VER_ECO=${CFE_VER_ECO}
101
102ifneq ("$(strip ${CFE_VER_SDK})","")
103  VDEF += -DCFE_VER_SDK=${CFE_VER_SDK}
104endif
105
106#
107# Construct the list of paths that will eventually become the include
108# paths and VPATH.
109#
110
111SRCDIRS = ${BOARD_SRC} $(CHIPSET_SRC) ${CPU_SRC} ${ARCH_SRC} ${TOP}/main ${TOP}/vendor ${TOP}/include ${TOP}/net ${TOP}/dev ${TOP}/ui ${TOP}/lib
112
113CFE_INC = ${TOP}/include ${TOP}/net ${TOP}/dev
114
115
116#
117# Some device drivers currently require PCI headers
118# to compile even when PCI is not configured.
119#
120
121CFE_INC += ${TOP}/pci
122
123#
124# Configure tools and basic tools flags.  This include sets up
125# macros for calling the C compiler, basic flags,
126# and linker scripts.
127#
128
129include ${ARCH_SRC}/tools.mk
130
131#
132# Add some common flags that are used on any architecture.
133#
134
135CFLAGS += -I. $(INCDIRS)
136CFLAGS += -D_CFE_ ${VDEF} -DCFG_BOARDNAME=\"${CFG_BOARDNAME}\"
137
138#
139# Gross - allow more options to be supplied from command line
140#
141
142ifdef CFG_OPTIONS
143OPTFLAGS = $(patsubst %,-D%,$(subst :, ,$(CFG_OPTIONS)))
144CFLAGS += ${OPTFLAGS}
145endif
146
147
148#
149# Decide whether we need to compile zlib or not. 
150#
151# Basically, we need ZLIB if it is required for either CFE
152# or ZipStart.
153#
154
155ifeq ($(strip ${CFG_ZLIB}),1)
156  SRCDIRS += ${TOP}/zlib
157  CFE_INC += ${TOP}/zlib
158else
159  ifeq ($(strip ${CFG_ZIPSTART}),1)
160    ifeq ($(strip ${CFG_ZIPPED_CFE}),1)
161      CFG_ZLIB = 1
162      SRCDIRS += ${TOP}/zlib
163      CFE_INC += ${TOP}/zlib
164    endif
165  endif
166endif
167
168
169#
170# Include the makefiles for the architecture-common, cpu-specific,
171# and board-specific directories.  Each of these will supply
172# some files to "ALLOBJS".  The BOARD and CHIPSET directories are optional
173# as some ports are so simple they don't need boad-specific stuff.
174#
175
176include ${ARCH_SRC}/Makefile
177include ${CPU_SRC}/Makefile
178
179ifneq ("$(strip ${CHIPSET})","")
180include ${CHIPSET_SRC}/Makefile
181endif
182
183ifneq ("$(strip ${BOARD})","")
184  include ${BOARD_SRC}/Makefile
185endif
186
187#
188# Pull in the common directories
189#
190
191include ${MAIN_SRC}/Makefile
192include ${TOP}/dev/Makefile
193include ${TOP}/ui/Makefile
194include ${TOP}/net/Makefile
195include ${TOP}/lib/Makefile
196
197#
198# Add more object files if we're supporting PCI
199#
200
201ifeq ($(strip ${CFG_PCI}),1)
202  include ${TOP}/pci/Makefile
203endif
204
205
206#
207# Add the common object files here.
208#
209
210ALLOBJS += $(LIBOBJS) $(CFEOBJS) $(UIOBJS) $(DEVOBJS) $(NETOBJS)
211
212#
213# Add optional code.  Each option will add to ALLOBJS with its Makefile,
214# and some append to SRCDIRS and/or CFE_INC.
215#
216
217#
218# USB support
219#
220
221ifeq ($(strip ${CFG_USB}),1)
222 SRCDIRS += ${TOP}/usb
223  CFE_INC += ${TOP}/usb
224  include ${TOP}/usb/Makefile
225endif
226
227#
228# M-Systems DoC support
229#
230
231ifeq ($(strip ${CFG_MSYS}),1)
232  ifndef ${MSYS_TOP}
233  # Supply a stub directory by default
234    MSYS_TOP = ${TOP}/msys
235  endif
236  include ${MSYS_TOP}/Makefile
237endif
238
239#
240# If we're including ZLIB, then add its makefile.
241#
242
243ifeq ($(strip ${CFG_ZLIB}),1)
244  SRCDIRS += ${TOP}/zlib
245  CFE_INC += ${TOP}/zlib
246  include ${TOP}/zlib/Makefile
247endif
248
249#
250# If we're doing the VGA console thing, pull in the x86 emulator
251# and the pcconsole subsystem
252#
253
254ifeq ($(strip ${CFG_VGACONSOLE}),1)
255  SRCDIRS += ${TOP}/x86emu ${TOP}/pccons
256  CFE_INC += ${TOP}/x86emu ${TOP}/pccons
257  include ${TOP}/x86emu/Makefile
258  include ${TOP}/pccons/Makefile
259endif
260
261
262ifeq ($(strip ${CFG_VAPI}),1)
263  SRCDIRS += ${TOP}/verif
264  CFE_INC += ${TOP}/verif
265  include ${TOP}/verif/Makefile
266endif
267
268#
269# Vendor extensions come next - they live in their own directory.
270#
271
272include ${TOP}/vendor/Makefile
273
274#
275# Bi-endian support: If we're building the little-endian
276# version, use a different linker script so we can locate the
277# ROM at a higher address.  You'd think we could do this with
278# normal linker command line switches, but there appears to be no
279# command-line way to override the 'AT' qualifier in the linker script.
280#
281# Also add the compiler switch to change
282# the way the vectors are generated.  These switches are
283# only added to the big-endian portion of the ROM,
284# which is located at the real boot vector.
285#
286
287CFG_TEXTAT1MB=0
288ifeq ($(strip ${CFG_BIENDIAN}),1)
289  ifeq ($(strip ${CFG_LITTLE}),1)
290    CFG_TEXT_START = 0x9fd00000
291    CFG_ROM_START  = 0xbfd00000
292    CFG_TEXTAT1MB=1
293  endif
294  ifeq ($(strip ${CFG_LITTLE}),0)
295    CFLAGS += -DCFG_BIENDIAN=1
296  endif
297endif
298
299
300#
301# Make the paths
302#
303
304INCDIRS = $(patsubst %,-I%,$(subst :, ,$(BOARD_INC) $(CHIPSET_INC) $(CPU_INC) $(ARCH_INC) $(CFE_INC)))
305
306VPATH = $(SRCDIRS)
307
308#
309# This is the makefile's main target.  Note that we actually
310# do most of the work in 'ALL' (from the build Makefile) not 'all'.
311#
312
313all : build_date.c makereg ALL
314
315.PHONY : all 
316.PHONY : ALL
317.PHONY : build_date.c
318
319#
320# Build the local tools that we use to construct other source files
321#
322
323HOST_CC = gcc
324HOST_CFLAGS = -g -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
325
326# For building the PCI device table
327AWK ?= gawk
328
329memconfig : ${TOP}/hosttools/memconfig.c
330	$(HOST_CC) $(HOST_CFLAGS) -o memconfig -D_MCSTANDALONE_ -D_MCSTANDALONE_NOISY_ -I${TOP}/arch/mips/chipset/sibyte/include -I${TOP}/arch/mips/cpu/sb1250/include -I${TOP}/include ${TOP}/hosttools/memconfig.c ${TOP}/arch/${ARCH}/cpu/${CPU}/src/sb1250_draminit.c
331
332memconfig1480 : ${TOP}/hosttools/memconfig1480.c
333	$(HOST_CC) $(HOST_CFLAGS) -o memconfig1480 -D_MCSTANDALONE_ -D_MCSTANDALONE_NOISY_ -I${TOP}/arch/mips/chipset/sibyte/include -I${TOP}/arch/mips/cpu/bcm1480/include -I${TOP}/include ${TOP}/hosttools/memconfig1480.c ${TOP}/arch/${ARCH}/cpu/${CPU}/src/bcm1480_draminit.c
334
335mkflashimage : ${TOP}/hosttools/mkflashimage.c
336	$(HOST_CC) $(HOST_CFLAGS) -o mkflashimage -I${TOP}/include ${TOP}/hosttools/mkflashimage.c
337
338swapflashimage : ${TOP}/hosttools/swapflashimage.c
339	$(HOST_CC) $(HOST_CFLAGS) -o swapflashimage -I${TOP}/include ${TOP}/hosttools/swapflashimage.c
340
341build_date.c :
342	echo "const char *builddate = \"`date`\";" > build_date.c
343	echo "const char *builduser = \"`whoami`@`hostname`\";" >> build_date.c
344
345#
346# Make a define for the board name
347#
348
349CFLAGS += -D_$(patsubst "%",%,${CFG_BOARDNAME})_
350
351#
352# Rules for building normal CFE files
353#
354
355LIBCFE = libcfe.a
356
357%.o : %.c
358	$(GCC) $(ENDIAN) $(CFE_CFLAGS) $(CFLAGS) -o $@ $<
359
360%.o : %.S
361	$(GCC) $(ENDIAN) $(CFE_CFLAGS) $(CFLAGS) -o $@ $<
362
363#
364# Rules for building ZIPSTART
365#
366
367LIBZIPSTART = libzipstart.a
368
369ZS_%.o : %.c
370	$(GCC) $(ENDIAN) $(ZIPSTART_CFLAGS) -D_ZIPSTART_ $(CFLAGS) -o $@ $<
371
372ZS_%.o : %.S
373	$(GCC) $(ENDIAN) $(ZIPSTART_CFLAGS) -D_ZIPSTART_ $(CFLAGS) -o $@ $<
374
375
376#
377# This rule constructs "libcfe.a" which contains most of the object
378# files.
379#
380
381$(LIBCFE) : $(ALLOBJS)
382	rm -f $(LIBCFE)
383	$(GAR) cr $(LIBCFE) $(ALLOBJS)
384	$(RANLIB) $(LIBCFE)
385
386
387
388