3 # script for pulling together a Linux app bundle.
5 # This will create a bundle for a single architecture.
6 # Execute this scirpt on both x86 and x86_64 and then use
7 # package to merge the 2 bundles into a final package with the
8 # installer. See "noderun" for a complete build script.
10 # where the GTK stack is installed
11 GTKSTACK_ROOT=$HOME/gtk/inst
12 # where the Ardour dependencies are installed
13 ARDOURSTACK_ROOT=$HOME/a3/inst
14 # the waf build tree to use when copying built/generated files
15 BUILD_ROOT=../../build
26 if [ $# -eq 0 ] ; then
28 echo "ERROR - Please specify build type"
35 while [ $# -gt 0 ] ; do
40 # top level build targets
62 --test) WITH_LADSPA=; STRIP= ; shift ;;
65 # specific build flags
68 --nojack) INTERNAL_JACK= ; shift ;;
69 --noladspa) WITH_LADSPA= ; shift ;;
70 --strip) STRIP=$2 ; shift ; shift ;;
71 --sysdeps) PRINT_SYSDEPS=1; shift ;;
72 --nls) WITH_NLS=1 ; shift ;;
75 #catch all for unknown arguments
77 echo "!!! ERROR !!! - Unknown argument $1"
84 if test x$STRIP != xall -a x$STRIP != xnone -a x$STRIP != xsome ; then
85 echo "Unknown strip option \"$STRIP\""
86 echo "Legal values are: all, none, some"
90 # Error out whenever possible
93 release_version=`grep -m 1 '^VERSION' ../../wscript | awk '{print $3}' | sed "s/'//g"`
94 svn_version=`grep -m 1 'svn_revision =' ../../libs/ardour/svn_revision.cc | cut -d"'" -f 2`
95 echo "Version is $release_version / $svn_version"
96 info_string="$release_version/$svn_version built on `hostname` by `whoami` on `date`"
97 echo "Info string is $info_string"
99 # Figure out our CPU type
101 i[3456789]86|x86|i86pc)
102 echo "Architecture is x86"
107 echo "Architecture is x86_64"
113 echo "ERROR - Unknown architecture `uname -m`"
119 # Figure out the Build Type
120 if grep -q "DEBUG = True" ../../build/c4che/default.cache.py; then
126 if [ x$DEBUG = xT ]; then
128 if [ x$STRIP = xall ] ; then
129 echo "A debug build with --strip all makes no sense - STRIP reset to \"some\""
134 # setup directory structure
136 if [ -z "${BUILDTYPE}" ]; then
137 APPDIR=${APPNAME}_${ARCH}-${release_version}_${svn_version}
138 APP_VER_NAME=${APPNAME}-${release_version}_${svn_version}
140 APPDIR=${APPNAME}_${ARCH}-${release_version}_${svn_version}-${BUILDTYPE}
141 APP_VER_NAME=${APPNAME}-${release_version}_${svn_version}-${BUILDTYPE}
150 Plugins=$APPLIB/plugins
151 Surfaces=$APPLIB/surfaces
152 Panners=$APPLIB/panners
154 Modules=$Libraries/modules
155 Loaders=$Libraries/loaders
157 Templates=$Shared/templates
158 ExportFormats=$Shared/export
159 Locale=$Shared/locale
160 MidiMaps=$Shared/midi_maps
161 PatchFiles=$Shared/patchfiles
162 MackieControl=$Shared/mcp
164 if [ x$PRINT_SYSDEPS != x ] ; then
166 # print system dependencies
169 for file in $APPBIN/* $Libraries/* $Modules/* $Plugins/*.so ; do
170 if ! file $file | grep -qs Mach-O ; then
173 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
178 echo "Removing old $APPDIR tree ..."
181 echo "Building new app directory structure ..."
183 # only bother to make the longest paths
197 mkdir -p $MackieControl
198 mkdir -p $ExportFormats
201 mkdir -p $Shared/templates
204 # maybe set variables
205 ENVIRONMENT=environment
209 if test x$MIXBUS != x ; then
210 echo export ARDOUR_MIXBUS=true >> $ENVIRONMENT
212 # current default for MIXBUS version is US keyboard layout without a keypad
214 echo export ARDOUR_KEYBOARD_LAYOUT=us-nokeypad >> $ENVIRONMENT
215 echo export ARDOUR_UI_CONF=ardour3_ui.conf >> $ENVIRONMENT
216 echo export ARDOUR3_UI_RC=ardour3_ui_dark.rc >> $ENVIRONMENT
220 # if we're not going to bundle JACK, make sure we can find
221 # jack in the places where it might be
224 echo export 'PATH=/usr/local/bin:/opt/bin:$PATH' >> $ENVIRONMENT
226 # create startup helper script
228 sed -e "/^%ENV%/r $ENVIRONMENT" -e '/^%ENV%/d' -e 's/%VER%/'"${release_version}"'/' < ardour.sh.in > $APPBIN/ardour3
229 rm $ENVIRONMENT && chmod 775 $APPBIN/ardour3
230 # the 3.0 here is not the same as "release-version" because the latter may include "-betaN" etc.
231 MAIN_EXECUTABLE=ardour-3.0
233 echo "Copying ardour executable ...."
234 cp $BUILD_ROOT/gtk2_ardour/$MAIN_EXECUTABLE $APPBIN
235 if test x$STRIP = xall ; then
236 strip $APPBIN/$MAIN_EXECUTABLE
240 # note that at present(feb 2011), the .mo files end up in the source tree which is
241 # not really as it should be.
242 if test x$WITH_NLS != x ; then
243 echo "NLS support ..."
244 echo "I hope you remembered to run scons msgupdate!"
247 for dl in gtk2_ardour libs/ardour libs/gtkmm2ext ; do
248 files=`find ../../$dl -name "*.mo"`
250 if [ -z "$files" ]; then
252 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$dl"
259 lang=`basename $file | sed 's/\.mo//'`
260 mkdir -p $Locale/$lang/LC_MESSAGES
261 cp $file $Locale/$lang/LC_MESSAGES/`basename $dl`
262 if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
265 LINGUAS="$LINGUAS $lang"
270 GTK_MESSAGES="atk10.mo gdk-pixbuf.mo gtk20-properties.mo gtk20.mo atk10.mo glib20.mo"
271 LOCALEROOT=/usr/share/locale
273 for l in $LINGUAS ; do
274 echo "Copying GTK i18n files for $l..."
275 for MO in $GTK_MESSAGES ; do
276 if [ -f $LOCALEROOT/$l/LC_MESSAGES/$MO ] ; then
277 cp $LOCALEROOT/$l/LC_MESSAGES/$MO $Locale/$l/LC_MESSAGES
279 # try with just the language spec
280 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
281 if [ -f $LOCALEROOT/$just_lang/LC_MESSAGES/$MO ] ; then
282 cp $LOCALEROOT/$just_lang/LC_MESSAGES/$MO $Locale/$just_lang/LC_MESSAGES
288 echo "Skipping NLS support"
292 # Copy stuff that may be dynamically loaded
295 cp -R $GTKSTACK_ROOT/etc/* $Etc
296 echo "Copying all Pango modules ..."
297 cp -R $GTKSTACK_ROOT/lib/pango/1.6.0/modules/*.so $Modules
298 echo "Copying all GDK Pixbuf loaders ..."
299 cp -R $GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.so $Loaders
301 # Generate a pango module file using the actual Pango that we're going to bundle
305 ModulesPath=$GTKSTACK_ROOT/lib/pango/1.6.0/modules
307 env PANGO_RC_FILE=pangorc $GTKSTACK_ROOT/bin/pango-querymodules | sed "s?$GTKSTACK_ROOT/lib/pango/1.6.0/?@ROOTDIR@/?" > $Etc/pango.modules.in
310 # Ditto for gdk-pixbuf loaders
311 gdk-pixbuf-query-loaders | sed "s?$GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/?@ROOTDIR@/?" > $Etc/gdk-pixbuf.loaders.in
313 # We rely on clearlooks, so include a version from our own build tree
314 # this one is special - we will set GTK_PATH to $Libraries/clearlooks
316 echo "Copying clearlooks ..."
317 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.so $Libraries
318 mkdir -p $Libraries/clearlooks/engines
319 (cd $Libraries/clearlooks/engines && ln -s ../../libclearlooks.so . )
322 if test x$WITH_LADSPA != x ; then
323 if test x$MIXBUS != x ; then
324 plugdir=mixbus_ladspa
328 echo "Copying `ls $plugdir | wc -l` plugins ..."
329 if [ -d $plugdir ] ; then
330 cp -r $plugdir/* $Plugins
335 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.so* $Surfaces
336 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp.so* $Libraries
339 # got to be careful with names here
340 for x in $BUILD_ROOT/../midi_maps/*.map ; do
345 # got to be careful with names here
346 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
351 # got to be careful with names here
352 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
353 cp "$x" $MackieControl
357 for f in $BUILD_ROOT/../templates/* ; do
358 if [ -d "$f" ] ; then
359 echo Template: $f ; cp -r "$f" $Templates ;
364 # got to be careful with names here
365 for x in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
366 cp "$x" $ExportFormats
370 cp $BUILD_ROOT/libs/panners/*/lib*.so* $Panners
372 # VAMP plugins that we use
373 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.so* $Libraries
376 cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Libraries
378 OURLIBDIR=$BUILD_ROOT/libs
379 OURLIBS=$OURLIBDIR/vamp-sdk:$OURLIBDIR/surfaces/control_protocol:$OURLIBDIR/ardour:$OURLIBDIR/midi++2:$OURLIBDIR/pbd:$OURLIBDIR/rubberband:$OURLIBDIR/soundtouch:$OURLIBDIR/gtkmm2ext:$OURLIBDIR/sigc++2:$OURLIBDIR/glibmm2:$OURLIBDIR/gtkmm2/atk:$OURLIBDIR/gtkmm2/pango:$OURLIBDIR/gtkmm2/gdk:$OURLIBDIR/gtkmm2/gtk:$OURLIBDIR/libgnomecanvasmm:$OURLIBDIR/libsndfile:$OURLIBDIR/evoral:$OURLIBDIR/evoral/src/libsmf:$OURLIBDIR/audiographer:$OURLIBDIR/timecode:$OURLIBDIR/taglib:$OURLIBDIR/qm-dsp
381 echo $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
388 filelist=`find $APPLIB/ -type f`
389 filelist="$APPBIN/$MAIN_EXECUTABLE $filelist"
391 for file in $filelist ; do
392 if ! file $file | grep -qs ELF ; then
396 # speed this up a bit by not checking things multiple times.
397 for i in "${depCheckedList[@]}"; do
398 if [ $i == $file ]; then
402 depCheckedList[$checkIdx]=$file
403 checkIdx=$(($checkIdx + 1))
405 # do not include libjack
406 deps=`LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | awk '{print $3}'`
409 for dep in $deps ; do
410 if test "not" = ${dep}; then
412 echo "!!! ERROR !!! - Missing dependant library for $file."
414 (LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file)
416 echo "!!! ERROR !!! - See Above"
420 # don't use anything mapped at a specific address
421 if echo $dep | grep -qs '0x' ; then continue; fi
423 if echo $dep | grep -qs "^/lib/" ; then continue; fi
425 if echo $dep | grep -qs libjack ; then continue; fi
427 if echo $dep | grep -qs libasound ; then continue; fi
428 # don't include any X Window libraries
429 if echo $dep | grep -qs libX\. ; then continue; fi
430 if echo $dep | grep -qs libxcb ; then continue; fi
431 if echo $dep | grep -qs libICE\. ; then continue; fi
432 if echo $dep | grep -qs libSM\. ; then continue; fi
434 if echo $dep | grep -qs 'libc\.' ; then continue; fi
435 # don't include libstdc++
436 if echo $dep | grep -qs libstdc++ ; then continue; fi
439 if ! test -f $Libraries/$base; then
440 parent=$(basename ${file})
441 if echo $dep | grep -sq '^libs' ; then
442 echo "Copying dependant lib $BUILD_ROOT/$dep (required by ${parent})"
443 cp $BUILD_ROOT/$dep $Libraries
445 echo "Copying dependant lib $dep (required by ${parent})"
449 # reset RPATH so that the runtime linker never looks
450 # in places we don't want it to
452 patchelf --set-rpath $Libraries $Libraries/`basename $dep`
453 if echo $dep | grep -sq '^/' ; then
454 # absolute path, candidate for stripping
455 deplibs="$deplibs $base"
461 if test x$missing = xfalse ; then
462 # everything has been found
469 if test x$STRIP = xall ; then
470 echo Stripping all libraries
471 # Must be writable so that we can strip
472 find $APPLIB/ -name "*.so*" | xargs chmod u+w
474 find $APPLIB/ -name "*.so*" | xargs strip
475 elif test x$STRIP = xsome ; then
476 echo Stripping dependent libraries
477 for l in $deplibs ; do
482 find $APPLIB/ -name "*.so*" | xargs chmod a+rx
484 echo "Copying other stuff to $APPDIR ..."
486 # these are all generated by waf
487 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Etc
488 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Etc
489 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc
490 cp $BUILD_ROOT/ardour_system.rc $Etc/ardour_system.rc
491 cp $BUILD_ROOT/gtk2_ardour/ardour3*.rc $Etc
493 # these are copied straight from the source tree
495 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui_default.conf
496 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui.conf
497 cp ../../instant.xml $Etc/instant.xml
498 cp ../../gtk2_ardour/step_editing.bindings $Etc
499 cp ../../gtk2_ardour/mixer.bindings $Etc
500 cp -r ../../gtk2_ardour/icons $Shared
501 cp -r ../../gtk2_ardour/pixmaps $Shared
505 # put sooper sekrit ingredients here and they will be copied
508 if [ -d specialSauce ] ; then
509 cp -r specialSauce $Etc
514 cp -R ../../gtk2_ardour/splash.png $Shared
516 # go through and recursively remove any .svn dirs in the bundle
517 for svndir in `find $APPDIR -name .svn -type d`; do
522 # Add the uninstaller
524 sed -e "s/%REPLACE_PGM%/${APPNAME}/" -e "s/%REPLACE_VENDOR%/${VENDOR}/" -e "s/%REPLACE_VERSION%/${release_version}/" -e "s/%REPLACE_BUILD%/${svn_version}/" -e "s/%REPLACE_TYPE%/${BUILDTYPE}/" < uninstall.sh.in > $APPBIN/${APP_VER_NAME}.uninstall.sh
525 chmod a+x $APPBIN/${APP_VER_NAME}.uninstall.sh
528 if [ -e $BUILD_ROOT/tools/sanity_check/sanityCheck ]; then
529 cp $BUILD_ROOT/tools/sanity_check/sanityCheck $APPBIN
531 echo "!!!ERROR !!! sanityCheck program is missing. packager will exit without being complete"
535 echo "Building tarball ..."
537 rm -f $APPDIR.tar.bz2
538 tar -cjf $APPDIR.tar.bz2 $APPDIR
540 echo "Calculating bundle size"
541 du -sb $APPDIR/ | awk '{print $1}' > $APPDIR.size