BuildingOnMac.wiki
changeset 1975 05c417d4d891
parent 1963 1175d2f6f198
child 1976 c764a1bf5795
equal deleted inserted replaced
1974:3a573bba359e 1975:05c417d4d891
     1 #summary Instructions for building Hedgewars on macOS
     1 #summary Instructions for building Hedgewars on macOS
     2 #labels Phase-Implementation,Phase-Deploy,Phase-Support
     2 #labels Phase-Implementation,Phase-Deploy,Phase-Support
     3 
     3 
     4 = Building on macOS =
     4 = Building on macOS =
     5 **Note: These instructions are OUTDATED!**
     5 Also known as OS X or Mac OS X.
       
     6 
       
     7 *Note:* These instructions were run on OS X 10.11 and backwards compiled for OS X 10.8 (Aug 2019). Newer versions will likely work but may require some adaptation.
     6 
     8 
     7 == Prerequisites ==
     9 == Prerequisites ==
     8 
    10 
     9   * XCode must be installed with command line tools
    11 === Required Build Dependencies ===
    10   * some knowledge of Terminal is preferred
    12 
       
    13 Homebrew (https://brew.sh/) can be used to gather many of these dependencies, but is not required. All can be found as installers, frameworks, or built manually without Homebrew.
       
    14 
       
    15 Unless otherwise specified, latest versions of the following dependencies can be used.
       
    16 
       
    17 ==== Compilers and Environment ====
       
    18 
       
    19   * Xcode command line tools
       
    20   * CMake 3.9 or later
       
    21   * fpc 2.6.x OR fpc 3.1.1+ (nothing in between, due a crashing bug)
       
    22 
       
    23 ==== Libraries ====
       
    24 
       
    25 Libraries can be dynamically linked libraries (.dylib) or Apple frameworks (.framework).  All must be on the system library or framework paths for CMake to find them. Frameworks can be put in your home directory at `~/Library/Frameworks`
       
    26 
       
    27   * Qt 5.9.x or later (unified installer works)
       
    28   * SDL2
       
    29   * SDL2_image (2.0.4 works, 2.0.5 might be buggy)
       
    30   * SDL2_mixer
       
    31   * SDL2_net
       
    32   * SDL2_ttf
       
    33   * Ogg
       
    34   * Vorbis
       
    35   * libpng 1.6.x
       
    36   * physfs 3.0.x
       
    37 
       
    38 
       
    39 ==== Notes ====
       
    40 # Other dependencies are linked with the SDL2 libraries, but not specifically used in Hedgewars. They may include:
       
    41   * FreeType
       
    42   * FLAC
       
    43   * Opus
       
    44   * GLEW
       
    45   * modplug
       
    46   * mpg123
       
    47   * webp
       
    48 # Good places to find required frameworks are found in the development packages for the various SDL2 libraries. They are found in the `Frameworks` subdirectory within the .framework itself. Example: `SDL2_ttf.framework/Frameworks/FreeType.framework`
       
    49 # Another good place for the frameworks/libraries are in the Hedgewars.app of a previous version (E.g. Hedgewars 1.0.0 Beta 2)
       
    50 
       
    51 === Optional Dependencies ===
       
    52 
       
    53 By default, the following optional features are turned on in the build system, and require the following dependencies.
       
    54 
       
    55   * Video recording
       
    56     * ffmpeg 4.2 (later versions are untested)
       
    57       * yasm 1.3+
       
    58   * Automatic updates
       
    59     * Sparkle
       
    60   * hedgewar-server
       
    61     * ghc, cabal (Haskell)
       
    62       * xz
       
    63 
       
    64 ==== Haskell Installation ====
       
    65 
       
    66 Steps to get the Haskell environment set up for compiling hedgewars-server:
       
    67 
       
    68 # Install ghc, cabal with instructions at https://www.haskell.org/ghcup/
       
    69 # Load ghc environment: `source ~/.ghcup/env`
       
    70 # Install cabal-uninstall: `cabal install cabal-uninstall`
       
    71 # Install haskell packages: `cabal install vector bytestring 'network < 2.7' time mtl sandi 'hslogger < 1.3' process utf8-string SHA entropy zlib random regex-tdfa deepseq`
       
    72 
       
    73 `cabal-uninstall` is for when you accidentally install newer package versions that don't work with hedgewars-server (e.g. hslogger-1.3.0.0)
       
    74 
       
    75 
       
    76 == Building Hedgewars ==
       
    77 
       
    78 === Environment Setup ===
       
    79 
       
    80   * Set macOS version to target for Xcode tools. The earlier the better:
       
    81 {{{
       
    82 export MACOSX_DEPLOYMENT_TARGET=10.8
       
    83 }}}
       
    84   * (Optional) Load haskell environment:
       
    85 {{{
       
    86 source ~/.ghcup/env
       
    87 }}}
       
    88   * Create (mkdir) a `build` subdirectory in the hedgewars source code
       
    89 
       
    90 
       
    91 === Build ===
       
    92 
       
    93 CMake is used to manage the build process, and is run with different flags depending on which optional dependencies you have elected to install.
       
    94 
       
    95 Take note of where QT is installed; it is a required build flag (see below).
       
    96 
       
    97 Steps to build:
       
    98 
       
    99 # `cd /path/to/hg/hedgewars/build`
       
   100 # `cmake .. -DCMAKE_PREFIX_PATH=/Users/user/Qt/5.9.8/clang_64/ -DCMAKE_BUILD_TYPE=Release`
       
   101 # `make -j2`
       
   102 # `make install`
       
   103 
       
   104 A Hedgewars.app file will be created in the same folder you ran CMake.
       
   105 
       
   106 To build the DMG, also run:
       
   107 
       
   108 # `make dmg`
    11 
   109 
    12 ==== Notes ====
   110 ==== Notes ====
    13 
   111 
    14    # it has been reported that Xcode 3.2.6 creates problem when linking frameworks! If you can't use another version, try this: https://discussions.apple.com/thread/2781968?threadID=2781968&tstart=105
   112 # To build a debug build, use the flag `-DCMAKE_BUILD_TYPE=Debug` instead of the `Release` one
    15    # for Xcode 4 onwards, you need to install the command line tools: open Xcode, go to Preferences, select "Downloads" and install the "Command Line Tools".
   113 # To build a minimum-features build, use the additional flags of `-DNOSERVER=1`, `-DNOVIDEOREC=1`, and `-DNOAUTOUPDATE=1`, for disabling of hedgewars-server, video recording, and Sparkle autoupdating, respectively.
    16    # for Qt series 4.7, only versions 4.7.0 and 4.7.4 are not suffering from this bug http://bugreports.qt.nokia.com/browse/QTBUG-17333 any other version will not work with online games.
   114 # The build uses CMake BundleUtilities which automatically deploys all libraries and dependencies  into the .app, and repairs the RPATH of each library and binary as needed.  If there is a missing dependency, the `make install` portion of the build will fail. The fix is usually to find the correct .framework and put in on library path, then run `make dmg` again.
    17    # Lion has an incompatible ABI with older version of Freepascal! Use only the new Freepascal version 2.6.0 or newer. See http://bugs.freepascal.org/view.php?id=19269
       
    18 
       
    19 === Necessary libraries ===
       
    20 
       
    21 Download the following libraries and place them under `/Library/Frameworks/`
       
    22 
       
    23   * SDL - http://www.libsdl.org/release/
       
    24   * SDL_image - http://www.libsdl.org/projects/SDL_image/release/
       
    25   * SDL_mixer - http://www.libsdl.org/projects/SDL_mixer/release/
       
    26   * SDL_net - http://www.libsdl.org/projects/SDL_net/release/
       
    27   * SDL_ttf - http://www.libsdl.org/projects/SDL_ttf/release/
       
    28   * Ogg sources - http://downloads.xiph.org/releases/ogg/
       
    29   * Vorbis sources - http://downloads.xiph.org/releases/vorbis/
       
    30 
       
    31 See [Dependencies] for the required versions.
       
    32 
       
    33 === Optional libraries ===
       
    34 
       
    35 The following libraries are optional:
       
    36  * Sparkle (auto-updater) - https://github.com/sparkle-project/Sparkle/releases/latest
       
    37 
       
    38 ==== Compiling Ogg Vorbis ====
       
    39 
       
    40 Since there is no framework distribution for ogg vorbis libraries, we will need to compile our own. Extract the sources and open the relative .xcodeproj file.
       
    41 
       
    42 It is likely that you will need to adjust some parameters, such as the Base SDK you have installed and for which architecture (ppc, i386, x86_64) you want to build. Go into "Project"->"Edit Project Settings", under "Build" set Architectures to Standard and Base SDK to 10.5 (otherwise newer).
       
    43 
       
    44 After that build as usual and copy the generated framework to the usual `/Library/Frameworks/` directory.
       
    45 
       
    46 ==== (Optional) Server ====
       
    47 
       
    48 If you want to compile server for hosting lan games, you need to download a Haskell compiler: we are going to use the Glasgow Haskell Compiler.
       
    49 
       
    50  * Download the Haskell Platform and install both the GHC and Haskell Platform - https://www.haskell.org/downloads#platform
       
    51  * Run `cabal update` to get an updated list of available libraries and install the necessary dependencies with
       
    52 {{{
       
    53 sudo cabal install gameServer/hedgewars-server.cabal
       
    54 }}}
       
    55   * _(even more optional)_ if you feel experimental, you can also try to use the 64bit variant of Haskell, just make sure that your `~/.cabal/` directory doesn't conflict with previous installations
       
    56 
       
    57 === Necessary tools ===
       
    58 
       
    59 Download and install the following toolchains
       
    60 
       
    61  * Freepascal compiler - https://sourceforge.net/projects/freepascal/files/Mac%20OS%20X/
       
    62  * CMake - https://cmake.org/download/
       
    63  * Qt - https://www1.qt.io/download/
       
    64   * Note that for compiling the 64 bit version you need download the `cocoa` version of Qt
       
    65 
       
    66 == Building process ==
       
    67 
       
    68   * Download the source tarball or clone the Mercurial repo
       
    69   * Configure the sources with the following line
       
    70 {{{
       
    71 cmake . -DQT_QMAKE_EXECUTABLE=/usr/bin/qmake -DCMAKE_BUILD_TYPE=Release
       
    72 }}}
       
    73   * Run `make` and `make install`
       
    74 
   115 
    75 Enjoy!
   116 Enjoy!