-
Notifications
You must be signed in to change notification settings - Fork 29
/
mac_build
executable file
·267 lines (249 loc) · 8.37 KB
/
mac_build
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#!/bin/bash
#
#Assumes you have libusb-1.0.8.tar.bz2 and XPlane SDK in the parent directory.
#
LTR_BASE=$(pwd)
LTR_VERSION=$(grep 'AC_INIT(\[LinuxTrack\],' configure.ac | tr -d '[],'| awk '{print $2}')
pushd ..
BASE=$(pwd)
popd
PREFIX=${BASE}/ltr
export WINE_PREFIX=${BASE}/ltr_wine
NSIS_PREFIX=${BASE}/nsis
LIB_DIR=ltr_gui.app/Contents/Frameworks
BIN_DIR=ltr_gui.app/Contents/MacOS
HELPER_DIR=ltr_gui.app/Contents/helper
WINE_DIR=ltr_gui.app/Contents/wine
RSRC_DIR=ltr_gui.app/Contents/Resources
WII_SRVR_DIR=
SDK_ROOT=/Developer/SDKs/MacOSX10.6.sdk
#COMMON_FLAGS=" -isysroot ${SDK_ROOT} -mmacosx-version-min=10.6"
COMMON_FLAGS=""
COMMON_CMAKE_FLAGS=""
#export MACOSX_DEPLOYMENT_TARGET=10.6
PARALEL_MAKE=" -j5 "
export PATH=${PATH}:${WINE_PREFIX}/bin:${NSIS_PREFIX}/nsis-2.46:${NSIS_PREFIX}/bin
if [ -f ${NSIS_PREFIX}/nsis-2.46/LibraryLocal ]; then
echo "Nsis installed already!"
else
echo ${NSIS_PREFIX}
mkdir -p ${NSIS_PREFIX}
# unpack nsis windows prebuild package
pushd ${NSIS_PREFIX}
unzip ${BASE}/nsis-2.46.zip
popd
#unpack and install scons
pushd ${BASE}
tar xfz scons-2.3.0.tar.gz
pushd scons-2.3.0
python setup.py install --prefix=${NSIS_PREFIX}
popd
#unpack and install nsis
tar xfj nsis-2.46-src.tar.bz2
pushd nsis-2.46-src
scons SKIPSTUBS=all SKIPPLUGINS=all SKIPUTILS=all SKIPMISC=all \
NSIS_CONFIG_CONST_DATA_PATH=no PREFIX=${NSIS_PREFIX}/nsis-2.46 \
install-compiler
scons NSIS_CONFIG_CONST_DATA_PATH=no PREFIX=${NSIS_PREFIX}/nsis-2.46 \
${NSIS_PREFIX}/nsis-2.46/LibraryLocal
popd
popd
fi
##Build libusbx-1.0
pushd ${BASE}
if [ -f ${PREFIX}/lib/libusb-1.0.dylib ]; then
echo 'Libusb-1.0 already exists!'
else
export CFLAGS=${COMMON_FLAGS}
tar xfj libusb-1.0.20.tar.bz2
pushd libusb-1.0.20
./configure --prefix=${PREFIX} --disable-dependency-tracking >/dev/null
make $PARALEL_MAKE >/dev/null
make install >/dev/null
unset CFLAGS
popd
fi
popd
##Build liblo
pushd ${BASE}
if [ -f ${PREFIX}/lib/liblo.a ]; then
echo 'Liblo already exists!'
else
export CFLAGS=${COMMON_FLAGS}
tar xfz liblo-0.28.tar.gz
pushd liblo-0.28
./configure --prefix=${PREFIX} --disable-dependency-tracking \
--enable-static --disable-shared >/dev/null
make $PARALEL_MAKE >/dev/null
make install >/dev/null
unset CFLAGS
popd
fi
popd
#Build OpenCV
pushd ${BASE}
if [ -f ${PREFIX}/bin/opencv_traincascade ]; then
echo 'OpenCV already exists!'
else
tar xfz opencv-2.4.6.1.tar.gz
pushd opencv-2.4.6.1
mkdir build
pushd build
cmake "-DCMAKE_INSTALL_PREFIX=${PREFIX}" "-DWITH_OPENCL=FALSE" ..
make $PARALEL_MAKE >/dev/null
make install >/dev/null
popd
popd
fi
popd
##Build Wine
WINE_VER=1.4.1
pushd ${BASE}
if [ -f ${WINE_PREFIX}/bin/wine ]; then
echo 'Wine already exists!'
else
tar xfj wine-${WINE_VER}.tar.bz2
pushd wine-${WINE_VER}
sed '/DllMain/,/TRUE/ s#WINSPOOL_LoadSystemPrinters#//WINSPOOL_LoadSystemPrinters#' dlls/winspool.drv/wspool.c
CFLAGS="${COMMON_FLAGS}" \
CXXFLAGS="${COMMON_FLAGS}" \
LD_FLAGS="${COMMON_FLAGS}" \
CPPFLAGS="${COMMON_FLAGS}" \
./configure --prefix=${WINE_PREFIX} --without-x --without-cups
make $PARALEL_MAKE >/dev/null
make install >/dev/null
popd
fi
##Build mxml
pushd ${BASE}
if [ -f ${PREFIX}/include/mxml.h ]; then
echo 'Libmxml already installed!'
else
tar xfz mxml-2.7.tar.gz
pushd mxml-2.7
CFLAGS="${COMMON_FLAGS}" \
CXXFLAGS="${COMMON_FLAGS}" \
LD_FLAGS="${COMMON_FLAGS}" \
CPPFLAGS="${COMMON_FLAGS}" \
./configure --prefix=${PREFIX}
sed -i ".old" 's/xDarwin/yDarwin/' Makefile
make $PARALEL_MAKE >/dev/null
make install >/dev/null
popd
fi
pushd ${BASE}
if [ -f ${PREFIX}/bin/cabextract ]; then
echo 'Cabextract already installed!'
else
tar xfz cabextract-1.4.tar.gz
pushd cabextract-1.4
CFLAGS="${COMMON_FLAGS}" \
CXXFLAGS="${COMMON_FLAGS}" \
LD_FLAGS="${COMMON_FLAGS}" \
CPPFLAGS="${COMMON_FLAGS}" \
./configure --prefix=${PREFIX}
make $PARALEL_MAKE >/dev/null
make install >/dev/null
popd
fi
#Build linuxtrack
pushd "$LTR_BASE"
#have to use this hack, because autoreconf on Mac doesn't pass -I ... to the aclocal
#export ACLOCAL="aclocal -I ./mac_m4"
#echo "Rebuilding with mac_m4"
make distclean
autoreconf -if
unset ACLOCAL
export CPPFLAGS="-I${PREFIX}/include -I${WINE_PREFIX}/include"
export CXXFLAGS="-I${PREFIX}/include -I${WINE_PREFIX}/include"
export LDFLAGS="-L${PREFIX}/lib "
OPENCV_CFLAGS=$(./pkgconf_extract ${PREFIX}/lib/pkgconfig/opencv.pc --with-opencv_cflags Cflags)
OPENCV_LIBS=$(./pkgconf_extract ${PREFIX}/lib/pkgconfig/opencv.pc --with-opencv-libs Libs)
./configure --prefix=${PREFIX} --with-xplane-sdk=${BASE}/SDK/CHeaders --enable-snow-leopard \
--with-wine-libs="-L${WINE_PREFIX}/lib -L${WINE_PREFIX}/lib/wine" "${OPENCV_CFLAGS}" "${OPENCV_LIBS}" &&
make $PARALEL_MAKE > build.log &&
make install > install.log
if [ $? != 0 ]; then
exit
fi
pushd src/qt_gui
#Prepare the image
mkdir -p ${LIB_DIR}
mkdir -p ${HELPER_DIR}
mkdir -p ${WINE_DIR}
echo "Copying libraries and other things..."
# XPlane v8 legacy plugin
##cp -R ${PREFIX}/lib/linuxtrack/xlinuxtrack.0.so ${LIB_DIR}/xlinuxtrack.0.dylib
cp -R ${PREFIX}/lib/linuxtrack/xlinuxtrack9.0.so ${LIB_DIR}/xlinuxtrack9.0.dylib
cp -R ${PREFIX}/lib/*.dylib ${LIB_DIR}
cp -R ${PREFIX}/lib/linuxtrack/*.dylib ${LIB_DIR}
cp -R ${PREFIX}/bin/qt_cam ${HELPER_DIR}
cp -R ${PREFIX}/bin/cabextract ${HELPER_DIR}
cp -R ${PREFIX}/share/OpenCV/*cascades ${RSRC_DIR}/linuxtrack
cp -R ${WINE_PREFIX}/* ${WINE_DIR}
echo "Fixing libraries and binaries..."
find ${LIB_DIR} -type f -exec ${LTR_BASE}/deploy {} 'lib/:'${PREFIX}'/lib' \;
find ${BIN_DIR} -type f -exec ${LTR_BASE}/deploy {} 'lib/:'${PREFIX}'/lib' \;
find ${HELPER_DIR} -type f -exec ${LTR_BASE}/deploy {} 'lib/:'${PREFIX}'/lib' \;
#Create archive image
echo "Deploying..."
macdeployqt ltr_gui.app -no-strip
echo "Deployed!"
popd
rm -rf dist
mkdir dist
pushd dist
echo "Creating WiiServer.app"
mkdir -p WiiServer.app/Contents/MacOS
mkdir -p WiiServer.app/Contents/Frameworks/
mkdir -p WiiServer.app/Contents/Resources/
cp -r ../src/mac/English.lproj WiiServer.app/Contents/Resources
cp ../src/mac/linuxtrack_wii.icns WiiServer.app/Contents/Resources
cp ../src/mac/Info.plist WiiServer.app/Contents
cp ../src/mac/PkgInfo WiiServer.app/Contents
cp -R ${PREFIX}/bin/WiiServer WiiServer.app/Contents/MacOS
cp -R ${PREFIX}/lib/linuxtrack/libltr.0.dylib WiiServer.app/Contents/Frameworks/
install_name_tool -id @executable_path/../Frameworks/libltr.0.dylib \
WiiServer.app/Contents/Frameworks/libltr.0.dylib
install_name_tool -change ${PREFIX}/lib/linuxtrack/libltr.0.dylib \
@executable_path/../Frameworks/libltr.0.dylib WiiServer.app/Contents/MacOS/WiiServer
echo "Creating OscServer.app"
mkdir -p OscServer.app/Contents/MacOS
mkdir -p OscServer.app/Contents/Frameworks/
mkdir -p OscServer.app/Contents/Resources/
cp -r ../src/osc_server_mac/English.lproj OscServer.app/Contents/Resources
rm -f OscServer.app/Contents/Resources/English.lproj/MainMenu.xib
cp ../src/osc_server_mac/linuxtrack.icns OscServer.app/Contents/Resources
cp ../src/osc_server_mac/OscServer-Info.plist OscServer.app/Contents/Info.plist
cp ../src/osc_server_mac/PkgInfo OscServer.app/Contents
cp -R ${PREFIX}/bin/OscServer OscServer.app/Contents/MacOS
cp -R ${PREFIX}/lib/linuxtrack/libltr.0.dylib OscServer.app/Contents/Frameworks/
install_name_tool -id @executable_path/../Frameworks/libltr.0.dylib \
OscServer.app/Contents/Frameworks/libltr.0.dylib
install_name_tool -change ${PREFIX}/lib/linuxtrack/libltr.0.dylib \
@executable_path/../Frameworks/libltr.0.dylib OscServer.app/Contents/MacOS/OscServer
mv ../src/qt_gui/ltr_gui.app .
cp ${PREFIX}/share/linuxtrack/linuxtrack-wine.exe .
cp -R ${PREFIX}/bin/ltr_server1 ${BIN_DIR}
install_name_tool -change ${PREFIX}/lib/linuxtrack/libltr.0.dylib \
@executable_path/../Frameworks/libltr.0.dylib ${BIN_DIR}/ltr_server1
if [ -f "${BASE}/bulk_config_data.tar.gz" ]; then
pushd ltr_gui.app/Contents/Resources/linuxtrack
tar xfz ${BASE}/bulk_config_data.tar.gz
popd
fi
mkdir develop
cp ../src/linuxtrack.h develop
cp ../src/linuxtrack.c develop
cp ../src/linuxtrack_hello_world.c develop
cp ../src/linuxtrack_hello_world_adv.c develop
cp ../Readme.rtf .
cp ../src/ltr_pipe .
cp ../src/osc_server .
popd
echo "Going to create the .dmg..."
rm -f linuxtrack*.dmg
DMG=linuxtrack-${LTR_VERSION}.dmg
hdiutil create ${DMG} -srcfolder dist -format UDZO -volname linuxtrack
popd
#