Newer
Older
# Tomasz Wlostowski for CERN, 2011,2012
CC = $(CROSS_COMPILE)gcc
OBJDUMP = $(CROSS_COMPILE)objdump
OBJCOPY = $(CROSS_COMPILE)objcopy
SIZE = $(CROSS_COMPILE)size
-include $(CURDIR)/.config
AUTOCONF = $(CURDIR)/include/generated/autoconf.h
PPSI_CONFIG = ppsi/include/generated/autoconf.h
# we miss CONFIG_ARCH_LM32 as we have no other archs by now
obj-y = arch/lm32/crt0.o arch/lm32/irq.o
LDS-$(CONFIG_WR_NODE) = arch/lm32/ram.ld
LDS-$(CONFIG_WR_SWITCH) = arch/lm32/ram-wrs.ld
obj-$(CONFIG_WR_NODE) += wrc_main.o
obj-$(CONFIG_WR_SWITCH) += wrs_main.o
obj-$(CONFIG_WR_SWITCH) += ipc/minipc-mem-server.o ipc/rt_ipc.o
# our linker script is preprocessed, so have a rule here
$(CC) -include $(AUTOCONF) -E -P $*.ld.S -o $@
cflags-y = -ffreestanding -include $(AUTOCONF) -Iinclude/std -Iinclude \
-I. -Isoftpll -Iipc
cflags-y += -I$(CURDIR)/pp_printf
cflags-$(CONFIG_PPSI) += \
-ffreestanding \
-include include/ppsi-wrappers.h \
-I$(PPSI)/arch-wrpc \
-I$(PPSI)/arch-wrpc/include \
-I$(PPSI)/proto-ext-whiterabbit \
-Iboards/spec
lib/ppsi-wrappers.o \
CFLAGS_PLATFORM = -mmultiply-enabled -mbarrel-shift-enabled
LDFLAGS_PLATFORM = -mmultiply-enabled -mbarrel-shift-enabled \
-nostdlib -T $(LDS-y)
# packet-filter rules depend on configuration; default is rules-plain
pfilter-y := rules-plain.bin
pfilter-$(CONFIG_ETHERBONE) := rules-ebone.bin
pfilter-$(CONFIG_NIC_PFILTER) := rules-e+nic.bin
export pfilter-y
all:
include shell/shell.mk
include lib/lib.mk
include pp_printf/printf.mk
include dev/dev.mk
include softpll/softpll.mk
# ppsi already has div64 (the same one), so only pick it if not using ppsi.
ifndef CONFIG_PPSI
# unfortunately, we need a prototype therex
cflags-y += -include include/wrc.h
endif
# And always complain if we pick the libgcc division: 64/32 = 32 is enough here.
obj-y += check-error.o
# add system check functions like stack overflow and check reset
obj-y += system_checks.o
# WR node has SDB support, WR switch does not
obj-$(CONFIG_WR_NODE) += sdb-lib/libsdbfs.a
cflags-$(CONFIG_WR_NODE) += -Isdb-lib
CFLAGS = $(CFLAGS_PLATFORM) $(cflags-y) -Wall -Wstrict-prototypes \
-ffunction-sections -fdata-sections -Os -Wmissing-prototypes \
-include include/trace.h -ggdb
LDFLAGS = $(LDFLAGS_PLATFORM) \
-Wl,--gc-sections -Os -lgcc -lc
OBJS = $(obj-y)
OUTPUT-$(CONFIG_WR_NODE) = wrc
OUTPUT-$(CONFIG_WR_SWITCH) = rt_cpu
OUTPUT := $(OUTPUT-y)
GIT_VER = $(shell git describe --always --dirty | sed 's;^wr-switch-sw-;;')
all: tools $(OUTPUT).ram $(OUTPUT).vhd $(OUTPUT).mif
.PRECIOUS: %.elf %.bin
.PHONY: all tools clean gitmodules $(PPSI)/ppsi.o
# we need to remove "ptpdump" support for ppsi if RAM size is small and
# we include etherbone
ifneq ($(CONFIG_RAMSIZE),131072)
ifdef CONFIG_ETHERBONE
PPSI_USER_CFLAGS = -DCONFIG_NO_PTPDUMP
endif
endif
PPSI_USER_CFLAGS += -DDIAG_PUTS=uart_sw_write_string
test -f $(PPSI)/.config || $(MAKE) -C $(PPSI) wrpc_defconfig
$(MAKE) -C $(PPSI) WRPCSW_ROOT=.. \
CROSS_COMPILE=$(CROSS_COMPILE) CONFIG_NO_PRINTF=y \
USER_CFLAGS="$(PPSI_USER_CFLAGS)"
sdb-lib/libsdbfs.a:
$(MAKE) -C sdb-lib
$(OUTPUT).elf: $(LDS-y) $(AUTOCONF) gitmodules $(OUTPUT).o config.o
$(CC) $(CFLAGS) -D__GIT_VER__="\"$(GIT_VER)\"" -c revision.c
${CC} -o $@ revision.o config.o $(OUTPUT).o $(LDFLAGS)
${OBJDUMP} -d $(OUTPUT).elf > $(OUTPUT)_disasm.S
$(LD) --gc-sections -e _start -r $(OBJS) -T bigobj.lds -o $@
config.o: .config
sed '1,3d' .config > .config.bin
dd bs=1 count=1 if=/dev/zero 2> /dev/null >> .config.bin
$(OBJCOPY) -I binary -O elf32-lm32 -B lm32 \
--rename-section .data=.data.config .config.bin $@
rm -f .config.bin
%.bin: %.elf
${OBJCOPY} -O binary $^ $@
%.ram: tools %.bin
./tools/genraminit $*.bin 0 > $@
%.vhd: tools %.bin
./tools/genramvhd -s $(CONFIG_RAMSIZE) $*.bin > $@
%.mif: tools %.bin
./tools/genrammif $*.bin $(CONFIG_RAMSIZE) > $@
$(AUTOCONF): silentoldconfig
rm -f $(OBJS) $(OUTPUT).elf $(OUTPUT).bin $(OUTPUT).ram \
$(LDS) rules-*.bin .depend
${CC} $(CFLAGS) $(PTPD_CFLAGS) $(INCLUDE_DIR) $(LIB_DIR) \
-include $(PPSI_CONFIG) -c $*.c -o $@
# if needed, check out the submodules (first time only), so users
# who didn't read carefully the manual won't get confused
gitmodules:
@test -d ppsi/arch-wrpc || echo "Checking out submodules"
@test -d ppsi/arch-wrpc || git submodule update --init
# following targets from Makefile.kconfig
silentoldconfig:
@mkdir -p include/config
$(MAKE) -f Makefile.kconfig $@
scripts_basic config:
$(MAKE) -f Makefile.kconfig $@
%config:
defconfig:
$(MAKE) -f Makefile.kconfig spec_defconfig
.config: silentoldconfig
# Trivial depend rule. We can't $(obj-y:.o=.c) because some objects come from
# assembly source. In glob avoid the toold directory, and ppsi/pp-printf
.depend: $(wildcard *.c [^pt]/*.c)
$(CC) $(CFLAGS) -DSDBFS_BIG_ENDIAN -MM $^ > $@