Makefile 2.75 KB
Newer Older
1
CROSS_COMPILE = lm32-elf-
2

3 4 5
OBJS_WRC = 	wrc_main.o \
						wrc_ptp.o \
						monitor/monitor.o
6

7
PTP_NOPOSIX = ptp-noposix
Grzegorz Daniluk's avatar
Grzegorz Daniluk committed
8

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
INCLUDE_DIRS = -I$(PTP_NOPOSIX)/wrsw_hal -I$(PTP_NOPOSIX)/libptpnetif -Isoftpll -Iinclude
					 
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 \
28 29
						$(PTP_NOPOSIX)/libposix/freestanding-wrapper.o \
						$(PTP_NOPOSIX)/libposix/net.o
Grzegorz Daniluk's avatar
Grzegorz Daniluk committed
30

31
CFLAGS_PLATFORM  = -mmultiply-enabled -mbarrel-shift-enabled 
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
32
LDFLAGS_PLATFORM = -mmultiply-enabled -mbarrel-shift-enabled   -nostdlib -T arch/lm32/ram.ld 
33

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

36 37
include shell/shell.mk
include tests/tests.mk
38
include lib/lib.mk
39 40
include softpll/softpll.mk
include dev/dev.mk
41 42 43

CC=$(CROSS_COMPILE)gcc
OBJDUMP=$(CROSS_COMPILE)objdump
44 45 46 47 48 49
OBJCOPY=$(CROSS_COMPILE)objcopy
SIZE=$(CROSS_COMPILE)size
					 
CFLAGS= $(CFLAGS_PLATFORM) $(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 --gc-sections -Os -Iinclude
OBJS=$(OBJS_PLATFORM) $(OBJS_WRC) $(OBJS_PTPD) $(OBJS_SHELL) $(OBJS_TESTS) $(OBJS_LIB) $(OBJS_SOFTPLL) $(OBJS_DEV)
50
OUTPUT=wrc
51 52
REVISION=$(shell git rev-parse HEAD)

53
all: 		$(OBJS)
54 55 56
				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
57
				$(SIZE) -t $(OBJS)
58
				${CC} -o $(OUTPUT).elf revision.o $(OBJS) $(LDFLAGS) 
59
				${OBJCOPY} -O binary $(OUTPUT).elf $(OUTPUT).bin
60
				${OBJDUMP} -d $(OUTPUT).elf > $(OUTPUT)_disasm.S
61
				./tools/genraminit $(OUTPUT).bin 0 > $(OUTPUT).ram
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
62
				./tools/genramvhd -s 81920 $(OUTPUT).bin > $(OUTPUT).vhd
Grzegorz Daniluk's avatar
Grzegorz Daniluk committed
63

64 65 66 67
clean:	
	rm -f $(OBJS) $(OUTPUT).elf $(OUTPUT).bin $(OUTPUT).ram

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

Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
70
load:	#all
71
		./tools/lm32-loader $(OUTPUT).bin
72 73 74 75 76 77 78 79

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