common: add header dependencies

This commit is contained in:
Zack Buhman 2023-07-23 22:30:47 +00:00
parent 0c7c2e663a
commit f6c9380ece
2 changed files with 13 additions and 4 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ segasmp/lib/sys_init.o
*.bin
*.gch
*.out
*.d

View File

@ -1,6 +1,7 @@
LIB ?= .
OPT ?= -Og
DEBUG ?= -g -gdwarf-4
GENERATED ?=
AARCH = --isa=sh2 --big
AFLAGS = --fatal-warnings
@ -8,6 +9,7 @@ AFLAGS = --fatal-warnings
CARCH = -m2 -mb
CFLAGS += -falign-functions=4 -ffunction-sections -fdata-sections -fshort-enums -ffreestanding -nostdlib
CFLAGS += -Wall -Werror -Wfatal-errors -Wno-error=unused-variable
DEPFLAGS = -MMD -E
LDFLAGS = --gc-sections --print-gc-sections --no-warn-rwx-segment --print-memory-usage --entry=_start --orphan-handling=error
CXXFLAGS = -std=c++20 -fno-exceptions -fno-non-call-exceptions -fno-rtti -fno-threadsafe-statics
@ -31,7 +33,7 @@ endef
as_obj_binary = _binary_$(subst .,_,$(subst /,_,$(basename $(1))))
define BUILD_BINARY_H
@echo $@
@echo gen $@
@echo '#pragma once' > $@
@echo '#include <stdint.h>' >> $@
@echo 'extern uint32_t $(call as_obj_binary,$@)_start __asm("$(call as_obj_binary,$@)_start");' >> $@
@ -45,10 +47,16 @@ endef
%.o: %.S
$(CC) $(CARCH) $(CFLAGS) $(OPT) $(DEBUG) -c $< -o $@
%.o: %.c
%.d: %.c $(GENERATED)
$(CC) $(CARCH) $(CFLAGS) $(OPT) $(DEBUG) $(DEPFLAGS) -c $< -MF $@ -o /dev/null
%.o: %.c %.d
$(CC) $(CARCH) $(CFLAGS) $(OPT) $(DEBUG) -c $< -o $@
%.o: %.cpp
%.d: %.cpp $(GENERATED)
$(CXX) $(CARCH) $(CFLAGS) $(CXXFLAGS) $(OPT) $(DEBUG) $(DEPFLAGS) -c $< -MF $@ -o /dev/null
%.o: %.cpp %.d
$(CXX) $(CARCH) $(CFLAGS) $(CXXFLAGS) $(OPT) $(DEBUG) -c $< -o $@
%.elf: $(LIB)/start.o
@ -127,7 +135,7 @@ sys_ip.elf: $(SYS_IP_OBJ)
@echo " INDEX 01 00:00:00" >> $@
clean:
rm -f *.iso *.o *.bin *.elf *.cue
rm -f *.iso *.o *.d *.bin *.elf *.cue
.SUFFIXES:
.INTERMEDIATE: