From 8813bb554e82f33df0ea6f461b1a653dee41bfe9 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Mon, 11 Feb 2008 21:56:54 +0100 Subject: [PATCH 1/1] add ugly sdl_helper to automagically find and enable SDL_mixer --- src/sim/makefile | 9 +++------ src/sim/sdl_helper | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 6 deletions(-) create mode 100755 src/sim/sdl_helper diff --git a/src/sim/makefile b/src/sim/makefile index a28ac84..5a8a622 100644 --- a/src/sim/makefile +++ b/src/sim/makefile @@ -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 index 0000000..5406da9 --- /dev/null +++ b/src/sim/sdl_helper @@ -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 '|(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 -- 2.39.5