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 elif test x$MIXBUS != x ; then
171 appname="Ardour3/Mixbus"
172 env="$env<key>ARDOUR_MIXBUS</key><string>true</string>"
174 # current default for MIXBUS version is US keyboard layout without a keypad
176 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>us-nokeypad</string>"
177 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui.conf</string>"
183 # if we're not going to bundle JACK, make sure we can find
184 # jack in the places where it might be
187 env="$env<key>PATH</key><string>/usr/local/bin:/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>"
188 env="$env<key>DYLIB_FALLBACK_LIBRARY_PATH</key><string>/usr/local/lib:/opt/lib</string>"
190 env="<key>LSEnvironment</key><dict>$env<key>ARDOUR_BUNDLED</key><string>true</string></dict>"
193 sed -e "s?@ENV@?$env?g" \
194 -e "s?@VERSION@?$release_version?g" \
195 -e "s?@INFOSTRING@?$info_string?g" < Info.plist.in > Info.plist
197 sed -e "s?@APPNAME@?$appname?" \
198 -e "s?@ENV@?$env?g" \
199 -e "s?@VERSION@?$release_version?g" \
200 -e "s?@INFOSTRING@?$info_string?g" < InfoPlist.strings.in > Resources/InfoPlist.strings || exit 1
204 cp Info.plist $APPROOT
205 cp -R Resources $APPROOT
209 rm -f Resources/InfoPlist.strings
212 # if we build a bundle without jack, then
213 # make the Ardour3 executable a helper
214 # script that checks to see if JACK is
218 cp startup_script $APPROOT/MacOS/Ardour3
219 chmod 775 $APPROOT/MacOS/Ardour3
220 MAIN_EXECUTABLE=Ardour3.bin
222 echo "Copying ardour executable ...."
223 cp $BUILD_ROOT/gtk2_ardour/ardour-$release_version $APPROOT/MacOS/$MAIN_EXECUTABLE
224 if test x$SAE != x ; then
225 # cp $BUILD_ROOT/gtk2_ardour/evtest $APPROOT/MacOS/gtkevents
226 cp Ardour3-SAE.icns $Resources/appIcon.icns
227 elif test x$MIXBUS != x ; then
228 cp Mixbus.icns $Resources/appIcon.icns
230 cp Ardour3.icns $Resources/appIcon.icns
232 cp typeArdour.icns $Resources/
235 if test x$WITH_NLS != x ; then
236 echo "NLS support ..."
237 echo "I hope you remembered to run waf i18n"
240 for pkg in gtk2_ardour libs/ardour libs/gtkmm2ext ; do
241 files=`find ../../$pkg -name "*.mo"`
244 # the package name is appended with a number so that
245 # it can be parallel installed during a regular install
246 # with older (and newer) versions. it is just the major
247 # number of the release (i.e. leading digits)
250 vsuffix=`echo $release_version | sed 's/^\([0-9][0-9]*\).*/\1/'`
252 if [ -z "$files" ]; then
254 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$pkg"
261 lang=`basename $file | sed 's/\.mo//'`
262 mkdir -p $Locale/$lang/LC_MESSAGES
263 cp $file $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
264 echo copy $file to $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
265 if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
268 LINGUAS="$LINGUAS $lang"
275 if [ -d $GTKSTACK_ROOT/share/locale/$l ] ; then
276 echo "Copying GTK i18n files for $l..."
277 cp -r $GTKSTACK_ROOT/share/locale/$l $Locale
279 # try with just the language spec
280 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
281 if [ -d $GTKSTACK_ROOT/share/locale/$just_lang ] ; then
282 echo "Copying GTK i18n files for $l..."
283 cp -r $GTKSTACK_ROOT/share/locale/$just_lang $Locale
288 echo "Skipping NLS support"
292 # Copy stuff that may be dynamically loaded
295 cp -R $GTKSTACK_ROOT/etc/* $Etc
296 echo "Copying all Pango modules ..."
297 cp -R $GTKSTACK_ROOT/lib/pango/1.8.0/modules/*.so $Frameworks/modules
298 echo "Copying all GDK Pixbuf loaders ..."
299 cp -R $GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.so $Frameworks/modules
301 cp -R $GTKSTACK_ROOT/lib/charset.alias $Resources
303 # generate new Pango module file
306 ModulesPath=$GTKSTACK_ROOT/lib/pango/1.8.0/modules
308 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
311 # generate a new GDK pixbufs loaders file
312 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
314 # We rely on clearlooks, so include a version from our own build tree
315 # this one is special - we will set GTK_PATH to $Frameworks/gtkengines
317 GTK_ENGINE_DIR=$Frameworks/gtkengines/engines
318 mkdir -p $GTK_ENGINE_DIR
320 echo "Copying GTK engines ..."
321 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.dylib $Frameworks
322 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.dylib . && ln -s ../../libclearlooks.dylib libclearlooks.so)
324 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Frameworks
325 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so)
328 if test x$WITH_LADSPA != x ; then
329 if test x$SAE != x ; then
331 elif test x$MIXBUS != x ; then
332 plugdir=mixbus_ladspa
336 if [ -d $plugdir -a "x$(ls $plugdir)" != x ] ; then
337 echo "Copying `ls $plugdir | wc -l` plugins ..."
338 cp -r $plugdir/* $Plugins
342 # Control Surface shared libraries
343 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.dylib $Surfaces
344 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp*.dylib $Frameworks
347 cp $BUILD_ROOT/libs/panners/*/lib*.dylib $Panners
350 for backend in jack wavesaudio dummy; do
351 cp $BUILD_ROOT/libs/backends/$backend/lib*.dylib $Backends
354 # Export Formats/Presets
355 for f in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
356 cp "$f" $ExportFormats ;
359 # Session and Route templates
360 #for f in $BUILD_ROOT/../templates/* ; do
361 # if [ -d "$f" ] ; then
362 # cp -r "$f" $Templates ;
367 # got to be careful with names here
368 for x in $BUILD_ROOT/../midi_maps/*.map ; do
373 # got to be careful with names here
374 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
379 # got to be careful with names here
380 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
381 cp "$x" $MackieControl
384 # VAMP plugins that we use
385 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.dylib $Frameworks
387 # Suil modules (new dir 'build-stack')
388 if test -d $GTKSTACK_ROOT/lib/suil-0/ ; then
389 cp $GTKSTACK_ROOT/lib/suil-0/lib* $Frameworks
392 # Suil modules (old dir 'build-ardour-stack')
393 if test -d $ARDOURSTACK_ROOT/lib/suil-0/ ; then
394 cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Frameworks
397 # VST scanner app and wrapper script, if they exist
398 if test -d $BUILD_ROOT/libs/fst ; then
399 cp $BUILD_ROOT/libs/fst/ardour-vst-scanner* $Frameworks/
403 if test -f $BUILD_ROOT/libs/vfork/ardour-exec-wrapper ; then
404 mkdir -p $Frameworks/vfork
405 cp $BUILD_ROOT/libs/vfork/ardour-exec-wrapper $Frameworks/
411 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Panners/*.dylib $Backends/*.dylib $Surfaces/*.dylib $Plugins/*.so ; do
412 if ! file $file | grep -qs Mach-O ; then
416 if test x$STRIP != x ; then
417 strip -u -r -arch all $file &>/dev/null
420 deps=`otool -L $file | awk '{print $1}' | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | grep -v 'libjack\.'`
422 for dep in $deps ; do
424 if ! test -f $Frameworks/$base; then
425 if echo $dep | grep -sq '^libs' ; then
426 cp $BUILD_ROOT/$dep $Frameworks
434 if test x$missing = xfalse ; then
435 # everything has been found
441 echo "Copying other stuff to $APPDIR ..."
443 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Resources
445 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Resources
446 cp ../../gtk2_ardour/mixer.bindings $Resources
447 cp ../../gtk2_ardour/step_editing.bindings $Resources
448 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Resources
450 if test x$SAE != x ; then
451 cp $BUILD_ROOT/gtk2_ardour/SAE-de-keypad.bindings $Resources
452 cp $BUILD_ROOT/gtk2_ardour/SAE-de-nokeypad.bindings $Resources
453 cp $BUILD_ROOT/gtk2_ardour/SAE-us-keypad.bindings $Resources
454 cp $BUILD_ROOT/gtk2_ardour/SAE-us-nokeypad.bindings $Resources
455 cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
456 echo cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
458 cp ../../system_config $Resources/system_config
459 cp ../../instant.xml $Resources/instant.xml
460 echo cp ../../instant.xml $Resources/instant.xml
462 cp $BUILD_ROOT/gtk2_ardour/default_ui_config $Resources
463 cp $BUILD_ROOT/gtk2_ardour/clearlooks.rc $Resources
466 cp -r ../../gtk2_ardour/icons $Resources
467 cp -r ../../gtk2_ardour/pixmaps $Resources
470 cp -R ../../gtk2_ardour/splash.png $Shared
471 cp -R ../../gtk2_ardour/small-splash.png $Shared
472 cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared
474 # go through and recursively remove any .svn dirs in the bundle
475 for svndir in `find $APPDIR -name .svn -type dir`; do
479 # install bundled LV2s to <app>/Contents/lib/LV2/
480 cp -R $BUILD_ROOT/libs/LV2 $Frameworks/
482 # now fix up the executables
483 echo "Fixing up executable dependency names ..."
484 executables=$MAIN_EXECUTABLE
485 if test x$SAE != x ; then
486 executables="$executables"
489 for exe in $executables; do
490 EXE=$APPROOT/MacOS/$exe
492 for lib in `otool -L $EXE | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
494 changes="$changes -change $lib @executable_path/../lib/$base"
496 if test "x$changes" != "x" ; then
497 install_name_tool $changes $EXE
501 echo "Fixing up library names ..."
502 # now do the same for all the libraries we include
503 for libdir in $Frameworks $Frameworks/modules $Surfaces $Panners $Backends ; do
505 libbase=`basename $libdir`
507 for dylib in $libdir/*.dylib $libdir/*.so ; do
511 if test -L $dylib ; then
515 # change all the dependencies
518 for lib in `otool -L $dylib | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
520 if echo $lib | grep -s libbase; then
521 changes="$changes -change $lib @executable_path/../$libbase/$base"
523 changes="$changes -change $lib @executable_path/../lib/$base"
527 if test "x$changes" != x ; then
528 if install_name_tool $changes $dylib ; then
535 # now the change what the library thinks its own name is
537 base=`basename $dylib`
538 install_name_tool -id @executable_path/../$libbase/$base $dylib
543 # and now ... the DMG
546 rm -rf $PRODUCT_PKG_DIR
547 mkdir $PRODUCT_PKG_DIR
550 DMGBACKGROUND=dmgbg.png
552 if [ x$SAE != x ] ; then
556 echo "Creating SAE packaging directory"
557 mv $APPDIR $PRODUCT_PKG_DIR/Ardour3-SAE.app
558 cp HowToInstallArdourSAE.pdf "$PRODUCT_PKG_DIR/How To Install Ardour SAE.pdf"
559 cp SAE-de-keypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts (keypad).pdf"
560 cp SAE-de-nokeypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts.pdf"
562 elif [ x$MIXBUS != x ] ; then
566 echo "Creating Mixbus packaging directory"
567 mv $APPDIR $PRODUCT_PKG_DIR/
568 cp MixBus_Install_QuickStart.pdf "$PRODUCT_PKG_DIR/Mixbus Install & Quick Start Guide.pdf"
570 YPOS=$[ $DMGWINBOTTOM - 300 ]
571 MIXBUSPOS="set position of item \"MixBus_Install_QuickStart.pdf\" of container window to {90, ${YPOS}}"
574 echo "Creating $APPNAME packaging directory"
575 mv $APPDIR $PRODUCT_PKG_DIR/
579 if test x$WITH_HARVID != x ; then
580 echo "installing video tools.."
581 HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
582 XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
584 echo "copying harvid and xjadeo ..."
587 rsync://ardour.org/video-tools/harvid-osx-${HARVID_VERSION}.tgz \
588 "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz"
591 rsync://ardour.org/video-tools/jadeo-${XJADEO_VERSION:1}.dmg \
592 "$CACHEDIR/jadeo-${XJADEO_VERSION:1}.dmg"
595 -C $PRODUCT_PKG_DIR/$APPROOT \
596 -f "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz" || exit 1
598 JADEO=$(hdiutil attach "$CACHEDIR/jadeo-${XJADEO_VERSION:1}.dmg" | grep Apple_HFS | grep dev/ | cut -f 3)
599 cp -r "${JADEO}/Jadeo.app" "$PRODUCT_PKG_DIR/"
600 hdiutil detach "${JADEO}"
603 YPOS=$[ $DMGWINBOTTOM - 300 ]
604 XJADEOPOS="set position of item \"Jadeo.app\" of container window to {310, ${YPOS}}"
606 DMGBACKGROUND=dmgbgxj.png
609 echo "Building DMG ..."
611 # UC_DMG=$APPNAME-${release_version}-UC.dmg
612 # FINAL_DMG=$APPNAME-${release_version}.dmg
614 if [ x$DEBUG = xT ]; then
615 UC_DMG=$APPNAME-$release_version-dbg.dmg
617 UC_DMG=$APPNAME-$release_version.dmg
619 VOLNAME=$APPNAME-$release_version
623 MNTPATH=`mktemp -d -t ardourimg`
624 TMPDMG=`mktemp -t ardour`
625 ICNSTMP=`mktemp -t ardouricon`
627 DMGMEGABYTES=$[ `du -sk "$PRODUCT_PKG_DIR" | cut -f 1` * 1024 / 1048576 + $EXTRA_SPACE_MB ]
629 echo "DMG MB = " $DMGMEGABYTES
631 rm -f $UC_DMG "$TMPDMG" "${TMPDMG}.dmg" "$ICNSTMP"
635 TMPDMG="${TMPDMG}.dmg"
637 hdiutil create -megabytes $DMGMEGABYTES "$TMPDMG"
638 DiskDevice=$(hdid -nomount "$TMPDMG" | grep Apple_HFS | cut -f 1 -d ' ')
639 newfs_hfs -v "${VOLNAME}" "${DiskDevice}"
640 mount -t hfs "${DiskDevice}" "${MNTPATH}"
642 cp -r ${PRODUCT_PKG_DIR}/* "${MNTPATH}" || exit
643 mkdir "${MNTPATH}/.background"
644 cp -vi ${DMGBACKGROUND} "${MNTPATH}/.background/dmgbg.png"
646 echo "setting DMG background ..."
648 if test $(sw_vers -productVersion | cut -d '.' -f 2) -lt 9; then
652 # OSX 10.9.X and later
653 DISKNAME=`basename "${MNTPATH}"`
657 tell application "Finder"
659 tell disk "${DISKNAME}"
661 set current view of container window to icon view
662 set toolbar visible of container window to false
663 set statusbar visible of container window to false
664 set the bounds of container window to {400, 200, 800, ${DMGWINBOTTOM}}
665 set theViewOptions to the icon view options of container window
666 set arrangement of theViewOptions to not arranged
667 set icon size of theViewOptions to 64
668 set background picture of theViewOptions to file ".background:dmgbg.png"
669 make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
670 set position of item "${APPDIR}" of container window to {90, 100}
671 set position of item "Applications" of container window to {310, 100}
677 update without registering applications
684 chmod -Rf go-w "${MNTPATH}"
687 echo "compressing Image ..."
690 umount "${DiskDevice}"
691 hdiutil eject "${DiskDevice}"
692 # Create a read-only version, use zlib compression
693 hdiutil convert -format UDZO "${TMPDMG}" -imagekey zlib-level=9 -o "${UC_DMG}"
694 # Delete the temporary files
698 echo "setting file icon ..."
700 cp ${PRODUCT_PKG_DIR}/$Resources/appIcon.icns ${ICNSTMP}.icns
701 sips -i ${ICNSTMP}.icns
702 DeRez -only icns ${ICNSTMP}.icns > ${ICNSTMP}.rsrc
703 Rez -append ${ICNSTMP}.rsrc -o "$UC_DMG"
704 SetFile -a C "$UC_DMG"
706 rm ${ICNSTMP}.icns ${ICNSTMP}.rsrc
709 echo "packaging suceeded."