#Build architecture/variant string, possible values: x86, armv7le, etc... PLATFORM ?= PSX #Build profile, possible values: release, debug, profile, coverage BUILD_DIR ?= bin BUILD_PROFILE ?= debug CONFIG_NAME ?= $(PLATFORM)-$(BUILD_PROFILE) OUTPUT_DIR = $(BUILD_DIR)/$(CONFIG_NAME) TARGET = $(OUTPUT_DIR)/$(ARTIFACT) #Compiler definitions HAS_LINUX_MIPS_GCC = $(shell which mipsel-linux-gnu-gcc > /dev/null 2> /dev/null && echo true || echo false) ifeq ($(HAS_LINUX_MIPS_GCC),true) PREFIX ?= mipsel-linux-gnu FORMAT ?= elf32-tradlittlemips else PREFIX ?= mipsel-none-elf FORMAT ?= elf32-littlemips endif CC = $(PREFIX)-gcc-10 CXX = $(PREFIX)-g++-10 LD = $(CXX) AR = ar #architecture flags ARCHFLAGS = -march=mips1 -mabi=32 -EL -fno-pic -mno-shared -mno-abicalls -mfp32 ARCHFLAGS += -fno-stack-protector -nostdlib -ffreestanding #Compiler flags for build profiles CCFLAGS_release += -O3 CCFLAGS_debug += -O0 CXXFLAGS += -fno-exceptions -fno-rtti USE_FUNCTION_SECTIONS ?= true ifeq ($(USE_FUNCTION_SECTIONS),true) CCFLAGS_all += -ffunction-sections endif CCFLAGS_all += -mno-gpopt -fomit-frame-pointer CCFLAGS_all += -fno-builtin -fno-strict-aliasing -Wno-attributes CCFLAGS_all += $(ARCHFLAGS) CCFLAGS_all += $(CCFLAGS_$(BUILD_PROFILE)) #Linker flags LDFLAGS_release += -Os LDFLAGS_all += -Wl,-Map=$(TARGET).map -nostdlib -T$(LDSCRIPT) -static -Wl,--gc-sections -Wl,--build-id=none LDFLAGS_all += $(ARCHFLAGS) -Wl,--oformat=$(FORMAT) LDFLAGS_all += $(LDFLAGS_$(BUILD_PROFILE)) LIBS_all += $(LIBS_$(BUILD_PROFILE)) DEPS = -Wp,-MMD,$(@:%.o=%.d),-MT,$@ #Object files list OBJS = $(addprefix $(OUTPUT_DIR)/,$(addsuffix .o, $(subst ..,!super,$(basename $(SRCS))))) #Compiling rule $(OUTPUT_DIR)/%.o: %.c @mkdir -p $(dir $@) $(CC) -c $(DEPS) -o $@ $(CCFLAGS_all) $(CCFLAGS) $< $(OUTPUT_DIR)/%.o: %.cpp @mkdir -p $(dir $@) $(CXX) -c $(DEPS) -o $@ $(CCFLAGS_all) $(CXXFLAGS) $< .SECONDEXPANSION: $(OUTPUT_DIR)/%.o: $$(subst !super,..,%.s) @mkdir -p $(dir $@) $(CC) $(ARCHFLAGS) -I$(PCSX_REDUX) -g -c -o $@ $< #Linking rule $(TARGET).a: $(OBJS) @mkdir -p $(dir $@) $(AR) rcs $(TARGET).a $(OBJS) $(TARGET).elf: $(OBJS) $(LD) -o $(TARGET).elf $(LDFLAGS_all) $(LDFLAGS) $(OBJS) $(LIBS_all) $(LIBS) #Strips the psexe $(TARGET).psexe: $(TARGET).elf $(PREFIX)-objcopy $(addprefix -R , $(OVERLAYSECTION)) -O binary $< $@ #Rules section for default compilation and linking rebuild: $(MAKE) clean $(MAKE) all #Inclusion of dependencies (object files to source and includes) -include $(OBJS:%.o=%.d)