3 # script for pulling together a MacOSX app bundle.
5 GTKQUARTZ_ROOT=$HOME/gtk/inst
6 ARDOURSTACK_ROOT=$HOME/a3/inst
8 if pkg-config --modversion gtk+-2.0 | grep -s 2.22 ; then
10 GDKPIXBUF_LOADERS=$GTKQUARTZ_ROOT/lib/gtk-2.0/2.10.0/loaders
13 echo "*****************************************************"
14 echo "You are building with the OLD GTK stack. I hope that is ok"
15 echo "*****************************************************"
20 GDKPIXBUF_LOADERS=$GTKQUARTZ_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders
23 echo "*****************************************************"
24 echo "You are building with the NEW GTK stack. I hope that is ok"
25 echo "*****************************************************"
37 while [ $# -gt 0 ] ; do
42 # top level build targets
49 PRODUCT_PKG_DIR=ArdourSAE ;
57 PRODUCT_PKG_DIR=MixBus;
64 PRODUCT_PKG_DIR=Ardour;
71 PRODUCT_PKG_DIR=Ardour ;
73 --test) SAE= ; WITH_LADSPA=; STRIP= ; shift ;;
76 # specific build flags
79 --noladspa) WITH_LADSPA= ; shift ;;
80 --nostrip) STRIP= ; shift ;;
81 --sysdeps) PRINT_SYSDEPS=1; shift ;;
82 --nls) WITH_NLS=1 ; shift ;;
86 BUILD_ROOT=../../build
88 #release_version=`grep -m 1 '^VERSION' ../../wscript | cut -d' ' -f 3 | sed "s/'//g"`
90 svn_version=`grep -m 1 'svn_revision =' ../../libs/ardour/svn_revision.cc | cut -d' ' -f 8 | sed 's/[^0-9]//g'`
91 echo "Version is $release_version / $svn_version"
92 info_string="$release_version/$svn_version built on `hostname` by `whoami` on `date`"
93 echo "Info string is $info_string"
95 # setup directory structure
98 APPROOT=$APPDIR/Contents
99 Frameworks=$APPROOT/lib
100 Resources=$APPROOT/Resources
102 # Since this is OS X, don't try to distinguish between etc and shared
103 # (machine dependent and independent data) - just put everything
108 Locale=$Resources/locale
110 # Bundled Plugins live in a top level folder
112 Plugins=$APPROOT/Plugins
113 Surfaces=$Frameworks/surfaces
114 Panners=$Frameworks/panners
115 MidiMaps=$Shared/midi_maps
116 ExportFormats=$Shared/export
117 Templates=$Shared/templates
118 PatchFiles=$Shared/patchfiles
119 MackieControl=$Shared/mcp
121 if [ x$PRINT_SYSDEPS != x ] ; then
123 # print system dependencies
126 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Plugins/*.so ; do
127 if ! file $file | grep -qs Mach-O ; then
130 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
135 echo "Removing old $APPDIR tree ..."
139 echo "Building new app directory structure ..."
141 # only bother to make the longest paths
143 mkdir -p $APPROOT/MacOS
144 mkdir -p $APPROOT/Resources
149 mkdir -p $ExportFormats
151 mkdir -p $Frameworks/modules
152 mkdir -p $Shared/templates
154 mkdir -p $MackieControl
156 # maybe set variables
158 if test x$SAE != x ; then
159 appname="Ardour3/SAE"
160 env="$env<key>ARDOUR_SAE</key><string>true</string>"
162 # current default for SAE version is German keyboard layout without a keypad
164 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>de-nokeypad</string>"
165 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui_sae.conf</string>"
166 env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark_sae.rc</string>"
167 elif test x$MIXBUS != x ; then
168 appname="Ardour3/Mixbus"
169 env="$env<key>ARDOUR_MIXBUS</key><string>true</string>"
171 # current default for MIXBUS version is US keyboard layout without a keypad
173 env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>us-nokeypad</string>"
174 env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui.conf</string>"
175 env="$env<key>ARDOUR3_UI_RC</key><string>ardour3_ui_dark.rc</string>"
181 # if we're not going to bundle JACK, make sure we can find
182 # jack in the places where it might be
185 env="$env<key>PATH</key><string>/usr/local/bin:/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>"
186 env="$env<key>DYLIB_FALLBACK_LIBRARY_PATH</key><string>/usr/local/lib:/opt/lib</string>"
188 env="<key>LSEnvironment</key><dict>$env<key>ARDOUR_BUNDLED</key><string>true</string></dict>"
191 sed -e "s?@ENV@?$env?g" \
192 -e "s?@VERSION@?$release_version/$svn_version?g" \
193 -e "s?@INFOSTRING@?$info_string?g" < Info.plist.in > Info.plist
195 sed -e "s?@APPNAME@?$appname?" \
196 -e "s?@ENV@?$env?g" \
197 -e "s?@VERSION@?$release_version/$svn_version?g" \
198 -e "s?@INFOSTRING@?$info_string?g" < InfoPlist.strings.in > Resources/InfoPlist.strings || exit 1
202 cp Info.plist $APPROOT
203 cp -R Resources $APPROOT
206 # if we build a bundle without jack, then
207 # make the Ardour3 executable a helper
208 # script that checks to see if JACK is
212 cp startup_script $APPROOT/MacOS/Ardour3
213 chmod 775 $APPROOT/MacOS/Ardour3
214 MAIN_EXECUTABLE=Ardour3.bin
216 echo "Copying ardour executable ...."
217 cp $BUILD_ROOT/gtk2_ardour/ardour-$release_version $APPROOT/MacOS/$MAIN_EXECUTABLE
218 if test x$SAE != x ; then
219 # cp $BUILD_ROOT/gtk2_ardour/evtest $APPROOT/MacOS/gtkevents
220 cp Ardour3-SAE.icns $Resources/appIcon.icns
221 elif test x$MIXBUS != x ; then
222 cp Mixbus.icns $Resources/appIcon.icns
224 cp Ardour3.icns $Resources/appIcon.icns
226 cp typeArdour.icns $Resources/
227 if test x$STRIP != x ; then
228 strip $APPROOT/MacOS/Ardour3
232 if test x$WITH_NLS != x ; then
233 echo "NLS support ..."
234 echo "I hope you remembered to run scons msgupdate!"
236 for file in $BUILD_ROOT/gtk2_ardour/*.mo
238 lang=`basename $file | sed 's/\.mo//'`
239 mkdir -p $Locale/$lang/LC_MESSAGES
240 cp $file $Locale/$lang/LC_MESSAGES/gtk2_ardour.mo
241 LINGUAS="$LINGUAS $lang"
243 for file in $BUILD_ROOT/libs/ardour/*.mo
245 lang=`basename $file | sed 's/\.mo//'`
246 mkdir -p $Locale/$lang/LC_MESSAGES
247 cp $file $Locale/$lang/LC_MESSAGES/libardour.mo
251 if [ -d $GTKQUARTZ_ROOT/share/locale/$l ] ; then
252 echo "Copying GTK i18n files for $l..."
253 cp -r $GTKQUARTZ_ROOT/share/locale/$l $Locale
255 # try with just the language spec
256 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
257 if [ -d $GTKQUARTZ_ROOT/share/locale/$just_lang ] ; then
258 echo "Copying GTK i18n files for $l..."
259 cp -r $GTKQUARTZ_ROOT/share/locale/$just_lang $Locale
264 echo "Skipping NLS support"
267 cp -R $GTKQUARTZ_ROOT/etc/* $Etc
268 echo "Copying all Pango modules ..."
269 cp -R $GTKQUARTZ_ROOT/lib/pango/1.6.0/modules/*.so $Frameworks/modules
270 echo "Copying all GDK Pixbuf loaders ..."
271 cp -R $GDKPIXBUF_LOADERS/*.so $Frameworks/modules
273 cp -R $GTKQUARTZ_ROOT/lib/charset.alias $Resources
277 if test x$WITH_LADSPA != x ; then
278 if test x$SAE != x ; then
280 elif test x$MIXBUS != x ; then
281 plugdir=mixbus_ladspa
285 echo "Copying `ls $plugdir | wc -l` plugins ..."
286 cp -r $plugdir/* $Plugins
289 # generate new Pango module file
292 ModulesPath=$GTKQUARTZ_ROOT/lib/pango/1.6.0/modules
294 env PANGO_RC_FILE=pangorc $GTKQUARTZ_ROOT/bin/pango-querymodules | sed "s?$GTKQUARTZ_ROOT/lib/pango/1.6.0/modules/?@executable_path/../lib/modules/?" > $Resources/pango.modules
297 # generate a new GDK pixbufs loaders file
298 gdk-pixbuf-query-loaders | sed "s?$GDKPIXBUF_LOADERS/?@executable_path/../lib/modules/?" > $Resources/gdk-pixbuf.loaders
300 # this one is special - we will set GTK_PATH to $Frameworks/clearlooks
301 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.dylib $Frameworks
302 mkdir -p $Frameworks/clearlooks/engines
303 (cd $Frameworks/clearlooks/engines && ln -s $BUILD_ROOT/libclearlooks.dylib libclearlooks.dylib && ln -s ../../libclearlooks.dylib libclearlooks.so)
305 # Control Surface shared libraries
306 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.dylib $Surfaces
307 # hack ... move libardour_cp back into Frameworks
308 mv $Surfaces/libardourcp*.dylib $Frameworks
311 cp $BUILD_ROOT/libs/panners/*/lib*.dylib $Panners
314 # Export Formats/Presets
315 for f in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
316 echo ExportFormat: $f
317 cp "$f" $ExportFormats ;
320 # Session and Route templates
321 for f in $BUILD_ROOT/../templates/* ; do
322 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
332 echo Copied MIDI map $x
336 # got to be careful with names here
337 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
339 echo Copied MIDNAM file "$x"
343 # got to be careful with names here
344 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
345 cp "$x" $MackieControl
346 echo Copied Mackie Control file $x
349 # VAMP plugins that we use
350 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.dylib $Frameworks
353 cp $ARDOURSTACK_ROOT/lib/suil-0/libsuil* $Frameworks
357 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Panners/*.dylib $Surfaces/*.dylib $Plugins/*.so ; do
358 if ! file $file | grep -qs Mach-O ; then
361 deps=`otool -L $file | awk '{print $1}' | egrep "($GTKQUARTZ_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | grep -v 'libjack\.'`
363 for dep in $deps ; do
365 if ! test -f $Frameworks/$base; then
366 if echo $dep | grep -sq '^libs' ; then
367 cp $BUILD_ROOT/$dep $Frameworks
375 if test x$missing = xfalse ; then
376 # everything has been found
382 echo "Copying other stuff to $APPDIR ..."
384 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Resources
386 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Resources
387 cp ../../gtk2_ardour/mixer.bindings $Resources
388 cp ../../gtk2_ardour/step_editing.bindings $Resources
389 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Resources
391 if test x$SAE != x ; then
392 cp $BUILD_ROOT/gtk2_ardour/SAE-de-keypad.bindings $Resources
393 cp $BUILD_ROOT/gtk2_ardour/SAE-de-nokeypad.bindings $Resources
394 cp $BUILD_ROOT/gtk2_ardour/SAE-us-keypad.bindings $Resources
395 cp $BUILD_ROOT/gtk2_ardour/SAE-us-nokeypad.bindings $Resources
396 cp $BUILD_ROOT/ardour_system_sae.rc $Resources/ardour_system.rc
397 echo cp $BUILD_ROOT/ardour_system_sae.rc $Resources/ardour_system.rc
398 cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
399 echo cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
401 # cp $BUILD_ROOT/ardour_system.rc $Resources/ardour_system.rc
402 # echo FOO cp $BUILD_ROOT/ardour_system.rc $Resources/ardour_system.rc
403 cp ../../instant.xml $Resources/instant.xml
404 echo cp ../../instant.xml $Resources/instant.xml
406 cp ../../gtk2_ardour/ardour3_ui_default.conf $Resources
407 cp ../../gtk2_ardour/ardour3_ui_default.conf $Resources/ardour3_ui.conf
408 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_light.rc $Resources
409 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_dark.rc $Resources
411 cp -r ../../gtk2_ardour/icons $Resources
412 cp -r ../../gtk2_ardour/pixmaps $Resources
414 # splash screen stuff
415 cp -R ../../gtk2_ardour/splash.png $Shared
417 # go through and recursively remove any .svn dirs in the bundle
418 for svndir in `find $APPDIR -name .svn -type dir`; do
422 # now fix up the executables
423 echo "Fixing up executable dependency names ..."
424 executables=$MAIN_EXECUTABLE
425 if test x$SAE != x ; then
426 executables="$executables"
429 for exe in $executables; do
430 EXE=$APPROOT/MacOS/$exe
432 for lib in `otool -L $EXE | egrep "($GTKQUARTZ_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
434 changes="$changes -change $lib @executable_path/../lib/$base"
436 if test "x$changes" != "x" ; then
437 install_name_tool $changes $EXE
441 echo "Fixing up library names ..."
442 # now do the same for all the libraries we include
443 for libdir in $Frameworks $Frameworks/modules $Surfaces $Panners ; do
445 libbase=`basename $libdir`
447 for dylib in $libdir/*.dylib $libdir/*.so ; do
451 if test -L $dylib ; then
455 # change all the dependencies
458 for lib in `otool -L $dylib | egrep "($GTKQUARTZ_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
460 if echo $lib | grep -s libbase; then
461 changes="$changes -change $lib @executable_path/../$libbase/$base"
463 changes="$changes -change $lib @executable_path/../lib/$base"
467 if test "x$changes" != x ; then
468 if install_name_tool $changes $dylib ; then
475 # now the change what the library thinks its own name is
477 base=`basename $dylib`
478 install_name_tool -id @executable_path/../$libbase/$base $dylib
483 # and now ... the DMG
486 rm -rf $PRODUCT_PKG_DIR
487 mkdir $PRODUCT_PKG_DIR
489 if [ x$SAE != x ] ; then
493 echo "Creating SAE packaging directory"
494 mv $APPDIR $PRODUCT_PKG_DIR/Ardour3-SAE.app
495 cp HowToInstallArdourSAE.pdf "$PRODUCT_PKG_DIR/How To Install Ardour SAE.pdf"
496 cp SAE-de-keypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts (keypad).pdf"
497 cp SAE-de-nokeypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts.pdf"
499 elif [ x$MIXBUS != x ] ; then
503 echo "Creating Mixbus packaging directory"
504 mv $APPDIR $PRODUCT_PKG_DIR/
505 cp MixBus_Install_QuickStart.pdf "$PRODUCT_PKG_DIR/Mixbus Install & Quick Start Guide.pdf"
509 echo "Creating $APPNAME packaging directory"
510 mv $APPDIR $PRODUCT_PKG_DIR/
514 echo "Building DMG ..."
516 # UC_DMG=$APPNAME-${release_version}-${svn_version}-UC.dmg
517 # FINAL_DMG=$APPNAME-${release_version}-${svn_version}.dmg
518 UC_DMG=$APPNAME-${release_version}-${svn_version}.dmg
521 echo hdiutil create $UC_DMG -volname $APPNAME-$release_version -fs HFS+ -srcfolder $PRODUCT_PKG_DIR
522 hdiutil create $UC_DMG -volname $APPNAME-$release_version -fs HFS+ -srcfolder $PRODUCT_PKG_DIR
525 # echo "Compressing DMG ..."
527 # hdiutil convert $UC_DMG -format UDBZ -o $FINAL_DMG