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

4
# 1 enables Etherbone support
5
WITH_ETHERBONE=0
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50











































# and don't touch the rest unless you know what you're doing.

51
CROSS_COMPILE = lm32-elf-
52

53 54 55
OBJS_WRC = 	wrc_main.o \
						wrc_ptp.o \
						monitor/monitor.o
56

57
PTP_NOPOSIX = ptp-noposix
Grzegorz Daniluk's avatar
Grzegorz Daniluk committed
58

59
INCLUDE_DIRS = -I$(PTP_NOPOSIX)/wrsw_hal -I$(PTP_NOPOSIX)/libptpnetif -I$(PTP_NOPOSIX)/softpll -Iinclude
60 61 62

CFLAGS_EB = -DWITH_ETHERBONE=$(WITH_ETHERBONE)

63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
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

OBJS_PTPD = $(PTP_NOPOSIX)/PTPWRd/arith.o \
						$(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 \
80
						$(PTP_NOPOSIX)/libposix/freestanding-wrapper.o \
81 82
						$(PTP_NOPOSIX)/libposix/net.o \
						$(PTP_NOPOSIX)/softpll/softpll_ng.o
Grzegorz Daniluk's avatar
Grzegorz Daniluk committed
83

84
CFLAGS_PLATFORM  = -mmultiply-enabled -mbarrel-shift-enabled 
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
85
LDFLAGS_PLATFORM = -mmultiply-enabled -mbarrel-shift-enabled   -nostdlib -T arch/lm32/ram.ld 
86

Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
87
OBJS_PLATFORM=arch/lm32/crt0.o arch/lm32/irq.o arch/lm32/debug.o
88

89 90
include shell/shell.mk
include tests/tests.mk
91
include lib/lib.mk
92
include sockitowm/sockitowm.mk
93
include dev/dev.mk
94 95 96

CC=$(CROSS_COMPILE)gcc
OBJDUMP=$(CROSS_COMPILE)objdump
97 98 99
OBJCOPY=$(CROSS_COMPILE)objcopy
SIZE=$(CROSS_COMPILE)size
					 
100
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
101
LDFLAGS= $(LDFLAGS_PLATFORM) -ffunction-sections -fdata-sections -Wl,--gc-sections -Os -Iinclude
102
OBJS=$(OBJS_PLATFORM) $(OBJS_WRC) $(OBJS_PTPD) $(OBJS_SHELL) $(OBJS_TESTS) $(OBJS_LIB) $(OBJS_SOCKITOWM) $(OBJS_SOFTPLL) $(OBJS_DEV)
103
OUTPUT=wrc
104 105
REVISION=$(shell git rev-parse HEAD)

106 107 108 109 110
$(shell ln -sf ../boards/$(BOARD)/board.h include/board.h) 

all:		tools wrc

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

121 122 123 124
clean:	
	rm -f $(OBJS) $(OUTPUT).elf $(OUTPUT).bin $(OUTPUT).ram

%.o:		%.c
Grzegorz Daniluk's avatar
Grzegorz Daniluk committed
125
				${CC} $(CFLAGS) $(PTPD_CFLAGS) $(INCLUDE_DIR) $(LIB_DIR) -c $^ -o $@
126 127

tools:
128
			make -C tools