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

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

7 8 9 10 11
CC =		$(CROSS_COMPILE)gcc
OBJDUMP =	$(CROSS_COMPILE)objdump
OBJCOPY =	$(CROSS_COMPILE)objcopy
SIZE =		$(CROSS_COMPILE)size

12 13
-include $(CURDIR)/.config

14

15
PTP_NOPOSIX = ptp-noposix
Grzegorz Daniluk's avatar
Grzegorz Daniluk committed
16

17 18
obj-y = arch/lm32/crt0.o arch/lm32/irq.o arch/lm32/debug.o
obj-y += wrc_main.o wrc_ptp.o monitor/monitor.o
19

20 21
cflags-y = -include $(CURDIR)/include/generated/autoconf.h \
	-Iinclude -I.
22

23 24
cflags-$(CONFIG_PTP_NOPOSIX) += \
	-ffreestanding \
25 26 27 28 29 30 31 32 33
	-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 \
34 35 36 37 38
	-include $(PTP_NOPOSIX)/libposix/ptpd-wrappers.h \
	-I$(PTP_NOPOSIX)/wrsw_hal \
	-I$(PTP_NOPOSIX)/libptpnetif \
	-I$(PTP_NOPOSIX)/softpll \
	-I$(PTP_NOPOSIX)/PTPWRd
39

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

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

59 60
include shell/shell.mk
include tests/tests.mk
61
include lib/lib.mk
62
include sockitowm/sockitowm.mk
63
include dev/dev.mk
64

65

66
CFLAGS = $(CFLAGS_PLATFORM) $(cflags-y) -Wall \
67 68
	-ffunction-sections -fdata-sections -Os \
	-include include/trace.h
69 70

LDFLAGS = $(LDFLAGS_PLATFORM) \
71
	-Wl,--gc-sections -Os -lgcc -lc
72

73
OBJS = $(obj-y)
74

75 76 77
OUTPUT = wrc

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

79
all: tools $(OUTPUT).ram $(OUTPUT).vhd
80

81
.PRECIOUS: %.elf %.bin
82
.PHONY: all tools clean gitmodules
83

84
$(OUTPUT).elf: silentoldconfig gitmodules $(OBJS)
85
	$(CC) $(CFLAGS) -DGIT_REVISION=\"$(REVISION)\" -c revision.c
86
	${CC} -o $@ revision.o $(OBJS) $(LDFLAGS)
87
	${OBJDUMP} -d $(OUTPUT).elf > $(OUTPUT)_disasm.S
88 89 90 91 92 93 94 95 96 97
	$(SIZE) $@

%.bin: %.elf
	${OBJCOPY} -O binary $^ $@

%.ram: tools %.bin
	./tools/genraminit $*.bin 0 > $@

%.vhd: tools %.bin
	./tools/genramvhd -s 90112 $*.bin > $@
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
113

114 115 116 117 118 119 120 121 122
# if needed, check out the submodules (first time only), so users
# who didn't read carefully the manual won't get confused
gitmodules:
	@test -d ptp-noposix/libposix || echo "Checking out submodules"
	@test -d ptp-noposix/libposix || \
		git submodule init && git submodule update



123 124 125 126 127 128 129
# following targets from Makefile.kconfig
silentoldconfig:
	@mkdir -p include/config
	$(MAKE) -f Makefile.kconfig $@

scripts_basic config %config:
	$(MAKE) -f Makefile.kconfig $@
130 131

.config: silentoldconfig
132