OSX compilation instructions

Started by josebita, December 08, 2012, 01:07:01 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

josebita


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.

       
  • Install Xcode
  • Installl macports
  • Open the Terminal program
  • Run the following program in your terminal:
    sudo port install libsdl +no_x11 +universal libsdl_mixer +universal zlib +universal libpng +universal
    (this'll take a while)
  • Download the BennuGD source code by running the following command in your terminal:
    svn co https://bennugd.svn.sourceforge.net/svnroot/bennugd bennugd
  • Copy the script included below into a file named "build-osx.sh"
  • Edit core/bgdi/src/main.c and in line 37 add:
    #include <SDL/SDL.h>
  • Run the following command in the folder with the BennuGD source in your terminal:
    cd bennugd
    chmod a+x build-osx.sh
    ./build-osx.sh release
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