aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 6ced3577365068a5b15901b5323d950e9f3b6dfb (about) (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
CFLAGS=-mcpu=cortex-a7 -ffreestanding -std=gnu99 -Wall -Wextra -I.

all : kernel7.img

kernel.o : kernel.c
	arm-none-eabi-gcc $(CFLAGS) -c $^ -o $@

uart.o : uart.c
	arm-none-eabi-gcc $(CFLAGS) -c $^ -o $@

boot.o : boot.S
	arm-none-eabi-as -mcpu=cortex-a7 $^ -o $@

kernel.elf : boot.o kernel.o uart.o
	arm-none-eabi-gcc -T linker.ld -o $@ -ffreestanding -O2 -nostdlib boot.o kernel.o uart.o -lgcc -I.

kernel7.img : kernel.elf
	arm-none-eabi-objcopy $^ -O binary $@

loader_stage2.o : loader_stage2.c
	arm-none-eabi-gcc $(CFLAGS) -c $^ -o $@

loader_stage2.elf : loader_stage2.o uart.o
	arm-none-eabi-gcc -T loader_stage2.ld -o $@ -ffreestanding -O2 -nostdlib $^ -lgcc

loader_stage2.img : loader_stage2.elf
	arm-none-eabi-objcopy $^ -O binary $@

loader_stage2_embeddable.o : loader_stage2.img
	arm-none-eabi-objcopy -I binary -O elf32-littlearm -B arm --rename-section .data=.rodata $^ $@

loader_stage1.o : loader_stage1.c
	arm-none-eabi-gcc $(CFLAGS) -c $^ -o $@

loader.elf : boot.o loader_stage1.o uart.o loader_stage2_embeddable.o
	arm-none-eabi-gcc -T loader_stage1.ld -o $@ -ffreestanding -O2 -nostdlib $^ -lgcc

loader.img : loader.elf
	arm-none-eabi-objcopy $^ -O binary $@

qemu-elf : kernel.elf
	qemu-system-arm -m 256 -M raspi2 -serial stdio -kernel $^

qemu-bin : kernel7.img
	qemu-system-arm -m 256 -M raspi2 -serial stdio -kernel $^

qemu-loader : loader.img
	qemu-system-arm -m 256 -M raspi2 -serial stdio -kernel $^

pipe_image : pipe_image.c
	gcc -Wall -std=gnu99 -O3 $^ -o $@

clean :
	-rm *.img *.elf *.o pipe_image

.PHONY: all qemu-elf qemu-bin clean