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 != x ]; 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/default
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}
147 Plugins=$APPLIB/plugins
148 Surfaces=$APPLIB/surfaces
149 Panners=$APPLIB/panners
150 Locale=$Shared/locale
151 MidiMaps=$Shared/midi_maps
152 Modules=$Libraries/modules
153 Loaders=$Libraries/loaders
156 if [ x$PRINT_SYSDEPS != x ] ; then
158 # print system dependencies
161 for file in $APPBIN/* $Libraries/* $Modules/* $Plugins/*.so ; do
162 if ! file $file | grep -qs Mach-O ; then
165 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
170 echo "Removing old $APPDIR tree ..."
173 echo "Building new app directory structure ..."
175 # only bother to make the longest paths
189 mkdir -p $Shared/templates
192 # maybe set variables
193 ENVIRONMENT=environment
197 if test x$MIXBUS != x ; then
198 echo export ARDOUR_MIXBUS=true >> $ENVIRONMENT
200 # current default for MIXBUS version is US keyboard layout without a keypad
202 echo export ARDOUR_KEYBOARD_LAYOUT=us-nokeypad >> $ENVIRONMENT
203 echo export ARDOUR_UI_CONF=ardour3_ui.conf >> $ENVIRONMENT
204 echo export ARDOUR3_UI_RC=ardour3_ui_dark.rc >> $ENVIRONMENT
208 # if we're not going to bundle JACK, make sure we can find
209 # jack in the places where it might be
212 echo export 'PATH=/usr/local/bin:/opt/bin:$PATH' >> $ENVIRONMENT
214 # create startup helper script
216 sed -e "/^%ENV%/r $ENVIRONMENT" -e '/^%ENV%/d' -e 's/%VER%/'"${release_version}"'/' < ardour.sh.in > $APPBIN/ardour3
217 rm $ENVIRONMENT && chmod 775 $APPBIN/ardour3
218 #MAIN_EXECUTABLE=ardour-$release_version
219 MAIN_EXECUTABLE=ardour-3.0
221 echo "Copying ardour executable ...."
222 cp $BUILD_ROOT/gtk2_ardour/$MAIN_EXECUTABLE $APPBIN
223 if test x$STRIP = xall ; then
224 strip $APPBIN/$MAIN_EXECUTABLE
228 # note that at present(feb 2011), the .mo files end up in the source tree which is
229 # not really as it should be.
230 if test x$WITH_NLS != x ; then
231 echo "NLS support ..."
232 echo "I hope you remembered to run scons msgupdate!"
234 files=`find ../../gtk2_ardour/ -name "*.mo"`
236 if [ -z "$files" ]; then
238 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../gtk2_ardour"
245 lang=`basename $file | sed 's/\.mo//'`
246 mkdir -p $Locale/$lang/LC_MESSAGES
247 cp $file $Locale/$lang/LC_MESSAGES/gtk2_ardour.mo
248 LINGUAS="$LINGUAS $lang"
251 files=`find ../../libs/ardour/ -name "*.mo"`
253 if [ -z "$files" ]; then
255 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../libs/ardour"
262 lang=`basename $file | sed 's/\.mo//'`
263 mkdir -p $Locale/$lang/LC_MESSAGES
264 cp $file $Locale/$lang/LC_MESSAGES/libardour.mo
267 GTK_MESSAGES="atk10.mo gdk-pixbuf.mo gtk20-properties.mo gtk20.mo atk10.mo glib20.mo"
268 LOCALEROOT=/usr/share/locale
270 for l in $LINGUAS ; do
271 echo "Copying GTK i18n files for $l..."
272 for MO in $GTK_MESSAGES ; do
273 if [ -f $LOCALEROOT/$l/LC_MESSAGES/$MO ] ; then
274 cp $LOCALEROOT/$l/LC_MESSAGES/$MO $Locale/$l/LC_MESSAGES
276 # try with just the language spec
277 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
278 if [ -f $LOCALEROOT/$just_lang/LC_MESSAGES/$MO ] ; then
279 cp $LOCALEROOT/$just_lang/LC_MESSAGES/$MO $Locale/$just_lang/LC_MESSAGES
285 echo "Skipping NLS support"
289 GTKROOT=`pkg-config --libs-only-L gtk+-2.0 | sed -e "s/-L//" -e "s/[[:space:]]//g"`
290 if [ ! -z "$GTKROOT" ]; then
291 echo "Found GTKROOT using pkg-config"
292 elif [ -d /usr/lib/gtk-2.0 ]; then
294 elif [ -d /usr/local/lib/gtk-2.0 ]; then
295 GTKROOT="/usr/local/lib"
298 echo "!!! ERROR !!! - Unable to locate gtk-2.0 directory. Packager will exit"
303 echo "GTKROOT is ${GTKROOT}"
304 versionDir=`ls ${GTKROOT}/gtk-2.0/ | grep "[0-9]*\.[0-9]*\.[0-9]*"`
307 for name in $versionDir ; do
311 if [ $num -eq 1 ]; then
312 GTKLIB=${GTKROOT}/gtk-2.0/$versionDir
313 echo "GTKLIB is ${GTKLIB}"
316 echo "!!! ERROR !!! - More than one gtk-2.0 version found in ${GTKROOT}/gtk-2.0/ ( $versionDir ). Packager will exit"
323 PANGOROOT=`pkg-config --libs-only-L pango | sed -e "s/-L//" -e "s/[[:space:]]//g"`
324 if [ ! -z "$PANGOROOT" ]; then
325 echo "Found PANGOROOT using pkg-config"
326 elif [ -d /usr/lib/pango ]; then
328 elif [ -d /usr/local/lib/pango ]; then
329 PANGOROOT="/usr/local/lib"
332 echo "!!! ERROR !!! - Unable to locate pango directory. Packager will exit"
337 echo "PANGOROOT is ${PANGOROOT}"
338 versionDir=`ls ${PANGOROOT}/pango/ | grep "[0-9]*\.[0-9]*\.[0-9]*"`
341 for name in $versionDir ; do
345 if [ $num -eq 1 ]; then
346 PANGOLIB=${PANGOROOT}/pango/$versionDir
347 echo "PANGOLIB is ${PANGOLIB}"
350 echo "!!! ERROR !!! - More than one pango version found in ${PANGOROOT}/pango/ ( $versionDir ). Packager will exit"
356 ### Find gdk-pixbuf ###
357 GDKPIXBUFROOT=`pkg-config --libs-only-L gdk-pixbuf-2.0 | sed -e "s/-L//" -e "s/[[:space:]]//g"`
358 if [ ! -z "$GDKPIXBUFROOT" ]; then
359 echo "Found GDKPIXBUFROOT using pkg-config"
360 elif [ -d /usr/lib/gdk-pixbuf-2.0 ]; then
361 GDKPIXBUFROOT="/usr/lib/gdk-pixbuf-2.0"
362 elif [ -d /usr/local/lib/gdk-pixbuf-2.0 ]; then
363 GDKPIXBUFROOT="/usr/local/lib/gdk-pixbuf-2.0"
364 elif [ -d ${GTKLIB}/loaders ]; then #odd ball case
365 GDKPIXBUFROOT=${GTKROOT}
366 GDKPIXBUFLIB=${GTKLIB}
369 echo "!!! ERROR !!! - Unable to locate gdk-pixbuf-2.0 directory. Packager will exit"
374 echo "GDKPIXBUFROOT is ${GDKPIXBUFROOT}"
376 if [ -z ${GDKPIXBUFLIB} ]; then
377 versionDir=`ls ${GDKPIXBUFROOT}/gdk-pixbuf-2.0/ | grep "[0-9]*\.[0-9]*\.[0-9]*"`
380 for name in $versionDir ; do
384 if [ $num -eq 1 ]; then
385 GDKPIXBUFLIB=${GDKPIXBUFROOT}/gdk-pixbuf-2.0/$versionDir
386 echo "GDKPIXBUFLIB is ${GDKPIXBUFLIB}"
389 echo "!!! ERROR !!! - More than one gdk-pixbuf-2.0 version found in ${GDKPIXBUFROOT}/pango/ ( $versionDir ). Packager will exit"
397 echo "Copying all Pango modules ..."
398 cp -R $PANGOLIB/modules/*.so $Modules
400 echo "Copying all GDK Pixbuf loaders ..."
401 cp -R $GDKPIXBUFLIB/loaders/*.so $Loaders
403 pango-querymodules | sed "s?$PANGOLIB/?@ROOTDIR@/?" > $Etc/pango.modules.in
404 gdk-pixbuf-query-loaders | sed "s?$GDKPIXBUFLIB/?@ROOTDIR@/?" > $Etc/gdk-pixbuf.loaders.in
406 # We sort of rely on clearlooks, so include a version
407 # this one is special - we will set GTK_PATH to $Libraries/clearlooks
409 if [ ! -e ${GTKLIB}/engines/libclearlooks.so ]; then
411 echo "!!! ERROR !!! - not able to locate libclearlooks.so"
413 echo "Packager with exit"
417 echo "Copying clearlooks ..."
418 cp ${GTKLIB}/engines/libclearlooks.so $Libraries
419 mkdir -p $Libraries/clearlooks/engines
420 (cd $Libraries/clearlooks/engines && ln -s ../../libclearlooks* libclearlooks.so )
423 if test x$WITH_LADSPA != x ; then
424 if test x$MIXBUS != x ; then
425 plugdir=mixbus_ladspa
429 echo "Copying `ls $plugdir | wc -l` plugins ..."
430 if [ -d $plugdir ] ; then
431 cp -r $plugdir/* $Plugins
436 cp $BUILD_ROOT/libs/surfaces/*/libardour*.so* $Surfaces
437 # hack ... move libardour_cp back into Libraries
438 mv $Surfaces/libardourcp.so* $Libraries
441 cp $BUILD_ROOT/../../midi_maps/*.map $MidiMaps
444 cp $BUILD_ROOT/libs/panners/*/lib*.so* $Panners
446 # VAMP plugins that we use
447 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.so* $Libraries
449 OURLIBDIR=$BUILD_ROOT/libs
450 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
452 echo $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
458 filelist=`find $APPLIB/ -type f`
459 filelist="$APPBIN/$MAIN_EXECUTABLE $filelist"
461 for file in $filelist ; do
462 if ! file $file | grep -qs ELF ; then
466 # speed this up a bit by not checking things multiple times.
467 for i in "${depCheckedList[@]}"; do
468 if [ $i == $file ]; then
472 depCheckedList[$checkIdx]=$file
473 checkIdx=$(($checkIdx + 1))
475 # do not include libjack
476 deps=`LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | awk '{print $3}'`
478 # LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | egrep "(/opt/|/local/|libs/|/usr/lib|/gtk)" | grep -v 'libjack\.'
480 for dep in $deps ; do
481 if test "not" = ${dep}; then
483 echo "!!! ERROR !!! - Missing dependant library for $file."
485 (LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file)
487 echo "!!! ERROR !!! - See Above"
491 # don't use anything mapped at a specific address
492 if echo $dep | grep -qs '0x' ; then continue; fi
494 if echo $dep | grep -qs "^/lib/" ; then continue; fi
496 if echo $dep | grep -qs libjack ; then continue; fi
497 # don't include any X Window libraries
498 if echo $dep | grep -qs libX ; then continue; fi
499 if echo $dep | grep -qs libxcb ; then continue; fi
501 if echo $dep | grep -qs 'libc\.' ; then continue; fi
502 # don't include libstdc++
503 if echo $dep | grep -qs libstdc++ ; then continue; fi
506 if ! test -f $Libraries/$base; then
507 parent=$(basename ${file})
508 if echo $dep | grep -sq '^libs' ; then
509 echo "Copying dependant lib $BUILD_ROOT/$dep (required by ${parent})"
510 cp $BUILD_ROOT/$dep $Libraries
512 echo "Copying dependant lib $dep (required by ${parent})"
514 deplibs = "$deplibs $base"
520 if test x$missing = xfalse ; then
521 # everything has been found
528 if test x$STRIP = xall ; then
529 echo Stripping all libraries
530 find $APPLIB/ -name "*.so*" | xargs strip
531 else if test x$STRIP = xsome ; then
532 echo Stripping dependent libraries
533 for l in $deplibs ; do
537 find $APPLIB/ -name "*.so*" | xargs chmod a+rx
539 echo "Copying other stuff to $APPDIR ..."
541 # these are all generated by waf
542 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Etc
543 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Etc
544 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc
545 cp $BUILD_ROOT/ardour_system.rc $Etc/ardour_system.rc
546 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_light.rc $Etc
547 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_dark.rc $Etc
549 # these are copied straight from the source tree
551 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui.conf
552 cp ../../instant.xml $Etc/instant.xml
553 cp -r ../../gtk2_ardour/icons $Etc
554 cp -r ../../gtk2_ardour/pixmaps $Etc
557 # put sooper sekrit ingredients here and they will be copied
560 if [ -d specialSauce ] ; then
561 cp -r specialSauce $Etc
566 cp -R ../../gtk2_ardour/splash.png $Shared
567 # currently no templates
568 #cp ../../templates/*.template $Shared/templates/
570 # go through and recursively remove any .svn dirs in the bundle
571 for svndir in `find $APPDIR -name .svn -type d`; do
576 # Add the uninstaller
578 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
579 chmod a+x $APPBIN/${APP_VER_NAME}.uninstall.sh
582 if [ -e $BUILD_ROOT/tools/sanity_check/sanityCheck ]; then
583 cp $BUILD_ROOT/tools/sanity_check/sanityCheck $APPBIN
585 echo "!!!ERROR !!! sanityCheck program is missing. packager will exit without being complete"
589 echo "Building tarball ..."
591 rm -f $APPDIR.tar.bz2
592 tar -cjf $APPDIR.tar.bz2 $APPDIR