Makefile 2.66 KB
Newer Older
1 2
PLATFORM = lm32

3
OBJS_WRC = wrc_main.o wrc_ptp.o dev/uart.o dev/endpoint.o dev/minic.o dev/pps_gen.o dev/syscon.o dev/softpll_ng.o lib/mprintf.o  dev/ep_pfilter.o dev/dna.o dev/i2c.o monitor/monitor.o dev/onewire.o dev/eeprom.o 
4

5
D = ptp-noposix
6
PTPD_CFLAGS  = -ffreestanding -DPTPD_FREESTANDING -DWRPC_EXTRA_SLIM -DPTPD_MSBF -DPTPD_DBG 
Grzegorz Daniluk's avatar
Grzegorz Daniluk committed
7 8
PTPD_CFLAGS += -Wall -ggdb -I$D/wrsw_hal \
	-I$D/libptpnetif -I$D/PTPWRd \
9
	-include $D/compat.h -include $D/PTPWRd/dep/trace.h -include $D/libposix/ptpd-wrappers.h
10
PTPD_CFLAGS += -DPTPD_NO_DAEMON -DNEW_SINGLE_WRFSM -DPTPD_TRACE_MASK=0
Grzegorz Daniluk's avatar
Grzegorz Daniluk committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

OBJS_PTPD = $D/PTPWRd/arith.o
OBJS_PTPD += $D/PTPWRd/bmc.o
OBJS_PTPD += $D/PTPWRd/dep/msg.o
OBJS_PTPD += $D/PTPWRd/dep/net.o
OBJS_PTPD += $D/PTPWRd/dep/servo.o
OBJS_PTPD += $D/PTPWRd/dep/sys.o
OBJS_PTPD += $D/PTPWRd/dep/timer.o
OBJS_PTPD += $D/PTPWRd/dep/wr_servo.o
OBJS_PTPD += $D/PTPWRd/protocol.o
OBJS_PTPD += $D/PTPWRd/wr_protocol.o
OBJS_PTPD_FREE   = $D/libposix/freestanding-startup.o
OBJS_PTPD_FREE	+= $D/libposix/freestanding-display.o
OBJS_PTPD_FREE	+= $D/libposix/wr_nolibs.o
OBJS_PTPD_FREE	+= $D/libposix/freestanding-wrapper.o

27
CROSS_COMPILE ?= lm32-elf-
28
CFLAGS_PLATFORM  = -mmultiply-enabled -mbarrel-shift-enabled 
29
LDFLAGS_PLATFORM = -mmultiply-enabled -mbarrel-shift-enabled   -nostdlib -T target/lm32/ram.ld 
Grzegorz Daniluk's avatar
Grzegorz Daniluk committed
30
OBJS_PLATFORM=target/lm32/crt0.o target/lm32/irq.o
31

32 33 34
# Comment this out if you don't want debugging
OBJS_PLATFORM+=target/lm32/debug.o

35 36
include shell/shell.mk
include tests/tests.mk
37 38 39 40

CC=$(CROSS_COMPILE)gcc
OBJCOPY=$(CROSS_COMPILE)objcopy
OBJDUMP=$(CROSS_COMPILE)objdump
41
CFLAGS= $(CFLAGS_PLATFORM) -ffunction-sections -fdata-sections -Os -Iinclude -include include/trace.h $(PTPD_CFLAGS) -Iptp-noposix/PTPWRd -I.
42
LDFLAGS= $(LDFLAGS_PLATFORM) -ffunction-sections -fdata-sections -Os -Iinclude
Grzegorz Daniluk's avatar
Grzegorz Daniluk committed
43
SIZE = $(CROSS_COMPILE)size
44
OBJS=$(OBJS_PLATFORM) $(OBJS_WRC) $(OBJS_PTPD) $(OBJS_PTPD_FREE) $(OBJS_SHELL) $(OBJS_TESTS)
45
OUTPUT=wrc
46 47
REVISION=$(shell git rev-parse HEAD)

48 49

all: 		$(OBJS)
50 51 52
				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
53
				$(SIZE) -t $(OBJS)
54
				${CC} -o $(OUTPUT).elf revision.o $(OBJS) $(LDFLAGS) 
55
				${OBJCOPY} -O binary $(OUTPUT).elf $(OUTPUT).bin
56
				${OBJDUMP} -d $(OUTPUT).elf > $(OUTPUT)_disasm.S
57
				./tools/genraminit $(OUTPUT).bin 0 > $(OUTPUT).ram
Grzegorz Daniluk's avatar
Grzegorz Daniluk committed
58

59 60 61 62
clean:	
	rm -f $(OBJS) $(OUTPUT).elf $(OUTPUT).bin $(OUTPUT).ram

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

Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
65
load:	#all
66
		./tools/lm32-loader $(OUTPUT).bin
67 68 69 70 71 72 73 74

tools:
			make -C tools
		
fpga:
		- killall -9 vuart_console
		../loadfile ../spec_top.bin
		./tools/zpu-loader $(OUTPUT).bin