Makefile: refine image dependency

This commit is contained in:
ULeang 2024-05-09 15:56:52 +08:00 committed by Zihao Yu
parent 6f2c345320
commit c3ffbc97c3
6 changed files with 17 additions and 16 deletions

View file

@ -15,14 +15,10 @@ AM_SRCS := native/trm.c \
CFLAGS += -fpie
ASFLAGS += -fpie -pie
comma = ,
LDFLAGS_CXX = $(addprefix -Wl$(comma), $(LDFLAGS))
image:
@echo + LD "->" $(IMAGE_REL)
@g++ -pie -o $(IMAGE) -Wl,--whole-archive $(LINKAGE) -Wl,-no-whole-archive $(LDFLAGS_CXX) -lSDL2 -ldl
LDFLAGS_CXX = $(addprefix -Wl$(comma), $(LDFLAGS)) -pie -lSDL2 -ldl
run: image
$(IMAGE)
$(IMAGE).elf
gdb: image
gdb -ex "handle SIGUSR1 SIGUSR2 SIGSEGV noprint nostop" $(IMAGE)
gdb -ex "handle SIGUSR1 SIGUSR2 SIGSEGV noprint nostop" $(IMAGE).elf

View file

@ -17,7 +17,7 @@ CFLAGS += -DMAINARGS=\"$(mainargs)\"
CFLAGS += -I$(AM_HOME)/am/src/platform/nemu/include
.PHONY: $(AM_HOME)/am/src/platform/nemu/trm.c
image: $(IMAGE).elf
image: image-dep
@$(OBJDUMP) -d $(IMAGE).elf > $(IMAGE).txt
@echo + OBJCOPY "->" $(IMAGE_REL).bin
@$(OBJCOPY) -S --set-section-flags .bss=alloc,contents -O binary $(IMAGE).elf $(IMAGE).bin

View file

@ -15,7 +15,7 @@ LDFLAGS += --gc-sections -e _start
CFLAGS += -DMAINARGS=\"$(mainargs)\"
.PHONY: $(AM_HOME)/am/src/riscv/npc/trm.c
image: $(IMAGE).elf
image: image-dep
@$(OBJDUMP) -d $(IMAGE).elf > $(IMAGE).txt
@echo + OBJCOPY "->" $(IMAGE_REL).bin
@$(OBJCOPY) -S --set-section-flags .bss=alloc,contents -O binary $(IMAGE).elf $(IMAGE).bin

View file

@ -11,7 +11,7 @@ build-arg: image
BOOT_HOME := $(AM_HOME)/am/src/x86/qemu/boot
image: $(IMAGE).elf
image: image-dep
@$(MAKE) -s -C $(BOOT_HOME)
@echo + CREATE "->" $(IMAGE_REL)
@( cat $(BOOT_HOME)/bootblock.o; head -c 1024 /dev/zero; cat $(IMAGE).elf ) > $(IMAGE)

View file

@ -16,4 +16,4 @@ LDFLAGS += --gc-sections -e _start
CFLAGS += -DMAINARGS=\"$(mainargs)\"
.PHONY: $(AM_HOME)/am/src/riscv/spike/trm.c
image: $(IMAGE).elf
image: image-dep