Difference between revisions of "Compiling ScummVM/macOS"

From ScummVM :: Wiki
Jump to navigation Jump to search
m (Text replacement - "<source lang=" to "<syntaxhighlight lang=")
m (Text replacement - "</source>" to "</syntaxhighlight>")
Line 13: Line 13:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
xcode-select --install
xcode-select --install
</source>
</syntaxhighlight>


=== Package manager ===
=== Package manager ===
Line 23: Line 23:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
</source>
</syntaxhighlight>


==== 2. MacPorts ====
==== 2. MacPorts ====
Line 37: Line 37:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
brew install sdl2 sdl2_net jpeg-turbo libmpeg2 libogg libvorbis flac libmad libpng theora faad2 freetype lzlib fluid-synth
brew install sdl2 sdl2_net jpeg-turbo libmpeg2 libogg libvorbis flac libmad libpng theora faad2 freetype lzlib fluid-synth
</source>
</syntaxhighlight>


=== 2. MacPorts ===
=== 2. MacPorts ===
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sudo port install libsdl2 libsdl2_net libjpeg-turbo libmpeg2 libogg libvorbis flac libmad libpng libtheora faad2 freetype zlib fluidsynth
sudo port install libsdl2 libsdl2_net libjpeg-turbo libmpeg2 libogg libvorbis flac libmad libpng libtheora faad2 freetype zlib fluidsynth
</source>
</syntaxhighlight>


=== 3. Fink ===
=== 3. Fink ===
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
TODO
TODO
</source>
</syntaxhighlight>


=== 4. Manual compilation ===
=== 4. Manual compilation ===
Line 80: Line 80:
make
make
make install
make install
</source>
</syntaxhighlight>


The default installation path is /usr/local, but you will need admin privileges to install the libraries in this location.
The default installation path is /usr/local, but you will need admin privileges to install the libraries in this location.
Line 88: Line 88:
make
make
sudo make install
sudo make install
</source>
</syntaxhighlight>


If you want your compilation to be compatible with older system, use the -mmacosx-version-min flag (for example -mmacosx-version-min=10.5). To force compilation in 32 bits use -arch i386. You can do that by setting environment variables before compiling all the libraries and ScummVM:
If you want your compilation to be compatible with older system, use the -mmacosx-version-min flag (for example -mmacosx-version-min=10.5). To force compilation in 32 bits use -arch i386. You can do that by setting environment variables before compiling all the libraries and ScummVM:
Line 95: Line 95:
export CFLAGS="-arch i386 -mmacosx-version-min=10.5"
export CFLAGS="-arch i386 -mmacosx-version-min=10.5"
export CXXFLAGS="-arch i386 -mmacosx-version-min=10.5"
export CXXFLAGS="-arch i386 -mmacosx-version-min=10.5"
</source>
</syntaxhighlight>


bzip2 is an exception. There is no configure and you directly call make with options. For example:
bzip2 is an exception. There is no configure and you directly call make with options. For example:
Line 101: Line 101:
make CFLAGS="-arch i386 -mmacosx-version-min=10.5 -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64" LDFLAGS="-arch i386 -mmacosx-version-min=10.5"
make CFLAGS="-arch i386 -mmacosx-version-min=10.5 -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64" LDFLAGS="-arch i386 -mmacosx-version-min=10.5"
make install PREFIX=/Users/criezy/Dev/scummvm-releases/libs
make install PREFIX=/Users/criezy/Dev/scummvm-releases/libs
</source>
</syntaxhighlight>


If you plan to build the ScummVM app bundle, you will need to generate static libraries. For most of the libraries this is done by default, but for a few you need to specify you want static libraries when invoking configure. Here are suggested configure options for each library. If the library is not listed in the table below this means the default is fine.
If you plan to build the ScummVM app bundle, you will need to generate static libraries. For most of the libraries this is done by default, but for a few you need to specify you want static libraries when invoking configure. Here are suggested configure options for each library. If the library is not listed in the table below this means the default is fine.
Line 128: Line 128:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
./configure
./configure
</source>
</syntaxhighlight>


If no errors come up, you should be ready to compile ScummvM.
If no errors come up, you should be ready to compile ScummvM.
Line 134: Line 134:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
./configure --help
./configure --help
</source>
</syntaxhighlight>


Here is a list of some options you may want to use:
Here is a list of some options you may want to use:
Line 147: Line 147:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
make -j4
make -j4
</source>
</syntaxhighlight>


To recompile everything and not just the modified files:
To recompile everything and not just the modified files:
Line 153: Line 153:
make clean
make clean
make -j4
make -j4
</source>
</syntaxhighlight>


=== Installing ScummVM ===
=== Installing ScummVM ===
Line 159: Line 159:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
./scummvm
./scummvm
</source>
</syntaxhighlight>


You can also generate an application bundle and move this one anywhere you want:
You can also generate an application bundle and move this one anywhere you want:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
make bundle
make bundle
</source>
</syntaxhighlight>


Some features such as dock integration are only available if you build the bundle.
Some features such as dock integration are only available if you build the bundle.
Line 176: Line 176:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
make devtools/create_project
make devtools/create_project
</source>
</syntaxhighlight>
Or alternatively you can use the Xcode project in devtools/create_project/xcode. Open it in Xcode or run the following command:
Or alternatively you can use the Xcode project in devtools/create_project/xcode. Open it in Xcode or run the following command:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
cd devtools/create_project/xcode; xcodebuild
cd devtools/create_project/xcode; xcodebuild
</source>
</syntaxhighlight>
* Run create_project '''from the root ScummVM directory''':
* Run create_project '''from the root ScummVM directory''':
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
./devtools/create_project/create_project . --xcode
./devtools/create_project/create_project . --xcode
</source>
</syntaxhighlight>


Note that `create_project` accepts most of the same flags that `configure` accepts.
Note that `create_project` accepts most of the same flags that `configure` accepts.

Revision as of 15:16, 25 October 2018

Compiling ScummVM under macOS

Compiling ScummVM under macOS requires setting up the build environment first, and then compiling the sources either via command line, or the Xcode GUI.

Things needed

Xcode

This can be installed from the Mac App Store.

Xcode command line tools

After installing Xcode, open a terminal and type:

xcode-select --install

Package manager

Getting the required libraries is easier with a package manager. The three most well-known ones are Homebrew, MacPorts, and Fink.

1. Homebrew (recommended)

Install Homebrew by pasting the following into a terminal:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2. MacPorts

Install MacPorts by downloading and running the installer from the MacPorts installation page.

3. Fink

Install Fink by downloading and building the source from the Fink Source Release page.

Obtaining the required libraries

After downloading the Xcode command line tools and a package manager, enter the following command to install all the required libraries:

1. Homebrew

brew install sdl2 sdl2_net jpeg-turbo libmpeg2 libogg libvorbis flac libmad libpng theora faad2 freetype lzlib fluid-synth

2. MacPorts

sudo port install libsdl2 libsdl2_net libjpeg-turbo libmpeg2 libogg libvorbis flac libmad libpng libtheora faad2 freetype zlib fluidsynth

3. Fink

TODO

4. Manual compilation

Get the source code from the libraries. With this method you will not only need to get the libraries ScummVM uses directly, but also those they depend on.

All the libraries are compiled and installed in the same way:

cd thelib-src
./configure --prefix=/path/to/install
make
make install

The default installation path is /usr/local, but you will need admin privileges to install the libraries in this location.

cd thelib-src
./configure
make
sudo make install

If you want your compilation to be compatible with older system, use the -mmacosx-version-min flag (for example -mmacosx-version-min=10.5). To force compilation in 32 bits use -arch i386. You can do that by setting environment variables before compiling all the libraries and ScummVM:

export LDFLAGS="-arch i386 -mmacosx-version-min=10.5"
export CFLAGS="-arch i386 -mmacosx-version-min=10.5"
export CXXFLAGS="-arch i386 -mmacosx-version-min=10.5"

bzip2 is an exception. There is no configure and you directly call make with options. For example:

make CFLAGS="-arch i386 -mmacosx-version-min=10.5 -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64" LDFLAGS="-arch i386 -mmacosx-version-min=10.5"
make install PREFIX=/Users/criezy/Dev/scummvm-releases/libs

If you plan to build the ScummVM app bundle, you will need to generate static libraries. For most of the libraries this is done by default, but for a few you need to specify you want static libraries when invoking configure. Here are suggested configure options for each library. If the library is not listed in the table below this means the default is fine.

Library configure flags Comments
pkg-config --with-internal-glib
glib --enable-static
libmpeg2 --disable-sdl

Need to add -std=gnu89 to CFLAGS (for example 'export CFLAGS="-std=gnu89"' before invoking configure)

FLAC --enable-static --disable-asm-optimizations
Theora --disable-examples
  • Need to edit configure before running it to remove flag -fforce-addr
  • Examples do not compile with libpng 1.6

Compiling ScummVM via the command line

Configuring ScummVM

Run the configure script:

./configure

If no errors come up, you should be ready to compile ScummvM. For a list of optional features (eg additional, not yet enabled engines) run:

./configure --help

Here is a list of some options you may want to use:

  • --enable-all-engines or --enable-engine=foo,bar to enable unsupported engines (not compiled by default)
  • --with-staticlib=/path/to/install/dir if your libraries are not in a standard place (e.g. you compiled the libraries manually with a custom installation directory). This is only used when building the application bundle.
  • --enable-updates --with-sparkle-prefix=/path/to/sparkle to enable Sparkle (disabled by default). The path should be the path to the directory that contains the Sparkle.framework and not the path to the Sparkle.framework itself.

Note: If you want to use Sparkle, there are some additional steps to do such as setting up DSA signatures. See [1] for details. ScummVM expects to find the DSA public key in dist/macosx.dsa_pub.pem.

Compiling ScummVM

Just run make (with -j to compile several files in parallel). For example

make -j4

To recompile everything and not just the modified files:

make clean
make -j4

Installing ScummVM

You can run ScummVM from the command line in the build directory:

./scummvm

You can also generate an application bundle and move this one anywhere you want:

make bundle

Some features such as dock integration are only available if you build the bundle.

Also if you run scummvm from the command line, you will need to set the Theme path in the ScummVM options so that it finds the modern theme. The themes are in gui/themes/ in the source code repository.

Compiling ScummVM via the Xcode GUI

Creating an Xcode project

  • Compile create_project inside devtools/create_project
make devtools/create_project

Or alternatively you can use the Xcode project in devtools/create_project/xcode. Open it in Xcode or run the following command:

cd devtools/create_project/xcode; xcodebuild
  • Run create_project from the root ScummVM directory:
./devtools/create_project/create_project . --xcode

Note that `create_project` accepts most of the same flags that `configure` accepts.

Build the Xcode project

  • Open the Xcode project
  • Go to Product -> Scheme and set the scheme to "ScummVM-macOS"
  • Go to Product -> Scheme -> Edit Scheme -> Run tab -> Options tab and uncheck "Allow debugging when using document Versions Browser"
  • Build with Product -> Build or Product -> Run

Further reading