aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2021-12-02 23:24:29 -0700
committerChristian Cunningham <cc@localhost>2021-12-02 23:24:29 -0700
commitbea722ff0d5445d716b26df8eabfda24b6000776 (patch)
treee3c2600eb3acd652100417792ab151d048b7e62a
parent7b88542a9894954f1427e2409cf8bbe27ba4133b (diff)
Updated Unix Make
-rw-r--r--Unix.mk30
1 files changed, 23 insertions, 7 deletions
diff --git a/Unix.mk b/Unix.mk
index 0252b36..761d406 100644
--- a/Unix.mk
+++ b/Unix.mk
@@ -1,9 +1,9 @@
C_SOURCES = $(wildcard src/*.c)
C_HEADERS = $(wildcard src/*.h)
-C_OBJECTS = ${C_SOURCES:.c=.o}
+C_OBJECTS = ${C_SOURCES:.c=.co}
C_OBJECTD = ${subst src,obj,${C_OBJECTS}}
A_SOURCES = $(wildcard src/*.S)
-A_OBJECTS = ${A_SOURCES:.S=.o}
+A_OBJECTS = ${A_SOURCES:.S=.ao}
A_OBJECTD = ${subst src,obj,${A_OBJECTS}}
CROSS = arm-none-eabi
@@ -13,31 +13,47 @@ OBJCOPY = ${CROSS}-objcopy
OBJDUMP = ${CROSS}-objdump
QEMU = qemu-system-arm
GDB = gdb-multiarch
-CFLAGS = -mcpu=cortex-a7 -fpic -ffreestanding -std=gnu99 -O2 -Wall -Wextra -nostdlib -g
-AFLAGS = -mcpu=cortex-a7
+CFLAGS = -mcpu=cortex-a7 -fpic -ffreestanding -std=gnu99 -O3 -Wall -Wextra -nostdlib -g
+AFLAGS = -mcpu=cortex-a7 -g
QFLAGS = -M raspi2 -cpu arm1176 -m 1G -serial mon:stdio -nographic
+BSP ?= 2
+
+ifeq ($(BSP),2)
+ BSP23 = 1
+ CFLAGS += -DBSP23
+endif
+
.PHONY: clean run run-debug debug export
default: clean build/kernel7.img
build/kernel7.img: build/kernel.elf
+ @mkdir -p $(@D)
${OBJCOPY} $< -O binary $@
build/kernel.list: build/kernel-g.elf
+ @mkdir -p $(@D)
${OBJDUMP} -D $< > $@
build/kernel-g.elf: ${A_OBJECTD} ${C_OBJECTD}
+ @mkdir -p $(@D)
${CC} -T linker.ld -o $@ ${CFLAGS} $^ -lgcc
build/kernel.elf: ${A_OBJECTD} ${C_OBJECTD}
+ @mkdir -p $(@D)
${CC} -T linker.ld -o $@ -ffreestanding -O2 -nostdlib $^ -lgcc
export: build/kernel.list
cp build/kernel-g.elf /mnt/c/Local/
-obj/%.o: src/%.S
- ${AS} ${AFLAGS} -g -c $< -o $@
+obj/%.co: src/%.c
+ @mkdir -p $(@D)
+ ${CC} ${CFLAGS} -c $< -o $@
+
+obj/%.ao: src/%.S
+ @mkdir -p $(@D)
+ ${AS} ${AFLAGS} -c $< -o $@
run: build/kernel.elf
${QEMU} -kernel $< ${QFLAGS}
@@ -49,4 +65,4 @@ debug: build/kernel-g.elf build/kernel.list
${GDB} $< -command=gdbinit
clean:
- rm -f obj/*.o build/*.elf build/*.list build/*.img
+ rm -f obj/*.o build/*.elf build/*.list build/*.img obj/*.ao obj/*.co