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
17 # where harvid and xjadeo binaries are cached
18 if test -z "$CACHEDIR" -o ! -d "$CACHEDIR"; then
33 if [ $# -eq 0 ] ; then
35 echo "ERROR - Please specify build type"
42 while [ $# -gt 0 ] ; do
47 # top level build targets
69 --test) WITH_LADSPA=; STRIP= ; shift ;;
72 # specific build flags
75 --nojack) INTERNAL_JACK= ; shift ;;
76 --noladspa) WITH_LADSPA= ; shift ;;
77 --strip) STRIP=$2 ; shift ; shift ;;
78 --sysdeps) PRINT_SYSDEPS=1; shift ;;
79 --nls) WITH_NLS=1 ; shift ;;
80 --harvid) WITH_HARVID=1 ; shift ;;
83 #catch all for unknown arguments
85 echo "!!! ERROR !!! - Unknown argument $1"
92 if test x$STRIP != xall -a x$STRIP != xnone -a x$STRIP != xsome ; then
93 echo "Unknown strip option \"$STRIP\""
94 echo "Legal values are: all, none, some"
98 . ../define_versions.sh
100 echo "Version is $release_version"
101 if [ "x$commit" != "x" ] ; then
102 info_string="$release_version ($commit) built on `hostname` by `whoami` on `date`"
104 info_string="$release_version built on `hostname` by `whoami` on `date`"
106 echo "Info string is $info_string"
108 # Figure out our CPU type
110 i[3456789]86|x86|i86pc)
111 echo "Architecture is x86"
114 MULTIARCH='i386-linux-gnu'
117 echo "Architecture is x86_64"
120 MULTIARCH='x86_64-linux-gnu'
124 echo "ERROR - Unknown architecture `uname -m`"
130 if [ x$DEBUG = xT ]; then
132 if [ x$STRIP = xall ] ; then
133 echo "A debug build with --strip all makes no sense - STRIP reset to \"some\""
138 # setup directory structure
140 if [ -z "${BUILDTYPE}" ]; then
141 APPDIR=${APPNAME}_${ARCH}-${release_version}
142 APP_VER_NAME=${APPNAME}-${release_version}
144 APPDIR=${APPNAME}_${ARCH}-${release_version}-${BUILDTYPE}
145 APP_VER_NAME=${APPNAME}-${release_version}-${BUILDTYPE}
154 Plugins=$APPLIB/plugins
155 Surfaces=$APPLIB/surfaces
156 Panners=$APPLIB/panners
157 Backends=$APPLIB/backends
159 Modules=$Libraries/modules
160 Loaders=$Libraries/loaders
162 Templates=$Shared/templates
163 ExportFormats=$Shared/export
164 Locale=$Shared/locale
165 MidiMaps=$Shared/midi_maps
166 PatchFiles=$Shared/patchfiles
167 MackieControl=$Shared/mcp
168 VFork=$Libraries/vfork
170 if [ x$PRINT_SYSDEPS != x ] ; then
172 # print system dependencies
175 for file in $APPBIN/* $Libraries/* $Modules/* $Plugins/*.so ; do
176 if ! file $file | grep -qs Mach-O ; then
179 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
184 echo "Removing old $APPDIR tree ..."
187 echo "Building new app directory structure ..."
189 # only bother to make the longest paths
203 mkdir -p $MackieControl
204 mkdir -p $ExportFormats
211 # maybe set variables
212 ENVIRONMENT=environment
216 if test x$MIXBUS != x ; then
217 echo export ARDOUR_MIXBUS=true >> $ENVIRONMENT
219 # current default for MIXBUS version is US keyboard layout without a keypad
221 echo export ARDOUR_KEYBOARD_LAYOUT=us-nokeypad >> $ENVIRONMENT
222 echo export ARDOUR_UI_CONF=ardour3_ui.conf >> $ENVIRONMENT
226 # if we're not going to bundle JACK, make sure we can find
227 # jack in the places where it might be
230 echo export 'PATH=/usr/local/bin:/opt/bin:$PATH' >> $ENVIRONMENT
232 # create startup helper script
234 sed -e "/^%ENV%/r $ENVIRONMENT" -e '/^%ENV%/d' -e 's/%VER%/'"${release_version}"'/' < ardour.sh.in > $APPBIN/ardour3
235 rm $ENVIRONMENT && chmod 775 $APPBIN/ardour3
236 MAIN_EXECUTABLE=ardour-${release_version}
238 echo "Copying ardour executable ...."
239 cp $BUILD_ROOT/gtk2_ardour/$MAIN_EXECUTABLE $APPBIN
240 if test x$STRIP = xall ; then
241 strip $APPBIN/$MAIN_EXECUTABLE
245 # note that at present(feb 2011), the .mo files end up in the source tree which is
246 # not really as it should be.
247 if test x$WITH_NLS != x ; then
248 echo "NLS support ..."
249 echo "I hope you remembered to run scons msgupdate!"
252 for pkg in gtk2_ardour libs/ardour libs/gtkmm2ext ; do
253 files=`find ../../$pkg -name "*.mo"`
256 # the package name is appended with a number so that
257 # it can be parallel installed during a regular install
258 # with older (and newer) versions. it is just the major
259 # number of the release (i.e. leading digits)
262 vsuffix=`echo $release_version | sed 's/^\([0-9][0-9]*\).*/\1/'`
264 if [ -z "$files" ]; then
266 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$pkg"
273 lang=`basename $file | sed 's/\.mo//'`
274 mkdir -p $Locale/$lang/LC_MESSAGES
275 cp $file $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
276 echo copy $file to $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
277 if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
280 LINGUAS="$LINGUAS $lang"
285 GTK_MESSAGES="atk10.mo gdk-pixbuf.mo gtk20-properties.mo gtk20.mo atk10.mo glib20.mo"
286 LOCALEROOT=$GTKSTACK_ROOT/share/locale
288 for l in $LINGUAS ; do
289 echo "Copying GTK i18n files for $l..."
290 for MO in $GTK_MESSAGES ; do
291 if [ -f $LOCALEROOT/$l/LC_MESSAGES/$MO ] ; then
292 cp $LOCALEROOT/$l/LC_MESSAGES/$MO $Locale/$l/LC_MESSAGES
294 # try with just the language spec
295 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
296 if [ -f $LOCALEROOT/$just_lang/LC_MESSAGES/$MO ] ; then
297 cp $LOCALEROOT/$just_lang/LC_MESSAGES/$MO $Locale/$just_lang/LC_MESSAGES
303 echo "Skipping NLS support"
307 # Copy stuff that may be dynamically loaded
310 cp -R $GTKSTACK_ROOT/etc/* $Etc
311 echo "Copying all Pango modules ..."
312 cp -R $GTKSTACK_ROOT/lib/pango/1.8.0/modules/*.so $Modules
313 echo "Copying all GDK Pixbuf loaders ..."
314 cp -R $GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.so $Loaders
316 # Generate a pango module file using the actual Pango that we're going to bundle
320 ModulesPath=$GTKSTACK_ROOT/lib/pango/1.8.0/modules
322 env PANGO_RC_FILE=pangorc $GTKSTACK_ROOT/bin/pango-querymodules | sed "s?$GTKSTACK_ROOT/lib/pango/1.8.0/?@ROOTDIR@/?" > $Etc/pango.modules.in
325 # Ditto for gdk-pixbuf loaders
326 gdk-pixbuf-query-loaders | sed "s?$GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/?@ROOTDIR@/?" > $Etc/gdk-pixbuf.loaders.in
328 # We rely on clearlooks, so include a version from our own build tree
329 # this one is special - we will set GTK_PATH to $Libraries/gtkengines
331 GTK_ENGINE_DIR=$Libraries/gtkengines/engines
332 mkdir -p $GTK_ENGINE_DIR
334 echo "Copying GTK engines ..."
335 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.so $Libraries
336 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.so . )
338 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Libraries
339 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so . )
342 if test x$WITH_LADSPA != x ; then
343 if test x$MIXBUS != x ; then
344 plugdir=mixbus_ladspa
348 echo "Copying `ls $plugdir | wc -l` plugins ..."
349 if [ -d $plugdir ] ; then
350 cp -r $plugdir/* $Plugins
355 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.so* $Surfaces
356 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp.so* $Libraries
359 # got to be careful with names here
360 for x in $BUILD_ROOT/../midi_maps/*.map ; do
365 # got to be careful with names here
366 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
371 # got to be careful with names here
372 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
373 cp "$x" $MackieControl
377 #for f in $BUILD_ROOT/../templates/* ; do
378 # if [ -d "$f" ] ; then
379 # echo Template: $f ; cp -r "$f" $Templates ;
384 # got to be careful with names here
385 for x in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
386 cp "$x" $ExportFormats
390 cp $BUILD_ROOT/libs/panners/*/lib*.so* $Panners
393 for backend in jack alsa dummy wavesaudio ; do
394 cp $BUILD_ROOT/libs/backends/$backend/lib*.so* $Backends
397 # VAMP plugins that we use
398 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.so* $Libraries
400 # Suil modules (new dir 'build-stack')
401 if test -d $GTKSTACK_ROOT/lib/suil-0/ ; then
402 cp $GTKSTACK_ROOT/lib/suil-0/lib* $Libraries
405 # Suil modules (old dir 'build-ardour-stack')
406 if test -d $ARDOURSTACK_ROOT/lib/suil-0/ ; then
407 cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Libraries
410 # VST scanner app (both LXVST as well as WIN-VST, 2in1)
411 # (if build with wine: ardour-vst-scanner is a wrapper
412 # script for ardour-vst-scanner.exe.so, if VST is disabled
413 # neither binary nor script exists)
414 if test -d $BUILD_ROOT/libs/fst ; then
415 cp $BUILD_ROOT/libs/fst/ardour-vst-scanner* $APPLIB || true
419 if test -f $BUILD_ROOT/libs/vfork/ardour-exec-wrapper ; then
420 cp $BUILD_ROOT/libs/vfork/ardour-exec-wrapper $APPLIB
423 # ALSA device reservation tool (if available)
424 if test -f $BUILD_ROOT/libs/ardouralsautil/ardour-request-device; then
425 cp $BUILD_ROOT/libs/ardouralsautil/ardour-request-device $APPLIB/ || true
428 OURLIBDIR=$BUILD_ROOT/libs
429 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/canvas:$OURLIBDIR/libsndfile:$OURLIBDIR/evoral:$OURLIBDIR/evoral/src/libsmf:$OURLIBDIR/audiographer:$OURLIBDIR/timecode:$OURLIBDIR/taglib:$OURLIBDIR/libltc:$OURLIBDIR/qm-dsp:$OURLIBDIR/ardouralsautil
431 echo $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
438 filelist=`find $APPLIB/ -type f`
439 filelist="$APPBIN/$MAIN_EXECUTABLE $filelist"
441 for file in $filelist ; do
442 if ! file $file | grep -qs ELF ; then
446 # speed this up a bit by not checking things multiple times.
447 for i in "${depCheckedList[@]}"; do
448 if [ $i == $file ]; then
452 depCheckedList[$checkIdx]=$file
453 checkIdx=$(($checkIdx + 1))
455 # do not include libjack
456 deps=`LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | awk '{print $3}'`
459 for dep in $deps ; do
460 if test "not" = ${dep}; then
462 echo "!!! ERROR !!! - Missing dependant library for $file."
463 echo "Searched: " $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
465 (LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file)
467 echo "!!! ERROR !!! - See Above"
471 # don't use anything mapped at a specific address
472 if echo $dep | grep -qs '0x' ; then continue; fi
474 if echo $dep | grep -qs "^/lib/" ; then continue; fi
476 if echo $dep | grep -qs libjack ; then continue; fi
478 if echo $dep | grep -qs libasound ; then continue; fi
479 # don't include any X Window libraries
480 if echo $dep | grep -qs libX\. ; then continue; fi
481 if echo $dep | grep -qs libxcb ; then continue; fi
482 if echo $dep | grep -qs libICE\. ; then continue; fi
483 if echo $dep | grep -qs libSM\. ; then continue; fi
485 if echo $dep | grep -qs 'libc\.' ; then continue; fi
486 # don't include libstdc++
487 if echo $dep | grep -qs libstdc++ ; then continue; fi
488 # don't include libdbus
489 if echo $dep | grep -qs libdbus ; then continue; fi
492 if ! test -f $Libraries/$base; then
493 parent=$(basename ${file})
494 if echo $dep | grep -sq '^libs' ; then
495 echo "Copying dependant lib $BUILD_ROOT/$dep (required by ${parent})"
496 cp $BUILD_ROOT/$dep $Libraries
498 echo "Copying dependant lib $dep (required by ${parent})"
502 # reset RPATH so that the runtime linker never looks
503 # in places we don't want it to
505 chrpath -r foo $Libraries/`basename $dep`
506 if echo $dep | grep -sq '^/' ; then
507 # absolute path, candidate for stripping
508 deplibs="$deplibs $base"
514 if test x$missing = xfalse ; then
515 # everything has been found
522 if test x$STRIP = xall ; then
523 echo Stripping all libraries
524 # Must be writable so that we can strip
525 find $APPLIB/ -name "*.so*" | xargs chmod u+w
527 find $APPLIB/ -name "*.so*" | xargs strip
528 elif test x$STRIP = xsome ; then
529 echo Stripping dependent libraries
530 for l in $deplibs ; do
535 find $APPLIB/ -name "*.so*" | xargs chmod a+rx
537 echo "Copying other stuff to $APPDIR ..."
539 # these are all generated by waf
540 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Etc
541 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Etc
542 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc
543 cp ../../system_config $Etc/system_config
544 cp $BUILD_ROOT/gtk2_ardour/clearlooks.rc $Etc
545 cp $BUILD_ROOT/gtk2_ardour/default_ui_config $Etc
547 # these are copied straight from the source tree
549 cp ../../instant.xml $Etc/instant.xml
550 cp ../../gtk2_ardour/step_editing.bindings $Etc
551 cp ../../gtk2_ardour/mixer.bindings $Etc
552 cp -r ../../gtk2_ardour/icons $Shared
553 cp -r ../../gtk2_ardour/pixmaps $Shared
557 # put sooper sekrit ingredients here and they will be copied
560 if [ -d specialSauce ] ; then
561 cp -r specialSauce $Etc
566 cp -R ../../gtk2_ardour/splash.png $Shared
567 cp -R ../../gtk2_ardour/small-splash.png $Shared
568 cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared
570 # install bundled LV2s to <app>/lib/LV2/
571 cp -R $BUILD_ROOT/libs/LV2 $APPLIB/
573 # go through and recursively remove any .svn dirs in the bundle
574 for svndir in `find $APPDIR -name .svn -type d`; do
578 if test x$WITH_HARVID != x ; then
580 HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
581 XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
584 rsync://ardour.org/video-tools/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz \
585 "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz"
588 rsync://ardour.org/video-tools/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz \
589 "$CACHEDIR/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz"
592 --exclude=README --exclude=harvid.1 --strip-components=1 \
593 -f "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz" || exit 1
596 --exclude=README --exclude=xjadeo.1 --strip-components=1 \
597 -f "$CACHEDIR/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz" || exit 1
603 # Add the uninstaller
605 sed -e "s/%REPLACE_PGM%/${APPNAME}/" -e "s/%REPLACE_VENDOR%/${VENDOR}/" -e "s/%REPLACE_VERSION%/${release_version}/" -e "s/%REPLACE_TYPE%/${BUILDTYPE}/" < uninstall.sh.in > $APPBIN/${APP_VER_NAME}.uninstall.sh
606 chmod a+x $APPBIN/${APP_VER_NAME}.uninstall.sh
609 if [ -e $BUILD_ROOT/tools/sanity_check/sanityCheck ]; then
610 cp $BUILD_ROOT/tools/sanity_check/sanityCheck $APPBIN
612 echo "!!!ERROR !!! sanityCheck program is missing. packager will exit without being complete"
616 echo "Building tarball ..."
618 rm -f $APPDIR.tar.bz2
619 tar -cjf $APPDIR.tar.bz2 $APPDIR
621 echo "Calculating bundle size"
622 du -sb $APPDIR/ | awk '{print $1}' > $APPDIR.size