forked from libmapper/libmapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_darwin_binaries.sh
executable file
·268 lines (237 loc) · 9.14 KB
/
build_darwin_binaries.sh
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
268
#!/bin/sh
# This script compiles universal binaries of the libmapper library
# and builds app bundles for the examples and a framework.
ARCHES="i386 x86_64"
if [ -d /Developer/SDKs/MacOSX10.5.sdk ]; then
SDKPATH="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs"
else
SDKPATH=/Developer/SDKs/
fi
if [ -d "$SDKPATH" ]; then
for i in 5 6 7 8; do
if [ -d "$SDKPATH/MacOSX10.$i.sdk" ]; then
SDK="$SDKPATH/MacOSX10.$i.sdk"
break
fi
done
fi
SDKC="--sysroot=$SDK"
SDKLD="-lgcc_s.1"
# Build darwin binaries for libmapper
# First argument must be the path to a libmapper source tarball.
LIBMAPPER_TAR="$1"
LIBLO_TAR="$2"
LIBMAPPER_VERSION=$(echo $LIBMAPPER_TAR|sed 's,.*libmapper-\(.*\).tar.gz,\1,')
LIBMAPPER_MAJOR=$(echo $LIBMAPPER_VERSION|sed 's,\([0-9]\)\(\.[0-9]*\)*,\1,')
LIBLO_VERSION=$(echo $LIBLO_TAR|sed 's,.*liblo-\(.*\).tar.gz,\1,')
LIBLO_MAJOR=$(echo $LIBLO_VERSION|sed 's,\([0-9]\)\(\.[0-9]*\)*,\1,')
if [ -z "$LIBMAPPER_TAR" ] || [ -z "$LIBLO_TAR" ]; then
echo Usage: $0 '<libmapper-VERSION.tar.gz>' '<liblo-VERSION.tar.gz>'
exit
fi
# Get absolute paths
LIBMAPPER_TAR="$PWD/$LIBMAPPER_TAR"
LIBLO_TAR="$PWD/$LIBLO_TAR"
mkdir -v binaries
cd binaries
function make_arches()
{
tar -xzf "$LIBLO_TAR"
cd $(basename "$LIBLO_TAR" .tar.gz)
if ./configure CFLAGS="-arch i386 -arch x86_64" CXXFLAGS="-arch i386 -arch x86_64" LDFLAGS="-arch i386 -arch x86_64" --prefix=`pwd`/../install --enable-static --enable-shared --disable-dependency-tracking && make && make install; then
cd ..
else
echo liblo Build error
exit 1
fi
tar -xzf "$LIBMAPPER_TAR"
cd $(basename "$LIBMAPPER_TAR" .tar.gz)
PREFIX=`pwd`/../install
if env PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig ./configure CFLAGS="-arch i386 -arch x86_64 -I$PREFIX/include" CXXFLAGS="-arch i386 -arch x86_64 -I$PREFIX/include" LDFLAGS="-arch i386 -arch x86_64 -L$PREFIX/lib -Wl,-rpath,@loader_path/Frameworks -llo" --prefix=$PREFIX --enable-static --enable-shared --disable-dependency-tracking; then
LIBLO_DYLIB=$(ls ../install/lib/liblo.*.dylib)
install_name_tool \
-id @rpath/lo.framework/Versions/$LIBLO_MAJOR/lo \
../install/lib/liblo.dylib || exit 1
install_name_tool \
-id @rpath/lo.framework/Versions/$LIBLO_MAJOR/lo \
$LIBLO_DYLIB || exit 1
if make && make install; then
cd ..
else
echo libmapper Build error
exit 1
fi
else
echo libmapper Build error
exit 1
fi
LIBMAPPER_DYLIB=install/lib/libmapper.*.dylib
install_name_tool \
-id @rpath/mapper.framework/Versions/$LIBMAPPER_MAJOR/mapper \
install/lib/libmapper.dylib || exit 1
install_name_tool \
-id @rpath/mapper.framework/Versions/$LIBMAPPER_MAJOR/mapper \
$LIBMAPPER_DYLIB || exit 1
}
function info_plist()
{
FILENAME=$1
NAME=$2
EXECNAME=$3
cat >$FILENAME <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>$NAME</string>
<key>CFBundleExecutable</key>
<string>$EXECNAME</string>
<key>CFBundleIdentifier</key>
<string>org.idmil.$NAME</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$NAME</string>
<key>CFBundleIconFile</key>
<string>libmapper.icns</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$LIBMAPPER_VERSION</string>
<key>CFBundleVersion</key>
<string>273</string>
<key>LSMinimumSystemVersion</key>
<string>10.5</string>
</dict>
</plist>
EOF
}
function make_bundles()
{
mkdir -v bundles
APP=bundles/libmapper_PWM_Example.app
mkdir -v $APP
mkdir -v $APP/Contents
mkdir -v $APP/Contents/MacOS
mkdir -v $APP/Contents/Resources
cp -v libmapper-$LIBMAPPER_VERSION/src/.libs/libmapper.*.dylib $APP/Contents/MacOS/libmapper.dylib
cp -v libmapper-$LIBMAPPER_VERSION/examples/pwm_example $APP/Contents/MacOS/
echo 'APPL????' >$APP/Contents/PkgInfo
info_plist $APP/Contents/Info.plist libmapper_PWM_Example pwm_example
cp -v ../icons/libmapper.icns $APP/Contents/Resources/
APP=bundles/libmapper_Slider_Example.app
mkdir -v $APP
mkdir -v $APP/Contents
mkdir -v $APP/Contents/MacOS
mkdir -v $APP/Contents/Resources
cp -v libmapper-$LIBMAPPER_VERSION/src/.libs/libmapper.*.dylib $APP/Contents/MacOS/libmapper/libmapper.dylib
cp -v libmapper-$LIBMAPPER_VERSION/bindings/python/mapper.py $APP/Contents/MacOS/
cp -v libmapper-$LIBMAPPER_VERSION/bindings/python/__init__.py $APP/Contents/MacOS/libmapper/
cp -v libmapper-$LIBMAPPER_VERSION/bindings/python/tkgui.py $APP/Contents/MacOS/
echo 'APPL????' >$APP/Contents/PkgInfo
info_plist $APP/Contents/Info.plist libmapper_Slider_Example tkgui.py
cp -v ../icons/libmapper.icns $APP/Contents/Resources/
APP=bundles/libmapper_Slider_Launcher.app
mkdir -v $APP
mkdir -v $APP/Contents
mkdir -v $APP/Contents/MacOS
mkdir -v $APP/Contents/Resources
cp -v libmapper-$LIBMAPPER_VERSION/extra/osx/libmapper_slider_launcher.py $APP/Contents/MacOS/
echo 'APPL????' >$APP/Contents/PkgInfo
info_plist $APP/Contents/Info.plist libmapper_Slider_Launcher libmapper_slider_launcher.py
cp -v ../icons/libmapper.icns $APP/Contents/Resources/
FRAMEWORK=bundles/mapper.framework
mkdir -v $FRAMEWORK
mkdir -v $FRAMEWORK/Versions
mkdir -v $FRAMEWORK/Versions/$LIBMAPPER_MAJOR
mkdir -v $FRAMEWORK/Versions/$LIBMAPPER_MAJOR/Libraries
cp -rv install/lib/libmapper.*.dylib \
$FRAMEWORK/Versions/$LIBMAPPER_MAJOR/Libraries/
find $FRAMEWORK/Versions/$LIBMAPPER_MAJOR/Libraries -type f \
-exec chmod 755 {} \;
ln -sv $FRAMEWORK/Versions/$LIBMAPPER_MAJOR/Libraries/libmapper.*.dylib \
$FRAMEWORK/Versions/$LIBMAPPER_MAJOR/Libraries/libmapper.dylib
mkdir -v $FRAMEWORK/Versions/$LIBMAPPER_MAJOR/Headers
cp -rv install/include/mapper/* \
$FRAMEWORK/Versions/$LIBMAPPER_MAJOR/Headers/
find $FRAMEWORK/Versions/$LIBMAPPER_MAJOR/Headers -type f \
-exec chmod 644 {} \;
ln -sv $LIBMAPPER_MAJOR $FRAMEWORK/Versions/Current
ln -sv Versions/Current/Headers $FRAMEWORK/Headers
mkdir -v $FRAMEWORK/Versions/$LIBMAPPER_MAJOR/Resources
ln -sv Versions/Current/Resources $FRAMEWORK/Resources
cat >$FRAMEWORK/Versions/$LIBMAPPER_MAJOR/Resources/Info.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>mapper</string>
<key>CFBundleIdentifier</key>
<string>org.idmil.mapper</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>mapper</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.1</string>
</dict>
</plist>
EOF
# Subframework for liblo
mkdir $FRAMEWORK/Versions/$LIBMAPPER_MAJOR/Frameworks
ln -sv Versions/$LIBMAPPER_MAJOR/Frameworks $FRAMEWORK/Frameworks
FRAMEWORK=$FRAMEWORK/Versions/$LIBMAPPER_MAJOR/Frameworks/lo.framework
mkdir -v $FRAMEWORK
mkdir -v $FRAMEWORK/Versions
mkdir -v $FRAMEWORK/Versions/$LIBLO_MAJOR
mkdir -v $FRAMEWORK/Versions/$LIBLO_MAJOR/Libraries
cp -rv install/lib/liblo.*.dylib $FRAMEWORK/Versions/$LIBLO_MAJOR/Libraries/
ln -sv $FRAMEWORK/Versions/$LIBLO_MAJOR/Libraries/liblo.*.dylib \
$FRAMEWORK/Versions/$LIBLO_MAJOR/Libraries/liblo.dylib
find $FRAMEWORK/Versions/$LIBLO_MAJOR/Libraries -type f -exec chmod 755 {} \;
mkdir -v $FRAMEWORK/Versions/$LIBLO_MAJOR/Headers
cp -rv install/include/lo/* \
$FRAMEWORK/Versions/$LIBLO_MAJOR/Headers/
find $FRAMEWORK/Versions/$LIBLO_MAJOR/Headers -type f -exec chmod 644 {} \;
ln -sv $LIBLO_MAJOR $FRAMEWORK/Versions/Current
ln -sv Versions/Current/Headers $FRAMEWORK/Headers
mkdir -v $FRAMEWORK/Versions/$LIBLO_MAJOR/Resources
ln -sv Versions/Current/Resources $FRAMEWORK/Resources
cat >$FRAMEWORK/Resources/Info.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>lo</string>
<key>CFBundleIdentifier</key>
<string>org.idmil.lo</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>lo</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.29</string>
</dict>
</plist>
EOF
}
make_arches
make_bundles
echo Done.