diff --git a/Makefile b/Makefile index e693006..9e84cb2 100644 --- a/Makefile +++ b/Makefile @@ -1,77 +1,40 @@ -# Compiler settings -CC = gcc -CFLAGS = -O2 -Wall -Wextra $(shell pkg-config --cflags sdl2 SDL2_image) -LIBS = $(shell pkg-config --libs sdl2 SDL2_image) +# Makefile for gsplash (community-standard layout) -# Project Structure -SRC = src/gsplash.c - -# Package output path (default to pkg layout used in repository) -PKG_DIR ?= pkg/gsplash-git/usr -BIN_DIR := $(PKG_DIR)/bin -# Compiler settings -CC = gcc -CFLAGS = -O2 -Wall -Wextra $(shell pkg-config --cflags sdl2 SDL2_image) -LIBS = $(shell pkg-config --libs sdl2 SDL2_image) - -SRC = src/gsplash.c - -# Build output (temporary) and package layout -BUILD_DIR := build -BUILD_TARGET := $(BUILD_DIR)/gsplash - -PKG_TOP ?= pkg/gsplash-git -PKG_DIR := $(PKG_TOP)/usr -BIN_DIR := $(PKG_DIR)/bin -PKG_TARGET := $(BIN_DIR)/gsplash - -# Installation Paths (Defaults to user local bin) PREFIX ?= /usr/local +bindir ?= $(PREFIX)/bin -# Default target: build the temporary artifact -all: $(BUILD_TARGET) +CC ?= gcc +CFLAGS ?= -O2 -Wall -Wextra +PKG_CONFIG ?= pkg-config -$(BUILD_DIR): - mkdir -p $(BUILD_DIR) +SDL_CFLAGS := $(shell $(PKG_CONFIG) --cflags sdl2 SDL2_image) +SDL_LIBS := $(shell $(PKG_CONFIG) --libs sdl2 SDL2_image) -$(BIN_DIR): - mkdir -p $(BIN_DIR) +ALL_CFLAGS := $(CFLAGS) $(SDL_CFLAGS) +ALL_LIBS := $(LIBS) $(SDL_LIBS) -# Build rule: produce a temporary build artifact in build/ -$(BUILD_TARGET): $(BUILD_DIR) $(SRC) - $(CC) $(CFLAGS) $(SRC) -o $(BUILD_TARGET) $(LIBS) - chmod 0755 $(BUILD_TARGET) +TARGET = gsplash +SRC = src/gsplash.c -# Package: copy build artifact into pkg layout and create a tarball -.PHONY: package dist -package: $(BUILD_TARGET) $(BIN_DIR) - cp -a $(BUILD_TARGET) $(PKG_TARGET) - chmod 0755 $(PKG_TARGET) - mkdir -p dist - # Create a tarball of the package top-level directory - tar -C pkg -czf dist/$(notdir $(PKG_TOP)).tar.gz $(notdir $(PKG_TOP)) +.PHONY: all clean install uninstall check -dist: package +all: $(TARGET) + +$(TARGET): $(SRC) + $(CC) $(ALL_CFLAGS) $(LDFLAGS) $< -o $@ $(ALL_LIBS) # Lightweight smoke test (headless via SDL_VIDEODRIVER=dummy) -.PHONY: check -check: $(BUILD_TARGET) +check: $(TARGET) @echo "Running smoke test (headless)..." - # Run with a non-existent image and a noop target (/bin/true) - exits quickly - SDL_VIDEODRIVER=dummy $(BUILD_TARGET) nonexistent.png /bin/true || true + SDL_VIDEODRIVER=dummy ./$(TARGET) nonexistent.png /bin/true || true @echo "Smoke test finished" -# Install binary system-wide (installs as gsplash) -install: $(BUILD_TARGET) - install -Dm755 $(BUILD_TARGET) $(DESTDIR)$(PREFIX)/bin/$(notdir $(PKG_TARGET)) +install: $(TARGET) + install -d "$(DESTDIR)$(bindir)" + install -m 755 $(TARGET) "$(DESTDIR)$(bindir)/$(TARGET)" -# Remove binary from system uninstall: - rm -f $(DESTDIR)$(PREFIX)/bin/$(notdir $(PKG_TARGET)) + rm -f "$(DESTDIR)$(bindir)/$(TARGET)" -# Clean build artifacts and package output clean: - rm -f $(BUILD_TARGET) $(PKG_TARGET) dist/$(notdir $(PKG_TOP)).tar.gz - -.PHONY: all install uninstall clean -uninstall: + rm -f $(TARGET) diff --git a/PKGBUILD b/PKGBUILD index fc0ac1d..75c291a 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -3,6 +3,7 @@ pkgver=0.1.0 pkgrel=1 pkgdesc="A lightweight native SDL2 splash screen wrapper for game launchers." arch=('x86_64') +license=('custom') depends=('sdl2' 'sdl2_image') makedepends=('make' 'gcc' 'pkgconf') @@ -11,7 +12,6 @@ source=() sha256sums=() build() { - # Point directly to your active project folder where the Makefile lives cd "$startdir" make } diff --git a/README.md b/README.md index d0d8585..c9ca8cd 100644 --- a/README.md +++ b/README.md @@ -28,18 +28,32 @@ makepkg -si For other distributions, build and install manually: ```bash +# Build the binary in the project root make + +# Install system-wide (defaults to /usr/local) sudo make install + +# Staged install (useful for packaging): +DESTDIR=/some/staging/path make install +``` + +## Smoke test (headless) + +Run a lightweight headless smoke test that uses the dummy video driver so it doesn't require a display: + +```bash +make check ``` ## Usage -Build output installs to `/usr/local/bin` by default. Override with `PREFIX`. - ```bash -gsplash [game_arguments...] +./gsplash [game_arguments...] ``` +Example: + ```bash -gsplash assets/splash.jpg /path/to/game --fullscreen --profile=default +./gsplash assets/splash.jpg /path/to/game --fullscreen --profile=default ```