From 1d2b1362af145b155c1dd9f7a75e59e1bf7307c8 Mon Sep 17 00:00:00 2001 From: Jaby Date: Sun, 24 Apr 2022 16:50:47 +0200 Subject: [PATCH] Attempt failed --- Code/NewMakefile | 61 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/Code/NewMakefile b/Code/NewMakefile index 5ea6bac5..06360fa8 100644 --- a/Code/NewMakefile +++ b/Code/NewMakefile @@ -8,11 +8,24 @@ BUILD_PROFILE ?= debug CONFIG_NAME ?= $(PLATFORM)-$(BUILD_PROFILE) OUTPUT_DIR = build/$(CONFIG_NAME) -TARGET = $(OUTPUT_DIR)/$(ARTIFACT) +TARGET = $(OUTPUT_DIR)/$(ARTIFACT) #Compiler definitions -CC = gcc -CXX = g++ +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 + +ROOTDIR = ../../../GIT/pcsx-redux/src/mips +LDSCRIPT ?= $(ROOTDIR)/ps-exe.ld +LDSCRIPT := $(addprefix $(ROOTDIR)/default.ld , -T$(LDSCRIPT)) + +CC = $(PREFIX)-gcc-10 +CXX = $(PREFIX)-g++-10 LD = $(CXX) #User defined include/preprocessor flags and libraries @@ -31,14 +44,30 @@ LIB_DEPS_PATHES = ../QtXTObj/build/$(CONFIG_NAME)-Qt_Obj CCFLAGS_release += -g -O3 CCFLAGS_debug += -g -O0 -fno-builtin -#Generic compiler flags (which include build type flags) -fcompare-debug-second -# v for now v v -CCFLAGS_all += -DTCP_SERVER -Wall -Wno-unused-variable -Wno-unused-but-set-variable -fmessage-length=0 -std=gnu++2a -Wno-unused-function -fcompare-debug-second -CCFLAGS_all += -march=skylake +CXXFLAGS += -fno-exceptions -fno-rtti + +#Generic compiler flags (which include build type flags) +ARCHFLAGS = -march=mips1 -mabi=32 -EL -fno-pic -mno-shared -mno-abicalls -mfp32 +ARCHFLAGS += -fno-stack-protector -nostdlib -ffreestanding + + +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=$(BINDIR)$(TARGET).map -nostdlib -T$(LDSCRIPT) -static -Wl,--gc-sections +LDFLAGS_all += $(ARCHFLAGS) -Wl,--oformat=$(FORMAT) LDFLAGS_all += $(LDFLAGS_$(BUILD_PROFILE)) + LIBS_all += $(LIBS_$(BUILD_PROFILE)) DEPS = -Wp,-MMD,$(@:%.o=%.d),-MT,$@ @@ -47,10 +76,11 @@ DEPS = -Wp,-MMD,$(@:%.o=%.d),-MT,$@ rwildcard = $(wildcard $(addprefix $1/*.,$2)) $(foreach d,$(wildcard $1/*),$(call rwildcard,$d,$2)) #Source list -SRCS = $(call rwildcard, src, c cpp) +SRCS += $(ROOTDIR)/common/crt0/crt0.s +SRCS += $(call rwildcard, src, c cpp) #Object files list -OBJS = $(addprefix $(OUTPUT_DIR)/,$(addsuffix .o, $(basename $(SRCS)))) +OBJS = $(addprefix $(OUTPUT_DIR)/,$(addsuffix .o, $(subst ..,super,$(basename $(SRCS))))) #Compiling rule $(OUTPUT_DIR)/%.o: %.c @@ -59,11 +89,18 @@ $(OUTPUT_DIR)/%.o: %.c $(OUTPUT_DIR)/%.o: %.cpp @mkdir -p $(dir $@) - $(CXX) -c $(DEPS) -o $@ $(INCLUDES) $(CCFLAGS_all) $(CCFLAGS) $< + $(CXX) -c $(DEPS) -o $@ $(INCLUDES) $(CCFLAGS_all) $(CXXFLAGS) $< + +.SECONDEXPANSION: +$(OUTPUT_DIR)/%.o: $$(subst super,..,%.s) + @mkdir -p $(dir $@) + $(CC) $(ARCHFLAGS) -I$(ROOTDIR) -g -c -o $@ $< + $(info at is $@) + $(info dollar is $<) #Linking rule -$(TARGET):$(OBJS) $(call pairmap,make-lib-dep,$(LIB_DEPS_PATHES),$(LIB_DEPS_NAMES)) - $(LD) -o $(TARGET) $(LDFLAGS_all) $(LDFLAGS) $(OBJS) $(LIBS_all) $(LIBS) +$(TARGET).elf: $(OBJS) + $(LD) -o $(TARGET).elf $(LDFLAGS_all) $(LDFLAGS) $(OBJS) $(LIBS_all) $(LIBS) #Rules section for default compilation and linking all: $(TARGET)