36 lines
1.3 KiB
Bash
Executable file
36 lines
1.3 KiB
Bash
Executable file
#!/bin/bash
|
|
# Build script for openkknd - the merged KKND-style 2D RTS.
|
|
set -e
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
CC=${CC:-gcc}
|
|
CFLAGS="-O2 -Wall -Iinclude"
|
|
SRCS="src/unit_card.c src/rng.c src/config.c src/png.c src/snapshot.c src/map.c src/sprites.c \
|
|
src/units.c src/buildings.c src/projectiles.c src/render.c \
|
|
src/input.c src/ai.c src/audio.c src/save.c src/engine.c src/main.c"
|
|
|
|
# Homebrew (macOS arm64/x86) often has .pc files that pkg-config misses without PATH.
|
|
if [ -d /opt/homebrew/lib/pkgconfig ]; then
|
|
export PKG_CONFIG_PATH="/opt/homebrew/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
|
|
elif [ -d /usr/local/lib/pkgconfig ]; then
|
|
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
|
|
fi
|
|
|
|
LIBS=$(pkg-config --cflags --libs sdl2 SDL2_ttf 2>/dev/null || true)
|
|
if [ -z "$LIBS" ]; then
|
|
if [ -d /opt/homebrew/include ]; then
|
|
LIBS="-I/opt/homebrew/include -L/opt/homebrew/lib -lSDL2 -lSDL2_ttf"
|
|
elif [ -d /usr/local/include ]; then
|
|
LIBS="-I/usr/local/include -L/usr/local/lib -lSDL2 -lSDL2_ttf"
|
|
else
|
|
LIBS="-lSDL2 -lSDL2_ttf"
|
|
fi
|
|
fi
|
|
LIBS="$LIBS -lz"
|
|
|
|
echo "openkknd: compiling..."
|
|
# shellcheck disable=SC2086
|
|
$CC $CFLAGS $SRCS -o openkknd $LIBS -lm
|
|
echo "openkknd: built -> ./openkknd"
|
|
echo "usage: ./openkknd [--easy|--normal|--hard] [--load savegame.kknd]"
|