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;
50 PRODUCT_PKG_DIR=Ardour;
57 PRODUCT_PKG_DIR=Ardour ;
59 --test) SAE= ; WITH_LADSPA=; STRIP= ; shift ;;
62 # specific build flags
65 --noharvid) WITH_HARVID= ; shift ;;
66 --noladspa) WITH_LADSPA= ; shift ;;
67 --nostrip) STRIP= ; shift ;;
68 --sysdeps) PRINT_SYSDEPS=1; shift ;;
69 --nls) WITH_NLS=1 ; shift ;;
73 if test -z "$PRODUCT_PKG_DIR" -o -z "$APPNAME"; then
74 echo "application or product-name was not specified"
78 . ../define_versions.sh
79 echo "Version is $release_version"
80 if [ "x$commit" != "x" ] ; then
81 info_string="$release_version ($commit) built on `hostname` by `whoami` on `date`"
83 info_string="$release_version built on `hostname` by `whoami` on `date`"
85 echo "Info string is $info_string"
87 # setup directory structure
90 APPROOT=$APPDIR/Contents
91 Frameworks=$APPROOT/lib
92 Resources=$APPROOT/Resources
94 # Since this is OS X, don't try to distinguish between etc and shared
95 # (machine dependent and independent data) - just put everything
100 Locale=$Resources/locale
102 # Bundled Plugins live in a top level folder
104 Plugins=$APPROOT/Plugins
105 Surfaces=$Frameworks/surfaces
106 Panners=$Frameworks/panners
107 Backends=$Frameworks/backends
108 MidiMaps=$Shared/midi_maps
109 ExportFormats=$Shared/export
110 Templates=$Shared/templates
111 PatchFiles=$Shared/patchfiles
112 MackieControl=$Shared/mcp
114 if [ x$PRINT_SYSDEPS != x ] ; then
116 # print system dependencies
119 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Plugins/*.so ; do
120 if ! file $file | grep -qs Mach-O ; then
123 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
128 echo "Removing old $APPDIR tree ..."
132 echo "Building new app directory structure ..."
134 # only bother to make the longest paths
136 mkdir -p $APPROOT/MacOS
137 mkdir -p $APPROOT/Resources
143 mkdir -p $ExportFormats
145 mkdir -p $Frameworks/modules
147 mkdir -p $MackieControl
150 # maybe set variables
152 if test x$SAE != x ; then
153 appname="Ardour3/SAE"
154 env="$env<key>ARDOUR_SAE</key><string>true</string>"
156 # current default for SAE version is German keyboard layout without a keypad
158 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>de-nokeypad</string>"
159 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui_sae.conf</string>"
160 env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark_sae.rc</string>"
161 elif test x$MIXBUS != x ; then
162 appname="Ardour3/Mixbus"
163 env="$env<key>ARDOUR_MIXBUS</key><string>true</string>"
165 # current default for MIXBUS version is US keyboard layout without a keypad
167 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>us-nokeypad</string>"
168 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui.conf</string>"
169 env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark.rc</string>"
175 # if we're not going to bundle JACK, make sure we can find
176 # jack in the places where it might be
179 env="$env<key>PATH</key><string>/usr/local/bin:/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>"
180 env="$env<key>DYLIB_FALLBACK_LIBRARY_PATH</key><string>/usr/local/lib:/opt/lib</string>"
182 env="<key>LSEnvironment</key><dict>$env<key>ARDOUR_BUNDLED</key><string>true</string></dict>"
185 sed -e "s?@ENV@?$env?g" \
186 -e "s?@VERSION@?$release_version?g" \
187 -e "s?@INFOSTRING@?$info_string?g" < Info.plist.in > Info.plist
189 sed -e "s?@APPNAME@?$appname?" \
190 -e "s?@ENV@?$env?g" \
191 -e "s?@VERSION@?$release_version?g" \
192 -e "s?@INFOSTRING@?$info_string?g" < InfoPlist.strings.in > Resources/InfoPlist.strings || exit 1
196 cp Info.plist $APPROOT
197 cp -R Resources $APPROOT
201 rm -f Resources/InfoPlist.strings
204 # if we build a bundle without jack, then
205 # make the Ardour3 executable a helper
206 # script that checks to see if JACK is
210 cp startup_script $APPROOT/MacOS/Ardour3
211 chmod 775 $APPROOT/MacOS/Ardour3
212 MAIN_EXECUTABLE=Ardour3.bin
214 echo "Copying ardour executable ...."
215 cp $BUILD_ROOT/gtk2_ardour/ardour-$release_version $APPROOT/MacOS/$MAIN_EXECUTABLE
216 if test x$SAE != x ; then
217 # cp $BUILD_ROOT/gtk2_ardour/evtest $APPROOT/MacOS/gtkevents
218 cp Ardour3-SAE.icns $Resources/appIcon.icns
219 elif test x$MIXBUS != x ; then
220 cp Mixbus.icns $Resources/appIcon.icns
222 cp Ardour3.icns $Resources/appIcon.icns
224 cp typeArdour.icns $Resources/
225 if test x$STRIP != x ; then
226 strip $APPROOT/MacOS/Ardour3
230 if test x$WITH_NLS != x ; then
231 echo "NLS support ..."
232 echo "I hope you remembered to run waf i18n"
235 for pkg in gtk2_ardour libs/ardour libs/gtkmm2ext ; do
236 files=`find ../../$pkg -name "*.mo"`
239 # the package name is appended with a number so that
240 # it can be parallel installed during a regular install
241 # with older (and newer) versions. it is just the major
242 # number of the release (i.e. leading digits)
245 vsuffix=`echo $release_version | sed 's/^\([0-9][0-9]*\).*/\1/'`
247 if [ -z "$files" ]; then
249 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$pkg"
256 lang=`basename $file | sed 's/\.mo//'`
257 mkdir -p $Locale/$lang/LC_MESSAGES
258 cp $file $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
259 echo copy $file to $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
260 if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
263 LINGUAS="$LINGUAS $lang"
270 if [ -d $GTKSTACK_ROOT/share/locale/$l ] ; then
271 echo "Copying GTK i18n files for $l..."
272 cp -r $GTKSTACK_ROOT/share/locale/$l $Locale
274 # try with just the language spec
275 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
276 if [ -d $GTKSTACK_ROOT/share/locale/$just_lang ] ; then
277 echo "Copying GTK i18n files for $l..."
278 cp -r $GTKSTACK_ROOT/share/locale/$just_lang $Locale
283 echo "Skipping NLS support"
287 # Copy stuff that may be dynamically loaded
290 cp -R $GTKSTACK_ROOT/etc/* $Etc
291 echo "Copying all Pango modules ..."
292 cp -R $GTKSTACK_ROOT/lib/pango/1.8.0/modules/*.so $Frameworks/modules
293 echo "Copying all GDK Pixbuf loaders ..."
294 cp -R $GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.so $Frameworks/modules
296 cp -R $GTKSTACK_ROOT/lib/charset.alias $Resources
298 # generate new Pango module file
301 ModulesPath=$GTKSTACK_ROOT/lib/pango/1.8.0/modules
303 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
306 # generate a new GDK pixbufs loaders file
307 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
309 # We rely on clearlooks, so include a version from our own build tree
310 # this one is special - we will set GTK_PATH to $Frameworks/gtkengines
312 GTK_ENGINE_DIR=$Frameworks/gtkengines/engines
313 mkdir -p $GTK_ENGINE_DIR
315 echo "Copying GTK engines ..."
316 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.dylib $Frameworks
317 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.dylib . && ln -s ../../libclearlooks.dylib libclearlooks.so)
319 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Frameworks
320 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so)
323 if test x$WITH_LADSPA != x ; then
324 if test x$SAE != x ; then
326 elif test x$MIXBUS != x ; then
327 plugdir=mixbus_ladspa
331 if [ -d $plugdir -a "x$(ls $plugdir)" != x ] ; then
332 echo "Copying `ls $plugdir | wc -l` plugins ..."
333 cp -r $plugdir/* $Plugins
337 # Control Surface shared libraries
338 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.dylib $Surfaces
339 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp*.dylib $Frameworks
342 cp $BUILD_ROOT/libs/panners/*/lib*.dylib $Panners
345 for backend in jack wavesaudio dummy; do
346 cp $BUILD_ROOT/libs/backends/$backend/lib*.dylib $Backends
349 # Export Formats/Presets
350 for f in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
351 cp "$f" $ExportFormats ;
354 # Session and Route templates
355 #for f in $BUILD_ROOT/../templates/* ; do
356 # if [ -d "$f" ] ; then
357 # cp -r "$f" $Templates ;
362 # got to be careful with names here
363 for x in $BUILD_ROOT/../midi_maps/*.map ; do
368 # got to be careful with names here
369 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
374 # got to be careful with names here
375 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
376 cp "$x" $MackieControl
379 # VAMP plugins that we use
380 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.dylib $Frameworks
382 # Suil modules (new dir 'build-stack')
383 if test -d $GTKSTACK_ROOT/lib/suil-0/ ; then
384 cp $GTKSTACK_ROOT/lib/suil-0/lib* $Frameworks
387 # Suil modules (old dir 'build-ardour-stack')
388 if test -d $ARDOURSTACK_ROOT/lib/suil-0/ ; then
389 cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Frameworks
392 # VST scanner app and wrapper script, if they exist
393 if test -d $BUILD_ROOT/libs/fst ; then
394 cp $BUILD_ROOT/libs/fst/ardour-vst-scanner* $Frameworks/
398 if test -f $BUILD_ROOT/libs/vfork/ardour-exec-wrapper ; then
399 mkdir -p $Frameworks/vfork
400 cp $BUILD_ROOT/libs/vfork/ardour-exec-wrapper $Frameworks/
406 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Panners/*.dylib $Backends/*.dylib $Surfaces/*.dylib $Plugins/*.so ; do
407 if ! file $file | grep -qs Mach-O ; then
410 deps=`otool -L $file | awk '{print $1}' | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | grep -v 'libjack\.'`
412 for dep in $deps ; do
414 if ! test -f $Frameworks/$base; then
415 if echo $dep | grep -sq '^libs' ; then
416 cp $BUILD_ROOT/$dep $Frameworks
424 if test x$missing = xfalse ; then
425 # everything has been found
431 echo "Copying other stuff to $APPDIR ..."
433 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Resources
435 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Resources
436 cp ../../gtk2_ardour/mixer.bindings $Resources
437 cp ../../gtk2_ardour/step_editing.bindings $Resources
438 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Resources
440 if test x$SAE != x ; then
441 cp $BUILD_ROOT/gtk2_ardour/SAE-de-keypad.bindings $Resources
442 cp $BUILD_ROOT/gtk2_ardour/SAE-de-nokeypad.bindings $Resources
443 cp $BUILD_ROOT/gtk2_ardour/SAE-us-keypad.bindings $Resources
444 cp $BUILD_ROOT/gtk2_ardour/SAE-us-nokeypad.bindings $Resources
445 cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
446 echo cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
448 cp ../../system_config $Resources/system_config
449 cp ../../instant.xml $Resources/instant.xml
450 echo cp ../../instant.xml $Resources/instant.xml
452 cp $BUILD_ROOT/gtk2_ardour/default_ui_config $Resources
453 cp $BUILD_ROOT/gtk2_ardour/dark_fonts.rc $Resources
454 cp $BUILD_ROOT/gtk2_ardour/dark_styles.rc $Resources
455 cp $BUILD_ROOT/gtk2_ardour/light_fonts.rc $Resources
456 cp $BUILD_ROOT/gtk2_ardour/light_styles.rc $Resources
457 cp $BUILD_ROOT/gtk2_ardour/ui_dark.rc $Resources
458 cp $BUILD_ROOT/gtk2_ardour/ui_light.rc $Resources
459 cp $BUILD_ROOT/gtk2_ardour/widgets.rc $Resources
461 cp -r ../../gtk2_ardour/icons $Resources
462 cp -r ../../gtk2_ardour/pixmaps $Resources
465 cp -R ../../gtk2_ardour/splash.png $Shared
466 cp -R ../../gtk2_ardour/small-splash.png $Shared
467 cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared
469 # go through and recursively remove any .svn dirs in the bundle
470 for svndir in `find $APPDIR -name .svn -type dir`; do
474 # install bundled LV2s to <app>/Contents/lib/LV2/
475 cp -R $BUILD_ROOT/libs/LV2 $Frameworks/
477 # now fix up the executables
478 echo "Fixing up executable dependency names ..."
479 executables=$MAIN_EXECUTABLE
480 if test x$SAE != x ; then
481 executables="$executables"
484 for exe in $executables; do
485 EXE=$APPROOT/MacOS/$exe
487 for lib in `otool -L $EXE | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
489 changes="$changes -change $lib @executable_path/../lib/$base"
491 if test "x$changes" != "x" ; then
492 install_name_tool $changes $EXE
496 echo "Fixing up library names ..."
497 # now do the same for all the libraries we include
498 for libdir in $Frameworks $Frameworks/modules $Surfaces $Panners $Backends ; do
500 libbase=`basename $libdir`
502 for dylib in $libdir/*.dylib $libdir/*.so ; do
506 if test -L $dylib ; then
510 # change all the dependencies
513 for lib in `otool -L $dylib | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
515 if echo $lib | grep -s libbase; then
516 changes="$changes -change $lib @executable_path/../$libbase/$base"
518 changes="$changes -change $lib @executable_path/../lib/$base"
522 if test "x$changes" != x ; then
523 if install_name_tool $changes $dylib ; then
530 # now the change what the library thinks its own name is
532 base=`basename $dylib`
533 install_name_tool -id @executable_path/../$libbase/$base $dylib
538 # and now ... the DMG
541 rm -rf $PRODUCT_PKG_DIR
542 mkdir $PRODUCT_PKG_DIR
545 DMGBACKGROUND=dmgbg.png
547 if [ x$SAE != x ] ; then
551 echo "Creating SAE packaging directory"
552 mv $APPDIR $PRODUCT_PKG_DIR/Ardour3-SAE.app
553 cp HowToInstallArdourSAE.pdf "$PRODUCT_PKG_DIR/How To Install Ardour SAE.pdf"
554 cp SAE-de-keypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts (keypad).pdf"
555 cp SAE-de-nokeypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts.pdf"
557 elif [ x$MIXBUS != x ] ; then
561 echo "Creating Mixbus packaging directory"
562 mv $APPDIR $PRODUCT_PKG_DIR/
563 cp MixBus_Install_QuickStart.pdf "$PRODUCT_PKG_DIR/Mixbus Install & Quick Start Guide.pdf"
565 YPOS=$[ $DMGWINBOTTOM - 300 ]
566 MIXBUSPOS="set position of item \"MixBus_Install_QuickStart.pdf\" of container window to {90, ${YPOS}}"
569 echo "Creating $APPNAME packaging directory"
570 mv $APPDIR $PRODUCT_PKG_DIR/
574 if test x$WITH_HARVID != x ; then
575 echo "installing video tools.."
576 HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
577 XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
579 echo "copying harvid and xjadeo ..."
582 rsync://ardour.org/video-tools/harvid-osx-${HARVID_VERSION}.tgz \
583 "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz"
586 rsync://ardour.org/video-tools/jadeo-${XJADEO_VERSION:1}.dmg \
587 "$CACHEDIR/jadeo-${XJADEO_VERSION:1}.dmg"
590 -C $PRODUCT_PKG_DIR/$APPROOT \
591 -f "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz" || exit 1
593 JADEO=$(hdiutil attach "$CACHEDIR/jadeo-${XJADEO_VERSION:1}.dmg" | grep Apple_HFS | grep dev/ | cut -f 3)
594 cp -r "${JADEO}/Jadeo.app" "$PRODUCT_PKG_DIR/"
595 hdiutil detach "${JADEO}"
598 YPOS=$[ $DMGWINBOTTOM - 300 ]
599 XJADEOPOS="set position of item \"Jadeo.app\" of container window to {310, ${YPOS}}"
601 DMGBACKGROUND=dmgbgxj.png
604 echo "Building DMG ..."
606 # UC_DMG=$APPNAME-${release_version}-UC.dmg
607 # FINAL_DMG=$APPNAME-${release_version}.dmg
608 UC_DMG=$APPNAME-$release_version.dmg
609 VOLNAME=$APPNAME-$release_version
613 MNTPATH=`mktemp -d -t ardourimg`
614 TMPDMG=`mktemp -t ardour`
615 ICNSTMP=`mktemp -t ardouricon`
617 DMGMEGABYTES=$[ `du -sk "$PRODUCT_PKG_DIR" | cut -f 1` * 1024 / 1048576 + $EXTRA_SPACE_MB ]
619 echo "DMG MB = " $DMGMEGABYTES
621 rm -f $UC_DMG "$TMPDMG" "${TMPDMG}.dmg" "$ICNSTMP"
625 TMPDMG="${TMPDMG}.dmg"
627 hdiutil create -megabytes $DMGMEGABYTES "$TMPDMG"
628 DiskDevice=$(hdid -nomount "$TMPDMG" | grep Apple_HFS | cut -f 1 -d ' ')
629 newfs_hfs -v "${VOLNAME}" "${DiskDevice}"
630 mount -t hfs "${DiskDevice}" "${MNTPATH}"
632 cp -r ${PRODUCT_PKG_DIR}/* "${MNTPATH}" || exit
633 mkdir "${MNTPATH}/.background"
634 cp -vi ${DMGBACKGROUND} "${MNTPATH}/.background/dmgbg.png"
636 echo "setting DMG background ..."
638 if test $(sw_vers -productVersion | cut -d '.' -f 2) -lt 9; then
642 # OSX 10.9.X and later
643 DISKNAME=`basename "${MNTPATH}"`
647 tell application "Finder"
649 tell disk "${DISKNAME}"
651 set current view of container window to icon view
652 set toolbar visible of container window to false
653 set statusbar visible of container window to false
654 set the bounds of container window to {400, 200, 800, ${DMGWINBOTTOM}}
655 set theViewOptions to the icon view options of container window
656 set arrangement of theViewOptions to not arranged
657 set icon size of theViewOptions to 64
658 set background picture of theViewOptions to file ".background:dmgbg.png"
659 make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
660 set position of item "${APPDIR}" of container window to {90, 100}
661 set position of item "Applications" of container window to {310, 100}
667 update without registering applications
674 chmod -Rf go-w "${MNTPATH}"
677 echo "compressing Image ..."
680 umount "${DiskDevice}"
681 hdiutil eject "${DiskDevice}"
682 # Create a read-only version, use zlib compression
683 hdiutil convert -format UDZO "${TMPDMG}" -imagekey zlib-level=9 -o "${UC_DMG}"
684 # Delete the temporary files
688 echo "setting file icon ..."
690 cp ${PRODUCT_PKG_DIR}/$Resources/appIcon.icns ${ICNSTMP}.icns
691 sips -i ${ICNSTMP}.icns
692 DeRez -only icns ${ICNSTMP}.icns > ${ICNSTMP}.rsrc
693 Rez -append ${ICNSTMP}.rsrc -o "$UC_DMG"
694 SetFile -a C "$UC_DMG"
696 rm ${ICNSTMP}.icns ${ICNSTMP}.rsrc
699 echo "packaging suceeded."