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

4
# 1 enables Etherbone support
5
WITH_ETHERBONE=0
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

CFLAGS_EB = -DWITH_ETHERBONE=$(WITH_ETHERBONE)

29 30 31 32 33 34 35 36 37 38 39
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
40 41

OBJS_PTPD = $(PTP_NOPOSIX)/PTPWRd/arith.o \
42 43 44 45 46 47 48 49 50 51 52 53 54
	$(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
55

56
CFLAGS_PLATFORM  = -mmultiply-enabled -mbarrel-shift-enabled
57 58
LDFLAGS_PLATFORM = -mmultiply-enabled -mbarrel-shift-enabled \
	-nostdlib -T arch/lm32/ram.ld
59

60
OBJS_PLATFORM = arch/lm32/crt0.o arch/lm32/irq.o arch/lm32/debug.o
61

62 63
include shell/shell.mk
include tests/tests.mk
64
include lib/lib.mk
65
include sockitowm/sockitowm.mk
66
include dev/dev.mk
67

68

69 70 71 72 73 74 75
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
76

77 78 79
OBJS = $(OBJS_PLATFORM) $(OBJS_WRC) $(OBJS_PTPD) \
	$(OBJS_SHELL) $(OBJS_TESTS) $(OBJS_LIB) \
	$(OBJS_SOCKITOWM) $(OBJS_SOFTPLL) $(OBJS_DEV)
80

81 82 83
OUTPUT = wrc

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

85 86 87 88 89 90 91 92 93 94 95 96 97
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
98

99 100 101 102 103 104
$(OBJS): include/board.h

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


105
clean:
106
	rm -f $(OBJS) $(OUTPUT).elf $(OUTPUT).bin $(OUTPUT).ram include/board.h
107 108

%.o:		%.c
109
	${CC} $(CFLAGS) $(PTPD_CFLAGS) $(INCLUDE_DIR) $(LIB_DIR) -c $*.c -o $@
110 111

tools:
112
	make -C tools