]> git.zerfleddert.de Git - micropolis/blobdiff - src/sim/sdl_helper
add ugly sdl_helper to automagically find and enable SDL_mixer
[micropolis] / src / sim / sdl_helper
diff --git a/src/sim/sdl_helper b/src/sim/sdl_helper
new file mode 100755 (executable)
index 0000000..5406da9
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+SDLINCLUDE="`pkg-config --cflags sdl 2>/dev/null`"
+SDLLIBS="`pkg-config --libs sdl 2>/dev/null`"
+
+found=0
+
+if echo '#include <SDL_mixer.h>'|(cpp ${SDLINCLUDE}) >/dev/null 2>&1; then
+       found=1
+else
+       for flag in ${SDLINCLUDE}; do
+               if echo "${flag}" | grep '^-I' >/dev/null 2>&1; then
+                       sdlpath="$(echo "${flag}"| sed -e 's/^-I//')"
+                       if [ -f "${sdlpath}/SDL_mixer.h" ]; then
+                               found=1
+                               break
+                       fi
+               fi
+       done
+fi
+
+if [ "${found}" = "1" ]; then
+       SDLINCLUDE="${SDLINCLUDE} -DWITH_SDL_MIXER"
+       SDLLIBS="${SDLLIBS} -lSDL_mixer"
+else
+       found=0
+
+       for sdlpath in /usr /usr/local /opt/local /opt/csw /sw; do
+               if [ -f "${sdlpath}/include/SDL/SDL_mixer.h" ]; then
+                       SDLINCLUDE="${SDLINCLUDE} -I${sdlpath}/include/SDL -DWITH_SDL_MIXER"
+                       SDLLIBS="${SDLLIBS} -L${sdlpath}/lib -lSDL -lSDL_mixer"
+
+                       found=1
+                       break
+               fi
+       done
+
+       if [ "${found}" = "0" ]; then
+               SDLINCLUDE=""
+               SDLLIBS=""
+       fi
+fi
+
+if [ "${1}" = "cflags" ]; then
+       echo "${SDLINCLUDE}"
+elif [ "${1}" = "libs" ]; then
+       echo "${SDLLIBS}"
+fi
Impressum, Datenschutz