3 # script for pulling together a MacOSX app bundle.
5 GTKQUARTZ_ROOT=$HOME/gtk/inst
7 if pkg-config --modversion gtk+-2.0 | grep -s 2.22 ; then
9 GDKPIXBUF_LOADERS=$GTKQUARTZ_ROOT/lib/gtk-2.0/2.10.0/loaders
12 echo "*****************************************************"
13 echo "You are building with the OLD GTK stack. I hope that is ok"
14 echo "*****************************************************"
19 GDKPIXBUF_LOADERS=$GTKQUARTZ_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders
22 echo "*****************************************************"
23 echo "You are building with the NEW GTK stack. I hope that is ok"
24 echo "*****************************************************"
38 while [ $# -gt 0 ] ; do
43 # top level build targets
51 PRODUCT_PKG_DIR=ArdourSAE ;
60 PRODUCT_PKG_DIR=MixBus;
68 PRODUCT_PKG_DIR=Ardour;
76 PRODUCT_PKG_DIR=Ardour ;
78 --test) SAE= ; INTERNAL_JACK=; WITH_LADSPA=; STRIP= ; shift ;;
81 # specific build flags
84 --nojack) INTERNAL_JACK= ; shift ;;
85 --noladspa) WITH_LADSPA= ; shift ;;
86 --nostrip) STRIP= ; shift ;;
87 --sysdeps) PRINT_SYSDEPS=1; shift ;;
88 --nls) WITH_NLS=1 ; shift ;;
89 --external_jack) EXTERNAL_JACK=$2; shift ; shift ;;
93 if [ x$EXTERNAL_JACK != x -a x$INTERNAL_JACK != x ] ; then
94 echo "It makes no sense to package JACK internally and externally. Please pick one."
97 BUILD_ROOT=../../build
99 #release_version=`grep -m 1 '^VERSION' ../../wscript | cut -d' ' -f 3 | sed "s/'//g"`
101 svn_version=`grep -m 1 'svn_revision =' ../../libs/ardour/svn_revision.cc | cut -d' ' -f 8 | sed 's/[^0-9]//g'`
102 echo "Version is $release_version / $svn_version"
103 info_string="$release_version/$svn_version built on `hostname` by `whoami` on `date`"
104 echo "Info string is $info_string"
106 # setup directory structure
108 APPDIR=${APPNAME}.app
109 APPROOT=$APPDIR/Contents
110 Frameworks=$APPROOT/Frameworks
111 Resources=$APPROOT/Resources
112 Plugins=$APPROOT/Plugins
113 Surfaces=$APPROOT/Surfaces
114 Panners=$APPROOT/Panners
115 MidiMaps=$APPROOT/MidiMaps
116 ExportFormats=$APPROOT/ExportFormats
117 Templates=$APPROOT/Templates
118 Shared=$Resources/share
120 Locale=$Resources/locale
122 if [ x$PRINT_SYSDEPS != x ] ; then
124 # print system dependencies
127 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Plugins/*.so ; do
128 if ! file $file | grep -qs Mach-O ; then
131 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
136 echo "Removing old $APPDIR tree ..."
140 echo "Building new app directory structure ..."
142 # only bother to make the longest paths
144 mkdir -p $APPROOT/MacOS
145 mkdir -p $APPROOT/Resources
150 mkdir -p $ExportFormats
152 mkdir -p $Frameworks/modules
153 mkdir -p $Shared/templates
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 if test x$INTERNAL_JACK != x ; then
186 env="$env<key>ARDOUR_INTERNAL_JACK</key><string>true</string>"
188 env="$env<key>PATH</key><string>/usr/local/bin:/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>"
189 env="$env<key>DYLIB_FALLBACK_LIBRARY_PATH</key><string>/usr/local/lib:/opt/lib</string>"
192 env="<key>LSEnvironment</key><dict>$env<key>ARDOUR_BUNDLED</key><string>true</string></dict>"
195 sed -e "s?@ENV@?$env?g" \
196 -e "s?@VERSION@?$release_version/$svn_version?g" \
197 -e "s?@INFOSTRING@?$info_string?g" < Info.plist.in > Info.plist
199 sed -e "s?@APPNAME@?$appname?" \
200 -e "s?@ENV@?$env?g" \
201 -e "s?@VERSION@?$release_version/$svn_version?g" \
202 -e "s?@INFOSTRING@?$info_string?g" < InfoPlist.strings.in > Resources/InfoPlist.strings || exit 1
206 cp Info.plist $APPROOT
207 cp -R Resources $APPROOT
210 # if we build a bundle without jack, then
211 # make the Ardour3 executable a helper
212 # script that checks to see if JACK is
216 if test x$INTERNAL_JACK != x ; then
217 MAIN_EXECUTABLE=Ardour3
219 cp startup_script $APPROOT/MacOS/Ardour3
220 chmod 775 $APPROOT/MacOS/Ardour3
221 MAIN_EXECUTABLE=Ardour3.bin
224 echo "Copying ardour executable ...."
225 cp $BUILD_ROOT/gtk2_ardour/ardour-$release_version $APPROOT/MacOS/$MAIN_EXECUTABLE
226 if test x$SAE != x ; then
227 # cp $BUILD_ROOT/gtk2_ardour/evtest $APPROOT/MacOS/gtkevents
228 cp Ardour3-SAE.icns $Resources/appIcon.icns
229 elif test x$MIXBUS != x ; then
230 cp Mixbus.icns $Resources/appIcon.icns
232 cp Ardour3.icns $Resources/appIcon.icns
234 if test x$STRIP != x ; then
235 strip $APPROOT/MacOS/Ardour3
237 if test x$INTERNAL_JACK != x ; then
238 if [ -f /usr/local/lib/jack/jack_coreaudio.so ] ; then
239 cp /usr/local/lib/jack/jack_coreaudio.so $Frameworks
240 cp /usr/local/bin/jackd $APPROOT/MacOS
241 JACK_SHARED_OBJECTS="$Frameworks/*.so"
246 if test x$WITH_NLS != x ; then
247 echo "NLS support ..."
248 echo "I hope you remembered to run scons msgupdate!"
250 for file in $BUILD_ROOT/gtk2_ardour/*.mo
252 lang=`basename $file | sed 's/\.mo//'`
253 mkdir -p $Locale/$lang/LC_MESSAGES
254 cp $file $Locale/$lang/LC_MESSAGES/gtk2_ardour.mo
255 LINGUAS="$LINGUAS $lang"
257 for file in $BUILD_ROOT/libs/ardour/*.mo
259 lang=`basename $file | sed 's/\.mo//'`
260 mkdir -p $Locale/$lang/LC_MESSAGES
261 cp $file $Locale/$lang/LC_MESSAGES/libardour.mo
265 if [ -d $GTKQUARTZ_ROOT/share/locale/$l ] ; then
266 echo "Copying GTK i18n files for $l..."
267 cp -r $GTKQUARTZ_ROOT/share/locale/$l $Locale
269 # try with just the language spec
270 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
271 if [ -d $GTKQUARTZ_ROOT/share/locale/$just_lang ] ; then
272 echo "Copying GTK i18n files for $l..."
273 cp -r $GTKQUARTZ_ROOT/share/locale/$just_lang $Locale
278 echo "Skipping NLS support"
281 cp -R $GTKQUARTZ_ROOT/etc/* $Etc
282 echo "Copying all Pango modules ..."
283 cp -R $GTKQUARTZ_ROOT/lib/pango/1.6.0/modules/*.so $Frameworks/modules
284 echo "Copying all GDK Pixbuf loaders ..."
285 cp -R $GDKPIXBUF_LOADERS/*.so $Frameworks/modules
287 cp -R $GTKQUARTZ_ROOT/lib/charset.alias $Resources
291 if test x$WITH_LADSPA != x ; then
292 if test x$SAE != x ; then
294 elif test x$MIXBUS != x ; then
295 plugdir=mixbus_ladspa
299 echo "Copying `ls $plugdir | wc -l` plugins ..."
300 cp -r $plugdir/* $Plugins
303 # generate new Pango module file
306 ModulesPath=$GTKQUARTZ_ROOT/lib/pango/1.6.0/modules
308 env PANGO_RC_FILE=pangorc $GTKQUARTZ_ROOT/bin/pango-querymodules | sed "s?$GTKQUARTZ_ROOT/lib/pango/1.6.0/modules/?@executable_path/../Frameworks/modules/?" > $Resources/pango.modules
311 # generate a new GDK pixbufs loaders file
312 gdk-pixbuf-query-loaders | sed "s?$GDKPIXBUF_LOADERS/?@executable_path/../Frameworks/modules/?" > $Resources/gdk-pixbuf.loaders
314 # this one is special - we will set GTK_PATH to $Frameworks/clearlooks
315 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.dylib $Frameworks
316 mkdir -p $Frameworks/clearlooks/engines
317 (cd $Frameworks/clearlooks/engines && ln -s $BUILD_ROOT/libclearlooks.dylib libclearlooks.dylib && ln -s ../../libclearlooks.dylib libclearlooks.so)
319 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.dylib $Surfaces
320 cp $BUILD_ROOT/libs/panners/*/lib*.dylib $Panners
322 for f in *.preset ; do
323 echo ExportFormat: $f; cp "$f" ../tools/osx_packaging/$ExportFormats ;
325 (cd $BUILD_ROOT/templates && \
326 for f in *.template ; do
327 echo Template: $f ; cp "$f" ../../tools/osx_packaging/$Templates ;
331 cp ../../midi_maps/*.map $MidiMaps
333 # VAMP plugins that we use
334 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.dylib $Frameworks
338 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Plugins/*.so ; do
339 if ! file $file | grep -qs Mach-O ; then
342 if test x$INTERNAL_JACK != x ; then
343 deps=`otool -L $file | awk '{print $1}' | egrep "($GTKQUARTZ_ROOT|/opt/|/local/|libs/)"`
345 # do not include libjack
346 deps=`otool -L $file | awk '{print $1}' | egrep "($GTKQUARTZ_ROOT|/opt/|/local/|libs/)" | grep -v 'libjack\.'`
349 for dep in $deps ; do
351 if ! test -f $Frameworks/$base; then
352 if echo $dep | grep -sq '^libs' ; then
353 cp $BUILD_ROOT/$dep $Frameworks
361 if test x$missing = xfalse ; then
362 # everything has been found
368 echo "Copying other stuff to $APPDIR ..."
370 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Resources
371 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Resources
372 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Resources
373 if test x$SAE != x ; then
374 cp $BUILD_ROOT/gtk2_ardour/SAE-de-keypad.bindings $Resources
375 cp $BUILD_ROOT/gtk2_ardour/SAE-de-nokeypad.bindings $Resources
376 cp $BUILD_ROOT/gtk2_ardour/SAE-us-keypad.bindings $Resources
377 cp $BUILD_ROOT/gtk2_ardour/SAE-us-nokeypad.bindings $Resources
378 cp $BUILD_ROOT/ardour_system_sae.rc $Resources/ardour_system.rc
379 echo cp $BUILD_ROOT/ardour_system_sae.rc $Resources/ardour_system.rc
380 cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
381 echo cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
383 # cp $BUILD_ROOT/ardour_system.rc $Resources/ardour_system.rc
384 # echo FOO cp $BUILD_ROOT/ardour_system.rc $Resources/ardour_system.rc
385 cp ../../instant.xml $Resources/instant.xml
386 echo cp ../../instant.xml $Resources/instant.xml
388 cp ../../gtk2_ardour/ardour3_ui_default.conf $Resources
389 cp ../../gtk2_ardour/ardour3_ui_default.conf $Resources/ardour3_ui.conf
390 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_light.rc $Resources
391 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_dark.rc $Resources
393 cp -r ../../gtk2_ardour/icons $Resources
394 cp -r ../../gtk2_ardour/pixmaps $Resources
396 # go through and recursively remove any .svn dirs in the bundle
397 for svndir in `find $APPDIR -name .svn -type dir`; do
401 # now fix up the executables
402 echo "Fixing up executable dependency names ..."
403 executables=$MAIN_EXECUTABLE
404 if test x$INTERNAL_JACK != x ; then
405 executables="$executables jackd"
407 if test x$SAE != x ; then
408 executables="$executables"
411 for exe in $executables; do
412 EXE=$APPROOT/MacOS/$exe
414 if test x$INTERNAL_JACK != x ; then
415 for lib in `otool -L $EXE | egrep "($GTKQUARTZ_ROOT|/opt/|/local/|libs/)" | awk '{print $1}'` ; do
417 changes="$changes -change $lib @executable_path/../Frameworks/$base"
420 for lib in `otool -L $EXE | egrep "($GTKQUARTZ_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
422 changes="$changes -change $lib @executable_path/../Frameworks/$base"
425 if test "x$changes" != "x" ; then
426 install_name_tool $changes $EXE
430 echo "Fixing up library names ..."
431 # now do the same for all the libraries we include
432 for dylib in $JACK_SHARED_OBJECTS $Frameworks/*.dylib $Frameworks/modules/*.so $Surfaces/*.dylib ; do
434 if test ! -L $dylib ; then
436 # change all the dependencies
439 if test x$INTERNAL_JACK != x ; then
440 for lib in `otool -L $dylib | egrep "($GTKQUARTZ_ROOT|/opt/|/local/|libs/)" | awk '{print $1}'` ; do
442 changes="$changes -change $lib @executable_path/../Frameworks/$base"
445 for lib in `otool -L $dylib | egrep "($GTKQUARTZ_ROOT|/opt/|/local/|libs/)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
447 changes="$changes -change $lib @executable_path/../Frameworks/$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/../Frameworks/$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"
491 if [ -x $EXTERNAL_JACK != x ] ; then
492 cp $EXTERNAL_JACK $PRODUCT_PKG_DIR
498 echo "Creating $APPNAME packaging directory"
499 mv $APPDIR $PRODUCT_PKG_DIR/
503 echo "Building DMG ..."
505 # UC_DMG=$APPNAME-${release_version}-${svn_version}-UC.dmg
506 # FINAL_DMG=$APPNAME-${release_version}-${svn_version}.dmg
507 UC_DMG=$APPNAME-${release_version}-${svn_version}.dmg
510 echo hdiutil create $UC_DMG -volname $APPNAME-$release_version -fs HFS+ -srcfolder $PRODUCT_PKG_DIR
511 hdiutil create $UC_DMG -volname $APPNAME-$release_version -fs HFS+ -srcfolder $PRODUCT_PKG_DIR
514 # echo "Compressing DMG ..."
516 # hdiutil convert $UC_DMG -format UDBZ -o $FINAL_DMG