-
Notifications
You must be signed in to change notification settings - Fork 9
/
COMPILE
137 lines (104 loc) · 5.76 KB
/
COMPILE
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
128
129
130
131
132
133
134
135
136
===============================================================================
Dependencies
===============================================================================
FLTK (1.3.x or later if compatible)
Boost
Lua 5.1 or greater or LuaJIT 2 or greater.
===============================================================================
Instructions
===============================================================================
If you are a Windows user and want to compile Retro Graphics Toolkit you will
need Mingw or Mingw-w64.
===============================================================================
WINDOWS ONLY BEGIN
===============================================================================
This step is only for Windows users. On other operating system, the
distribution should already have provided FLTK.
For MinGW to reduce the distribution size it's recommended but not required
that MinGW be built using win32 threads instead of posix threads so that way we
don't have to ship the winpthreads DLL or staticlly link against it. Pass the
--enable-threads=win32 option to the gcc configure script. Another advatage if
you do this along with disable large file support in libstc++ the EXEs will run
on older versions of Windows such as Windows 95 and Windows 98.
You will now need to build FLTK to do this download fltk-1.3.5 (or later if
compatible) and extract it into the Retro Graphics Toolkit project folder and
build it using either ./configure if you are on Windows or if you are cross
compiling you need to do something like this:
RANLIB=/usr/bin/i586-w64-mingw32-gcc-ranlib NM=/usr/bin/i586-w64-mingw32-gcc-nm AR=/usr/bin/i586-w64-mingw32-gcc-ar CFLAGS="-fno-rtti -DWINVER=0x0400 -Os -s -flto=16 -fuse-linker-plugin -m32" CXXFLAGS=$CFLAGS LDFLAGS=$CFLAGS ./configure --host=i586-w64-mingw32 --build=x86_64-unknown-linux-gnu --enable-gl=no --disable-largefile ; make -j16
Or to build without LTO:
CFLAGS="-Os -s -m32" CXXFLAGS=$CFLAGS LDFLAGS=$CFLAGS ./configure --host=i586-w64-mingw32 --build=x86_64-unknown-linux-gnu ; make -j16
Debug:
CFLAGS="-Og -ggdb3 -m32" CXXFLAGS=$CFLAGS LDFLAGS=$CFLAGS ./configure --host=i586-w64-mingw32 --build=x86_64-unknown-linux-gnu ; make -j16
For some reason if the absolute path is not specified for RANLIB, NM and AR you
will get errors relating to plugin support needed for LTO.
** If you try building it with bintuils 2.35.1 (and most likely 2.35) and LTO
it will give you errors. It works with bintuils 2.34. If there is a newer
version first try that and if not try binutils 2.34 to use LTO.**
Regardless of how ./configure is ran you will just need to run make and you are
done building FLTK. Note that the libraries will compile but after that some of
the sample programs won't. This won't impact compiling Retro Graphics Toolkit
and you can safely ignore these errors.
If you would like to build the samples you may use apply this patch:
wget https://github.com/fltk/fltk/commit/a0caebb66353f5a2fbee0a2b70a770e51c2aac11.patch
patch -p1 < a0caebb66353f5a2fbee0a2b70a770e51c2aac11.patch
You will also need to put Boost in the directory you cloned this repository in.
After extracting the archive rename boost_version_number to boost.
Next build Libunicows.
cd Libunicows/src/
make -f makefile.crossmingw32
Optional step to reduce binary size: Run these two commands in the lib
directory where GCC was compiled. Do likewise in the folder called
x86_64-w64-mingw32 (may be different depending on how you compiled your mingw
toolchain)
find \( -name '*.o' -o -name '*.a' \) -exec i586-w64-mingw32-objcopy -R '.rdata$zzz' {} \;
The purpose of that command is to remove all the GCC version strings. If you
don't run this command you will have hundreds of duplicate GCC version strings
in the final binary.
In the Retro Graphics Toolkit directory extract the latest stable version of
Lua JIT and rename the extracted folder to "LuaJIT-windows-build". Make sure
you extracted the archive directly in the folder. Don't have
luaJit-windows-build/LuaJit-2.x.
Before building LuaJIT edit the makefile in the src folder look for the line
starting with TARGET_AR= and replace $(CROSS)ar with
/usr/bin/i586-w64-mingw32-gcc-ar
Also look for CCOPT= and set it to:
-Os -flto -fuse-linker-plugin -fomit-frame-pointer
run
cd LuaJIT-windows-build/src/
make HOST_CC="gcc -m32" CROSS=i586-w64-mingw32- TARGET_SYS=Windows CFLAGS="-Os -flto -fuse-linker-plugin" LDFLAGS="$TARGET_CFLAGS" -j16
cp lua51.dll ../../
cp luajit.exe ../../
cd ../../
cp /usr/i586-w64-mingw32/bin/libgcc_s_dw2-1.dll .
# Optional steps to add documentation and make the files smaller to reduce the archive size.
cp -r LuaJIT-windows-build/doc luajit-doc
wget https://www.lua.org/ftp/refman-5.1.tar.gz
tar -xf refman-5.1.tar.gz
mv lua-5.1 lua-doc
optipng -o9 -strip all lua-doc/doc/cover.png lua-doc/doc/logo.gif
advpng -z -4 lua-doc/doc/cover.png
advpng -z -4 lua-doc/doc/logo.png
advpng -z -4 luajit-doc/img/contact.png
rm lua-doc/doc/logo.gif
sed -i 's/logo.gif/logo.png/g' lua-doc/doc/*.html
cd ManualSrc
python3 genManuals_html.py
rm -rf Manual
mkdir Manual
cp Pandoc/*.html Manual/
cd Manual
sed -i 's|https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/master/Docs/Screenshots/||g' *.html
cp ../../Docs/Screenshots/*.png .
tree -H '.' -L 1 --noreport --charset utf-8 -P "*.html" > index.html
find -iname '*.html' -exec htmlmin {} {} \;
cd ..
rm -rf ../Manual
mv Manual ..
cd ..
htmlmin help-src.html help.html
===============================================================================
END OF WINDOWS ONLY SECTION
===============================================================================
Now on Linux run make or on Windows run make -f make.win note that you may need
to modify the CXX and CC variables in make.win.
You should now have a compiled version of Retro Graphics Toolkit.