From 376ead0f2fb6d2048cb0fe958c5455f2c5ea8961 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Mon, 13 Jan 2020 15:09:29 +0100 Subject: one %.o : %.c rule for host and arm --- build/Makefile | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'build/Makefile') 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) > $@ -- cgit v1.2.3