3 # script for pulling together a MacOSX app bundle.
5 GTKSTACK_ROOT=$HOME/gtk/inst
6 ARDOURSTACK_ROOT=$HOME/a3/inst
9 # where harvid and xjadeo binaries are cached
10 if test -z "$CACHEDIR" -o ! -d "$CACHEDIR"; then
23 while [ $# -gt 0 ] ; do
28 # top level build targets
35 PRODUCT_PKG_DIR=ArdourSAE ;
43 PRODUCT_PKG_DIR=MixBus;
49 PRODUCT_PKG_DIR=Ardour;
56 PRODUCT_PKG_DIR=Ardour ;
58 --test) SAE= ; WITH_LADSPA=; STRIP= ; shift ;;
61 # specific build flags
64 --noharvid) WITH_HARVID= ; shift ;;
65 --noladspa) WITH_LADSPA= ; shift ;;
66 --nostrip) STRIP= ; shift ;;
67 --sysdeps) PRINT_SYSDEPS=1; shift ;;
68 --nls) WITH_NLS=1 ; shift ;;
72 if test -z "$PRODUCT_PKG_DIR" -o -z "$APPNAME"; then
73 echo "application or product-name was not specified"
77 . ../define_versions.sh
78 echo "Version is $release_version"
79 if [ "x$commit" != "x" ] ; then
80 info_string="$release_version ($commit) built on `hostname` by `whoami` on `date`"
82 info_string="$release_version built on `hostname` by `whoami` on `date`"
84 echo "Info string is $info_string"
86 if [ x$DEBUG = xT ]; then
88 echo "Debug build, strip disabled"
90 if test x$STRIP != x ; then
91 echo "No debug build, strip enabled"
93 echo "No debug build, but strip disabled."
97 # setup directory structure
100 APPROOT=$APPDIR/Contents
101 Frameworks=$APPROOT/lib
102 Resources=$APPROOT/Resources
104 # Since this is OS X, don't try to distinguish between etc and shared
105 # (machine dependent and independent data) - just put everything
110 Locale=$Resources/locale
112 # Bundled Plugins live in a top level folder
114 Plugins=$APPROOT/Plugins
115 Surfaces=$Frameworks/surfaces
116 Panners=$Frameworks/panners
117 Backends=$Frameworks/backends
118 MidiMaps=$Shared/midi_maps
119 ExportFormats=$Shared/export
120 Templates=$Shared/templates
121 PatchFiles=$Shared/patchfiles
122 MackieControl=$Shared/mcp
124 if [ x$PRINT_SYSDEPS != x ] ; then
126 # print system dependencies
129 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Plugins/*.so ; do
130 if ! file $file | grep -qs Mach-O ; then
133 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
138 echo "Removing old $APPDIR tree ..."
142 echo "Building new app directory structure ..."
144 # only bother to make the longest paths
146 mkdir -p $APPROOT/MacOS
147 mkdir -p $APPROOT/Resources
153 mkdir -p $ExportFormats
155 mkdir -p $Frameworks/modules
157 mkdir -p $MackieControl
160 # maybe set variables
162 if test x$SAE != x ; then
163 appname="Ardour3/SAE"
164 env="$env<key>ARDOUR_SAE</key><string>true</string>"
166 # current default for SAE version is German keyboard layout without a keypad
168 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>de-nokeypad</string>"
169 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui_sae.conf</string>"
170 env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark_sae.rc</string>"
171 elif test x$MIXBUS != x ; then
172 appname="Ardour3/Mixbus"
173 env="$env<key>ARDOUR_MIXBUS</key><string>true</string>"
175 # current default for MIXBUS version is US keyboard layout without a keypad
177 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>us-nokeypad</string>"
178 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui.conf</string>"
179 env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark.rc</string>"
185 # if we're not going to bundle JACK, make sure we can find
186 # jack in the places where it might be
189 env="$env<key>PATH</key><string>/usr/local/bin:/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>"
190 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?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?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
211 rm -f Resources/InfoPlist.strings
214 # if we build a bundle without jack, then
215 # make the Ardour3 executable a helper
216 # script that checks to see if JACK is
220 cp startup_script $APPROOT/MacOS/Ardour3
221 chmod 775 $APPROOT/MacOS/Ardour3
222 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/
237 if test x$WITH_NLS != x ; then
238 echo "NLS support ..."
239 echo "I hope you remembered to run waf i18n"
242 for pkg in gtk2_ardour libs/ardour libs/gtkmm2ext ; do
243 files=`find ../../$pkg -name "*.mo"`
246 # the package name is appended with a number so that
247 # it can be parallel installed during a regular install
248 # with older (and newer) versions. it is just the major
249 # number of the release (i.e. leading digits)
252 vsuffix=`echo $release_version | sed 's/^\([0-9][0-9]*\).*/\1/'`
254 if [ -z "$files" ]; then
256 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$pkg"
263 lang=`basename $file | sed 's/\.mo//'`
264 mkdir -p $Locale/$lang/LC_MESSAGES
265 cp $file $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
266 echo copy $file to $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
267 if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
270 LINGUAS="$LINGUAS $lang"
277 if [ -d $GTKSTACK_ROOT/share/locale/$l ] ; then
278 echo "Copying GTK i18n files for $l..."
279 cp -r $GTKSTACK_ROOT/share/locale/$l $Locale
281 # try with just the language spec
282 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
283 if [ -d $GTKSTACK_ROOT/share/locale/$just_lang ] ; then
284 echo "Copying GTK i18n files for $l..."
285 cp -r $GTKSTACK_ROOT/share/locale/$just_lang $Locale
290 echo "Skipping NLS support"
294 # Copy stuff that may be dynamically loaded
297 cp -R $GTKSTACK_ROOT/etc/* $Etc
298 echo "Copying all Pango modules ..."
299 cp -R $GTKSTACK_ROOT/lib/pango/1.8.0/modules/*.so $Frameworks/modules
300 echo "Copying all GDK Pixbuf loaders ..."
301 cp -R $GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.so $Frameworks/modules
303 cp -R $GTKSTACK_ROOT/lib/charset.alias $Resources
305 # generate new Pango module file
308 ModulesPath=$GTKSTACK_ROOT/lib/pango/1.8.0/modules
310 env PANGO_RC_FILE=pangorc $GTKSTACK_ROOT/bin/pango-querymodules | sed "s?$GTKSTACK_ROOT/lib/pango/1.8.0/modules/?@executable_path/../lib/modules/?" > $Resources/pango.modules
313 # generate a new GDK pixbufs loaders file
314 gdk-pixbuf-query-loaders | sed "s?$GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/?@executable_path/../lib/modules/?" > $Resources/gdk-pixbuf.loaders
316 # We rely on clearlooks, so include a version from our own build tree
317 # this one is special - we will set GTK_PATH to $Frameworks/gtkengines
319 GTK_ENGINE_DIR=$Frameworks/gtkengines/engines
320 mkdir -p $GTK_ENGINE_DIR
322 echo "Copying GTK engines ..."
323 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.dylib $Frameworks
324 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.dylib . && ln -s ../../libclearlooks.dylib libclearlooks.so)
326 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Frameworks
327 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so)
330 if test x$WITH_LADSPA != x ; then
331 if test x$SAE != x ; then
333 elif test x$MIXBUS != x ; then
334 plugdir=mixbus_ladspa
338 if [ -d $plugdir -a "x$(ls $plugdir)" != x ] ; then
339 echo "Copying `ls $plugdir | wc -l` plugins ..."
340 cp -r $plugdir/* $Plugins
344 # Control Surface shared libraries
345 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.dylib $Surfaces
346 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp*.dylib $Frameworks
349 cp $BUILD_ROOT/libs/panners/*/lib*.dylib $Panners
352 for backend in jack wavesaudio dummy; do
353 cp $BUILD_ROOT/libs/backends/$backend/lib*.dylib $Backends
356 # Export Formats/Presets
357 for f in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
358 cp "$f" $ExportFormats ;
361 # Session and Route templates
362 #for f in $BUILD_ROOT/../templates/* ; do
363 # if [ -d "$f" ] ; then
364 # cp -r "$f" $Templates ;
369 # got to be careful with names here
370 for x in $BUILD_ROOT/../midi_maps/*.map ; do
375 # got to be careful with names here
376 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
381 # got to be careful with names here
382 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
383 cp "$x" $MackieControl
386 # VAMP plugins that we use
387 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.dylib $Frameworks
389 # Suil modules (new dir 'build-stack')
390 if test -d $GTKSTACK_ROOT/lib/suil-0/ ; then
391 cp $GTKSTACK_ROOT/lib/suil-0/lib* $Frameworks
394 # Suil modules (old dir 'build-ardour-stack')
395 if test -d $ARDOURSTACK_ROOT/lib/suil-0/ ; then
396 cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Frameworks
399 # VST scanner app and wrapper script, if they exist
400 if test -d $BUILD_ROOT/libs/fst ; then
401 cp $BUILD_ROOT/libs/fst/ardour-vst-scanner* $Frameworks/
405 if test -f $BUILD_ROOT/libs/vfork/ardour-exec-wrapper ; then
406 mkdir -p $Frameworks/vfork
407 cp $BUILD_ROOT/libs/vfork/ardour-exec-wrapper $Frameworks/
413 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Panners/*.dylib $Backends/*.dylib $Surfaces/*.dylib $Plugins/*.so ; do
414 if ! file $file | grep -qs Mach-O ; then
418 if test x$STRIP != x ; then
419 strip -u -r -arch all $file &>/dev/null
422 deps=`otool -L $file | awk '{print $1}' | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | grep -v 'libjack\.'`
424 for dep in $deps ; do
426 if ! test -f $Frameworks/$base; then
427 if echo $dep | grep -sq '^libs' ; then
428 cp $BUILD_ROOT/$dep $Frameworks
436 if test x$missing = xfalse ; then
437 # everything has been found
443 echo "Copying other stuff to $APPDIR ..."
445 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Resources
447 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Resources
448 cp ../../gtk2_ardour/mixer.bindings $Resources
449 cp ../../gtk2_ardour/step_editing.bindings $Resources
450 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Resources
452 if test x$SAE != x ; then
453 cp $BUILD_ROOT/gtk2_ardour/SAE-de-keypad.bindings $Resources
454 cp $BUILD_ROOT/gtk2_ardour/SAE-de-nokeypad.bindings $Resources
455 cp $BUILD_ROOT/gtk2_ardour/SAE-us-keypad.bindings $Resources
456 cp $BUILD_ROOT/gtk2_ardour/SAE-us-nokeypad.bindings $Resources
457 cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
458 echo cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
460 cp ../../system_config $Resources/system_config
461 cp ../../instant.xml $Resources/instant.xml
462 echo cp ../../instant.xml $Resources/instant.xml
464 cp $BUILD_ROOT/gtk2_ardour/default_ui_config $Resources
465 cp $BUILD_ROOT/gtk2_ardour/dark_fonts.rc $Resources
466 cp $BUILD_ROOT/gtk2_ardour/dark_styles.rc $Resources
467 cp $BUILD_ROOT/gtk2_ardour/light_fonts.rc $Resources
468 cp $BUILD_ROOT/gtk2_ardour/light_styles.rc $Resources
469 cp $BUILD_ROOT/gtk2_ardour/ui_dark.rc $Resources
470 cp $BUILD_ROOT/gtk2_ardour/ui_light.rc $Resources
471 cp $BUILD_ROOT/gtk2_ardour/widgets.rc $Resources
473 cp -r ../../gtk2_ardour/icons $Resources
474 cp -r ../../gtk2_ardour/pixmaps $Resources
477 cp -R ../../gtk2_ardour/splash.png $Shared
478 cp -R ../../gtk2_ardour/small-splash.png $Shared
479 cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared
481 # go through and recursively remove any .svn dirs in the bundle
482 for svndir in `find $APPDIR -name .svn -type dir`; do
486 # install bundled LV2s to <app>/Contents/lib/LV2/
487 cp -R $BUILD_ROOT/libs/LV2 $Frameworks/
489 # now fix up the executables
490 echo "Fixing up executable dependency names ..."
491 executables=$MAIN_EXECUTABLE
492 if test x$SAE != x ; then
493 executables="$executables"
496 for exe in $executables; do
497 EXE=$APPROOT/MacOS/$exe
499 for lib in `otool -L $EXE | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
501 changes="$changes -change $lib @executable_path/../lib/$base"
503 if test "x$changes" != "x" ; then
504 install_name_tool $changes $EXE
508 echo "Fixing up library names ..."
509 # now do the same for all the libraries we include
510 for libdir in $Frameworks $Frameworks/modules $Surfaces $Panners $Backends ; do
512 libbase=`basename $libdir`
514 for dylib in $libdir/*.dylib $libdir/*.so ; do
518 if test -L $dylib ; then
522 # change all the dependencies
525 for lib in `otool -L $dylib | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
527 if echo $lib | grep -s libbase; then
528 changes="$changes -change $lib @executable_path/../$libbase/$base"
530 changes="$changes -change $lib @executable_path/../lib/$base"
534 if test "x$changes" != x ; then
535 if install_name_tool $changes $dylib ; then
542 # now the change what the library thinks its own name is
544 base=`basename $dylib`
545 install_name_tool -id @executable_path/../$libbase/$base $dylib
550 # and now ... the DMG
553 rm -rf $PRODUCT_PKG_DIR
554 mkdir $PRODUCT_PKG_DIR
557 DMGBACKGROUND=dmgbg.png
559 if [ x$SAE != x ] ; then
563 echo "Creating SAE packaging directory"
564 mv $APPDIR $PRODUCT_PKG_DIR/Ardour3-SAE.app
565 cp HowToInstallArdourSAE.pdf "$PRODUCT_PKG_DIR/How To Install Ardour SAE.pdf"
566 cp SAE-de-keypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts (keypad).pdf"
567 cp SAE-de-nokeypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts.pdf"
569 elif [ x$MIXBUS != x ] ; then
573 echo "Creating Mixbus packaging directory"
574 mv $APPDIR $PRODUCT_PKG_DIR/
575 cp MixBus_Install_QuickStart.pdf "$PRODUCT_PKG_DIR/Mixbus Install & Quick Start Guide.pdf"
577 YPOS=$[ $DMGWINBOTTOM - 300 ]
578 MIXBUSPOS="set position of item \"MixBus_Install_QuickStart.pdf\" of container window to {90, ${YPOS}}"
581 echo "Creating $APPNAME packaging directory"
582 mv $APPDIR $PRODUCT_PKG_DIR/
586 if test x$WITH_HARVID != x ; then
587 echo "installing video tools.."
588 HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
589 XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
591 echo "copying harvid and xjadeo ..."
594 rsync://ardour.org/video-tools/harvid-osx-${HARVID_VERSION}.tgz \
595 "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz"
598 rsync://ardour.org/video-tools/jadeo-${XJADEO_VERSION:1}.dmg \
599 "$CACHEDIR/jadeo-${XJADEO_VERSION:1}.dmg"
602 -C $PRODUCT_PKG_DIR/$APPROOT \
603 -f "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz" || exit 1
605 JADEO=$(hdiutil attach "$CACHEDIR/jadeo-${XJADEO_VERSION:1}.dmg" | grep Apple_HFS | grep dev/ | cut -f 3)
606 cp -r "${JADEO}/Jadeo.app" "$PRODUCT_PKG_DIR/"
607 hdiutil detach "${JADEO}"
610 YPOS=$[ $DMGWINBOTTOM - 300 ]
611 XJADEOPOS="set position of item \"Jadeo.app\" of container window to {310, ${YPOS}}"
613 DMGBACKGROUND=dmgbgxj.png
616 echo "Building DMG ..."
618 # UC_DMG=$APPNAME-${release_version}-UC.dmg
619 # FINAL_DMG=$APPNAME-${release_version}.dmg
621 if [ x$DEBUG = xT ]; then
622 UC_DMG=$APPNAME-$release_version-dbg.dmg
624 UC_DMG=$APPNAME-$release_version.dmg
626 VOLNAME=$APPNAME-$release_version
630 MNTPATH=`mktemp -d -t ardourimg`
631 TMPDMG=`mktemp -t ardour`
632 ICNSTMP=`mktemp -t ardouricon`
634 DMGMEGABYTES=$[ `du -sk "$PRODUCT_PKG_DIR" | cut -f 1` * 1024 / 1048576 + $EXTRA_SPACE_MB ]
636 echo "DMG MB = " $DMGMEGABYTES
638 rm -f $UC_DMG "$TMPDMG" "${TMPDMG}.dmg" "$ICNSTMP"
642 TMPDMG="${TMPDMG}.dmg"
644 hdiutil create -megabytes $DMGMEGABYTES "$TMPDMG"
645 DiskDevice=$(hdid -nomount "$TMPDMG" | grep Apple_HFS | cut -f 1 -d ' ')
646 newfs_hfs -v "${VOLNAME}" "${DiskDevice}"
647 mount -t hfs "${DiskDevice}" "${MNTPATH}"
649 cp -r ${PRODUCT_PKG_DIR}/* "${MNTPATH}" || exit
650 mkdir "${MNTPATH}/.background"
651 cp -vi ${DMGBACKGROUND} "${MNTPATH}/.background/dmgbg.png"
653 echo "setting DMG background ..."
655 if test $(sw_vers -productVersion | cut -d '.' -f 2) -lt 9; then
659 # OSX 10.9.X and later
660 DISKNAME=`basename "${MNTPATH}"`
664 tell application "Finder"
666 tell disk "${DISKNAME}"
668 set current view of container window to icon view
669 set toolbar visible of container window to false
670 set statusbar visible of container window to false
671 set the bounds of container window to {400, 200, 800, ${DMGWINBOTTOM}}
672 set theViewOptions to the icon view options of container window
673 set arrangement of theViewOptions to not arranged
674 set icon size of theViewOptions to 64
675 set background picture of theViewOptions to file ".background:dmgbg.png"
676 make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
677 set position of item "${APPDIR}" of container window to {90, 100}
678 set position of item "Applications" of container window to {310, 100}
684 update without registering applications
691 chmod -Rf go-w "${MNTPATH}"
694 echo "compressing Image ..."
697 umount "${DiskDevice}"
698 hdiutil eject "${DiskDevice}"
699 # Create a read-only version, use zlib compression
700 hdiutil convert -format UDZO "${TMPDMG}" -imagekey zlib-level=9 -o "${UC_DMG}"
701 # Delete the temporary files
705 echo "setting file icon ..."
707 cp ${PRODUCT_PKG_DIR}/$Resources/appIcon.icns ${ICNSTMP}.icns
708 sips -i ${ICNSTMP}.icns
709 DeRez -only icns ${ICNSTMP}.icns > ${ICNSTMP}.rsrc
710 Rez -append ${ICNSTMP}.rsrc -o "$UC_DMG"
711 SetFile -a C "$UC_DMG"
713 rm ${ICNSTMP}.icns ${ICNSTMP}.rsrc
716 echo "packaging suceeded."