add qm-dsp lib dir to linux packaging script
[ardour2.git] / tools / linux_packaging / build
blob5f3eacfdde16257cb087c44e4d5a2cc270871fb6
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=1
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=1;
45 APPNAME=Mixbus ;
46 VENDOR=Harrison ;
47 shift ;;
48 --public)
49 WITH_NLS=1 ;
50 WITH_LADSPA=;
51 STRIP=1 ;
52 APPNAME=Ardour ;
53 shift ;;
54 --allinone)
55 WITH_NLS= ;
56 WITH_LADSPA=1;
57 STRIP=1;
58 shift ;;
59 --test) WITH_LADSPA=; STRIP= ; shift ;;
62 # specific build flags
65 --nojack) INTERNAL_JACK= ; shift ;;
66 --noladspa) WITH_LADSPA= ; shift ;;
67 --nostrip) STRIP= ; 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 release_version=`grep -m 1 '^VERSION' ../../wscript | awk '{print $3}' | sed "s/'//g"`
82 svn_version=`grep -m 1 'svn_revision =' ../../libs/ardour/svn_revision.cc | cut -d"'" -f 2`
83 echo "Version is $release_version / $svn_version"
84 info_string="$release_version/$svn_version built on `hostname` by `whoami` on `date`"
85 echo "Info string is $info_string"
87 # Figure out our CPU type
88 case `uname -m` in
89 i[3456789]86|x86|i86pc)
90 echo "Architecture is x86"
91 ARCH='x86'
92 ARCH_BITS='32-bit'
94 x86_64|amd64|AMD64)
95 echo "Architecture is x86_64"
96 ARCH='x86_64'
97 ARCH_BITS='64-bit'
100 echo ""
101 echo "ERROR - Unknown architecture `uname -m`"
102 echo ""
103 exit 1
105 esac
107 # Figure out the Build Type
108 if grep -q "DEBUG = True" ../../build/c4che/default.cache.py; then
109 DEBUG="T"
110 else
111 DEBUG="F"
114 if [ x$DEBUG != x ]; then
115 if [ x$STRIP != x ]; then
116 BUILDTYPE="strip"
117 else
118 BUILDTYPE="dbg"
122 # the waf build tree to use when copying built/generated files
124 BUILD_ROOT=../../build/default
126 # setup directory structure
128 if [ -z "${BUILDTYPE}" ]; then
129 APPDIR=${APPNAME}_${ARCH}-${release_version}_${svn_version}
130 APP_VER_NAME=${APPNAME}-${release_version}_${svn_version}
131 else
132 APPDIR=${APPNAME}_${ARCH}-${release_version}_${svn_version}-${BUILDTYPE}
133 APP_VER_NAME=${APPNAME}-${release_version}_${svn_version}-${BUILDTYPE}
136 APPBIN=$APPDIR/bin
137 APPLIB=$APPDIR/lib
138 Libraries=$APPLIB
139 Etc=$APPDIR/etc
140 Shared=$APPDIR/share
141 Plugins=$APPLIB/plugins
142 Surfaces=$APPLIB/surfaces
143 Panners=$APPLIB/panners
144 Locale=$Shared/locale
145 Modules=$Libraries/modules
146 Loaders=$Libraries/loaders
149 if [ x$PRINT_SYSDEPS != x ] ; then
151 # print system dependencies
154 for file in $APPBIN/* $Libraries/* $Modules/* $Plugins/*.so ; do
155 if ! file $file | grep -qs Mach-O ; then
156 continue
158 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
159 done | sort | uniq
160 exit 0
163 echo "Removing old $APPDIR tree ..."
164 rm -rf $APPDIR/
166 echo "Building new app directory structure ..."
168 # only bother to make the longest paths
170 mkdir -p $APPDIR
171 mkdir -p $APPBIN
172 mkdir -p $APPLIB
173 mkdir -p $Etc
174 mkdir -p $Plugins
175 mkdir -p $Modules
176 mkdir -p $Loaders
177 mkdir -p $Shared
178 mkdir -p $Locale
179 mkdir -p $Surfaces
180 mkdir -p $Panners
181 mkdir -p $Shared/templates
182 mkdir -p $Shared/doc
184 # maybe set variables
185 ENVIRONMENT=environment
186 rm -f $ENVIRONMENT
187 touch $ENVIRONMENT
189 if test x$MIXBUS != x ; then
190 echo export ARDOUR_MIXBUS=true >> $ENVIRONMENT
192 # current default for MIXBUS version is US keyboard layout without a keypad
194 echo export ARDOUR_KEYBOARD_LAYOUT=us-nokeypad >> $ENVIRONMENT
195 echo export ARDOUR_UI_CONF=ardour3_ui.conf >> $ENVIRONMENT
196 echo export ARDOUR3_UI_RC=ardour3_ui_dark.rc >> $ENVIRONMENT
200 # if we're not going to bundle JACK, make sure we can find
201 # jack in the places where it might be
204 echo export 'PATH=/usr/local/bin:/opt/bin:$PATH' >> $ENVIRONMENT
206 # create startup helper script
208 sed -e "/^%ENV%/r $ENVIRONMENT" -e '/^%ENV%/d' -e 's/%VER%/'"${release_version}"'/' < ardour.sh.in > $APPBIN/ardour3
209 rm $ENVIRONMENT && chmod 775 $APPBIN/ardour3
210 #MAIN_EXECUTABLE=ardour-$release_version
211 MAIN_EXECUTABLE=ardour-3.0
213 echo "Copying ardour executable ...."
214 cp $BUILD_ROOT/gtk2_ardour/$MAIN_EXECUTABLE $APPBIN
215 if test x$STRIP != x ; then
216 strip $APPBIN/$MAIN_EXECUTABLE
219 # copy locale files
220 # note that at present(feb 2011), the .mo files end up in the source tree which is
221 # not really as it should be.
222 if test x$WITH_NLS != x ; then
223 echo "NLS support ..."
224 echo "I hope you remembered to run scons msgupdate!"
225 LINGUAS=
226 files=`find ../../gtk2_ardour/ -name "*.mo"`
228 if [ -z "$files" ]; then
229 echo ""
230 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../gtk2_ardour"
231 echo ""
234 for file in $files
236 echo $file
237 lang=`basename $file | sed 's/\.mo//'`
238 mkdir -p $Locale/$lang/LC_MESSAGES
239 cp $file $Locale/$lang/LC_MESSAGES/gtk2_ardour.mo
240 LINGUAS="$LINGUAS $lang"
241 done
243 files=`find ../../libs/ardour/ -name "*.mo"`
245 if [ -z "$files" ]; then
246 echo ""
247 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../libs/ardour"
248 echo ""
251 for file in $files
253 echo $file
254 lang=`basename $file | sed 's/\.mo//'`
255 mkdir -p $Locale/$lang/LC_MESSAGES
256 cp $file $Locale/$lang/LC_MESSAGES/libardour.mo
257 done
259 GTK_MESSAGES="atk10.mo gdk-pixbuf.mo gtk20-properties.mo gtk20.mo atk10.mo glib20.mo"
260 LOCALEROOT=/usr/share/locale
262 for l in $LINGUAS ; do
263 echo "Copying GTK i18n files for $l..."
264 for MO in $GTK_MESSAGES ; do
265 if [ -f $LOCALEROOT/$l/LC_MESSAGES/$MO ] ; then
266 cp $LOCALEROOT/$l/LC_MESSAGES/$MO $Locale/$l/LC_MESSAGES
267 else
268 # try with just the language spec
269 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
270 if [ -f $LOCALEROOT/$just_lang/LC_MESSAGES/$MO ] ; then
271 cp $LOCALEROOT/$just_lang/LC_MESSAGES/$MO $Locale/$just_lang/LC_MESSAGES
274 done
275 done
276 else
277 echo "Skipping NLS support"
280 ### Find gtk ###
281 GTKROOT=`pkg-config --libs-only-L gtk+-2.0 | sed -e "s/-L//" -e "s/[[:space:]]//g"`
282 if [ ! -z "$GTKROOT" ]; then
283 echo "Found GTKROOT using pkg-config"
284 elif [ -d /usr/lib/gtk-2.0 ]; then
285 GTKROOT="/usr/lib"
286 elif [ -d /usr/local/lib/gtk-2.0 ]; then
287 GTKROOT="/usr/local/lib"
288 else
289 echo ""
290 echo "!!! ERROR !!! - Unable to locate gtk-2.0 directory. Packager will exit"
291 echo ""
292 exit 1
295 echo "GTKROOT is ${GTKROOT}"
296 versionDir=`ls ${GTKROOT}/gtk-2.0/ | grep "[0-9]*\.[0-9]*\.[0-9]*"`
298 num=0
299 for name in $versionDir ; do
300 num=$(($num + 1))
301 done
303 if [ $num -eq 1 ]; then
304 GTKLIB=${GTKROOT}/gtk-2.0/$versionDir
305 echo "GTKLIB is ${GTKLIB}"
306 else
307 echo ""
308 echo "!!! ERROR !!! - More than one gtk-2.0 version found in ${GTKROOT}/gtk-2.0/ ( $versionDir ). Packager will exit"
309 echo ""
310 exit 1
314 ### Find pango ###
315 PANGOROOT=`pkg-config --libs-only-L pango | sed -e "s/-L//" -e "s/[[:space:]]//g"`
316 if [ ! -z "$PANGOROOT" ]; then
317 echo "Found PANGOROOT using pkg-config"
318 elif [ -d /usr/lib/pango ]; then
319 PANGOROOT="/usr/lib"
320 elif [ -d /usr/local/lib/pango ]; then
321 PANGOROOT="/usr/local/lib"
322 else
323 echo ""
324 echo "!!! ERROR !!! - Unable to locate pango directory. Packager will exit"
325 echo ""
326 exit 1
329 echo "PANGOROOT is ${PANGOROOT}"
330 versionDir=`ls ${PANGOROOT}/pango/ | grep "[0-9]*\.[0-9]*\.[0-9]*"`
332 num=0
333 for name in $versionDir ; do
334 num=$(($num + 1))
335 done
337 if [ $num -eq 1 ]; then
338 PANGOLIB=${PANGOROOT}/pango/$versionDir
339 echo "PANGOLIB is ${PANGOLIB}"
340 else
341 echo ""
342 echo "!!! ERROR !!! - More than one pango version found in ${PANGOROOT}/pango/ ( $versionDir ). Packager will exit"
343 echo ""
344 exit 1
348 ### Find gdk-pixbuf ###
349 GDKPIXBUFROOT=`pkg-config --libs-only-L gdk-pixbuf-2.0 | sed -e "s/-L//" -e "s/[[:space:]]//g"`
350 if [ ! -z "$GDKPIXBUFROOT" ]; then
351 echo "Found GDKPIXBUFROOT using pkg-config"
352 elif [ -d /usr/lib/gdk-pixbuf-2.0 ]; then
353 GDKPIXBUFROOT="/usr/lib/gdk-pixbuf-2.0"
354 elif [ -d /usr/local/lib/gdk-pixbuf-2.0 ]; then
355 GDKPIXBUFROOT="/usr/local/lib/gdk-pixbuf-2.0"
356 elif [ -d ${GTKLIB}/loaders ]; then #odd ball case
357 GDKPIXBUFROOT=${GTKROOT}
358 GDKPIXBUFLIB=${GTKLIB}
359 else
360 echo ""
361 echo "!!! ERROR !!! - Unable to locate gdk-pixbuf-2.0 directory. Packager will exit"
362 echo ""
363 exit 1
366 echo "GDKPIXBUFROOT is ${GDKPIXBUFROOT}"
368 if [ -z ${GDKPIXBUFLIB} ]; then
369 versionDir=`ls ${GDKPIXBUFROOT}/gdk-pixbuf-2.0/ | grep "[0-9]*\.[0-9]*\.[0-9]*"`
371 num=0
372 for name in $versionDir ; do
373 num=$(($num + 1))
374 done
376 if [ $num -eq 1 ]; then
377 GDKPIXBUFLIB=${GDKPIXBUFROOT}/gdk-pixbuf-2.0/$versionDir
378 echo "GDKPIXBUFLIB is ${GDKPIXBUFLIB}"
379 else
380 echo ""
381 echo "!!! ERROR !!! - More than one gdk-pixbuf-2.0 version found in ${GDKPIXBUFROOT}/pango/ ( $versionDir ). Packager will exit"
382 echo ""
383 exit 1
389 echo "Copying all Pango modules ..."
390 cp -R $PANGOLIB/modules/*.so $Modules
392 echo "Copying all GDK Pixbuf loaders ..."
393 cp -R $GDKPIXBUFLIB/loaders/*.so $Loaders
395 pango-querymodules | sed "s?$PANGOLIB/?@ROOTDIR@/?" > $Etc/pango.modules.in
396 gdk-pixbuf-query-loaders | sed "s?$GDKPIXBUFLIB/?@ROOTDIR@/?" > $Etc/gdk-pixbuf.loaders.in
398 # We sort of rely on clearlooks, so include a version
399 # this one is special - we will set GTK_PATH to $Libraries/clearlooks
401 if [ ! -e ${GTKLIB}/engines/libclearlooks.so ]; then
402 echo ""
403 echo "!!! ERROR !!! - not able to locate libclearlooks.so"
404 echo ""
405 echo "Packager with exit"
406 exit 1
409 echo "Copying clearlooks ..."
410 cp ${GTKLIB}/engines/libclearlooks.so $Libraries
411 mkdir -p $Libraries/clearlooks/engines
412 (cd $Libraries/clearlooks/engines && ln -s ../../libclearlooks* libclearlooks.so )
414 # LADSPA
415 if test x$WITH_LADSPA != x ; then
416 if test x$MIXBUS != x ; then
417 plugdir=mixbus_ladspa
418 else
419 plugdir=ladspa
421 echo "Copying `ls $plugdir | wc -l` plugins ..."
422 if [ -d $plugdir ] ; then
423 cp -r $plugdir/* $Plugins
427 # Control Surfaces
428 cp $BUILD_ROOT/libs/surfaces/*/libardour*.so* $Surfaces
429 # hack ... move libardour_cp back into Libraries
430 mv $Surfaces/libardourcp.so* $Libraries
432 # Panners
433 cp $BUILD_ROOT/libs/panners/*/lib*.so* $Panners
435 # VAMP plugins that we use
436 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.so* $Libraries
438 OURLIBDIR=$BUILD_ROOT/libs
439 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
441 echo $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
443 checkedIdx=0
445 while [ true ] ; do
446 missing=false
447 filelist=`find $APPLIB/ -type f`
448 filelist="$APPBIN/$MAIN_EXECUTABLE $filelist"
450 for file in $filelist ; do
451 if ! file $file | grep -qs ELF ; then
452 continue
455 # speed this up a bit by not checking things multiple times.
456 for i in "${depCheckedList[@]}"; do
457 if [ $i == $file ]; then
458 continue 2
460 done
461 depCheckedList[$checkIdx]=$file
462 checkIdx=$(($checkIdx + 1))
464 # do not include libjack
465 deps=`LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | awk '{print $3}'`
467 # LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | egrep "(/opt/|/local/|libs/|/usr/lib|/gtk)" | grep -v 'libjack\.'
468 echo -n "."
469 for dep in $deps ; do
470 if test "not" = ${dep}; then
471 echo ""
472 echo "!!! ERROR !!! - Missing dependant library for $file."
473 echo ""
474 (LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file)
475 echo ""
476 echo "!!! ERROR !!! - See Above"
477 exit 1
480 # don't use anything mapped at a specific address
481 if echo $dep | grep -qs '0x' ; then continue; fi
482 # don't include /lib
483 if echo $dep | grep -qs "^/lib/" ; then continue; fi
484 # don't include jack
485 if echo $dep | grep -qs libjack ; then continue; fi
486 # don't include any X Window libraries
487 if echo $dep | grep -qs libX ; then continue; fi
488 if echo $dep | grep -qs libxcb ; then continue; fi
489 # don't include libc
490 if echo $dep | grep -qs 'libc\.' ; then continue; fi
491 # don't include libstdc++
492 if echo $dep | grep -qs libstdc++ ; then continue; fi
494 base=`basename $dep`
495 if ! test -f $Libraries/$base; then
496 parent=$(basename ${file})
497 if echo $dep | grep -sq '^libs' ; then
498 echo "Copying dependant lib $BUILD_ROOT/$dep (required by ${parent})"
499 cp $BUILD_ROOT/$dep $Libraries
500 else
501 echo "Copying dependant lib $dep (required by ${parent})"
502 cp $dep $Libraries
504 missing=true
506 done
507 done
508 if test x$missing = xfalse ; then
509 # everything has been found
510 break
512 done
513 echo
515 # strip libraries
516 if test x$STRIP != x ; then
517 echo Stripping libraries
518 find $APPLIB/ -name "*.so*" | xargs strip
520 find $APPLIB/ -name "*.so*" | xargs chmod a+rx
522 echo "Copying other stuff to $APPDIR ..."
524 # these are all generated by waf
525 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Etc
526 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Etc
527 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc
528 cp $BUILD_ROOT/ardour_system.rc $Etc/ardour_system.rc
529 # temporarily unavailable
530 #cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_light.rc $Etc
531 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_dark.rc $Etc
533 # these are copied straight from the source tree
535 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui.conf
536 cp ../../instant.xml $Etc/instant.xml
537 cp -r ../../gtk2_ardour/icons $Etc
538 cp -r ../../gtk2_ardour/pixmaps $Etc
541 # put sooper sekrit ingredients here and they will be copied
544 if [ -d specialSauce ] ; then
545 cp -r specialSauce $Etc
548 # share stuff
550 cp -R ../../gtk2_ardour/splash.png $Shared
551 # currently no templates
552 #cp ../../templates/*.template $Shared/templates/
554 # go through and recursively remove any .svn dirs in the bundle
555 for svndir in `find $APPDIR -name .svn -type d`; do
556 rm -rf $svndir
557 done
560 # Add the uninstaller
562 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
563 chmod a+x $APPBIN/${APP_VER_NAME}.uninstall.sh
565 #Sanity Check file
566 if [ -e $BUILD_ROOT/tools/sanity_check/sanityCheck ]; then
567 cp $BUILD_ROOT/tools/sanity_check/sanityCheck $APPBIN
568 else
569 echo "!!!ERROR !!! sanityCheck program is missing. packager will exit without being complete"
570 exit 1
573 echo "Building tarball ..."
575 rm -f $APPDIR.tar.bz2
576 tar -cjf $APPDIR.tar.bz2 $APPDIR
578 rm -rf $APPDIR/
580 echo "Done."