GreatShift
Neeno Bonifarzia

PSExtended

Texture Pack

Wordlist Pack

BoNeeMods

BoniMaps

PS-Client Mods
Calculators
Compiling Guides
62842
GitLab
HTML5 Powered with CSS3 / Styling, and Semantics

Compiling guide for Mac OS X - static

last edit: 05/14/2016
In addition to the offcial compiling guide this guide describes the compiling process for a static PlaneShift client on Mac OS X 10.11 (El Capitan) in short. For a good backwards compatibility we are using the Mac OS X 10.6 SDK, because it is the first version with full 64-bit support.

Prerequisites

Install MacPorts.
Now we are able to install some additional tools:
Copy
port install automake autoconf apple-gcc42 libtool cmake ftjam
After that download and install the nVidia Cg Toolkit.
Before the show begins we create our working directory:
Copy
mkdir $HOME/development
The next step is to set up some variables:
Copy
path="$HOME/development"
path_cal3d="$path/CAL3D"
path_cs="$path/CrystalSpace3D"
path_pse="$path/PSExtended"
path_sdk="$path/MacOSX10.6.sdk"
path_dl="$path/download"
gccv="gcc-apple-4.2"
gppv="g++-apple-4.2"
buildx="x86_64-apple-darwin10"
I1="$path_sdk/usr/include"

Get the sources

Mac OS X 10.6 SDK:
Copy
git clone git@gitlab.com:GreatShift/MacOSX10.6.sdk.git $path_sdk
CAL3D:
Copy
git clone git@gitlab.com:GreatShift/CAL3D.git $path_cal3d
CrystalSpace 3D:
Copy
git clone git@gitlab.com:GreatShift/CrystalSpace3D.git $path_cs
PSExtended:
Copy
git clone git@gitlab.com:GreatShift/PSExtended.git $path_pse
Additional libraries:
Copy
mkdir $path_dl; cd $path_dl
#download
curl -sLO "http://prdownloads.sourceforge.net/libpng/zlib-1.2.8.tar.gz"
curl -sLO "http://ijg.org/files/jpegsrc.v9b.tar.gz"
curl -sLO "http://prdownloads.sourceforge.net/libpng/libpng-1.6.21.tar.gz"
curl -sLO "https://sourceforge.net/projects/lcms/files/lcms/2.7/lcms2-2.7.tar.gz"
curl -sLO "https://sourceforge.net/projects/libmng/files/libmng-devel/2.0.3/libmng-2.0.3.tar.gz"
curl -sL "https://github.com/hunspell/hunspell/archive/v1.3.4.tar.gz" -o "hunspell-v1.3.4.tar.gz"
curl -sLO "https://www.openssl.org/source/openssl-1.0.2f.tar.gz"
curl -sLO "https://curl.haxx.se/download/curl-7.47.1.tar.gz"
curl -sLO "http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz"
curl -sLO "http://http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz"
curl -sLO "http://downloads.xiph.org/releases/speex/speex-1.2rc1.tar.gz"
curl -sLO "https://sourceforge.net/projects/freetype/files/freetype2/2.6.2/freetype-2.6.2.tar.gz"
curl -sLO "http://kcat.strangesoft.net/openal-releases/openal-soft-1.17.2.tar.bz2"
#extract everything
for i in *.tar.gz; do tar xfz $i -C $path; done
for i in *.tar.bz2; do tar xfj $i -C $path; done

Compiling

zlib:
Copy
mv $path/zlib* $path/zlib
cd $path/zlib
CC=$gccv CXX=$gppv \
CPPFLAGS="-I$I1" \
CFLAGS="-isysroot $path_sdk -mmacosx-version-min=10.6" \
./configure --prefix=$path/zlib --static --64
make
make install
libjpeg:
Copy
mv $path/jpeg* $path/jpeg
cd $path/jpeg
CC=$gccv CXX=$gppv \
CPPFLAGS="-I$I1" \
CFLAGS="-nostdinc -mmacosx-version-min=10.6" \
./configure --build $buildx --prefix=$path/jpeg --enable-shared=no --enable-static=yes
make
make install
libpng:
Copy
mv $path/libpng* $path/libpng
cd $path/libpng
CC=$gccv CXX=$gppv \
CPPFLAGS="-I$I1" \
CFLAGS="-mmacosx-version-min=10.6" \
./configure --build $buildx --prefix=$path/libpng --with-zlib-prefix=$path/zlib  --enable-shared=no --enable-static=yes
make
make install
LCMS:
Copy
mv $path/lcms* $path/lcms
cd $path/lcms
CC=$gccv CXX=$gppv \
CPPFLAGS="-I$I1" \
CFLAGS="-mmacosx-version-min=10.6" \
./configure --build $buildx --prefix=$path/lcms --with-jpeg=$path/jpeg --with-zlib=$path/zlib --enable-shared=no --enable-static=yes
make
make install
libmng:
Copy
mv $path/libmng* $path/libmng
cd $path/libmng
CC=$gccv CXX=$gppv \
CPPFLAGS="-I$I1" \
CFLAGS="-mmacosx-version-min=10.6" \
./configure --build $buildx --prefix=$path/libmng --with-zlib=$path/zlib --with-lcms2=$path/lcms --with-jpeg=$path/jpeg --enable-shared=no --enable-static=yes
make
make install
sed -i '' 's#typedef int boolean;#//typedef int boolean;#' $path/libmng/include/libmng_types.h
Hunspell:
Copy
mv $path/hunspell* $path/hunspell
cd $path/hunspell
CC=$gccv CXX=$gppv \
CPPFLAGS="-I$I1" \
CFLAGS="-isysroot $path_sdk -mmacosx-version-min=10.6" \
./configure --build $buildx --prefix=$path/hunspell --enable-shared=no --enable-static=yes
make
make install
OpenSSL:
Copy
mv $path/openssl* $path/openssl
cd $path/openssl
CC=$gccv CXX=$gppv \
CPPFLAGS="-I$I1" \
CFLAGS="-isysroot $path_sdk -mmacosx-version-min=10.6" \
./Configure darwin64-x86_64-cc --prefix=$path/openssl/installx no-shared zlib -I$path/zlib/include -L$path/zlib/lib
make
make install
cURL:
Copy
mv $path/curl* $path/curl
cd $path/curl
CC=$gccv CXX=$gppv \
CPPFLAGS="-I$I1" \
CFLAGS="-isysroot $path_sdk -mmacosx-version-min=10.6" \
./configure --build $buildx --prefix=$path/curl --with-zlib=$path/zlib --with-ssl=$path/openssl/installx --disable-ldap --enable-shared=no --enable-static=yes
make
make install
libogg:
Copy
mv $path/libogg* $path/libogg
cd $path/libogg
CC=$gccv CXX=$gppv \
CPPFLAGS="-I$I1" \
CFLAGS="-isysroot $path_sdk -mmacosx-version-min=10.6" \
./configure --build $buildx --prefix=$path/libogg --enable-shared=no --enable-static=yes
make
make install
libvorbis:
Copy
mv $path/libvorbis* $path/libvorbis
cd $path/libvorbis
CC=$gccv CXX=$gppv \
CPPFLAGS="-I$I1" \
CFLAGS="-mmacosx-version-min=10.6" \
./configure --build $buildx --prefix=$path/libvorbis/install --with-ogg=$path/libogg --enable-shared=no --enable-static=yes
make
make install
Speex:
Copy
mv $path/speex* $path/speex
cd $path/speex
CC=$gccv CXX=$gppv \
CPPFLAGS="-I$I1" \
CFLAGS="-mmacosx-version-min=10.6" \
./configure --build $buildx --prefix=$path/speex --with-ogg=$path/libogg --enable-shared=no --enable-static=yes
make
make install
FreeType:
Copy
mv $path/freetype* $path/freetype
cd $path/freetype
CC=$gccv CXX=$gppv \
CPPFLAGS="-I$I1" \
CFLAGS="-isysroot $path_sdk -mmacosx-version-min=10.6" \
./configure --build $buildx --prefix=$path/freetype --with-zlib=yes --with-png=yes --with-bzip2=no --with-harfbuzz=no --enable-shared=no --enable-static=yes \
LIBPNG_CFLAGS="-I$path/libpng/include" LIBPNG_LIBS="-L$path/libpng/lib -lpng16" \
ZLIB_CFLAGS="-I$path/zlib/include" ZLIB_LIBS="-L$path/zlib/lib -lz"
make
make install
OpenAL Soft:
Copy
mv $path/openal* $path/openal
## little SDK hack
mv $path_sdk/usr/include $path_sdk/usr/include_
ln -s /usr/include $path_sdk/usr/include
##
cd $path/openal
sed -i '' 's#/System/Library/Frameworks/AudioUnit.framework#'$path_sdk'/System/Library/Frameworks/AudioUnit.framework#' CMakeLists.txt
sed -i '' 's#/System/Library/Frameworks/ApplicationServices.framework#'$path_sdk'/System/Library/Frameworks/ApplicationServices.framework#' CMakeLists.txt
cd $path/openal/build
CC=$gccv CXX=$gppv \
CPPFLAGS="-I$I1" \
CFLAGS="-isysroot $path_sdk -mmacosx-version-min=10.6" \
cmake .. -DCMAKE_OSX_ARCHITECTURES=x86_64 \
         -DCMAKE_OSX_SYSROOT:PATH=$path_sdk \
         -DCMAKE_INSTALL_PREFIX=$path/openal/build \
         -DALSOFT_EXAMPLES=OFF \
         -DALSOFT_UTILS=OFF \
         -DALSOFT_TESTS=OFF \
         -DALSOFT_CONFIG=OFF \
         -DLIBTYPE=STATIC
make
make install
## revert SDK hack
rm $path_sdk/usr/include
mv $path_sdk/usr/include_ $path_sdk/usr/include
##
CAL3D:
Copy
cd $path_cal3d
autoreconf --install --force
sed -i '' 's/PKG_CHECK_MODULES(UNITTESTCPP/# PKG_CHECK_MODULES(UNITTESTCPP/' configure
CC=$gccv CXX=$gppv \
CPPFLAGS="-I$I1" \
CFLAGS="-isysroot $path_sdk -mmacosx-version-min=10.6" \
./configure --build $buildx --prefix=$path/$path_cal3d --disable-static --enable-shared
make
make install
#correct linking
install_name_tool -id @executable_path/../Frameworks/libcal3d.12.dylib $path_cal3d/lib/libcal3d.12.dylib
CrystalSpace 3D:
Copy
## little SDK hack
mv $path_sdk/usr/include $path_sdk/usr/include_
ln -s /usr/include $path_sdk/usr/include
##
cd $path_cs
chmod +x configure
sed -i '' '12932s/cs_host_macosx=no/cs_host_macosx=yes/' configure #force Mac OS X
./configure CC=$gccv CXX=$gppv \
            CPPFLAGS="-I$I1" \
            CFLAGS="-isysroot $path_sdk -mmacosx-version-min=10.6" \
            --build $buildx \
            --enable-make-emulation="no" \
            --enable-relaytool="no" \
            --without-CEGUI \
            --without-ode \
            --without-wx \
            --without-assimp \
            --without-java \
            --without-bullet \
            --without-perl \
            --without-python \
            --without-3ds \
            --without-GTK \
            --without-jackasyn \
            --without-theoradec \
            --without-bfd \
            --without-cppunit \
            --without-cairo \
            --without-cairomm \
            --without-vgvm \
            --without-asound \
            --without-x \
            --without-mesa \
            --without-xxf86vm \
            --without-x11 \
            --without-xext \
            --without-xaw7 \
            --without-xrender \
            --without-xcursor \
            --disable-universal-binary \
            --with-cal3d=$path_cal3d \
            --with-z=$path/zlib \
            --with-freetype2=$path/freetype \
            --with-lcms=$path/lcms \
            --with-jpeg=$path/jpeg \
            --with-mng=$path/libmng \
            --with-png=$path/libpng \
            --with-curl=$path/curl \
            --with-speex=$path/speex \
            --with-ogg=$path/libogg \
            --with-vorbis=$path/libvorbis/install
#FreeType
if [ `grep -c FT2.AVAILABLE Jamconfig` = 0 ]; \
then \
    echo 'FT2.AVAILABLE ?= yes ;' >> Jamconfig; \
    echo "FT2.CFLAGS ?= -I$path/freetype/include/freetype2 ;" >> Jamconfig; \
    echo "FT2.LFLAGS ?= -L$path/freetype/lib -lfreetype ;" >> Jamconfig; \
fi
#cURL
if [ `grep -c CURL.AVAILABLE Jamconfig` = 0 ]; \
then \
    echo 'CURL.AVAILABLE ?= yes ;' >> Jamconfig; \
    echo "CURL.CFLAGS ?= -I$path/curl/include -DCURL_STATICLIB ;" >> Jamconfig; \
    echo "CURL.LFLAGS ?= -L$path/curl/lib -lcurl -lz -L$path/openssl/installx/lib -lssl -lcrypto ;" >> Jamconfig; \
else \
    sed -i '' 's#.*CURL.AVAILABLE.*#CURL.AVAILABLE ?= yes ;#' Jamconfig; \
    sed -i '' 's#.*CURL.CFLAGS.*#CURL.CFLAGS ?= -I'$path'/curl/include -DCURL_STATICLIB ;#' Jamconfig; \
    sed -i '' 's#.*CURL.LFLAGS.*#CURL.LFLAGS ?= -L'$path'/curl/lib -lcurl -lz -L'$path'/openssl/installx/lib -lssl -lcrypto ;#' Jamconfig; \
fi
#libmng
if [ `grep -c MNG.AVAILABLE Jamconfig` = 0 ]; \
then \
    echo 'MNG.AVAILABLE ?= yes ;' >> Jamconfig; \
    echo "MNG.CFLAGS ?= -I$path/libmng/include -I$path/lcms/include -I$path/jpeg/include -I$path/zlib/include ;" >> Jamconfig; \
    echo "MNG.LFLAGS ?= -L$path/libmng/lib -L$path/jpeg/lib -lmng -L$path/lcms/lib -llcms2 -ljpeg -L$path/zlib/lib -lz ;" >> Jamconfig; \
fi
#OpenAL Soft
if [ `grep -c OPENAL.AVAILABLE Jamconfig` = 0 ]; \
then \
    echo 'OPENAL.AVAILABLE ?= yes ;' >> Jamconfig; \
    echo "OPENAL.CFLAGS ?= -DCS_OPENAL_PATH=$path/openal/build/include/AL -I$path/openal/build/include -DAL_LIBTYPE_STATIC ;" >> Jamconfig; \
    echo "OPENAL.LFLAGS ?= -L$path/openal/build/lib -lopenal ;" >> Jamconfig; \
else \
    sed -i '' 's#.*OPENAL.AVAILABLE.*#OPENAL.AVAILABLE ?= yes ;#' Jamconfig; \
    sed -i '' 's#.*OPENAL.CFLAGS.*#OPENAL.CFLAGS ?= -I'$path'/openal/build/include -I='$path'/openal/build/include/AL -DAL_LIBTYPE_STATIC ;#' Jamconfig; \
    sed -i '' 's#.*OPENAL.LFLAGS.*#OPENAL.LFLAGS ?= -L'$path'/openal/build/lib -lopenal ;#' Jamconfig; \
fi
#build
jam -j4 -q libs staticplugins cs-config
## revert SDK hack
rm $path_sdk/usr/include
mv $path_sdk/usr/include_ $path_sdk/usr/include
##
export CRYSTAL=$path_cs
PSExtended:
Copy
## little SDK hack
mv $path_sdk/usr/include $path_sdk/usr/include_
ln -s /usr/include $path_sdk/usr/include
##
cd $path_pse
chmod +x autogen.sh
./autogen.sh
./configure CC=$gccv CXX=$gppv \
            CPPFLAGS="-I$I1" \
            CFLAGS="-isysroot $path_sdk -mmacosx-version-min=10.6" \
            --build $buildx \
            --with-cal3d=$path_cal3d \
            --with-hunspell=$path/hunspell \
            --enable-relaytool="no" \
            --disable-universal-binary \
            --without-mysqlclient \
            --without-sqlite3 \
            --without-pq \
            --without-gtest \
            --without-breakpad \
            --without-bfd
#cURL
if [ `grep -c CURL.AVAILABLE Jamconfig` = 0 ]; \
then \
    echo 'CURL.AVAILABLE ?= yes ;' >> Jamconfig; \
    echo "CURL.CFLAGS ?= -I$path/curl/include -DCURL_STATICLIB ;" >> Jamconfig; \
    echo "CURL.LFLAGS ?= -L$path/curl/lib -lcurl -lz -L$path/openssl/installx/lib -lssl -lcrypto ;" >> Jamconfig; \
else \
    sed -i '' 's#.*CURL.AVAILABLE.*#CURL.AVAILABLE ?= yes ;#' Jamconfig; \
    sed -i '' 's#.*CURL.CFLAGS.*#CURL.CFLAGS ?= -I'$path'/curl/include -DCURL_STATICLIB ;#' Jamconfig; \
    sed -i '' 's#.*CURL.LFLAGS.*#CURL.LFLAGS ?= -L'$path'/curl/lib -lcurl -lz -L'$path'/openssl/installx/lib -lssl -lcrypto ;#' Jamconfig; \
fi
sed -i '' 's#PLUGIN.LFLAGS += -shared ;#PLUGIN.LFLAGS += ;#' Jamconfig
#Hunspell
if [ `grep -c HUNSPELL.AVAILABLE Jamconfig` = 0 ]; \
then \
    echo 'HUNSPELL.AVAILABLE ?= yes ;' >> Jamconfig; \
    echo "HUNSPELL.CFLAGS ?= -I$path/hunspell/include/hunspell ;" >> Jamconfig; \
    echo "HUNSPELL.LFLAGS ?= -L$path/hunspell/lib -lhunspell-1.3 ;" >> Jamconfig; \
fi
#build
jam -j4 -q client_static
## revert SDK hack
rm $path_sdk/usr/include
mv $path_sdk/usr/include_ $path_sdk/usr/include
##
#copy Cg & libcal3d
mkdir psclient_static.app/Contents/Frameworks
mkdir psclient_static.app/Contents/Frameworks/Cg.framework
cp /Library/Frameworks/Cg.framework/Versions/1.0/Cg psclient_static.app/Contents/Frameworks/Cg.framework/Cg
cp $path_cal3d/lib/libcal3d.12.dylib psclient_static.app/Contents/Frameworks/libcal3d.12.dylib

You are done now. The final binaries are called 'pslaunch_static.app' and 'psclient_static.app'.
Congratulations!