Makefile: sort out CFLAGS and LDFLAGS

This commit is contained in:
xinyangli 2024-12-11 17:01:38 +08:00
parent 5ca5e6972b
commit 3e33f2e0f1
Signed by: xin
SSH key fingerprint: SHA256:UU5pRTl7NiLFJbWJZa+snLylZSXIz5rgHmwjzv8v4oE
4 changed files with 39 additions and 20 deletions

View file

@ -56,7 +56,7 @@ $(eval $(call COMPILE_RULES,$(2)))
$(1).elf: $$($(2)OBJS)
@mkdir -p $$(dir $$@)
@echo + LD "->" $$(patsubst $$(CURDIR)/%,%,$(1).elf)
@$$(LD) $$($(2)_LDFLAGS) -o $$@ --start-group $$($(2)OBJS) --end-group
@$$(LD) $$($(2)LDFLAGS) -o $$@ --start-group $$($(2)OBJS) --end-group
$(1).bin: $(1).elf
@echo + OBJCOPY "->" $$(patsubst $$(CURDIR)/%,%,$(1))
@$$(OBJCOPY) -S --set-section-flags .bss=alloc,contents -O binary $(1).elf $(1).bin

View file

@ -7,10 +7,14 @@ AM_SRCS := am/src/platform/nemu/trm.c \
am/src/platform/nemu/ioe/disk.c \
am/src/platform/nemu/mpe.c
AM_CFLAGS += -fdata-sections -ffunction-sections
AM_LDFLAGS += -T $(AM_HOME)/scripts/linker.ld \
--defsym=_pmem_start=0x80000000 --defsym=_entry_offset=0x0
AM_LDFLAGS += --gc-sections -e _start
AM_PUBLIC_CFLAGS := -fdata-sections -ffunction-sections
AM_PUBLIC_LDFLAGS := --defsym=_pmem_start=0x80000000 --defsym=_entry_offset=0x0 \
--gc-sections --entry=_start
AM_CFLAGS += $(AM_PUBLIC_CFLAGS)
AM_LDFLAGS += -T$(AM_HOME)/scripts/linker.ld $(AM_PUBLIC_LDFLAGS)
AM_INTERFACE_CFLAGS += $(AM_PUBLIC_CFLAGS)
AM_INTERFACE_LDFLAGS += -T$(LIB_INSTALLDIR)/ldscripts/linker.ld $(AM_PUBLIC_LDFLAGS)
AM_CFLAGS += -DMAINARGS=\"$(mainargs)\"
AM_INCPATH += $(AM_HOME)/am/src/platform/nemu/include