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
169 if [ x$PRINT_SYSDEPS != x ] ; then
171 # print system dependencies
174 for file in $APPBIN/* $Libraries/* $Modules/* $Plugins/*.so ; do
175 if ! file $file | grep -qs Mach-O ; then
178 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
183 echo "Removing old $APPDIR tree ..."
186 echo "Building new app directory structure ..."
188 # only bother to make the longest paths
202 mkdir -p $MackieControl
203 mkdir -p $ExportFormats
209 # maybe set variables
210 ENVIRONMENT=environment
214 if test x$MIXBUS != x ; then
215 echo export ARDOUR_MIXBUS=true >> $ENVIRONMENT
217 # current default for MIXBUS version is US keyboard layout without a keypad
219 echo export ARDOUR_KEYBOARD_LAYOUT=us-nokeypad >> $ENVIRONMENT
220 echo export ARDOUR_UI_CONF=ardour3_ui.conf >> $ENVIRONMENT
221 echo export ARDOUR3_UI_RC=ardour3_ui_dark.rc >> $ENVIRONMENT
225 # if we're not going to bundle JACK, make sure we can find
226 # jack in the places where it might be
229 echo export 'PATH=/usr/local/bin:/opt/bin:$PATH' >> $ENVIRONMENT
231 # create startup helper script
233 sed -e "/^%ENV%/r $ENVIRONMENT" -e '/^%ENV%/d' -e 's/%VER%/'"${release_version}"'/' < ardour.sh.in > $APPBIN/ardour3
234 rm $ENVIRONMENT && chmod 775 $APPBIN/ardour3
235 MAIN_EXECUTABLE=ardour-${release_version}
237 echo "Copying ardour executable ...."
238 cp $BUILD_ROOT/gtk2_ardour/$MAIN_EXECUTABLE $APPBIN
239 if test x$STRIP = xall ; then
240 strip $APPBIN/$MAIN_EXECUTABLE
244 # note that at present(feb 2011), the .mo files end up in the source tree which is
245 # not really as it should be.
246 if test x$WITH_NLS != x ; then
247 echo "NLS support ..."
248 echo "I hope you remembered to run scons msgupdate!"
251 for pkg in gtk2_ardour libs/ardour libs/gtkmm2ext ; do
252 files=`find ../../$pkg -name "*.mo"`
255 # the package name is appended with a number so that
256 # it can be parallel installed during a regular install
257 # with older (and newer) versions. it is just the major
258 # number of the release (i.e. leading digits)
261 vsuffix=`echo $release_version | sed 's/^\([0-9][0-9]*\).*/\1/'`
263 if [ -z "$files" ]; then
265 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$pkg"
272 lang=`basename $file | sed 's/\.mo//'`
273 mkdir -p $Locale/$lang/LC_MESSAGES
274 cp $file $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
275 echo copy $file to $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
276 if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
279 LINGUAS="$LINGUAS $lang"
284 GTK_MESSAGES="atk10.mo gdk-pixbuf.mo gtk20-properties.mo gtk20.mo atk10.mo glib20.mo"
285 LOCALEROOT=$GTKSTACK_ROOT/share/locale
287 for l in $LINGUAS ; do
288 echo "Copying GTK i18n files for $l..."
289 for MO in $GTK_MESSAGES ; do
290 if [ -f $LOCALEROOT/$l/LC_MESSAGES/$MO ] ; then
291 cp $LOCALEROOT/$l/LC_MESSAGES/$MO $Locale/$l/LC_MESSAGES
293 # try with just the language spec
294 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
295 if [ -f $LOCALEROOT/$just_lang/LC_MESSAGES/$MO ] ; then
296 cp $LOCALEROOT/$just_lang/LC_MESSAGES/$MO $Locale/$just_lang/LC_MESSAGES
302 echo "Skipping NLS support"
306 # Copy stuff that may be dynamically loaded
309 cp -R $GTKSTACK_ROOT/etc/* $Etc
310 echo "Copying all Pango modules ..."
311 cp -R $GTKSTACK_ROOT/lib/pango/1.8.0/modules/*.so $Modules
312 echo "Copying all GDK Pixbuf loaders ..."
313 cp -R $GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.so $Loaders
315 # Generate a pango module file using the actual Pango that we're going to bundle
319 ModulesPath=$GTKSTACK_ROOT/lib/pango/1.8.0/modules
321 env PANGO_RC_FILE=pangorc $GTKSTACK_ROOT/bin/pango-querymodules | sed "s?$GTKSTACK_ROOT/lib/pango/1.8.0/?@ROOTDIR@/?" > $Etc/pango.modules.in
324 # Ditto for gdk-pixbuf loaders
325 gdk-pixbuf-query-loaders | sed "s?$GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/?@ROOTDIR@/?" > $Etc/gdk-pixbuf.loaders.in
327 # We rely on clearlooks, so include a version from our own build tree
328 # this one is special - we will set GTK_PATH to $Libraries/gtkengines
330 GTK_ENGINE_DIR=$Libraries/gtkengines/engines
331 mkdir -p $GTK_ENGINE_DIR
333 echo "Copying GTK engines ..."
334 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.so $Libraries
335 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.so . )
337 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Libraries
338 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so . )
341 if test x$WITH_LADSPA != x ; then
342 if test x$MIXBUS != x ; then
343 plugdir=mixbus_ladspa
347 echo "Copying `ls $plugdir | wc -l` plugins ..."
348 if [ -d $plugdir ] ; then
349 cp -r $plugdir/* $Plugins
354 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.so* $Surfaces
355 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp.so* $Libraries
358 # got to be careful with names here
359 for x in $BUILD_ROOT/../midi_maps/*.map ; do
364 # got to be careful with names here
365 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
370 # got to be careful with names here
371 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
372 cp "$x" $MackieControl
376 #for f in $BUILD_ROOT/../templates/* ; do
377 # if [ -d "$f" ] ; then
378 # echo Template: $f ; cp -r "$f" $Templates ;
383 # got to be careful with names here
384 for x in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
385 cp "$x" $ExportFormats
389 cp $BUILD_ROOT/libs/panners/*/lib*.so* $Panners
392 cp $BUILD_ROOT/libs/backends/*/lib*.so* $Backends
394 # VAMP plugins that we use
395 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.so* $Libraries
398 cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Libraries
400 OURLIBDIR=$BUILD_ROOT/libs
401 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
403 echo $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
410 filelist=`find $APPLIB/ -type f`
411 filelist="$APPBIN/$MAIN_EXECUTABLE $filelist"
413 for file in $filelist ; do
414 if ! file $file | grep -qs ELF ; then
418 # speed this up a bit by not checking things multiple times.
419 for i in "${depCheckedList[@]}"; do
420 if [ $i == $file ]; then
424 depCheckedList[$checkIdx]=$file
425 checkIdx=$(($checkIdx + 1))
427 # do not include libjack
428 deps=`LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | awk '{print $3}'`
431 for dep in $deps ; do
432 if test "not" = ${dep}; then
434 echo "!!! ERROR !!! - Missing dependant library for $file."
435 echo "Searched: " $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
437 (LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file)
439 echo "!!! ERROR !!! - See Above"
443 # don't use anything mapped at a specific address
444 if echo $dep | grep -qs '0x' ; then continue; fi
446 if echo $dep | grep -qs "^/lib/" ; then continue; fi
448 if echo $dep | grep -qs libjack ; then continue; fi
450 if echo $dep | grep -qs libasound ; then continue; fi
451 # don't include any X Window libraries
452 if echo $dep | grep -qs libX\. ; then continue; fi
453 if echo $dep | grep -qs libxcb ; then continue; fi
454 if echo $dep | grep -qs libICE\. ; then continue; fi
455 if echo $dep | grep -qs libSM\. ; then continue; fi
457 if echo $dep | grep -qs 'libc\.' ; then continue; fi
458 # don't include libstdc++
459 if echo $dep | grep -qs libstdc++ ; then continue; fi
462 if ! test -f $Libraries/$base; then
463 parent=$(basename ${file})
464 if echo $dep | grep -sq '^libs' ; then
465 echo "Copying dependant lib $BUILD_ROOT/$dep (required by ${parent})"
466 cp $BUILD_ROOT/$dep $Libraries
468 echo "Copying dependant lib $dep (required by ${parent})"
472 # reset RPATH so that the runtime linker never looks
473 # in places we don't want it to
475 chrpath -r foo $Libraries/`basename $dep`
476 if echo $dep | grep -sq '^/' ; then
477 # absolute path, candidate for stripping
478 deplibs="$deplibs $base"
484 if test x$missing = xfalse ; then
485 # everything has been found
492 if test x$STRIP = xall ; then
493 echo Stripping all libraries
494 # Must be writable so that we can strip
495 find $APPLIB/ -name "*.so*" | xargs chmod u+w
497 find $APPLIB/ -name "*.so*" | xargs strip
498 elif test x$STRIP = xsome ; then
499 echo Stripping dependent libraries
500 for l in $deplibs ; do
505 find $APPLIB/ -name "*.so*" | xargs chmod a+rx
507 echo "Copying other stuff to $APPDIR ..."
509 # these are all generated by waf
510 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Etc
511 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Etc
512 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc
513 cp ../../ardour_system.rc $Etc/ardour_system.rc
514 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_*.rc $Etc
516 # these are copied straight from the source tree
518 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui_default.conf
519 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui.conf
520 cp ../../instant.xml $Etc/instant.xml
521 cp ../../gtk2_ardour/step_editing.bindings $Etc
522 cp ../../gtk2_ardour/mixer.bindings $Etc
523 cp -r ../../gtk2_ardour/icons $Shared
524 cp -r ../../gtk2_ardour/pixmaps $Shared
528 # put sooper sekrit ingredients here and they will be copied
531 if [ -d specialSauce ] ; then
532 cp -r specialSauce $Etc
537 cp -R ../../gtk2_ardour/splash.png $Shared
538 cp -R ../../gtk2_ardour/small-splash.png $Shared
539 cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared
541 # install bundled LV2s to <app>/lib/LV2/
542 cp -R $BUILD_ROOT/libs/LV2 $APPLIB/
544 # go through and recursively remove any .svn dirs in the bundle
545 for svndir in `find $APPDIR -name .svn -type d`; do
549 if test x$WITH_HARVID != x ; then
551 HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
552 XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
555 rsync://ardour.org/video-tools/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz \
556 "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz"
559 rsync://ardour.org/video-tools/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz \
560 "$CACHEDIR/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz"
563 --exclude=README --exclude=harvid.1 --strip-components=1 \
564 -f "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz" || exit 1
567 --exclude=README --exclude=xjadeo.1 --strip-components=1 \
568 -f "$CACHEDIR/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz" || exit 1
574 # Add the uninstaller
576 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
577 chmod a+x $APPBIN/${APP_VER_NAME}.uninstall.sh
580 if [ -e $BUILD_ROOT/tools/sanity_check/sanityCheck ]; then
581 cp $BUILD_ROOT/tools/sanity_check/sanityCheck $APPBIN
583 echo "!!!ERROR !!! sanityCheck program is missing. packager will exit without being complete"
587 echo "Building tarball ..."
589 rm -f $APPDIR.tar.bz2
590 tar -cjf $APPDIR.tar.bz2 $APPDIR
592 echo "Calculating bundle size"
593 du -sb $APPDIR/ | awk '{print $1}' > $APPDIR.size