Redo more console makefiles

This commit is contained in:
UnknownShadow200 2025-06-29 12:11:17 +10:00
parent ffb3964b10
commit 62ef0198c5
19 changed files with 372 additions and 479 deletions

View File

@ -1,136 +1,115 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# configurable options
#---------------------------------------------------------------------------------
APP_ICON := $(TOPDIR)/misc/3ds/icon.png
APP_TITLE := ClassiCube
APP_DESCRIPTION := Simple block building sandbox
APP_AUTHOR := ClassiCube team
TARGET := ClassiCube-3ds
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing header files
#---------------------------------------------------------------------------------
BUILD := build-3ds
SOURCES := src misc/3ds third_party/bearssl/src
INCLUDES := third_party/bearssl/inc
CIA_BANNER_BIN := $(TOPDIR)/misc/3ds/banner.bin
CIA_ICON_BIN := $(TOPDIR)/misc/3ds/icon.bin
CIA_SPEC_RSF := $(TOPDIR)/misc/3ds/spec.rsf
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -D__3DS__
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lctru -lm
include $(DEVKITPRO)/devkitARM/base_tools
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
# Configurable options
#---------------------------------------------------------------------------------
# Name of the final output
TARGET = ClassiCube-3ds
# List of directories containing source code
SOURCE_DIRS = src src/3ds third_party/bearssl/src
# List of directories containing shader files
SHDR_DIRS = misc/3ds
# List of directories containing more header files
INCLUDES = -Ithird_party/bearssl/inc
# Directory where object files are placed
BUILD_DIR = build/3ds
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
APP_ICON = misc/3ds/icon.png
APP_TITLE = ClassiCube
APP_DESCRIPTION = Simple block building sandbox
APP_AUTHOR = ClassiCube team
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
CIA_BANNER_BIN = misc/3ds/banner.bin
CIA_ICON_BIN = misc/3ds/icon.bin
CIA_SPEC_RSF = misc/3ds/spec.rsf
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
export LD := $(CC)
export OFILES_SOURCES := $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES_BIN := $(PICAFILES:.v.pica=.shbin.o)
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(CTRULIB),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(CTRULIB),-L$(dir)/lib)
export _3DSXFLAGS = --smdh=$(CURDIR)/$(TARGET).smdh
.PHONY: all clean
#---------------------------------------------------------------------------------
all: $(BUILD)
$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/misc/3ds/Makefile
# Code generation
#---------------------------------------------------------------------------------
S_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S))
C_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o)))
PICAFILES := $(foreach dir,$(SHDR_DIRS),$(notdir $(wildcard $(dir)/*.v.pica)))
OBJS += $(addprefix $(BUILD_DIR)/, $(PICAFILES:.v.pica=.shbin.o))
ARCH = -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS = -g -Wall -O2 -mword-relocations -ffunction-sections $(ARCH) $(INCLUDE) -D__3DS__
ASFLAGS = -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH)
LIBS = -lctru -lm
CTRULIB = $(DEVKITPRO)/libctru
INCLUDES += $(foreach dir, $(CTRULIB), -I$(dir)/include)
LDFLAGS += $(foreach dir, $(CTRULIB), -L$(dir)/lib)
# Dependency tracking
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d
DEPFILES := $(OBJS:%.o=%.d)
$(BUILD):
mkdir -p $@
#---------------------------------------------------------------------------------
# Main targets
#---------------------------------------------------------------------------------
default: $(BUILD_DIR) $(TARGET).cia
clean:
echo clean ...
rm -fr $(BUILD) $(TARGET).cia $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
rm $(TARGET).cia $(TARGET).3dsx $(TARGET).elf $(OBJS)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
#---------------------------------------------------------------------------------
else
# Executable generation
#---------------------------------------------------------------------------------
$(TARGET).elf: $(OBJS)
$(CC) $(LDFLAGS) $^ -o $@ $(LIBS)
$(BUILD_DIR).smdh: $(APP_ICON)
smdhtool --create "$(APP_TITLE)" "$(APP_DESCRIPTION)" "$(APP_AUTHOR)" $(APP_ICON) $@
$(TARGET).3dsx: $(TARGET).elf $(BUILD_DIR).smdh
3dsxtool $< $@ --smdh=$(BUILD_DIR).smdh
$(BUILD_DIR)/makerom:
wget https://github.com/3DSGuy/Project_CTR/releases/download/makerom-v0.18.3/makerom-v0.18.3-ubuntu_x86_64.zip -O $(BUILD_DIR)/makerom.zip
unzip $(BUILD_DIR)/makerom.zip -d $(BUILD_DIR)
chmod +x $(BUILD_DIR)/makerom
$(TARGET).cia : $(TARGET).3dsx $(BUILD_DIR)/makerom
$(BUILD_DIR)/makerom -f cia -o $(TARGET).cia -elf $(TARGET).elf -rsf $(CIA_SPEC_RSF) -icon $(CIA_ICON_BIN) -banner $(CIA_BANNER_BIN) -exefslogo -target t
#---------------------------------------------------------------------------------
# main targets
# Object generation
#---------------------------------------------------------------------------------
$(OUTPUT).cia : $(OUTPUT).3dsx makerom
./makerom -f cia -o "$(OUTPUT).cia" -elf "$(OUTPUT).elf" -rsf "$(CIA_SPEC_RSF)" -icon "$(CIA_ICON_BIN)" -banner "$(CIA_BANNER_BIN)" -exefslogo -target t
makerom:
wget https://github.com/3DSGuy/Project_CTR/releases/download/makerom-v0.18.3/makerom-v0.18.3-ubuntu_x86_64.zip
unzip makerom-v0.18.3-ubuntu_x86_64.zip
chmod +x makerom
$(BUILD_DIR)/%.o: src/%.c
$(CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@
$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
$(BUILD_DIR)/%.o: src/3ds/%.c
$(CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o: third_party/bearssl/src/%.c
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(BUILD_DIR)/%.shbin: misc/3ds/%.v.pica
picasso $< -o $@
$(BUILD_DIR)/%.shbin.o: $(BUILD_DIR)/%.shbin
bin2s $< | $(AS) -o $@
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
.PRECIOUS : %.shbin
# Dependency tracking
#---------------------------------------------------------------------------------
$(DEPFILES):
%.shbin.o : %.v.pica
$(eval CUR_SRC := $<)
$(eval CUR_FILE := $(notdir $(CUR_SRC)))
$(eval CUR_BIN := $(CURDIR)/$(subst .v.pica,.shbin,$(CUR_FILE)))
picasso -o $(CUR_BIN) $(CUR_SRC)
bin2s $(CUR_BIN) | $(AS) -o $(CUR_BIN).o
-include $(DEPSDIR)/*.d
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
include $(wildcard $(DEPFILES))

View File

@ -1,130 +1,88 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
endif
include $(DEVKITARM)/gba_rules
#---------------------------------------------------------------------------------
# the LIBGBA path is defined in gba_rules, but we have to define LIBTONC ourselves
#---------------------------------------------------------------------------------
LIBTONC := $(DEVKITPRO)/libtonc
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#
# All directories are specified relative to the project directory where
# the makefile is found
#
#---------------------------------------------------------------------------------
TARGET := ClassiCube-gba
BUILD := build-gba
SOURCES := src
INCLUDES := include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -mthumb -mthumb-interwork
CFLAGS := -g -Wall -O2 -DPLAT_GBA -ffunction-sections -fdata-sections\
-mcpu=arm7tdmi -mtune=arm7tdmi\
$(ARCH)
CFLAGS += $(INCLUDE)
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
ASFLAGS := -g $(ARCH)
LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map)
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lmm -ltonc
include $(DEVKITPRO)/devkitARM/gba_rules
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib.
# the LIBGBA path should remain in this list if you want to use maxmod
# Configurable options
#---------------------------------------------------------------------------------
LIBDIRS := $(LIBGBA) $(LIBTONC)
# Name of the final output
TARGET = ClassiCube-gba
# List of directories containing source code
SOURCE_DIRS = src src/gba
# Directory where object files are placed
BUILD_DIR = build/gba
GAME_TITLE = ClassiCube
GAME_CODE = 0000
MAKER_CODE = 00
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
# Code generation
#---------------------------------------------------------------------------------
S_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S))
C_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o)))
ARCH = -mthumb -mthumb-interwork
CFLAGS = -g -Wall -O2 -DPLAT_GBA -ffunction-sections -fdata-sections -mcpu=arm7tdmi -mtune=arm7tdmi $(ARCH)
ASFLAGS = -g $(ARCH)
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
LDFLAGS = -specs=gba.specs -g $(ARCH)
LIBS = -lmm -ltonc
export OUTPUT := $(CURDIR)/$(TARGET)
LIBGBA := $(DEVKITPRO)/libgba
INCLUDES += $(foreach dir, $(LIBGBA), -I$(dir)/include)
LDFLAGS += $(foreach dir, $(LIBGBA), -L$(dir)/lib)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
LIBTONC = $(DEVKITPRO)/libtonc
INCLUDES += $(foreach dir, $(LIBTONC), -I$(dir)/include)
LDFLAGS += $(foreach dir, $(LIBTONC), -L$(dir)/lib)
export DEPSDIR := $(CURDIR)/$(BUILD)
# Dependency tracking
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d
DEPFILES := $(OBJS:%.o=%.d)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
export LD := $(CC)
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) $(PNGFILES:.png=.h)
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
.PHONY: $(BUILD) clean
all: $(BUILD)
$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/misc/gba/Makefile
#---------------------------------------------------------------------------------
$(BUILD):
mkdir -p $@
# Main targets
#---------------------------------------------------------------------------------
default: $(BUILD_DIR) $(TARGET).gba
clean:
echo clean ...
rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba
rm $(TARGET).gba $(TARGET).elf $(OBJS)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
#---------------------------------------------------------------------------------
else
# Executable generation
#---------------------------------------------------------------------------------
$(TARGET).elf: $(OBJS)
$(CC) $(LDFLAGS) $^ -o $@ $(LIBS)
$(TARGET).gba: $(TARGET).elf
$(OBJCOPY) -O binary $< $@
gbafix $@ -t$(GAME_TITLE) -c$(GAME_CODE) -m$(MAKER_CODE)
#---------------------------------------------------------------------------------
# main targets
# Object generation
#---------------------------------------------------------------------------------
$(BUILD_DIR)/%.o: src/%.c
$(CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@
$(OUTPUT).gba : $(OUTPUT).elf
$(BUILD_DIR)/%.o: src/gba/%.c
$(CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@
$(OUTPUT).elf : $(OFILES)
$(OFILES_SOURCES) : $(HFILES)
#---------------------------------------------------------------------------------
# Dependency tracking
#---------------------------------------------------------------------------------
$(DEPFILES):
# make likes to delete intermediate files. This prevents it from deleting the
# files generated by grit after building the GBA ROM.
.SECONDARY:
-include $(DEPSDIR)/*.d
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
include $(wildcard $(DEPFILES))

View File

@ -1,23 +1,21 @@
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
endif
include $(DEVKITPPC)/gamecube_rules
include $(DEVKITPRO)/devkitPPC/base_tools
#---------------------------------------------------------------------------------
# Configurable options
#---------------------------------------------------------------------------------
# Directory where object files are placed
BUILD_DIR := build/gc
# List of directories containing source code
SOURCE_DIRS := src src/gcwii third_party/bearssl/src
# Name of the final output
TARGET := ClassiCube-gc
# Additional libraries to link against
LIBS = -lasnd -lbba -lfat -logc -lm
TARGET = ClassiCube-gc
# List of directories containing source code
SOURCE_DIRS = src src/gcwii third_party/bearssl/src
# List of directories containing more header files
INCLUDES = -Ithird_party/bearssl/inc
# Directory where object files are placed
BUILD_DIR = build/gc
#---------------------------------------------------------------------------------
@ -26,8 +24,13 @@ INCLUDES = -Ithird_party/bearssl/inc
S_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S))
C_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o)))
CFLAGS = -g -O2 -Wall $(MACHDEP) -I$(LIBOGC_INC)
LDFLAGS = -g $(MACHDEP) -L$(LIBOGC_LIB)
MACHDEP = -DGEKKO -mogc -mcpu=750 -meabi -mhard-float
CFLAGS = -g -O2 -Wall $(MACHDEP) -I$(DEVKITPRO)/libogc/include
LDFLAGS = -g $(MACHDEP) -L$(DEVKITPRO)/libogc/lib/cube
# Additional libraries to link against
LIBS = -lasnd -lbba -lfat -logc -lm
# Dependency tracking
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d

View File

@ -8,9 +8,12 @@ endif
#---------------------------------------------------------------------------------
# Configurable options
#---------------------------------------------------------------------------------
BUILD_DIR := build/ps1
SOURCE_DIRS := src src/ps1
# Name of the final output
TARGET := ClassiCube-ps1
# List of directories containing source code
SOURCE_DIRS := src src/ps1
# Directory where object files are placed
BUILD_DIR := build/ps1
#---------------------------------------------------------------------------------
@ -28,12 +31,13 @@ CFLAGS := -DPLAT_PS1 -DPSN00BSDK=1 -g -Wa,--strip-local-absolute -ffreestanding
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d
DEPFILES := $(OBJS:%.o=%.d)
# Additional libraries to link against
# libpsxgpu -> $(PSN00BSDK_ROOT)/lib/libpsn00b/debug/libpsxgpu_exe_gprel.a
PS1LIBS := libpsxgpu libpsxgte libpsxspu libpsxcd libpsxpress libpsxsio libpsxetc libpsxapi libsmd liblzp libc
PS1LIBS := $(addprefix $(PSN00BSDK_ROOT)/lib/libpsn00b/debug/, $(PS1LIBS))
PS1LIBS := $(addsuffix _exe_gprel.a, $(PS1LIBS))
LDFLAGS = -g -T$(PSN00BSDK_ROOT)/lib/libpsn00b/ldscripts/exe.ld -nostdlib -Wl,-gc-sections -G8 -static
LDFLAGS = -g -T$(PSN00BSDK_ROOT)/lib/libpsn00b/ldscripts/exe.ld -nostdlib -Wl,-gc-sections -G8 -static \
LIBS = -lgcc $(PS1LIBS)
#---------------------------------------------------------------------------------

View File

@ -1,140 +1,96 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/libnx/switch_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing header files
#
# NO_ICON: if set to anything, do not use icon.
# NO_NACP: if set to anything, no .nacp file is generated.
# APP_TITLE is the name of the app stored in the .nacp file (Optional)
# APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
# APP_VERSION is the version of the app stored in the .nacp file (Optional)
# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
# ICON is the filename of the icon (.jpg), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.jpg
# - icon.jpg
# - <libnx folder>/default_icon.jpg
#
#---------------------------------------------------------------------------------
TARGET := ClassiCube-switch
BUILD := build-switch
SOURCES := src misc/switch third_party/bearssl/src
INCLUDES := third_party/bearssl/inc
APP_TITLE := ClassiCube
APP_AUTHOR := ClassiCube team
APP_ICON := $(TOPDIR)/misc/switch/icon.jpg
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
CFLAGS := -g -Wall -O2 -ffunction-sections \
$(ARCH) $(DEFINES)
CFLAGS += $(INCLUDE) -D__SWITCH__
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lGLESv2 -lEGL -lglapi -ldrm_nouveau -lnx -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(LIBNX)
include $(DEVKITPRO)/devkitA64/base_tools
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
# Configurable options
#---------------------------------------------------------------------------------
# Name of the final output
TARGET = ClassiCube-switch
# List of directories containing source code
SOURCE_DIRS = src src/switch third_party/bearssl/src
# List of directories containing more header files
INCLUDES = -Ithird_party/bearssl/inc
# Directory where object files are placed
BUILD_DIR = build/switch
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
APP_TITLE = ClassiCube
APP_AUTHOR = ClassiCube team
APP_ICON = misc/switch/icon.jpg
APP_VERSION = 1.3.7
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
export LD := $(CXX)
export OFILES := $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
export NROFLAGS += --icon=$(APP_ICON)
ifeq ($(strip $(NO_NACP)),)
export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
endif
ifneq ($(APP_TITLEID),)
export NACPFLAGS += --titleid=$(APP_TITLEID)
endif
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
# Code generation
#---------------------------------------------------------------------------------
S_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S))
C_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o)))
ARCH = -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
CFLAGS = -g -Wall -O2 -ffunction-sections $(ARCH) -D__SWITCH__
ASFLAGS = -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH)
LIBS = -lGLESv2 -lEGL -lglapi -ldrm_nouveau -lnx -lm
LIBNX = $(DEVKITPRO)/libnx
INCLUDES += $(foreach dir, $(LIBNX), -I$(dir)/include)
LDFLAGS += $(foreach dir, $(LIBNX), -L$(dir)/lib)
PORTLIBS = $(PORTLIBS_PATH)/switch
INCLUDES += $(foreach dir, $(PORTLIBS), -I$(dir)/include)
LDFLAGS += $(foreach dir, $(PORTLIBS), -L$(dir)/lib)
# Dependency tracking
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d
DEPFILES := $(OBJS:%.o=%.d)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/misc/switch/Makefile
#---------------------------------------------------------------------------------
# Main targets
#---------------------------------------------------------------------------------
default: $(BUILD_DIR) $(TARGET).nro
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf
rm $(TARGET).nro $(BUILD_DIR)/$(TARGET).nacp $(TARGET).elf $(OBJS)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
#---------------------------------------------------------------------------------
else
.PHONY: all
# Executable generation
#---------------------------------------------------------------------------------
$(TARGET).elf: $(OBJS)
$(CXX) $(LDFLAGS) $^ -o $@ $(LIBS)
$(BUILD_DIR)/$(TARGET).nacp:
nacptool --create "$(APP_TITLE)" "$(APP_AUTHOR)" "$(APP_VERSION)" $@ --titleid=$(APP_TITLEID)
$(TARGET).nro: $(TARGET).elf $(BUILD_DIR)/$(TARGET).nacp
elf2nro $< $@ --icon=$(APP_ICON) --nacp=$(BUILD_DIR)/$(TARGET).nacp
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
# Object generation
#---------------------------------------------------------------------------------
all : $(OUTPUT).nro
$(BUILD_DIR)/%.o: src/%.c
$(CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@
ifeq ($(strip $(NO_NACP)),)
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
else
$(OUTPUT).nro : $(OUTPUT).elf
endif
$(BUILD_DIR)/%.o: src/switch/%.c
$(CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@
$(OUTPUT).elf : $(OFILES)
$(BUILD_DIR)/%.o: third_party/bearssl/src/%.c
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(OFILES_SRC) : $(HFILES_BIN)
-include $(DEPENDS)
#---------------------------------------------------------------------------------
# Dependency tracking
#---------------------------------------------------------------------------------
$(DEPFILES):
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
include $(wildcard $(DEPFILES))

View File

@ -1,23 +1,21 @@
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
endif
include $(DEVKITPPC)/wii_rules
include $(DEVKITPRO)/devkitPPC/base_tools
#---------------------------------------------------------------------------------
# Configurable options
#---------------------------------------------------------------------------------
# Directory where object files are placed
BUILD_DIR := build/wii
# List of directories containing source code
SOURCE_DIRS := src src/gcwii third_party/bearssl/src
# Name of the final output
TARGET := ClassiCube-wii
# Additional libraries to link against
LIBS = -lasnd -lwiikeyboard -lwiiuse -lbte -lfat -logc -lm
TARGET = ClassiCube-wii
# List of directories containing source code
SOURCE_DIRS = src src/gcwii third_party/bearssl/src
# List of directories containing more header files
INCLUDES = -Ithird_party/bearssl/inc
# Directory where object files are placed
BUILD_DIR = build/wii
#---------------------------------------------------------------------------------
@ -26,8 +24,13 @@ INCLUDES = -Ithird_party/bearssl/inc
S_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S))
C_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o)))
CFLAGS = -g -O2 -Wall $(MACHDEP) -I$(LIBOGC_INC)
LDFLAGS = -g $(MACHDEP) -L$(LIBOGC_LIB)
MACHDEP = -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float
CFLAGS = -g -O2 -Wall $(MACHDEP) -I$(DEVKITPRO)/libogc/include
LDFLAGS = -g $(MACHDEP) -L$(DEVKITPRO)/libogc/lib/wii
# Additional libraries to link against
LIBS = -lasnd -lwiikeyboard -lwiiuse -lbte -lfat -logc -lm
# Dependency tracking
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d

View File

@ -5,10 +5,15 @@ endif
#---------------------------------------------------------------------------------
# Configurable options
#---------------------------------------------------------------------------------
# Name of the final output
TARGET = ClassiCube-xbox
# Application name/title
XBE_TITLE = ClassiCube
# List of directories containing source code
SOURCE_DIRS = src src/xbox third_party/bearssl/src
# Shader objects
SHADER_OBJS = misc/xbox/vs_coloured.inl misc/xbox/vs_textured.inl misc/xbox/ps_coloured.inl misc/xbox/ps_textured.inl
# Directory where object files are placed
BUILD_DIR = build/xbox

View File

@ -1,8 +1,6 @@
#include "Core.h"
#if defined CC_BUILD_3DS
#include "../Core.h"
#include "../Audio.h"
#include <3ds.h>
#include "Audio.h"
struct AudioContext {
int chanID, count;
@ -11,7 +9,7 @@ struct AudioContext {
cc_bool stereo;
};
#define AUDIO_OVERRIDE_ALLOC
#include "_AudioBase.h"
#include "../_AudioBase.h"
static int channelIDs;
#define MAX_AUDIO_VOICES 24
@ -200,5 +198,4 @@ cc_result Audio_AllocChunks(cc_uint32 size, struct AudioChunk* chunks, int numCh
void Audio_FreeChunks(struct AudioChunk* chunks, int numChunks) {
linearFree(chunks[0].data);
}
#endif

View File

@ -1,12 +1,12 @@
#include "Core.h"
#if defined CC_BUILD_3DS
#include "_GraphicsBase.h"
#include "Errors.h"
#include "Logger.h"
#include "Window.h"
#include "../Core.h"
#include "../_GraphicsBase.h"
#include "../Errors.h"
#include "../Logger.h"
#include "../Window.h"
#include <3ds.h>
#define BUFFER_BASE_PADDR OS_VRAM_PADDR // VRAM physical address
#include "../third_party/citro3d.c"
#include "../../third_party/citro3d.c"
// autogenerated from the .v.pica files by Makefile
extern const u8 coloured_shbin[];
@ -1072,4 +1072,4 @@ void Gfx_Draw2DTexture(const struct Texture* tex, PackedCol color) {
C3D_ImmSendAttrib(v[0].U, v[0].V, 0.0f, 0.0f);
C3D_ImmDrawEnd();
}
#endif

View File

@ -1,15 +1,13 @@
#include "Core.h"
#if defined CC_BUILD_3DS
#include "../Core.h"
#define CC_XTEA_ENCRYPTION
#include "_PlatformBase.h"
#include "Stream.h"
#include "ExtMath.h"
#include "Funcs.h"
#include "Window.h"
#include "Utils.h"
#include "Errors.h"
#include "PackedCol.h"
#include "../_PlatformBase.h"
#include "../Stream.h"
#include "../ExtMath.h"
#include "../Funcs.h"
#include "../Window.h"
#include "../Utils.h"
#include "../Errors.h"
#include "../PackedCol.h"
#include <errno.h>
#include <time.h>
@ -29,7 +27,7 @@
#include <netdb.h>
#include <3ds.h>
#include <citro3d.h>
#include "_PlatformConsole.h"
#include "../_PlatformConsole.h"
#define US_PER_SEC 1000000LL
#define NS_PER_MS 1000000LL
@ -469,4 +467,4 @@ cc_result Platform_GetEntropy(void* data, int len) {
return PS_GenerateRandomBytes(data, len);
// NOTE: PS_GenerateRandomBytes isn't implemented in Citra
}
#endif

View File

@ -1,22 +1,22 @@
#include "Core.h"
#if defined CC_BUILD_3DS
#include "Window.h"
#include "Platform.h"
#include "Input.h"
#include "Event.h"
#include "Graphics.h"
#include "String.h"
#include "Funcs.h"
#include "Bitmap.h"
#include "Errors.h"
#include "ExtMath.h"
#include "Gui.h"
#include "../Core.h"
#include "../Window.h"
#include "../Platform.h"
#include "../Input.h"
#include "../Event.h"
#include "../Graphics.h"
#include "../String.h"
#include "../Funcs.h"
#include "../Bitmap.h"
#include "../Errors.h"
#include "../ExtMath.h"
#include "../Gui.h"
#include <3ds.h>
static cc_bool launcherMode;
static u16 top_width, top_height;
static u16 btm_width, btm_height;
#include "VirtualKeyboard.h"
#include "../VirtualKeyboard.h"
struct _DisplayData DisplayInfo;
struct cc_window WindowInfo;
@ -268,4 +268,4 @@ cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) {
cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) {
return ERR_NOT_SUPPORTED;
}
#endif

View File

@ -1,24 +1,19 @@
#include "Core.h"
#if defined CC_BUILD_GBA
#include "_PlatformBase.h"
#include "Stream.h"
#include "ExtMath.h"
#include "Funcs.h"
#include "Window.h"
#include "Utils.h"
#include "Errors.h"
#include "Options.h"
#include "Animations.h"
#include "../Core.h"
#include "../_PlatformBase.h"
#include "../Stream.h"
#include "../ExtMath.h"
#include "../Funcs.h"
#include "../Window.h"
#include "../Utils.h"
#include "../Errors.h"
#include "../Options.h"
#include "../Animations.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include "_PlatformConsole.h"
#include "../_PlatformConsole.h"
typedef volatile uint8_t vu8;
typedef volatile uint16_t vu16;
@ -27,9 +22,9 @@ typedef volatile uint32_t vu32;
const cc_result ReturnCode_FileShareViolation = 1000000000; // not used
const cc_result ReturnCode_FileNotFound = ENOENT;
const cc_result ReturnCode_DirectoryExists = EEXIST;
const cc_result ReturnCode_SocketInProgess = EINPROGRESS;
const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK;
const cc_result ReturnCode_SocketDropped = EPIPE;
const cc_result ReturnCode_SocketInProgess = -1000;
const cc_result ReturnCode_SocketWouldBlock = -1000;
const cc_result ReturnCode_SocketDropped = -1000;
const char* Platform_AppNameSuffix = " GBA";
cc_bool Platform_ReadonlyFilesystem;
@ -54,9 +49,9 @@ static void Log_Nocash(char* buffer) {
}
#define MGBA_LOG_DEBUG 4
#define REG_DEBUG_ENABLE (vu16*) 0x4FFF780
#define REG_DEBUG_FLAGS (vu16*) 0x4FFF700
#define REG_DEBUG_STRING (char*) 0x4FFF600
#define REG_DEBUG_ENABLE (vu16*)0x4FFF780
#define REG_DEBUG_FLAGS (vu16*)0x4FFF700
#define REG_DEBUG_STRING (char*)0x4FFF600
static void Log_mgba(char* buffer, int len) {
*REG_DEBUG_ENABLE = 0xC0DE;
@ -264,5 +259,4 @@ cc_result Platform_Encrypt(const void* data, int len, cc_string* dst) {
cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
return ERR_NOT_SUPPORTED;
}
#endif

View File

@ -1,33 +1,33 @@
#include "Core.h"
#if defined CC_BUILD_GBA
#include "Window.h"
#include "Platform.h"
#include "Input.h"
#include "Event.h"
#include "Graphics.h"
#include "String.h"
#include "Funcs.h"
#include "Bitmap.h"
#include "Errors.h"
#include "ExtMath.h"
#include "Camera.h"
#include "../Core.h"
#include "../Window.h"
#include "../Platform.h"
#include "../Input.h"
#include "../Event.h"
#include "../Graphics.h"
#include "../String.h"
#include "../Funcs.h"
#include "../Bitmap.h"
#include "../Errors.h"
#include "../ExtMath.h"
#include "../Camera.h"
#include <stdint.h>
typedef volatile uint8_t vu8;
typedef volatile uint16_t vu16;
typedef volatile uint32_t vu32;
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 160
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 160
#define DCNT_MODE3 0x0003
#define DCNT_BG2 0x0400
#define DCNT_MODE3 0x0003
#define DCNT_BG2 0x0400
#define MEM_IO 0x04000000
#define MEM_VRAM 0x06000000
#define MEM_IO 0x04000000
#define MEM_VRAM 0x06000000
#define REG_DISPCNT *(vu32*)(MEM_IO + 0x0000)
#define REG_KEYINPUT *(vu16*)(MEM_IO + 0x0130)
#define REG_DISPCNT *(vu32*)(MEM_IO + 0x0000)
#define REG_KEYINPUT *(vu16*)(MEM_IO + 0x0130)
#define KEY_A 0x0001
#define KEY_B 0x0002
@ -182,4 +182,4 @@ cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) {
cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) {
return ERR_NOT_SUPPORTED;
}
#endif

View File

@ -26,7 +26,7 @@
#ifdef HW_RVL
#include <ogc/wiilaunch.h>
#endif
#include "../_PlatfromConsole.h"
#include "../_PlatformConsole.h"
const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */
const cc_result ReturnCode_FileNotFound = ENOENT;

View File

@ -22,7 +22,7 @@
static cc_bool needsFBUpdate;
static cc_bool launcherMode;
static int mouseSupported;
#include "VirtualCursor.h"
#include "../VirtualCursor.h"
static void* xfb;
static GXRModeObj* rmode;
void* Window_XFB;

View File

@ -1,10 +1,9 @@
#include "Core.h"
#include "../Core.h"
#include "../Audio.h"
#if defined CC_BUILD_SWITCH
#include <switch.h>
#include <stdio.h>
#include <stdlib.h>
#include "Audio.h"
struct AudioContext {
int chanID, count;
@ -12,7 +11,7 @@ struct AudioContext {
int channels, sampleRate;
};
#define AUDIO_OVERRIDE_ALLOC
#include "_AudioBase.h"
#include "../_AudioBase.h"
static int channelIDs;
AudioDriver drv;
@ -256,5 +255,4 @@ void Audio_FreeChunks(struct AudioChunk* chunks, int numChunks) {
}
free(chunks[0].data);
}
#endif

View File

@ -1,17 +1,15 @@
#include "Core.h"
#if defined CC_BUILD_SWITCH
#include "../Core.h"
#define CC_XTEA_ENCRYPTION
#include "_PlatformBase.h"
#include "Stream.h"
#include "ExtMath.h"
#include "Funcs.h"
#include "Window.h"
#include "Utils.h"
#include "Errors.h"
#include "Options.h"
#include <switch.h>
#include "../_PlatformBase.h"
#include "../Stream.h"
#include "../ExtMath.h"
#include "../Funcs.h"
#include "../Window.h"
#include "../Utils.h"
#include "../Errors.h"
#include "../Options.h"
#include <switch.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@ -27,7 +25,7 @@
#include <sys/socket.h>
#include <sys/types.h>
#include <netdb.h>
#include "_PlatformConsole.h"
#include "../_PlatformConsole.h"
const cc_result ReturnCode_FileShareViolation = 1000000000; // not used
const cc_result ReturnCode_FileNotFound = ENOENT;
@ -543,4 +541,4 @@ static cc_result GetMachineID(cc_uint32* key) {
Mem_Copy(key, MACHINE_KEY, sizeof(MACHINE_KEY) - 1);
return 0;
}
#endif

View File

@ -1,18 +1,18 @@
#include "Core.h"
#if defined CC_BUILD_SWITCH
#include "_WindowBase.h"
#include "Window.h"
#include "Platform.h"
#include "Input.h"
#include "Event.h"
#include "Graphics.h"
#include "String.h"
#include "Funcs.h"
#include "Bitmap.h"
#include "Errors.h"
#include "ExtMath.h"
#include "Input.h"
#include "Gui.h"
#include "../Core.h"
#include "../_WindowBase.h"
#include "../Window.h"
#include "../Platform.h"
#include "../Input.h"
#include "../Event.h"
#include "../Graphics.h"
#include "../String.h"
#include "../Funcs.h"
#include "../Bitmap.h"
#include "../Errors.h"
#include "../ExtMath.h"
#include "../Input.h"
#include "../Gui.h"
#include <switch.h>
static cc_bool launcherMode;
@ -312,4 +312,4 @@ cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) {
cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) {
return ERR_NOT_SUPPORTED;
}
#endif

View File

@ -38,10 +38,10 @@ static void LoadVertexShader(uint32_t* program, int programSize) {
}
static uint32_t vs_coloured_program[] = {
#include "../misc/xbox/vs_coloured.inl"
#include "../../misc/xbox/vs_coloured.inl"
};
static uint32_t vs_textured_program[] = {
#include "../misc/xbox/vs_textured.inl"
#include "../../misc/xbox/vs_textured.inl"
};
@ -49,7 +49,7 @@ static void LoadFragmentShader_Coloured(void) {
uint32_t* p;
p = pb_begin();
#include "../misc/xbox/ps_coloured.inl"
#include "../../misc/xbox/ps_coloured.inl"
pb_end(p);
}
@ -57,7 +57,7 @@ static void LoadFragmentShader_Textured(void) {
uint32_t* p;
p = pb_begin();
#include "../misc/xbox/ps_textured.inl"
#include "../../misc/xbox/ps_textured.inl"
pb_end(p);
}