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_NEWRELOC ?= 0 17CFG_BOOTRAM ?= 0 18CFG_VGACONSOLE ?= 0 19CFG_PCI ?= 1 20CFG_LDT_REV_017 ?= 0 21CFG_ZLIB ?= 0 22CFG_LZMA ?= 0 23CFG_BIENDIAN ?= 0 24CFG_DOWNLOAD ?= 0 25CFG_RAMAPP ?= 0 26CFG_USB ?= 0 27CFG_XIP ?= 0 28CFG_SIM ?= 0 29CFG_SIM_CONSOLE ?= 0 30CFG_LDR_SREC ?= 0 31CFG_LDR_ELF ?= 0 32 33# 34# Paths to other parts of the firmware. Everything's relative to ${TOP} 35# so that you can actually do a build anywhere you want. 36# 37 38ARCH_TOP = ${TOP}/arch/${ARCH} 39ARCH_CMN = ${TOP}/arch/common 40ARCH_SRC = ${ARCH_TOP}/common/src 41ARCH_INC = ${ARCH_TOP}/common/include 42CPU_SRC = ${ARCH_TOP}/cpu/${CPU}/src 43CPU_INC = ${ARCH_TOP}/cpu/${CPU}/include 44 45# 46# It's actually optional to have a 'board' 47# directory. If you don't specify BOARD, 48# don't include the files. 49# 50 51ifneq ("$(strip ${BOARD})","") 52BOARD_SRC = ${ARCH_TOP}/board/${BOARD}/src 53BOARD_CMN = ${ARCH_CMN}/board/${BOARD}/src 54BOARD_INC = ${ARCH_TOP}/board/${BOARD}/include 55endif 56 57# 58# Preprocessor defines for CFE's version number 59# 60 61VDEF = -DCFE_VER_MAJ=${CFE_VER_MAJ} -DCFE_VER_MIN=${CFE_VER_MIN} -DCFE_VER_ECO=${CFE_VER_ECO} 62 63# 64# Construct the list of paths that will eventually become the include 65# paths and VPATH 66# 67 68SRCDIRS = ${ARCH_SRC} ${CPU_SRC} ${BOARD_SRC} ${BOARD_CMN} ${TOP}/main ${TOP}/vendor ${TOP}/include ${TOP}/net ${TOP}/dev ${TOP}/pci ${TOP}/ui ${TOP}/lib ${TOP}/common ${TOP}/verif 69 70CFE_INC = ${TOP}/include ${TOP}/pci ${TOP}/net 71 72ifeq ($(strip ${CFG_VGACONSOLE}),1) 73SRCDIRS += ${TOP}/x86emu ${TOP}/pccons 74CFE_INC += ${TOP}/x86emu ${TOP}/pccons 75endif 76 77ifeq ($(strip ${CFG_VAPI}),1) 78SRCDIRS += ${TOP}/verif 79CFE_INC += ${TOP}/verif 80endif 81 82ifeq ($(strip ${CFG_ZLIB}),1) 83SRCDIRS += ${TOP}/zlib 84CFE_INC += ${TOP}/zlib 85endif 86 87ifeq ($(strip ${CFG_SIM}),1) 88CFLAGS += -DCFG_SIM=1 89endif 90 91ifeq ($(strip ${CFG_SIM_CONSOLE}),1) 92CFLAGS += -DCFG_SIM_CONSOLE=1 93endif 94 95ifneq (${CFG_HEAP_SIZE},) 96CFLAGS += -DCFG_HEAP_SIZE=${CFG_HEAP_SIZE} 97endif 98 99ifeq ($(strip ${CFG_LZMA}),1) 100SRCDIRS += ${SRCBASE}/tools/misc/lzma_src/C 101CFE_INC += ${SRCBASE}/tools/misc/lzma_src/C 102endif 103 104ifeq ($(strip ${CFG_LDR_SREC}),1) 105CFLAGS += -DCFG_LDR_SREC=1 106endif 107 108ifeq ($(strip ${CFG_LDR_ELF}),1) 109CFLAGS += -DCFG_LDR_ELF=1 110endif 111 112INCDIRS = $(patsubst %,-I%,$(subst :, ,$(ARCH_INC) $(CPU_INC) $(BOARD_INC) $(CFE_INC))) 113 114VPATH = $(SRCDIRS) 115 116# 117# Bi-endian support: If we're building the little-endian 118# version, use a different linker script so we can locate the 119# ROM at a higher address. You'd think we could do this with 120# normal linker command line switches, but there appears to be no 121# command-line way to override the 'AT' qualifier in the linker script. 122# 123 124CFG_TEXTAT1MB=0 125ifeq ($(strip ${CFG_BIENDIAN}),1) 126 ifeq ($(strip ${CFG_LITTLE}),1) 127 CFG_TEXT_START = 0x9fd00000 128 CFG_ROM_START = 0xbfd00000 129 CFG_TEXTAT1MB=1 130 endif 131endif 132 133 134# 135# Configure tools and basic tools flags. This include sets up 136# macros for calling the C compiler, basic flags, 137# and linker scripts. 138# 139 140include ${ARCH_SRC}/tools.mk 141 142# 143# Add some common flags that are used on any architecture. 144# 145 146CFLAGS += -I. $(INCDIRS) 147CFLAGS += -D_CFE_ ${VDEF} -DCFG_BOARDNAME=\"${CFG_BOARDNAME}\" 148 149# 150# Gross - allow more options to be supplied from command line 151# 152 153ifdef CFG_OPTIONS 154OPTFLAGS = $(patsubst %,-D%,$(subst :, ,$(CFG_OPTIONS))) 155CFLAGS += ${OPTFLAGS} 156endif 157 158 159# 160# This is the makefile's main target. Note that we actually 161# do most of the work in 'ALL' not 'all', since we include 162# other makefiles after this point. 163# 164 165all : build_date.c makereg pcidevs_data2.h ALL 166 167# 168# Macros that expand to the list of arch-independent files 169# 170 171DEVOBJS = dev_flash.o dev_newflash.o dev_null.o dev_promice.o \ 172 dev_ide_common.o dev_ns16550.o dev_ds17887clock.o 173LIBOBJS = lib_malloc.o lib_printf.o lib_queue.o lib_string.o lib_string2.o \ 174 lib_arena.o lib_misc.o lib_setjmp.o lib_qsort.o lib_hssubr.o lib_physio.o \ 175 lib_scanf.o 176NETOBJS = net_ether.o net_arp.o net_ip.o net_udp.o net_api.o net_dns.o \ 177 net_dhcp.o net_tftp.o net_icmp.o net_tcp.o net_tcpbuf.o dev_tcpconsole.o net_http.o 178CFEOBJS = env_subr.o cfe_attach.o cfe_iocb_dispatch.o cfe_devfuncs.o \ 179 nvram_subr.o cfe_console.o cfe_main.o cfe_mem.o cfe_timer.o \ 180 cfe_background.o cfe_error.o build_date.o \ 181 cfe_rawfs.o cfe_zlibfs.o cfe_xreq.o cfe_fatfs.o cfe_httpfs.o cfe_filesys.o cfe_boot.o \ 182 cfe_autoboot.o cfe_ldr_elf.o cfe_ldr_raw.o cfe_ldr_srec.o cfe_loader.o url.o \ 183 cfe_savedata.o cfe_memfs.o 184UIOBJS = ui_command.o ui_cmddisp.o ui_envcmds.o ui_devcmds.o \ 185 ui_netcmds.o ui_tcpcmds.o ui_memcmds.o ui_loadcmds.o ui_pcicmds.o \ 186 ui_examcmds.o ui_flash.o ui_misccmds.o \ 187 ui_test_disk.o ui_test_ether.o ui_test_flash.o ui_test_uart.o 188 189# 190# Add more object files if we're supporting PCI 191# 192 193ifeq ($(strip ${CFG_PCI}),1) 194PCIOBJS = pciconf.o pci_subr.o pci_devs.o 195PCIOBJS += ldtinit.o 196DEVOBJS += dev_sp1011.o dev_ht7520.o 197DEVOBJS += dev_ide_pci.o dev_ns16550_pci.o 198DEVOBJS += dev_tulip.o dev_dp83815.o 199CFLAGS += -DCFG_PCI=1 200ifeq ($(strip ${CFG_LDT_REV_017}),1) 201CFLAGS += -DCFG_LDT_REV_017=1 202endif 203ifeq ($(strip ${CFG_DOWNLOAD}),1) 204DEVOBJS += dev_bcm1250.o download.data 205CFLAGS += -DCFG_DOWNLOAD=1 206endif 207endif 208 209ifeq ($(strip ${CFG_LZMA}),1) 210ALLOBJS += cfe_lzmafs.o LzmaDec.o 211CFLAGS += -DCFG_LZMA=1 212endif 213 214# 215# If doing bi-endian, add the compiler switch to change 216# the way the vectors are generated. These switches are 217# only added to the big-endian portion of the ROM, 218# which is located at the real boot vector. 219# 220 221ifeq ($(strip ${CFG_BIENDIAN}),1) 222 ifeq ($(strip ${CFG_LITTLE}),0) 223 CFLAGS += -DCFG_BIENDIAN=1 224 endif 225endif 226 227# 228# Use the (slightly more) portable C flash engine 229# 230 231ifeq ($(strip ${CFG_CFLASH}),1) 232CFLAGS += -DCFG_CFLASH=1 233ALLOBJS += dev_flashop_engine.o 234endif 235 236# 237# Include the makefiles for the architecture-common, cpu-specific, 238# and board-specific directories. Each of these will supply 239# some files to "ALLOBJS". The BOARD directory is optional 240# as some ports are so simple they don't need boad-specific stuff. 241# 242 243include ${ARCH_SRC}/Makefile 244include ${CPU_SRC}/Makefile 245 246ifneq ("$(strip ${BOARD})","") 247include ${BOARD_SRC}/Makefile 248endif 249 250# 251# Add the common object files here. 252# 253 254ALLOBJS += $(LIBOBJS) $(DEVOBJS) $(CFEOBJS) $(VENOBJS) $(UIOBJS) $(NETOBJS) $(PCIOBJS) 255 256# 257# VAPI continues to be a special case. 258# 259 260ifeq ($(strip ${CFG_VAPI}),1) 261include ${TOP}/verif/Makefile 262endif 263 264# 265# USB support 266# 267 268ifeq ($(strip ${CFG_USB}),1) 269SRCDIRS += ${TOP}/usb 270CFE_INC += ${TOP}/usb 271include ${TOP}/usb/Makefile 272endif 273 274# 275# If we're doing the VGA console thing, pull in the x86 emulator 276# and the pcconsole subsystem 277# 278 279ifeq ($(strip ${CFG_VGACONSOLE}),1) 280include ${TOP}/x86emu/Makefile 281include ${TOP}/pccons/Makefile 282endif 283 284# 285# If we're including ZLIB, then add its makefile. 286# 287 288ifeq ($(strip ${CFG_ZLIB}),1) 289include ${TOP}/zlib/Makefile 290CFLAGS += -DCFG_ZLIB=1 -DMY_ZCALLOC -DNO_MEMCPY 291endif 292 293# 294# Vendor extensions come next - they live in their own directory. 295# 296 297include ${TOP}/vendor/Makefile 298 299.PHONY : all 300.PHONY : ALL 301.PHONY : build_date.c 302 303# 304# Build the local tools that we use to construct other source files 305# 306 307mkpcidb : ${TOP}/hosttools/mkpcidb.c 308 gcc -o mkpcidb ${TOP}/hosttools/mkpcidb.c 309 310memconfig : ${TOP}/hosttools/memconfig.c 311 gcc -o memconfig -D_MCSTANDALONE_ -D_MCSTANDALONE_NOISY_ -I${TOP}/arch/mips/cpu/sb1250/include ${TOP}/hosttools/memconfig.c ${TOP}/arch/${ARCH}/cpu/${CPU}/src/sb1250_draminit.c 312 313pcidevs_data2.h : mkpcidb ${TOP}/pci/pcidevs_data.h 314 ./mkpcidb > pcidevs_data2.h 315 316mkflashimage : ${TOP}/hosttools/mkflashimage.c 317 gcc -o mkflashimage -I${TOP}/include ${TOP}/hosttools/mkflashimage.c 318 319pci_subr.o : ${TOP}/pci/pci_subr.c pcidevs_data2.h 320 321build_date.c : 322 echo "const char *builddate = \"`date`\";" > build_date.c 323 echo "const char *builduser = \"`whoami`@`hostname`\";" >> build_date.c 324 325# 326# Make a define for the board name 327# 328 329CFLAGS += -D_$(patsubst "%",%,${CFG_BOARDNAME})_ 330 331LIBCFE = libcfe.a 332 333%.o : %.c 334 $(GCC) $(CFLAGS) -o $@ $< 335 336%.o : %.S 337 $(GCC) $(ASFLAGS) $(CFLAGS) -o $@ $< 338 339# 340# This rule constructs "libcfe.a" which contains most of the object 341# files. 342# 343 344$(LIBCFE) : $(ALLOBJS) 345 rm -f $(LIBCFE) 346 $(GAR) cr $(LIBCFE) $(ALLOBJS) 347 $(RANLIB) $(LIBCFE) 348