forked from joncampbell123/dosbox-x
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-macos-print-sdl2-app
executable file
·165 lines (140 loc) · 5.2 KB
/
build-macos-print-sdl2-app
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env bash
cd "$(dirname "$0")"
make distclean || true
# I'm sick and tired of all the churn the three versions of autoconf
# are causing in this repo. Stop committing the configure scripts
# and just autoregen.
./autogen.sh || exit 1
# where are we?
top=$(pwd)
if test -z "${top}" ; then exit 1; fi
# fix
chmod +x vs/sdl/build-scripts/strip_fPIC.sh
chmod +x vs/sdl2/build-dosbox.sh
orig_CFLAGS="${CFLAGS}"
orig_LDFLAGS="${LDFLAGS}"
orig_CPPFLAGS="${CPPFLAGS}"
orig_CXXFLAGS="${CXXFLAGS}"
# Remove our temporary copies of dosbox-x executable before rebuilding
rm -f src/dosbox-x-arm64 src/dosbox-x-x86_64
do_cleanup() {
rm -rf vs/sdl2/linux-host vs/sdl2/linux-build
rm -rf vs/zlib/linux-host vs/zlib/linux-build
rm -rf vs/libpng/linux-host vs/libpng/linux-build
rm -rf vs/freetype/linux-host vs/freetype/linux-build
[ -e Makefile ] && make clean
}
universal=0
architectures="$(uname -m)"
if [ "${1}" = "universal" ]; then
shift
if [ "${architectures}" = "arm64" ]; then
# We can only build universal binaries on an arm64 host because we
# need homebrew functional under both architectures.
universal=1
architectures="arm64 x86_64"
fi
fi
arm64_brew_cmd=""
x86_64_brew_cmd=""
# arm64 native Homebrew
if [ -x /opt/homebrew/bin/brew ]; then
arm64_brew_cmd="/opt/homebrew/bin/brew"
fi
# x86_64 Homebrew
if [ -x /usr/local/bin/brew ]; then
# old homebrew
x86_64_brew_cmd="/usr/local/bin/brew"
elif [ -x /usr/local/Homebrew/bin/brew ]; then
# new homebrew
x86_64_brew_cmd="/usr/local/Homebrew/bin/brew"
fi
# x86_64 on arm64 for universal builds if x86_64 Homebrew is installed
if [ -n "${x86_64_brew_cmd}" ] && [ "${universal}" -eq 1 ]; then
x86_64_brew_cmd="/usr/bin/arch -x86_64 ${x86_64_brew_cmd}"
fi
for arch in ${architectures}; do
declare brew_cmd="${arch}_brew_cmd"
if [ -n "${!brew_cmd}" ]; then
${!brew_cmd} list fluid-synth &>/dev/null || ${!brew_cmd} install fluid-synth
${!brew_cmd} list libslirp &>/dev/null || ${!brew_cmd} install libslirp
${!brew_cmd} list pkg-config &>/dev/null || ${!brew_cmd} install pkg-config
fi
do_cleanup
arch_flags="-arch ${arch} -mmacosx-version-min=10.12 "
CFLAGS="${arch_flags}${orig_CFLAGS}"
LDFLAGS="${arch_flags}${orig_LDFLAGS}"
CPPFLAGS="${arch_flags}${orig_CPPFLAGS}"
CXXFLAGS="${arch_flags}${orig_CXXFLAGS}"
export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS
# prefer to compile against our own copy of SDL 2.x IF the system does not provide one
echo "Compiling our internal SDL 2.x"
(cd vs/sdl2 && ./build-dosbox.sh) || exit 1
new="-I${top}/vs/sdl2/linux-host/include "
nld="-L${top}/vs/sdl2/linux-host/lib "
CFLAGS="${CFLAGS}${new}"
LDFLAGS="${LDFLAGS}${nld}"
CPPFLAGS="${CPPFLAGS}${new}"
CXXFLAGS="${CXXFLAGS}${new}"
export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS
# prefer to compile against our own zlib
echo "Compiling our internal zlib"
(cd vs/zlib && ./build-dosbox.sh) || exit 1
new="-I${top}/vs/zlib/linux-host/include "
nld="-L${top}/vs/zlib/linux-host/lib "
CFLAGS="${CFLAGS}${new}"
LDFLAGS="${LDFLAGS}${nld}"
CPPFLAGS="${CPPFLAGS}${new}"
CXXFLAGS="${CXXFLAGS}${new}"
export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS
# prefer to compile against our own libpng (comment this out to disable)
echo "Compiling our internal libpng"
(cd vs/libpng && ./build-dosbox.sh) || exit 1
new="-I${top}/vs/libpng/linux-host/include "
nld="-L${top}/vs/libpng/linux-host/lib "
CFLAGS="${CFLAGS}${new}"
LDFLAGS="${LDFLAGS}${nld}"
CPPFLAGS="${CPPFLAGS}${new}"
CXXFLAGS="${CXXFLAGS}${new}"
export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS
# prefer to compile against our own freetype
echo "Compiling our internal freetype"
(cd vs/freetype && ./build-dosbox.sh) || exit 1
new="-I${top}/vs/freetype/linux-host/include/freetype2 "
nld="-L${top}/vs/freetype/linux-host/lib -lfreetype "
CFLAGS="${CFLAGS}${new}"
LDFLAGS="${LDFLAGS}${nld}"
CPPFLAGS="${CPPFLAGS}${new}"
CXXFLAGS="${CXXFLAGS}${new}"
INTERNAL_FREETYPE=1
export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS INTERNAL_FREETYPE
opts=
# if Brew has installed packages, try to use those too
if [ -n "${!brew_cmd}" ]; then
echo "Brew is installed, I'm going to use it's libraries too"
new="-I$(${!brew_cmd} --prefix)/include "
nld="-L$(${!brew_cmd} --prefix)/lib "
CFLAGS="${CFLAGS}${new}"
LDFLAGS="${LDFLAGS}${nld}"
CPPFLAGS="${CPPFLAGS}${new}"
CXXFLAGS="${CXXFLAGS}${new}"
PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:$(${!brew_cmd} --prefix)/lib/pkgconfig"
export CFLAGS LDFLAGS CPPFLAGS CXXFLAGS PKG_CONFIG_PATH
fi
if [ "${universal}" = 1 ]; then
opts="${opts} --enable-universal"
fi
# now compile ourself
echo "Compiling DOSBox-X"
chmod +x configure
./configure --enable-debug=heavy --prefix=/usr --enable-sdl2 "${opts}" "${@}" || exit 1
make -j3 || exit 1
cp src/dosbox-x "src/dosbox-x-${arch}"
done
r
rm -f dosbox-x.app || true
rm -f dosbox-x-SDL2.app || true
make dosbox-x.app
mv -f dosbox-x.app dosbox-x-SDL2.app
cp -R contrib/macos/BonjourEvents.app ./dosbox-x-SDL2.app/Contents/Resources
open ./dosbox-x-SDL2.app