aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2020-01-13 15:09:29 +0100
committerWojtek Kosior <kwojtus@protonmail.com>2020-01-13 15:09:29 +0100
commit376ead0f2fb6d2048cb0fe958c5455f2c5ea8961 (patch)
treedd2444b483306c933683fb77303dcf96080ecade
parentdf3f8539c01c0de5bca95d932dddb93f04283a42 (diff)
downloadrpi-MMU-example-376ead0f2fb6d2048cb0fe958c5455f2c5ea8961.tar.gz
rpi-MMU-example-376ead0f2fb6d2048cb0fe958c5455f2c5ea8961.zip
one %.o : %.c rule for host and arm
-rw-r--r--build/Makefile19
1 files changed, 13 insertions, 6 deletions
diff --git a/build/Makefile b/build/Makefile
index 7c9432f..8487dff 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -1,4 +1,10 @@
-CFLAGS=-mcpu=cortex-a7 -ffreestanding -std=gnu11 -Wall -Wextra $(addprefix -I, $(dirs))
+HOST_CC=gcc
+
+HOST_CFLAGS=-Wall -std=gnu99 -I../src/lib/rs232 -O3
+
+ARM_CC=arm-none-eabi-gcc
+
+ARM_CFLAGS=-mcpu=cortex-a7 -ffreestanding -std=gnu11 -Wall -Wextra $(addprefix -I, $(dirs))
ELFFLAGS=-nostdlib -lgcc
ARM_OBJECTS=kernel.o paging.o demo_functionality.o PL0_test.o uart.o loader_stage1.o loader_stage2.o
@@ -27,7 +33,8 @@ echo :
echo $(CFLAGS)
%.o : %.c
- arm-none-eabi-gcc $(CFLAGS) -c $< -o $@
+ $(if $(findstring /arm/,$<),\
+ $(ARM_CC) $(ARM_CFLAGS),$(HOST_CC) $(HOST_CFLAGS)) -c $< -o $@
%.img : %.elf
arm-none-eabi-objcopy $^ -O binary $@
@@ -68,11 +75,11 @@ run-on-rpi : kernel.img pipe_image
./pipe_image --stdout | sudo socat FILE:/dev/ttyUSB0,b115200,raw -
screen /dev/ttyUSB0 115200,cs8,-parenb,-cstopb,-hupcl
-pipe_image : pipe_image.c rs232.c
- gcc -Wall -std=gnu99 -I../src/lib/rs232 -O3 $^ -o $@
+pipe_image : pipe_image.o rs232.o
+ $(HOST_CC) $^ -o $@
-makefs : makefs.c
- gcc -Wall -std=gnu99 -O3 $^ -o $@
+makefs : makefs.o
+ $(HOST_CC) $^ -o $@
ramfs.img : makefs $(RAMFS_FILES)
./makefs $(RAMFS_FILES) > $@