aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile11
1 files changed, 7 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index f031d7c..96a809a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,7 @@
CFLAGS=-mcpu=cortex-a7 -ffreestanding -std=gnu99 -Wall -Wextra -I.
+ELFFLAGS=-ffreestanding -O2 -nostdlib -lgcc -I.
+
all : kernel7.img
kernel.o : kernel.c
@@ -12,7 +14,7 @@ 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.
+ arm-none-eabi-gcc -T linker.ld -o $@ $(ELFFLAGS) $^
kernel7.img : kernel.elf
arm-none-eabi-objcopy $^ -O binary $@
@@ -21,10 +23,11 @@ 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
+ arm-none-eabi-gcc -T loader_stage2.ld -o $@ $(ELFFLAGS) $^
loader_stage2.img : loader_stage2.elf
arm-none-eabi-objcopy $^ -O binary $@
+ test -n "$$(find $@ -size -16384c)" || exit -1
loader_stage2_embeddable.o : loader_stage2.img
arm-none-eabi-objcopy -I binary -O elf32-littlearm -B arm --rename-section .data=.rodata $^ $@
@@ -33,7 +36,7 @@ loader_stage1.o : loader_stage1.c
arm-none-eabi-gcc $(CFLAGS) -c $^ -o $@
loader.elf : boot.o loader_stage1.o loader_stage2_embeddable.o
- arm-none-eabi-gcc -T loader_stage1.ld -o $@ -ffreestanding -O2 -nostdlib $^ -lgcc
+ arm-none-eabi-gcc -T loader_stage1.ld -o $@ $(ELFFLAGS) $^
loader.img : loader.elf
arm-none-eabi-objcopy $^ -O binary $@
@@ -49,7 +52,7 @@ run-on-rpi : kernel7.img pipe_image
sleep 1
screen /dev/ttyUSB0 115200,cs8,-parenb,-cstopb,-hupcl
-pipe_image : pipe_image.c
+pipe_image : pipe_image.c RS-232/rs232.c
gcc -Wall -std=gnu99 -O3 $^ -o $@
clean :