aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2018-01-04 11:47:43 -0500
committerClyne Sullivan <tullivan99@gmail.com>2018-01-04 11:47:43 -0500
commite5ae7f10f3e144f4a08ee7a66b4105a5aa86e6e7 (patch)
treeae084444f0ea8c91f9b29683f26e09699f11d3f3 /Makefile
parent058c283919424ef8b4425cdf74739535dd1d8072 (diff)
initrd, lcd, file cleanup
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile54
1 files changed, 41 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 48175ff..87dd3a0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,16 +1,44 @@
+CROSS = arm-none-eabi-
+CC = gcc
+AS = as
+AR = ar
+OBJCOPY = objcopy
+
MCUFLAGS = -mthumb -mcpu=cortex-m4
-CFLAGS = -Iinclude $(MCUFLAGS)
-
-all:
- arm-none-eabi-as $(MCUFLAGS) startup_stm32l476xx.s -c -o out/startup_stm32l476xx.o
- arm-none-eabi-gcc $(CFLAGS) system_stm32l4xx.c -c -o out/system_stm32l4xx.o
- arm-none-eabi-gcc $(CFLAGS) stm32l4xx_it.c -c -o out/stm32l4xx_it.o
- arm-none-eabi-gcc $(CFLAGS) clock.c -c -o out/clock.o
- arm-none-eabi-gcc $(CFLAGS) heap.c -c -o out/heap.o
- arm-none-eabi-gcc $(CFLAGS) task.c -c -o out/task.o
- arm-none-eabi-gcc $(CFLAGS) main.c -c -o out/main.o
- arm-none-eabi-gcc $(CFLAGS) -T link.ld out/*.o -o out/main.elf
- arm-none-eabi-objcopy -O ihex out/main.elf main.hex
+AFLAGS = $(MCUFLAGS)
+CFLAGS = $(MCUFLAGS) -Iinclude -ffreestanding -Wall -Werror -Wextra
+OFLAGS = -O ihex
+
+CFILES = $(wildcard src/*.c)
+AFILES = $(wildcard src/*.s)
+
+OUTDIR = out
+OFILES = $(patsubst src/%.c, $(OUTDIR)/%.o, $(CFILES)) \
+ $(patsubst src/%.s, $(OUTDIR)/%.asm.o, $(AFILES))
+
+LIBDIR = -Llib
+LIBS = -llua
+
+HEX = main.hex
+
+all: $(HEX)
+
+$(HEX): $(OFILES)
+ @echo " LINK " $(HEX)
+ @$(CROSS)$(OBJCOPY) -B arm -I binary -O elf32-littlearm initrd.img out/initrd.img.o
+ @$(CROSS)$(CC) $(CFLAGS) $(LIBDIR) $(LIBS) -T link.ld out/*.o -o out/main.elf
+ @$(CROSS)$(OBJCOPY) $(OFLAGS) out/main.elf $(HEX)
+
+$(OUTDIR)/%.o: src/%.c
+ @echo " CC " $<
+ @$(CROSS)$(CC) $(CFLAGS) -c $< -o $@
+
+$(OUTDIR)/%.asm.o: src/%.s
+ @echo " AS " $<
+ @$(CROSS)$(AS) $(AFLAGS) -c $< -o $@
clean:
- rm -rf out/*
+ @echo " CLEAN"
+ @rm -rf out/*
+
+