Blob Blame History Raw
#!/bin/bash

set -e

# build options
DEPS="sdl2 SDL2_mixer SDL2_image freetype2"
CFLAGS="$CFLAGS -DNDEBUG -fPIC -O3 `pkg-config --cflags $DEPS`"
LDFLAGS="$LDFLAGS -lm -lGL `pkg-config --libs $DEPS`"
BUILDDIR="$PWD"


# just helping function
function echodo() {
    echo "$@"
    "$@"
}


# compile files
mkdir -p src
cd ..
for file in src/*.c src/*.S; do
    echodo cc -c $CFLAGS "$file" -o "$BUILDDIR/$file.o"
done
cd "$BUILDDIR"


# make static library
echodo ar rcs libhelianthus.a src/*.o


# make shader library
echodo ld src/*.o $LDFLAGS -shared -o libhelianthus.so.0.1.0
echodo ln -s libhelianthus.so.0.1.0 libhelianthus.so.0
echodo ln -s libhelianthus.so.0.1.0 libhelianthus.so


# build demo (this ste is not required)
echodo ln -sf ../src helianthus
echodo ln -sf ../demo/data
echodo cc $CFLAGS -I. -I./helianthus ../demo/src/*.c $LDFLAGS "$BUILDDIR/libhelianthus.so" -o demo


echo "done"