3 # script for pulling together a MacOSX app bundle.
5 GTKSTACK_ROOT=$HOME/gtk/inst
6 ARDOURSTACK_ROOT=$HOME/a3/inst
17 while [ $# -gt 0 ] ; do
22 # top level build targets
29 PRODUCT_PKG_DIR=ArdourSAE ;
37 PRODUCT_PKG_DIR=MixBus;
44 PRODUCT_PKG_DIR=Ardour;
51 PRODUCT_PKG_DIR=Ardour ;
53 --test) SAE= ; WITH_LADSPA=; STRIP= ; shift ;;
56 # specific build flags
59 --harvid) WITH_HARVID=1 ; shift ;;
60 --noladspa) WITH_LADSPA= ; shift ;;
61 --nostrip) STRIP= ; shift ;;
62 --sysdeps) PRINT_SYSDEPS=1; shift ;;
63 --nls) WITH_NLS=1 ; shift ;;
67 if test -z "$PRODUCT_PKG_DIR" -o -z "$APPNAME"; then
68 echo "application or product-name was not specified"
72 . ../define_versions.sh
73 echo "Version is $release_version / $revision"
74 info_string="$version built on `hostname` by `whoami` on `date`"
75 echo "Info string is $info_string"
77 # setup directory structure
80 APPROOT=$APPDIR/Contents
81 Frameworks=$APPROOT/lib
82 Resources=$APPROOT/Resources
84 # Since this is OS X, don't try to distinguish between etc and shared
85 # (machine dependent and independent data) - just put everything
90 Locale=$Resources/locale
92 # Bundled Plugins live in a top level folder
94 Plugins=$APPROOT/Plugins
95 Surfaces=$Frameworks/surfaces
96 Panners=$Frameworks/panners
97 MidiMaps=$Shared/midi_maps
98 ExportFormats=$Shared/export
99 Templates=$Shared/templates
100 PatchFiles=$Shared/patchfiles
101 MackieControl=$Shared/mcp
103 if [ x$PRINT_SYSDEPS != x ] ; then
105 # print system dependencies
108 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Plugins/*.so ; do
109 if ! file $file | grep -qs Mach-O ; then
112 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
117 echo "Removing old $APPDIR tree ..."
121 echo "Building new app directory structure ..."
123 # only bother to make the longest paths
125 mkdir -p $APPROOT/MacOS
126 mkdir -p $APPROOT/Resources
131 mkdir -p $ExportFormats
133 mkdir -p $Frameworks/modules
135 mkdir -p $MackieControl
137 # maybe set variables
139 if test x$SAE != x ; then
140 appname="Ardour3/SAE"
141 env="$env<key>ARDOUR_SAE</key><string>true</string>"
143 # current default for SAE version is German keyboard layout without a keypad
145 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>de-nokeypad</string>"
146 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui_sae.conf</string>"
147 env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark_sae.rc</string>"
148 elif test x$MIXBUS != x ; then
149 appname="Ardour3/Mixbus"
150 env="$env<key>ARDOUR_MIXBUS</key><string>true</string>"
152 # current default for MIXBUS version is US keyboard layout without a keypad
154 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>us-nokeypad</string>"
155 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui.conf</string>"
156 env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark.rc</string>"
162 # if we're not going to bundle JACK, make sure we can find
163 # jack in the places where it might be
166 env="$env<key>PATH</key><string>/usr/local/bin:/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>"
167 env="$env<key>DYLIB_FALLBACK_LIBRARY_PATH</key><string>/usr/local/lib:/opt/lib</string>"
169 env="<key>LSEnvironment</key><dict>$env<key>ARDOUR_BUNDLED</key><string>true</string></dict>"
172 sed -e "s?@ENV@?$env?g" \
173 -e "s?@VERSION@?$release_version/$revision?g" \
174 -e "s?@INFOSTRING@?$info_string?g" < Info.plist.in > Info.plist
176 sed -e "s?@APPNAME@?$appname?" \
177 -e "s?@ENV@?$env?g" \
178 -e "s?@VERSION@?$release_version/$revision?g" \
179 -e "s?@INFOSTRING@?$info_string?g" < InfoPlist.strings.in > Resources/InfoPlist.strings || exit 1
183 cp Info.plist $APPROOT
184 cp -R Resources $APPROOT
187 # if we build a bundle without jack, then
188 # make the Ardour3 executable a helper
189 # script that checks to see if JACK is
193 cp startup_script $APPROOT/MacOS/Ardour3
194 chmod 775 $APPROOT/MacOS/Ardour3
195 MAIN_EXECUTABLE=Ardour3.bin
197 echo "Copying ardour executable ...."
198 cp $BUILD_ROOT/gtk2_ardour/ardour-$release_version $APPROOT/MacOS/$MAIN_EXECUTABLE
199 if test x$SAE != x ; then
200 # cp $BUILD_ROOT/gtk2_ardour/evtest $APPROOT/MacOS/gtkevents
201 cp Ardour3-SAE.icns $Resources/appIcon.icns
202 elif test x$MIXBUS != x ; then
203 cp Mixbus.icns $Resources/appIcon.icns
205 cp Ardour3.icns $Resources/appIcon.icns
207 cp typeArdour.icns $Resources/
208 if test x$STRIP != x ; then
209 strip $APPROOT/MacOS/Ardour3
213 if test x$WITH_NLS != x ; then
214 echo "NLS support ..."
215 echo "I hope you remembered to run scons msgupdate!"
217 for file in $BUILD_ROOT/gtk2_ardour/*.mo
219 lang=`basename $file | sed 's/\.mo//'`
220 mkdir -p $Locale/$lang/LC_MESSAGES
221 cp $file $Locale/$lang/LC_MESSAGES/gtk2_ardour.mo
222 LINGUAS="$LINGUAS $lang"
224 for file in $BUILD_ROOT/libs/ardour/*.mo
226 lang=`basename $file | sed 's/\.mo//'`
227 mkdir -p $Locale/$lang/LC_MESSAGES
228 cp $file $Locale/$lang/LC_MESSAGES/libardour.mo
232 if [ -d $GTKSTACK_ROOT/share/locale/$l ] ; then
233 echo "Copying GTK i18n files for $l..."
234 cp -r $GTKSTACK_ROOT/share/locale/$l $Locale
236 # try with just the language spec
237 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
238 if [ -d $GTKSTACK_ROOT/share/locale/$just_lang ] ; then
239 echo "Copying GTK i18n files for $l..."
240 cp -r $GTKSTACK_ROOT/share/locale/$just_lang $Locale
245 echo "Skipping NLS support"
249 # Copy stuff that may be dynamically loaded
252 cp -R $GTKSTACK_ROOT/etc/* $Etc
253 echo "Copying all Pango modules ..."
254 cp -R $GTKSTACK_ROOT/lib/pango/1.6.0/modules/*.so $Frameworks/modules
255 echo "Copying all GDK Pixbuf loaders ..."
256 cp -R $GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.so $Frameworks/modules
258 cp -R $GTKSTACK_ROOT/lib/charset.alias $Resources
260 # generate new Pango module file
263 ModulesPath=$GTKSTACK_ROOT/lib/pango/1.6.0/modules
265 env PANGO_RC_FILE=pangorc $GTKSTACK_ROOT/bin/pango-querymodules | sed "s?$GTKSTACK_ROOT/lib/pango/1.6.0/modules/?@executable_path/../lib/modules/?" > $Resources/pango.modules
268 # generate a new GDK pixbufs loaders file
269 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
271 # We rely on clearlooks, so include a version from our own build tree
272 # this one is special - we will set GTK_PATH to $Frameworks/gtkengines
274 GTK_ENGINE_DIR=$Frameworks/gtkengines/engines
275 mkdir -p $GTK_ENGINE_DIR
277 echo "Copying GTK engines ..."
278 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.dylib $Frameworks
279 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.dylib . && ln -s ../../libclearlooks.dylib libclearlooks.so)
281 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Frameworks
282 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so)
285 if test x$WITH_LADSPA != x ; then
286 if test x$SAE != x ; then
288 elif test x$MIXBUS != x ; then
289 plugdir=mixbus_ladspa
293 if [ -d $plugdir -a "x$(ls $plugdir)" != x ] ; then
294 echo "Copying `ls $plugdir | wc -l` plugins ..."
295 cp -r $plugdir/* $Plugins
299 # Control Surface shared libraries
300 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.dylib $Surfaces
301 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp*.dylib $Frameworks
304 cp $BUILD_ROOT/libs/panners/*/lib*.dylib $Panners
307 # Export Formats/Presets
308 for f in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
309 cp "$f" $ExportFormats ;
312 # Session and Route templates
313 #for f in $BUILD_ROOT/../templates/* ; do
314 # if [ -d "$f" ] ; then
315 # cp -r "$f" $Templates ;
320 # got to be careful with names here
321 for x in $BUILD_ROOT/../midi_maps/*.map ; do
326 # got to be careful with names here
327 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
332 # got to be careful with names here
333 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
334 cp "$x" $MackieControl
337 # VAMP plugins that we use
338 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.dylib $Frameworks
341 cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Frameworks
345 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Panners/*.dylib $Surfaces/*.dylib $Plugins/*.so ; do
346 if ! file $file | grep -qs Mach-O ; then
349 deps=`otool -L $file | awk '{print $1}' | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | grep -v 'libjack\.'`
351 for dep in $deps ; do
353 if ! test -f $Frameworks/$base; then
354 if echo $dep | grep -sq '^libs' ; then
355 cp $BUILD_ROOT/$dep $Frameworks
363 if test x$missing = xfalse ; then
364 # everything has been found
370 echo "Copying other stuff to $APPDIR ..."
372 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Resources
374 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Resources
375 cp ../../gtk2_ardour/mixer.bindings $Resources
376 cp ../../gtk2_ardour/step_editing.bindings $Resources
377 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Resources
379 if test x$SAE != x ; then
380 cp $BUILD_ROOT/gtk2_ardour/SAE-de-keypad.bindings $Resources
381 cp $BUILD_ROOT/gtk2_ardour/SAE-de-nokeypad.bindings $Resources
382 cp $BUILD_ROOT/gtk2_ardour/SAE-us-keypad.bindings $Resources
383 cp $BUILD_ROOT/gtk2_ardour/SAE-us-nokeypad.bindings $Resources
384 cp $BUILD_ROOT/ardour_system_sae.rc $Resources/ardour_system.rc
385 echo cp $BUILD_ROOT/ardour_system_sae.rc $Resources/ardour_system.rc
386 cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
387 echo cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
389 cp ../../ardour_system.rc $Resources/ardour_system.rc
390 cp ../../instant.xml $Resources/instant.xml
391 echo cp ../../instant.xml $Resources/instant.xml
393 cp ../../gtk2_ardour/ardour3_ui_default.conf $Resources
394 cp ../../gtk2_ardour/ardour3_ui_default.conf $Resources/ardour3_ui.conf
395 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_light.rc $Resources
396 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_dark.rc $Resources
398 cp -r ../../gtk2_ardour/icons $Resources
399 cp -r ../../gtk2_ardour/pixmaps $Resources
402 cp -R ../../gtk2_ardour/splash.png $Shared
403 cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared
405 # go through and recursively remove any .svn dirs in the bundle
406 for svndir in `find $APPDIR -name .svn -type dir`; do
410 # now fix up the executables
411 echo "Fixing up executable dependency names ..."
412 executables=$MAIN_EXECUTABLE
413 if test x$SAE != x ; then
414 executables="$executables"
417 for exe in $executables; do
418 EXE=$APPROOT/MacOS/$exe
420 for lib in `otool -L $EXE | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
422 changes="$changes -change $lib @executable_path/../lib/$base"
424 if test "x$changes" != "x" ; then
425 install_name_tool $changes $EXE
429 echo "Fixing up library names ..."
430 # now do the same for all the libraries we include
431 for libdir in $Frameworks $Frameworks/modules $Surfaces $Panners ; do
433 libbase=`basename $libdir`
435 for dylib in $libdir/*.dylib $libdir/*.so ; do
439 if test -L $dylib ; then
443 # change all the dependencies
446 for lib in `otool -L $dylib | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
448 if echo $lib | grep -s libbase; then
449 changes="$changes -change $lib @executable_path/../$libbase/$base"
451 changes="$changes -change $lib @executable_path/../lib/$base"
455 if test "x$changes" != x ; then
456 if install_name_tool $changes $dylib ; then
463 # now the change what the library thinks its own name is
465 base=`basename $dylib`
466 install_name_tool -id @executable_path/../$libbase/$base $dylib
471 # and now ... the DMG
474 rm -rf $PRODUCT_PKG_DIR
475 mkdir $PRODUCT_PKG_DIR
478 DMGBACKGROUND=dmgbg.png
480 if [ x$SAE != x ] ; then
484 echo "Creating SAE packaging directory"
485 mv $APPDIR $PRODUCT_PKG_DIR/Ardour3-SAE.app
486 cp HowToInstallArdourSAE.pdf "$PRODUCT_PKG_DIR/How To Install Ardour SAE.pdf"
487 cp SAE-de-keypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts (keypad).pdf"
488 cp SAE-de-nokeypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts.pdf"
490 elif [ x$MIXBUS != x ] ; then
494 echo "Creating Mixbus packaging directory"
495 mv $APPDIR $PRODUCT_PKG_DIR/
496 cp MixBus_Install_QuickStart.pdf "$PRODUCT_PKG_DIR/Mixbus Install & Quick Start Guide.pdf"
498 YPOS=$[ $DMGWINBOTTOM - 300 ]
499 MIXBUSPOS="set position of item \"MixBus_Install_QuickStart.pdf\" of container window to {90, ${YPOS}}"
502 echo "Creating $APPNAME packaging directory"
503 mv $APPDIR $PRODUCT_PKG_DIR/
507 if test x$WITH_HARVID != x ; then
508 echo "installing video tools.."
509 # TODO move files to http://ardour.org/files/ - symlink 'latest'
510 HARVID_VERSION=$(curl http://ardour.org/files/video-tools/harvid_version.txt)
511 XJADEO_VERSION=$(curl http://ardour.org/files/video-tools/xjadeo_version.txt)
512 echo "copying harvid and xjadeo ..."
513 curl -L -o "$PRODUCT_PKG_DIR/xjadeo-${XJADEO_VERSION:1}.dmg" "http://sourceforge.net/projects/xjadeo/files/xjadeo/${XJADEO_VERSION}/jadeo-${XJADEO_VERSION:1}.dmg/download"
514 curl -L "http://ardour.org/files/video-tools/harvid-osx-${HARVID_VERSION}.tgz"\
515 | tar -x -z -C $PRODUCT_PKG_DIR/$APPROOT
517 ls -l "$PRODUCT_PKG_DIR/xjadeo-${XJADEO_VERSION:1}.dmg"
518 JADEO=$(hdiutil attach "$PRODUCT_PKG_DIR/xjadeo-${XJADEO_VERSION:1}.dmg" | grep Apple_HFS | grep dev/ | cut -f 3)
519 cp -r "${JADEO}/Jadeo.app" "$PRODUCT_PKG_DIR/"
520 hdiutil detach "${JADEO}"
521 rm "$PRODUCT_PKG_DIR/xjadeo-${XJADEO_VERSION:1}.dmg"
524 YPOS=$[ $DMGWINBOTTOM - 300 ]
525 XJADEOPOS="set position of item \"Jadeo.app\" of container window to {310, ${YPOS}}"
527 DMGBACKGROUND=dmgbgxj.png
530 echo "Building DMG ..."
532 # UC_DMG=$APPNAME-${release_version}-${revision}-UC.dmg
533 # FINAL_DMG=$APPNAME-${release_version}-${revision}.dmg
534 UC_DMG=$APPNAME-$version.dmg
535 VOLNAME=$APPNAME-$version
539 MNTPATH=`mktemp -d -t /ardourimg`
540 TMPDMG=`mktemp -t ardour`
541 ICNSTMP=`mktemp -t ardouricon`
543 DMGMEGABYTES=$[ `du -sk "$PRODUCT_PKG_DIR" | cut -f 1` * 1024 / 1048576 + $EXTRA_SPACE_MB ]
545 echo "DMG MB = " $DMGMEGABYTES
547 rm -f $UC_DMG "$TMPDMG" "${TMPDMG}.dmg" "$ICNSTMP"
551 TMPDMG="${TMPDMG}.dmg"
553 hdiutil create -megabytes $DMGMEGABYTES "$TMPDMG"
554 DiskDevice=$(hdid -nomount "$TMPDMG" | grep Apple_HFS | cut -f 1 -d ' ')
555 newfs_hfs -v "${VOLNAME}" "${DiskDevice}"
556 mount -t hfs "${DiskDevice}" "${MNTPATH}"
558 cp -r ${PRODUCT_PKG_DIR}/* "${MNTPATH}" || exit
559 mkdir "${MNTPATH}/.background"
560 cp -vi ${DMGBACKGROUND} "${MNTPATH}/.background/dmgbg.png"
562 echo "setting DMG background ..."
565 tell application "Finder"
566 tell disk "'${VOLNAME}'"
568 set current view of container window to icon view
569 set toolbar visible of container window to false
570 set statusbar visible of container window to false
571 set the bounds of container window to {400, 200, 800, '${DMGWINBOTTOM}'}
572 set theViewOptions to the icon view options of container window
573 set arrangement of theViewOptions to not arranged
574 set icon size of theViewOptions to 64
575 set background picture of theViewOptions to file ".background:dmgbg.png"
576 make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
577 set position of item "'${APPDIR}'" of container window to {90, 100}
578 set position of item "Applications" of container window to {310, 100}
584 update without registering applications
591 chmod -Rf go-w "${MNTPATH}"
594 echo "compressing Image ..."
597 umount "${DiskDevice}"
598 hdiutil eject "${DiskDevice}"
599 # Create a read-only version, use zlib compression
600 hdiutil convert -format UDZO "${TMPDMG}" -imagekey zlib-level=9 -o "${UC_DMG}"
601 # Delete the temporary files
605 echo "setting file icon ..."
607 cp ${PRODUCT_PKG_DIR}/$Resources/appIcon.icns ${ICNSTMP}.icns
608 /usr/bin/sips -i ${ICNSTMP}.icns
609 /Developer/Tools/DeRez -only icns ${ICNSTMP}.icns > ${ICNSTMP}.rsrc
610 /Developer/Tools/Rez -append ${ICNSTMP}.rsrc -o "$UC_DMG"
611 /Developer/Tools/SetFile -a C "$UC_DMG"
613 rm ${ICNSTMP}.icns ${ICNSTMP}.rsrc
616 echo "packaging suceeded."