v0.9.5 beta — full feature build ready for distribution
Core additions since initial commit: - Platform-split MIDI (midi_linux.c / midi_windows.c) - Patch system: save/load/scan, subdirectory navigation, favourites - Config system: last MIDI device and CC mappings persisted to disk - Custom embedded pixel font and sprite sheet (no loose asset files at runtime) - Window icon embedded at runtime (SetWindowIcon) and in Windows .exe (windres) - chdirToExeDir() in platform.c so double-click launch finds patches/ correctly - About screen accessible from Master panel UI polish: - TITLE_BAR_H constant (20 px) — sprite buttons now fit inside title bars - All title bar text, button overlay text, and close/active labels vertically centred - Full-screen dim overlay computed from camera transform (no more partial coverage) - Patch browser: folder navigation, breadcrumb title, 256-slot limit lifted Build: - Makefile auto-discovers sources; embeds sprites/font/icon via xxd rules - Windows cross-compile: make PLATFORM=windows (mingw-w64 + windres) - windows.h isolated in platform.c to avoid Rectangle/CloseWindow conflicts with raylib.h - WIN_RES uses lazy = assignment so OBJ_DIR expands correctly for windres output path Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
80
makefile
80
makefile
@@ -1,12 +1,38 @@
|
||||
# Recursive Directory Digesting Makefile V1.0
|
||||
# === Project Settings ===
|
||||
PROJECT := soundThing # Change this to your project name
|
||||
CC := gcc
|
||||
CFLAGS := -Wall -Wextra -std=c11 -O2
|
||||
# Preprocessor flags (deps only here)
|
||||
CPPFLAGS := -MMD -MP
|
||||
# Add linker flags
|
||||
LDFLAGS = -lraylib -lm -ldl -lpthread -lGL -lrt -lX11 -lasound #here (e.g. -lm)
|
||||
|
||||
# === Platform Selection ===
|
||||
# Build for Linux (default): make
|
||||
# Cross-compile for Windows: make PLATFORM=windows
|
||||
PLATFORM ?= linux
|
||||
|
||||
ifeq ($(PLATFORM),windows)
|
||||
CC := x86_64-w64-mingw32-gcc
|
||||
BIN_NAME := $(PROJECT).exe
|
||||
# Point RAYLIB_WIN at the extracted raylib-*_win64_mingw-w64 directory, e.g.:
|
||||
# make PLATFORM=windows RAYLIB_WIN=/opt/raylib-win64
|
||||
# RAYLIB_WIN ?=
|
||||
RAYLIB_WIN = /home/qwhilla/projects/externalLibraries/win64/raylib
|
||||
ifneq ($(RAYLIB_WIN),)
|
||||
CPPFLAGS += -I$(RAYLIB_WIN)/include
|
||||
LDFLAGS := -L$(RAYLIB_WIN)/lib -lraylib -lm -lpthread -lopengl32 -lwinmm -lgdi32 -lws2_32 -static
|
||||
else
|
||||
LDFLAGS := -lraylib -lm -lpthread -lopengl32 -lwinmm -lgdi32 -lws2_32 -static
|
||||
endif
|
||||
MIDI_SRC := midi_windows.c
|
||||
WINDRES := x86_64-w64-mingw32-windres
|
||||
WIN_RES = $(OBJ_DIR)/icon_res.o
|
||||
else
|
||||
CC := gcc
|
||||
BIN_NAME := $(PROJECT)
|
||||
LDFLAGS := -lraylib -lm -ldl -lpthread -lGL -lrt -lX11 -lasound
|
||||
MIDI_SRC := midi_linux.c
|
||||
WIN_RES :=
|
||||
endif
|
||||
|
||||
# === Directory Structure ===
|
||||
SRC_DIR := source
|
||||
@@ -18,25 +44,31 @@ INC_DIR := include
|
||||
INC_SUBDIRS := $(shell find $(INC_DIR) -type d)
|
||||
CPPFLAGS += $(addprefix -I,$(INC_SUBDIRS))
|
||||
|
||||
# === Discover sources recursively ===
|
||||
SRC := $(shell find $(SRC_DIR) -type f -name '*.c')
|
||||
# === Discover sources (exclude platform-split MIDI files, add the right one) ===
|
||||
SRC_AUTO := $(shell find $(SRC_DIR) -type f -name '*.c' ! -name 'midi_*.c' ! -name '*.old')
|
||||
SRC := $(SRC_AUTO) $(SRC_DIR)/$(MIDI_SRC)
|
||||
# Map source paths to object paths (mirror folders under build/)
|
||||
OBJ := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRC))
|
||||
DEP := $(OBJ:.o=.d)
|
||||
BIN := $(BIN_DIR)/$(PROJECT)
|
||||
BIN := $(BIN_DIR)/$(BIN_NAME)
|
||||
|
||||
# === Embedded assets ===
|
||||
SPRITES_DATA := $(SRC_DIR)/sprites_data.c
|
||||
FONT_DATA := $(SRC_DIR)/font_data.c
|
||||
ICON_DATA := $(SRC_DIR)/icon_data.c
|
||||
|
||||
# === Rules ===
|
||||
.PHONY: all clean run dirs
|
||||
|
||||
all: dirs $(BIN)
|
||||
all: dirs $(SPRITES_DATA) $(FONT_DATA) $(ICON_DATA) $(BIN)
|
||||
|
||||
dirs:
|
||||
@mkdir -p $(BIN_DIR)
|
||||
@mkdir -p $(sort $(dir $(OBJ))) # create object subdirs that mirror source/
|
||||
|
||||
# Link objects into final executable
|
||||
$(BIN): $(OBJ)
|
||||
$(CC) $(OBJ) -o $@ $(LDFLAGS)
|
||||
$(BIN): $(OBJ) $(WIN_RES)
|
||||
$(CC) $(OBJ) $(WIN_RES) -o $@ $(LDFLAGS)
|
||||
@echo "Linked -> $@"
|
||||
|
||||
# Compile each .c into a .o, with auto header deps
|
||||
@@ -56,3 +88,33 @@ clean:
|
||||
|
||||
# Include auto-generated dependency files (if present)
|
||||
-include $(DEP)
|
||||
|
||||
# Regenerate embedded sprite data when the PNG changes
|
||||
$(SPRITES_DATA): assets/sprites.png
|
||||
xxd -i $< | sed 's/assets_sprites_png/sprites_png/g' > $@
|
||||
@echo "Generated -> $@"
|
||||
|
||||
# Regenerate embedded font data when the PNG changes
|
||||
$(FONT_DATA): assets/myFont.png
|
||||
xxd -i $< | sed 's/assets_myFont_png/font_png/g' > $@
|
||||
@echo "Generated -> $@"
|
||||
|
||||
# Regenerate embedded icon data when the PNG changes
|
||||
$(ICON_DATA): assets/NPNGear.png
|
||||
xxd -i $< | sed 's/assets_NPNGear_png/icon_png/g' > $@
|
||||
@echo "Generated -> $@"
|
||||
|
||||
# Generate .ico from PNG using pure Python3 stdlib (no Pillow required)
|
||||
assets/NPNGear.ico: assets/NPNGear.png
|
||||
python3 -c "import struct; d=open('$<','rb').read(); \
|
||||
hdr=struct.pack('<HHH',0,1,1); \
|
||||
ent=struct.pack('<BBBBHHII',128,128,0,0,1,32,len(d),22); \
|
||||
open('$@','wb').write(hdr+ent+d)"
|
||||
@echo "Generated -> $@"
|
||||
|
||||
# Compile Windows resource (icon.rc -> icon_res.o), only when cross-compiling
|
||||
ifeq ($(PLATFORM),windows)
|
||||
$(WIN_RES): icon.rc assets/NPNGear.ico
|
||||
$(WINDRES) $< -o $@
|
||||
@echo "Compiled resource -> $@"
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user