3 # script for pulling together a MacOSX app bundle.
5 GTKSTACK_ROOT=$HOME/gtk/inst
6 ARDOURSTACK_ROOT=$HOME/a3/inst
16 while [ $# -gt 0 ] ; do
21 # top level build targets
28 PRODUCT_PKG_DIR=ArdourSAE ;
36 PRODUCT_PKG_DIR=MixBus;
43 PRODUCT_PKG_DIR=Ardour;
50 PRODUCT_PKG_DIR=Ardour ;
52 --test) SAE= ; WITH_LADSPA=; STRIP= ; shift ;;
55 # specific build flags
58 --noladspa) WITH_LADSPA= ; shift ;;
59 --nostrip) STRIP= ; shift ;;
60 --sysdeps) PRINT_SYSDEPS=1; shift ;;
61 --nls) WITH_NLS=1 ; shift ;;
65 #release_version=`grep -m 1 '[^A-Za-z_]OSX_VERSION = ' ../../wscript | cut -d' ' -f 3 | sed "s/'//g"`
67 svn_version=`grep -m 1 'svn_revision =' ../../libs/ardour/svn_revision.cc | cut -d' ' -f 8 | sed 's/[^0-9]//g'`
68 echo "Version is $release_version / $svn_version"
69 info_string="$release_version/$svn_version built on `hostname` by `whoami` on `date`"
70 echo "Info string is $info_string"
72 # setup directory structure
75 APPROOT=$APPDIR/Contents
76 Frameworks=$APPROOT/lib
77 Resources=$APPROOT/Resources
79 # Since this is OS X, don't try to distinguish between etc and shared
80 # (machine dependent and independent data) - just put everything
85 Locale=$Resources/locale
87 # Bundled Plugins live in a top level folder
89 Plugins=$APPROOT/Plugins
90 Surfaces=$Frameworks/surfaces
91 Panners=$Frameworks/panners
92 MidiMaps=$Shared/midi_maps
93 ExportFormats=$Shared/export
94 Templates=$Shared/templates
95 PatchFiles=$Shared/patchfiles
96 MackieControl=$Shared/mcp
98 if [ x$PRINT_SYSDEPS != x ] ; then
100 # print system dependencies
103 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Plugins/*.so ; do
104 if ! file $file | grep -qs Mach-O ; then
107 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
112 echo "Removing old $APPDIR tree ..."
116 echo "Building new app directory structure ..."
118 # only bother to make the longest paths
120 mkdir -p $APPROOT/MacOS
121 mkdir -p $APPROOT/Resources
126 mkdir -p $ExportFormats
128 mkdir -p $Frameworks/modules
129 mkdir -p $Shared/templates
131 mkdir -p $MackieControl
133 # maybe set variables
135 if test x$SAE != x ; then
136 appname="Ardour3/SAE"
137 env="$env<key>ARDOUR_SAE</key><string>true</string>"
139 # current default for SAE version is German keyboard layout without a keypad
141 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>de-nokeypad</string>"
142 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui_sae.conf</string>"
143 env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark_sae.rc</string>"
144 elif test x$MIXBUS != x ; then
145 appname="Ardour3/Mixbus"
146 env="$env<key>ARDOUR_MIXBUS</key><string>true</string>"
148 # current default for MIXBUS version is US keyboard layout without a keypad
150 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>us-nokeypad</string>"
151 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui.conf</string>"
152 env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark.rc</string>"
158 # if we're not going to bundle JACK, make sure we can find
159 # jack in the places where it might be
162 env="$env<key>PATH</key><string>/usr/local/bin:/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>"
163 env="$env<key>DYLIB_FALLBACK_LIBRARY_PATH</key><string>/usr/local/lib:/opt/lib</string>"
165 env="<key>LSEnvironment</key><dict>$env<key>ARDOUR_BUNDLED</key><string>true</string></dict>"
168 sed -e "s?@ENV@?$env?g" \
169 -e "s?@VERSION@?$release_version/$svn_version?g" \
170 -e "s?@INFOSTRING@?$info_string?g" < Info.plist.in > Info.plist
172 sed -e "s?@APPNAME@?$appname?" \
173 -e "s?@ENV@?$env?g" \
174 -e "s?@VERSION@?$release_version/$svn_version?g" \
175 -e "s?@INFOSTRING@?$info_string?g" < InfoPlist.strings.in > Resources/InfoPlist.strings || exit 1
179 cp Info.plist $APPROOT
180 cp -R Resources $APPROOT
183 # if we build a bundle without jack, then
184 # make the Ardour3 executable a helper
185 # script that checks to see if JACK is
189 cp startup_script $APPROOT/MacOS/Ardour3
190 chmod 775 $APPROOT/MacOS/Ardour3
191 MAIN_EXECUTABLE=Ardour3.bin
193 echo "Copying ardour executable ...."
194 cp $BUILD_ROOT/gtk2_ardour/ardour-$release_version $APPROOT/MacOS/$MAIN_EXECUTABLE
195 if test x$SAE != x ; then
196 # cp $BUILD_ROOT/gtk2_ardour/evtest $APPROOT/MacOS/gtkevents
197 cp Ardour3-SAE.icns $Resources/appIcon.icns
198 elif test x$MIXBUS != x ; then
199 cp Mixbus.icns $Resources/appIcon.icns
201 cp Ardour3.icns $Resources/appIcon.icns
203 cp typeArdour.icns $Resources/
204 if test x$STRIP != x ; then
205 strip $APPROOT/MacOS/Ardour3
209 if test x$WITH_NLS != x ; then
210 echo "NLS support ..."
211 echo "I hope you remembered to run scons msgupdate!"
213 for file in $BUILD_ROOT/gtk2_ardour/*.mo
215 lang=`basename $file | sed 's/\.mo//'`
216 mkdir -p $Locale/$lang/LC_MESSAGES
217 cp $file $Locale/$lang/LC_MESSAGES/gtk2_ardour.mo
218 LINGUAS="$LINGUAS $lang"
220 for file in $BUILD_ROOT/libs/ardour/*.mo
222 lang=`basename $file | sed 's/\.mo//'`
223 mkdir -p $Locale/$lang/LC_MESSAGES
224 cp $file $Locale/$lang/LC_MESSAGES/libardour.mo
228 if [ -d $GTKSTACK_ROOT/share/locale/$l ] ; then
229 echo "Copying GTK i18n files for $l..."
230 cp -r $GTKSTACK_ROOT/share/locale/$l $Locale
232 # try with just the language spec
233 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
234 if [ -d $GTKSTACK_ROOT/share/locale/$just_lang ] ; then
235 echo "Copying GTK i18n files for $l..."
236 cp -r $GTKSTACK_ROOT/share/locale/$just_lang $Locale
241 echo "Skipping NLS support"
245 # Copy stuff that may be dynamically loaded
248 cp -R $GTKSTACK_ROOT/etc/* $Etc
249 echo "Copying all Pango modules ..."
250 cp -R $GTKSTACK_ROOT/lib/pango/1.6.0/modules/*.so $Frameworks/modules
251 echo "Copying all GDK Pixbuf loaders ..."
252 cp -R $GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.so $Frameworks/modules
254 cp -R $GTKSTACK_ROOT/lib/charset.alias $Resources
256 # generate new Pango module file
259 ModulesPath=$GTKSTACK_ROOT/lib/pango/1.6.0/modules
261 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
264 # generate a new GDK pixbufs loaders file
265 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
267 # We rely on clearlooks, so include a version from our own build tree
268 # this one is special - we will set GTK_PATH to $Frameworks/gtkengines
270 GTK_ENGINE_DIR=$Frameworks/gtkengines/engines
271 mkdir -p $GTK_ENGINE_DIR
273 echo "Copying GTK engines ..."
274 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.so $Frameworks
275 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.dylib . && ln -s ../../libclearlooks.dylib libclearlooks.so)
277 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Frameworks
278 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.dylib . && ln -s ../../libpixmap.dylib libpixmap.so)
281 if test x$WITH_LADSPA != x ; then
282 if test x$SAE != x ; then
284 elif test x$MIXBUS != x ; then
285 plugdir=mixbus_ladspa
289 if [ -d $plugdir -a "x$(ls $plugdir)" != x ] ; then
290 echo "Copying `ls $plugdir | wc -l` plugins ..."
291 cp -r $plugdir/* $Plugins
295 # Control Surface shared libraries
296 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.dylib $Surfaces
297 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp*.dylib $Frameworks
300 cp $BUILD_ROOT/libs/panners/*/lib*.dylib $Panners
303 # Export Formats/Presets
304 for f in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
305 cp "$f" $ExportFormats ;
308 # Session and Route templates
309 for f in $BUILD_ROOT/../templates/* ; do
310 if [ -d "$f" ] ; then
311 cp -r "$f" $Templates ;
316 # got to be careful with names here
317 for x in $BUILD_ROOT/../midi_maps/*.map ; do
322 # got to be careful with names here
323 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
328 # got to be careful with names here
329 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
330 cp "$x" $MackieControl
333 # VAMP plugins that we use
334 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.dylib $Frameworks
337 cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Frameworks
341 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Panners/*.dylib $Surfaces/*.dylib $Plugins/*.so ; do
342 if ! file $file | grep -qs Mach-O ; then
345 deps=`otool -L $file | awk '{print $1}' | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | grep -v 'libjack\.'`
347 for dep in $deps ; do
349 if ! test -f $Frameworks/$base; then
350 if echo $dep | grep -sq '^libs' ; then
351 cp $BUILD_ROOT/$dep $Frameworks
359 if test x$missing = xfalse ; then
360 # everything has been found
366 echo "Copying other stuff to $APPDIR ..."
368 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Resources
370 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Resources
371 cp ../../gtk2_ardour/mixer.bindings $Resources
372 cp ../../gtk2_ardour/step_editing.bindings $Resources
373 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Resources
375 if test x$SAE != x ; then
376 cp $BUILD_ROOT/gtk2_ardour/SAE-de-keypad.bindings $Resources
377 cp $BUILD_ROOT/gtk2_ardour/SAE-de-nokeypad.bindings $Resources
378 cp $BUILD_ROOT/gtk2_ardour/SAE-us-keypad.bindings $Resources
379 cp $BUILD_ROOT/gtk2_ardour/SAE-us-nokeypad.bindings $Resources
380 cp $BUILD_ROOT/ardour_system_sae.rc $Resources/ardour_system.rc
381 echo cp $BUILD_ROOT/ardour_system_sae.rc $Resources/ardour_system.rc
382 cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
383 echo cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
385 cp ../../ardour_system.rc $Resources/ardour_system.rc
386 cp ../../instant.xml $Resources/instant.xml
387 echo cp ../../instant.xml $Resources/instant.xml
389 cp ../../gtk2_ardour/ardour3_ui_default.conf $Resources
390 cp ../../gtk2_ardour/ardour3_ui_default.conf $Resources/ardour3_ui.conf
391 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_light.rc $Resources
392 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_dark.rc $Resources
394 cp -r ../../gtk2_ardour/icons $Resources
395 cp -r ../../gtk2_ardour/pixmaps $Resources
398 cp -R ../../gtk2_ardour/splash.png $Shared
399 cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared
401 # go through and recursively remove any .svn dirs in the bundle
402 for svndir in `find $APPDIR -name .svn -type dir`; do
406 # now fix up the executables
407 echo "Fixing up executable dependency names ..."
408 executables=$MAIN_EXECUTABLE
409 if test x$SAE != x ; then
410 executables="$executables"
413 for exe in $executables; do
414 EXE=$APPROOT/MacOS/$exe
416 for lib in `otool -L $EXE | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
418 changes="$changes -change $lib @executable_path/../lib/$base"
420 if test "x$changes" != "x" ; then
421 install_name_tool $changes $EXE
425 echo "Fixing up library names ..."
426 # now do the same for all the libraries we include
427 for libdir in $Frameworks $Frameworks/modules $Surfaces $Panners ; do
429 libbase=`basename $libdir`
431 for dylib in $libdir/*.dylib $libdir/*.so ; do
435 if test -L $dylib ; then
439 # change all the dependencies
442 for lib in `otool -L $dylib | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
444 if echo $lib | grep -s libbase; then
445 changes="$changes -change $lib @executable_path/../$libbase/$base"
447 changes="$changes -change $lib @executable_path/../lib/$base"
451 if test "x$changes" != x ; then
452 if install_name_tool $changes $dylib ; then
459 # now the change what the library thinks its own name is
461 base=`basename $dylib`
462 install_name_tool -id @executable_path/../$libbase/$base $dylib
467 # and now ... the DMG
470 rm -rf $PRODUCT_PKG_DIR
471 mkdir $PRODUCT_PKG_DIR
473 if [ x$SAE != x ] ; then
477 echo "Creating SAE packaging directory"
478 mv $APPDIR $PRODUCT_PKG_DIR/Ardour3-SAE.app
479 cp HowToInstallArdourSAE.pdf "$PRODUCT_PKG_DIR/How To Install Ardour SAE.pdf"
480 cp SAE-de-keypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts (keypad).pdf"
481 cp SAE-de-nokeypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts.pdf"
483 elif [ x$MIXBUS != x ] ; then
487 echo "Creating Mixbus packaging directory"
488 mv $APPDIR $PRODUCT_PKG_DIR/
489 cp MixBus_Install_QuickStart.pdf "$PRODUCT_PKG_DIR/Mixbus Install & Quick Start Guide.pdf"
493 echo "Creating $APPNAME packaging directory"
494 mv $APPDIR $PRODUCT_PKG_DIR/
498 echo "Building DMG ..."
500 # UC_DMG=$APPNAME-${release_version}-${svn_version}-UC.dmg
501 # FINAL_DMG=$APPNAME-${release_version}-${svn_version}.dmg
502 UC_DMG=$APPNAME-${release_version}-${svn_version}.dmg
503 VOLNAME=$APPNAME-$release_version
506 MNTPATH=`mktemp -d -t ardourimg`
507 TMPDMG=`mktemp -t ardour`
508 ICNSTMP=`mktemp -t ardouricon`
509 DMGSIZE=$[ `du -sm "$PRODUCT_PKG_DIR" | cut -f 1` * 1049 / 1000 + 3 ]
511 rm -f $UC_DMG "$TMPDMG" "${TMPDMG}.dmg" "$ICNSTMP"
515 TMPDMG="${TMPDMG}.dmg"
517 hdiutil create -megabytes $DMGSIZE "$TMPDMG"
518 DiskDevice=$(hdid -nomount "$TMPDMG" | grep Apple_HFS | cut -f 1 -d ' ')
519 newfs_hfs -v "${VOLNAME}" "${DiskDevice}"
520 mount -t hfs "${DiskDevice}" "${MNTPATH}"
522 cp -r ${PRODUCT_PKG_DIR}/${APPDIR} "${MNTPATH}" || exit
523 mkdir "${MNTPATH}/.background"
524 cp -vi dmgbg.png "${MNTPATH}/.background/dmgbg.png"
526 echo "setting DMG background ..."
529 tell application "Finder"
530 tell disk "'${VOLNAME}'"
532 set current view of container window to icon view
533 set toolbar visible of container window to false
534 set statusbar visible of container window to false
535 set the bounds of container window to {400, 200, 800, 440}
536 set theViewOptions to the icon view options of container window
537 set arrangement of theViewOptions to not arranged
538 set icon size of theViewOptions to 64
539 set background picture of theViewOptions to file ".background:dmgbg.png"
540 make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
541 set position of item "'${APPDIR}'" of container window to {90, 100}
542 set position of item "Applications" of container window to {310, 100}
545 update without registering applications
552 chmod -Rf go-w "${MNTPATH}"
555 echo "compressing Image ..."
558 umount "${DiskDevice}"
559 hdiutil eject "${DiskDevice}"
560 # Create a read-only version, use zlib compression
561 hdiutil convert -format UDZO "${TMPDMG}" -imagekey zlib-level=9 -o "${UC_DMG}"
562 # Delete the temporary files
566 echo "setting file icon ..."
568 cp ${PRODUCT_PKG_DIR}/$Resources/appIcon.icns ${ICNSTMP}.icns
569 /usr/bin/sips -i ${ICNSTMP}.icns
570 /Developer/Tools/DeRez -only icns ${ICNSTMP}.icns > ${ICNSTMP}.rsrc
571 /Developer/Tools/Rez -append ${ICNSTMP}.rsrc -o "$UC_DMG"
572 /Developer/Tools/SetFile -a C "$UC_DMG"
574 rm ${ICNSTMP}.icns ${ICNSTMP}.rsrc
577 echo "packaging suceeded."