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
22 while [ $# -gt 0 ] ; do
27 # top level build targets
34 PRODUCT_PKG_DIR=ArdourSAE ;
42 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 # setup directory structure
89 APPROOT=$APPDIR/Contents
90 Frameworks=$APPROOT/lib
91 Resources=$APPROOT/Resources
93 # Since this is OS X, don't try to distinguish between etc and shared
94 # (machine dependent and independent data) - just put everything
99 Locale=$Resources/locale
101 # Bundled Plugins live in a top level folder
103 Plugins=$APPROOT/Plugins
104 Surfaces=$Frameworks/surfaces
105 Panners=$Frameworks/panners
106 Backends=$Frameworks/backends
107 MidiMaps=$Shared/midi_maps
108 ExportFormats=$Shared/export
109 Templates=$Shared/templates
110 PatchFiles=$Shared/patchfiles
111 MackieControl=$Shared/mcp
113 if [ x$PRINT_SYSDEPS != x ] ; then
115 # print system dependencies
118 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Plugins/*.so ; do
119 if ! file $file | grep -qs Mach-O ; then
122 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
127 echo "Removing old $APPDIR tree ..."
131 echo "Building new app directory structure ..."
133 # only bother to make the longest paths
135 mkdir -p $APPROOT/MacOS
136 mkdir -p $APPROOT/Resources
142 mkdir -p $ExportFormats
144 mkdir -p $Frameworks/modules
146 mkdir -p $MackieControl
149 # maybe set variables
151 if test x$SAE != x ; then
152 appname="Ardour3/SAE"
153 env="$env<key>ARDOUR_SAE</key><string>true</string>"
155 # current default for SAE version is German keyboard layout without a keypad
157 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>de-nokeypad</string>"
158 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui_sae.conf</string>"
159 env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark_sae.rc</string>"
160 elif test x$MIXBUS != x ; then
161 appname="Ardour3/Mixbus"
162 env="$env<key>ARDOUR_MIXBUS</key><string>true</string>"
164 # current default for MIXBUS version is US keyboard layout without a keypad
166 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>us-nokeypad</string>"
167 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui.conf</string>"
168 env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark.rc</string>"
174 # if we're not going to bundle JACK, make sure we can find
175 # jack in the places where it might be
178 env="$env<key>PATH</key><string>/usr/local/bin:/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>"
179 env="$env<key>DYLIB_FALLBACK_LIBRARY_PATH</key><string>/usr/local/lib:/opt/lib</string>"
181 env="<key>LSEnvironment</key><dict>$env<key>ARDOUR_BUNDLED</key><string>true</string></dict>"
184 sed -e "s?@ENV@?$env?g" \
185 -e "s?@VERSION@?$release_version?g" \
186 -e "s?@INFOSTRING@?$info_string?g" < Info.plist.in > Info.plist
188 sed -e "s?@APPNAME@?$appname?" \
189 -e "s?@ENV@?$env?g" \
190 -e "s?@VERSION@?$release_version?g" \
191 -e "s?@INFOSTRING@?$info_string?g" < InfoPlist.strings.in > Resources/InfoPlist.strings || exit 1
195 cp Info.plist $APPROOT
196 cp -R Resources $APPROOT
199 # if we build a bundle without jack, then
200 # make the Ardour3 executable a helper
201 # script that checks to see if JACK is
205 cp startup_script $APPROOT/MacOS/Ardour3
206 chmod 775 $APPROOT/MacOS/Ardour3
207 MAIN_EXECUTABLE=Ardour3.bin
209 echo "Copying ardour executable ...."
210 cp $BUILD_ROOT/gtk2_ardour/ardour-$release_version $APPROOT/MacOS/$MAIN_EXECUTABLE
211 if test x$SAE != x ; then
212 # cp $BUILD_ROOT/gtk2_ardour/evtest $APPROOT/MacOS/gtkevents
213 cp Ardour3-SAE.icns $Resources/appIcon.icns
214 elif test x$MIXBUS != x ; then
215 cp Mixbus.icns $Resources/appIcon.icns
217 cp Ardour3.icns $Resources/appIcon.icns
219 cp typeArdour.icns $Resources/
220 if test x$STRIP != x ; then
221 strip $APPROOT/MacOS/Ardour3
225 if test x$WITH_NLS != x ; then
226 echo "NLS support ..."
227 echo "I hope you remembered to run waf i18n"
230 for pkg in gtk2_ardour libs/ardour libs/gtkmm2ext ; do
231 files=`find ../../$pkg -name "*.mo"`
234 # the package name is appended with a number so that
235 # it can be parallel installed during a regular install
236 # with older (and newer) versions. it is just the major
237 # number of the release (i.e. leading digits)
240 vsuffix=`echo $release_version | sed 's/^\([0-9][0-9]*\).*/\1/'`
242 if [ -z "$files" ]; then
244 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$pkg"
251 lang=`basename $file | sed 's/\.mo//'`
252 mkdir -p $Locale/$lang/LC_MESSAGES
253 cp $file $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
254 echo copy $file to $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
255 if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
258 LINGUAS="$LINGUAS $lang"
265 if [ -d $GTKSTACK_ROOT/share/locale/$l ] ; then
266 echo "Copying GTK i18n files for $l..."
267 cp -r $GTKSTACK_ROOT/share/locale/$l $Locale
269 # try with just the language spec
270 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
271 if [ -d $GTKSTACK_ROOT/share/locale/$just_lang ] ; then
272 echo "Copying GTK i18n files for $l..."
273 cp -r $GTKSTACK_ROOT/share/locale/$just_lang $Locale
278 echo "Skipping NLS support"
282 # Copy stuff that may be dynamically loaded
285 cp -R $GTKSTACK_ROOT/etc/* $Etc
286 echo "Copying all Pango modules ..."
287 cp -R $GTKSTACK_ROOT/lib/pango/1.8.0/modules/*.so $Frameworks/modules
288 echo "Copying all GDK Pixbuf loaders ..."
289 cp -R $GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.so $Frameworks/modules
291 cp -R $GTKSTACK_ROOT/lib/charset.alias $Resources
293 # generate new Pango module file
296 ModulesPath=$GTKSTACK_ROOT/lib/pango/1.8.0/modules
298 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
301 # generate a new GDK pixbufs loaders file
302 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
304 # We rely on clearlooks, so include a version from our own build tree
305 # this one is special - we will set GTK_PATH to $Frameworks/gtkengines
307 GTK_ENGINE_DIR=$Frameworks/gtkengines/engines
308 mkdir -p $GTK_ENGINE_DIR
310 echo "Copying GTK engines ..."
311 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.dylib $Frameworks
312 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.dylib . && ln -s ../../libclearlooks.dylib libclearlooks.so)
314 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Frameworks
315 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so)
318 if test x$WITH_LADSPA != x ; then
319 if test x$SAE != x ; then
321 elif test x$MIXBUS != x ; then
322 plugdir=mixbus_ladspa
326 if [ -d $plugdir -a "x$(ls $plugdir)" != x ] ; then
327 echo "Copying `ls $plugdir | wc -l` plugins ..."
328 cp -r $plugdir/* $Plugins
332 # Control Surface shared libraries
333 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.dylib $Surfaces
334 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp*.dylib $Frameworks
337 cp $BUILD_ROOT/libs/panners/*/lib*.dylib $Panners
340 cp $BUILD_ROOT/libs/backends/*/lib*.dylib $Backends
342 # Export Formats/Presets
343 for f in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
344 cp "$f" $ExportFormats ;
347 # Session and Route templates
348 #for f in $BUILD_ROOT/../templates/* ; do
349 # if [ -d "$f" ] ; then
350 # cp -r "$f" $Templates ;
355 # got to be careful with names here
356 for x in $BUILD_ROOT/../midi_maps/*.map ; do
361 # got to be careful with names here
362 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
367 # got to be careful with names here
368 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
369 cp "$x" $MackieControl
372 # VAMP plugins that we use
373 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.dylib $Frameworks
376 cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Frameworks
378 # VST scanner app and wrapper script, if they exist
379 cp $BUILD_ROOT/libs/fst/ardour-vst-scanner* $Frameworks/ || true
382 cp $BUILD_ROOT/libs/vfork/ardour-exec-wrapper $Frameworks/
387 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Panners/*.dylib $Backends/*.dylib $Surfaces/*.dylib $Plugins/*.so ; do
388 if ! file $file | grep -qs Mach-O ; then
391 deps=`otool -L $file | awk '{print $1}' | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | grep -v 'libjack\.'`
393 for dep in $deps ; do
395 if ! test -f $Frameworks/$base; then
396 if echo $dep | grep -sq '^libs' ; then
397 cp $BUILD_ROOT/$dep $Frameworks
405 if test x$missing = xfalse ; then
406 # everything has been found
412 echo "Copying other stuff to $APPDIR ..."
414 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Resources
416 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Resources
417 cp ../../gtk2_ardour/mixer.bindings $Resources
418 cp ../../gtk2_ardour/step_editing.bindings $Resources
419 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Resources
421 if test x$SAE != x ; then
422 cp $BUILD_ROOT/gtk2_ardour/SAE-de-keypad.bindings $Resources
423 cp $BUILD_ROOT/gtk2_ardour/SAE-de-nokeypad.bindings $Resources
424 cp $BUILD_ROOT/gtk2_ardour/SAE-us-keypad.bindings $Resources
425 cp $BUILD_ROOT/gtk2_ardour/SAE-us-nokeypad.bindings $Resources
426 cp $BUILD_ROOT/ardour_system_sae.rc $Resources/ardour_system.rc
427 echo cp $BUILD_ROOT/ardour_system_sae.rc $Resources/ardour_system.rc
428 cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
429 echo cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
431 cp ../../ardour_system.rc $Resources/ardour_system.rc
432 cp ../../instant.xml $Resources/instant.xml
433 echo cp ../../instant.xml $Resources/instant.xml
435 cp ../../gtk2_ardour/ardour3_ui_default.conf $Resources
436 cp ../../gtk2_ardour/ardour3_ui_default.conf $Resources/ardour3_ui.conf
437 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_light.rc $Resources
438 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_dark.rc $Resources
440 cp -r ../../gtk2_ardour/icons $Resources
441 cp -r ../../gtk2_ardour/pixmaps $Resources
444 cp -R ../../gtk2_ardour/splash.png $Shared
445 cp -R ../../gtk2_ardour/small-splash.png $Shared
446 cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared
448 # go through and recursively remove any .svn dirs in the bundle
449 for svndir in `find $APPDIR -name .svn -type dir`; do
453 # install bundled LV2s to <app>/Contents/lib/LV2/
454 cp -R $BUILD_ROOT/libs/LV2 $Frameworks/
456 # now fix up the executables
457 echo "Fixing up executable dependency names ..."
458 executables=$MAIN_EXECUTABLE
459 if test x$SAE != x ; then
460 executables="$executables"
463 for exe in $executables; do
464 EXE=$APPROOT/MacOS/$exe
466 for lib in `otool -L $EXE | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
468 changes="$changes -change $lib @executable_path/../lib/$base"
470 if test "x$changes" != "x" ; then
471 install_name_tool $changes $EXE
475 echo "Fixing up library names ..."
476 # now do the same for all the libraries we include
477 for libdir in $Frameworks $Frameworks/modules $Surfaces $Panners $Backends ; do
479 libbase=`basename $libdir`
481 for dylib in $libdir/*.dylib $libdir/*.so ; do
485 if test -L $dylib ; then
489 # change all the dependencies
492 for lib in `otool -L $dylib | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
494 if echo $lib | grep -s libbase; then
495 changes="$changes -change $lib @executable_path/../$libbase/$base"
497 changes="$changes -change $lib @executable_path/../lib/$base"
501 if test "x$changes" != x ; then
502 if install_name_tool $changes $dylib ; then
509 # now the change what the library thinks its own name is
511 base=`basename $dylib`
512 install_name_tool -id @executable_path/../$libbase/$base $dylib
517 # and now ... the DMG
520 rm -rf $PRODUCT_PKG_DIR
521 mkdir $PRODUCT_PKG_DIR
524 DMGBACKGROUND=dmgbg.png
526 if [ x$SAE != x ] ; then
530 echo "Creating SAE packaging directory"
531 mv $APPDIR $PRODUCT_PKG_DIR/Ardour3-SAE.app
532 cp HowToInstallArdourSAE.pdf "$PRODUCT_PKG_DIR/How To Install Ardour SAE.pdf"
533 cp SAE-de-keypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts (keypad).pdf"
534 cp SAE-de-nokeypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts.pdf"
536 elif [ x$MIXBUS != x ] ; then
540 echo "Creating Mixbus packaging directory"
541 mv $APPDIR $PRODUCT_PKG_DIR/
542 cp MixBus_Install_QuickStart.pdf "$PRODUCT_PKG_DIR/Mixbus Install & Quick Start Guide.pdf"
544 YPOS=$[ $DMGWINBOTTOM - 300 ]
545 MIXBUSPOS="set position of item \"MixBus_Install_QuickStart.pdf\" of container window to {90, ${YPOS}}"
548 echo "Creating $APPNAME packaging directory"
549 mv $APPDIR $PRODUCT_PKG_DIR/
553 if test x$WITH_HARVID != x ; then
554 echo "installing video tools.."
555 HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
556 XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
557 echo "copying harvid and xjadeo ..."
560 rsync://ardour.org/video-tools/harvid-osx-${HARVID_VERSION}.tgz \
561 "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz"
564 rsync://ardour.org/video-tools/jadeo-${XJADEO_VERSION:1}.dmg \
565 "$CACHEDIR/jadeo-${XJADEO_VERSION:1}.dmg"
568 -C $PRODUCT_PKG_DIR/$APPROOT \
569 -f "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz" || exit 1
571 JADEO=$(hdiutil attach "$CACHEDIR/jadeo-${XJADEO_VERSION:1}.dmg" | grep Apple_HFS | grep dev/ | cut -f 3)
572 cp -r "${JADEO}/Jadeo.app" "$PRODUCT_PKG_DIR/"
573 hdiutil detach "${JADEO}"
576 YPOS=$[ $DMGWINBOTTOM - 300 ]
577 XJADEOPOS="set position of item \"Jadeo.app\" of container window to {310, ${YPOS}}"
579 DMGBACKGROUND=dmgbgxj.png
582 echo "Building DMG ..."
584 # UC_DMG=$APPNAME-${release_version}-UC.dmg
585 # FINAL_DMG=$APPNAME-${release_version}.dmg
586 UC_DMG=$APPNAME-$release_version.dmg
587 VOLNAME=$APPNAME-$release_version
591 MNTPATH=`mktemp -d -t /ardourimg`
592 TMPDMG=`mktemp -t ardour`
593 ICNSTMP=`mktemp -t ardouricon`
595 DMGMEGABYTES=$[ `du -sk "$PRODUCT_PKG_DIR" | cut -f 1` * 1024 / 1048576 + $EXTRA_SPACE_MB ]
597 echo "DMG MB = " $DMGMEGABYTES
599 rm -f $UC_DMG "$TMPDMG" "${TMPDMG}.dmg" "$ICNSTMP"
603 TMPDMG="${TMPDMG}.dmg"
605 hdiutil create -megabytes $DMGMEGABYTES "$TMPDMG"
606 DiskDevice=$(hdid -nomount "$TMPDMG" | grep Apple_HFS | cut -f 1 -d ' ')
607 newfs_hfs -v "${VOLNAME}" "${DiskDevice}"
608 mount -t hfs "${DiskDevice}" "${MNTPATH}"
610 cp -r ${PRODUCT_PKG_DIR}/* "${MNTPATH}" || exit
611 mkdir "${MNTPATH}/.background"
612 cp -vi ${DMGBACKGROUND} "${MNTPATH}/.background/dmgbg.png"
614 echo "setting DMG background ..."
617 tell application "Finder"
618 tell disk "'${VOLNAME}'"
620 set current view of container window to icon view
621 set toolbar visible of container window to false
622 set statusbar visible of container window to false
623 set the bounds of container window to {400, 200, 800, '${DMGWINBOTTOM}'}
624 set theViewOptions to the icon view options of container window
625 set arrangement of theViewOptions to not arranged
626 set icon size of theViewOptions to 64
627 set background picture of theViewOptions to file ".background:dmgbg.png"
628 make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
629 set position of item "'${APPDIR}'" of container window to {90, 100}
630 set position of item "Applications" of container window to {310, 100}
636 update without registering applications
643 chmod -Rf go-w "${MNTPATH}"
646 echo "compressing Image ..."
649 umount "${DiskDevice}"
650 hdiutil eject "${DiskDevice}"
651 # Create a read-only version, use zlib compression
652 hdiutil convert -format UDZO "${TMPDMG}" -imagekey zlib-level=9 -o "${UC_DMG}"
653 # Delete the temporary files
657 echo "setting file icon ..."
659 cp ${PRODUCT_PKG_DIR}/$Resources/appIcon.icns ${ICNSTMP}.icns
660 /usr/bin/sips -i ${ICNSTMP}.icns
661 /Developer/Tools/DeRez -only icns ${ICNSTMP}.icns > ${ICNSTMP}.rsrc
662 /Developer/Tools/Rez -append ${ICNSTMP}.rsrc -o "$UC_DMG"
663 /Developer/Tools/SetFile -a C "$UC_DMG"
665 rm ${ICNSTMP}.icns ${ICNSTMP}.rsrc
668 echo "packaging suceeded."