I use the following shell script to build GameMaker on Mac OS X...

Code:
#!/bin/sh

echo "Deleting All objs from previous compilation"
cd ~/alienbrainWork/GameMakerMAC/Game\ Maker\ 7/Mac/YoYo70
cd objs/
rm *
cd ..

Processor="`uname -m`"
Kernel="`uname -s`"

echo "Building for...."
echo "Kernel : $Kernel"
echo "Processor : $Processor"

Target=""

echo "Which Processor would you like to"
read -p "target ( i386/powerpc/arm ) ? " Target

GMode=""

echo "Would you like to compile for"
read -p "2D or 3D mode ( 2/3 ) ? " GMode

case $Kernel in
  "Darwin")
    case $Processor in
      "i386")gui="carbon"; compiledunits="i386-darwin"; linkedfiles="-k-framework -kcarbon -k-framework -kcocoa -k-framework -ksdl -k-framework -ksdl_mixer"; entrypoint="-XMSDL_main"; exepath="./YoYo70"; compilerpath="/usr/local/bin";localshare="local/share";targetunits="$Target-darwin";;
      
      "Power Macintosh")gui="carbon"; compiledunits="powerpc-darwin"; linkedfiles="-k-framework -kcarbon -k-framework -kcocoa -k-framework -ksdl -k-framework -ksdl_mixer"; entrypoint="-XMSDL_main"; exepath="./YoYo70"; compilerpath="/usr/local/bin";localshare="local/share";targetunits="$Target-darwin";;
    esac;;
  
  "Linux")
    case $Processor in
      "i386")gui="gtk"; compiledunits="i386-linux"; linkedfiles="";entrypoint=""; exepath="./YoYo70";compilerpath="/usr/bin";localshare="local/share";targetunits="$Target-darwin";;
      
      "i686")gui="gtk"; compiledunits="i386-linux"; linkedfiles="";entrypoint=""; exepath="./YoYo70";compilerpath="/usr/bin";localshare="local/share";targetunits="$Target-darwin";;
    esac;;
esac

case $GMode in
  "2")graphicsmode="";;
  "3")graphicsmode="OPENGL";;
esac

$compilerpath/fpc YoYo70.lpr -S2dg -Os3 -Xs -XX $linkedfiles -WG -vewnhi -l -Fl/usr/lib/ -Fl/usr/X11R6/lib/ -Fl/sw/lib -Fu/usr/$localshare/lazarus/lcl/units/$compiledunits/ -Fu/usr/$localshare/lazarus/lcl/units/$compiledunits/$gui/ -Fu/usr/$localshare/lazarus/packager/units/$compiledunits/ -Fu. -FUobjs/ -o"$exepath-$Processor" $entrypoint -dLCL -dLCL$gui -dYOYO70 -d$graphicsmode

cd objs/
rm *
cd ..

$compilerpath/fpc YoYo70.lpr -P$Target -S2dg -Os3 -Xs -XX $linkedfiles -WG -vewnhi -l -Fl/usr/lib/ -Fl/usr/X11R6/lib/ -Fl/sw/lib -Fu/usr/$localshare/lazarus/lcl/units/$targetunits/ -Fu/usr/$localshare/lazarus/lcl/units/$targetunits/$gui/ -Fu/usr/$localshare/lazarus/packager/units/$targetunits/ -Fu. -FUobjs/ -o"$exepath-$Target" $entrypoint -dLCL -dLCL$gui -dYOYO70 -d$graphicsmode

case $Kernel in
  "Darwin")lipo -create "$exepath-$Processor" "$exepath-$Target" -output "$exepath";;
esac

# cd YoYo70.app/Contents/MacOS/
rm "$exepath-$Processor"
rm "$exepath-$Target"
# cd ../../../

echo "Deleting All objs from previous compilation"
cd objs/
rm *
cd ..
This shell script should also work on Linux as well.

Amend as appropriate and if you have any questions, don't hesitate to ask.