fix serious breakage with setup of plugin automatable controls/parameters, in which...
[ardour2.git] / tools / linux_packaging / build
blob2cef0bb04587f58840a98e35cf3b4aad0b294aaa
1 #!/bin/bash
5 . ./buildenv
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
12 # installer.
14 MIXBUS=
15 WITH_LADSPA=0
16 STRIP=all
17 PRINT_SYSDEPS=
18 WITH_NLS=
19 EXTERNAL_JACK=
20 VENDOR=Ardour ;
21 BUILDTYPE=""
23 if [ $# -eq 0 ] ; then
24 echo ""
25 echo "ERROR - Please specify build type"
26 echo " --public"
27 echo " --mixbus"
28 echo ""
29 exit 1
32 while [ $# -gt 0 ] ; do
33 echo "arg = $1"
34 case $1 in
37 # top level build targets
40 --mixbus)
41 MIXBUS=1;
42 WITH_NLS=1 ;
43 WITH_LADSPA=;
44 STRIP=all
45 APPNAME=Mixbus ;
46 VENDOR=Harrison ;
47 shift ;;
48 --public)
49 WITH_NLS=1 ;
50 WITH_LADSPA=;
51 STRIP=all ;
52 APPNAME=Ardour ;
53 shift ;;
54 --allinone)
55 WITH_NLS= ;
56 WITH_LADSPA=1;
57 STRIP=all;
58 shift ;;
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
73 echo ""
74 echo "!!! ERROR !!! - Unknown argument $1"
75 echo ""
76 exit 1
78 esac
79 done
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"
84 exit 1
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
94 case `uname -m` in
95 i[3456789]86|x86|i86pc)
96 echo "Architecture is x86"
97 ARCH='x86'
98 ARCH_BITS='32-bit'
100 x86_64|amd64|AMD64)
101 echo "Architecture is x86_64"
102 ARCH='x86_64'
103 ARCH_BITS='64-bit'
106 echo ""
107 echo "ERROR - Unknown architecture `uname -m`"
108 echo ""
109 exit 1
111 esac
113 # Figure out the Build Type
114 if grep -q "DEBUG = True" ../../build/c4che/default.cache.py; then
115 DEBUG="T"
116 else
117 DEBUG="F"
120 if [ x$DEBUG = xT ]; then
121 BUILDTYPE="dbg"
122 if [ x$STRIP = xall ] ; then
123 echo "A debug build with --strip all makes no sense - STRIP reset to \"some\""
124 STRIP=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}
137 else
138 APPDIR=${APPNAME}_${ARCH}-${release_version}_${svn_version}-${BUILDTYPE}
139 APP_VER_NAME=${APPNAME}-${release_version}_${svn_version}-${BUILDTYPE}
142 APPBIN=$APPDIR/bin
143 APPLIB=$APPDIR/lib
144 Libraries=$APPLIB
145 Etc=$APPDIR/etc
146 Shared=$APPDIR/share
147 Plugins=$APPLIB/plugins
148 Surfaces=$APPLIB/surfaces
149 Panners=$APPLIB/panners
150 ExportFormats=$Shared/export
151 Locale=$Shared/locale
152 MidiMaps=$Shared/midi_maps
153 Modules=$Libraries/modules
154 Loaders=$Libraries/loaders
157 if [ x$PRINT_SYSDEPS != x ] ; then
159 # print system dependencies
162 for file in $APPBIN/* $Libraries/* $Modules/* $Plugins/*.so ; do
163 if ! file $file | grep -qs Mach-O ; then
164 continue
166 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
167 done | sort | uniq
168 exit 0
171 echo "Removing old $APPDIR tree ..."
172 rm -rf $APPDIR/
174 echo "Building new app directory structure ..."
176 # only bother to make the longest paths
178 mkdir -p $APPDIR
179 mkdir -p $APPBIN
180 mkdir -p $APPLIB
181 mkdir -p $Etc
182 mkdir -p $Plugins
183 mkdir -p $Modules
184 mkdir -p $Loaders
185 mkdir -p $Shared
186 mkdir -p $Locale
187 mkdir -p $Surfaces
188 mkdir -p $MidiMaps
189 mkdir -p $ExportFormats
190 mkdir -p $Panners
191 mkdir -p $Shared/templates
192 mkdir -p $Shared/doc
194 # maybe set variables
195 ENVIRONMENT=environment
196 rm -f $ENVIRONMENT
197 touch $ENVIRONMENT
199 if test x$MIXBUS != x ; then
200 echo export ARDOUR_MIXBUS=true >> $ENVIRONMENT
202 # current default for MIXBUS version is US keyboard layout without a keypad
204 echo export ARDOUR_KEYBOARD_LAYOUT=us-nokeypad >> $ENVIRONMENT
205 echo export ARDOUR_UI_CONF=ardour3_ui.conf >> $ENVIRONMENT
206 echo export ARDOUR3_UI_RC=ardour3_ui_dark.rc >> $ENVIRONMENT
210 # if we're not going to bundle JACK, make sure we can find
211 # jack in the places where it might be
214 echo export 'PATH=/usr/local/bin:/opt/bin:$PATH' >> $ENVIRONMENT
216 # create startup helper script
218 sed -e "/^%ENV%/r $ENVIRONMENT" -e '/^%ENV%/d' -e 's/%VER%/'"${release_version}"'/' < ardour.sh.in > $APPBIN/ardour3
219 rm $ENVIRONMENT && chmod 775 $APPBIN/ardour3
220 #MAIN_EXECUTABLE=ardour-$release_version
221 MAIN_EXECUTABLE=ardour-3.0
223 echo "Copying ardour executable ...."
224 cp $BUILD_ROOT/gtk2_ardour/$MAIN_EXECUTABLE $APPBIN
225 if test x$STRIP = xall ; then
226 strip $APPBIN/$MAIN_EXECUTABLE
229 # copy locale files
230 # note that at present(feb 2011), the .mo files end up in the source tree which is
231 # not really as it should be.
232 if test x$WITH_NLS != x ; then
233 echo "NLS support ..."
234 echo "I hope you remembered to run scons msgupdate!"
235 LINGUAS=
236 files=`find ../../gtk2_ardour/ -name "*.mo"`
238 if [ -z "$files" ]; then
239 echo ""
240 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../gtk2_ardour"
241 echo ""
244 for file in $files
246 echo $file
247 lang=`basename $file | sed 's/\.mo//'`
248 mkdir -p $Locale/$lang/LC_MESSAGES
249 cp $file $Locale/$lang/LC_MESSAGES/gtk2_ardour.mo
250 LINGUAS="$LINGUAS $lang"
251 done
253 files=`find ../../libs/ardour/ -name "*.mo"`
255 if [ -z "$files" ]; then
256 echo ""
257 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../libs/ardour"
258 echo ""
261 for file in $files
263 echo $file
264 lang=`basename $file | sed 's/\.mo//'`
265 mkdir -p $Locale/$lang/LC_MESSAGES
266 cp $file $Locale/$lang/LC_MESSAGES/libardour.mo
267 done
269 GTK_MESSAGES="atk10.mo gdk-pixbuf.mo gtk20-properties.mo gtk20.mo atk10.mo glib20.mo"
270 LOCALEROOT=/usr/share/locale
272 for l in $LINGUAS ; do
273 echo "Copying GTK i18n files for $l..."
274 for MO in $GTK_MESSAGES ; do
275 if [ -f $LOCALEROOT/$l/LC_MESSAGES/$MO ] ; then
276 cp $LOCALEROOT/$l/LC_MESSAGES/$MO $Locale/$l/LC_MESSAGES
277 else
278 # try with just the language spec
279 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
280 if [ -f $LOCALEROOT/$just_lang/LC_MESSAGES/$MO ] ; then
281 cp $LOCALEROOT/$just_lang/LC_MESSAGES/$MO $Locale/$just_lang/LC_MESSAGES
284 done
285 done
286 else
287 echo "Skipping NLS support"
290 ### Find gtk ###
291 GTKROOT=`pkg-config --libs-only-L gtk+-2.0 | sed -e "s/-L//" -e "s/[[:space:]]//g"`
292 if [ ! -z "$GTKROOT" ]; then
293 echo "Found GTKROOT using pkg-config"
294 elif [ -d /usr/lib/gtk-2.0 ]; then
295 GTKROOT="/usr/lib"
296 elif [ -d /usr/local/lib/gtk-2.0 ]; then
297 GTKROOT="/usr/local/lib"
298 else
299 echo ""
300 echo "!!! ERROR !!! - Unable to locate gtk-2.0 directory. Packager will exit"
301 echo ""
302 exit 1
305 echo "GTKROOT is ${GTKROOT}"
306 versionDir=`ls ${GTKROOT}/gtk-2.0/ | grep "[0-9]*\.[0-9]*\.[0-9]*"`
308 num=0
309 for name in $versionDir ; do
310 num=$(($num + 1))
311 done
313 if [ $num -eq 1 ]; then
314 GTKLIB=${GTKROOT}/gtk-2.0/$versionDir
315 echo "GTKLIB is ${GTKLIB}"
316 else
317 echo ""
318 echo "!!! ERROR !!! - More than one gtk-2.0 version found in ${GTKROOT}/gtk-2.0/ ( $versionDir ). Packager will exit"
319 echo ""
320 exit 1
324 ### Find pango ###
325 PANGOROOT=`pkg-config --libs-only-L pango | sed -e "s/-L//" -e "s/[[:space:]]//g"`
326 if [ ! -z "$PANGOROOT" ]; then
327 echo "Found PANGOROOT using pkg-config"
328 elif [ -d /usr/lib/pango ]; then
329 PANGOROOT="/usr/lib"
330 elif [ -d /usr/local/lib/pango ]; then
331 PANGOROOT="/usr/local/lib"
332 else
333 echo ""
334 echo "!!! ERROR !!! - Unable to locate pango directory. Packager will exit"
335 echo ""
336 exit 1
339 echo "PANGOROOT is ${PANGOROOT}"
340 versionDir=`ls ${PANGOROOT}/pango/ | grep "[0-9]*\.[0-9]*\.[0-9]*"`
342 num=0
343 for name in $versionDir ; do
344 num=$(($num + 1))
345 done
347 if [ $num -eq 1 ]; then
348 PANGOLIB=${PANGOROOT}/pango/$versionDir
349 echo "PANGOLIB is ${PANGOLIB}"
350 else
351 echo ""
352 echo "!!! ERROR !!! - More than one pango version found in ${PANGOROOT}/pango/ ( $versionDir ). Packager will exit"
353 echo ""
354 exit 1
358 ### Find gdk-pixbuf ###
359 GDKPIXBUFROOT=`pkg-config --libs-only-L gdk-pixbuf-2.0 | sed -e "s/-L//" -e "s/[[:space:]]//g"`
360 if [ ! -z "$GDKPIXBUFROOT" ]; then
361 echo "Found GDKPIXBUFROOT using pkg-config"
362 elif [ -d /usr/lib/gdk-pixbuf-2.0 ]; then
363 GDKPIXBUFROOT="/usr/lib/gdk-pixbuf-2.0"
364 elif [ -d /usr/local/lib/gdk-pixbuf-2.0 ]; then
365 GDKPIXBUFROOT="/usr/local/lib/gdk-pixbuf-2.0"
366 elif [ -d ${GTKLIB}/loaders ]; then #odd ball case
367 GDKPIXBUFROOT=${GTKROOT}
368 GDKPIXBUFLIB=${GTKLIB}
369 else
370 echo ""
371 echo "!!! ERROR !!! - Unable to locate gdk-pixbuf-2.0 directory. Packager will exit"
372 echo ""
373 exit 1
376 echo "GDKPIXBUFROOT is ${GDKPIXBUFROOT}"
378 if [ -z ${GDKPIXBUFLIB} ]; then
379 versionDir=`ls ${GDKPIXBUFROOT}/gdk-pixbuf-2.0/ | grep "[0-9]*\.[0-9]*\.[0-9]*"`
381 num=0
382 for name in $versionDir ; do
383 num=$(($num + 1))
384 done
386 if [ $num -eq 1 ]; then
387 GDKPIXBUFLIB=${GDKPIXBUFROOT}/gdk-pixbuf-2.0/$versionDir
388 echo "GDKPIXBUFLIB is ${GDKPIXBUFLIB}"
389 else
390 echo ""
391 echo "!!! ERROR !!! - More than one gdk-pixbuf-2.0 version found in ${GDKPIXBUFROOT}/pango/ ( $versionDir ). Packager will exit"
392 echo ""
393 exit 1
399 echo "Copying all Pango modules ..."
400 cp -R $PANGOLIB/modules/*.so $Modules
402 echo "Copying all GDK Pixbuf loaders ..."
403 cp -R $GDKPIXBUFLIB/loaders/*.so $Loaders
405 pango-querymodules | sed "s?$PANGOLIB/?@ROOTDIR@/?" > $Etc/pango.modules.in
406 gdk-pixbuf-query-loaders | sed "s?$GDKPIXBUFLIB/?@ROOTDIR@/?" > $Etc/gdk-pixbuf.loaders.in
408 # We sort of rely on clearlooks, so include a version
409 # this one is special - we will set GTK_PATH to $Libraries/clearlooks
411 if [ ! -e ${GTKLIB}/engines/libclearlooks.so ]; then
412 echo ""
413 echo "!!! ERROR !!! - not able to locate libclearlooks.so"
414 echo ""
415 echo "Packager with exit"
416 exit 1
419 echo "Copying clearlooks ..."
420 cp ${GTKLIB}/engines/libclearlooks.so $Libraries
421 mkdir -p $Libraries/clearlooks/engines
422 (cd $Libraries/clearlooks/engines && ln -s ../../libclearlooks* libclearlooks.so )
424 # LADSPA
425 if test x$WITH_LADSPA != x ; then
426 if test x$MIXBUS != x ; then
427 plugdir=mixbus_ladspa
428 else
429 plugdir=ladspa
431 echo "Copying `ls $plugdir | wc -l` plugins ..."
432 if [ -d $plugdir ] ; then
433 cp -r $plugdir/* $Plugins
437 # Control Surfaces
438 cp $BUILD_ROOT/libs/surfaces/*/libardour*.so* $Surfaces
439 # hack ... move libardour_cp back into Libraries
440 mv $Surfaces/libardourcp.so* $Libraries
442 # MidiMaps
443 # got to be careful with names here
444 for x in $BUILD_ROOT/../../midi_maps/*.map ; do
445 cp "$x" $MidiMaps
446 echo Copied MIDI map $x
447 done
449 # ExportFormats
450 # got to be careful with names here
451 for x in $BUILD_ROOT/../../export/*.preset $BUILD_ROOT/../../export/*.format ; do
452 cp "$x" $ExportFormats
453 done
455 # Panners
456 cp $BUILD_ROOT/libs/panners/*/lib*.so* $Panners
458 # VAMP plugins that we use
459 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.so* $Libraries
461 OURLIBDIR=$BUILD_ROOT/libs
462 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
464 echo $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
466 checkedIdx=0
467 deplibs=
469 while [ true ] ; do
470 missing=false
471 filelist=`find $APPLIB/ -type f`
472 filelist="$APPBIN/$MAIN_EXECUTABLE $filelist"
474 for file in $filelist ; do
475 if ! file $file | grep -qs ELF ; then
476 continue
479 # speed this up a bit by not checking things multiple times.
480 for i in "${depCheckedList[@]}"; do
481 if [ $i == $file ]; then
482 continue 2
484 done
485 depCheckedList[$checkIdx]=$file
486 checkIdx=$(($checkIdx + 1))
488 # do not include libjack
489 deps=`LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | awk '{print $3}'`
491 # LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | egrep "(/opt/|/local/|libs/|/usr/lib|/gtk)" | grep -v 'libjack\.'
492 echo -n "."
493 for dep in $deps ; do
494 if test "not" = ${dep}; then
495 echo ""
496 echo "!!! ERROR !!! - Missing dependant library for $file."
497 echo ""
498 (LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file)
499 echo ""
500 echo "!!! ERROR !!! - See Above"
501 exit 1
504 # don't use anything mapped at a specific address
505 if echo $dep | grep -qs '0x' ; then continue; fi
506 # don't include /lib
507 if echo $dep | grep -qs "^/lib/" ; then continue; fi
508 # don't include jack
509 if echo $dep | grep -qs libjack ; then continue; fi
510 # don't include any X Window libraries
511 if echo $dep | grep -qs libX ; then continue; fi
512 if echo $dep | grep -qs libxcb ; then continue; fi
513 # don't include libc
514 if echo $dep | grep -qs 'libc\.' ; then continue; fi
515 # don't include libstdc++
516 if echo $dep | grep -qs libstdc++ ; then continue; fi
518 base=`basename $dep`
519 if ! test -f $Libraries/$base; then
520 parent=$(basename ${file})
521 if echo $dep | grep -sq '^libs' ; then
522 echo "Copying dependant lib $BUILD_ROOT/$dep (required by ${parent})"
523 cp $BUILD_ROOT/$dep $Libraries
524 else
525 echo "Copying dependant lib $dep (required by ${parent})"
526 cp $dep $Libraries
528 if echo $dep | grep -sq '^/' ; then
529 # absolute path, candidate for stripping
530 deplibs="$deplibs $base"
532 missing=true
534 done
535 done
536 if test x$missing = xfalse ; then
537 # everything has been found
538 break
540 done
541 echo
543 # strip libraries
544 if test x$STRIP = xall ; then
545 echo Stripping all libraries
546 find $APPLIB/ -name "*.so*" | xargs strip
547 elif test x$STRIP = xsome ; then
548 echo Stripping dependent libraries
549 for l in $deplibs ; do
550 strip $APPLIB/$l
551 done
553 find $APPLIB/ -name "*.so*" | xargs chmod a+rx
555 echo "Copying other stuff to $APPDIR ..."
557 # these are all generated by waf
558 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Etc
559 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Etc
560 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc
561 cp $BUILD_ROOT/ardour_system.rc $Etc/ardour_system.rc
562 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_light.rc $Etc
563 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_dark.rc $Etc
565 # these are copied straight from the source tree
567 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui.conf
568 cp ../../instant.xml $Etc/instant.xml
569 cp -r ../../gtk2_ardour/icons $Etc
570 cp -r ../../gtk2_ardour/pixmaps $Etc
573 # put sooper sekrit ingredients here and they will be copied
576 if [ -d specialSauce ] ; then
577 cp -r specialSauce $Etc
580 # share stuff
582 cp -R ../../gtk2_ardour/splash.png $Shared
583 # currently no templates
584 #cp ../../templates/*.template $Shared/templates/
586 # go through and recursively remove any .svn dirs in the bundle
587 for svndir in `find $APPDIR -name .svn -type d`; do
588 rm -rf $svndir
589 done
592 # Add the uninstaller
594 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
595 chmod a+x $APPBIN/${APP_VER_NAME}.uninstall.sh
597 #Sanity Check file
598 if [ -e $BUILD_ROOT/tools/sanity_check/sanityCheck ]; then
599 cp $BUILD_ROOT/tools/sanity_check/sanityCheck $APPBIN
600 else
601 echo "!!!ERROR !!! sanityCheck program is missing. packager will exit without being complete"
602 exit 1
605 echo "Building tarball ..."
607 rm -f $APPDIR.tar.bz2
608 tar -cjf $APPDIR.tar.bz2 $APPDIR
610 echo "Calculating bundle size"
611 du -sb $APPDIR/ | awk '{print $1}' > $APPDIR.size
613 rm -rf $APPDIR/
615 echo "Done."