Debian Codegraph @

INSTALL.markdown

raw
1 # Installing D1X-Rebirth and D2X-Rebirth
2 ## Building
3
4 D1X-Rebirth and D2X-Rebirth (generically DXX-Rebirth) are built by an SConstruct script. DXX-Rebirth runs on Windows (XP and later), Linux (x86 and amd64), recent Mac OS X, and Raspberry Pi. Other targets may also work, but are not tracked by the core team. If you maintain a working target not listed here, please file an issue to have it included in this list.
5
6 The DXX-Rebirth maintainers have no control over the sites linked below. The maintainers are not responsible for the safety or correct operation of the prerequisites listed below. Unless specified otherwise, the maintainers of DXX-Rebirth have not verified that the links are current, safe, or produce a working environment.
7
8 ### Prerequisites
9
10 * [Python 3.x](https://www.python.org/) to run [scons](https://www.scons.org/), the processor for SConstruct scripts.
11 [Python 3.12](https://www.python.org/downloads/release/python-3127/) is recommended.
12 * C++ compiler with support for selected C++20 features. One of:
13 * [gcc](https://gcc.gnu.org/) 12, 13, or 14
14 * [clang](https://clang.llvm.org/) 16.0 or later
15 * Microsoft Visual Studio is **not** supported at this time.
16 Visual Studio 2022 release notes indicate it has sufficient C++ support
17 that it should be able to compile Rebirth. However, due to limitations
18 of the Visual Studio installation environment, the core team does not
19 use, test, or support Visual Studio.
20 * [SDL 1.2](https://www.libsdl.org/).
21 SDL 2 is also supported, and will become the default soon.
22 * [PhysicsFS](https://icculus.org/physfs/).
23 PhysFS 3.x or later is required.
24
25 Optional, but recommended:
26
27 * [SDL\_image 1.2](https://www.libsdl.org/projects/SDL_image/).
28 * [SDL\_mixer 1.2](https://www.libsdl.org/projects/SDL_mixer/).
29 * [libpng](http://www.libpng.org/).
30
31 Unless otherwise noted, using the newest release available is recommended. For example, prefer gcc-13 to gcc-12, even though both should work.
32
33 DXX-Rebirth can be built on one system to run on a different system, such as using Linux to build for Windows (a "cross-compiled build"). The sections below specify where to get prerequisites for a build meant to run on the system where it is built (a "native build").
34
35 For each prerequisite, its development headers (files ending in **.h**) and its libraries (ending in **.so** for Linux, **.dylib** for Mac OS X, and **.dll** for Windows) must be found by the compiler. You can do this by placing these files in an existing directory which the compiler will search, or by placing these files in a directory which you instruct the compiler to search.
36
37 In general, avoid installing prerequisites to paths which contain embedded spaces. Although Rebirth quotes paths to handle this, some prerequisites may use `pkg-config` files that do not handle embedded spaces well.
38
39 #### Placing files in a directory which you instruct the compiler to search (preferred)
40
41 If you choose to install the headers and/or libraries in a new path, you must instruct the build system to search that path. To do this for development headers, add to the scons command line **"CPPFLAGS=-isystem** _/absolute/path/to/header/directory_**"**. To do this for libraries, add to the scons command line **"LINKFLAGS=-L** _/absolute/path/to/library/directory_**"**.
42
43 #### Adding files to an existing directory which the compiler will search
44
45 To find these paths for gcc:
46 * Get the compiler's header search path by running **gcc -Wp,-v -S -x c++ /dev/null** and looking at the lines under the label **#include <...> search starts here:**. Any of these lines will work. The paths _without_ a compiler version number in them are preferable. Windows users may need to write **gcc -Wp,-v -S -x c++ nul** instead, due to Windows using a different name for the null device.
47 * Get the compiler's library search path by running **gcc -print-search-dirs** and looking at the line labeled **libraries:**. This line is a list of directories that will be searched. Any of the directories will work. Again, prefer directories that are do not have a compile version number in them.
48
49 #### Windows
50 Where possible, Windows users should try to obtain a compiled package, rather than locally compiling from source. To build from source, read on.
51
52 If you are not sure whether your system is Windows x86 or Windows x64, use the packages for Windows x86. Systems running Windows x64 support running Windows x86 programs, but Windows x86 systems do not run Windows x64 programs.
53
54 * [Python x86 installer](https://www.python.org/ftp/python/3.11.7/python-3.11.7.exe) |
55 [Python x64 installer](https://www.python.org/ftp/python/3.11.7/python-3.11.7-amd64.exe)
56 * [SCons](http://prdownloads.sourceforge.net/scons/scons-4.2.0.zip)
57 * C++ compiler
58 * mingw-gcc: [Getting Started](http://www.mingw.org/wiki/Getting_Started) |
59 [Direct download](https://sourceforge.net/projects/mingw/files/latest/download)
60 * [SDL 1.2 x86 zip](https://www.libsdl.org/release/SDL-1.2.15-win32.zip) |
61 [SDL 1.2 x64 zip](https://www.libsdl.org/release/SDL-1.2.15-win32-x64.zip)
62 * No published PhysFS package for Windows is known.
63 You must [build it](https://hg.icculus.org/icculus/physfs/raw-file/bf155bd2127b/INSTALL.txt)
64 from [source](https://icculus.org/physfs/downloads/physfs-3.0.2.tar.bz2).
65 You may be able avoid building from source by copying PhysFS DLLs from a
66 previous Rebirth release and installing current PhysFS headers.
67 However, building from source is recommended to ensure a consistent
68 environment.
69
70 #### MSYS2/mingw-w64 (Windows alternate method)
71 * `pacman -S git ${MINGW_PACKAGE_PREFIX}-{gcc,pkgconf,scons,SDL,SDL_image,SDL_mixer,libpng,physfs}`
72
73 #### Linux
74 Install the listed prerequisites through your system package manager.
75 * Arch PKGBUILD files are in `contrib/arch/`
76 * An RPM spec file is in `contrib/rpm/`
77 * Gentoo ebuild files are in `contrib/gentoo/`
78
79 ##### Arch
80 * **pacman -S
81 base-devel
82 scons
83 sdl
84 sdl\_image
85 sdl\_mixer
86 physfs**
87
88 ##### Fedora
89 * **yum install
90 gcc-c++
91 scons
92 SDL-devel
93 SDL\_image-devel
94 SDL\_mixer-devel
95 physfs-devel**
96
97 ##### Gentoo
98 * **emerge --ask --verbose --noreplace
99 dev-util/scons
100 media-libs/libsdl
101 media-libs/sdl-image
102 media-libs/sdl-mixer
103 dev-games/physfs**
104
105 ##### Ubuntu
106 * **apt-get install
107 build-essential
108 scons
109 libsdl1.2-dev
110 libsdl-image1.2-dev
111 libsdl-mixer1.2-dev
112 libphysfs-dev**
113
114 #### Mac OS X
115 Where possible, Mac users should try to obtain a compiled package, rather than locally compiling from source. To build from source, read on.
116
117 Install the listed prerequisites through your preferred package manager.
118
119 PhysicsFS must be installed as a separate dynamic library. It is not supported as an OS X Framework. The required files will be installed into the correct locations by the PhysicsFS installer; refer to the relevant instructions.
120
121 The Mac OS X Command Line Tools are required. Install them by running
122
123 xcode-select --install
124
125 from the Terminal. This may need to be done after each major OS upgrade as well.
126
127 DXX-Rebirth can be built from the Terminal (via SCons) without Xcode; to build using Xcode requires Xcode to be installed.
128
129 When building for Mac OS X, only SDL 2 is currently supported, as SDL 1.2 has long-standing issues with modern versions of the operating system. Terminal builds for Mac OS X default to SDL 2, which is equivalent to passing **sdl2=True** as a parameter to the SCons command.
130
131 **Note:** If intending to cross-compile from Linux to macOS, information about this process can be found at [macOS_Cross_Compilation.markdown](macOS_Cross_Compilation.markdown).
132
133 ##### [Homebrew](https://github.com/Homebrew/homebrew/)
134 The project includes a Brewfile for installing all required dependencies, if you use Homebrew. You can install them with:
135
136 * **brew bundle**
137
138 **Note:** Because Homebrew only installs libraries and not frameworks, when building for Mac OS X with Homebrew-provided dependencies, you must provide **macos_add_frameworks=False** as a SCons command parameter in order for the build system to look for libraries rather than frameworks.
139
140 ### Building
141 Once prerequisites are installed, run **scons** *options* to build. By default, both D1X-Rebirth and D2X-Rebirth are built. To build only D1X-Rebirth, run **scons d1x=1**. To build only D2X-Rebirth, run **scons d2x=1**.
142
143 If unspecified, **SConstruct** uses $CXX for the compiler, $CPPFLAGS for preprocessor options, $CXXFLAGS for C++ compiler options, and $LDFLAGS for linker options. You may override any or all of these choices by setting options of the corresponding name: **scons CXX=/opt/my/c++ 'CXXFLAGS=-O0 -ggdb'**. **SConstruct** supports numerous options for adjusting build details. Run **scons -h** to see them. Option names are case sensitive. Commonly used options include:
144
145 * **CXX=**_path_ - path to C++ compiler
146 * **CPPFLAGS='**_flags_**'** - flags for C preprocessor
147 * **CXXFLAGS='**_flags_**'** - flags for C++ compiler
148 * **LDFLAGS='**_flags_**'** - flags for linker
149 * **lto=1** - enable Link Time Optimization
150 * **sdlmixer=1** - enable support for SDL\_mixer
151 * **builddir=**_path_ - set directory for build outputs; defaults to "."
152 * **builddir\_prefix=**_path_ - Developer option; set builddir to builddir\_prefix plus a path derived from build options.
153 Use this to build multiple targets without picking specific paths for each one.
154 The generated path is stable across multiple runs with the same options.
155 Packaging scripts should use **builddir** with manually chosen directories.
156 * **verbosebuild=1** - show commands executed instead of short descriptions of the commands
157 * **prefix=**_path_ - (Linux only); equivalent to **--prefix** in Autoconf
158 * **sharepath=**_path_ - (Linux only); sets system directory to search for game data
159
160 The build system supports building multiple targets in parallel. This is primarily useful for developers, but can also be used by packagers to create secondary builds with different features enabled. To use it, run **scons** *game*=*profile[,profile...]*. **SConstruct** will search each profile for the known options. The first match wins. For example:
161
162 scons dxx=gcc13,e, d2x=gcc12,sdl2, \
163 gcc13_CXX=/path/to/gcc-13 \
164 gcc12_CXX=/path/to/gcc-12 \
165 e_editor=1 sdl2_sdl2=1
166
167 This tells **SConstruct** to build both games (**dxx**) with the profiles **gcc13**, **e**, *empty* and also to build D2X-Rebirth (**d2x**) with the profiles **gcc12**, **sdl2**, *empty*. Profiles **gcc13** and **gcc12** define private values for **CXX**, so the default value of **CXX** is ignored. Profile **e** enables the **editor** option, which builds features used by players who want to create their own levels. Profile **sdl2** sets the **sdl2** option to true, which produces a build that uses libSDL2 instead of libSDL. Profile *empty* is the default namespace, so CPPFLAGS, CXXFLAGS, etc. are found when it is searched. Since these values were not assigned, they are drawn from the corresponding environment variables.
168
169 The build system supports specifying a group of closely related targets. This is mostly redundant on shells with brace expansion support, but can be easier to type. For example:
170
171 scons builddir_prefix=build/ \
172 dxx=gcc12+gcc13,prof1,prof2,prof3,
173
174 This is equivalent to the shell brace expansion:
175
176 scons builddir_prefix=build/ \
177 dxx={gcc12,gcc13},prof1,prof2,prof3,
178
179 or
180
181 scons builddir_prefix=build/ \
182 dxx=gcc12,prof1,prof2,prof3, \
183 dxx=gcc13,prof1,prof2,prof3,
184
185 Profile addition can be stacked: **scons dxx=a+b,c+d,e+f** is equivalent to **scons dxx=a,c,e dxx=a,d,e dxx=b,c,e dxx=b,d,e dxx=a,c,f dxx=a,d,f dxx=b,c,f dxx=b,d,f**.
186
187 #### Configuration
188 **SConstruct** runs tests to check for common problems and available functionality. **SConstruct** will automatically enable available compiler features. **SConstruct** will not automatically enable optional features which require an external library. If the feature is enabled, either by default or by the provided options, and the library is present, it will be used. If the feature is enabled, and the library is absent, the build fails. If the feature is disabled, either by default or by the provided options, the library check is skipped and the feature is not used.
189
190 If required functionality is missing, **SConstruct** will stop the build and print a diagnostic message. A stop at this stage indicates an environment problem. If any target fails to configure, no target will be built.
191
192 Before reporting an issue, clear any applicable caches (**ccache -C**; **rm .sconsign.dblite**) and reproduce the failure. The DXX-Rebirth maintainers may be able to help you resolve environment problems if you cannot solve them on your own. If you need help, please post the full output of running **scons** and the contents of **sconf.log** from your build directory.
193
194 #### Compiling
195 After **SConstruct** finishes the configure tests, **scons** will compile and link the program. Failures at this stage may indicate a bug that should be reported. Broken environments are usually caught by **SConstruct** checks before the build began. If the compilation succeeds, the output files will be found in game-specific directories. If the profile specified editor features, then **-editor** is appended to the filename.
196
197 The output path can be overridden with the **SConstruct** option **program\_name**. If **program\_name** is set, it overrides the game directory prefix and the optional **-editor** modification. It does not override the output suffix (**.exe** for Windows, *empty* for Linux).
198
199 Windows output with **program\_name** unset:
200
201 * *build-directory*/d1x-rebirth/d1x-rebirth*[-editor]*.exe
202 * *build-directory*/d2x-rebirth/d2x-rebirth*[-editor]*.exe
203
204 Windows output with **d1x=1 program\_name**=**d1x-local**:
205
206 * *build-directory*/d1x-local.exe
207
208 Linux output with **program\_name** unset:
209
210 * *build-directory*/d1x-rebirth/d1x-rebirth*[-editor]*
211 * *build-directory*/d2x-rebirth/d2x-rebirth*[-editor]*
212
213 ##### Compiling with MSYS2
214 MSYS2 offers its users three terminal environments: msys2, for building with POSIX compatibility (linking to runtime `/usr/bin/msys-2.0.dll`); and mingw32 and mingw64, for building portable native Windows apps (linking to `C:\WINDOWS\System32\msvcrt.dll`), on i686 and x86_64 respectively.
215 * Install [MSYS2](https://www.msys2.org), following the directions on the main page.
216 * In either a mingw32 or mingw64 (not msys2) terminal:
217
218 pacman -Syuu # update MSYS2, as needed
219 pacman -S --needed git ${MINGW_PACKAGE_PREFIX}-{gcc,pkgconf,scons,SDL,SDL_image,SDL_mixer,libpng,physfs}
220 # ^ substitute SDL2 for SDL if desired
221 git clone https://github.com/dxx-rebirth/dxx-rebirth.git
222 cd dxx-rebirth
223 scons
224 # Or (for example) to build d1x only, with SDL 2, with lower process priority, on all cores:
225 time nice scons -j$(nproc) sdl2=1 d1x=1
226
227 * A locally built executable will run anywhere if it's invoked from inside the appropriate mingw32 or mingw64 terminal. To run it instead directly in Windows, either:
228 1. The linked mingw-w64 libraries will need to be added to PATH (See [contrib/msys2](contrib/msys2) for working example batch files); or
229 2. Dependency DLLs from MSYS2 will need to be copied to the same directory as the executable.
230
231 #### Installing
232 For Windows and Linux, DXX-Rebirth installs only the main game binary. The binary can be run from anywhere and can be installed by copying the game binary. The game does not inspect the name of its binary. You may rename the output after compilation without affecting the game.
233
234 As a convenience, if **register\_install\_target=True**, **SConstruct** registers a pseudo-target named **install** which copies the compiled files to *BINDIR*, as modified by the SCons option **--install-sandbox**. By default, **register\_install\_target=True**, the sandbox prefix path is empty, and *BINDIR* is *PREFIX*__/bin__, which expands to **/usr/local/bin**.
235
236 DXX-Rebirth [requires game data](https://www.dxx-rebirth.com/game-content/) to play. The build system has no support for interacting with game data. You can get [Descent 1 PC shareware data](https://www.dxx-rebirth.com/download/dxx/content/descent-pc-shareware.zip) and [Descent 2 PC demo data](https://www.dxx-rebirth.com/download/dxx/content/descent2-pc-demo.zip) from the DXX-Rebirth website. Full game data is supported (and recommended), but is not freely available. You can [buy full Descent 1 game data](https://www.gog.com/game/descent) and/or [buy full Descent 2 game data](https://www.gog.com/game/descent_2) from GOG.com. Historically, both Descent 1 and Descent 2 were sold as a single unit. After a nearly two-year hiatus from sale, the games returned to GOG.com in November 2017 as separate units. DXX-Rebirth contains engines for both games. Each engine works for its respective game without the data from the other, so players who wish to purchase only one game may do so.