Blob Blame History Raw
#!/bin/bash

set -e


function icons() {
    echo "// this file is autogenerated"
    echo
    echo "#include \"icons.h\""
    echo
    for f in Back Count1 Count2 Count3 Count4 Noturn Turn; do
        echo "const unsigned char dataIcon${f}[] = {"
        cat "data/icons/$(echo "$f" | tr '[:upper:]' '[:lower:]').png" | xxd -i
        echo "};"
        echo "const size_t dataIcon${f}Size = sizeof(dataIcon${f});"
        echo
    done
}


if [ -z "$1" ] || [ "$1" == "release" ]; then
    echo "build release"
    FLAGS="-O3 -DNDEBUG"
elif [ "$1" == "debug" ]; then
    echo "build debug"
    FLAGS="-g -O0"
elif [ "$1" == "icons" ]; then
    echo "update icons.c"
    icons > icons.c
    echo "success"
    exit 0
else
    echo "usage: $0 [debug|release|icons]"
    exit 1
fi

LIBS="$(pkg-config --cflags --libs helianthus) -lm"
FLAGS="-Wall $FLAGS $LIBS"

cc $FLAGS *.c $LIBS -lm -o jigsaw

echo "build success"