Downloading and Compiling under macOS: Difference between revisions

From Arx Libertatis Wiki
Jump to navigation Jump to search
m (Temporarily commented out the icon part)
Line 11: Line 11:
* <code>Xcode</code> (App Store or https://developer.apple.com/xcode/)
* <code>Xcode</code> (App Store or https://developer.apple.com/xcode/)
* <code>CMake</code> (http://www.cmake.org/)
* <code>CMake</code> (http://www.cmake.org/)
And either one of these:
Optionally you can use either one of these to install the dependencies:
* <code>homebrew</code> (http://brew.sh/)
* <code>homebrew</code> (http://brew.sh/)
* <code>MacPorts</code> (http://www.macports.org/)
* <code>MacPorts</code> (http://www.macports.org/)
Line 22: Line 22:
* <code>FreeType</code> 2.3.0 or newer (http://www.freetype.org/)
* <code>FreeType</code> 2.3.0 or newer (http://www.freetype.org/)
<code>OpenGL</code> and <code>OpenAL</code> are already bundled with Xcode.
<code>OpenGL</code> and <code>OpenAL</code> are already bundled with Xcode.
You can also optionally install <code>git</code> (http://git-scm.com/) if you want to compile the development version.
You can also install <code>git</code> (http://git-scm.com/) if you want to compile the development version.


=== Example ===
=== Example ===
Line 48: Line 48:
  sudo port install libsdl glew zlib boost glm freetype
  sudo port install libsdl glew zlib boost glm freetype
*NOTE: These packages take a long time to build. Do not be discouraged if it seems like nothing is happening.
*NOTE: These packages take a long time to build. Do not be discouraged if it seems like nothing is happening.


== Getting the source code ==
== Getting the source code ==

Revision as of 23:41, 21 June 2014

ℹ️  This page describes compiling Arx Libertatis from source under Mac OS X and assumes some familiarity with the command-line. If you just want to play the game, it might be easier to grab a binary release or snapshot if available.

This page documents how to compile Arx Libertatis from https://github.com/arx/ArxLibertatis under Mac OS X.
There are also instructions available for Windows and Linux / FreeBSD

Specific instructions are given for a cleanly installed Lion 10.7.3 system, but the procedure should be similar for other versions.

Setting Up the Build Environment

To download and compile Arx Libertatis you will need the following tools:

Optionally you can use either one of these to install the dependencies:

Your system must have the following dependencies installed:

OpenGL and OpenAL are already bundled with Xcode. You can also install git (http://git-scm.com/) if you want to compile the development version.

Example

  • Download and install the latest version of Xcode from the App Store or from https://developer.apple.com/xcode/, depending on your OS version
  • Install command line tools from Xcode, in Preferences -> Download
  • Set the path to the Xcode folder:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

After installing Xcode you can either use homebrew or MacPorts to install the dependencies. Using homebrew is recommended because most of the dependencies are already bottled, that is, they will not have to be compiled.

  • NOTE: do not install both as they tend to generate issues when installed on the same system

homebrew

  • Install homebrew:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
  • Install the dependencies with homebrew:
brew install cmake sdl glew zlib boost glm freetype

MacPorts

sudo port install libsdl glew zlib boost glm freetype
  • NOTE: These packages take a long time to build. Do not be discouraged if it seems like nothing is happening.

Getting the source code

If you want to compile the development version, first install git with homebrew (brew install git) or from http://git-scm.com/.

  • WARNING: last time I tried the development version failed to compile, you should download the latest release instead.

There are several methods to get the Arx Libertatis source code - choose the one that suits you best:

Downloading a released version

The easiest way to get the AL source code is to download a versioned release. This will get you a reasonably up to date copy of the source code that has been tested to work.

Cloning the repository

If you want the absolute latest version of the Arx Libertatis development code and stay up to date, you can clone the AL source code repository. Beware that this will give you the current master development branch that we are actively working on. While the code in that branch should always work, it hasn't undergone any significant testing. If you just want to play the game, consider using a released version instead.

To clone the repository, type:

git clone git://github.com/arx/ArxLibertatis.git

This creates a directory called ArxLibertatis and downloads the current source code from github.

Later if you want to update your local copy of the source code, run

git pull

The git repository does not contain raster images for the icon and logo. These will be generated from scalable versions when building Arx Libertatis, but doing so requires additional dependencies (Inkscape, ImageMagick and OptiPNG). To avoid this, you can instead get the generated images from the ArxLibertatisData repo:

git clone --depth 1 git://github.com/arx/ArxLibertatisData.git

Downloading a snapshot

Alternatively you can download the current snapshot of the source code repository as a .zip or .tar.gz file and extract that:

This will give you the same code as cloning the repository, but won't let you update it without downloading everything again.

Compiling

First, cd to where you downloaded / extracted the AL source code (the directory containing the `CMakeLists.txt` file):

cd ArxLibertatis

Then create a build directory and run CMake to configure:

mkdir build && cd build && cmake ..

And now you should be able to compile with:

make

Finally, you can install the executable system-wide with:

sudo make install

Enter your account password at the prompt.


Running the executable

You can run the Arx Libertatis executable from the terminal:

arx

By default, the user directory for Arx on Mac is /Users/username/Library/Application Support/ArxLibertatis/

You will need to obtain a copy of the data files from a commercial copy of Arx Fatalis, or use the demo data files, put these in the directory mentioned above and you are ready to go! Run the file "arx" which is in the ArxLibertatis repository. The game will automatically change all used files to lower-case on the first start. If you want to run the game with read-only data you need to do this manually.

For running arx in a debugger, see Debugging

Creating an .app wrapper

If you want to have an icon you can pin on your dock or in your launchpad you can create a simple AppleScript to wrap the executable in an .app bundle.

  • First, determine where the arx executable is.
    • If you didn't make install figure out the path to the folder you built it to.
    • If you ran make install, use this to find out the position of the executable, then copy the output:
which arx
  • Open AppleScript Editor (it should be in Applications/Utilities/)
  • Assuming the path to arx is /usr/local/bin/arx, copy the following lines into the window:
to run
	do shell script "/usr/local/bin/arx"
end run

Replace /usr/local/bin/arx with the position of your executable if needed.

  • Save the script as an application.