summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 33f6d07a62167e258ac39ed7665c64c64f53d7b9 (plain)
1
2
3
4
5
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Main debug switch
DEBUG ?= 0

# FW version
FW_VERSION = 2

# ARM compiler for userspace test code
CROSS_COMPILE ?= arm-linux-
CC = $(CROSS_COMPILE)gcc
CFLAGS = -Wall -Os -Werror

# M68K toolchain for CF firmware
M68KCROSS ?= /opt/cross/binutils-coldfire/bin/m68k-unknown-elf-
M68KAS=$(M68KCROSS)as
M68KLD=$(M68KCROSS)ld
M68KOC=$(M68KCROSS)objcopy

M68KCPPFLAGS = -DFW_VERSION=$(FW_VERSION)

ifeq ($(DEBUG),1)
M68KCPPFLAGS += -DENABLE_TRACE
endif
M68KAFLAGS = -march=isac --pcrel -k
M68KLDFLAGS = -Ttext 0

# FW code files
TARGET_DEFS = $(wildcard cf-code/*.h)
TARGETS_bin = $(patsubst %.h,%.bin,$(TARGET_DEFS))

FW_SOURCE = cf-code/cf-fsi-fw.S
FW_DEPS = $(FW_SOURCE) cf-fsi-fw.h

all: cf-fsi-fw.bin cf-fsi-test-rom cf-fsi-test-palm

cf-code/%.s : cf-code/%.h $(FW_DEPS)
	$(CC) -E $(M68KCPPFLAGS) -I. -include $< $(FW_SOURCE) -o $@

cf-code/%.o : cf-code/%.s
	$(M68KAS) $(M68KAFLAGS) -march=isac $^ -o $@

cf-code/%.elf : cf-code/%.o
	$(M68KLD) $(M68KLDFLAGS) $^ -o $@

cf-code/%.bin : cf-code/%.elf
	$(M68KOC) -O binary $^ $@

cf-fsi-fw.bin : $(TARGETS_bin)
	cat $^ >$@

cf-wrapper.o : cf-fsi-fw.bin cf-wrapper.S
	$(CC) $(CFLAGS) -DCF_FILE=$< -c cf-wrapper.S -o $@

cf-fsi-test-rom : cf-fsi-test.c cf-wrapper.o
	$(CC) $(CFLAGS) -DROMULUS $^ -o $@

cf-fsi-test-palm : cf-fsi-test.c cf-wrapper.o
	$(CC) $(CFLAGS) -O0 -mcpu=arm926ej-s -DPALMETTO $^ -o $@

# Keep the ELF for debugging
.PRECIOUS : cf-code/%.elf

clean:
	rm -rf cf-fsi-test-* *.o *.s *.bin
	rm -rf cf-code/*.elf cf-code/*.bin cf-code/*.s cf-code/*.o
OpenPOWER on IntegriCloud