#!/bin/sh

CFLAGS="-ggdb3 -Wall -Werror"
# HACK, FIXME
CFLAGS="$CFLAGS -Wno-write-strings"
LDFLAGS=""

# Boost.Thread
BOOST_THREAD_LIB=`ls /usr{/,/local/}lib/libboost_thread*.a 2>/dev/null | head -n 1`
BOOST_THREAD_LIB=`basename $BOOST_THREAD_LIB .a | sed 's/^lib//'`
LDFLAGS="$LDFLAGS -l$BOOST_THREAD_LIB"

# PhysicsFS
CFLAGS="$CFLAGS -Ilibs/physicsfs-2.0.2"
if [ `uname -s` = "Darwin" ]; then
  LDFLAGS="$LDFLAGS -framework IOKit"
fi

# SDL, SDL_mixer
CFLAGS="$CFLAGS `pkg-config --cflags sdl SDL_mixer`"
LDFLAGS="$LDFLAGS `pkg-config --libs sdl SDL_mixer`"

# GLEW and OpenGL
CFLAGS="$CFLAGS -DGLEW_STATIC -Ilibs/glew-1.6.0/"
if [ `uname -s` = "Darwin" ]; then
  CFLAGS="$CFLAGS -FOpenGL"
  LDFLAGS="$LDFLAGS -framework OpenGL"
elif [ `uname -s` = "Cygwin" ]; then
  LDFLAGS="$LDFLAGS -lopengl32 -lglu32"
else
  CFLAGS="$CFLAGS -I/usr/X11R6/include"
  LDFLAGS="$LDFLAGS -lGL -lGLU"
fi

# SOIL
CFLAGS="$CFLAGS -Ilibs/soil"
