Makefile: group -l to avoid deps at image generation

This commit is contained in:
xinyangli 2024-12-11 20:50:32 +08:00
parent 5f096b8805
commit 989ee41ac7
Signed by: xin
SSH key fingerprint: SHA256:UU5pRTl7NiLFJbWJZa+snLylZSXIz5rgHmwjzv8v4oE
2 changed files with 5 additions and 3 deletions

View file

@ -8,7 +8,7 @@
# E.g: # E.g:
# $(eval $(call COMPILE_RULES,AM_)) # $(eval $(call COMPILE_RULES,AM_))
define COMPILE_RULES define COMPILE_RULES
$(1)OBJS := $$(addprefix $$(BUILDDIR)/, $$(addsuffix .o, $$($(1)SRCS))) $(1)OBJS += $$(addprefix $$(BUILDDIR)/, $$(addsuffix .o, $$($(1)SRCS)))
### Rule (compile): a single `.c` -> `.c.o` (gcc) ### Rule (compile): a single `.c` -> `.c.o` (gcc)
$$(filter %.c.o, $$($(1)OBJS)): $$(BUILDDIR)/%.c.o: %.c $$(filter %.c.o, $$($(1)OBJS)): $$(BUILDDIR)/%.c.o: %.c
@mkdir -p $$(dir $$@) && echo + CC $$< @mkdir -p $$(dir $$@) && echo + CC $$<
@ -56,9 +56,9 @@ $(eval $(call COMPILE_RULES,$(2)))
$(1).elf: $$($(2)OBJS) $(1).elf: $$($(2)OBJS)
@mkdir -p $$(dir $$@) @mkdir -p $$(dir $$@)
@echo + LD "->" $$(patsubst $$(CURDIR)/%,%,$(1).elf) @echo + LD "->" $$(patsubst $$(CURDIR)/%,%,$(1).elf)
@$$(LD) $$($(2)LDFLAGS) -o $$@ --start-group $$($(2)OBJS) --end-group @$$(LD) -o $$@ $$(filter-out -l%,$$($(2)LDFLAGS)) --start-group $$($(2)OBJS) $$(filter -l%,$$($(2)LDFLAGS)) --end-group
$(1).bin: $(1).elf $(1).bin: $(1).elf
@echo + OBJCOPY "->" $$(patsubst $$(CURDIR)/%,%,$(1)) @echo + OBJCOPY "->" $$(patsubst $$(CURDIR)/%,%,$(1).bin)
@$$(OBJCOPY) -S --set-section-flags .bss=alloc,contents -O binary $(1).elf $(1).bin @$$(OBJCOPY) -S --set-section-flags .bss=alloc,contents -O binary $(1).elf $(1).bin
endef endef

View file

@ -1,7 +1,9 @@
include $(AM_HOME)/scripts/isa/riscv.mk include $(AM_HOME)/scripts/isa/riscv.mk
include $(AM_HOME)/scripts/platform/nemu.mk include $(AM_HOME)/scripts/platform/nemu.mk
AM_CFLAGS += -DISA_H=\"riscv/riscv.h\" -march=rv32im_zicsr -mabi=ilp32 AM_CFLAGS += -DISA_H=\"riscv/riscv.h\" -march=rv32im_zicsr -mabi=ilp32
KLIB_CFLAGS += -march=rv32im_zicsr -mabi=ilp32
AM_LDFLAGS += -melf32lriscv AM_LDFLAGS += -melf32lriscv
INTERFACE_CFLAGS += -march=rv32im_zicsr -mabi=ilp32
AM_SRCS += am/src/riscv/nemu/start.S \ AM_SRCS += am/src/riscv/nemu/start.S \
am/src/riscv/nemu/cte.c \ am/src/riscv/nemu/cte.c \