Compiling for OS X
This guide is for compiling TPT on OS X. It should work on all OS X versions before Mavericks (OS X 10.9). It does not work on OS X 10.10 (Yosemite), 10.11 (El Capitan), or 10.12 (Sierra).
If there are problems, try posting your errors on the development help section of the forums, or coming onto irc.
This step is optional, if you don't want to install Xcode (very large, 3 GB), then instead follow the section "Installing the command line tools". You'll probably want another IDE to edit the code with if you don't use Xcode.
Install and open Xcode. Go to Xcode -> Preferences and click on Downloads. Install "Command Line Tools"
Installing the command-line tools
If you don't want to install Xcode due to the size or other reasons, follow this section instead. If you already have Xcode and the command line tools, skip ahead.
Option #1: Homebrew
Install Homebrew - this will give you easy access to each of the libraries below. You can then install almost all the necessary tools and libraries with it:
brew install fftw scons
You still need to install SDL and Lua the old way!
Option #2: Manual library installation
Download scons and unzip it. Go into the terminal, and type in
(you can use tab to complete a folder name so you don't have to type it all out). Next type
sudo python setup.py install. The terminal will ask you for your password. Note that you can not see your password while you are typing it in. You now have scons installed. Keep the terminal open for later.
Download the fftw3 source. Double click to extract it, then go back to the terminal and type
cd ../fftw-3.3.4/. Once in the fftw folder, type
./configure && make . Some different options may be needed to make it compile (I used a lot) but maybe this works.
Download the lua source. Double click to extract it, then go back to the terminal and type
cd ../lua-5.1.5/. Once in the lua folder, type
make macosx and then
sudo make install. The lua library is now installed.
Note: you still need to do this if you used Homebrew to install the other libraries!
Download the SDL framework. Open the freshly downloaded DMG file and drag SDL.Framework to the folder
Getting TPT source code
Make a new folder in your Documents called "TPT" - this will become your project directory for all the TPT source code. We'll now download the entire commit history to that folder - this will let you add your own commits, creating your unique code project.
cd ~/Documents/TPT to move to the project directory, then
git clone https://github.com/simtr/The-Powder-Toy.git . to clone all the history. The dot at the end means that we won't make a new subdirectory inside the TPT project directory.
At the end of this we have a fully functional environment to build, as well as a local copy of the entire project. Great job! :D
This is the part you've been waiting for - type
scons into the terminal and press enter. The script will check if your environment is alright (it is) and then it'll start compiling each of the source code files.
For a list of all the options you can give to scons, see Scons_command_line_flags
If it compiled without errors, you will find a file called
powder64-x in the build folder. Double click it and run it.
Congrats, you have compiled the source code and have made a OS X application.
This was written by Candunc, rewritten by jmeyer2k, and fixed again by jacob1, and cleaned up by boxmein. Thanks to the editors on the Mac OS X compile page, and thanks to people at Mac Rumors and Ximon to help me find out various errors.
I hope this helps future users become Mac Compilers and push TPT to Mac users!