Merge pull request #18 from Hyenadae/master
Strip out N64 ROM building from Makefile (WIP)
This commit is contained in:
commit
e5f21323a2
243
Makefile
243
Makefile
|
@ -16,17 +16,15 @@ GRUCODE ?= f3d_old
|
||||||
# If COMPARE is 1, check the output sha1sum when building 'all'
|
# If COMPARE is 1, check the output sha1sum when building 'all'
|
||||||
COMPARE ?= 1
|
COMPARE ?= 1
|
||||||
# If NON_MATCHING is 1, define the NON_MATCHING and AVOID_UB macros when building (recommended)
|
# If NON_MATCHING is 1, define the NON_MATCHING and AVOID_UB macros when building (recommended)
|
||||||
NON_MATCHING ?= 0
|
NON_MATCHING ?= 1
|
||||||
# Build for the N64 (turn this off for ports)
|
# Sane default until N64 build scripts rm'd
|
||||||
TARGET_N64 ?= 0
|
TARGET_N64 ?= 0
|
||||||
|
|
||||||
# Build and optimize for Raspberry Pi(s)
|
# Build and optimize for Raspberry Pi(s)
|
||||||
TARGET_RPI ?= 0
|
TARGET_RPI ?= 0
|
||||||
# Compiler to use (ido or gcc)
|
# Compiler to use (ido or gcc)
|
||||||
COMPILER ?= ido
|
COMPILER ?= ido
|
||||||
|
|
||||||
ifeq ($(COMPILER),gcc)
|
|
||||||
NON_MATCHING := 1
|
|
||||||
endif
|
|
||||||
# Build for Emscripten/WebGL
|
# Build for Emscripten/WebGL
|
||||||
TARGET_WEB ?= 0
|
TARGET_WEB ?= 0
|
||||||
# Specify the target you are building for, 0 means native
|
# Specify the target you are building for, 0 means native
|
||||||
|
@ -39,18 +37,18 @@ else
|
||||||
BITS :=
|
BITS :=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Automatic settings only for ports
|
# Automatic settings for PC port(s)
|
||||||
ifeq ($(TARGET_N64),0)
|
|
||||||
NON_MATCHING := 1
|
NON_MATCHING := 1
|
||||||
GRUCODE := f3dex2e
|
GRUCODE := f3dex2e
|
||||||
WINDOWS_BUILD := 0
|
WINDOWS_BUILD := 0
|
||||||
|
|
||||||
ifeq ($(TARGET_WEB),0)
|
ifeq ($(TARGET_WEB),0)
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
WINDOWS_BUILD := 1
|
WINDOWS_BUILD := 1
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
|
|
||||||
# Release
|
# Release (version) flag defs
|
||||||
|
|
||||||
ifeq ($(VERSION),jp)
|
ifeq ($(VERSION),jp)
|
||||||
VERSION_CFLAGS := -DVERSION_JP
|
VERSION_CFLAGS := -DVERSION_JP
|
||||||
|
@ -103,7 +101,7 @@ ifeq ($(GRUCODE), f3dex2) # Fast3DEX2
|
||||||
TARGET := $(TARGET).f3dex2
|
TARGET := $(TARGET).f3dex2
|
||||||
COMPARE := 0
|
COMPARE := 0
|
||||||
else
|
else
|
||||||
ifeq ($(GRUCODE), f3dex2e) # Fast3DEX2 Extended (for PC)
|
ifeq ($(GRUCODE), f3dex2e) # Fast3DEX2 Extended (PC default)
|
||||||
GRUCODE_CFLAGS := -DF3DEX_GBI_2E
|
GRUCODE_CFLAGS := -DF3DEX_GBI_2E
|
||||||
TARGET := $(TARGET).f3dex2e
|
TARGET := $(TARGET).f3dex2e
|
||||||
COMPARE := 0
|
COMPARE := 0
|
||||||
|
@ -126,19 +124,15 @@ endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(TARGET_N64),0)
|
# Default build is for PC now
|
||||||
NON_MATCHING := 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(NON_MATCHING),1)
|
|
||||||
VERSION_CFLAGS := $(VERSION_CFLAGS) -DNON_MATCHING -DAVOID_UB
|
VERSION_CFLAGS := $(VERSION_CFLAGS) -DNON_MATCHING -DAVOID_UB
|
||||||
|
|
||||||
ifeq ($(TARGET_RPI),1) # Define RPi to change SDL2 title & GLES2 hints
|
ifeq ($(TARGET_RPI),1) # Define RPi to change SDL2 title & GLES2 hints
|
||||||
# Other platforms will use GLES2 eventually, not only RPis.
|
|
||||||
VERSION_CFLAGS += -DUSE_GLES
|
VERSION_CFLAGS += -DUSE_GLES
|
||||||
endif
|
endif
|
||||||
|
|
||||||
VERSION_ASFLAGS := --defsym AVOID_UB=1
|
VERSION_ASFLAGS := --defsym AVOID_UB=1
|
||||||
COMPARE := 0
|
COMPARE := 0
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_WEB),1)
|
ifeq ($(TARGET_WEB),1)
|
||||||
VERSION_CFLAGS := $(VERSION_CFLAGS) -DTARGET_WEB
|
VERSION_CFLAGS := $(VERSION_CFLAGS) -DTARGET_WEB
|
||||||
|
@ -175,34 +169,30 @@ endif
|
||||||
|
|
||||||
# BUILD_DIR is location where all build artifacts are placed
|
# BUILD_DIR is location where all build artifacts are placed
|
||||||
BUILD_DIR_BASE := build
|
BUILD_DIR_BASE := build
|
||||||
ifeq ($(TARGET_N64),1)
|
|
||||||
BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)
|
|
||||||
else
|
|
||||||
ifeq ($(TARGET_WEB),1)
|
ifeq ($(TARGET_WEB),1)
|
||||||
BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)_web
|
BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)_web
|
||||||
else
|
else
|
||||||
BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)_pc
|
BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)_pc
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
|
|
||||||
LIBULTRA := $(BUILD_DIR)/libultra.a
|
LIBULTRA := $(BUILD_DIR)/libultra.a
|
||||||
|
|
||||||
ifeq ($(TARGET_WEB),1)
|
ifeq ($(TARGET_WEB),1)
|
||||||
EXE := $(BUILD_DIR)/$(TARGET).html
|
EXE := $(BUILD_DIR)/$(TARGET).html
|
||||||
else
|
else
|
||||||
ifeq ($(WINDOWS_BUILD),1)
|
ifeq ($(WINDOWS_BUILD),1)
|
||||||
EXE := $(BUILD_DIR)/$(TARGET).exe
|
EXE := $(BUILD_DIR)/$(TARGET).exe
|
||||||
|
|
||||||
else #Linux builds here
|
else # Linux builds/binary namer
|
||||||
ifeq ($(TARGET_RPI),1)
|
ifeq ($(TARGET_RPI),1)
|
||||||
EXE := $(BUILD_DIR)/$(TARGET).arm
|
EXE := $(BUILD_DIR)/$(TARGET).arm
|
||||||
else
|
else
|
||||||
EXE := $(BUILD_DIR)/$(TARGET)
|
EXE := $(BUILD_DIR)/$(TARGET)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ROM := $(BUILD_DIR)/$(TARGET).z64
|
|
||||||
ELF := $(BUILD_DIR)/$(TARGET).elf
|
ELF := $(BUILD_DIR)/$(TARGET).elf
|
||||||
LD_SCRIPT := sm64.ld
|
LD_SCRIPT := sm64.ld
|
||||||
MIO0_DIR := $(BUILD_DIR)/bin
|
MIO0_DIR := $(BUILD_DIR)/bin
|
||||||
|
@ -212,14 +202,11 @@ ACTOR_DIR := actors
|
||||||
LEVEL_DIRS := $(patsubst levels/%,%,$(dir $(wildcard levels/*/header.h)))
|
LEVEL_DIRS := $(patsubst levels/%,%,$(dir $(wildcard levels/*/header.h)))
|
||||||
|
|
||||||
# Directories containing source files
|
# Directories containing source files
|
||||||
SRC_DIRS := src src/engine src/game src/audio src/menu src/buffers actors levels bin data assets
|
|
||||||
ASM_DIRS := lib
|
# Hi, I'm a PC
|
||||||
ifeq ($(TARGET_N64),1)
|
SRC_DIRS := src src/engine src/game src/audio src/menu src/buffers actors levels bin data assets src/pc src/pc/gfx src/pc/audio src/pc/controller
|
||||||
ASM_DIRS := asm $(ASM_DIRS)
|
|
||||||
else
|
|
||||||
SRC_DIRS := $(SRC_DIRS) src/pc src/pc/gfx src/pc/audio src/pc/controller
|
|
||||||
ASM_DIRS :=
|
ASM_DIRS :=
|
||||||
endif
|
|
||||||
BIN_DIRS := bin bin/$(VERSION)
|
BIN_DIRS := bin bin/$(VERSION)
|
||||||
|
|
||||||
ULTRA_SRC_DIRS := lib/src lib/src/math
|
ULTRA_SRC_DIRS := lib/src lib/src/math
|
||||||
|
@ -245,18 +232,17 @@ else
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(TARGET_N64),0)
|
# Set BITS (32/64) to compile for
|
||||||
OPT_FLAGS += $(BITS)
|
OPT_FLAGS += $(BITS)
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_WEB),1)
|
ifeq ($(TARGET_WEB),1)
|
||||||
OPT_FLAGS := -O2 -g4 --source-map-base http://localhost:8080/
|
OPT_FLAGS := -O2 -g4 --source-map-base http://localhost:8080/
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Use a default opt flag for gcc
|
# Use a default opt flag for gcc, then override if RPi
|
||||||
ifeq ($(COMPILER),gcc)
|
ifeq ($(COMPILER),gcc)
|
||||||
OPT_FLAGS := -O2
|
OPT_FLAGS := -O2 # Breaks sound on x86?
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(TARGET_RPI),1)
|
ifeq ($(TARGET_RPI),1)
|
||||||
|
@ -286,6 +272,7 @@ ifeq ($(TARGET_RPI),1)
|
||||||
else ifneq (,$(findstring 4,$(model)))
|
else ifneq (,$(findstring 4,$(model)))
|
||||||
OPT_FLAGS := -march=armv8-a+crc+simd -mtune=cortex-a72 -O3
|
OPT_FLAGS := -march=armv8-a+crc+simd -mtune=cortex-a72 -O3
|
||||||
endif
|
endif
|
||||||
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -299,9 +286,7 @@ CXX_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
|
||||||
S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s))
|
S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s))
|
||||||
ULTRA_C_FILES := $(foreach dir,$(ULTRA_SRC_DIRS),$(wildcard $(dir)/*.c))
|
ULTRA_C_FILES := $(foreach dir,$(ULTRA_SRC_DIRS),$(wildcard $(dir)/*.c))
|
||||||
GODDARD_C_FILES := $(foreach dir,$(GODDARD_SRC_DIRS),$(wildcard $(dir)/*.c))
|
GODDARD_C_FILES := $(foreach dir,$(GODDARD_SRC_DIRS),$(wildcard $(dir)/*.c))
|
||||||
ifeq ($(TARGET_N64),1)
|
|
||||||
ULTRA_S_FILES := $(foreach dir,$(ULTRA_ASM_DIRS),$(wildcard $(dir)/*.s))
|
|
||||||
endif
|
|
||||||
GENERATED_C_FILES := $(BUILD_DIR)/assets/mario_anim_data.c $(BUILD_DIR)/assets/demo_data.c \
|
GENERATED_C_FILES := $(BUILD_DIR)/assets/mario_anim_data.c $(BUILD_DIR)/assets/demo_data.c \
|
||||||
$(addprefix $(BUILD_DIR)/bin/,$(addsuffix _skybox.c,$(notdir $(basename $(wildcard textures/skyboxes/*.png)))))
|
$(addprefix $(BUILD_DIR)/bin/,$(addsuffix _skybox.c,$(notdir $(basename $(wildcard textures/skyboxes/*.png)))))
|
||||||
|
|
||||||
|
@ -309,7 +294,9 @@ ifeq ($(WINDOWS_BUILD),0)
|
||||||
CXX_FILES :=
|
CXX_FILES :=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(TARGET_N64),1)
|
# We need to keep this for now
|
||||||
|
# If we're not N64 use below
|
||||||
|
|
||||||
ULTRA_C_FILES_SKIP := \
|
ULTRA_C_FILES_SKIP := \
|
||||||
sqrtf.c \
|
sqrtf.c \
|
||||||
string.c \
|
string.c \
|
||||||
|
@ -368,7 +355,8 @@ ifneq ($(TARGET_N64),1)
|
||||||
|
|
||||||
C_FILES := $(filter-out src/game/main.c,$(C_FILES))
|
C_FILES := $(filter-out src/game/main.c,$(C_FILES))
|
||||||
ULTRA_C_FILES := $(filter-out $(addprefix lib/src/,$(ULTRA_C_FILES_SKIP)),$(ULTRA_C_FILES))
|
ULTRA_C_FILES := $(filter-out $(addprefix lib/src/,$(ULTRA_C_FILES_SKIP)),$(ULTRA_C_FILES))
|
||||||
endif
|
|
||||||
|
# "If we're not N64, use the above"
|
||||||
|
|
||||||
ifeq ($(VERSION),sh)
|
ifeq ($(VERSION),sh)
|
||||||
SOUND_BANK_FILES := $(wildcard sound/sound_banks/*.json)
|
SOUND_BANK_FILES := $(wildcard sound/sound_banks/*.json)
|
||||||
|
@ -393,7 +381,6 @@ SOUND_OBJ_FILES := $(SOUND_BIN_DIR)/sound_data.ctl.o \
|
||||||
$(SOUND_BIN_DIR)/sequences.bin.o \
|
$(SOUND_BIN_DIR)/sequences.bin.o \
|
||||||
$(SOUND_BIN_DIR)/bank_sets.o
|
$(SOUND_BIN_DIR)/bank_sets.o
|
||||||
|
|
||||||
|
|
||||||
# Object files
|
# Object files
|
||||||
O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o)) \
|
O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o)) \
|
||||||
$(foreach file,$(CXX_FILES),$(BUILD_DIR)/$(file:.cpp=.o)) \
|
$(foreach file,$(CXX_FILES),$(BUILD_DIR)/$(file:.cpp=.o)) \
|
||||||
|
@ -408,13 +395,6 @@ GODDARD_O_FILES := $(foreach file,$(GODDARD_C_FILES),$(BUILD_DIR)/$(file:.c=.o))
|
||||||
# Automatic dependency files
|
# Automatic dependency files
|
||||||
DEP_FILES := $(O_FILES:.o=.d) $(ULTRA_O_FILES:.o=.d) $(GODDARD_O_FILES:.o=.d) $(BUILD_DIR)/$(LD_SCRIPT).d
|
DEP_FILES := $(O_FILES:.o=.d) $(ULTRA_O_FILES:.o=.d) $(GODDARD_O_FILES:.o=.d) $(BUILD_DIR)/$(LD_SCRIPT).d
|
||||||
|
|
||||||
# Files with GLOBAL_ASM blocks
|
|
||||||
ifneq ($(NON_MATCHING),1)
|
|
||||||
GLOBAL_ASM_C_FILES != grep -rl 'GLOBAL_ASM(' $(wildcard src/**/*.c)
|
|
||||||
GLOBAL_ASM_O_FILES = $(foreach file,$(GLOBAL_ASM_C_FILES),$(BUILD_DIR)/$(file:.c=.o))
|
|
||||||
GLOBAL_ASM_DEP = $(BUILD_DIR)/src/audio/non_matching_dep
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Segment elf files
|
# Segment elf files
|
||||||
SEG_FILES := $(SEGMENT_ELF_FILES) $(ACTOR_ELF_FILES) $(LEVEL_ELF_FILES)
|
SEG_FILES := $(SEGMENT_ELF_FILES) $(ACTOR_ELF_FILES) $(LEVEL_ELF_FILES)
|
||||||
|
|
||||||
|
@ -422,82 +402,23 @@ SEG_FILES := $(SEGMENT_ELF_FILES) $(ACTOR_ELF_FILES) $(LEVEL_ELF_FILES)
|
||||||
INCLUDE_CFLAGS := -I include -I $(BUILD_DIR) -I $(BUILD_DIR)/include -I src -I .
|
INCLUDE_CFLAGS := -I include -I $(BUILD_DIR) -I $(BUILD_DIR)/include -I src -I .
|
||||||
ENDIAN_BITWIDTH := $(BUILD_DIR)/endian-and-bitwidth
|
ENDIAN_BITWIDTH := $(BUILD_DIR)/endian-and-bitwidth
|
||||||
|
|
||||||
ifeq ($(TARGET_N64),1)
|
# Huge deleted N64 section was here
|
||||||
IRIX_ROOT := tools/ido5.3_compiler
|
|
||||||
|
|
||||||
ifeq ($(shell type mips-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
|
||||||
CROSS := mips-linux-gnu-
|
|
||||||
else ifeq ($(shell type mips64-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
|
||||||
CROSS := mips64-linux-gnu-
|
|
||||||
else ifeq ($(shell type mips64-elf-ld >/dev/null 2>/dev/null; echo $$?), 0)
|
|
||||||
CROSS := mips64-elf-
|
|
||||||
endif
|
|
||||||
|
|
||||||
# check that either QEMU_IRIX is set or qemu-irix package installed
|
|
||||||
ifndef QEMU_IRIX
|
|
||||||
QEMU_IRIX := $(shell which qemu-irix)
|
|
||||||
ifeq (, $(QEMU_IRIX))
|
|
||||||
$(error Please install qemu-irix package or set QEMU_IRIX env var to the full qemu-irix binary path)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
AS := $(CROSS)as
|
|
||||||
CC := $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/bin/cc
|
|
||||||
CPP := cpp -P -Wno-trigraphs
|
|
||||||
LD := $(CROSS)ld
|
|
||||||
AR := $(CROSS)ar
|
|
||||||
OBJDUMP := $(CROSS)objdump
|
|
||||||
OBJCOPY := $(CROSS)objcopy
|
|
||||||
PYTHON := python3
|
|
||||||
|
|
||||||
# change the compiler to gcc, to use the default, install the gcc-mips-linux-gnu package
|
|
||||||
ifeq ($(COMPILER),gcc)
|
|
||||||
CC := $(CROSS)gcc
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_N64),1)
|
|
||||||
TARGET_CFLAGS := -nostdinc -I include/libc -DTARGET_N64
|
|
||||||
CC_CFLAGS := -fno-builtin
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Check code syntax with host compiler
|
|
||||||
CC_CHECK := gcc -fsyntax-only -fsigned-char $(CC_CFLAGS) $(TARGET_CFLAGS) $(INCLUDE_CFLAGS) -std=gnu90 -Wall -Wextra -Wno-format-security -Wno-main -DNON_MATCHING -DAVOID_UB $(VERSION_CFLAGS) $(GRUCODE_CFLAGS)
|
|
||||||
|
|
||||||
COMMON_CFLAGS = $(OPT_FLAGS) $(TARGET_CFLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(MIPSISET) $(GRUCODE_CFLAGS)
|
|
||||||
|
|
||||||
ASFLAGS := -march=vr4300 -mabi=32 -I include -I $(BUILD_DIR) $(VERSION_ASFLAGS) $(GRUCODE_ASFLAGS)
|
|
||||||
CFLAGS = -Wab,-r4300_mul -non_shared -G 0 -Xcpluscomm -Xfullwarn -signed $(COMMON_CFLAGS) $(MIPSBIT)
|
|
||||||
OBJCOPYFLAGS := --pad-to=0x800000 --gap-fill=0xFF
|
|
||||||
SYMBOL_LINKING_FLAGS := $(addprefix -R ,$(SEG_FILES))
|
|
||||||
LDFLAGS := -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(SYMBOL_LINKING_FLAGS)
|
|
||||||
ENDIAN_BITWIDTH := $(BUILD_DIR)/endian-and-bitwidth
|
|
||||||
|
|
||||||
ifeq ($(COMPILER),gcc)
|
|
||||||
CFLAGS := -march=vr4300 -mfix4300 -mno-shared -G 0 -mhard-float -fno-stack-protector -fno-common -I include -I src/ -I $(BUILD_DIR)/include -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra $(COMMON_CFLAGS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(shell getconf LONG_BIT), 32)
|
|
||||||
# Work around memory allocation bug in QEMU
|
|
||||||
export QEMU_GUEST_BASE := 1
|
|
||||||
else
|
|
||||||
# Ensure that gcc treats the code as 32-bit
|
|
||||||
CC_CHECK += $(BITS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
else # TARGET_N64
|
|
||||||
|
|
||||||
AS := as
|
AS := as
|
||||||
ifneq ($(TARGET_WEB),1)
|
|
||||||
|
ifneq ($(TARGET_WEB),1) # As in, not-web PC port
|
||||||
CC := $(CROSS)gcc
|
CC := $(CROSS)gcc
|
||||||
CXX := $(CROSS)g++
|
CXX := $(CROSS)g++
|
||||||
else
|
else
|
||||||
CC := emcc
|
CC := emcc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(WINDOWS_BUILD),1)
|
ifeq ($(WINDOWS_BUILD),1)
|
||||||
LD := $(CXX)
|
LD := $(CXX)
|
||||||
else
|
else
|
||||||
LD := $(CC)
|
LD := $(CC)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CPP := cpp -P
|
CPP := cpp -P
|
||||||
OBJDUMP := objdump
|
OBJDUMP := objdump
|
||||||
OBJCOPY := objcopy
|
OBJCOPY := objcopy
|
||||||
|
@ -506,9 +427,11 @@ PYTHON := python3
|
||||||
ifeq ($(WINDOWS_BUILD),1)
|
ifeq ($(WINDOWS_BUILD),1)
|
||||||
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(CROSS)sdl2-config --cflags`
|
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(CROSS)sdl2-config --cflags`
|
||||||
CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(CROSS)sdl2-config --cflags`
|
CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(CROSS)sdl2-config --cflags`
|
||||||
|
|
||||||
else ifeq ($(TARGET_WEB),1)
|
else ifeq ($(TARGET_WEB),1)
|
||||||
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -s USE_SDL=2
|
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -s USE_SDL=2
|
||||||
CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv -s USE_SDL=2
|
CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv -s USE_SDL=2
|
||||||
|
|
||||||
# Linux / Other builds below
|
# Linux / Other builds below
|
||||||
else
|
else
|
||||||
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(CROSS)sdl2-config --cflags`
|
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(CROSS)sdl2-config --cflags`
|
||||||
|
@ -520,9 +443,11 @@ ASFLAGS := -I include -I $(BUILD_DIR) $(VERSION_ASFLAGS)
|
||||||
ifeq ($(TARGET_WEB),1)
|
ifeq ($(TARGET_WEB),1)
|
||||||
LDFLAGS := -lm -lGL -lSDL2 -no-pie -s TOTAL_MEMORY=20MB -g4 --source-map-base http://localhost:8080/ -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain']"
|
LDFLAGS := -lm -lGL -lSDL2 -no-pie -s TOTAL_MEMORY=20MB -g4 --source-map-base http://localhost:8080/ -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain']"
|
||||||
else
|
else
|
||||||
|
|
||||||
ifeq ($(WINDOWS_BUILD),1)
|
ifeq ($(WINDOWS_BUILD),1)
|
||||||
LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(CROSS)sdl2-config --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -no-pie -static
|
LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(CROSS)sdl2-config --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -no-pie -static
|
||||||
else
|
else
|
||||||
|
|
||||||
# Linux / Other builds below
|
# Linux / Other builds below
|
||||||
ifeq ($(TARGET_RPI),1)
|
ifeq ($(TARGET_RPI),1)
|
||||||
LDFLAGS := $(OPT_FLAGS) -lm -lGLESv2 `$(CROSS)sdl2-config --libs` -no-pie
|
LDFLAGS := $(OPT_FLAGS) -lm -lGLESv2 `$(CROSS)sdl2-config --libs` -no-pie
|
||||||
|
@ -532,14 +457,13 @@ endif
|
||||||
endif
|
endif
|
||||||
endif #Added for Pi ifeq
|
endif #Added for Pi ifeq
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Prevent a crash with -sopt
|
# Prevent a crash with -sopt
|
||||||
export LANG := C
|
export LANG := C
|
||||||
|
|
||||||
####################### Other Tools #########################
|
####################### Other Tools #########################
|
||||||
|
|
||||||
# N64 tools
|
# N64 conversion tools
|
||||||
TOOLS_DIR = tools
|
TOOLS_DIR = tools
|
||||||
MIO0TOOL = $(TOOLS_DIR)/mio0
|
MIO0TOOL = $(TOOLS_DIR)/mio0
|
||||||
N64CKSUM = $(TOOLS_DIR)/n64cksum
|
N64CKSUM = $(TOOLS_DIR)/n64cksum
|
||||||
|
@ -557,32 +481,13 @@ LOADER = loader64
|
||||||
LOADER_FLAGS = -vwf
|
LOADER_FLAGS = -vwf
|
||||||
SHA1SUM = sha1sum
|
SHA1SUM = sha1sum
|
||||||
|
|
||||||
# Use Objcopy instead of extract_data_for_mio
|
|
||||||
ifeq ($(COMPILER),gcc)
|
|
||||||
EXTRACT_DATA_FOR_MIO := $(OBJCOPY) -O binary --only-section=.data
|
|
||||||
endif
|
|
||||||
|
|
||||||
###################### Dependency Check #####################
|
###################### Dependency Check #####################
|
||||||
|
|
||||||
ifeq ($(TARGET_N64),1)
|
# Stubbed
|
||||||
BINUTILS_VER_MAJOR := $(shell $(LD) --version | grep ^GNU | sed 's/^.* //; s/\..*//g')
|
|
||||||
BINUTILS_VER_MINOR := $(shell $(LD) --version | grep ^GNU | sed 's/^[^.]*\.//; s/\..*//g')
|
|
||||||
BINUTILS_DEPEND := $(shell expr $(BINUTILS_VER_MAJOR) \>= 2 \& $(BINUTILS_VER_MINOR) \>= 27)
|
|
||||||
ifeq ($(BINUTILS_DEPEND),0)
|
|
||||||
$(error binutils version 2.27 required, version $(BINUTILS_VER_MAJOR).$(BINUTILS_VER_MINOR) detected)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
######################## Targets #############################
|
######################## Targets #############################
|
||||||
|
|
||||||
ifeq ($(TARGET_N64),1)
|
|
||||||
all: $(ROM)
|
|
||||||
ifeq ($(COMPARE),1)
|
|
||||||
@$(SHA1SUM) -c $(TARGET).sha1 || (echo 'The build succeeded, but did not match the official ROM. This is expected if you are making changes to the game.\nTo silence this message, use "make COMPARE=0"'. && false)
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
all: $(EXE)
|
all: $(EXE)
|
||||||
endif
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) -r $(BUILD_DIR_BASE)
|
$(RM) -r $(BUILD_DIR_BASE)
|
||||||
|
@ -613,10 +518,6 @@ $(BUILD_DIR)/include/text_strings.h: include/text_strings.h.in
|
||||||
$(BUILD_DIR)/include/text_menu_strings.h: include/text_menu_strings.h.in
|
$(BUILD_DIR)/include/text_menu_strings.h: include/text_menu_strings.h.in
|
||||||
$(TEXTCONV) charmap_menu.txt $< $@
|
$(TEXTCONV) charmap_menu.txt $< $@
|
||||||
|
|
||||||
ifeq ($(COMPILER),gcc)
|
|
||||||
$(BUILD_DIR)/lib/src/math/%.o: CFLAGS += -fno-builtin
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(VERSION),eu)
|
ifeq ($(VERSION),eu)
|
||||||
TEXT_DIRS := text/de text/us text/fr
|
TEXT_DIRS := text/de text/us text/fr
|
||||||
|
|
||||||
|
@ -642,7 +543,6 @@ $(BUILD_DIR)/bin/segment2.o: $(BUILD_DIR)/text/$(VERSION)/define_text.inc.c
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
$(BUILD_DIR)/text/%/define_courses.inc.c: text/define_courses.inc.c text/%/courses.h
|
$(BUILD_DIR)/text/%/define_courses.inc.c: text/define_courses.inc.c text/%/courses.h
|
||||||
$(CPP) $(VERSION_CFLAGS) $< -o $@ -I text/$*/
|
$(CPP) $(VERSION_CFLAGS) $< -o $@ -I text/$*/
|
||||||
$(TEXTCONV) charmap.txt $@ $@
|
$(TEXTCONV) charmap.txt $@ $@
|
||||||
|
@ -657,6 +557,7 @@ ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS) $(GOD
|
||||||
DUMMY != mkdir -p $(ALL_DIRS)
|
DUMMY != mkdir -p $(ALL_DIRS)
|
||||||
|
|
||||||
$(BUILD_DIR)/include/text_strings.h: $(BUILD_DIR)/include/text_menu_strings.h
|
$(BUILD_DIR)/include/text_strings.h: $(BUILD_DIR)/include/text_menu_strings.h
|
||||||
|
|
||||||
ifeq ($(VERSION),eu)
|
ifeq ($(VERSION),eu)
|
||||||
$(BUILD_DIR)/src/menu/file_select.o: $(BUILD_DIR)/include/text_strings.h $(BUILD_DIR)/bin/eu/translation_en.o $(BUILD_DIR)/bin/eu/translation_de.o $(BUILD_DIR)/bin/eu/translation_fr.o
|
$(BUILD_DIR)/src/menu/file_select.o: $(BUILD_DIR)/include/text_strings.h $(BUILD_DIR)/bin/eu/translation_en.o $(BUILD_DIR)/bin/eu/translation_de.o $(BUILD_DIR)/bin/eu/translation_fr.o
|
||||||
$(BUILD_DIR)/src/menu/star_select.o: $(BUILD_DIR)/include/text_strings.h $(BUILD_DIR)/bin/eu/translation_en.o $(BUILD_DIR)/bin/eu/translation_de.o $(BUILD_DIR)/bin/eu/translation_fr.o
|
$(BUILD_DIR)/src/menu/star_select.o: $(BUILD_DIR)/include/text_strings.h $(BUILD_DIR)/bin/eu/translation_en.o $(BUILD_DIR)/bin/eu/translation_de.o $(BUILD_DIR)/bin/eu/translation_fr.o
|
||||||
|
@ -692,38 +593,7 @@ $(BUILD_DIR)/%.ci4: %.ci4.png
|
||||||
|
|
||||||
# compressed segment generation
|
# compressed segment generation
|
||||||
|
|
||||||
ifeq ($(TARGET_N64),1)
|
# PC Area
|
||||||
# TODO: ideally this would be `-Trodata-segment=0x07000000` but that doesn't set the address
|
|
||||||
|
|
||||||
$(BUILD_DIR)/bin/%.elf: $(BUILD_DIR)/bin/%.o
|
|
||||||
$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map -o $@ $<
|
|
||||||
$(BUILD_DIR)/actors/%.elf: $(BUILD_DIR)/actors/%.o
|
|
||||||
$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map -o $@ $<
|
|
||||||
|
|
||||||
# Override for level.elf, which otherwise matches the above pattern
|
|
||||||
.SECONDEXPANSION:
|
|
||||||
$(BUILD_DIR)/levels/%/leveldata.elf: $(BUILD_DIR)/levels/%/leveldata.o $(BUILD_DIR)/bin/$$(TEXTURE_BIN).elf
|
|
||||||
$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map --just-symbols=$(BUILD_DIR)/bin/$(TEXTURE_BIN).elf -o $@ $<
|
|
||||||
|
|
||||||
$(BUILD_DIR)/bin/%.bin: $(BUILD_DIR)/bin/%.elf
|
|
||||||
$(EXTRACT_DATA_FOR_MIO) $< $@
|
|
||||||
|
|
||||||
$(BUILD_DIR)/actors/%.bin: $(BUILD_DIR)/actors/%.elf
|
|
||||||
$(EXTRACT_DATA_FOR_MIO) $< $@
|
|
||||||
|
|
||||||
$(BUILD_DIR)/levels/%/leveldata.bin: $(BUILD_DIR)/levels/%/leveldata.elf
|
|
||||||
$(EXTRACT_DATA_FOR_MIO) $< $@
|
|
||||||
|
|
||||||
$(BUILD_DIR)/%.mio0: $(BUILD_DIR)/%.bin
|
|
||||||
$(MIO0TOOL) $< $@
|
|
||||||
|
|
||||||
$(BUILD_DIR)/%.mio0.o: $(BUILD_DIR)/%.mio0.s
|
|
||||||
$(AS) $(ASFLAGS) -o $@ $<
|
|
||||||
|
|
||||||
$(BUILD_DIR)/%.mio0.s: $(BUILD_DIR)/%.mio0
|
|
||||||
printf ".section .data\n\n.incbin \"$<\"\n" > $@
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(BUILD_DIR)/%.table: %.aiff
|
$(BUILD_DIR)/%.table: %.aiff
|
||||||
$(AIFF_EXTRACT_CODEBOOK) $< >$@
|
$(AIFF_EXTRACT_CODEBOOK) $< >$@
|
||||||
|
|
||||||
|
@ -760,10 +630,7 @@ $(SOUND_BIN_DIR)/%.m64: $(SOUND_BIN_DIR)/%.o
|
||||||
$(SOUND_BIN_DIR)/%.o: $(SOUND_BIN_DIR)/%.s
|
$(SOUND_BIN_DIR)/%.o: $(SOUND_BIN_DIR)/%.s
|
||||||
$(AS) $(ASFLAGS) -o $@ $<
|
$(AS) $(ASFLAGS) -o $@ $<
|
||||||
|
|
||||||
ifeq ($(TARGET_N64),1)
|
|
||||||
$(SOUND_BIN_DIR)/%.s: $(SOUND_BIN_DIR)/%
|
|
||||||
printf ".section .data\n\n.incbin \"$<\"\n" > $@
|
|
||||||
else
|
|
||||||
$(SOUND_BIN_DIR)/sound_data.ctl.c: $(SOUND_BIN_DIR)/sound_data.ctl
|
$(SOUND_BIN_DIR)/sound_data.ctl.c: $(SOUND_BIN_DIR)/sound_data.ctl
|
||||||
echo "unsigned char gSoundDataADSR[] = {" > $@
|
echo "unsigned char gSoundDataADSR[] = {" > $@
|
||||||
hexdump -v -e '1/1 "0x%X,"' $< >> $@
|
hexdump -v -e '1/1 "0x%X,"' $< >> $@
|
||||||
|
@ -783,7 +650,6 @@ $(SOUND_BIN_DIR)/bank_sets.c: $(SOUND_BIN_DIR)/bank_sets
|
||||||
echo "unsigned char gBankSetsData[] = {" > $@
|
echo "unsigned char gBankSetsData[] = {" > $@
|
||||||
hexdump -v -e '1/1 "0x%X,"' $< >> $@
|
hexdump -v -e '1/1 "0x%X,"' $< >> $@
|
||||||
echo "};" >> $@
|
echo "};" >> $@
|
||||||
endif
|
|
||||||
|
|
||||||
$(BUILD_DIR)/levels/scripts.o: $(BUILD_DIR)/include/level_headers.h
|
$(BUILD_DIR)/levels/scripts.o: $(BUILD_DIR)/include/level_headers.h
|
||||||
|
|
||||||
|
@ -840,9 +706,6 @@ $(BUILD_DIR)/src/audio/%.copt: $(BUILD_DIR)/src/audio/%.acpp
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(NON_MATCHING),0)
|
|
||||||
$(GLOBAL_ASM_O_FILES): CC := $(PYTHON) tools/asm_processor/build.py $(CC) -- $(AS) $(ASFLAGS) --
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Rebuild files with 'GLOBAL_ASM' if the NON_MATCHING flag changes.
|
# Rebuild files with 'GLOBAL_ASM' if the NON_MATCHING flag changes.
|
||||||
$(GLOBAL_ASM_O_FILES): $(GLOBAL_ASM_DEP).$(NON_MATCHING)
|
$(GLOBAL_ASM_O_FILES): $(GLOBAL_ASM_DEP).$(NON_MATCHING)
|
||||||
|
@ -866,32 +729,10 @@ $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c
|
||||||
$(BUILD_DIR)/%.o: %.s
|
$(BUILD_DIR)/%.o: %.s
|
||||||
$(AS) $(ASFLAGS) -MD $(BUILD_DIR)/$*.d -o $@ $<
|
$(AS) $(ASFLAGS) -MD $(BUILD_DIR)/$*.d -o $@ $<
|
||||||
|
|
||||||
ifeq ($(TARGET_N64),1)
|
|
||||||
$(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT)
|
|
||||||
$(CPP) $(VERSION_CFLAGS) -MMD -MP -MT $@ -MF $@.d -I include/ -I . -DBUILD_DIR=$(BUILD_DIR) -o $@ $<
|
|
||||||
|
|
||||||
$(BUILD_DIR)/libultra.a: $(ULTRA_O_FILES)
|
|
||||||
$(AR) rcs -o $@ $(ULTRA_O_FILES)
|
|
||||||
tools/patch_libultra_math $@
|
|
||||||
|
|
||||||
$(BUILD_DIR)/libgoddard.a: $(GODDARD_O_FILES)
|
|
||||||
$(AR) rcs -o $@ $(GODDARD_O_FILES)
|
|
||||||
|
|
||||||
$(ELF): $(O_FILES) $(MIO0_OBJ_FILES) $(SOUND_OBJ_FILES) $(SEG_FILES) $(BUILD_DIR)/$(LD_SCRIPT) undefined_syms.txt $(BUILD_DIR)/libultra.a $(BUILD_DIR)/libgoddard.a
|
|
||||||
$(LD) -L $(BUILD_DIR) $(LDFLAGS) -o $@ $(O_FILES)$(LIBS) -lultra -lgoddard
|
|
||||||
|
|
||||||
$(ROM): $(ELF)
|
|
||||||
$(OBJCOPY) $(OBJCOPYFLAGS) $< $(@:.z64=.bin) -O binary
|
|
||||||
$(N64CKSUM) $(@:.z64=.bin) $@
|
|
||||||
|
|
||||||
$(BUILD_DIR)/$(TARGET).objdump: $(ELF)
|
|
||||||
$(OBJDUMP) -D $< > $@
|
|
||||||
|
|
||||||
else
|
|
||||||
$(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES)
|
$(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES)
|
||||||
$(LD) -L $(BUILD_DIR) -o $@ $(O_FILES) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS)
|
$(LD) -L $(BUILD_DIR) -o $@ $(O_FILES) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS)
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: all clean distclean default diff test load libultra
|
.PHONY: all clean distclean default diff test load libultra
|
||||||
.PRECIOUS: $(BUILD_DIR)/bin/%.elf $(SOUND_BIN_DIR)/%.ctl $(SOUND_BIN_DIR)/%.tbl $(SOUND_SAMPLE_TABLES) $(SOUND_BIN_DIR)/%.s $(BUILD_DIR)/%
|
.PRECIOUS: $(BUILD_DIR)/bin/%.elf $(SOUND_BIN_DIR)/%.ctl $(SOUND_BIN_DIR)/%.tbl $(SOUND_SAMPLE_TABLES) $(SOUND_BIN_DIR)/%.s $(BUILD_DIR)/%
|
||||||
|
|
Loading…
Reference in New Issue
Block a user