aboutsummaryrefslogtreecommitdiff
path: root/doc/BUILD-win9x.md
blob: 2120f4e79048810f3861a68aaccf7d161552ceb7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Cross-compilation for Win9x
Creating a toolchain targetting `i386-mingw32` is not usually possible
with the distribution-provided packages. This documentation describes
which versions are known to work so far, as well as detailed
configuration scripts.

The following documentation assumes the installation prefix
`$HOME/i386-mingw32` for the GNU toolchain. However, feel free to
change this value, if required.

Some specific library versions might be hard to find, so download links
are provided.

## Environment variables
Since it is desirable to avoid messing with system-level libraries,
when building for Win9x, `rts` will look for dependencies by inspecting
the following environment variables:

- `SDL_PATH`
- `SDL_TTF_PATH`
- `FREETYPE_PATH`
- `SDL_MIXER_PATH`

Also, the directory containing the GNU toolchain binaries (which
should be located at `$HOME/i386-mingw32/bin` by default) must be added
to the `PATH` variable.

## gcc
From own experience, modern versions of `gcc` cannot be used to compile
a cross-compiler for Win9x. Instead, a *much* older version is required.
So far, `gcc-3.4.5` is the latest known version to work.

### Known issues
- Take into account only C99 is supported by `gcc-3.4.5`.
- `gcc-3.4.5` complains about the use of `-ffunction-sections` and
`-fdata-sections`.

```sh
../gcc-3.4.5-20060117-2/configure --disable-nls --disable-rpath \
    --disable-win32-registry --enable-languages=c --enable-sjlj-exceptions \
    --enable-threads=win32 --prefix=$HOME/i386-mingw32 \
    --program-prefix=i386-mingw32- --target=i386 -mingw32 --with-gnu-as \
    --with-gnu-ld
```

[gcc-core-3.4.5-20060117-2-src.tar.gz](https://sourceforge.net/proejcts/mingw/files/MinGW/Base/gcc/Version3/Previous%20Release_%20gcc-3.45-20060117-2/gcc-core-3.4.5-20060117-2-src.tar.gz)

## binutils
GNU binutils is usually not so problematic, so any version should do.
Only `binutils-2.35` has been tested.

```sh
../binutils-2.35/configure --prefix=$HOME/i386-mingw32 --target=i386-mingw32
```
## mingwrt and w32api
So far, only versions `mingwrt-3.15.2-mingw32` and `w32api-3.13-mingw32`
have been tested.

### Known issues
- Some hacks have to be done in order to compile these libraries. These
are described on the script below.

```sh
../w32api-3.13-mingw32/configure --prefix=$HOME/i386-mingw32 --host=i386-mingw32
# Hack at line below
cd mingwrt-3.15.2-mingw32/ && cp -r include/* ~/i386-mingw32/include/
../mingwrt-3.15.2-mingw32/configure --prefix=$HOME/i386-mingw32 --target=i386-mingw32
../sdl-1.2.15-src/configure --host=i386-mingw32 --prefix=/home/xavier/sdl-1.2.15 \
    --enable-shared=no CC=i386-mingw32-gcc
```

[mingw-runtime-3.15.2](https://sourceforge.net/projects/mingw/files/OldFiles/mingwrt-3.15.2/mingwrt-3.15.2-mingw32-src.tar.gz)

[mingw-w32api-3.13](https://sourceforge.net/projects/mingw/files/OldFiles/w32api-3.13/w32api-3.13-mingw32-src.tar.gz)

## freetype (not required)
Only `freetype-2.4.8` is known to work so far.

### Known issues
- Apparently, out of source builds are not possible.

```sh
cd freetype-2.4.8-src/ && ./configure --prefix=$HOME/freetype-2.4.8 \
        --host=i386-mingw32 --enable-shared=no CC=i386-mingw32-gcc
```

## SDL
`sdl-1.2.15` is the latest version supported version for the Win9x family
of operating systems. In order to keep things easy, the script below
configures SDL as a static library.

```sh
../sdl-1.2.15-src/configure --host=i386-mingw32 --prefix=$HOME/sdl-1.2.15 \
    --enable-shared=no CC=i386-mingw32-gcc \
    CFLAGS='-ffunction-sections -fdata-sections'
```

### DirectX headers and static libraries
DirectX can help with hardware acceleration on older hardware. Fortunately,
the SDL team distribute both source and binaries that can be included when
building `sdl-1.2.15`. While two tarballs are distributed, only
`directx-devel.tar.gz` has been tested so far.

[directx-devel.tar.gz](https://www.libsdl.org/extras/win32/common/directx-devel.tar.gz)
[directx-source.tar.z](https://www.libsdl.org/extras/win32/common/directx-source.tar.gz)

```sh
../sdl-1.2.15-src/configure --host=i386-mingw32 --prefix=$HOME/sdl-1.2.15 \
    --enable-shared=no CC=i386-mingw32-gcc \
    CFLAGS="-ffunction-sections -fdata-sections \
    -I$HOME/directx-devel/include -L$HOME/directx-devel/lib"
```

In order to take advantage of DirectX, remember to assign the environment
variable `SDL_VIDEODRIVER` to `directx` before running `rts`.

## SDL_mixer
Only `SDL_mixer-1.2.12` is known to work so far. Since `rts` only uses
WAVE files, support for other audio formats is not required.

```sh
../SDL_mixer-1.2.12-src/configure --host=i386-mingw32 --enable-shared=no \
    --prefix=$HOME/SDL_mixer-1.2.12 --disable-music-cmd --disable-music-mod \
    --disable-music-ogg --disable-music-mp3 --disable-music-midi \
    --disable-music-flac CC=i386-mingw32-gcc --with-sdl-prefix=$HOME/sdl-1.2.15 \
    CFLAGS='-ffunction-sections -fdata-sections'
```