From 15b9aebb9fdeaa2008475ab143d68f12bbbe3450 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 17 Jul 2010 03:06:28 +0000 Subject: [PATCH] updated linux scripts to more generically handled discovery of shared libraries --- mk/linux/glest | 118 +++++++++++++++++-------------------- mk/linux/setupBuildDeps.sh | 18 +++--- 2 files changed, 62 insertions(+), 74 deletions(-) diff --git a/mk/linux/glest b/mk/linux/glest index 157ec852..b64af5e3 100755 --- a/mk/linux/glest +++ b/mk/linux/glest @@ -1,5 +1,28 @@ #!/bin/sh +findMissingSO () { + + LDCONFIG="$1" + SO_LINKEDLIBNAME="$2" + SO_LIBLOOKUP1="$3" + SO_LIBLOOKUP2="$4" + + hasSO=`$LDCONFIG -p | grep -m 1 "$SO_LIBLOOKUP1" | cut "-d>" -f2 | cut "-d " -f2` + if [ -n "$hasSO" ]; then + echo default library [$SO_LINKEDLIBNAME] was found in [$hasSO] + else + echo default library [$SO_LINKEDLIBNAME] is missing, attempting to find and link to a newer version if available... + + hasSO=`$LDCONFIG -p | grep -m 1 "$SO_LIBLOOKUP2" | cut "-d>" -f2 | cut "-d " -f2` + if [ -n "$hasSO" ]; then + echo new library link [$hasSO] pointed to from [$SO_LINKEDLIBNAME] + ln -f -s $hasSO $SO_LINKEDLIBNAME + fi + fi + + return 0 +} + # Library directory LIBDIR="lib" @@ -19,15 +42,21 @@ echo gamedir [$GAMEDIR] test -n "${LIBDIR}" && export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GAMEDIR}/${LIBDIR}" # ensure ldconfig is found (was an issue on OpenSuSE 11.2) +echo Looking for LDCONFIG [$LDCONFIG]... >&2 + if [ "$LDCONFIG"'x' = 'x' ] # 'LDCONFIG' environment variable, if set, overrides the following detection then + echo 'Looking for LDCONFIG environment var not found...' >&2 if [ `which ldconfig 2>/dev/null` ] then LDCONFIG=`which ldconfig 2>/dev/null` + + echo Found LDCONFIG using which [$LDCONFIG]... >&2 else if [ -x /sbin/ldconfig ] then LDCONFIG=/sbin/ldconfig + echo Found LDCONFIG in sbin [$LDCONFIG]... >&2 # optionally add more custom locations using 'elseif' here else echo 'ERROR: Could not find the "ldconfig" command.' >&2 @@ -47,85 +76,48 @@ OPENAL_LIBLOOKUP2="libopenal.so.1" DIRECTFB_LINKEDLIBNAME="libdirectfb-1.0.so.0" DIRECTFB_LIBLOOKUP1=${DIRECTFB_LINKEDLIBNAME} -DIRECTFB_LIBLOOKUP2="libdirectfb-1.2.so.0" +DIRECTFB_LIBLOOKUP2="libdirectfb-" FUSION_LINKEDLIBNAME="libfusion-1.0.so.0" FUSION_LIBLOOKUP1=${DIRECTFB_LINKEDLIBNAME} -FUSION_LIBLOOKUP2="libfusion-1.2.so.0" +FUSION_LIBLOOKUP2="libfusion-" DIRECT_LINKEDLIBNAME="libdirect-1.0.so.0" DIRECT_LIBLOOKUP1=${DIRECT_LINKEDLIBNAME} -DIRECT_LIBLOOKUP2="libdirect-1.2.so.0" +DIRECT_LIBLOOKUP2="libdirect-" if [ "$OS_TYPE" = "x86_64" ]; then - OPENAL_LIBLOOKUP1="${OPENAL_LIBLOOKUP1} (libc6)" - OPENAL_LIBLOOKUP2="${OPENAL_LIBLOOKUP2} (libc6)" + DIRECTFB_LINKEDLIBNAME="libdirectfb-1.2.so.0" + DIRECTFB_LIBLOOKUP1=${DIRECTFB_LINKEDLIBNAME} + DIRECTFB_LIBLOOKUP2="libdirectfb-" - DIRECTFB_LIBLOOKUP1="${DIRECTFB_LIBLOOKUP1} (libc6)" - DIRECTFB_LIBLOOKUP2="${DIRECTFB_LIBLOOKUP2} (libc6)" + FUSION_LINKEDLIBNAME="libfusion-1.2.so.0" + FUSION_LIBLOOKUP1=${DIRECTFB_LINKEDLIBNAME} + FUSION_LIBLOOKUP2="libfusion-" - FUSION_LIBLOOKUP1="${FUSION_LIBLOOKUP1} (libc6)" - FUSION_LIBLOOKUP2="${FUSION_LIBLOOKUP2} (libc6)" - - DIRECT_LIBLOOKUP1="${DIRECT_LIBLOOKUP1} (libc6)" - DIRECT_LIBLOOKUP2="${DIRECT_LIBLOOKUP2} (libc6)" + DIRECT_LINKEDLIBNAME="libdirect-1.2.so.0" + DIRECT_LIBLOOKUP1=${DIRECT_LINKEDLIBNAME} + DIRECT_LIBLOOKUP2="libdirect-" fi -hasopenal=`$LDCONFIG -p | grep -m 1 "$OPENAL_LIBLOOKUP1" | cut "-d>" -f2 | cut "-d " -f2` -#echo "openal search = [$hasopenal]" -if [ -n "$hasopenal" ]; then - echo "default openal library was found in [$hasopenal]" -else - echo "default openal library is missing, attempting to find and link to a newer version if available..." +#if [ "$OS_TYPE" = "x86_64" ]; then +# OPENAL_LIBLOOKUP1="${OPENAL_LIBLOOKUP1} (libc6)" +# OPENAL_LIBLOOKUP2="${OPENAL_LIBLOOKUP2} (libc6)" - hasopenal=`$LDCONFIG -p | grep -m 1 "$OPENAL_LIBLOOKUP2" | cut "-d>" -f2 | cut "-d " -f2` - if [ -n "$hasopenal" ]; then - echo "new openal library link = $hasopenal" - ln -f -s $hasopenal $GAMEDIR/$LIBDIR/${OPENAL_LINKEDLIBNAME} - fi -fi +# DIRECTFB_LIBLOOKUP1="${DIRECTFB_LIBLOOKUP1} (libc6)" +# DIRECTFB_LIBLOOKUP2="${DIRECTFB_LIBLOOKUP2} (libc6)" -hasdirectfb=`$LDCONFIG -p | grep -m 1 "$DIRECTFB_LIBLOOKUP1" | cut "-d>" -f2 | cut "-d " -f2` -#echo "directfb search = [$hasdirectfb]" -if [ -n "$hasdirectfb" ]; then - echo "default directfb library was found in [$hasdirectfb]" -else - echo "default directfb library is missing, attempting to find and link to a different location if available..." +# FUSION_LIBLOOKUP1="${FUSION_LIBLOOKUP1} (libc6)" +# FUSION_LIBLOOKUP2="${FUSION_LIBLOOKUP2} (libc6)" - hasdirectfb=`$LDCONFIG -p | grep -m 1 "$DIRECTFB_LIBLOOKUP2" | cut "-d>" -f2 | cut "-d " -f2` - if [ -n "$hasdirectfb" ]; then - echo "new directfb library link = $hasdirectfb" - ln -f -s $hasdirectfb $GAMEDIR/$LIBDIR/${DIRECTFB_LINKEDLIBNAME} - fi -fi +# DIRECT_LIBLOOKUP1="${DIRECT_LIBLOOKUP1} (libc6)" +# DIRECT_LIBLOOKUP2="${DIRECT_LIBLOOKUP2} (libc6)" +#fi -hasfusion=`$LDCONFIG -p | grep -m 1 "$FUSION_LIBLOOKUP1" | cut "-d>" -f2 | cut "-d " -f2` -#echo "fusion search = [$hasfusion]" -if [ -n "$hasfusion" ]; then - echo "default fusion library was found in [$hasfusion]" -else - echo "default fusion library is missing, attempting to find and link to a different location if available..." - - hasfusion=`$LDCONFIG -p | grep -m 1 "$FUSION_LIBLOOKUP2" | cut "-d>" -f2 | cut "-d " -f2` - if [ -n "$hasfusion" ]; then - echo "new fusion library link = $hasfusion" - ln -f -s $hasfusion $GAMEDIR/$LIBDIR/${FUSION_LINKEDLIBNAME} - fi -fi - -hasdirect=`$LDCONFIG -p | grep -m 1 "$DIRECT_LIBLOOKUP1" | cut "-d>" -f2 | cut "-d " -f2` -#echo "direct search = [$hasdirect]" -if [ -n "$hasdirect" ]; then - echo "default direct library was found in [$hasdirect]" -else - echo "default direct library is missing, attempting to find and link to a different location if available..." - - hasdirect=`$LDCONFIG -p | grep -m 1 "$DIRECT_LIBLOOKUP2" | cut "-d>" -f2 | cut "-d " -f2` - if [ -n "$hasdirect" ]; then - echo "new direct library link = $hasdirect" - ln -f -s $hasdirect $GAMEDIR/$LIBDIR/${DIRECT_LINKEDLIBNAME} - fi -fi +findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${OPENAL_LINKEDLIBNAME}" "$OPENAL_LIBLOOKUP1" "$OPENAL_LIBLOOKUP2" +findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${DIRECTFB_LINKEDLIBNAME}" "$DIRECTFB_LIBLOOKUP1" "$DIRECTFB_LIBLOOKUP2" +findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${FUSION_LINKEDLIBNAME}" "$FUSION_LIBLOOKUP1" "$FUSION_LIBLOOKUP2" +findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${DIRECT_LINKEDLIBNAME}" "$DIRECT_LIBLOOKUP1" "$DIRECT_LIBLOOKUP2" ./bin/glest.bin $@ 2>&1 | tee -a glest.log # ./bin/glest.bin $@ 2>&1 | tee -a /tmp/`date +"%F_%k-%M-%S"`.glest.log 2>&1 diff --git a/mk/linux/setupBuildDeps.sh b/mk/linux/setupBuildDeps.sh index e671fab6..dc40eb0f 100755 --- a/mk/linux/setupBuildDeps.sh +++ b/mk/linux/setupBuildDeps.sh @@ -10,30 +10,26 @@ else sudo apt-get install build-essential subversion automake autoconf autogen jam fi - -if [ -f /etc/fedora-release ]; then +if [ -f /etc/SuSE-release ]; then + echo "=====> Using build deps for SuSE 11.3..." + sudo zypper install SDL-devel xerces-c-devel mesa-libGL-devel mesa-libGLU-devel libvorbis-devel wxBase wxGTK-devel lua-devel libjpeg-devel libpng-devel libcurl-devel openal-soft-devel libX11-devel +elif [ -f /etc/fedora-release ]; then echo "=====> Using build deps for fedora 13..." - sudo yum install SDL-devel xerces-c-devel mesa-libGL-devel mesa-libGLU-devel libvorbis-devel wxBase wxGTK-devel lua-devel libjpeg-devel libpng-devel libcurl-devel openal-soft-devel libX11-devel - elif [ "`uname -r`" = $ubuntu804_32 ]; then echo "=====> Using build deps for old Ubuntu 8.04..." - sudo apt-get install libsdl1.2-dev libxerces28-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev - elif [ "$OSTYPE" = "x86_64" ]; then echo "=====> Using build deps for 64 bit linux..." - sudo apt-get install libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libircclient-dev cmake-curses-gui libgtk2.0-dev - else echo "=====> Using build deps for 32 bit Linux..." - sudo apt-get install libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libircclient-dev - fi -if [ -f /etc/fedora-release ]; then +if [ -f /etc/SuSE-release ]; then + sudo zypper install cmake +elif [ -f /etc/fedora-release ]; then sudo yum install cmake else sudo apt-get install cmake