Open main menu

Difference between revisions of "Compiling ScummVM/macOS"

2,709 bytes added ,  11:34, 19 December 2023
→‎Manual compilation: added libvpx and libmikmod links
(→‎1. Homebrew: -- updated)
(→‎Manual compilation: added libvpx and libmikmod links)
 
(28 intermediate revisions by 4 users not shown)
Line 1: Line 1:
This page explains how to compile your own version of [[ScummVM]] for [[macOS]]. See also [[Compiling ScummVM/iPhone]] for iOS based devices.
== Compiling ScummVM under macOS ==
== Compiling ScummVM under macOS ==


Line 5: Line 7:
== Things needed ==
== Things needed ==


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


=== Xcode command line tools ===
=== 2. Xcode command line tools ===
After installing Xcode, open a terminal and type:
After installing Xcode, open a terminal and type:


Line 15: Line 17:
</syntaxhighlight>
</syntaxhighlight>


=== Package manager ===
=== 3. Package manager ===
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].
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. Homebrew (recommended) ====
==== Homebrew (recommended) ====
Install Homebrew by pasting the following into a terminal:
Install Homebrew by pasting the following into a terminal:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
</syntaxhighlight>
</syntaxhighlight>


==== 2. MacPorts ====
==== MacPorts ====
Install MacPorts by downloading and running the installer from the [https://www.macports.org/install.php MacPorts installation page].
Install MacPorts by downloading and running the installer from the [https://www.macports.org/install.php MacPorts installation page].
==== 3. Fink ====
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:
If you only want to build scummvm for your own use and are fine executing it from the command line, you can use a package manager ([[#Homebrew|method 1]] and [[#MacPorts_2|2 below]]) to get the required libraries. However those methods to not provide the static libraries needed to build a ScummVM.app bundle. If your goal is to build such a bundle you will need to download our libs package ([[#Download our libs package|method 3]]) or compile the libraries manually ([[#Manual compilation|method 4]]).


=== 1. Homebrew ===
=== Homebrew ===
After downloading the Xcode command line tools and installing Homebrew, enter the following command to install all the required libraries:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
brew install a52dec curl-openssl faad2 flac fluid-synth freetype jpeg-turbo libmad libmpeg2 libogg libpng libvorbis lzlib pkg-config sdl2 sdl2_net theora
brew install a52dec faad2 flac fluid-synth freetype fribidi mad libmpeg2 libogg libpng libvorbis sdl2 sdl2_net theora giflib zlib jpeg-turbo curl pkg-config pandoc libvpx libmikmod
</syntaxhighlight>
</syntaxhighlight>


=== 2. MacPorts ===
=== MacPorts ===
After downloading the Xcode command line tools and installing MacPorts, enter the following command to install all the required libraries:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sudo port install libsdl2 libsdl2_net libjpeg-turbo libmpeg2 libogg libvorbis flac libmad libpng libtheora faad2 a52dec freetype zlib fluidsynth
sudo port install libsdl2 libsdl2_net libjpeg-turbo libmpeg2 libogg libvorbis flac libmad libpng libtheora faad2 a52dec freetype zlib fluidsynth fribidi pandoc
</syntaxhighlight>
</syntaxhighlight>


=== 3. Fink ===
=== Download our libs package ===
* For Intel 32 bits (targets Mac OS X 10.6 or above): [https://downloads.scummvm.org/frs/build/scummvm-macosx-libs-i386.zip scummvm-macosx-libs-i386.zip]
* For Intel 64 bits (targets Mac OS X 10.9 or above): [https://downloads.scummvm.org/frs/build/scummvm-macosx-libs-x86_64.zip scummvm-macosx-libs-x86_64.zip]
* For Apple Silicon (targets macOS 11.0 or above): [https://downloads.scummvm.org/frs/build/scummvm-macosx-libs-arm64.zip scummvm-macosx-libs-arm64.zip]
 
Those packages are configured to be placed in /usr/local/. So you should for example have the following structure:
<pre>
/usr/local/bin
/usr/local/include
/usr/local/lib
/usr/local/share
</pre>
 
They also contain a relocate.sh script, which you can use if you place the package content in any other location.
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
TODO
./relocate.sh --from /usr/local --to /Users/FooBar/Documents/scummvm-libs
</syntaxhighlight>
</syntaxhighlight>
The script should be able to automatically determine the ''from'' and ''to'' paths, so they can be omitted in most cases.


=== 4. Manual compilation ===
If you place the content of the packages to a place other than /usr/local, you will need to specify the path to the libraries when you call '''configure''':
<syntaxhighlight lang="bash">
./configure --with-staticlib-prefix=/path/to/libs
</syntaxhighlight>
 
=== 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:
Line 57: Line 77:
** [http://www.ijg.org/ jpeg]
** [http://www.ijg.org/ jpeg]
** [http://www.libpng.org/pub/png/libpng.html libpng]
** [http://www.libpng.org/pub/png/libpng.html libpng]
** [http://giflib.sourceforge.net giflib] Use giflib 5.1.4 as versions 5.1.5 to 5.2.1 (the latest as of this note) do not compile on macOS. Alternatively see the patch in https://sourceforge.net/p/giflib/bugs/133/).
** [http://www.xiph.org/vorbis/ libogg and libvorbis]
** [http://www.xiph.org/vorbis/ libogg and libvorbis]
** [http://www.xiph.org/flac FLAC]
** [http://www.xiph.org/flac FLAC]
** [http://www.underbit.com/products/mad/ libmad]
** [http://www.underbit.com/products/mad/ libmad]
** [http://libmpeg2.sourceforge.net mpeg2]
** [http://libmpeg2.sourceforge.net mpeg2]
** [http://www.audiocoding.com/faad2.html FAAD2]  
** [https://github.com/knik0/faad2 FAAD2]  
** [http://liba52.sourceforge.net liba52]
** [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)
** [https://github.com/webmproject/libvpx libvpx]
** [https://mikmod.sourceforge.net/ libmikmod]
** For cloud support:
*** [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)
*** [https://curl.haxx.se/ libcurl]
** For Freetype
** For Freetype
*** [http://www.bzip.org bzip2]
*** [http://www.bzip.org bzip2]
Line 74: Line 99:
*** [https://git.gnome.org/browse/glib glib]
*** [https://git.gnome.org/browse/glib glib]
*** [http://www.fluidsynth.org FluidSynth]
*** [http://www.fluidsynth.org FluidSynth]
** For FriBiDi
*** [https://www.gnu.org/software/autoconf/autoconf.html Autoconf]
*** [https://www.gnu.org/software/automake/ Automake]
*** [https://www.gnu.org/software/libtool/ Libtool]
*** [https://github.com/fribidi/fribidi FriBiDi]


All the libraries are compiled and installed in the same way:
All the libraries are compiled and installed in the same way:
Line 117: Line 147:
|- style="background-color: #fafafa;"
|- style="background-color: #fafafa;"
| align=center valign=top| FLAC || --enable-static --disable-asm-optimizations ||
| align=center valign=top| FLAC || --enable-static --disable-asm-optimizations ||
|- style="background-color: #fafafa;"
| align=center valign=top| FriBiDi || --enable-static ||
|- style="background-color: #fafafa;"
|- style="background-color: #fafafa;"
| align=center valign=top| Theora || --disable-examples ||
| align=center valign=top| Theora || --disable-examples ||
Line 139: Line 171:
Here is a list of some options you may want to use:
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)
* '''--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.
* '''--with-staticlib-prefix=/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.
* '''--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.


Line 145: Line 177:


=== Compiling ScummVM ===
=== Compiling ScummVM ===
Just run make (with -j to compile several files in parallel). For example:
Just run make (with -j to compile several files in parallel, usually number of your virtual CPUs+2). For example, for a 2 core CPU:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
make -j4
make -j4
</syntaxhighlight>
</syntaxhighlight>
or -j18 for a 16-core CPU (including hyperthreaded cores).


To recompile everything and not just the modified files:
To recompile everything and not just the modified files:
Line 188: Line 222:


=== Creating an Xcode project ===
=== Creating an Xcode project ===
* Compile '''create_project''' inside devtools/create_project
* Compile '''create_project''':
<syntaxhighlight lang="bash">
make devtools/create_project
</syntaxhighlight>
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
</syntaxhighlight>
</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
cd ../../..
./devtools/create_project/xcode/build/Release/create_project . --xcode
</syntaxhighlight>
</syntaxhighlight>


Line 207: Line 239:
* Go to Product -> Scheme and set the scheme to "ScummVM-macOS"  
* 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"
* Go to Product -> Scheme -> Edit Scheme -> Run tab -> Options tab and uncheck "Allow debugging when using document Versions Browser"
* If the required libraries (such as SDL2) are not in ''/usr/local'', you will need to update the ''Header Search Paths'' and ''Library Search Paths'' build settings in Xcode.
* Build with Product -> Build or Product -> Run
* Build with Product -> Build or Product -> Run


== Further reading ==
== Further reading ==
* [https://github.com/scummvm/scummvm/blob/master/README.md#100-compiling ScummVM README, Section 10.0]
* [https://github.com/scummvm/scummvm/blob/master/README.md#100-compiling ScummVM README, Section 10.0]