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 $version / $commit"
101 info_string="$version ($commit) built on `hostname` by `whoami` on `date`"
102 echo "Info string is $info_string"
104 # Figure out our CPU type
106 i[3456789]86|x86|i86pc)
107 echo "Architecture is x86"
110 MULTIARCH='i386-linux-gnu'
113 echo "Architecture is x86_64"
116 MULTIARCH='x86_64-linux-gnu'
120 echo "ERROR - Unknown architecture `uname -m`"
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}-${version}
138 APP_VER_NAME=${APPNAME}-${version}
140 APPDIR=${APPNAME}_${ARCH}-${version}-${BUILDTYPE}
141 APP_VER_NAME=${APPNAME}-${version}-${BUILDTYPE}
150 Plugins=$APPLIB/plugins
151 Surfaces=$APPLIB/surfaces
152 Panners=$APPLIB/panners
153 Backends=$APPLIB/backends
155 Modules=$Libraries/modules
156 Loaders=$Libraries/loaders
158 Templates=$Shared/templates
159 ExportFormats=$Shared/export
160 Locale=$Shared/locale
161 MidiMaps=$Shared/midi_maps
162 PatchFiles=$Shared/patchfiles
163 MackieControl=$Shared/mcp
165 if [ x$PRINT_SYSDEPS != x ] ; then
167 # print system dependencies
170 for file in $APPBIN/* $Libraries/* $Modules/* $Plugins/*.so ; do
171 if ! file $file | grep -qs Mach-O ; then
174 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
179 echo "Removing old $APPDIR tree ..."
182 echo "Building new app directory structure ..."
184 # only bother to make the longest paths
198 mkdir -p $MackieControl
199 mkdir -p $ExportFormats
205 # maybe set variables
206 ENVIRONMENT=environment
210 if test x$MIXBUS != x ; then
211 echo export ARDOUR_MIXBUS=true >> $ENVIRONMENT
213 # current default for MIXBUS version is US keyboard layout without a keypad
215 echo export ARDOUR_KEYBOARD_LAYOUT=us-nokeypad >> $ENVIRONMENT
216 echo export ARDOUR_UI_CONF=ardour3_ui.conf >> $ENVIRONMENT
217 echo export ARDOUR3_UI_RC=ardour3_ui_dark.rc >> $ENVIRONMENT
221 # if we're not going to bundle JACK, make sure we can find
222 # jack in the places where it might be
225 echo export 'PATH=/usr/local/bin:/opt/bin:$PATH' >> $ENVIRONMENT
227 # create startup helper script
229 sed -e "/^%ENV%/r $ENVIRONMENT" -e '/^%ENV%/d' -e 's/%VER%/'"${release_version}"'/' < ardour.sh.in > $APPBIN/ardour3
230 rm $ENVIRONMENT && chmod 775 $APPBIN/ardour3
231 MAIN_EXECUTABLE=ardour-${release_version}
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 pkg in gtk2_ardour libs/ardour libs/gtkmm2ext ; do
248 files=`find ../../$pkg -name "*.mo"`
251 # the package name is appended with a number so that
252 # it can be parallel installed during a regular install
253 # with older (and newer) versions. it is just the major
254 # number of the release (i.e. leading digits)
257 vsuffix=`echo $release_version | sed 's/^\([0-9][0-9]*\).*/\1/'`
259 if [ -z "$files" ]; then
261 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$pkg"
268 lang=`basename $file | sed 's/\.mo//'`
269 mkdir -p $Locale/$lang/LC_MESSAGES
270 cp $file $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
271 echo copy $file to $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
272 if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
275 LINGUAS="$LINGUAS $lang"
280 GTK_MESSAGES="atk10.mo gdk-pixbuf.mo gtk20-properties.mo gtk20.mo atk10.mo glib20.mo"
281 LOCALEROOT=$GTKSTACK_ROOT/share/locale
283 for l in $LINGUAS ; do
284 echo "Copying GTK i18n files for $l..."
285 for MO in $GTK_MESSAGES ; do
286 if [ -f $LOCALEROOT/$l/LC_MESSAGES/$MO ] ; then
287 cp $LOCALEROOT/$l/LC_MESSAGES/$MO $Locale/$l/LC_MESSAGES
289 # try with just the language spec
290 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
291 if [ -f $LOCALEROOT/$just_lang/LC_MESSAGES/$MO ] ; then
292 cp $LOCALEROOT/$just_lang/LC_MESSAGES/$MO $Locale/$just_lang/LC_MESSAGES
298 echo "Skipping NLS support"
302 # Copy stuff that may be dynamically loaded
305 cp -R $GTKSTACK_ROOT/etc/* $Etc
306 echo "Copying all Pango modules ..."
307 cp -R $GTKSTACK_ROOT/lib/pango/1.8.0/modules/*.so $Modules
308 echo "Copying all GDK Pixbuf loaders ..."
309 cp -R $GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.so $Loaders
311 # Generate a pango module file using the actual Pango that we're going to bundle
315 ModulesPath=$GTKSTACK_ROOT/lib/pango/1.8.0/modules
317 env PANGO_RC_FILE=pangorc $GTKSTACK_ROOT/bin/pango-querymodules | sed "s?$GTKSTACK_ROOT/lib/pango/1.8.0/?@ROOTDIR@/?" > $Etc/pango.modules.in
320 # Ditto for gdk-pixbuf loaders
321 gdk-pixbuf-query-loaders | sed "s?$GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/?@ROOTDIR@/?" > $Etc/gdk-pixbuf.loaders.in
323 # We rely on clearlooks, so include a version from our own build tree
324 # this one is special - we will set GTK_PATH to $Libraries/gtkengines
326 GTK_ENGINE_DIR=$Libraries/gtkengines/engines
327 mkdir -p $GTK_ENGINE_DIR
329 echo "Copying GTK engines ..."
330 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.so $Libraries
331 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.so . )
333 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Libraries
334 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so . )
337 if test x$WITH_LADSPA != x ; then
338 if test x$MIXBUS != x ; then
339 plugdir=mixbus_ladspa
343 echo "Copying `ls $plugdir | wc -l` plugins ..."
344 if [ -d $plugdir ] ; then
345 cp -r $plugdir/* $Plugins
350 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.so* $Surfaces
351 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp.so* $Libraries
354 # got to be careful with names here
355 for x in $BUILD_ROOT/../midi_maps/*.map ; do
360 # got to be careful with names here
361 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
366 # got to be careful with names here
367 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
368 cp "$x" $MackieControl
372 #for f in $BUILD_ROOT/../templates/* ; do
373 # if [ -d "$f" ] ; then
374 # echo Template: $f ; cp -r "$f" $Templates ;
379 # got to be careful with names here
380 for x in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
381 cp "$x" $ExportFormats
385 cp $BUILD_ROOT/libs/panners/*/lib*.so* $Panners
388 cp $BUILD_ROOT/libs/backends/*/lib*.so* $Backends
390 # VAMP plugins that we use
391 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.so* $Libraries
394 cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Libraries
396 OURLIBDIR=$BUILD_ROOT/libs
397 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
399 echo $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
406 filelist=`find $APPLIB/ -type f`
407 filelist="$APPBIN/$MAIN_EXECUTABLE $filelist"
409 for file in $filelist ; do
410 if ! file $file | grep -qs ELF ; then
414 # speed this up a bit by not checking things multiple times.
415 for i in "${depCheckedList[@]}"; do
416 if [ $i == $file ]; then
420 depCheckedList[$checkIdx]=$file
421 checkIdx=$(($checkIdx + 1))
423 # do not include libjack
424 deps=`LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | awk '{print $3}'`
427 for dep in $deps ; do
428 if test "not" = ${dep}; then
430 echo "!!! ERROR !!! - Missing dependant library for $file."
431 echo "Searched: " $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
433 (LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file)
435 echo "!!! ERROR !!! - See Above"
439 # don't use anything mapped at a specific address
440 if echo $dep | grep -qs '0x' ; then continue; fi
442 if echo $dep | grep -qs "^/lib/" ; then continue; fi
444 if echo $dep | grep -qs libjack ; then continue; fi
446 if echo $dep | grep -qs libasound ; then continue; fi
447 # don't include any X Window libraries
448 if echo $dep | grep -qs libX\. ; then continue; fi
449 if echo $dep | grep -qs libxcb ; then continue; fi
450 if echo $dep | grep -qs libICE\. ; then continue; fi
451 if echo $dep | grep -qs libSM\. ; then continue; fi
453 if echo $dep | grep -qs 'libc\.' ; then continue; fi
454 # don't include libstdc++
455 if echo $dep | grep -qs libstdc++ ; then continue; fi
458 if ! test -f $Libraries/$base; then
459 parent=$(basename ${file})
460 if echo $dep | grep -sq '^libs' ; then
461 echo "Copying dependant lib $BUILD_ROOT/$dep (required by ${parent})"
462 cp $BUILD_ROOT/$dep $Libraries
464 echo "Copying dependant lib $dep (required by ${parent})"
468 # reset RPATH so that the runtime linker never looks
469 # in places we don't want it to
471 chrpath -r foo $Libraries/`basename $dep`
472 if echo $dep | grep -sq '^/' ; then
473 # absolute path, candidate for stripping
474 deplibs="$deplibs $base"
480 if test x$missing = xfalse ; then
481 # everything has been found
488 if test x$STRIP = xall ; then
489 echo Stripping all libraries
490 # Must be writable so that we can strip
491 find $APPLIB/ -name "*.so*" | xargs chmod u+w
493 find $APPLIB/ -name "*.so*" | xargs strip
494 elif test x$STRIP = xsome ; then
495 echo Stripping dependent libraries
496 for l in $deplibs ; do
501 find $APPLIB/ -name "*.so*" | xargs chmod a+rx
503 echo "Copying other stuff to $APPDIR ..."
505 # these are all generated by waf
506 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Etc
507 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Etc
508 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc
509 cp ../../ardour_system.rc $Etc/ardour_system.rc
510 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_*.rc $Etc
512 # these are copied straight from the source tree
514 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui_default.conf
515 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui.conf
516 cp ../../instant.xml $Etc/instant.xml
517 cp ../../gtk2_ardour/step_editing.bindings $Etc
518 cp ../../gtk2_ardour/mixer.bindings $Etc
519 cp -r ../../gtk2_ardour/icons $Shared
520 cp -r ../../gtk2_ardour/pixmaps $Shared
524 # put sooper sekrit ingredients here and they will be copied
527 if [ -d specialSauce ] ; then
528 cp -r specialSauce $Etc
533 cp -R ../../gtk2_ardour/splash.png $Shared
534 cp -R ../../gtk2_ardour/small-splash.png $Shared
535 cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared
537 # install bundled LV2s to <app>/lib/LV2/
538 cp -R $BUILD_ROOT/libs/LV2 $APPLIB/
540 # go through and recursively remove any .svn dirs in the bundle
541 for svndir in `find $APPDIR -name .svn -type d`; do
545 if test x$WITH_HARVID != x ; then
547 HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
548 XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
551 rsync://ardour.org/video-tools/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz \
552 "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz"
555 rsync://ardour.org/video-tools/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz \
556 "$CACHEDIR/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz"
559 --exclude=README --exclude=harvid.1 --strip-components=1 \
560 -f "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz" || exit 1
563 --exclude=README --exclude=xjadeo.1 --strip-components=1 \
564 -f "$CACHEDIR/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz" || exit 1
570 # Add the uninstaller
572 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
573 chmod a+x $APPBIN/${APP_VER_NAME}.uninstall.sh
576 if [ -e $BUILD_ROOT/tools/sanity_check/sanityCheck ]; then
577 cp $BUILD_ROOT/tools/sanity_check/sanityCheck $APPBIN
579 echo "!!!ERROR !!! sanityCheck program is missing. packager will exit without being complete"
583 echo "Building tarball ..."
585 rm -f $APPDIR.tar.bz2
586 tar -cjf $APPDIR.tar.bz2 $APPDIR
588 echo "Calculating bundle size"
589 du -sb $APPDIR/ | awk '{print $1}' > $APPDIR.size