3 # script for pulling together a MacOSX app bundle.
5 GTKQUARTZ_ROOT=$HOME/gtk/inst
7 if pkg-config --modversion gtk+-2.0 | grep -s 2.22 ; then
9 GDKPIXBUF_LOADERS=$GTKQUARTZ_ROOT/lib/gtk-2.0/2.10.0/loaders
12 echo "*****************************************************"
13 echo "You are building with the OLD GTK stack. I hope that is ok"
14 echo "*****************************************************"
19 GDKPIXBUF_LOADERS=$GTKQUARTZ_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders
22 echo "*****************************************************"
23 echo "You are building with the NEW GTK stack. I hope that is ok"
24 echo "*****************************************************"
38 while [ $# -gt 0 ] ; do
43 # top level build targets
51 PRODUCT_PKG_DIR=ArdourSAE ;
60 PRODUCT_PKG_DIR=MixBus;
68 PRODUCT_PKG_DIR=Ardour;
76 PRODUCT_PKG_DIR=Ardour ;
78 --test) SAE= ; INTERNAL_JACK=; WITH_LADSPA=; STRIP= ; shift ;;
81 # specific build flags
84 --nojack) INTERNAL_JACK= ; shift ;;
85 --noladspa) WITH_LADSPA= ; shift ;;
86 --nostrip) STRIP= ; shift ;;
87 --sysdeps) PRINT_SYSDEPS=1; shift ;;
88 --nls) WITH_NLS=1 ; shift ;;
89 --external_jack) EXTERNAL_JACK=$2; shift ; shift ;;
93 if [ x$EXTERNAL_JACK != x -a x$INTERNAL_JACK != x ] ; then
94 echo "It makes no sense to package JACK internally and externally. Please pick one."
97 BUILD_ROOT=../../build
99 #release_version=`grep -m 1 '^VERSION' ../../wscript | cut -d' ' -f 3 | sed "s/'//g"`
101 svn_version=`grep -m 1 'svn_revision =' ../../libs/ardour/svn_revision.cc | cut -d' ' -f 8 | sed 's/[^0-9]//g'`
102 echo "Version is $release_version / $svn_version"
103 info_string="$release_version/$svn_version built on `hostname` by `whoami` on `date`"
104 echo "Info string is $info_string"
106 # setup directory structure
108 APPDIR=${APPNAME}.app
109 APPROOT=$APPDIR/Contents
110 Frameworks=$APPROOT/Frameworks
111 Resources=$APPROOT/Resources
112 Plugins=$APPROOT/Plugins
113 Surfaces=$APPROOT/Surfaces
114 Panners=$APPROOT/Panners
115 MidiMaps=$APPROOT/MidiMaps
116 ExportFormats=$APPROOT/ExportFormats
117 Templates=$APPROOT/Templates
118 Shared=$Resources/share
120 Locale=$Resources/locale
122 if [ x$PRINT_SYSDEPS != x ] ; then
124 # print system dependencies
127 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Plugins/*.so ; do
128 if ! file $file | grep -qs Mach-O ; then
131 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
136 echo "Removing old $APPDIR tree ..."
140 echo "Building new app directory structure ..."
142 # only bother to make the longest paths
144 mkdir -p $APPROOT/MacOS
145 mkdir -p $APPROOT/Resources
150 mkdir -p $ExportFormats
152 mkdir -p $Frameworks/modules
153 mkdir -p $Shared/templates
156 # maybe set variables
158 if test x$SAE != x ; then
159 appname="Ardour3/SAE"
160 env="$env<key>ARDOUR_SAE</key><string>true</string>"
162 # current default for SAE version is German keyboard layout without a keypad
164 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>de-nokeypad</string>"
165 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui_sae.conf</string>"
166 env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark_sae.rc</string>"
167 elif test x$MIXBUS != x ; then
168 appname="Ardour3/Mixbus"
169 env="$env<key>ARDOUR_MIXBUS</key><string>true</string>"
171 # current default for MIXBUS version is US keyboard layout without a keypad
173 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>us-nokeypad</string>"
174 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui.conf</string>"
175 env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark.rc</string>"
181 # if we're not going to bundle JACK, make sure we can find
182 # jack in the places where it might be
185 if test x$INTERNAL_JACK != x ; then
186 env="$env<key>ARDOUR_INTERNAL_JACK</key><string>true</string>"
188 env="$env<key>PATH</key><string>/usr/local/bin:/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>"
189 env="$env<key>DYLIB_FALLBACK_LIBRARY_PATH</key><string>/usr/local/lib:/opt/lib</string>"
192 env="<key>LSEnvironment</key><dict>$env<key>ARDOUR_BUNDLED</key><string>true</string></dict>"
195 sed -e "s?@ENV@?$env?g" \
196 -e "s?@VERSION@?$release_version/$svn_version?g" \
197 -e "s?@INFOSTRING@?$info_string?g" < Info.plist.in > Info.plist
199 sed -e "s?@APPNAME@?$appname?" \
200 -e "s?@ENV@?$env?g" \
201 -e "s?@VERSION@?$release_version/$svn_version?g" \
202 -e "s?@INFOSTRING@?$info_string?g" < InfoPlist.strings.in > Resources/InfoPlist.strings || exit 1
206 cp Info.plist $APPROOT
207 cp -R Resources $APPROOT
210 # if we build a bundle without jack, then
211 # make the Ardour3 executable a helper
212 # script that checks to see if JACK is
216 if test x$INTERNAL_JACK != x ; then
217 MAIN_EXECUTABLE=Ardour3
219 cp startup_script $APPROOT/MacOS/Ardour3
220 chmod 775 $APPROOT/MacOS/Ardour3
221 MAIN_EXECUTABLE=Ardour3.bin
224 echo "Copying ardour executable ...."
225 cp $BUILD_ROOT/gtk2_ardour/ardour-$release_version $APPROOT/MacOS/$MAIN_EXECUTABLE
226 if test x$SAE != x ; then
227 # cp $BUILD_ROOT/gtk2_ardour/evtest $APPROOT/MacOS/gtkevents
228 cp Ardour3-SAE.icns $Resources/appIcon.icns
229 elif test x$MIXBUS != x ; then
230 cp Mixbus.icns $Resources/appIcon.icns
232 cp Ardour3.icns $Resources/appIcon.icns
234 cp typeArdour.icns $Resources/
235 if test x$STRIP != x ; then
236 strip $APPROOT/MacOS/Ardour3
238 if test x$INTERNAL_JACK != x ; then
239 if [ -f /usr/local/lib/jack/jack_coreaudio.so ] ; then
240 cp /usr/local/lib/jack/jack_coreaudio.so $Frameworks
241 cp /usr/local/bin/jackd $APPROOT/MacOS
242 JACK_SHARED_OBJECTS="$Frameworks/*.so"
247 if test x$WITH_NLS != x ; then
248 echo "NLS support ..."
249 echo "I hope you remembered to run scons msgupdate!"
251 for file in $BUILD_ROOT/gtk2_ardour/*.mo
253 lang=`basename $file | sed 's/\.mo//'`
254 mkdir -p $Locale/$lang/LC_MESSAGES
255 cp $file $Locale/$lang/LC_MESSAGES/gtk2_ardour.mo
256 LINGUAS="$LINGUAS $lang"
258 for file in $BUILD_ROOT/libs/ardour/*.mo
260 lang=`basename $file | sed 's/\.mo//'`
261 mkdir -p $Locale/$lang/LC_MESSAGES
262 cp $file $Locale/$lang/LC_MESSAGES/libardour.mo
266 if [ -d $GTKQUARTZ_ROOT/share/locale/$l ] ; then
267 echo "Copying GTK i18n files for $l..."
268 cp -r $GTKQUARTZ_ROOT/share/locale/$l $Locale
270 # try with just the language spec
271 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
272 if [ -d $GTKQUARTZ_ROOT/share/locale/$just_lang ] ; then
273 echo "Copying GTK i18n files for $l..."
274 cp -r $GTKQUARTZ_ROOT/share/locale/$just_lang $Locale
279 echo "Skipping NLS support"
282 cp -R $GTKQUARTZ_ROOT/etc/* $Etc
283 echo "Copying all Pango modules ..."
284 cp -R $GTKQUARTZ_ROOT/lib/pango/1.6.0/modules/*.so $Frameworks/modules
285 echo "Copying all GDK Pixbuf loaders ..."
286 cp -R $GDKPIXBUF_LOADERS/*.so $Frameworks/modules
288 cp -R $GTKQUARTZ_ROOT/lib/charset.alias $Resources
292 if test x$WITH_LADSPA != x ; then
293 if test x$SAE != x ; then
295 elif test x$MIXBUS != x ; then
296 plugdir=mixbus_ladspa
300 echo "Copying `ls $plugdir | wc -l` plugins ..."
301 cp -r $plugdir/* $Plugins
304 # generate new Pango module file
307 ModulesPath=$GTKQUARTZ_ROOT/lib/pango/1.6.0/modules
309 env PANGO_RC_FILE=pangorc $GTKQUARTZ_ROOT/bin/pango-querymodules | sed "s?$GTKQUARTZ_ROOT/lib/pango/1.6.0/modules/?@executable_path/../Frameworks/modules/?" > $Resources/pango.modules
312 # generate a new GDK pixbufs loaders file
313 gdk-pixbuf-query-loaders | sed "s?$GDKPIXBUF_LOADERS/?@executable_path/../Frameworks/modules/?" > $Resources/gdk-pixbuf.loaders
315 # this one is special - we will set GTK_PATH to $Frameworks/clearlooks
316 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.dylib $Frameworks
317 mkdir -p $Frameworks/clearlooks/engines
318 (cd $Frameworks/clearlooks/engines && ln -s $BUILD_ROOT/libclearlooks.dylib libclearlooks.dylib && ln -s ../../libclearlooks.dylib libclearlooks.so)
320 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.dylib $Surfaces
321 cp $BUILD_ROOT/libs/panners/*/lib*.dylib $Panners
323 for f in *.preset ; do
324 echo ExportFormat: $f; cp "$f" ../tools/osx_packaging/$ExportFormats ;
326 (cd $BUILD_ROOT/templates && \
327 for f in *.template ; do
328 echo Template: $f ; cp "$f" ../../tools/osx_packaging/$Templates ;
332 cp ../../midi_maps/*.map $MidiMaps
334 # VAMP plugins that we use
335 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.dylib $Frameworks
339 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Plugins/*.so ; do
340 if ! file $file | grep -qs Mach-O ; then
343 if test x$INTERNAL_JACK != x ; then
344 deps=`otool -L $file | awk '{print $1}' | egrep "($GTKQUARTZ_ROOT|/opt/|/local/|libs/)"`
346 # do not include libjack
347 deps=`otool -L $file | awk '{print $1}' | egrep "($GTKQUARTZ_ROOT|/opt/|/local/|libs/)" | grep -v 'libjack\.'`
350 for dep in $deps ; do
352 if ! test -f $Frameworks/$base; then
353 if echo $dep | grep -sq '^libs' ; then
354 cp $BUILD_ROOT/$dep $Frameworks
362 if test x$missing = xfalse ; then
363 # everything has been found
369 echo "Copying other stuff to $APPDIR ..."
371 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Resources
373 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Resources
374 cp ../../gtk2_ardour/mixer.bindings $Resources
375 cp ../../gtk2_ardour/step_editing.bindings $Resources
376 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Resources
378 if test x$SAE != x ; then
379 cp $BUILD_ROOT/gtk2_ardour/SAE-de-keypad.bindings $Resources
380 cp $BUILD_ROOT/gtk2_ardour/SAE-de-nokeypad.bindings $Resources
381 cp $BUILD_ROOT/gtk2_ardour/SAE-us-keypad.bindings $Resources
382 cp $BUILD_ROOT/gtk2_ardour/SAE-us-nokeypad.bindings $Resources
383 cp $BUILD_ROOT/ardour_system_sae.rc $Resources/ardour_system.rc
384 echo cp $BUILD_ROOT/ardour_system_sae.rc $Resources/ardour_system.rc
385 cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
386 echo cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
388 # cp $BUILD_ROOT/ardour_system.rc $Resources/ardour_system.rc
389 # echo FOO cp $BUILD_ROOT/ardour_system.rc $Resources/ardour_system.rc
390 cp ../../instant.xml $Resources/instant.xml
391 echo cp ../../instant.xml $Resources/instant.xml
393 cp ../../gtk2_ardour/ardour3_ui_default.conf $Resources
394 cp ../../gtk2_ardour/ardour3_ui_default.conf $Resources/ardour3_ui.conf
395 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_light.rc $Resources
396 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_dark.rc $Resources
398 cp -r ../../gtk2_ardour/icons $Resources
399 cp -r ../../gtk2_ardour/pixmaps $Resources
401 # go through and recursively remove any .svn dirs in the bundle
402 for svndir in `find $APPDIR -name .svn -type dir`; do
406 # now fix up the executables
407 echo "Fixing up executable dependency names ..."
408 executables=$MAIN_EXECUTABLE
409 if test x$INTERNAL_JACK != x ; then
410 executables="$executables jackd"
412 if test x$SAE != x ; then
413 executables="$executables"
416 for exe in $executables; do
417 EXE=$APPROOT/MacOS/$exe
419 if test x$INTERNAL_JACK != x ; then
420 for lib in `otool -L $EXE | egrep "($GTKQUARTZ_ROOT|/opt/|/local/|libs/)" | awk '{print $1}'` ; do
422 changes="$changes -change $lib @executable_path/../Frameworks/$base"
425 for lib in `otool -L $EXE | egrep "($GTKQUARTZ_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
427 changes="$changes -change $lib @executable_path/../Frameworks/$base"
430 if test "x$changes" != "x" ; then
431 install_name_tool $changes $EXE
435 echo "Fixing up library names ..."
436 # now do the same for all the libraries we include
437 for dylib in $JACK_SHARED_OBJECTS $Frameworks/*.dylib $Frameworks/modules/*.so $Surfaces/*.dylib ; do
439 if test ! -L $dylib ; then
441 # change all the dependencies
444 if test x$INTERNAL_JACK != x ; then
445 for lib in `otool -L $dylib | egrep "($GTKQUARTZ_ROOT|/opt/|/local/|libs/)" | awk '{print $1}'` ; do
447 changes="$changes -change $lib @executable_path/../Frameworks/$base"
450 for lib in `otool -L $dylib | egrep "($GTKQUARTZ_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
452 changes="$changes -change $lib @executable_path/../Frameworks/$base"
456 if test "x$changes" != x ; then
457 if install_name_tool $changes $dylib ; then
464 # now the change what the library thinks its own name is
466 base=`basename $dylib`
467 install_name_tool -id @executable_path/../Frameworks/$base $dylib
472 # and now ... the DMG
475 rm -rf $PRODUCT_PKG_DIR
476 mkdir $PRODUCT_PKG_DIR
478 if [ x$SAE != x ] ; then
482 echo "Creating SAE packaging directory"
483 mv $APPDIR $PRODUCT_PKG_DIR/Ardour3-SAE.app
484 cp HowToInstallArdourSAE.pdf "$PRODUCT_PKG_DIR/How To Install Ardour SAE.pdf"
485 cp SAE-de-keypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts (keypad).pdf"
486 cp SAE-de-nokeypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts.pdf"
488 elif [ x$MIXBUS != x ] ; then
492 echo "Creating Mixbus packaging directory"
493 mv $APPDIR $PRODUCT_PKG_DIR/
494 cp MixBus_Install_QuickStart.pdf "$PRODUCT_PKG_DIR/Mixbus Install & Quick Start Guide.pdf"
496 if [ -x $EXTERNAL_JACK != x ] ; then
497 cp $EXTERNAL_JACK $PRODUCT_PKG_DIR
503 echo "Creating $APPNAME packaging directory"
504 mv $APPDIR $PRODUCT_PKG_DIR/
508 echo "Building DMG ..."
510 # UC_DMG=$APPNAME-${release_version}-${svn_version}-UC.dmg
511 # FINAL_DMG=$APPNAME-${release_version}-${svn_version}.dmg
512 UC_DMG=$APPNAME-${release_version}-${svn_version}.dmg
515 echo hdiutil create $UC_DMG -volname $APPNAME-$release_version -fs HFS+ -srcfolder $PRODUCT_PKG_DIR
516 hdiutil create $UC_DMG -volname $APPNAME-$release_version -fs HFS+ -srcfolder $PRODUCT_PKG_DIR
519 # echo "Compressing DMG ..."
521 # hdiutil convert $UC_DMG -format UDBZ -o $FINAL_DMG