Bennu Game Development

English Forums => Platforms => MacOS X (x86) => Topic started by: josebita on December 08, 2012, 01:07:01 AM

Title: OSX compilation instructions
Post by: josebita on December 08, 2012, 01:07:01 AM

I've just reinstalled my Mac and since I'm re-installing all the software required to build BennuGD in OSX I'll just post the instructions here.
Once you've done this, you should have working BennuGD binaries in your bin/osx-darwin folder.

#!/bin/bash

TARGET=osx-darwin

echo "### Building BennuGD Core ###"

cd core
chmod a+x configure

# Patch Makefile.in's to build .dylib's instead of .so's
FILES="bgdrtm/src/Makefile.in
bgdrtm/src/Makefile.am"
for i in $FILES; do
    sed -i -e 's/-module/-shared/g' $i
done

FILES="bgdi/src/Makefile.in
bgdi/src/Makefile.am"
for i in $FILES; do
    sed -i -e 's/-lbgdrtm/-lbgdrtm -lSDLmain -lSDL -Wl,-framework,Cocoa/g' $i
done

case $1 in
    release)
        CFLAGS="-arch i386 -I/opt/local/include" LDFLAGS="-arch i386 -L/opt/local/lib" ./configure && make clean && make
        ;;

    *)
        make
        ;;
esac
if [ $? -ne 0 ]; then
    echo "*** ABORT ***"
    exit 1
fi
cd -

echo "### Building BennuGD Modules ###"

cd modules
chmod a+x configure

# Patch Makefile.in's to build .dylib's instead of .so's
for i in *; do
    if [ -d $i ]; then
        sed -i -e 's/-module/-shared/g' $i/Makefile.in;
        sed -i -e 's/-module/-shared/g' $i/Makefile.am;
    fi;
done

case $1 in
    release)
        CFLAGS="-arch i386 -I/opt/local/include" LDFLAGS="-arch i386 -L/opt/local/lib" ./configure && make clean && make
        ;;

    *)
        make
        ;;
esac
if [ $? -ne 0 ]; then
    echo "*** ABORT ***"
    exit 1
fi
cd -

echo "### Building BennuGD Tools ###"

cd tools/moddesc
chmod a+x configure
case $1 in
    release)
        CFLAGS="-arch i386 -I/opt/local/include" LDFLAGS="-arch i386 -L/opt/local/lib" ./configure && make clean && make
        ;;

    *)
        make
        ;;
esac
if [ $? -ne 0 ]; then
    echo "*** ABORT ***"
    exit 1
fi
cd -

echo "### Copying files to bin folder ###"

mkdir -p bin/$TARGET 2>/dev/null
#cp 3rdparty/des-4.04b/libdes.so bin/$TARGET
cp core/bgdi/src/.libs/bgdi bin/$TARGET
cp core/bgdc/src/bgdc bin/$TARGET
cp core/bgdrtm/src/.libs/libbgdrtm.dylib bin/$TARGET
cp $(find modules -name '*.dylib') bin/$TARGET
cp tools/moddesc/moddesc bin/$TARGET

echo "### Build done! ###"

exit 0