From 0c679b24b05da2fbfcdc7c6c08063c15aac734fa Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 7 Jul 2024 13:56:41 -0700 Subject: [PATCH] Makefile Improvements (#81) * Include WORKING_DIR in CC so can call compiler with just CC not WORKING_DIR/CC * Move makefiles (except the main one) to a makefiles folder to keep root cleaner * Set compiler based on target, and use that to set proper makefile * .mk file extension * Use AS for assembly files instead of CC --- Makefile | 28 ++++++++++++++++++---------- Makefile.gcc => makefiles/gcc.mk | 17 ++++++++--------- Makefile.ido => makefiles/ido.mk | 9 ++++----- 3 files changed, 30 insertions(+), 24 deletions(-) rename Makefile.gcc => makefiles/gcc.mk (86%) rename Makefile.ido => makefiles/ido.mk (94%) diff --git a/Makefile b/Makefile index eff34bd2..8b0c78db 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,14 @@ TARGET ?= libgultra_rom VERSION ?= L CROSS ?= mips-linux-gnu- +ifeq ($(findstring libgultra,$(TARGET)),libgultra) +COMPILER := gcc +else ifeq ($(findstring libultra,$(TARGET)),libultra) +COMPILER := ido +else +$(error Invalid Target) +endif + BASE_DIR := extracted/$(VERSION)/$(TARGET) BASE_AR := base/$(VERSION)/$(TARGET).a BUILD_ROOT := build @@ -41,15 +49,15 @@ else DEBUGFLAG := -DNDEBUG endif -ifeq ($(findstring libgultra,$(TARGET)),libgultra) --include Makefile.gcc -else ifeq ($(findstring libultra,$(TARGET)),libultra) --include Makefile.ido +ifeq ($(COMPILER),gcc) +-include makefiles/gcc.mk +else ifeq ($(COMPILER),ido) +-include makefiles/ido.mk else -$(error Invalid Target) +$(error Invalid Compiler) endif -export COMPILER_PATH := $(WORKING_DIR)/$(COMPILER_DIR) +export COMPILER_PATH := $(COMPILER_DIR) ifeq ($(findstring _rom,$(TARGET)),_rom) CPPFLAGS += -D_FINALROM @@ -168,10 +176,10 @@ $(BUILD_DIR)/src/sp/sprite.marker: GBIDEFINE := -DF3D_GBI $(BUILD_DIR)/src/sp/spriteex.marker: GBIDEFINE := $(BUILD_DIR)/src/sp/spriteex2.marker: GBIDEFINE := $(BUILD_DIR)/src/voice/%.marker: OPTFLAGS += -DLANG_JAPANESE -I$(WORKING_DIR)/src -I$(WORKING_DIR)/src/voice -$(BUILD_DIR)/src/voice/%.marker: CC := tools/compile_sjis.py -D__CC=$(WORKING_DIR)/$(CC) -D__BUILD_DIR=$(BUILD_DIR) +$(BUILD_DIR)/src/voice/%.marker: CC := $(WORKING_DIR)/tools/compile_sjis.py -D__CC=$(CC) -D__BUILD_DIR=$(BUILD_DIR) $(C_MARKER_FILES): $(BUILD_DIR)/%.marker: %.c - cd $(