Difference between revisions of "MG/Mac Compiling"

From MegaGlest
Jump to navigation Jump to search
(Swapped around packaging and running the game as testing before distribution is a desirable thing. another reason would be packaging is currently broken so should take a backseat)
Line 1: Line 1:
 
This page explains how to compile [[MegaGlest]] on a Mac computer.
 
This page explains how to compile [[MegaGlest]] on a Mac computer.
 +
  
 
==Prerequisites==
 
==Prerequisites==
* [http://developer.apple.com/technologies/xcode.html XCode]
+
* XCode (from App store)
* [http://www.cmake.org/cmake/resources/software.html CMake]
+
* Various 3rd party build dependencies, also GCC compiler (all from MacPorts)
* Various 3rd party build dependencies
+
 
* GCC (Optional, but may be needed to achieve stable network compatibility for multiplayer games)
 
  
 
=== Dependencies ===
 
=== Dependencies ===
  
 
Dependencies can be installed in two ways:
 
Dependencies can be installed in two ways:
* Retrieve the build dependencies / 3rd party libraries and extract the contents of the archive in your library directory ~/Library/Frameworks
+
 
or
 
 
* Install them using a 3rd party package manager like [https://www.macports.org/ MacPorts] or [http://www.finkproject.org/ Fink].
 
* Install them using a 3rd party package manager like [https://www.macports.org/ MacPorts] or [http://www.finkproject.org/ Fink].
  
In this example I show how to install the packages with MacPorts which will handle the install of dependencies, and there is a lot of them. Full dependency lists are available on [[MG/Linux Compiling|Linux Compiling]] or [[MG/FreeBSD Compiling|FreeBSD Compiling]] if you would like to install them manually.
+
In this example you'll see how to install the packages with MacPorts which will handle the install of dependencies. (Full dependency lists are available in [[MG/Linux Compiling|Linux Compiling]] section if something is missing and you would like to install them manually.)
 +
 
 +
  sudo port install git pkgconfig cmake libsdl lua jpeg libpng freetype ftgl libogg glew libvorbis cppunit fribidi miniupnpc VLC gcc49 wxWidgets-3.0
 +
If you have few possibilities, then always install latest stable version of the package (not beta or devel).
 +
 
 +
 
 +
or (alternative way):
 +
----
 +
 
 +
* Retrieve the build dependencies / 3rd party libraries and extract the contents of the archive in your library directory ~/Library/Frameworks
  
  sudo port install git cmake VLC-devel fribidi ftgl glew wxWidgets-2.8 wxgtk-2.8
 
  
 
=== Configuring Environment ===
 
=== Configuring Environment ===
Once wxwidgets is installed you will need to ensure '''wx-config''' is in your path. Add the following fragment to ''~/.profile'' or the configuration file appropriate to your shell.
+
Once wxwidgets is installed you will need to ensure '''wx-config''' is in your path (same situation with gcc).  
 +
 
 +
MacPorts have even nice way to do this:
 +
 
 +
example for wxwidgets:
 +
port select --list wxwidgets
 +
sudo port select --set wxwidgets wxWidgets-3.0
 +
 
 +
example for gcc:
 +
port select --list gcc
 +
sudo port select --set gcc gcc49
 +
 
  
 +
or (alternative way):
 +
----
 +
As an alternative you can add the following fragment to ''~/.profile'' or the configuration file appropriate to your shell.
 
  # Add wx-config to path for cmake
 
  # Add wx-config to path for cmake
 
  export PATH=$PATH:/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxGTK/2.8/bin/
 
  export PATH=$PATH:/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxGTK/2.8/bin/
  
 
Once that has been added you will need to source the configuration file again to pick up the new settings
 
Once that has been added you will need to source the configuration file again to pick up the new settings
 +
source ~/.profile
  
source ~/.profile
 
  
 
== Preparing to compile ==
 
== Preparing to compile ==
  
However you choose to compile you will need to use [[MG/Getting_The_Code|''Git to check out'']] the MegaGlest source code ready for building.
+
Before compilation you will need to use [[MG/Getting_The_Code|''Git to check out'']] the MegaGlest source code ready for building.
 +
 
  
 
==Compiling==
 
==Compiling==
This can be done in two ways: Using an XCode project or GNU Make  
+
This can be done in two ways: Using an XCode project or GNU Make, but because MG should be compiled by gcc then classic cmake>make is best for this task and we have script for this job.
 +
 
 +
(''Recommended scripted way'')
 +
cd mk/macosx
 +
./build-mg.sh
 +
 
 +
== Running the game ==
 +
./megaglest
 +
 
 +
 
 +
== Packaging ==
 +
When game is compiled you can choose to run it directly from repository (see the previous section) or package it for yourself (and also for others).
 +
cd mk/macosx
 +
./make-release-archives.sh
  
If you change between methods (and if you want to be extra sure your changes are being made between runs) this command will remove previous run/s ouput.
+
This script ^ produces 2 type of packages '.zip' and '.dmg'.  
  rm -rf Makefile CMakeCache.txt MegaGlest.xcodeproj/
 
  
=== XCode project ===
+
Dmg image is more preferred but remember one important and simple thing, this package is (and will be probably always) produced by "unidentified developer" and you will see security warning about this. It is normal and you usually need a root password to be able to launch such package (if you need more details search "in the google" for something like: mac how open from unidentified developer). If this is a serious problem for you then just .zip package is better for you.
  
Generate the XCode project
+
Zip archive is a bit less common (old standard) but on this case you will not see any security warnings. From archive you can easily launch game because OS know this type of archive, but installation is just a bit more difficult because you have to 'manually' find the "/Applications" folder and simply drag an "MegaGlest.app" there.
cmake -GXcode -DWANT_DEV_OUTPATH=ON
 
  
Build everything for Release or Debug (This is case sensitive).
 
xcodebuild -configuration Release
 
  
=== GNU Make ===
+
== Packaging binary archive ==
Generate the Makefile
 
  cmake -G"Unix Makefiles" -DWANT_DEV_OUTPATH=ON
 
  
Build using gnumake
+
For releases but also for development snapshots you should make also binary archive.
  gnumake
+
  cd mk/macosx
 +
./make-binary-archive.sh
  
== Running the game ==
+
This package is helpful for games based on MG engine (binary for release) and for tests how game works on the Mac.
Before running make sure you move the megaglest binaries to mk/macosx and copy glest-dev.ini in to the same directory as the binaries. When moving the binaries they wil end up in different locations depending on how they were built - gnumake will put them in data/glest_game while Xcode will put them under a Release or Debug directory depending on the build style selected.
 
  mv data/glest_game/megaglest* mk/macosx/
 
  cp mk/linux/*.ini mk/macosx/
 
  
Run it with
 
  open -F ./mk/macosx/megaglest
 
  
== Packaging ==
+
----
Once all the compilation is done you can choose to run the game directly (see next section) or package it for others.
 
  
CURRENTLY BROKEN! Making this function is a work in progress!
 
  
This command will generate the installer
+
For CI you should consider sequence like
  cpack -C CPackConfig.cmake
+
  cd mk/macosx
 +
./build-mg.sh && ./make-binary-archive.sh
  
You should have a megaglest-#.dmg file in your current directory. You can install this and play it.
+
because this will produce more verbose and helpful output.
  
 
==See Also==
 
==See Also==

Revision as of 20:17, 24 March 2015

This page explains how to compile MegaGlest on a Mac computer.


Prerequisites

  • XCode (from App store)
  • Various 3rd party build dependencies, also GCC compiler (all from MacPorts)


Dependencies

Dependencies can be installed in two ways:

  • Install them using a 3rd party package manager like MacPorts or Fink.

In this example you'll see how to install the packages with MacPorts which will handle the install of dependencies. (Full dependency lists are available in Linux Compiling section if something is missing and you would like to install them manually.)

 sudo port install git pkgconfig cmake libsdl lua jpeg libpng freetype ftgl libogg glew libvorbis cppunit fribidi miniupnpc VLC gcc49 wxWidgets-3.0

If you have few possibilities, then always install latest stable version of the package (not beta or devel).


or (alternative way):


  • Retrieve the build dependencies / 3rd party libraries and extract the contents of the archive in your library directory ~/Library/Frameworks


Configuring Environment

Once wxwidgets is installed you will need to ensure wx-config is in your path (same situation with gcc).

MacPorts have even nice way to do this:

example for wxwidgets:

port select --list wxwidgets
sudo port select --set wxwidgets wxWidgets-3.0

example for gcc:

port select --list gcc
sudo port select --set gcc gcc49


or (alternative way):


As an alternative you can add the following fragment to ~/.profile or the configuration file appropriate to your shell.

# Add wx-config to path for cmake
export PATH=$PATH:/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxGTK/2.8/bin/

Once that has been added you will need to source the configuration file again to pick up the new settings

source ~/.profile


Preparing to compile

Before compilation you will need to use Git to check out the MegaGlest source code ready for building.


Compiling

This can be done in two ways: Using an XCode project or GNU Make, but because MG should be compiled by gcc then classic cmake>make is best for this task and we have script for this job.

(Recommended scripted way)

cd mk/macosx
./build-mg.sh

Running the game

./megaglest


Packaging

When game is compiled you can choose to run it directly from repository (see the previous section) or package it for yourself (and also for others).

cd mk/macosx
./make-release-archives.sh

This script ^ produces 2 type of packages '.zip' and '.dmg'.

Dmg image is more preferred but remember one important and simple thing, this package is (and will be probably always) produced by "unidentified developer" and you will see security warning about this. It is normal and you usually need a root password to be able to launch such package (if you need more details search "in the google" for something like: mac how open from unidentified developer). If this is a serious problem for you then just .zip package is better for you.

Zip archive is a bit less common (old standard) but on this case you will not see any security warnings. From archive you can easily launch game because OS know this type of archive, but installation is just a bit more difficult because you have to 'manually' find the "/Applications" folder and simply drag an "MegaGlest.app" there.


Packaging binary archive

For releases but also for development snapshots you should make also binary archive.

cd mk/macosx
./make-binary-archive.sh

This package is helpful for games based on MG engine (binary for release) and for tests how game works on the Mac.




For CI you should consider sequence like

cd mk/macosx
./build-mg.sh && ./make-binary-archive.sh

because this will produce more verbose and helpful output.

See Also