# # Roo/E, the Kangaroo Punch Portable GUI Toolkit # Copyright (C) 2026 Scott Duensing # # http://kangaroopunch.com # # # This file is part of Roo/E. # # Roo/E is free software: you can redistribute it and/or modify it under the # terms of the GNU Affero General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) # any later version. # # Roo/E is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU Affero General Public License # along with Roo/E. If not, see . # # This Makefile is terrible. I have no idea what I'm doing. # Tools CC := gcc AR := ar DXE3GEN := dxe3gen EXE2COFF := exe2coff # Compiler Settings override CFLAGS += -Wall -MD override LDFLAGS += # Output Directories OBJ := obj BIN := bin DYN := $(BIN)/dyn APP := $(BIN)/app SDK := $(BIN)/sdk FNT := $(BIN)/fonts FIN := font/in # Include Paths INC := include 3rdparty 3rdparty/pthreads/include roo_e # Use MEMWATCH? ifneq (,$(findstring MEMWATCH,$(CFLAGS))) MEMWATCH_SRC := 3rdparty/memwatch/memwatch.c MEMWATCH_OBJ := $(OBJ)/$(MEMWATCH_SRC).o INC += 3rdparty/memwatch else MEMWATCH_SRC := MEMWATCH_OBJ := endif # Font Compiler Source and Target - NOTE: This is a Linux binary! FONT_ELF := font FONT_SRC := $(shell find font/src -name '*.c') $(MEMWATCH_SRC) FONT_OBJ := $(FONT_SRC:%=$(OBJ)/%.o) FONT_LIB := -lm # Roo/E Source and Target ROOE_EXE := roo_e.exe ROOE_SRC := $(shell find roo_e -name '*.c') $(MEMWATCH_SRC) ROOE_OBJ := $(ROOE_SRC:%=$(OBJ)/%.o) ROOE_LIB := 3rdparty/pthreads/lib/libgthreads.a -lgcc -lm # MultiPlayer Game Client MPGC_EXE := kpsmpgc.app MPGC_SRC := $(shell find kpsmpgc -name '*.c') $(MEMWATCH_SRC) MPGC_OBJ := $(MPGC_SRC:%=$(OBJ)/%.o) MPGC_LIB := DYNS := kpssurf kpsplatf stbimage FONTS := vga4x8 vga8x8 vga8x14 vga8x16 # Wiring override CFLAGS += $(INC_FLAGS) INC_FLAGS := $(addprefix -I,$(INC)) $(foreach DIR,$(DYNS),-Idyn/$(DIR)) APP_OBJS := $(ROOE_OBJ) $(MPGC_OBJ) FONTS := $(addprefix $(FNT)/,$(addsuffix .fnt,$(FONTS))) FONT_PNGS := $(subst .fnt,.png,$(subst $(FNT),$(FIN),$(FONTS))) DYN_FILES := $(foreach DIR,$(DYNS),$(DYN)/$(DIR).dyn) DYN_SOURCE := $(foreach DIR,$(DYNS),$(shell find dyn/$(DIR) -name '*.c' -or -name '*.h')) # Force User to Run This Using Toolchains .PHONY: use_build_script use_build_script: @echo "Use build.sh to cross-compile, not make." # Build Everything .PHONY: dos dos: $(BIN)/$(ROOE_EXE) $(APP)/$(MPGC_EXE) $(DYN_FILES) sdk_extra .PHONY: linux linux: $(FONTS) # Remove Everything .PHONY: clean clean: rm -rf $(OBJ) $(BIN) # Font Compiler Target $(BIN)/$(FONT_ELF): $(FONT_OBJ) Makefile @echo "\n---------- $@" mkdir -p $(dir $@) $(BIN)/fonts $(CC) $(FONT_OBJ) -o $@ $(LDFLAGS) $(FONT_LIB) $(FONTS) &: $(FONT_PNGS) $(BIN)/$(FONT_ELF) cd $(BIN) && ./$(FONT_ELF) # Roo/E Target $(BIN)/$(ROOE_EXE): $(ROOE_OBJ) Makefile @echo "\n---------- $@" mkdir -p $(dir $@) $(CC) $(ROOE_OBJ) -o $@ $(LDFLAGS) $(ROOE_LIB) # Embed the DPMI Server $(EXE2COFF) $(BIN)/$(ROOE_EXE) cat 3rdparty/CWSDPMI/CWSDSTUB.EXE $(basename $(BIN)/$(ROOE_EXE)) > $(BIN)/$(ROOE_EXE) rm $(basename $(BIN)/$(ROOE_EXE)) # MPGC Target $(APP)/$(MPGC_EXE): $(MPGC_OBJ) Makefile @echo "\n---------- $@" mkdir -p $(dir $@) $(DXE3GEN) -o $@ $(MPGC_OBJ) -U $(LDFLAGS) $(MPGC_LIB) # DYN Targets - This is NOT how make should be used. .PHONY: dyns $(DYN_FILES): $(DYN_SOURCE) Makefile @echo "\n---------- $@" mkdir -p $(DYN) $(OBJ)/dyn/$(basename $(notdir $@)) $(SDK)/lib $(SDK)/include $(foreach CFILE,$(shell find dyn/$(basename $(notdir $@)) -name '*.c'),$(CC) $(CFLAGS) -o $(OBJ)/dyn/$(basename $(notdir $@))/$(subst dyn/$(basename $(notdir $@))/,,$(CFILE).o) -c $(CFILE) && ) true $(AR) rcs $(OBJ)/dyn/$(basename $(notdir $@)).a $(OBJ)/dyn/$(basename $(notdir $@))/*.o $(MEMWATCH_OBJ) $(DXE3GEN) -o $@ -Y $@.a --whole-archive -U $(OBJ)/dyn/$(basename $(notdir $@)).a $(LDFLAGS) mv $@.a $(SDK)/lib/. if [ ! -z "$(shell find dyn/$(basename $(notdir $@)) -name '*.h')" ]; then cp $(shell find dyn/$(basename $(notdir $@)) -name '*.h') $(SDK)/include/.; fi # Extra SDK Files .PHONEY: sdk_extra sdk_extra: 3rdparty/stbds.h 3rdparty/stbimage.h Makefile cp 3rdparty/stbds.h 3rdparty/stbimage.h ${SDK}/include/. cp roo_e/*.h ${SDK}/include/. # Build C Files $(OBJ)/%.c.o: %.c mkdir -p $(dir $@) $(CC) $(CFLAGS) -c $< -o $@ # Track Header Changes in APPs and Roo/E -include $(APP_OBJS:.o=.d)