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
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
203 # maybe set variables
204 ENVIRONMENT=environment
208 if test x$MIXBUS != x ; then
209 echo export ARDOUR_MIXBUS=true >> $ENVIRONMENT
211 # current default for MIXBUS version is US keyboard layout without a keypad
213 echo export ARDOUR_KEYBOARD_LAYOUT=us-nokeypad >> $ENVIRONMENT
214 echo export ARDOUR_UI_CONF=ardour3_ui.conf >> $ENVIRONMENT
215 echo export ARDOUR3_UI_RC=ardour3_ui_dark.rc >> $ENVIRONMENT
219 # if we're not going to bundle JACK, make sure we can find
220 # jack in the places where it might be
223 echo export 'PATH=/usr/local/bin:/opt/bin:$PATH' >> $ENVIRONMENT
225 # create startup helper script
227 sed -e "/^%ENV%/r $ENVIRONMENT" -e '/^%ENV%/d' -e 's/%VER%/'"${release_version}"'/' < ardour.sh.in > $APPBIN/ardour3
228 rm $ENVIRONMENT && chmod 775 $APPBIN/ardour3
229 MAIN_EXECUTABLE=ardour-${release_version}
231 echo "Copying ardour executable ...."
232 cp $BUILD_ROOT/gtk2_ardour/$MAIN_EXECUTABLE $APPBIN
233 if test x$STRIP = xall ; then
234 strip $APPBIN/$MAIN_EXECUTABLE
238 # note that at present(feb 2011), the .mo files end up in the source tree which is
239 # not really as it should be.
240 if test x$WITH_NLS != x ; then
241 echo "NLS support ..."
242 echo "I hope you remembered to run scons msgupdate!"
245 for pkg in gtk2_ardour libs/ardour libs/gtkmm2ext ; do
246 files=`find ../../$pkg -name "*.mo"`
249 # the package name is appended with a number so that
250 # it can be parallel installed during a regular install
251 # with older (and newer) versions. it is just the major
252 # number of the release (i.e. leading digits)
255 vsuffix=`echo $release_version | sed 's/^\([0-9][0-9]*\).*/\1/'`
257 if [ -z "$files" ]; then
259 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$pkg"
266 lang=`basename $file | sed 's/\.mo//'`
267 mkdir -p $Locale/$lang/LC_MESSAGES
268 cp $file $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
269 echo copy $file to $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
270 if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
273 LINGUAS="$LINGUAS $lang"
278 GTK_MESSAGES="atk10.mo gdk-pixbuf.mo gtk20-properties.mo gtk20.mo atk10.mo glib20.mo"
279 LOCALEROOT=$GTKSTACK_ROOT/share/locale
281 for l in $LINGUAS ; do
282 echo "Copying GTK i18n files for $l..."
283 for MO in $GTK_MESSAGES ; do
284 if [ -f $LOCALEROOT/$l/LC_MESSAGES/$MO ] ; then
285 cp $LOCALEROOT/$l/LC_MESSAGES/$MO $Locale/$l/LC_MESSAGES
287 # try with just the language spec
288 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
289 if [ -f $LOCALEROOT/$just_lang/LC_MESSAGES/$MO ] ; then
290 cp $LOCALEROOT/$just_lang/LC_MESSAGES/$MO $Locale/$just_lang/LC_MESSAGES
296 echo "Skipping NLS support"
300 # Copy stuff that may be dynamically loaded
303 cp -R $GTKSTACK_ROOT/etc/* $Etc
304 echo "Copying all Pango modules ..."
305 cp -R $GTKSTACK_ROOT/lib/pango/1.6.0/modules/*.so $Modules
306 echo "Copying all GDK Pixbuf loaders ..."
307 cp -R $GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.so $Loaders
309 # Generate a pango module file using the actual Pango that we're going to bundle
313 ModulesPath=$GTKSTACK_ROOT/lib/pango/1.6.0/modules
315 env PANGO_RC_FILE=pangorc $GTKSTACK_ROOT/bin/pango-querymodules | sed "s?$GTKSTACK_ROOT/lib/pango/1.6.0/?@ROOTDIR@/?" > $Etc/pango.modules.in
318 # Ditto for gdk-pixbuf loaders
319 gdk-pixbuf-query-loaders | sed "s?$GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/?@ROOTDIR@/?" > $Etc/gdk-pixbuf.loaders.in
321 # We rely on clearlooks, so include a version from our own build tree
322 # this one is special - we will set GTK_PATH to $Libraries/gtkengines
324 GTK_ENGINE_DIR=$Libraries/gtkengines/engines
325 mkdir -p $GTK_ENGINE_DIR
327 echo "Copying GTK engines ..."
328 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.so $Libraries
329 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.so . )
331 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Libraries
332 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so . )
335 if test x$WITH_LADSPA != x ; then
336 if test x$MIXBUS != x ; then
337 plugdir=mixbus_ladspa
341 echo "Copying `ls $plugdir | wc -l` plugins ..."
342 if [ -d $plugdir ] ; then
343 cp -r $plugdir/* $Plugins
348 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.so* $Surfaces
349 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp.so* $Libraries
352 # got to be careful with names here
353 for x in $BUILD_ROOT/../midi_maps/*.map ; do
358 # got to be careful with names here
359 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
364 # got to be careful with names here
365 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
366 cp "$x" $MackieControl
370 #for f in $BUILD_ROOT/../templates/* ; do
371 # if [ -d "$f" ] ; then
372 # echo Template: $f ; cp -r "$f" $Templates ;
377 # got to be careful with names here
378 for x in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
379 cp "$x" $ExportFormats
383 cp $BUILD_ROOT/libs/panners/*/lib*.so* $Panners
385 # VAMP plugins that we use
386 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.so* $Libraries
389 cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Libraries
391 OURLIBDIR=$BUILD_ROOT/libs
392 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
394 echo $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
401 filelist=`find $APPLIB/ -type f`
402 filelist="$APPBIN/$MAIN_EXECUTABLE $filelist"
404 for file in $filelist ; do
405 if ! file $file | grep -qs ELF ; then
409 # speed this up a bit by not checking things multiple times.
410 for i in "${depCheckedList[@]}"; do
411 if [ $i == $file ]; then
415 depCheckedList[$checkIdx]=$file
416 checkIdx=$(($checkIdx + 1))
418 # do not include libjack
419 deps=`LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | awk '{print $3}'`
422 for dep in $deps ; do
423 if test "not" = ${dep}; then
425 echo "!!! ERROR !!! - Missing dependant library for $file."
426 echo "Searched: " $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
428 (LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file)
430 echo "!!! ERROR !!! - See Above"
434 # don't use anything mapped at a specific address
435 if echo $dep | grep -qs '0x' ; then continue; fi
437 if echo $dep | grep -qs "^/lib/" ; then continue; fi
439 if echo $dep | grep -qs libjack ; then continue; fi
441 if echo $dep | grep -qs libasound ; then continue; fi
442 # don't include any X Window libraries
443 if echo $dep | grep -qs libX\. ; then continue; fi
444 if echo $dep | grep -qs libxcb ; then continue; fi
445 if echo $dep | grep -qs libICE\. ; then continue; fi
446 if echo $dep | grep -qs libSM\. ; then continue; fi
448 if echo $dep | grep -qs 'libc\.' ; then continue; fi
449 # don't include libstdc++
450 if echo $dep | grep -qs libstdc++ ; then continue; fi
453 if ! test -f $Libraries/$base; then
454 parent=$(basename ${file})
455 if echo $dep | grep -sq '^libs' ; then
456 echo "Copying dependant lib $BUILD_ROOT/$dep (required by ${parent})"
457 cp $BUILD_ROOT/$dep $Libraries
459 echo "Copying dependant lib $dep (required by ${parent})"
463 # reset RPATH so that the runtime linker never looks
464 # in places we don't want it to
466 chrpath -r foo $Libraries/`basename $dep`
467 if echo $dep | grep -sq '^/' ; then
468 # absolute path, candidate for stripping
469 deplibs="$deplibs $base"
475 if test x$missing = xfalse ; then
476 # everything has been found
483 if test x$STRIP = xall ; then
484 echo Stripping all libraries
485 # Must be writable so that we can strip
486 find $APPLIB/ -name "*.so*" | xargs chmod u+w
488 find $APPLIB/ -name "*.so*" | xargs strip
489 elif test x$STRIP = xsome ; then
490 echo Stripping dependent libraries
491 for l in $deplibs ; do
496 find $APPLIB/ -name "*.so*" | xargs chmod a+rx
498 echo "Copying other stuff to $APPDIR ..."
500 # these are all generated by waf
501 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Etc
502 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Etc
503 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc
504 cp ../../ardour_system.rc $Etc/ardour_system.rc
505 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_*.rc $Etc
507 # these are copied straight from the source tree
509 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui_default.conf
510 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui.conf
511 cp ../../instant.xml $Etc/instant.xml
512 cp ../../gtk2_ardour/step_editing.bindings $Etc
513 cp ../../gtk2_ardour/mixer.bindings $Etc
514 cp -r ../../gtk2_ardour/icons $Shared
515 cp -r ../../gtk2_ardour/pixmaps $Shared
519 # put sooper sekrit ingredients here and they will be copied
522 if [ -d specialSauce ] ; then
523 cp -r specialSauce $Etc
528 cp -R ../../gtk2_ardour/splash.png $Shared
529 cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared
531 # go through and recursively remove any .svn dirs in the bundle
532 for svndir in `find $APPDIR -name .svn -type d`; do
536 if test x$WITH_HARVID != x ; then
538 HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
539 XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
542 rsync://ardour.org/video-tools/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz \
543 "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz"
546 rsync://ardour.org/video-tools/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz \
547 "$CACHEDIR/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz"
550 --exclude=README --exclude=harvid.1 --strip-components=1 \
551 -f "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz" || exit 1
554 --exclude=README --exclude=xjadeo.1 --strip-components=1 \
555 -f "$CACHEDIR/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz" || exit 1
561 # Add the uninstaller
563 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
564 chmod a+x $APPBIN/${APP_VER_NAME}.uninstall.sh
567 if [ -e $BUILD_ROOT/tools/sanity_check/sanityCheck ]; then
568 cp $BUILD_ROOT/tools/sanity_check/sanityCheck $APPBIN
570 echo "!!!ERROR !!! sanityCheck program is missing. packager will exit without being complete"
574 echo "Building tarball ..."
576 rm -f $APPDIR.tar.bz2
577 tar -cjf $APPDIR.tar.bz2 $APPDIR
579 echo "Calculating bundle size"
580 du -sb $APPDIR/ | awk '{print $1}' > $APPDIR.size