Support .c files in Makefile

This commit is contained in:
Aetias
2024-04-20 13:08:56 +02:00
parent 9b3049e7e6
commit a4330e37e9
2 changed files with 13 additions and 4 deletions
+12 -4
View File
@@ -26,10 +26,12 @@ ARM7_BIOS := arm7_bios.bin
ASSETS_TXT := assets.txt
ASM_FILES := $(shell find asm -name *.s)
CXX_FILES := $(shell find src -name *.cpp)
CXX_FILES := $(shell find src -name *.cpp) $(shell find libs -name *.cpp)
C_FILES := $(shell find src -name *.c) $(shell find libs -name *.c)
ASM_OBJS = $(ASM_FILES:%.s=$(TARGET_DIR)/%.s.o)
ASM_INCS = $(ASM_FILES:%.s=%.inc)
CXX_OBJS = $(CXX_FILES:%.cpp=$(TARGET_DIR)/%.cpp.o)
C_OBJS = $(C_FILES:%.c=$(TARGET_DIR)/%.c.o)
OV_BINS := $(wildcard $(TARGET_DIR)/overlays/*.bin)
OV_LZS = $(OV_BINS:%.bin=%.lz)
@@ -47,7 +49,9 @@ LCF_FILE := $(ROOT)/$(BUILD_DIR)/arm9_linker_script.lcf
OBJS_FILE := $(ROOT)/$(BUILD_DIR)/arm9_objects.txt
ASM_FLAGS := -proc arm5te -d $(REGION) -i asm -msgstyle gcc
CC_FLAGS := -proc arm946e -interworking -O4,p -enum int -i include -i- -i libs/c/include -nolink -d $(REGION) -char signed -lang=c++ -sym on -msgstyle gcc
CC_FLAGS := -proc arm946e -interworking -O4,p -enum int -i include -i- -i libs/c/include -i libs/cpp/include -nolink -d $(REGION) -char signed -sym on -msgstyle gcc
C_FLAGS := -lang=c
CXX_FLAGS := -lang=c++
LD_FLAGS := -proc arm946e -nostdlib -interworking -nodead -m Entry -map closure,unused -o main.bin -msgstyle gcc
ifeq ($(NONMATCHING),1)
@@ -121,10 +125,14 @@ $(ASM_OBJS): $(TARGET_DIR)/%.o: %
$(CXX_OBJS): $(TARGET_DIR)/%.o: %
mkdir -p $(dir $@)
LM_LICENSE_FILE=$(MW_LICENSE) $(WINE) $(MW_CC) $(CC_FLAGS) $< -o $@
LM_LICENSE_FILE=$(MW_LICENSE) $(WINE) $(MW_CC) $(CC_FLAGS) $(CXX_FLAGS) $< -o $@
$(C_OBJS): $(TARGET_DIR)/%.o: %
mkdir -p $(dir $@)
LM_LICENSE_FILE=$(MW_LICENSE) $(WINE) $(MW_CC) $(CC_FLAGS) $(C_FLAGS) $< -o $@
.PHONY: link
link: lcf $(ASM_OBJS) $(CXX_OBJS)
link: lcf $(ASM_OBJS) $(CXX_OBJS) $(C_OBJS)
cd $(TARGET_DIR) && LM_LICENSE_FILE=$(MW_LICENSE) $(WINE) $(MW_LD) $(LD_FLAGS) $(LCF_FILE) @$(OBJS_FILE)
.PHONY: compress
+1
View File
@@ -39,6 +39,7 @@ _0211bf50: .word data_ov09_0211f59c
- If no suitable header file exists, make a new one and put any structs and types you need in there.
1. Paste the context into decomp.me, and create the scratch.
1. Copy the `CC_FLAGS` from `Makefile` into the arguments field in decomp.me.
- Also copy `CXX_FLAGS` if your function comes from a `.cpp` file. Otherwise, copy `C_FLAGS` if it's a `.c` file.
- Replace the `-d $(REGION)` flag with whichever region you intend to decompile for. You can also delete the flag entirely
if the function contains no region differences.
1. Decompile the function and try to get a 100% match.