summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: ed3b57a72bc9b78f3dc055d814a4b5f7e3d6006f (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
# Main debug switch
DEBUG ?= 0

# FW version
FW_VERSION = 1

# 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_s = $(patsubst %.h,%.s,$(TARGET_DEFS))
TARGETS_o = $(patsubst %.h,%.o,$(TARGET_DEFS))
TARGETS_elf = $(patsubst %.h,%.elf,$(TARGET_DEFS))
TARGETS_bin = $(patsubst %.h,%.bin,$(TARGET_DEFS))

all: $(TARGETS_bin) cf-fsi-test

cf-code/%.s : cf-code/%.h cf-code/cf-fsi-fw.S
	$(CC) -E $(M68KCPPFLAGS) -I. -include $^ -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-wrapper.o : cf-wrapper.S cf-code/cf-fsi-romulus.bin
	$(CC) $(CFLAGS) -c cf-wrapper.S -o $@

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

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

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