Slightly tidy up some console makefiles

This commit is contained in:
UnknownShadow200 2024-06-20 19:03:55 +10:00
parent b72d7027f5
commit af3b4ed6d3
5 changed files with 85 additions and 49 deletions

View File

@ -1,48 +1,39 @@
BUILD_DIR := build-dc
SOURCE_DIRS := src third_party/bearssl/src misc/dreamcast
BUILD_DIR := build-dc
SOURCE_DIRS := src third_party/bearssl/src misc/dreamcast
TARGET := ClassiCube-dc
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 -pipe -fno-math-errno -Ithird_party/bearssl/inc
CFLAGS := -g -O2 -pipe -fno-math-errno -Ithird_party/bearssl/inc
# Dependency tracking
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d
DEPFILES := $(OBJS:%.o=%.d)
GLDC_LIB=third_party/gldc/libGLdc.a
LDFLAGS=-g
LIBS=-lm $(GLDC_LIB) -lppp -lkosfat
TARGET := ClassiCube-dc
CC_TEXTURES = misc/dreamcast/classicube.zip
GLDC_LIB = third_party/gldc/libGLdc.a
LDFLAGS = -g
LIBS = -lm $(GLDC_LIB) -lppp -lkosfat
ifeq ($(strip $(KOS_BASE)),)
$(error "Please set KOS variables in your environment.")
$(warning Please set KOS variables in your environment. For example:)
$(warning source /opt/toolchains/dc/kos/environ.sh)
$(error Failed to find KallistiOS installation)
endif
default: $(CC_TEXTURES) $(GLDC_LIB) $(BUILD_DIR) $(TARGET).cdi
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(GLDC_LIB): FORCE
$(MAKE) -C third_party/gldc
FORCE: ;
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
default: $(GLDC_LIB) $(BUILD_DIR) $(TARGET).cdi
# TODO add textures to misc folder ?
$(CC_TEXTURES):
curl http://www.classicube.net/static/default.zip -o $@
$(BUILD_DIR)/%.o: src/%.c
kos-cc $(CFLAGS) $(DEPFLAGS) -c $< -o $@
clean:
rm $(TARGET).cdi $(TARGET).iso $(TARGET).elf $(TARGET)-scr.bin $(TARGET).bin $(OBJS)
$(BUILD_DIR)/%.o: misc/dreamcast/%.S
kos-cc -c $< -o $@
$(BUILD_DIR)/%.o: third_party/bearssl/src/%.c
kos-cc $(CFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
# executable generation
#---------------------------------------------------------------------------------
$(TARGET).elf: $(OBJS)
kos-cc $(LDFLAGS) $^ -o $@ $(LIBS)
@ -60,14 +51,34 @@ $(TARGET).iso: $(TARGET)-scr.bin
mkdir -p ISO_FILES/maps
mkdir -p ISO_FILES/texpacks
mkdir -p ISO_FILES/texturecache
cp $(CC_TEXTURES) ISO_FILES/texpacks/default.zip
cp misc/dreamcast/classicube.zip ISO_FILES/texpacks/default.zip
cp misc/dreamcast/IP.BIN IP.BIN
mkisofs -G IP.BIN -C 0,11702 -J -l -r -o $(TARGET).iso ISO_FILES
# genisoimage -V ClassiCube -G IP.BIN -joliet -rock -l -o $(TARGET).iso ISO_FILES
mkisofs -G IP.BIN -C 0,11702 -J -l -r -quiet -o $(TARGET).iso ISO_FILES
# genisoimage -V ClassiCube -G IP.BIN -joliet -rock -l -o $(TARGET).iso ISO_FILES
$(TARGET).cdi: $(TARGET).iso
cdi4dc $(TARGET).iso $(TARGET).cdi
#---------------------------------------------------------------------------------
# object generation
#---------------------------------------------------------------------------------
$(GLDC_LIB): FORCE
$(MAKE) -C third_party/gldc
FORCE: ;
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(BUILD_DIR)/%.o: src/%.c
kos-cc $(CFLAGS) $(DEPFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o: third_party/bearssl/src/%.c
kos-cc $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o: misc/dreamcast/%.S
kos-cc -c $< -o $@
# Dependency tracking
$(DEPFILES):

View File

@ -1,26 +1,27 @@
all: ClassiCube-n64.z64
BUILD_DIR = build-n64
SOURCE_DIR = src
N64_ROM_TITLE = "ClassiCube"
N64_ROM_RTC = true
BUILD_DIR = build-n64
SOURCE_DIR = src
N64_ROM_TITLE = "ClassiCube"
N64_ROM_RTC = true
TARGET := ClassiCube-n64
CFILES := $(notdir $(wildcard src/*.c))
OFILES := $(CFILES:.c=.o)
OBJS := $(addprefix $(BUILD_DIR)/,$(OFILES))
CFLAGS := -Wno-error=missing-braces -Wno-error=strict-aliasing -Wno-error=incompatible-pointer-types -Wno-error=maybe-uninitialized
default: $(TARGET).z64
include $(N64_INST)/include/n64.mk
ClassiCube-n64.z64: N64_ROM_TITLE = "ClassiCube"
ClassiCube-n64.z64: $(BUILD_DIR)/filesystem.dfs
$(TARGET).z64: N64_ROM_TITLE = "ClassiCube"
$(TARGET).z64: $(BUILD_DIR)/filesystem.dfs
$(BUILD_DIR)/filesystem.dfs: misc/n64/default.zip
$(BUILD_DIR)/ClassiCube-n64.elf: $(OBJS)
clean:
rm -rf $(BUILD_DIR) *.z64
rm -rf $(BUILD_DIR) $(TARGET).z64
.PHONY: clean
-include $(wildcard $(BUILD_DIR)/*.d)

View File

@ -11,15 +11,30 @@ OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o)))
LIBS += -lm -lSceDisplay_stub -lSceCtrl_stub -lSceTouch_stub -lSceGxm_stub -lSceCommonDialog_stub
# Dependency tracking
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d
DEPFILES := $(OBJS:%.o=%.d)
ifeq ($(strip $(VITASDK)),)
$(warning "Please set VITASDK variables in your environment. For example:")
$(warning export VITASDK=/usr/local/vitasdk)
$(warning export PATH=$$VITASDK/bin:$$PATH)
$(error Failed to find VitaSDK installation)
endif
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
default: $(BUILD_DIR) $(TARGET).vpk
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
clean:
rm $(TARGET).velf $(TARGET).elf $(TARGET).vpk param.sfo eboot.bin $(OBJS)
#---------------------------------------------------------------------------------
# executable generation
#---------------------------------------------------------------------------------
$(TARGET).vpk: eboot.bin param.sfo
vita-pack-vpk -s param.sfo -b eboot.bin -a misc/vita/sce_sys/ICON0.png=sce_sys/ICON0.png $(TARGET).vpk
@ -36,13 +51,20 @@ $(TARGET).velf: $(TARGET).elf
$(TARGET).elf: $(OBJS)
arm-vita-eabi-gcc $(CFLAGS) $^ $(LIBS) -o $@
#---------------------------------------------------------------------------------
# object generation
#---------------------------------------------------------------------------------
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(BUILD_DIR)/%.o : src/%.c
arm-vita-eabi-gcc -c $(CFLAGS) -o $@ $<
arm-vita-eabi-gcc $(CFLAGS) $(DEPFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o : third_party/bearssl/src/%.c
arm-vita-eabi-gcc -c $(CFLAGS) -o $@ $<
# TODO: There's gotta be a better way of .o to .c than this
arm-vita-eabi-gcc $(CFLAGS) -c $< -o $@
clean:
rm $(TARGET).velf $(TARGET).elf $(TARGET).vpk param.sfo eboot.bin $(OBJS)
# Dependency tracking
$(DEPFILES):
include $(wildcard $(DEPFILES))

View File

@ -23,4 +23,4 @@ default: $(TARGET)
$(TARGET): $(OBJS)
kos-ar cr $@ $^
kos-ranlib $@
kos-ranlib $@

View File

@ -40,6 +40,8 @@ void _glInitContext() {
/* Depth Testing */
void glClearDepth(float depth) {
/* We reverse because using invW means that farther Z == lower number */
float D = MIN(1.0f - depth, PVR_MIN_Z);
Platform_Log2("DEPTH: %f3, %x", &D, &D);
pvr_set_zclip(MIN(1.0f - depth, PVR_MIN_Z));
}