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
27 if [ $# -eq 0 ] ; then
29 echo "ERROR - Please specify build type"
36 while [ $# -gt 0 ] ; do
41 # top level build targets
63 --test) WITH_LADSPA=; STRIP= ; shift ;;
66 # specific build flags
69 --nojack) INTERNAL_JACK= ; shift ;;
70 --noladspa) WITH_LADSPA= ; shift ;;
71 --strip) STRIP=$2 ; shift ; shift ;;
72 --sysdeps) PRINT_SYSDEPS=1; shift ;;
73 --nls) WITH_NLS=1 ; shift ;;
74 --harvid) WITH_HARVID=1 ; shift ;;
77 #catch all for unknown arguments
79 echo "!!! ERROR !!! - Unknown argument $1"
86 if test x$STRIP != xall -a x$STRIP != xnone -a x$STRIP != xsome ; then
87 echo "Unknown strip option \"$STRIP\""
88 echo "Legal values are: all, none, some"
92 . ./define_versions.sh
94 echo "Version is $version / $commit"
95 info_string="$version ($commit) built on `hostname` by `whoami` on `date`"
96 echo "Info string is $info_string"
98 # Figure out our CPU type
100 i[3456789]86|x86|i86pc)
101 echo "Architecture is x86"
104 MULTIARCH='i386-linux-gnu'
107 echo "Architecture is x86_64"
110 MULTIARCH='x86_64-linux-gnu'
114 echo "ERROR - Unknown architecture `uname -m`"
120 if [ x$DEBUG = xT ]; then
122 if [ x$STRIP = xall ] ; then
123 echo "A debug build with --strip all makes no sense - STRIP reset to \"some\""
128 # setup directory structure
130 if [ -z "${BUILDTYPE}" ]; then
131 APPDIR=${APPNAME}_${ARCH}-${version}
132 APP_VER_NAME=${APPNAME}-${version}
134 APPDIR=${APPNAME}_${ARCH}-${version}-${BUILDTYPE}
135 APP_VER_NAME=${APPNAME}-${version}-${BUILDTYPE}
144 Plugins=$APPLIB/plugins
145 Surfaces=$APPLIB/surfaces
146 Panners=$APPLIB/panners
148 Modules=$Libraries/modules
149 Loaders=$Libraries/loaders
151 Templates=$Shared/templates
152 ExportFormats=$Shared/export
153 Locale=$Shared/locale
154 MidiMaps=$Shared/midi_maps
155 PatchFiles=$Shared/patchfiles
156 MackieControl=$Shared/mcp
158 if [ x$PRINT_SYSDEPS != x ] ; then
160 # print system dependencies
163 for file in $APPBIN/* $Libraries/* $Modules/* $Plugins/*.so ; do
164 if ! file $file | grep -qs Mach-O ; then
167 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
172 echo "Removing old $APPDIR tree ..."
175 echo "Building new app directory structure ..."
177 # only bother to make the longest paths
191 mkdir -p $MackieControl
192 mkdir -p $ExportFormats
197 # maybe set variables
198 ENVIRONMENT=environment
202 if test x$MIXBUS != x ; then
203 echo export ARDOUR_MIXBUS=true >> $ENVIRONMENT
205 # current default for MIXBUS version is US keyboard layout without a keypad
207 echo export ARDOUR_KEYBOARD_LAYOUT=us-nokeypad >> $ENVIRONMENT
208 echo export ARDOUR_UI_CONF=ardour3_ui.conf >> $ENVIRONMENT
209 echo export ARDOUR3_UI_RC=ardour3_ui_dark.rc >> $ENVIRONMENT
213 # if we're not going to bundle JACK, make sure we can find
214 # jack in the places where it might be
217 echo export 'PATH=/usr/local/bin:/opt/bin:$PATH' >> $ENVIRONMENT
219 # create startup helper script
221 sed -e "/^%ENV%/r $ENVIRONMENT" -e '/^%ENV%/d' -e 's/%VER%/'"${release_version}"'/' < ardour.sh.in > $APPBIN/ardour3
222 rm $ENVIRONMENT && chmod 775 $APPBIN/ardour3
223 # the 3.0 here is not the same as "release-version" because the latter may include "-betaN" etc.
224 MAIN_EXECUTABLE=ardour-3.0
226 echo "Copying ardour executable ...."
227 cp $BUILD_ROOT/gtk2_ardour/$MAIN_EXECUTABLE $APPBIN
228 if test x$STRIP = xall ; then
229 strip $APPBIN/$MAIN_EXECUTABLE
233 # note that at present(feb 2011), the .mo files end up in the source tree which is
234 # not really as it should be.
235 if test x$WITH_NLS != x ; then
236 echo "NLS support ..."
237 echo "I hope you remembered to run scons msgupdate!"
240 for pkg in gtk2_ardour libs/ardour libs/gtkmm2ext ; do
241 files=`find ../../$pkg -name "*.mo"`
244 # the package name is appended with a number so that
245 # it can be parallel installed during a regular install
246 # with older (and newer) versions. it is just the major
247 # number of the release (i.e. leading digits)
250 vsuffix=`echo $release_version | sed 's/^\([0-9][0-9]*\).*/\1/'`
252 if [ -z "$files" ]; then
254 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$pkg"
261 lang=`basename $file | sed 's/\.mo//'`
262 mkdir -p $Locale/$lang/LC_MESSAGES
263 cp $file $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
264 echo copy $file to $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
265 if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
268 LINGUAS="$LINGUAS $lang"
273 GTK_MESSAGES="atk10.mo gdk-pixbuf.mo gtk20-properties.mo gtk20.mo atk10.mo glib20.mo"
274 LOCALEROOT=$GTKSTACK_ROOT/share/locale
276 for l in $LINGUAS ; do
277 echo "Copying GTK i18n files for $l..."
278 for MO in $GTK_MESSAGES ; do
279 if [ -f $LOCALEROOT/$l/LC_MESSAGES/$MO ] ; then
280 cp $LOCALEROOT/$l/LC_MESSAGES/$MO $Locale/$l/LC_MESSAGES
282 # try with just the language spec
283 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
284 if [ -f $LOCALEROOT/$just_lang/LC_MESSAGES/$MO ] ; then
285 cp $LOCALEROOT/$just_lang/LC_MESSAGES/$MO $Locale/$just_lang/LC_MESSAGES
291 echo "Skipping NLS support"
295 # Copy stuff that may be dynamically loaded
298 cp -R $GTKSTACK_ROOT/etc/* $Etc
299 echo "Copying all Pango modules ..."
300 cp -R $GTKSTACK_ROOT/lib/pango/1.6.0/modules/*.so $Modules
301 echo "Copying all GDK Pixbuf loaders ..."
302 cp -R $GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.so $Loaders
304 # Generate a pango module file using the actual Pango that we're going to bundle
308 ModulesPath=$GTKSTACK_ROOT/lib/pango/1.6.0/modules
310 env PANGO_RC_FILE=pangorc $GTKSTACK_ROOT/bin/pango-querymodules | sed "s?$GTKSTACK_ROOT/lib/pango/1.6.0/?@ROOTDIR@/?" > $Etc/pango.modules.in
313 # Ditto for gdk-pixbuf loaders
314 gdk-pixbuf-query-loaders | sed "s?$GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/?@ROOTDIR@/?" > $Etc/gdk-pixbuf.loaders.in
316 # We rely on clearlooks, so include a version from our own build tree
317 # this one is special - we will set GTK_PATH to $Libraries/gtkengines
319 GTK_ENGINE_DIR=$Libraries/gtkengines/engines
320 mkdir -p $GTK_ENGINE_DIR
322 echo "Copying GTK engines ..."
323 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.so $Libraries
324 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.so . )
326 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Libraries
327 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so . )
330 if test x$WITH_LADSPA != x ; then
331 if test x$MIXBUS != x ; then
332 plugdir=mixbus_ladspa
336 echo "Copying `ls $plugdir | wc -l` plugins ..."
337 if [ -d $plugdir ] ; then
338 cp -r $plugdir/* $Plugins
343 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.so* $Surfaces
344 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp.so* $Libraries
347 # got to be careful with names here
348 for x in $BUILD_ROOT/../midi_maps/*.map ; do
353 # got to be careful with names here
354 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
359 # got to be careful with names here
360 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
361 cp "$x" $MackieControl
365 #for f in $BUILD_ROOT/../templates/* ; do
366 # if [ -d "$f" ] ; then
367 # echo Template: $f ; cp -r "$f" $Templates ;
372 # got to be careful with names here
373 for x in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
374 cp "$x" $ExportFormats
378 cp $BUILD_ROOT/libs/panners/*/lib*.so* $Panners
380 # VAMP plugins that we use
381 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.so* $Libraries
384 cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Libraries
386 OURLIBDIR=$BUILD_ROOT/libs
387 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/libltc:$OURLIBDIR/qm-dsp
389 echo $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
396 filelist=`find $APPLIB/ -type f`
397 filelist="$APPBIN/$MAIN_EXECUTABLE $filelist"
399 for file in $filelist ; do
400 if ! file $file | grep -qs ELF ; then
404 # speed this up a bit by not checking things multiple times.
405 for i in "${depCheckedList[@]}"; do
406 if [ $i == $file ]; then
410 depCheckedList[$checkIdx]=$file
411 checkIdx=$(($checkIdx + 1))
413 # do not include libjack
414 deps=`LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | awk '{print $3}'`
417 for dep in $deps ; do
418 if test "not" = ${dep}; then
420 echo "!!! ERROR !!! - Missing dependant library for $file."
421 echo "Searched: " $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
423 (LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file)
425 echo "!!! ERROR !!! - See Above"
429 # don't use anything mapped at a specific address
430 if echo $dep | grep -qs '0x' ; then continue; fi
432 if echo $dep | grep -qs "^/lib/" ; then continue; fi
434 if echo $dep | grep -qs libjack ; then continue; fi
436 if echo $dep | grep -qs libasound ; then continue; fi
437 # don't include any X Window libraries
438 if echo $dep | grep -qs libX\. ; then continue; fi
439 if echo $dep | grep -qs libxcb ; then continue; fi
440 if echo $dep | grep -qs libICE\. ; then continue; fi
441 if echo $dep | grep -qs libSM\. ; then continue; fi
443 if echo $dep | grep -qs 'libc\.' ; then continue; fi
444 # don't include libstdc++
445 if echo $dep | grep -qs libstdc++ ; then continue; fi
448 if ! test -f $Libraries/$base; then
449 parent=$(basename ${file})
450 if echo $dep | grep -sq '^libs' ; then
451 echo "Copying dependant lib $BUILD_ROOT/$dep (required by ${parent})"
452 cp $BUILD_ROOT/$dep $Libraries
454 echo "Copying dependant lib $dep (required by ${parent})"
458 # reset RPATH so that the runtime linker never looks
459 # in places we don't want it to
461 chrpath -r foo $Libraries/`basename $dep`
462 if echo $dep | grep -sq '^/' ; then
463 # absolute path, candidate for stripping
464 deplibs="$deplibs $base"
470 if test x$missing = xfalse ; then
471 # everything has been found
478 if test x$STRIP = xall ; then
479 echo Stripping all libraries
480 # Must be writable so that we can strip
481 find $APPLIB/ -name "*.so*" | xargs chmod u+w
483 find $APPLIB/ -name "*.so*" | xargs strip
484 elif test x$STRIP = xsome ; then
485 echo Stripping dependent libraries
486 for l in $deplibs ; do
491 find $APPLIB/ -name "*.so*" | xargs chmod a+rx
493 echo "Copying other stuff to $APPDIR ..."
495 # these are all generated by waf
496 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Etc
497 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Etc
498 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc
499 cp ../../ardour_system.rc $Etc/ardour_system.rc
500 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_*.rc $Etc
502 # these are copied straight from the source tree
504 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui_default.conf
505 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui.conf
506 cp ../../instant.xml $Etc/instant.xml
507 cp ../../gtk2_ardour/step_editing.bindings $Etc
508 cp ../../gtk2_ardour/mixer.bindings $Etc
509 cp -r ../../gtk2_ardour/icons $Shared
510 cp -r ../../gtk2_ardour/pixmaps $Shared
514 # put sooper sekrit ingredients here and they will be copied
517 if [ -d specialSauce ] ; then
518 cp -r specialSauce $Etc
523 cp -R ../../gtk2_ardour/splash.png $Shared
524 cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared
526 # go through and recursively remove any .svn dirs in the bundle
527 for svndir in `find $APPDIR -name .svn -type d`; do
531 if test x$WITH_HARVID != x ; then
533 HARVID_VERSION="v0.7.0" # todo make 'latest' symlink on github work somehow.
534 curl -L http://x42.github.com/harvid/releases/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz \
535 | tar -x -z --exclude=README --exclude=harvid.1 --strip-components=1 || exit 1
540 # Add the uninstaller
542 sed -e "s/%REPLACE_PGM%/${APPNAME}/" -e "s/%REPLACE_VENDOR%/${VENDOR}/" -e "s/%REPLACE_VERSION%/${version}/" -e "s/%REPLACE_TYPE%/${BUILDTYPE}/" < uninstall.sh.in > $APPBIN/${APP_VER_NAME}.uninstall.sh
543 chmod a+x $APPBIN/${APP_VER_NAME}.uninstall.sh
546 if [ -e $BUILD_ROOT/tools/sanity_check/sanityCheck ]; then
547 cp $BUILD_ROOT/tools/sanity_check/sanityCheck $APPBIN
549 echo "!!!ERROR !!! sanityCheck program is missing. packager will exit without being complete"
553 echo "Building tarball ..."
555 rm -f $APPDIR.tar.bz2
556 tar -cjf $APPDIR.tar.bz2 $APPDIR
558 echo "Calculating bundle size"
559 du -sb $APPDIR/ | awk '{print $1}' > $APPDIR.size