Open main menu

Difference between revisions of "Compiling ScummVM/macOS"

1,197 bytes added ,  22:01, 20 February 2019
m
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Compiling ScummVM under OS X ==
== Compiling ScummVM under macOS ==


Compiling ScummVM under OS X requires setting up the build environment first, and then compiling the sources either via command line, or the XCode GUI
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 ==
== Things needed ==


=== XCode ===
=== Xcode ===
This can be installed from the Apple Store
This can be installed from the [https://itunes.apple.com/us/app/xcode/id497799835?mt=12 Mac App Store].


=== XCode command line tools ===
=== Xcode command line tools ===
After installing XCode, open a terminal and type
After installing Xcode, open a terminal and type:
<source lang="bash">
 
<syntaxhighlight lang="bash">
xcode-select --install
xcode-select --install
</source>
</syntaxhighlight>


=== Package manager ===
=== Package manager ===
Getting the required libraries is easier with a package manager. The three most well-known ones are [https://www.macports.org/ MacPorts], [http://brew.sh/ Homebrew] and [http://www.finkproject.org/ Fink].
Getting the required libraries is easier with a package manager. The three most well-known ones are [http://brew.sh/ Homebrew], [https://www.macports.org/ MacPorts], and [http://www.finkproject.org/ Fink].


==== 1. MacPorts ====
==== 1. Homebrew (recommended) ====
Get the MacPorts installer for your OS X version from the [https://www.macports.org/install.php MacPorts installation page]
Install Homebrew by pasting the following into a terminal:


==== 2. Homebrew ====
<syntaxhighlight lang="bash">
You can install homebrew by pasting the following into a terminal:
<source 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 ====
Install MacPorts by downloading and running the installer from the [https://www.macports.org/install.php MacPorts installation page].


==== 3. Fink ====
==== 3. Fink ====
You can install Fink by downloading and building the source from the [http://www.finkproject.org/download/srcdist.php Fink Source Release] page
Install Fink by downloading and building the source from the [http://www.finkproject.org/download/srcdist.php Fink Source Release] page.


== Obtaining the required libraries ==
== 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:
After downloading the Xcode command line tools and a package manager, enter the following command to install all the required libraries:


=== 1. MacPorts ===
=== 1. Homebrew ===
<source lang="bash">
<syntaxhighlight lang="bash">
sudo port install libsdl libjpeg-turbo libmpeg2 libogg libvorbis flac libmad libpng libtheora faad2 freetype zlib fluidsynth
brew install sdl2 sdl2_net jpeg-turbo libmpeg2 libogg libvorbis flac libmad libpng theora faad2 a52dec freetype lzlib fluid-synth
</source>
</syntaxhighlight>


=== 2. Homebrew ===
=== 2. MacPorts ===
<source lang="bash">
<syntaxhighlight lang="bash">
brew install sdl jpeg-turbo libmpeg2 libogg libvorbis flac libmad libpng theora faad2 freetype lzlib fluid-synth
sudo port install libsdl2 libsdl2_net libjpeg-turbo libmpeg2 libogg libvorbis flac libmad libpng libtheora faad2 a52dec freetype zlib fluidsynth
</source>
</syntaxhighlight>


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


=== 4. Manual compilation ===
=== 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.
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.
* Required:
* Required:
** [https://www.libsdl.org SDL 1.2 or SDL 2]
** [https://www.libsdl.org SDL 2 or 1.2] (prefer SDL 2 unless you are on a very old version of MacOS X)
*Optional:
*Optional:
** [http://zlib.net zlib]
** [http://zlib.net zlib]
Line 60: Line 62:
** [http://libmpeg2.sourceforge.net mpeg2]
** [http://libmpeg2.sourceforge.net mpeg2]
** [http://www.audiocoding.com/faad2.html FAAD2]  
** [http://www.audiocoding.com/faad2.html FAAD2]  
** [http://liba52.sourceforge.net liba52]
** [https://theora.org Theora]
** [https://theora.org Theora]
** [https://www.libsdl.org/projects/SDL_net/ SDL_net 2] or [https://www.libsdl.org/projects/SDL_net/release-1.2.html 1.2] (use same version as SDL)
** For Freetype
** For Freetype
*** [http://www.bzip.org bzip2]
*** [http://www.bzip.org bzip2]
Line 72: Line 76:


All the libraries are compiled and installed in the same way:
All the libraries are compiled and installed in the same way:
<source lang="bash">
<syntaxhighlight lang="bash">
cd thelib-src
cd thelib-src
./configure --prefix=/path/to/install
./configure --prefix=/path/to/install
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.
<source lang="bash">
<syntaxhighlight lang="bash">
cd thelib-src
cd thelib-src
./configure
./configure
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:
<source lang="bash">
<syntaxhighlight lang="bash">
export LDFLAGS="-arch i386 -mmacosx-version-min=10.5"
export LDFLAGS="-arch i386 -mmacosx-version-min=10.5"
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:
<source lang="bash">
<syntaxhighlight lang="bash">
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 123: Line 127:
=== Configuring ScummVM ===
=== Configuring ScummVM ===
Run the configure script:
Run the configure script:
<source 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.
For a list of optional features (eg additional, not yet enabled engines) run:
For a list of optional features (eg additional, not yet enabled engines) run:
<source 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 141: Line 145:


=== Compiling ScummVM ===
=== Compiling ScummVM ===
Run "make clean" and then "make"
Just run make (with -j to compile several files in parallel). For example
<syntaxhighlight lang="bash">
make -j4
</syntaxhighlight>
 
To recompile everything and not just the modified files:
<syntaxhighlight lang="bash">
make clean
make -j4
</syntaxhighlight>


=== Installing ScummVM ===
=== Installing ScummVM ===
You can run ScummVM from the command line in the build directory:
You can run ScummVM from the command line in the build directory:
<source 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:
<source 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.


== Compiling ScummVM via the XCode GUI ==
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.


=== Creating an XCode project ===
== Compiling ScummVM via the Xcode GUI ==
 
=== Creating an Xcode project ===
* Compile '''create_project''' inside devtools/create_project
* Compile '''create_project''' inside devtools/create_project
* Copy the generated create_project tool in the ScummVM root folder
<syntaxhighlight lang="bash">
* Run the following:
make devtools/create_project
<source lang="bash">
</syntaxhighlight>
./create_project . --xcode --build-events --disable-nasm
Or alternatively you can use the Xcode project in devtools/create_project/xcode. Open it in Xcode or run the following command:
</source>
<syntaxhighlight lang="bash">
cd devtools/create_project/xcode; xcodebuild
</syntaxhighlight>
* Run create_project '''from the root ScummVM directory''':
<syntaxhighlight lang="bash">
./devtools/create_project/create_project . --xcode
</syntaxhighlight>
 
Note that `create_project` accepts most of the same flags that `configure` accepts.


=== Build the XCode project ===
=== Build the Xcode project ===
* Open and build the XCode project
* Open the Xcode project
* Note that you may need to change the project architecture. Click on the ScummVM project, and change "Architectures" to "64-bit Intel (x86_64)"
* Go to Product -> Scheme and set the scheme to "ScummVM-macOS"  
* If you're using XCode 5 or newer, you will also need to go to Product -> Scheme -> Edit Scheme -> Run tab -> Options tab and uncheck "Allow debugging when using document Versions Browser", otherwise the invalid "nsdocumentrevisionsdebugmode" option will be passed to the ScummVM executable by XCode
* 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 ==
== Further reading ==
* [https://github.com/scummvm/scummvm/blob/master/README#L2416 ScummVM README, Section 9.0]
* [https://github.com/scummvm/scummvm/blob/master/README.md#100-compiling ScummVM README, Section 10.0]