Makefile 3.07 KB
Newer Older
1
# choose your board here.
2
BOARD = spec
3

4 5
# Uncomment to enable Etherbone support (will soon be a Kconfig variable)
# CONFIG_ETHERBONE=y
6 7 8


# and don't touch the rest unless you know what you're doing.
9
CROSS_COMPILE ?= lm32-elf-
10

11 12 13 14 15
CC =		$(CROSS_COMPILE)gcc
OBJDUMP =	$(CROSS_COMPILE)objdump
OBJCOPY =	$(CROSS_COMPILE)objcopy
SIZE =		$(CROSS_COMPILE)size

16
OBJS_WRC = 	wrc_main.o \
17 18
		wrc_ptp.o \
		monitor/monitor.o
19

20
PTP_NOPOSIX = ptp-noposix
Grzegorz Daniluk's avatar
Grzegorz Daniluk committed
21

22 23 24 25
INCLUDE_DIRS = -I$(PTP_NOPOSIX)/wrsw_hal \
		-I$(PTP_NOPOSIX)/libptpnetif \
		-I$(PTP_NOPOSIX)/softpll \
		-Iinclude
26

27 28 29 30
# Will soon be managed by Kconfig
ifdef CONFIG_ETHERBONE
CFLAGS_EB = -DCONFIG_ETHERBONE=1
endif
31

32 33 34 35 36 37 38 39 40 41 42
CFLAGS_PTPD  = -ffreestanding \
	-DPTPD_FREESTANDING \
	-DWRPC_EXTRA_SLIM \
	-DPTPD_MSBF \
	-DPTPD_DBG \
	-DPTPD_NO_DAEMON \
	-DNEW_SINGLE_WRFSM \
	-DPTPD_TRACE_MASK=0 \
	-include $(PTP_NOPOSIX)/compat.h \
	-include $(PTP_NOPOSIX)/PTPWRd/dep/trace.h \
	-include $(PTP_NOPOSIX)/libposix/ptpd-wrappers.h
43 44

OBJS_PTPD = $(PTP_NOPOSIX)/PTPWRd/arith.o \
45 46 47 48 49 50 51 52 53 54 55 56 57
	$(PTP_NOPOSIX)/PTPWRd/bmc.o \
	$(PTP_NOPOSIX)/PTPWRd/dep/msg.o \
	$(PTP_NOPOSIX)/PTPWRd/dep/net.o \
	$(PTP_NOPOSIX)/PTPWRd/dep/sys.o \
	$(PTP_NOPOSIX)/PTPWRd/dep/timer.o \
	$(PTP_NOPOSIX)/PTPWRd/dep/wr_servo.o \
	$(PTP_NOPOSIX)/PTPWRd/dep/servo.o \
	$(PTP_NOPOSIX)/PTPWRd/protocol.o \
	$(PTP_NOPOSIX)/PTPWRd/wr_protocol.o \
	$(PTP_NOPOSIX)/libposix/freestanding-startup.o \
	$(PTP_NOPOSIX)/libposix/freestanding-wrapper.o \
	$(PTP_NOPOSIX)/libposix/net.o \
	$(PTP_NOPOSIX)/softpll/softpll_ng.o
Grzegorz Daniluk's avatar
Grzegorz Daniluk committed
58

59
CFLAGS_PLATFORM  = -mmultiply-enabled -mbarrel-shift-enabled
60 61
LDFLAGS_PLATFORM = -mmultiply-enabled -mbarrel-shift-enabled \
	-nostdlib -T arch/lm32/ram.ld
62

63
OBJS_PLATFORM = arch/lm32/crt0.o arch/lm32/irq.o arch/lm32/debug.o
64

65 66
include shell/shell.mk
include tests/tests.mk
67
include lib/lib.mk
68
include sockitowm/sockitowm.mk
69
include dev/dev.mk
70

71

72 73 74 75 76 77 78
CFLAGS = $(CFLAGS_PLATFORM) $(CFLAGS_EB) $(CFLAGS_PTPD) $(INCLUDE_DIRS) \
	-ffunction-sections -fdata-sections -Os -Iinclude \
	-include include/trace.h \
	$(PTPD_CFLAGS) -I$(PTP_NOPOSIX)/PTPWRd -I. -Isoftpll

LDFLAGS = $(LDFLAGS_PLATFORM) \
	-ffunction-sections -fdata-sections -Wl,--gc-sections -Os -Iinclude
79

80 81 82
OBJS = $(OBJS_PLATFORM) $(OBJS_WRC) $(OBJS_PTPD) \
	$(OBJS_SHELL) $(OBJS_TESTS) $(OBJS_LIB) \
	$(OBJS_SOCKITOWM) $(OBJS_SOFTPLL) $(OBJS_DEV)
83

84 85 86
OUTPUT = wrc

REVISION=$(shell git describe --dirty --always)
87

88 89 90 91 92 93 94 95 96 97 98 99 100
all: tools wrc

wrc: $(OBJS)
	echo "const char *build_revision = \"$(REVISION)\";" > revision.c
	echo "const char *build_date = __DATE__ \" \" __TIME__;" >> revision.c
	$(CC) $(CFLAGS) -c revision.c
	$(SIZE) -t $(OBJS)
	${CC} -o $(OUTPUT).elf revision.o $(OBJS) $(LDFLAGS)
	${OBJCOPY} -O binary $(OUTPUT).elf $(OUTPUT).bin
	${OBJDUMP} -d $(OUTPUT).elf > $(OUTPUT)_disasm.S
	cd tools; $(MAKE)
	./tools/genraminit $(OUTPUT).bin 0 > $(OUTPUT).ram
	./tools/genramvhd -s 90112 $(OUTPUT).bin > $(OUTPUT).vhd
Grzegorz Daniluk's avatar
Grzegorz Daniluk committed
101

102 103 104 105 106 107
$(OBJS): include/board.h

include/board.h:
	ln -sf ../boards/$(BOARD)/board.h include/board.h


108
clean:
109
	rm -f $(OBJS) $(OUTPUT).elf $(OUTPUT).bin $(OUTPUT).ram include/board.h
110 111

%.o:		%.c
112
	${CC} $(CFLAGS) $(PTPD_CFLAGS) $(INCLUDE_DIR) $(LIB_DIR) -c $*.c -o $@
113 114

tools:
115
	make -C tools