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
195 mkdir -p $Shared/templates
198 # maybe set variables
199 ENVIRONMENT=environment
203 if test x$MIXBUS != x ; then
204 echo export ARDOUR_MIXBUS=true >> $ENVIRONMENT
206 # current default for MIXBUS version is US keyboard layout without a keypad
208 echo export ARDOUR_KEYBOARD_LAYOUT=us-nokeypad >> $ENVIRONMENT
209 echo export ARDOUR_UI_CONF=ardour3_ui.conf >> $ENVIRONMENT
210 echo export ARDOUR3_UI_RC=ardour3_ui_dark.rc >> $ENVIRONMENT
214 # if we're not going to bundle JACK, make sure we can find
215 # jack in the places where it might be
218 echo export 'PATH=/usr/local/bin:/opt/bin:$PATH' >> $ENVIRONMENT
220 # create startup helper script
222 sed -e "/^%ENV%/r $ENVIRONMENT" -e '/^%ENV%/d' -e 's/%VER%/'"${release_version}"'/' < ardour.sh.in > $APPBIN/ardour3
223 rm $ENVIRONMENT && chmod 775 $APPBIN/ardour3
224 # the 3.0 here is not the same as "release-version" because the latter may include "-betaN" etc.
225 MAIN_EXECUTABLE=ardour-3.0
227 echo "Copying ardour executable ...."
228 cp $BUILD_ROOT/gtk2_ardour/$MAIN_EXECUTABLE $APPBIN
229 if test x$STRIP = xall ; then
230 strip $APPBIN/$MAIN_EXECUTABLE
234 # note that at present(feb 2011), the .mo files end up in the source tree which is
235 # not really as it should be.
236 if test x$WITH_NLS != x ; then
237 echo "NLS support ..."
238 echo "I hope you remembered to run scons msgupdate!"
241 for pkg in gtk2_ardour libs/ardour libs/gtkmm2ext ; do
242 files=`find ../../$pkg -name "*.mo"`
245 # the package name is appended with a number so that
246 # it can be parallel installed during a regular install
247 # with older (and newer) versions. it is just the major
248 # number of the release (i.e. leading digits)
251 vsuffix=`echo $release_version | sed 's/^\([0-9][0-9]*\).*/\1/'`
253 if [ -z "$files" ]; then
255 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$pkg"
262 lang=`basename $file | sed 's/\.mo//'`
263 mkdir -p $Locale/$lang/LC_MESSAGES
264 cp $file $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
265 echo copy $file to $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
266 if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
269 LINGUAS="$LINGUAS $lang"
274 GTK_MESSAGES="atk10.mo gdk-pixbuf.mo gtk20-properties.mo gtk20.mo atk10.mo glib20.mo"
275 LOCALEROOT=$GTKSTACK_ROOT/share/locale
277 for l in $LINGUAS ; do
278 echo "Copying GTK i18n files for $l..."
279 for MO in $GTK_MESSAGES ; do
280 if [ -f $LOCALEROOT/$l/LC_MESSAGES/$MO ] ; then
281 cp $LOCALEROOT/$l/LC_MESSAGES/$MO $Locale/$l/LC_MESSAGES
283 # try with just the language spec
284 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
285 if [ -f $LOCALEROOT/$just_lang/LC_MESSAGES/$MO ] ; then
286 cp $LOCALEROOT/$just_lang/LC_MESSAGES/$MO $Locale/$just_lang/LC_MESSAGES
292 echo "Skipping NLS support"
296 # Copy stuff that may be dynamically loaded
299 cp -R $GTKSTACK_ROOT/etc/* $Etc
300 echo "Copying all Pango modules ..."
301 cp -R $GTKSTACK_ROOT/lib/pango/1.6.0/modules/*.so $Modules
302 echo "Copying all GDK Pixbuf loaders ..."
303 cp -R $GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.so $Loaders
305 # Generate a pango module file using the actual Pango that we're going to bundle
309 ModulesPath=$GTKSTACK_ROOT/lib/pango/1.6.0/modules
311 env PANGO_RC_FILE=pangorc $GTKSTACK_ROOT/bin/pango-querymodules | sed "s?$GTKSTACK_ROOT/lib/pango/1.6.0/?@ROOTDIR@/?" > $Etc/pango.modules.in
314 # Ditto for gdk-pixbuf loaders
315 gdk-pixbuf-query-loaders | sed "s?$GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/?@ROOTDIR@/?" > $Etc/gdk-pixbuf.loaders.in
317 # We rely on clearlooks, so include a version from our own build tree
318 # this one is special - we will set GTK_PATH to $Libraries/gtkengines
320 GTK_ENGINE_DIR=$Libraries/gtkengines/engines
321 mkdir -p $GTK_ENGINE_DIR
323 echo "Copying GTK engines ..."
324 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.so $Libraries
325 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.so . )
327 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Libraries
328 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so . )
331 if test x$WITH_LADSPA != x ; then
332 if test x$MIXBUS != x ; then
333 plugdir=mixbus_ladspa
337 echo "Copying `ls $plugdir | wc -l` plugins ..."
338 if [ -d $plugdir ] ; then
339 cp -r $plugdir/* $Plugins
344 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.so* $Surfaces
345 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp.so* $Libraries
348 # got to be careful with names here
349 for x in $BUILD_ROOT/../midi_maps/*.map ; do
354 # got to be careful with names here
355 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
360 # got to be careful with names here
361 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
362 cp "$x" $MackieControl
366 for f in $BUILD_ROOT/../templates/* ; do
367 if [ -d "$f" ] ; then
368 echo Template: $f ; cp -r "$f" $Templates ;
373 # got to be careful with names here
374 for x in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
375 cp "$x" $ExportFormats
379 cp $BUILD_ROOT/libs/panners/*/lib*.so* $Panners
381 # VAMP plugins that we use
382 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.so* $Libraries
385 cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Libraries
387 OURLIBDIR=$BUILD_ROOT/libs
388 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
390 echo $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
397 filelist=`find $APPLIB/ -type f`
398 filelist="$APPBIN/$MAIN_EXECUTABLE $filelist"
400 for file in $filelist ; do
401 if ! file $file | grep -qs ELF ; then
405 # speed this up a bit by not checking things multiple times.
406 for i in "${depCheckedList[@]}"; do
407 if [ $i == $file ]; then
411 depCheckedList[$checkIdx]=$file
412 checkIdx=$(($checkIdx + 1))
414 # do not include libjack
415 deps=`LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | awk '{print $3}'`
418 for dep in $deps ; do
419 if test "not" = ${dep}; then
421 echo "!!! ERROR !!! - Missing dependant library for $file."
422 echo "Searched: " $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
424 (LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file)
426 echo "!!! ERROR !!! - See Above"
430 # don't use anything mapped at a specific address
431 if echo $dep | grep -qs '0x' ; then continue; fi
433 if echo $dep | grep -qs "^/lib/" ; then continue; fi
435 if echo $dep | grep -qs libjack ; then continue; fi
437 if echo $dep | grep -qs libasound ; then continue; fi
438 # don't include any X Window libraries
439 if echo $dep | grep -qs libX\. ; then continue; fi
440 if echo $dep | grep -qs libxcb ; then continue; fi
441 if echo $dep | grep -qs libICE\. ; then continue; fi
442 if echo $dep | grep -qs libSM\. ; then continue; fi
444 if echo $dep | grep -qs 'libc\.' ; then continue; fi
445 # don't include libstdc++
446 if echo $dep | grep -qs libstdc++ ; then continue; fi
449 if ! test -f $Libraries/$base; then
450 parent=$(basename ${file})
451 if echo $dep | grep -sq '^libs' ; then
452 echo "Copying dependant lib $BUILD_ROOT/$dep (required by ${parent})"
453 cp $BUILD_ROOT/$dep $Libraries
455 echo "Copying dependant lib $dep (required by ${parent})"
459 # reset RPATH so that the runtime linker never looks
460 # in places we don't want it to
462 chrpath -r foo $Libraries/`basename $dep`
463 if echo $dep | grep -sq '^/' ; then
464 # absolute path, candidate for stripping
465 deplibs="$deplibs $base"
471 if test x$missing = xfalse ; then
472 # everything has been found
479 if test x$STRIP = xall ; then
480 echo Stripping all libraries
481 # Must be writable so that we can strip
482 find $APPLIB/ -name "*.so*" | xargs chmod u+w
484 find $APPLIB/ -name "*.so*" | xargs strip
485 elif test x$STRIP = xsome ; then
486 echo Stripping dependent libraries
487 for l in $deplibs ; do
492 find $APPLIB/ -name "*.so*" | xargs chmod a+rx
494 echo "Copying other stuff to $APPDIR ..."
496 # these are all generated by waf
497 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Etc
498 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Etc
499 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc
500 cp ../../ardour_system.rc $Etc/ardour_system.rc
501 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_*.rc $Etc
503 # these are copied straight from the source tree
505 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui_default.conf
506 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui.conf
507 cp ../../instant.xml $Etc/instant.xml
508 cp ../../gtk2_ardour/step_editing.bindings $Etc
509 cp ../../gtk2_ardour/mixer.bindings $Etc
510 cp -r ../../gtk2_ardour/icons $Shared
511 cp -r ../../gtk2_ardour/pixmaps $Shared
515 # put sooper sekrit ingredients here and they will be copied
518 if [ -d specialSauce ] ; then
519 cp -r specialSauce $Etc
524 cp -R ../../gtk2_ardour/splash.png $Shared
525 cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared
527 # go through and recursively remove any .svn dirs in the bundle
528 for svndir in `find $APPDIR -name .svn -type d`; do
532 if test x$WITH_HARVID != x ; then
534 HARVID_VERSION="v0.7.0" # todo make 'latest' symlink on github work somehow.
535 curl http://x42.github.com/harvid/releases/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz \
536 | tar -x -z --exclude=README --exclude=harvid.1 --strip-components=1 || exit 1
541 # Add the uninstaller
543 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
544 chmod a+x $APPBIN/${APP_VER_NAME}.uninstall.sh
547 if [ -e $BUILD_ROOT/tools/sanity_check/sanityCheck ]; then
548 cp $BUILD_ROOT/tools/sanity_check/sanityCheck $APPBIN
550 echo "!!!ERROR !!! sanityCheck program is missing. packager will exit without being complete"
554 echo "Building tarball ..."
556 rm -f $APPDIR.tar.bz2
557 tar -cjf $APPDIR.tar.bz2 $APPDIR
559 echo "Calculating bundle size"
560 du -sb $APPDIR/ | awk '{print $1}' > $APPDIR.size