aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 6821aebda6df5c73c812aae6640f734f9593ae97 (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

PREFIX=arm-none-eabi-
AS=$(PREFIX)as
GCC=$(PREFIX)gcc
OBJCOPY=$(PREFIX)objcopy

DEBUG=-g

ASFLAGS=-mcpu=cortex-m3 -W --fatal-warnings $(DEBUG)
CFLAGS=-mcpu=cortex-m3 -mthumb -ffreestanding -nostdlib -nostartfiles -nodefaultlibs $(DEBUG) -Wall -Wextra -Werror
LDFLAGS=-static

CFLAGS+=-Os

all: test1-kern.bin
all: test2-kern.bin
all: test3-kern.bin
all: test4-kern.bin
all: test5-kern.bin
all: test6-kern.bin
all: test7-kern.bin
all: test8-kern.bin
all: test9-kern.bin
all: test10-kern.bin
all: test11-kern.bin

test1-kern.elf: cortexm.ld common.ld setup.o init-m.o test1.o
test2-kern.elf: cortexm.ld common.ld setup.o init-m.o test2.o
test3-kern.elf: cortexm.ld common.ld setup.o init-m.o test3.o
test4-kern.elf: cortexm.ld common.ld setup.o init-m.o test4.o
test5-kern.elf: cortexm.ld common.ld setup.o init-m.o test5.o
test6-kern.elf: cortexm.ld common.ld setup.o init-m.o test6.o
test7-kern.elf: cortexm.ld common.ld setup.o init-m.o test7.o
test8-kern.elf: cortexm.ld common.ld setup.o init-m.o test8.o inst_skip.o
test9-kern.elf: cortexm.ld common.ld setup.o init-m-test9.o test9.o
test10-kern.elf:cortexm.ld common.ld setup.o init-m.o test10.o
test11-kern.elf:cortexm.ld common.ld setup.o init-m.o test11-buserr.o inst_skip.o

clean:
	rm -f *.o *.elf *.map *.bin *.img

%.o: %.c armv7m.h
	$(GCC) -c $< -o $@ $(CFLAGS)

%.o: %.S
	$(GCC) -c $< -o $@ $(CFLAGS)

%.elf:
	$(GCC) -T$(firstword $(filter %.ld,$^)) -Wl,-Map=$*.map -o $@ $(CFLAGS) $($*_CFLAGS) $(LDFLAGS) $(*_LDFLAGS) $(filter %.o,$^) -lgcc

%.bin: %.elf
	$(OBJCOPY) -S -O binary $< $@

%.img: %.bin
	rm -f $@
	dd if=/dev/zero of=$@ bs=1M count=64 conv=sparse
	dd if=$< of=$@ bs=1M conv=notrunc,sparse