linux packaging fixes for a3 build
[ardour2.git] / tools / linux_packaging / build
blob85e4ec109d633038f6b00e1e716f63e0a4432107
1 #!/bin/bash
5 . ./buildenv
7 # script for pulling together a Linux app bundle.
9 MIXBUS=
10 INTERNAL_JACK=1
11 WITH_LADSPA=0
12 STRIP=1
13 PRINT_SYSDEPS=
14 WITH_NLS=
15 EXTERNAL_JACK=
17 if [ $# -eq 0 ] ; then
18 echo ""
19 echo "ERROR - Please specify build type"
20 echo " --public"
21 echo " --mixbus"
22 echo ""
23 exit 1
26 while [ $# -gt 0 ] ; do
27 echo "arg = $1"
28 case $1 in
31 # top level build targets
34 --mixbus)
35 MIXBUS=1;
36 WITH_NLS=1 ;
37 INTERNAL_JACK=;
38 WITH_LADSPA=;
39 STRIP= ;
40 APPNAME=Mixbus ;
41 shift ;;
42 --public)
43 WITH_NLS=1 ;
44 INTERNAL_JACK=;
45 WITH_LADSPA=;
46 STRIP= ;
47 APPNAME=Ardour ;
48 shift ;;
49 --allinone)
50 WITH_NLS= ;
51 INTERNAL_JACK=1;
52 WITH_LADSPA=1;
53 STRIP= ;
54 shift ;;
55 --test) INTERNAL_JACK=; WITH_LADSPA=; STRIP= ; shift ;;
58 # specific build flags
61 --nojack) INTERNAL_JACK= ; shift ;;
62 --noladspa) WITH_LADSPA= ; shift ;;
63 --nostrip) STRIP= ; shift ;;
64 --sysdeps) PRINT_SYSDEPS=1; shift ;;
65 --nls) WITH_NLS=1 ; shift ;;
66 --external_jack) EXTERNAL_JACK=$2; shift ; shift ;;
69 #catch all for unknown arguments
70 echo ""
71 echo "!!! ERROR !!! - Unknown argument $1"
72 echo ""
73 exit 1
75 esac
76 done
78 if [ x$EXTERNAL_JACK != x -a x$INTERNAL_JACK != x ] ; then
79 echo "It makes no sense to package JACK internally and externally. Please pick one."
82 release_version=`grep -m 1 '^VERSION' ../../wscript | awk '{print $3}' | sed "s/'//g"`
83 svn_version=`grep -m 1 'svn_revision =' ../../libs/ardour/svn_revision.cc | cut -d"'" -f 2`
84 echo "Version is $release_version / $svn_version"
85 info_string="$release_version/$svn_version built on `hostname` by `whoami` on `date`"
86 echo "Info string is $info_string"
88 # Figure out our CPU type
89 case `uname -m` in
90 i[3456789]86|x86|i86pc)
91 echo "Architecture is x86"
92 ARCH='x86'
93 ARCH_BITS='32-bit'
95 x86_64|amd64|AMD64)
96 echo "Architecture is x86_64"
97 ARCH='x86_64'
98 ARCH_BITS='64-bit'
101 echo ""
102 echo "ERROR - Unknown architecture `uname -m`"
103 echo ""
104 exit 1
106 esac
108 # the waf build tree to use when copying built/generated files
110 BUILD_ROOT=../../build/default
112 # setup directory structure
114 APPDIR=${APPNAME}_${ARCH}-${release_version}_${svn_version}
115 APPBIN=$APPDIR/bin
116 APPLIB=$APPDIR/lib
117 Libraries=$APPLIB
118 Etc=$APPDIR/etc
119 Shared=$APPDIR/share
120 Plugins=$APPLIB/plugins
121 Surfaces=$APPLIB/surfaces
122 Panners=$APPLIB/panners
123 Locale=$Shared/locale
124 Modules=$Libraries/modules
125 Loaders=$Libraries/loaders
128 if [ x$PRINT_SYSDEPS != x ] ; then
130 # print system dependencies
133 for file in $APPBIN/* $Libraries/* $Modules/* $Plugins/*.so ; do
134 if ! file $file | grep -qs Mach-O ; then
135 continue
137 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
138 done | sort | uniq
139 exit 0
142 echo "Removing old $APPDIR tree ..."
143 rm -rf $APPDIR/
145 echo "Building new app directory structure ..."
147 # only bother to make the longest paths
149 mkdir -p $APPDIR
150 mkdir -p $APPBIN
151 mkdir -p $APPLIB
152 mkdir -p $Etc
153 mkdir -p $Plugins
154 mkdir -p $Modules
155 mkdir -p $Loaders
156 mkdir -p $Shared
157 mkdir -p $Locale
158 mkdir -p $Surfaces
159 mkdir -p $Panners
160 mkdir -p $Shared/templates
162 # maybe set variables
163 ENVIRONMENT=environment
164 rm -f $ENVIRONMENT
165 touch $ENVIRONMENT
167 if test x$MIXBUS != x ; then
168 echo export ARDOUR_MIXBUS=true >> $ENVIRONMENT
170 # current default for MIXBUS version is US keyboard layout without a keypad
172 echo export ARDOUR_KEYBOARD_LAYOUT=us-nokeypad >> $ENVIRONMENT
173 echo export ARDOUR_UI_CONF=ardour2_ui.conf >> $ENVIRONMENT
174 echo export ARDOUR2_UI_RC=ardour2_ui_dark.rc >> $ENVIRONMENT
178 # if we're not going to bundle JACK, make sure we can find
179 # jack in the places where it might be
182 echo export 'PATH=/usr/local/bin:/opt/bin:$PATH' >> $ENVIRONMENT
184 # create startup helper script
186 sed -e "/^%ENV%/r $ENVIRONMENT" -e '/^%ENV%/d' -e 's/%VER%/'"${release_version}"'/' < ardour.sh.in > $APPBIN/ardour2
187 rm $ENVIRONMENT && chmod 775 $APPBIN/ardour2
188 MAIN_EXECUTABLE=ardour-$release_version
190 echo "Copying ardour executable ...."
191 cp ../../gtk2_ardour/$MAIN_EXECUTABLE $APPBIN
192 if test x$STRIP != x ; then
193 strip $APPBIN/$MAIN_EXECUTABLE
196 # copy locale files
197 if test x$WITH_NLS != x ; then
198 echo "NLS support ..."
199 echo "I hope you remembered to run scons msgupdate!"
200 LINGUAS=
201 files=`find ../../gtk2_ardour/ -name "*.mo"`
203 if [ -z "$files" ]; then
204 echo ""
205 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../gtk2_ardour"
206 echo ""
209 for file in $files
211 echo $file
212 lang=`basename $file | sed 's/\.mo//'`
213 mkdir -p $Locale/$lang/LC_MESSAGES
214 cp $file $Locale/$lang/LC_MESSAGES/gtk2_ardour.mo
215 LINGUAS="$LINGUAS $lang"
216 done
218 files=`find ../../libs/ardour/ -name "*.mo"`
220 if [ -z "$files" ]; then
221 echo ""
222 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../libs/ardour"
223 echo ""
226 for file in $files
228 echo $file
229 lang=`basename $file | sed 's/\.mo//'`
230 mkdir -p $Locale/$lang/LC_MESSAGES
231 cp $file $Locale/$lang/LC_MESSAGES/libardour.mo
232 done
234 GTK_MESSAGES="atk10.mo gdk-pixbuf.mo gtk20-properties.mo gtk20.mo atk10.mo glib20.mo"
235 LOCALEROOT=/usr/share/locale
237 for l in $LINGUAS ; do
238 echo "Copying GTK i18n files for $l..."
239 for MO in $GTK_MESSAGES ; do
240 if [ -f $LOCALEROOT/$l/LC_MESSAGES/$MO ] ; then
241 cp $LOCALEROOT/$l/LC_MESSAGES/$MO $Locale/$l/LC_MESSAGES
242 else
243 # try with just the language spec
244 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
245 if [ -f $LOCALEROOT/$just_lang/LC_MESSAGES/$MO ] ; then
246 cp $LOCALEROOT/$just_lang/LC_MESSAGES/$MO $Locale/$just_lang/LC_MESSAGES
249 done
250 done
251 else
252 echo "Skipping NLS support"
255 ### Find gtk ###
256 GTKROOT=`pkg-config --libs-only-L gtk+-2.0 | sed -e "s/-L//" -e "s/[[:space:]]//g"`
257 if [ ! -z "$GTKROOT" ]; then
258 echo "Found GTKROOT using pkg-config"
259 elif [ -d /usr/lib/gtk-2.0 ]; then
260 GTKROOT="/usr/lib/gtk-2.0"
261 elif [ -d /usr/local/lib/gtk-2.0 ]; then
262 GTKROOT="/usr/local/lib/gtk-2.0"
263 else
264 echo ""
265 echo "!!! ERROR !!! - Unable to locate gtk-2.0 directory. Packager will exit"
266 echo ""
267 exit 1
270 echo "GTKROOT is ${GTKROOT}"
271 versionDir=`ls ${GTKROOT}/gtk-2.0/ | grep "[0-9]*\.[0-9]*\.[0-9]*"`
273 num=0
274 for name in $versionDir ; do
275 let "num += 1"
276 done
278 if [ $num -eq 1 ]; then
279 GTKLIB=${GTKROOT}/gtk-2.0/$versionDir
280 echo "GTKLIB is ${GTKLIB}"
281 else
282 echo ""
283 echo "!!! ERROR !!! - More than one gtk-2.0 version found in ${GTKROOT}/gtk-2.0/ ( $versionDir ). Packager will exit"
284 echo ""
285 exit 1
289 ### Find pango ###
290 PANGOROOT=`pkg-config --libs-only-L pango | sed -e "s/-L//" -e "s/[[:space:]]//g"`
291 if [ ! -z "$PANGOROOT" ]; then
292 echo "Found PANGOROOT using pkg-config"
293 elif [ -d /usr/lib/pango ]; then
294 PANGOROOT="/usr/lib/pango"
295 elif [ -d /usr/local/lib/pango ]; then
296 PANGOROOT="/usr/local/lib/pango"
297 else
298 echo ""
299 echo "!!! ERROR !!! - Unable to locate pango directory. Packager will exit"
300 echo ""
301 exit 1
304 echo "PANGOROOT is ${PANGOROOT}"
305 versionDir=`ls ${PANGOROOT}/pango/ | grep "[0-9]*\.[0-9]*\.[0-9]*"`
307 num=0
308 for name in $versionDir ; do
309 let "num += 1"
310 done
312 if [ $num -eq 1 ]; then
313 PANGOLIB=${PANGOROOT}/pango/$versionDir
314 echo "PANGOLIB is ${PANGOLIB}"
315 else
316 echo ""
317 echo "!!! ERROR !!! - More than one pango version found in ${PANGOROOT}/pango/ ( $versionDir ). Packager will exit"
318 echo ""
319 exit 1
323 ### Find gdk-pixbuf ###
324 GDKPIXBUFROOT=`pkg-config --libs-only-L gdk-pixbuf-2.0 | sed -e "s/-L//" -e "s/[[:space:]]//g"`
325 if [ ! -z "$GDKPIXBUFROOT" ]; then
326 echo "Found GDKPIXBUFROOT using pkg-config"
327 elif [ -d /usr/lib/gdk-pixbuf-2.0 ]; then
328 GDKPIXBUFROOT="/usr/lib/gdk-pixbuf-2.0"
329 elif [ -d /usr/local/lib/gdk-pixbuf-2.0 ]; then
330 GDKPIXBUFROOT="/usr/local/lib/gdk-pixbuf-2.0"
331 elif [ -d ${GTKLIB}/loaders ]; then #odd ball case
332 GDKPIXBUFROOT=${GTKROOT}
333 GDKPIXBUFLIB=${GTKLIB}
334 else
335 echo ""
336 echo "!!! ERROR !!! - Unable to locate gdk-pixbuf-2.0 directory. Packager will exit"
337 echo ""
338 exit 1
341 echo "GDKPIXBUFROOT is ${GDKPIXBUFROOT}"
343 if [ -z ${GDKPIXBUFLIB} ]; then
344 versionDir=`ls ${GDKPIXBUFROOT}/gdk-pixbuf-2.0/ | grep "[0-9]*\.[0-9]*\.[0-9]*"`
346 num=0
347 for name in $versionDir ; do
348 let "num += 1"
349 done
351 if [ $num -eq 1 ]; then
352 GDKPIXBUFLIB=${GDKPIXBUFROOT}/gdk-pixbuf-2.0/$versionDir
353 echo "GDKPIXBUFLIB is ${GDKPIXBUFLIB}"
354 else
355 echo ""
356 echo "!!! ERROR !!! - More than one gdk-pixbuf-2.0 version found in ${GDKPIXBUFROOT}/pango/ ( $versionDir ). Packager will exit"
357 echo ""
358 exit 1
364 echo "Copying all Pango modules ..."
365 cp -R $PANGOLIB/modules/*.so $Modules
367 echo "Copying all GDK Pixbuf loaders ..."
368 cp -R $GDKPIXBUFLIB/loaders/*.so $Loaders
370 pango-querymodules | sed "s?$PANGOLIB/?@ROOTDIR@/?" > $Etc/pango.modules.in
371 gdk-pixbuf-query-loaders | sed "s?$GDKPIXBUFLIB/?@ROOTDIR@/?" > $Etc/gdk-pixbuf.loaders.in
373 # We sort of rely on clearlooks, so include a version
374 # this one is special - we will set GTK_PATH to $Libraries/clearlooks
376 #if [ ! -e ${GTKLIB}/engines/libclearlooks.so ]; then
377 # echo ""
378 # echo "!!! ERROR !!! - not able to locate libclearlooks.so"
379 # echo ""
380 # echo "Packager with exit"
381 # exit 1
384 #echo "Copying clearlooks ..."
385 #cp ${GTKLIB}/engines/libclearlooks.so $Libraries
386 #mkdir -p $Libraries/clearlooks/engines
387 #(cd $Libraries/clearlooks/engines && ln -s ../../libclearlooks* libclearlooks.so )
389 # LADSPA
390 if test x$WITH_LADSPA != x ; then
391 if test x$MIXBUS != x ; then
392 plugdir=mixbus_ladspa
393 else
394 plugdir=ladspa
396 echo "Copying `ls $plugdir | wc -l` plugins ..."
397 if [ -d $plugdir ] ; then
398 cp -r $plugdir/* $Plugins
402 # XXX STILL NEED TO DO PANNERS FOR TRUNK
403 cp ../../libs/surfaces/*/libardour_*.so* $Surfaces
404 # hack ... move libardour_cp back into Libraries
405 mv $Surfaces/libardour_cp.so* $Libraries
407 # VAMP plugins that we use
408 cp ../../libs/vamp-plugins/libardourvampplugins.so* $Libraries
410 OURLIBDIR=../../libs
411 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
413 echo $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
415 checkedIdx=0
417 while [ true ] ; do
418 missing=false
419 filelist=`find $APPLIB/ -type f`
420 filelist="$APPBIN/$MAIN_EXECUTABLE $filelist"
422 for file in $filelist ; do
423 if ! file $file | grep -qs ELF ; then
424 continue
427 # speed this up a bit by not checking things multiple times.
428 for i in "${depCheckedList[@]}"; do
429 if [ $i == $file ]; then
430 continue 2
432 done
433 depCheckedList[$checkIdx]=$file
434 let "checkIdx += 1"
436 # do not include libjack
437 deps=`LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | awk '{print $3}'`
439 # LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | egrep "(/opt/|/local/|libs/|/usr/lib|/gtk)" | grep -v 'libjack\.'
440 echo -n "."
441 for dep in $deps ; do
442 if test "not" = ${dep}; then
443 echo ""
444 echo "!!! ERROR !!! - Missing dependant library for $file."
445 echo ""
446 (LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file)
447 echo ""
448 echo "!!! ERROR !!! - See Above"
449 exit 1
452 # don't use anything mapped at a specific address
453 if echo $dep | grep -qs '0x' ; then continue; fi
454 # don't include /lib
455 if echo $dep | grep -qs "^/lib/" ; then continue; fi
456 # don't include jack
457 if echo $dep | grep -qs libjack ; then continue; fi
458 # don't include any X Window libraries
459 if echo $dep | grep -qs libX ; then continue; fi
460 if echo $dep | grep -qs libxcb ; then continue; fi
461 # don't include libc
462 if echo $dep | grep -qs 'libc\.' ; then continue; fi
463 # don't include libstdc++
464 if echo $dep | grep -qs libstdc++ ; then continue; fi
466 base=`basename $dep`
467 if ! test -f $Libraries/$base; then
468 parent=$(basename ${file})
469 if echo $dep | grep -sq '^libs' ; then
470 echo "Copying dependant lib ../../$dep (required by ${parent})"
471 cp ../../$dep $Libraries
472 else
473 echo "Copying dependant lib $dep (required by ${parent})"
474 cp $dep $Libraries
476 missing=true
478 done
479 done
480 if test x$missing = xfalse ; then
481 # everything has been found
482 break
484 done
485 echo
487 # strip libraries
488 echo Stripping libraries
489 find $APPLIB/ -name "*.so*" | xargs strip
490 find $APPLIB/ -name "*.so*" | xargs chmod a+rx
492 echo "Copying other stuff to $APPDIR ..."
494 # these are all generated by waf
495 #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Etc
496 cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Etc
497 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc
498 cp $BUILD_ROOT/ardour_system.rc $Etc/ardour_system.rc
499 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_light.rc $Etc
500 cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_dark.rc $Etc
502 # these are copied straight from the source tree
504 cp ../../gtk2_ardour/ardour3_ui_default.conf $Etc/ardour3_ui.conf
505 cp ../../instant.xml $Etc/instant.xml
506 cp -r ../../gtk2_ardour/icons $Etc
507 cp -r ../../gtk2_ardour/pixmaps $Etc
510 # put sooper sekrit ingredients here and they will be copied
513 if [ -d specialSauce ] ; then
514 cp -r specialSauce $Etc
517 # share stuff
519 cp -R ../../gtk2_ardour/splash.png $Shared
520 cp ../../templates/*.template $Shared/templates/
522 # go through and recursively remove any .svn dirs in the bundle
523 for svndir in `find $APPDIR -name .svn -type d`; do
524 rm -rf $svndir
525 done
527 #Sanity Check file
528 if [ -e $BUILD_ROOT/tools/sanity_check/sanityCheck ]; then
529 cp $BUILD_ROOT/tools/sanity_check/sanityCheck $APPDIR
530 else
531 echo "!!!ERROR !!! sanityCheck program is missing. packager will exit without being complete"
532 exit 1
536 # and now ... the final package
539 if [ x$MIXBUS != x ] ; then
541 # Mixbus packaging
543 echo "Creating Mixbus packaging directory"
544 cp MixBus_Install_QuickStart.pdf "$APPDIR/Mixbus Install & Quick Start Guide.pdf"
546 if [ -x $EXTERNAL_JACK != x ] ; then
547 cp $EXTERNAL_JACK $PRODUCT_PKG_DIR
551 echo "Building tarball ..."
553 rm -f $APPDIR.tar.bz2
554 tar -cjf $APPDIR.tar.bz2 $APPDIR
556 echo "Done."