]> cvs.zerfleddert.de Git - micropolis/commitdiff
add ugly sdl_helper to automagically find and enable SDL_mixer
authorMichael Gernoth <michael@gernoth.net>
Mon, 11 Feb 2008 20:56:54 +0000 (21:56 +0100)
committerMichael Gernoth <michael@gernoth.net>
Mon, 11 Feb 2008 20:56:54 +0000 (21:56 +0100)
src/sim/makefile
src/sim/sdl_helper [new file with mode: 0755]

index a28ac84e4f22f0843ae17cd9cc07caabd55e37b9..5a8a62268db0734033630bba3fc40327a10798a4 100644 (file)
@@ -5,11 +5,8 @@ TCLXHOME = ../tclx
 TCLLIBRARY = /usr/local/lib/tcl
 TKLIBRARY = /usr/local/lib/tk
 
-SDLINCLUDE =
-SDLLIBS = -lSDL -lSDL_mixer
-#SDLINCLUDE += $$(pkg-config --cflags sdl)
-#SDLLIBS += $$(pkg-config --libs sdl)
+SDLINCLUDE = $$(./sdl_helper cflags)
+SDLLIBS = $$(./sdl_helper libs)
 
 CC = gcc
 
@@ -17,7 +14,7 @@ OPTFLAGS = -O3
 #OPTFLAGS = -g
 
 #DEFINES = -DIS_LINUX -DCAM -DNET
-DEFINES = -DIS_LINUX -DWITH_SDL_MIXER -DNO_AIRCRASH
+DEFINES = -DIS_LINUX -DNO_AIRCRASH
 
 CFLAGS += $(OPTFLAGS) $(DEFINES)
 
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