This document contains instructions for how to build the desktop version of Golly. Contents
How to install wxWidgets How to install wxWidgetsIf you want to build Golly from source code then you'll have to install wxWidgets first. Visit http://www.wxwidgets.org/downloads and grab the appropriate source archive for your platform:
Golly should compile with wxWidgets 2.8.0 or later, but it's best to use the latest version. Mac users should get 2.9 or later (this is necessary for a 64-bit Cocoa build). On WindowsIf you've installed wxWidgets to (say) C:\wxWidgets then, from a DOS or Visual Studio command prompt: cd \wxWidgets\build\msw nmake -f makefile.vc BUILD=release RUNTIME_LIBS=static UNICODE=1 DEBUG_INFO=0 DEBUG_FLAG=0On 64-bit Windows add TARGET_CPU=AMD64 to the above nmake command. On Mac OS XUnpack the wxWidgets source archive wherever you like, start up Terminal and type these commands (using the correct version number): cd /path/to/wxWidgets-2.9.4 mkdir build-osx cd build-osx ../configure --with-osx_cocoa --disable-shared --enable-unicode make If you plan to build Golly using CMake (see below) then also do "sudo make install". On LinuxUnpack the wxGTK source archive wherever you like, start up a terminal session and type these commands (using the correct version number): cd /path/to/wxGTK-2.8.12 mkdir build-gtk cd build-gtk ../configure --with-gtk --disable-shared --enable-unicode make sudo make install sudo ldconfig This installs the wx libraries in a suitable directory. It also installs the wx-config program which will be called by makefile-gtk to set the appropriate compile and link options for building Golly. How to install Perl and PythonGolly uses Perl and Python for scripting, so you'll need to make sure both are installed. Mac OS X users don't have to do anything because Perl and Python are already installed. If you are running Linux, you probably have Perl installed. Type "perl -v" at the command line to print out the version. Golly's code should compile happily with Perl 5.10.x or later, but support for interpreter threads is required.
Windows users are advised to download the ActivePerl installer from
Windows and Linux users can download a Python installer from How to build GollyOnce wxWidgets, Perl and Python are installed, building Golly should be relatively easy: On WindowsFirst, locate local-win-template.mk in the gui-wx folder and copy it to a new file called local-win.mk. This file is included by makefile-win. Edit local-win.mk and specify where wxWidgets is installed by changing the WX_DIR path near the start of the file. Also make sure WX_RELEASE specifies the first two digits of your wxWidgets version. The headers for Perl and Python must also be included, so change the paths for PERL_INCLUDE and PYTHON_INCLUDE if necessary. Now you're ready to build Golly. On 32-bit Windows (from a DOS or Visual Studio command prompt): cd \path\to\golly\gui-wx nmake -f makefile-win BUILD=release RUNTIME_LIBS=static UNICODE=1 DEBUG_INFO=0 DEBUG_FLAG=0 On 64-bit Windows add TARGET_CPU=AMD64 to the above nmake command. On Mac OS XGo to the gui-wx folder and make a copy of makefile-mac called makefile. Edit makefile and specify where wxWidgets is installed by changing the WX_DIR path near the start of the file. Also make sure WX_RELEASE specifies the first two digits of your wxWidgets version. On Mac OS 10.6 or later you can then build a 64-bit Cocoa version of Golly by opening a Terminal window and doing: cd /path/to/golly/gui-wx make On LinuxYou might need to add some development packages first. For example, from a default Ubuntu install (at the time of writing) you will need to install the following packages: libgtk2.0-dev, python2.6-dev (for GTK and Python respectively). Open a terminal window and build the golly executable by doing: cd /path/to/golly/gui-wx make -f makefile-gtk Note that the CXXFLAGS and LDFLAGS environmental variables may be used to append to (and override) the package default flags. Additionally, GOLLYDIR specifies an absolute directory path to look for the application data files. For system-wide installation, it probably makes sense to set GOLLYDIR to /usr/share/golly and install the Help, Patterns, Scripts and Rules directories in there. Aternative methods for building Golly are also available, as discussed in the following two sections. Building Golly using configureGolly can be built using the standard GNU build tools. If you obtained the Golly source code from the Git repository instead of a source release, you need to generate the configure script first: cd /path/to/golly/gui-wx/configure ./autogen.sh This requires that autoconf, automake and Perl 5.x are installed. The configure script offers various options to customize building and installation. For an overview of the available options, run: ./configure --help Run the configure script to create an appropriate Makefile for your operating system and then run make to build Golly. For example, for a system-wide installation, you could do this: cd /path/to/golly/gui-wx/configure ./configure make make install Building Golly using CMakeThe CMakeLists.txt file included in the gui-wx directory allows Golly to be built using CMake. Visit http://www.cmake.org to download a suitable installer for your operating system. Once CMake is installed, you can build Golly using these commands: cd /path/to/golly/gui-wx (location of CMakeLists.txt) mkdir cmakedir (use any name for this subdirectory) cd cmakedir cmake .. make (or nmake on Windows) CMake also comes with a GUI application if you'd prefer not to use the command line. Some notes:
How to build bgollyThe above make/nmake commands will also create bgolly, a simple "batch mode" version of Golly without any GUI. To build bgolly separately, just specify bgolly as the target of the make/nmake command. For example, on Linux: make -f makefile-gtk bgolly You don't need to install wxWidgets, Perl or Python to build bgolly. Source code road mapIf you'd like to modify Golly then the following information should help you get started. Directory structureGolly's source code can be downloaded from Sourceforge as a Git repository or as a .tar.gz file. You should see the following directories:cmdline
docs
gollybase
gui-android
gui-common
gui-ios
gui-wx
Help
Patterns
Rules
Scripts
Note that the executables (Golly and bgolly) are created in the same location as the above directories. This means you can test a new Golly build without having to copy it somewhere else because the required directories (Help, Patterns, Rules and Scripts) are in the correct location. High-level GUI codeThe desktop version of Golly uses wxWidgets to implement the graphical user interface. All the GUI code is stored in the gui-wx directory in a number of wx* files. Each module is described in (roughly) top-down order, and some key routines are mentioned: wxgolly.*
GollyApp::OnInit() is where it all starts. wxmain.*
MainFrame::OnMenu() handles all menu commands. MainFrame::UpdateEverything() updates all parts of the GUI. wxfile.cpp
MainFrame::NewPattern() creates a new, empty universe. MainFrame::LoadPattern() reads in a pattern file. wxcontrol.cpp
MainFrame::GeneratePattern() runs the current pattern. MainFrame::ChangeAlgorithm() switches to a new algorithm. wxtimeline.*
CreateTimelineBar() creates timeline bar below the viewport window. StartStopRecording() starts or stops recording a timeline. DeleteTimeline() deletes an existing timeline. wxrule.*
ChangeRule() opens the Set Rule dialog. wxedit.*
CreateEditBar() creates the edit bar above the viewport window. ToggleEditBar() shows/hides the edit bar. wxselect.*
Selection::CopyToClipboard() copies the selection to the clipboard. Selection::RandomFill() randomly fills the current selection. Selection::Rotate() rotates the current selection. Selection::Flip() flips the current selection. wxview.*
PatternView::ProcessKey() processes keyboard shortcuts. PatternView::ProcessClick() processes mouse clicks. wxrender.*
DrawView() draws the pattern, grid lines, selection, etc. wxalgos.*
InitAlgorithms() initializes all algorithms and algoinfo data. CreateNewUniverse() creates a new universe of given type. wxlayer.*
AddLayer() adds a new, empty layer. DeleteLayer() deletes the current layer. SetLayerColors() lets user change the current layer's colors. wxundo.*
UndoRedo::RememberCellChanges() saves cell state changes. UndoRedo::UndoChange() undoes a recent change. UndoRedo::RedoChange() redoes an undone change. wxstatus.*
StatusBar::DrawStatusBar() shows gen count, pop count, etc. StatusBar::DisplayMessage() shows message in bottom line. wxhelp.*
ShowHelp() displays a given .html file. wxinfo.*
ShowInfo() displays the comments in a given pattern file. wxscript.*
RunScript() runs a given script file. wxperl.*
RunPerlScript() runs a given .pl file. wxpython.*
RunPythonScript() runs a given .py file. wxprefs.*
GetPrefs() loads data from GollyPrefs file. SavePrefs() writes data to GollyPrefs file. ChangePrefs() opens the Preferences dialog. wxutils.*
Warning() displays message in modal dialog. Fatal() displays message and exits the app. Low-level base codeThe gollybase directory contains low-level code used by all the various clients (desktop Golly, bgolly, and the Android/iPad versions): platform.h
lifealgo.*
lifealgo::setcell() sets given cell to given state. lifealgo::getcell() gets state of given cell. lifealgo::nextcell() finds next live cell in current row. lifealgo::step() advances pattern by current increment. lifealgo::fit() fits pattern within given viewport. lifealgo::draw() renders pattern in given viewport. liferules.*
liferules::setrule() parses and validates a given rule string. liferules::getrule() returns the current rule in canonical form. lifepoll.*
lifepoll::checkevents() processes any pending events. viewport.*
viewport::zoom() zooms into a given location. viewport::unzoom() zooms out from a given location. viewport::setmag() sets the magnification. viewport::move() scrolls view by given number of pixels. liferender.*
liferender::killrect() fills an area with the dead cell color. liferender::pixblit() draws an area with at least one live cell. qlifealgo.*
hlifealgo.*
ghashbase.*
generationsalgo.*
jvnalgo.*
ruleloaderalgo.*
ruletable_algo.*
ruletreealgo.*
qlifedraw.cpp
hlifedraw.cpp
ghashdraw.cpp
readpattern.*
readpattern() loads a pattern into the given universe. readcomments() extracts comments from the given file. writepattern.*
writepattern() saves the pattern in a specified format. bigint.*
util.*
warning() displays error message. fatal() displays error message and exits. Have fun, and please let us know if you make any changes!
Andrew Trevorrow (andrew@trevorrow.com) |