Difference between revisions of "Compiling ScummVM/macOS"

Jump to navigation Jump to search
1,656 bytes added ,  19:23, 4 November 2019
→‎4. Manual compilation: -- removed duplicate
m (Text replacement - "<source lang=" to "<syntaxhighlight lang=")
(→‎4. Manual compilation: -- removed duplicate)
(7 intermediate revisions by 4 users not shown)
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 36: Line 36:
=== 1. Homebrew ===
=== 1. Homebrew ===
<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 a52dec curl-openssl faad2 flac fluid-synth freetype jpeg-turbo libmad libmpeg2 libogg libpng libvorbis lzlib pkg-config sdl2 sdl2_net theora
</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 a52dec 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 62: 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 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 80: Line 83:
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 91:
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 systems, 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:
<syntaxhighlight 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:
Line 101: Line 104:
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 131:
<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.
For a list of optional features (eg additional, not yet enabled engines) run:
For a list of optional features (e.g. additional, not yet enabled engines) run:
<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 144: Line 147:


=== 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). For example:
<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 156:
make clean
make clean
make -j4
make -j4
</source>
</syntaxhighlight>


=== Installing ScummVM ===
=== Installing ScummVM ===
Line 159: Line 162:
<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.


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.
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.
==== Important note about SDL2 ====
The scummvm compilation assumes that the bundle uses the static SDL library. However if you have both a dynamic and static SDL2 library, SDL2 by default will instruct to use the dynamic library. To make bundles that work on other computers you can do one of two things:
# Locate the installed sdl2-config script (for example ''/usr/local/bin/sdl2-config'') and edit the line after <code>--static-libs)</code>, replace <code>echo -L${exec_prefix}/lib -lSDL2</code> with <code>echo ${exec_prefix}/lib/libSDL2.a</code> (and preserve the rest of the line). This needs to be done before you make the bundle.
# After creating the bundle, copy the dynamic libSDL2 to the bundle and instruct the executable where to find it:
<syntaxhighlight lang="bash">
otool -L ScummVM.app/Contents/MacOS/scummvm  | grep SDL2
  <Note the path for the SDL2 library - below we assume it is /usr/local/lib/libSDL2-2.0.0.dylib>
mkdir ScummVM.app/Contents/Frameworks/
cp /usr/local/lib/libSDL2-2.0.0.dylib ScummVM.app/Contents/Frameworks/
install_name_tool -change /usr/local/lib/libSDL2-2.0.0.dylib "@executable_path/../Frameworks/libSDL2-2.0.0.dylib"  ScummVM.app/Contents/MacOS/scummvm
</syntaxhighlight>
Doing that is not needed if you are only going to use the ScummVM application on the same computer you compiled it on.


== Compiling ScummVM via the Xcode GUI ==
== Compiling ScummVM via the Xcode GUI ==
Line 176: Line 193:
<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.
Line 195: Line 212:


== 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]

Navigation menu