7 # script for pulling together a Linux app bundle.
9 # This will create a bundle for a single architecture.
10 # Execute this scirpt on both x86 and x86_64 and then use
11 # package to merge the 2 bundles into a final package with the
23 if [ $# -eq 0 ] ; then
25 echo "ERROR - Please specify build type"
32 while [ $# -gt 0 ] ; do
37 # top level build targets
59 --test) WITH_LADSPA=; STRIP= ; shift ;;
62 # specific build flags
65 --nojack) INTERNAL_JACK= ; shift ;;
66 --noladspa) WITH_LADSPA= ; shift ;;
67 --strip) STRIP=$2 ; shift ; shift ;;
68 --sysdeps) PRINT_SYSDEPS=1; shift ;;
69 --nls) WITH_NLS=1 ; shift ;;
72 #catch all for unknown arguments
74 echo "!!! ERROR !!! - Unknown argument $1"
81 if test x$STRIP != xall -a x$STRIP != xnone -a x$STRIP != xsome ; then
82 echo "Unknown strip option \"$STRIP\""
83 echo "Legal values are: all, none, some"
87 release_version=`grep -m 1 '^VERSION' ../../wscript | awk '{print $3}' | sed "s/'//g"`
88 svn_version=`grep -m 1 'svn_revision =' ../../libs/ardour/svn_revision.cc | cut -d"'" -f 2`
89 echo "Version is $release_version / $svn_version"
90 info_string="$release_version/$svn_version built on `hostname` by `whoami` on `date`"
91 echo "Info string is $info_string"
93 # Figure out our CPU type
95 i[3456789]86|x86|i86pc)
96 echo "Architecture is x86"
101 echo "Architecture is x86_64"
107 echo "ERROR - Unknown architecture `uname -m`"
113 # Figure out the Build Type
114 if grep -q "DEBUG = True" ../../build/c4che/default.cache.py; then
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 # the waf build tree to use when copying built/generated files
130 BUILD_ROOT=../../build
132 # setup directory structure
134 if [ -z "${BUILDTYPE}" ]; then
135 APPDIR=${APPNAME}_${ARCH}-${release_version}_${svn_version}
136 APP_VER_NAME=${APPNAME}-${release_version}_${svn_version}
138 APPDIR=${APPNAME}_${ARCH}-${release_version}_${svn_version}-${BUILDTYPE}
139 APP_VER_NAME=${APPNAME}-${release_version}_${svn_version}-${BUILDTYPE}
148 Plugins=$APPLIB/plugins
149 Surfaces=$APPLIB/surfaces
150 Panners=$APPLIB/panners
152 Modules=$Libraries/modules
153 Loaders=$Libraries/loaders
155 Templates=$Shared/templates
156 ExportFormats=$Shared/export
157 Locale=$Shared/locale
158 MidiMaps=$Shared/midi_maps
159 PatchFiles=$Shared/patchfiles
160 MackieControl=$Shared/mcp
162 if [ x$PRINT_SYSDEPS != x ] ; then
164 # print system dependencies
167 for file in $APPBIN/* $Libraries/* $Modules/* $Plugins/*.so ; do
168 if ! file $file | grep -qs Mach-O ; then
171 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
176 echo "Removing old $APPDIR tree ..."
179 echo "Building new app directory structure ..."
181 # only bother to make the longest paths
195 mkdir -p $MackieControl
196 mkdir -p $ExportFormats
199 mkdir -p $Shared/templates
202 # maybe set variables
203 ENVIRONMENT=environment
207 if test x$MIXBUS != x ; then
208 echo export ARDOUR_MIXBUS=true >> $ENVIRONMENT
210 # current default for MIXBUS version is US keyboard layout without a keypad
212 echo export ARDOUR_KEYBOARD_LAYOUT=us-nokeypad >> $ENVIRONMENT
213 echo export ARDOUR_UI_CONF=ardour3_ui.conf >> $ENVIRONMENT
214 echo export ARDOUR3_UI_RC=ardour3_ui_dark.rc >> $ENVIRONMENT
218 # if we're not going to bundle JACK, make sure we can find
219 # jack in the places where it might be
222 echo export 'PATH=/usr/local/bin:/opt/bin:$PATH' >> $ENVIRONMENT
224 # create startup helper script
226 sed -e "/^%ENV%/r $ENVIRONMENT" -e '/^%ENV%/d' -e 's/%VER%/'"${release_version}"'/' < ardour.sh.in > $APPBIN/ardour3
227 rm $ENVIRONMENT && chmod 775 $APPBIN/ardour3
228 #MAIN_EXECUTABLE=ardour-$release_version
229 MAIN_EXECUTABLE=ardour-3.0
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 dl in gtk2_ardour libs/ardour libs/gtkmm2ext ; do
246 files=`find ../../$dl -name "*.mo"`
248 if [ -z "$files" ]; then
250 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$dl"
257 lang=`basename $file | sed 's/\.mo//'`
258 mkdir -p $Locale/$lang/LC_MESSAGES
259 cp $file $Locale/$lang/LC_MESSAGES/`basename $dl`
260 if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
263 LINGUAS="$LINGUAS $lang"
268 GTK_MESSAGES="atk10.mo gdk-pixbuf.mo gtk20-properties.mo gtk20.mo atk10.mo glib20.mo"
269 LOCALEROOT=/usr/share/locale
271 for l in $LINGUAS ; do
272 echo "Copying GTK i18n files for $l..."
273 for MO in $GTK_MESSAGES ; do
274 if [ -f $LOCALEROOT/$l/LC_MESSAGES/$MO ] ; then
275 cp $LOCALEROOT/$l/LC_MESSAGES/$MO $Locale/$l/LC_MESSAGES
277 # try with just the language spec
278 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
279 if [ -f $LOCALEROOT/$just_lang/LC_MESSAGES/$MO ] ; then
280 cp $LOCALEROOT/$just_lang/LC_MESSAGES/$MO $Locale/$just_lang/LC_MESSAGES
286 echo "Skipping NLS support"
289 ### Find fontconfig ###
290 FCROOT=`pkg-config --libs-only-L fontconfig | sed -e "s/-L//" -e "s/[[:space:]]//g"`
291 if [ ! -z "$FCROOT" ]; then
292 echo "Found FCOOT using pkg-config"
293 FCETC=`dirname $FCROOT`/etc
294 elif [ -d /usr/lib/gtk-2.0 ]; then
296 elif [ -d /usr/local/lib/gtk-2.0 ]; then
297 FCETC="/usr/local/etc"
300 echo "!!! ERROR !!! - Unable to locate fontconfig directory. Packager will exit"
305 echo "Copying Fontconfig files to $Etc ..."
306 cp -r $FCETC/fonts $Etc
309 GTKROOT=`pkg-config --libs-only-L gtk+-2.0 | sed -e "s/-L//" -e "s/[[:space:]]//g"`
310 if [ ! -z "$GTKROOT" ]; then
311 echo "Found GTKROOT using pkg-config"
312 elif [ -d /usr/lib/gtk-2.0 ]; then
314 elif [ -d /usr/local/lib/gtk-2.0 ]; then
315 GTKROOT="/usr/local/lib"
318 echo "!!! ERROR !!! - Unable to locate gtk-2.0 directory. Packager will exit"
323 echo "GTKROOT is ${GTKROOT}"
324 versionDir=`ls ${GTKROOT}/gtk-2.0/ | grep "[0-9]*\.[0-9]*\.[0-9]*"`
327 for name in $versionDir ; do
331 if [ $num -eq 1 ]; then
332 GTKLIB=${GTKROOT}/gtk-2.0/$versionDir
333 echo "GTKLIB is ${GTKLIB}"
336 echo "!!! ERROR !!! - More than one gtk-2.0 version found in ${GTKROOT}/gtk-2.0/ ( $versionDir ). Packager will exit"
343 PANGOROOT=`pkg-config --libs-only-L pango | sed -e "s/-L//" -e "s/[[:space:]]//g"`
344 if [ ! -z "$PANGOROOT" ]; then
345 echo "Found PANGOROOT using pkg-config"
346 elif [ -d /usr/lib/pango ]; then
348 elif [ -d /usr/local/lib/pango ]; then
349 PANGOROOT="/usr/local/lib"
350 elif [ -d /usr/lib/x86_64-linux-gnu/pango ]; then
351 PANGOROOT="/usr/lib/x86_64-linux-gnu"
354 echo "!!! ERROR !!! - Unable to locate pango directory. Packager will exit"
359 echo "PANGOROOT is ${PANGOROOT}"
360 versionDir=`ls ${PANGOROOT}/pango/ | grep "[0-9]*\.[0-9]*\.[0-9]*"`
363 for name in $versionDir ; do
367 if [ $num -eq 1 ]; then
368 PANGOLIB=${PANGOROOT}/pango/$versionDir
369 echo "PANGOLIB is ${PANGOLIB}"
372 echo "!!! ERROR !!! - More than one pango version found in ${PANGOROOT}/pango/ ( $versionDir ). Packager will exit"
378 ### Find gdk-pixbuf ###
379 GDKPIXBUFROOT=`pkg-config --libs-only-L gdk-pixbuf-2.0 | sed -e "s/-L//" -e "s/[[:space:]]//g"`
380 if [ ! -z "$GDKPIXBUFROOT" ]; then
381 echo "Found GDKPIXBUFROOT using pkg-config"
382 elif [ -d /usr/lib/gdk-pixbuf-2.0 ]; then
383 GDKPIXBUFROOT="/usr/lib"
384 elif [ -d /usr/local/lib/gdk-pixbuf-2.0 ]; then
385 GDKPIXBUFROOT="/usr/local/lib"
386 elif [ -d ${GTKLIB}/loaders ]; then #odd ball case
387 GDKPIXBUFROOT=${GTKROOT}
388 GDKPIXBUFLIB=${GTKLIB}
391 echo "!!! ERROR !!! - Unable to locate gdk-pixbuf-2.0 directory. Packager will exit"
396 echo "GDKPIXBUFROOT is ${GDKPIXBUFROOT}"
398 if [ -z ${GDKPIXBUFLIB} ]; then
399 versionDir=`ls ${GDKPIXBUFROOT}/gdk-pixbuf-2.0/ | grep "[0-9]*\.[0-9]*\.[0-9]*"`
402 for name in $versionDir ; do
406 if [ $num -eq 1 ]; then
407 GDKPIXBUFLIB=${GDKPIXBUFROOT}/gdk-pixbuf-2.0/$versionDir
408 echo "GDKPIXBUFLIB is ${GDKPIXBUFLIB}"
411 echo "!!! ERROR !!! - More than one gdk-pixbuf-2.0 version found in ${GDKPIXBUFROOT}/pango/ ( $versionDir ). Packager will exit"
419 echo "Copying all Pango modules ..."
420 cp -R $PANGOLIB/modules/*.so $Modules
422 echo "Copying all GDK Pixbuf loaders ..."
423 cp -R $GDKPIXBUFLIB/loaders/*.so $Loaders
425 pango-querymodules | sed "s?$PANGOLIB/?@ROOTDIR@/?" > $Etc/pango.modules.in
426 gdk-pixbuf-query-loaders | sed "s?$GDKPIXBUFLIB/?@ROOTDIR@/?" > $Etc/gdk-pixbuf.loaders.in
428 # We sort of rely on clearlooks, so include a version
429 # this one is special - we will set GTK_PATH to $Libraries/clearlooks
431 if [ ! -e ${GTKLIB}/engines/libclearlooks.so ]; then
432 if [ ! -e $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.so ] ; then
434 echo "!!! ERROR !!! - not able to locate libclearlooks.so"
436 echo "Packager with exit"
439 clearlooks_so=$BUILD_ROOT/libs/clearlooks-newer/libclearlooks.so
442 clearlooks_so=${GTKLIB}/engines/libclearlooks.so
445 echo "Copying clearlooks ..."
446 cp $clearlooks_so $Libraries
447 mkdir -p $Libraries/clearlooks/engines
448 (cd $Libraries/clearlooks/engines && ln -s ../../libclearlooks* libclearlooks.so )
451 if test x$WITH_LADSPA != x ; then
452 if test x$MIXBUS != x ; then
453 plugdir=mixbus_ladspa
457 echo "Copying `ls $plugdir | wc -l` plugins ..."
458 if [ -d $plugdir ] ; then
459 cp -r $plugdir/* $Plugins
464 cp $BUILD_ROOT/libs/surfaces/*/libardour*.so* $Surfaces
465 # hack ... move libardour_cp back into Libraries
466 mv $Surfaces/libardourcp.so* $Libraries
469 # got to be careful with names here
470 for x in $BUILD_ROOT/../midi_maps/*.map ; do
472 echo Copied MIDI map $x
476 # got to be careful with names here
477 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
479 echo Copied MIDNAM file "$x"
483 # got to be careful with names here
484 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
485 cp "$x" $MackieControl
486 echo Copied Mackie Control file $x
490 for f in $BUILD_ROOT/../templates/* ; do
491 if [ -d "$f" ] ; then
492 echo Template: $f ; cp -r "$f" $Templates ;
497 # got to be careful with names here
498 for x in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
499 cp "$x" $ExportFormats
503 cp $BUILD_ROOT/libs/panners/*/lib*.so* $Panners
505 # VAMP plugins that we use
506 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.so* $Libraries
508 OURLIBDIR=$BUILD_ROOT/libs
509 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/qm-dsp
511 echo $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
518 filelist=`find $APPLIB/ -type f`
519 filelist="$APPBIN/$MAIN_EXECUTABLE $filelist"
521 for file in $filelist ; do
522 if ! file $file | grep -qs ELF ; then
526 # speed this up a bit by not checking things multiple times.
527 for i in "${depCheckedList[@]}"; do
528 if [ $i == $file ]; then
532 depCheckedList[$checkIdx]=$file
533 checkIdx=$(($checkIdx + 1))
535 # do not include libjack
536 deps=`LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | awk '{print $3}'`
539 for dep in $deps ; do
540 if test "not" = ${dep}; then
542 echo "!!! ERROR !!! - Missing dependant library for $file."
544 (LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file)
546 echo "!!! ERROR !!! - See Above"
550 # don't use anything mapped at a specific address
551 if echo $dep | grep -qs '0x' ; then continue; fi
553 if echo $dep | grep -qs "^/lib/" ; then continue; fi
555 if echo $dep | grep -qs libjack ; then continue; fi
557 if echo $dep | grep -qs libasound ; then continue; fi
558 # don't include any X Window libraries
559 if echo $dep | grep -qs libX\. ; then continue; fi
560 if echo $dep | grep -qs libxcb ; then continue; fi
561 if echo $dep | grep -qs libSM\. ; then continue; fi
563 if echo $dep | grep -qs 'libc\.' ; then continue; fi
564 # don't include libstdc++
565 if echo $dep | grep -qs libstdc++ ; then continue; fi
568 if ! test -f $Libraries/$base; then
569 parent=$(basename ${file})
570 if echo $dep | grep -sq '^libs' ; then
571 echo "Copying dependant lib $BUILD_ROOT/$dep (required by ${parent})"
572 cp $BUILD_ROOT/$dep $Libraries
574 echo "Copying dependant lib $dep (required by ${parent})"
577 if echo $dep | grep -sq '^/' ; then
578 # absolute path, candidate for stripping
579 deplibs="$deplibs $base"
585 if test x$missing = xfalse ; then
586 # everything has been found
593 if test x$STRIP = xall ; then
594 echo Stripping all libraries
595 # Must be writable so that we can strip
596 find $APPLIB/ -name "*.so*" | xargs chmod u+w
598 find $APPLIB/ -name "*.so*" | xargs strip
599 elif test x$STRIP = xsome ; then
600 echo Stripping dependent libraries
601 for l in $deplibs ; do
606 find $APPLIB/ -name "*.so*" | xargs chmod a+rx
608 echo "Copying other stuff to $APPDIR ..."
610 # these are all generated by waf
611 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Etc
612 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Etc
613 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc
614 cp $BUILD_ROOT/ardour_system.rc $Etc/ardour_system.rc
615 cp $BUILD_ROOT/gtk2_ardour/ardour3*.rc $Etc
617 # these are copied straight from the source tree
619 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui_default.conf
620 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui.conf
621 cp ../../instant.xml $Etc/instant.xml
622 cp ../../gtk2_ardour/step_editing.bindings $Etc
623 cp ../../gtk2_ardour/mixer.bindings $Etc
624 cp -r ../../gtk2_ardour/icons $Shared
625 cp -r ../../gtk2_ardour/pixmaps $Shared
629 # put sooper sekrit ingredients here and they will be copied
632 if [ -d specialSauce ] ; then
633 cp -r specialSauce $Etc
638 cp -R ../../gtk2_ardour/splash.png $Shared
640 # go through and recursively remove any .svn dirs in the bundle
641 for svndir in `find $APPDIR -name .svn -type d`; do
646 # Add the uninstaller
648 sed -e "s/%REPLACE_PGM%/${APPNAME}/" -e "s/%REPLACE_VENDOR%/${VENDOR}/" -e "s/%REPLACE_VERSION%/${release_version}/" -e "s/%REPLACE_BUILD%/${svn_version}/" -e "s/%REPLACE_TYPE%/${BUILDTYPE}/" < uninstall.sh.in > $APPBIN/${APP_VER_NAME}.uninstall.sh
649 chmod a+x $APPBIN/${APP_VER_NAME}.uninstall.sh
652 if [ -e $BUILD_ROOT/tools/sanity_check/sanityCheck ]; then
653 cp $BUILD_ROOT/tools/sanity_check/sanityCheck $APPBIN
655 echo "!!!ERROR !!! sanityCheck program is missing. packager will exit without being complete"
659 echo "Building tarball ..."
661 rm -f $APPDIR.tar.bz2
662 tar -cjf $APPDIR.tar.bz2 $APPDIR
664 echo "Calculating bundle size"
665 du -sb $APPDIR/ | awk '{print $1}' > $APPDIR.size