From 0b88faf650ec9f14bc0d014d59fea81e2c542c72 Mon Sep 17 00:00:00 2001 From: isubasinghe Date: Mon, 27 Nov 2023 10:31:54 +1100 Subject: [PATCH] added concat of headers as a build output Signed-off-by: isubasinghe --- libmicrokit/Makefile | 6 +++++- monitor/Makefile | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libmicrokit/Makefile b/libmicrokit/Makefile index 97313480..b12e9ec6 100644 --- a/libmicrokit/Makefile +++ b/libmicrokit/Makefile @@ -17,6 +17,7 @@ CFLAGS := -std=gnu11 -g3 -O3 -nostdlib -ffreestanding -mcpu=$(GCC_CPU) -Wall -Wn LIBS := libmicrokit.a OBJS := main.o dbg.o OTHER_OBJS := crt0.o +ALLS := main_all.c $(BUILD_DIR)/%.o : src/%.S $(TOOLCHAIN)gcc -x assembler-with-cpp -c -g3 -mcpu=$(GCC_CPU) $< -o $@ @@ -24,12 +25,15 @@ $(BUILD_DIR)/%.o : src/%.S $(BUILD_DIR)/%.o : src/%.s $(TOOLCHAIN)as -g -mcpu=$(GCC_CPU) $< -o $@ +$(BUILD_DIR)/%_all.c: src/%.c + $(TOOLCHAIN)gcc $(CFLAGS) -E $< > $@ + $(BUILD_DIR)/%.o : src/%.c $(TOOLCHAIN)gcc -c $(CFLAGS) $< -o $@ LIB = $(addprefix $(BUILD_DIR)/, $(LIBS)) -all: $(LIB) $(addprefix $(BUILD_DIR)/, $(OTHER_OBJS)) +all: $(LIB) $(addprefix $(BUILD_DIR)/, $(OTHER_OBJS)) $(addprefix $(BUILD_DIR)/, $(ALLS)) $(LIB): $(addprefix $(BUILD_DIR)/, $(OBJS)) $(TOOLCHAIN)ar -rv $@ $^ diff --git a/monitor/Makefile b/monitor/Makefile index 569f4d2b..b195a14e 100644 --- a/monitor/Makefile +++ b/monitor/Makefile @@ -16,6 +16,7 @@ CFLAGS := -std=gnu11 -g3 -O3 -nostdlib -ffreestanding -mcpu=$(GCC_CPU) -Wall -Wn PROGS := monitor.elf OBJECTS := main.o crt0.o debug.o util.o +ALLS := main_all.c LINKSCRIPT := monitor.ld $(BUILD_DIR)/%.o : src/%.S @@ -24,12 +25,15 @@ $(BUILD_DIR)/%.o : src/%.S $(BUILD_DIR)/%.o : src/%.s $(TOOLCHAIN)as -g -mcpu=$(GCC_CPU) $< -o $@ +$(BUILD_DIR)/%_all.c: src/%.c + $(TOOLCHAIN)gcc $(CFLAGS) -E $< > $@ + $(BUILD_DIR)/%.o : src/%.c $(TOOLCHAIN)gcc -c $(CFLAGS) $< -o $@ OBJPROG = $(addprefix $(BUILD_DIR)/, $(PROGS)) -all: $(OBJPROG) +all: $(OBJPROG) $(addprefix $(BUILD_DIR)/, $(ALLS)) $(OBJPROG): $(addprefix $(BUILD_DIR)/, $(OBJECTS)) $(LINKSCRIPT) $(TOOLCHAIN)ld -T$(LINKSCRIPT) $(addprefix $(BUILD_DIR)/, $(OBJECTS)) -o $@