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