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 / $revision"
79 info_string="$version built on `hostname` by `whoami` on `date`"
80 echo "Info string is $info_string"
82 # setup directory structure
85 APPROOT=$APPDIR/Contents
86 Frameworks=$APPROOT/lib
87 Resources=$APPROOT/Resources
89 # Since this is OS X, don't try to distinguish between etc and shared
90 # (machine dependent and independent data) - just put everything
95 Locale=$Resources/locale
97 # Bundled Plugins live in a top level folder
99 Plugins=$APPROOT/Plugins
100 Surfaces=$Frameworks/surfaces
101 Panners=$Frameworks/panners
102 Backends=$Frameworks/backends
103 MidiMaps=$Shared/midi_maps
104 ExportFormats=$Shared/export
105 Templates=$Shared/templates
106 PatchFiles=$Shared/patchfiles
107 MackieControl=$Shared/mcp
109 if [ x$PRINT_SYSDEPS != x ] ; then
111 # print system dependencies
114 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Plugins/*.so ; do
115 if ! file $file | grep -qs Mach-O ; then
118 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
123 echo "Removing old $APPDIR tree ..."
127 echo "Building new app directory structure ..."
129 # only bother to make the longest paths
131 mkdir -p $APPROOT/MacOS
132 mkdir -p $APPROOT/Resources
138 mkdir -p $ExportFormats
140 mkdir -p $Frameworks/modules
142 mkdir -p $MackieControl
144 # maybe set variables
146 if test x$SAE != x ; then
147 appname="Ardour3/SAE"
148 env="$env<key>ARDOUR_SAE</key><string>true</string>"
150 # current default for SAE version is German keyboard layout without a keypad
152 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>de-nokeypad</string>"
153 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui_sae.conf</string>"
154 env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark_sae.rc</string>"
155 elif test x$MIXBUS != x ; then
156 appname="Ardour3/Mixbus"
157 env="$env<key>ARDOUR_MIXBUS</key><string>true</string>"
159 # current default for MIXBUS version is US keyboard layout without a keypad
161 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>us-nokeypad</string>"
162 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui.conf</string>"
163 env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark.rc</string>"
169 # if we're not going to bundle JACK, make sure we can find
170 # jack in the places where it might be
173 env="$env<key>PATH</key><string>/usr/local/bin:/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>"
174 env="$env<key>DYLIB_FALLBACK_LIBRARY_PATH</key><string>/usr/local/lib:/opt/lib</string>"
176 env="<key>LSEnvironment</key><dict>$env<key>ARDOUR_BUNDLED</key><string>true</string></dict>"
179 sed -e "s?@ENV@?$env?g" \
180 -e "s?@VERSION@?$release_version/$revision?g" \
181 -e "s?@INFOSTRING@?$info_string?g" < Info.plist.in > Info.plist
183 sed -e "s?@APPNAME@?$appname?" \
184 -e "s?@ENV@?$env?g" \
185 -e "s?@VERSION@?$release_version/$revision?g" \
186 -e "s?@INFOSTRING@?$info_string?g" < InfoPlist.strings.in > Resources/InfoPlist.strings || exit 1
190 cp Info.plist $APPROOT
191 cp -R Resources $APPROOT
194 # if we build a bundle without jack, then
195 # make the Ardour3 executable a helper
196 # script that checks to see if JACK is
200 cp startup_script $APPROOT/MacOS/Ardour3
201 chmod 775 $APPROOT/MacOS/Ardour3
202 MAIN_EXECUTABLE=Ardour3.bin
204 echo "Copying ardour executable ...."
205 cp $BUILD_ROOT/gtk2_ardour/ardour-$release_version $APPROOT/MacOS/$MAIN_EXECUTABLE
206 if test x$SAE != x ; then
207 # cp $BUILD_ROOT/gtk2_ardour/evtest $APPROOT/MacOS/gtkevents
208 cp Ardour3-SAE.icns $Resources/appIcon.icns
209 elif test x$MIXBUS != x ; then
210 cp Mixbus.icns $Resources/appIcon.icns
212 cp Ardour3.icns $Resources/appIcon.icns
214 cp typeArdour.icns $Resources/
215 if test x$STRIP != x ; then
216 strip $APPROOT/MacOS/Ardour3
220 if test x$WITH_NLS != x ; then
221 echo "NLS support ..."
222 echo "I hope you remembered to run scons msgupdate!"
224 for file in $BUILD_ROOT/gtk2_ardour/*.mo
226 lang=`basename $file | sed 's/\.mo//'`
227 mkdir -p $Locale/$lang/LC_MESSAGES
228 cp $file $Locale/$lang/LC_MESSAGES/gtk2_ardour.mo
229 LINGUAS="$LINGUAS $lang"
231 for file in $BUILD_ROOT/libs/ardour/*.mo
233 lang=`basename $file | sed 's/\.mo//'`
234 mkdir -p $Locale/$lang/LC_MESSAGES
235 cp $file $Locale/$lang/LC_MESSAGES/libardour.mo
239 if [ -d $GTKSTACK_ROOT/share/locale/$l ] ; then
240 echo "Copying GTK i18n files for $l..."
241 cp -r $GTKSTACK_ROOT/share/locale/$l $Locale
243 # try with just the language spec
244 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
245 if [ -d $GTKSTACK_ROOT/share/locale/$just_lang ] ; then
246 echo "Copying GTK i18n files for $l..."
247 cp -r $GTKSTACK_ROOT/share/locale/$just_lang $Locale
252 echo "Skipping NLS support"
256 # Copy stuff that may be dynamically loaded
259 cp -R $GTKSTACK_ROOT/etc/* $Etc
260 echo "Copying all Pango modules ..."
261 cp -R $GTKSTACK_ROOT/lib/pango/1.8.0/modules/*.so $Frameworks/modules
262 echo "Copying all GDK Pixbuf loaders ..."
263 cp -R $GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.so $Frameworks/modules
265 cp -R $GTKSTACK_ROOT/lib/charset.alias $Resources
267 # generate new Pango module file
270 ModulesPath=$GTKSTACK_ROOT/lib/pango/1.8.0/modules
272 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
275 # generate a new GDK pixbufs loaders file
276 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
278 # We rely on clearlooks, so include a version from our own build tree
279 # this one is special - we will set GTK_PATH to $Frameworks/gtkengines
281 GTK_ENGINE_DIR=$Frameworks/gtkengines/engines
282 mkdir -p $GTK_ENGINE_DIR
284 echo "Copying GTK engines ..."
285 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.dylib $Frameworks
286 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.dylib . && ln -s ../../libclearlooks.dylib libclearlooks.so)
288 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Frameworks
289 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so)
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 if [ -d $plugdir -a "x$(ls $plugdir)" != x ] ; then
301 echo "Copying `ls $plugdir | wc -l` plugins ..."
302 cp -r $plugdir/* $Plugins
306 # Control Surface shared libraries
307 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.dylib $Surfaces
308 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp*.dylib $Frameworks
311 cp $BUILD_ROOT/libs/panners/*/lib*.dylib $Panners
314 cp $BUILD_ROOT/libs/backends/*/lib*.dylib $Backends
316 # Export Formats/Presets
317 for f in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
318 cp "$f" $ExportFormats ;
321 # Session and Route templates
322 #for f in $BUILD_ROOT/../templates/* ; do
323 # if [ -d "$f" ] ; then
324 # cp -r "$f" $Templates ;
329 # got to be careful with names here
330 for x in $BUILD_ROOT/../midi_maps/*.map ; do
335 # got to be careful with names here
336 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
341 # got to be careful with names here
342 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
343 cp "$x" $MackieControl
346 # VAMP plugins that we use
347 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.dylib $Frameworks
350 cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Frameworks
354 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Panners/*.dylib $Surfaces/*.dylib $Plugins/*.so ; do
355 if ! file $file | grep -qs Mach-O ; then
358 deps=`otool -L $file | awk '{print $1}' | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | grep -v 'libjack\.'`
360 for dep in $deps ; do
362 if ! test -f $Frameworks/$base; then
363 if echo $dep | grep -sq '^libs' ; then
364 cp $BUILD_ROOT/$dep $Frameworks
372 if test x$missing = xfalse ; then
373 # everything has been found
379 echo "Copying other stuff to $APPDIR ..."
381 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Resources
383 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Resources
384 cp ../../gtk2_ardour/mixer.bindings $Resources
385 cp ../../gtk2_ardour/step_editing.bindings $Resources
386 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Resources
388 if test x$SAE != x ; then
389 cp $BUILD_ROOT/gtk2_ardour/SAE-de-keypad.bindings $Resources
390 cp $BUILD_ROOT/gtk2_ardour/SAE-de-nokeypad.bindings $Resources
391 cp $BUILD_ROOT/gtk2_ardour/SAE-us-keypad.bindings $Resources
392 cp $BUILD_ROOT/gtk2_ardour/SAE-us-nokeypad.bindings $Resources
393 cp $BUILD_ROOT/ardour_system_sae.rc $Resources/ardour_system.rc
394 echo cp $BUILD_ROOT/ardour_system_sae.rc $Resources/ardour_system.rc
395 cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
396 echo cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
398 cp ../../ardour_system.rc $Resources/ardour_system.rc
399 cp ../../instant.xml $Resources/instant.xml
400 echo cp ../../instant.xml $Resources/instant.xml
402 cp ../../gtk2_ardour/ardour3_ui_default.conf $Resources
403 cp ../../gtk2_ardour/ardour3_ui_default.conf $Resources/ardour3_ui.conf
404 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_light.rc $Resources
405 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_dark.rc $Resources
407 cp -r ../../gtk2_ardour/icons $Resources
408 cp -r ../../gtk2_ardour/pixmaps $Resources
411 cp -R ../../gtk2_ardour/splash.png $Shared
412 cp -R ../../gtk2_ardour/small-splash.png $Shared
413 cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared
415 # go through and recursively remove any .svn dirs in the bundle
416 for svndir in `find $APPDIR -name .svn -type dir`; do
420 # now fix up the executables
421 echo "Fixing up executable dependency names ..."
422 executables=$MAIN_EXECUTABLE
423 if test x$SAE != x ; then
424 executables="$executables"
427 for exe in $executables; do
428 EXE=$APPROOT/MacOS/$exe
430 for lib in `otool -L $EXE | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
432 changes="$changes -change $lib @executable_path/../lib/$base"
434 if test "x$changes" != "x" ; then
435 install_name_tool $changes $EXE
439 echo "Fixing up library names ..."
440 # now do the same for all the libraries we include
441 for libdir in $Frameworks $Frameworks/modules $Surfaces $Panners ; do
443 libbase=`basename $libdir`
445 for dylib in $libdir/*.dylib $libdir/*.so ; do
449 if test -L $dylib ; then
453 # change all the dependencies
456 for lib in `otool -L $dylib | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
458 if echo $lib | grep -s libbase; then
459 changes="$changes -change $lib @executable_path/../$libbase/$base"
461 changes="$changes -change $lib @executable_path/../lib/$base"
465 if test "x$changes" != x ; then
466 if install_name_tool $changes $dylib ; then
473 # now the change what the library thinks its own name is
475 base=`basename $dylib`
476 install_name_tool -id @executable_path/../$libbase/$base $dylib
481 # and now ... the DMG
484 rm -rf $PRODUCT_PKG_DIR
485 mkdir $PRODUCT_PKG_DIR
488 DMGBACKGROUND=dmgbg.png
490 if [ x$SAE != x ] ; then
494 echo "Creating SAE packaging directory"
495 mv $APPDIR $PRODUCT_PKG_DIR/Ardour3-SAE.app
496 cp HowToInstallArdourSAE.pdf "$PRODUCT_PKG_DIR/How To Install Ardour SAE.pdf"
497 cp SAE-de-keypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts (keypad).pdf"
498 cp SAE-de-nokeypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts.pdf"
500 elif [ x$MIXBUS != x ] ; then
504 echo "Creating Mixbus packaging directory"
505 mv $APPDIR $PRODUCT_PKG_DIR/
506 cp MixBus_Install_QuickStart.pdf "$PRODUCT_PKG_DIR/Mixbus Install & Quick Start Guide.pdf"
508 YPOS=$[ $DMGWINBOTTOM - 300 ]
509 MIXBUSPOS="set position of item \"MixBus_Install_QuickStart.pdf\" of container window to {90, ${YPOS}}"
512 echo "Creating $APPNAME packaging directory"
513 mv $APPDIR $PRODUCT_PKG_DIR/
517 if test x$WITH_HARVID != x ; then
518 echo "installing video tools.."
519 HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
520 XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
521 echo "copying harvid and xjadeo ..."
524 rsync://ardour.org/video-tools/harvid-osx-${HARVID_VERSION}.tgz \
525 "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz"
528 rsync://ardour.org/video-tools/jadeo-${XJADEO_VERSION:1}.dmg \
529 "$CACHEDIR/jadeo-${XJADEO_VERSION:1}.dmg"
532 -C $PRODUCT_PKG_DIR/$APPROOT \
533 -f "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz" || exit 1
535 JADEO=$(hdiutil attach "$CACHEDIR/jadeo-${XJADEO_VERSION:1}.dmg" | grep Apple_HFS | grep dev/ | cut -f 3)
536 cp -r "${JADEO}/Jadeo.app" "$PRODUCT_PKG_DIR/"
537 hdiutil detach "${JADEO}"
540 YPOS=$[ $DMGWINBOTTOM - 300 ]
541 XJADEOPOS="set position of item \"Jadeo.app\" of container window to {310, ${YPOS}}"
543 DMGBACKGROUND=dmgbgxj.png
546 echo "Building DMG ..."
548 # UC_DMG=$APPNAME-${release_version}-${revision}-UC.dmg
549 # FINAL_DMG=$APPNAME-${release_version}-${revision}.dmg
550 UC_DMG=$APPNAME-$version.dmg
551 VOLNAME=$APPNAME-$version
555 MNTPATH=`mktemp -d -t /ardourimg`
556 TMPDMG=`mktemp -t ardour`
557 ICNSTMP=`mktemp -t ardouricon`
559 DMGMEGABYTES=$[ `du -sk "$PRODUCT_PKG_DIR" | cut -f 1` * 1024 / 1048576 + $EXTRA_SPACE_MB ]
561 echo "DMG MB = " $DMGMEGABYTES
563 rm -f $UC_DMG "$TMPDMG" "${TMPDMG}.dmg" "$ICNSTMP"
567 TMPDMG="${TMPDMG}.dmg"
569 hdiutil create -megabytes $DMGMEGABYTES "$TMPDMG"
570 DiskDevice=$(hdid -nomount "$TMPDMG" | grep Apple_HFS | cut -f 1 -d ' ')
571 newfs_hfs -v "${VOLNAME}" "${DiskDevice}"
572 mount -t hfs "${DiskDevice}" "${MNTPATH}"
574 cp -r ${PRODUCT_PKG_DIR}/* "${MNTPATH}" || exit
575 mkdir "${MNTPATH}/.background"
576 cp -vi ${DMGBACKGROUND} "${MNTPATH}/.background/dmgbg.png"
578 echo "setting DMG background ..."
581 tell application "Finder"
582 tell disk "'${VOLNAME}'"
584 set current view of container window to icon view
585 set toolbar visible of container window to false
586 set statusbar visible of container window to false
587 set the bounds of container window to {400, 200, 800, '${DMGWINBOTTOM}'}
588 set theViewOptions to the icon view options of container window
589 set arrangement of theViewOptions to not arranged
590 set icon size of theViewOptions to 64
591 set background picture of theViewOptions to file ".background:dmgbg.png"
592 make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
593 set position of item "'${APPDIR}'" of container window to {90, 100}
594 set position of item "Applications" of container window to {310, 100}
600 update without registering applications
607 chmod -Rf go-w "${MNTPATH}"
610 echo "compressing Image ..."
613 umount "${DiskDevice}"
614 hdiutil eject "${DiskDevice}"
615 # Create a read-only version, use zlib compression
616 hdiutil convert -format UDZO "${TMPDMG}" -imagekey zlib-level=9 -o "${UC_DMG}"
617 # Delete the temporary files
621 echo "setting file icon ..."
623 cp ${PRODUCT_PKG_DIR}/$Resources/appIcon.icns ${ICNSTMP}.icns
624 /usr/bin/sips -i ${ICNSTMP}.icns
625 /Developer/Tools/DeRez -only icns ${ICNSTMP}.icns > ${ICNSTMP}.rsrc
626 /Developer/Tools/Rez -append ${ICNSTMP}.rsrc -o "$UC_DMG"
627 /Developer/Tools/SetFile -a C "$UC_DMG"
629 rm ${ICNSTMP}.icns ${ICNSTMP}.rsrc
632 echo "packaging suceeded."