add mixer actions for toggle disk & input monitoring; bind to d and i in mixer bindings
[ardour.git] / tools / linux_packaging / build
1 #!/bin/bash
2
3 # script for pulling together a Linux app bundle.
4 #
5 # This will create a bundle for a single architecture.
6 # Execute this scirpt on both x86 and x86_64 and then use
7 # package to merge the 2 bundles into a final package with the
8 # installer. See "noderun" for a complete build script.
9
10 # where the GTK stack is installed
11 GTKSTACK_ROOT=$HOME/gtk/inst
12 # where the Ardour dependencies are installed
13 ARDOURSTACK_ROOT=$HOME/a3/inst
14 # the waf build tree to use when copying built/generated files
15 BUILD_ROOT=../../build
16
17 . ../define_versions.sh
18
19 # where harvid and xjadeo binaries are cached
20 if test -z "$CACHEDIR" -o ! -d "$CACHEDIR"; then
21         CACHEDIR=`pwd`
22 fi
23
24 MIXBUS=
25 WITH_HARRISON_LV2=
26 WITH_X42_LV2=
27 WITH_HARVID=
28 STRIP=all
29 PRINT_SYSDEPS=
30 WITH_NLS=
31 EXTERNAL_JACK=
32 VENDOR=Ardour ;
33 EXENAME=ardour
34 GCC5ABI=false
35 USEWINE=false
36 BUILDTYPE=""
37 NOSTRIP="libsuil|libserd|libsord|liblilv|libsratom|liblrdf|libardour|libpbd|libevoral"
38
39 : ${HARRISONCHANNELSTRIP=harrison_channelstrip}
40 : ${HARRISONLV2=harrison_lv2s-n}
41 : ${HARRISONDSPURL=http://www.harrisonconsoles.com/plugins/releases/public}
42
43 if [ $# -eq 0 ] ; then
44         echo ""
45         echo "ERROR - Please specify build type"
46         echo "    --public"
47         echo "    --mixbus"
48         echo ""
49         exit 1
50 fi
51
52 while [ $# -gt 0 ] ; do
53         echo "arg = $1"
54         case $1 in
55
56         #
57         # top level build targets
58         #
59
60         --mixbus)
61                 MIXBUS=1;
62                 WITH_HARRISON_LV2=1 ;
63                 WITH_X42_LV2=1 ;
64                 WITH_NLS=1 ;
65                 STRIP=all
66                 APPNAME=Mixbus ;
67                 VENDOR=Harrison ;
68                 EXENAME=mixbus ;
69                 shift ;;
70         --mixbus32c)
71                 MIXBUS=1;
72                 WITH_HARRISON_LV2=1 ;
73                 WITH_X42_LV2=1 ;
74                 WITH_NLS=1 ;
75                 STRIP=all
76                 APPNAME=Mixbus32C ;
77                 VENDOR=Harrison ;
78                 EXENAME=mixbus32c ;
79                 major_version=""
80                 shift ;;
81         --public)
82                 WITH_HARRISON_LV2=1 ;
83                 WITH_NLS=1 ;
84                 STRIP=all ;
85                 APPNAME=Ardour ;
86                 shift ;;
87         --allinone)
88                 WITH_NLS= ;
89                 STRIP=all;
90                 shift ;;
91         --test) STRIP= ; shift ;;
92
93         #
94         # specific build flags
95         #
96
97         --nojack) INTERNAL_JACK= ; shift ;;
98         --strip) STRIP=$2 ; shift ; shift ;;
99         --sysdeps) PRINT_SYSDEPS=1; shift ;;
100         --nls) WITH_NLS=1 ; shift ;;
101         --harvid) WITH_HARVID=1 ; shift ;;
102         --gcc5abi) GCC5ABI=true ; shift ;;
103         --chanstrip) HARRISONCHANNELSTRIP=$2 ; shift; shift ;;
104
105         *)
106                 #catch all for unknown arguments
107                 echo ""
108                 echo "!!! ERROR !!! - Unknown argument $1"
109                 echo ""
110                 exit 1
111                 ;;
112         esac
113 done
114
115 if test x$STRIP != xall -a x$STRIP != xnone -a x$STRIP != xsome ; then
116     echo "Unknown strip option \"$STRIP\""
117     echo "Legal values are: all, none, some"
118     exit 1
119 fi
120
121 . ../define_versions.sh
122 lower_case_appname=`echo $APPNAME | tr '[:upper:]' '[:lower:]'`
123
124 echo "Version is $release_version"
125 if [ "x$commit" != "x" ] ; then
126     info_string="$release_version ($commit) built on `hostname` by `whoami` on `date`"
127 else
128     info_string="$release_version built on `hostname` by `whoami` on `date`"
129 fi
130 echo "Info string is $info_string"
131
132 # Figure out our CPU type
133 case `uname -m` in
134         i[3456789]86|x86|i86pc)
135                 echo "Architecture is x86"
136                 ARCH='x86'
137                 WARCH='i386'
138                 HARCH='linux32'
139                 ARCH_BITS='32-bit'
140                 MULTIARCH='i386-linux-gnu'
141                 ;;
142         x86_64|amd64|AMD64)
143                 echo "Architecture is x86_64"
144                 ARCH='x86_64'
145                 WARCH='x86_64'
146                 HARCH='linux64'
147                 ARCH_BITS='64-bit'
148                 MULTIARCH='x86_64-linux-gnu'
149                 ;;
150         *)
151                 echo ""
152                 echo "ERROR - Unknown architecture `uname -m`"
153                 echo ""
154                 exit 1
155                 ;;
156 esac
157
158 if [ x$DEBUG = xT ]; then
159     BUILDTYPE="dbg"
160     if [ x$STRIP = xall ] ; then
161         echo "A debug build with --strip all makes no sense - STRIP reset to \"some\""
162         STRIP=some
163     fi
164 fi
165
166 # setup directory structure
167
168 if [ -z "${BUILDTYPE}" ]; then
169         APPDIR=${APPNAME}_${ARCH}-${release_version}
170         APP_VER_NAME=${APPNAME}-${release_version}
171 else
172         APPDIR=${APPNAME}_${ARCH}-${release_version}-${BUILDTYPE}
173         APP_VER_NAME=${APPNAME}-${release_version}-${BUILDTYPE}
174 fi
175
176 APPBIN=$APPDIR/bin
177 APPLIB=$APPDIR/lib
178 Libraries=$APPLIB
179 Etc=$APPDIR/etc
180 Shared=$APPDIR/share
181
182 Plugins=$APPLIB/plugins
183 Surfaces=$APPLIB/surfaces
184 Panners=$APPLIB/panners
185 Backends=$APPLIB/backends
186
187 Themes=$Shared/themes
188 Templates=$Shared/templates
189 PluginMetadata=$Shared/plugin_metadata
190 MixerSettings=$Shared/mixer_settings
191 ExportFormats=$Shared/export
192 Locale=$Shared/locale
193 MidiMaps=$Shared/midi_maps
194 PatchFiles=$Shared/patchfiles
195 LuaScripts=$Shared/scripts
196 MackieControl=$Shared/mcp
197 OSC=$Shared/osc
198
199 if [ x$PRINT_SYSDEPS != x ] ; then
200 #
201 # print system dependencies
202 #
203
204         for file in $APPBIN/* $Libraries/* $Plugins/*.so ; do
205                 if ! file $file | grep -qs Mach-O ; then
206                         continue
207                 fi
208                 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
209         done | sort | uniq
210         exit 0
211 fi
212
213 echo "Removing old $APPDIR tree ..."
214 rm -rf $APPDIR/
215
216 echo "Building new app directory structure ..."
217
218 # only bother to make the longest paths
219
220 mkdir -p $APPDIR
221 mkdir -p $APPBIN
222 mkdir -p $APPLIB
223 mkdir -p $Etc
224 mkdir -p $Shared
225 mkdir -p $Themes
226 mkdir -p $Locale
227 mkdir -p $Surfaces
228 mkdir -p $MidiMaps
229 mkdir -p $PatchFiles
230 mkdir -p $LuaScripts
231 mkdir -p $MackieControl
232 mkdir -p $OSC
233 mkdir -p $ExportFormats
234 mkdir -p $Panners
235 mkdir -p $Backends
236 mkdir -p $Shared/doc
237
238 # maybe set variables
239 ENVIRONMENT=environment
240 rm -f $ENVIRONMENT
241 touch $ENVIRONMENT
242
243 if test x$MIXBUS != x ; then
244         echo export ARDOUR_MIXBUS=true >> $ENVIRONMENT
245         #
246         # current default for MIXBUS version is US keyboard layout without a keypad
247         #
248         echo export ARDOUR_KEYBOARD_LAYOUT=us-nokeypad >> $ENVIRONMENT
249         echo export ARDOUR_UI_CONF=ardour3_ui.conf >> $ENVIRONMENT
250 fi
251
252 #
253 # if we're not going to bundle JACK, make sure we can find
254 # jack in the places where it might be
255 #
256
257 echo export 'PATH="/usr/local/bin:/opt/bin:$PATH"' >> $ENVIRONMENT
258
259 # create startup helper script
260 if test -d $BUILD_ROOT/vst; then
261         WINEEXE=wine
262         USEWINE=true
263         echo export INSTALL_DIR >> $ENVIRONMENT
264 else
265         WINEEXE=
266 fi
267
268 sed -e "/^%ENV%/r $ENVIRONMENT" -e '/^%ENV%/d' -e 's/%VER%/'"${release_version}"'/;s/%EXENAME%/'"${EXENAME}"'/;s/%WINE%/'"$WINEEXE"'/' < ardour.sh.in > $APPBIN/${EXENAME}${major_version}
269 rm $ENVIRONMENT && chmod 775 $APPBIN/${EXENAME}${major_version}
270
271 echo "Copying ardour executable ...."
272 if test -d $BUILD_ROOT/vst; then
273         #cp -v $BUILD_ROOT/gtk2_ardour/libgtk2_ardour.so $APPLIB/
274         cp -v $BUILD_ROOT/gtk2_ardour/ardour-${release_version}-vst.exe.so $APPBIN/${EXENAME}-${release_version}
275 else
276         cp -v $BUILD_ROOT/gtk2_ardour/ardour-${release_version}* $APPBIN/${EXENAME}-${release_version}
277 fi
278
279 if test x$STRIP = xall ; then
280         strip -s $APPBIN/${EXENAME}-${release_version}
281 fi
282
283 # copy locale files
284 # note that at present(feb 2011), the .mo files end up in the source tree which is
285 # not really as it should be.
286 if test x$WITH_NLS != x ; then
287         echo "NLS support ..."
288         echo "I hope you remembered to run scons msgupdate!"
289         LINGUAS=
290
291         for pkg in gtk2_ardour libs/ardour libs/gtkmm2ext ; do
292             files=`find ../../$pkg -name "*.mo"`
293
294             #
295             # the package name is appended with a number so that
296             # it can be parallel installed during a regular install
297             # with older (and newer) versions. it is just the major
298             # number of the release (i.e. leading digits)
299             #
300
301             vsuffix=`echo $release_version | sed 's/^\([0-9][0-9]*\).*/\1/'`
302
303             if [ -z "$files" ]; then
304                 echo ""
305                 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$pkg"
306                 echo ""
307             fi
308
309             for file in $files
310             do
311                 echo $file
312                 lang=`basename $file | sed 's/\.mo//'`
313                 mkdir -p $Locale/$lang/LC_MESSAGES
314                 cp $file $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
315                 echo copy $file to $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
316                 if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
317                     :
318                 else
319                     LINGUAS="$LINGUAS $lang"
320                 fi
321             done
322         done
323
324         GTK_MESSAGES="atk10.mo gdk-pixbuf.mo gtk20-properties.mo gtk20.mo atk10.mo glib20.mo"
325         LOCALEROOT=$GTKSTACK_ROOT/share/locale
326
327         for l in $LINGUAS ; do
328                 echo "Copying GTK i18n files for $l..."
329                 for MO in $GTK_MESSAGES ; do
330                         if [ -f $LOCALEROOT/$l/LC_MESSAGES/$MO ] ; then
331                                 cp $LOCALEROOT/$l/LC_MESSAGES/$MO $Locale/$l/LC_MESSAGES
332                         else
333                                 # try with just the language spec
334                                 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
335                                 if [ -f $LOCALEROOT/$just_lang/LC_MESSAGES/$MO ] ; then
336                                         cp $LOCALEROOT/$just_lang/LC_MESSAGES/$MO $Locale/$just_lang/LC_MESSAGES
337                                 fi
338                         fi
339                 done
340         done
341 else
342         echo "Skipping NLS support"
343 fi
344
345 # We rely on clearlooks, so include a version from our own build tree
346 # this one is special - we will set GTK_PATH to $Libraries/gtkengines
347
348 GTK_ENGINE_DIR=$Libraries/gtkengines/engines
349 mkdir -p $GTK_ENGINE_DIR
350
351 echo "Copying GTK engines ..."
352 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.so $Libraries
353 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.so . )
354
355 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Libraries
356 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so . )
357
358 # Control Surfaces
359 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.so* $Surfaces
360 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp.so* $Libraries
361
362 # MidiMaps
363 # got to be careful with names here
364 for x in $BUILD_ROOT/../midi_maps/*.map ; do
365     cp "$x" $MidiMaps
366 done
367
368 # MIDNAM Patch Files
369 # got to be careful with names here
370 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
371     cp "$x" $PatchFiles
372 done
373
374 # Lua Scripts Files
375 # got to be careful with names here
376 for x in $BUILD_ROOT/../scripts/*.lua ; do
377                 BN=$(basename $x)
378           if test "${BN:0:1}" = "_"; then
379                         continue;
380                 fi
381     cp "$x" $LuaScripts
382 done
383
384 # MackieControl data
385 # got to be careful with names here
386 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
387     cp "$x" $MackieControl
388 done
389
390 # OSC data
391 # got to be careful with names here
392 for x in $BUILD_ROOT/../osc/*.preset ; do
393     cp "$x" $OSC
394 done
395
396 # Mixbus MixerSettings (if any)
397 for x in $BUILD_ROOT/../mixer_settings/*.lua ; do
398     mkdir -p $MixerSettings  # create on demand
399     cp "$x" $MixerSettings
400 done
401
402 #Session templates
403 cp -av $BUILD_ROOT/../templates $Templates
404
405 # PluginMetadata
406 cp -av $BUILD_ROOT/../plugin_metadata $PluginMetadata
407
408 # ExportFormats
409 # got to be careful with names here
410 for x in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
411     cp "$x" $ExportFormats
412 done
413
414 # Panners
415 cp $BUILD_ROOT/libs/panners/*/lib*.so* $Panners
416
417 # Backends
418 for backend in jack alsa dummy wavesaudio pulseaudio; do
419     cp $BUILD_ROOT/libs/backends/$backend/lib*.so* $Backends
420 done
421
422 # VAMP plugins that we use
423 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.so* $Libraries
424 cp $BUILD_ROOT/libs/vamp-pyin/libardourvamppyin.so* $Libraries
425
426 # Suil modules (new dir 'build-stack')
427 if test -d $GTKSTACK_ROOT/lib/suil-0/ ; then
428     cp $GTKSTACK_ROOT/lib/suil-0/lib* $Libraries
429 fi
430
431 # Suil modules (old dir 'build-ardour-stack')
432 if test -d $ARDOURSTACK_ROOT/lib/suil-0/ ; then
433     cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Libraries
434 fi
435
436 # VST scanner app (both LXVST as well as WIN-VST, 2in1)
437 # (if build with wine: ardour-vst-scanner is a wrapper
438 #  script for ardour-vst-scanner.exe.so, if VST is disabled
439 #  neither binary nor script exists)
440 if test -d $BUILD_ROOT/libs/fst ; then
441     cp $BUILD_ROOT/libs/fst/ardour-vst-scanner* $APPLIB || true
442     if test x$STRIP = xall ; then
443         strip -s $APPLIB/ardour-vst-scanner*
444     fi
445 fi
446
447 # vfork wrapper
448 if test -f $BUILD_ROOT/libs/vfork/ardour-exec-wrapper ; then
449     cp $BUILD_ROOT/libs/vfork/ardour-exec-wrapper $APPLIB
450     if test x$STRIP = xall ; then
451         strip -s $APPLIB/ardour-exec-wrapper
452     fi
453 fi
454
455 # ALSA device reservation tool (if available)
456 if test -f $BUILD_ROOT/libs/ardouralsautil/ardour-request-device; then
457     cp $BUILD_ROOT/libs/ardouralsautil/ardour-request-device $APPLIB/ || true
458     if test x$STRIP = xall ; then
459         strip -s $APPLIB/ardour-request-device
460     fi
461 fi
462
463 # session-utils
464 HAVE_SESSION_UTILS=false
465 for file in $BUILD_ROOT/session_utils/${lower_case_appname}${major_version}-*; do
466         BN=$(basename $file)
467         cp -v $file $APPLIB/
468         if test x$STRIP = xall ; then
469                 strip -s $APPLIB/${BN}
470         fi
471         ln -s ../lib/ardour-util.sh $APPBIN/${BN}
472         HAVE_SESSION_UTILS=true
473 done
474
475 if test -x $BUILD_ROOT/tools/luadevel/luasession; then
476         BN=${lower_case_appname}${major_version}-lua
477         cp -v $BUILD_ROOT/tools/luadevel/luasession $APPLIB/$BN
478         if test x$STRIP = xall ; then
479                 strip -s $APPLIB/${BN}
480         fi
481         ln -s ../lib/ardour-util.sh $APPBIN/${BN}
482         HAVE_SESSION_UTILS=true
483 fi
484
485 if test "$HAVE_SESSION_UTILS" = true ; then
486         cat >> $APPLIB/ardour-util.sh << EOF
487 #!/bin/sh
488
489 BIN_DIR=\$(dirname \$(readlink -f \$0))
490 INSTALL_DIR=\$(dirname \$BIN_DIR)
491
492 export LD_LIBRARY_PATH=\$INSTALL_DIR/lib\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH}
493
494 export ARDOUR_DATA_PATH=\$INSTALL_DIR/share
495 export ARDOUR_CONFIG_PATH=\$INSTALL_DIR/etc
496 export ARDOUR_DLL_PATH=\$INSTALL_DIR/lib
497 export VAMP_PATH=\$INSTALL_DIR/lib\${VAMP_PATH:+:\$VAMP_PATH}
498
499 SELF=\$(basename \$0)
500 exec "\$INSTALL_DIR/lib/\$SELF" "\$@"
501 EOF
502         chmod +x $APPLIB/ardour-util.sh
503 fi
504
505 OURLIBDIR=$BUILD_ROOT/libs
506 OURLIBS=$OURLIBDIR/surfaces/control_protocol:$OURLIBDIR/ardour:$OURLIBDIR/midi++2:$OURLIBDIR/pbd:$OURLIBDIR/gtkmm2ext:$OURLIBDIR/glibmm2:$OURLIBDIR/canvas:$OURLIBDIR/widgets:$OURLIBDIR/waveview:$OURLIBDIR/evoral:$OURLIBDIR/evoral/src/libsmf:$OURLIBDIR/audiographer:$OURLIBDIR/temporal:$OURLIBDIR/libltc:$OURLIBDIR/qm-dsp:$OURLIBDIR/ardouralsautil:$OURLIBDIR/ptformat:$BUILD_ROOT/gtk2_ardour
507
508 echo $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
509
510 checkedIdx=0
511
512 # these are dynamically loaded by NSS
513 deplibs="libfreeblpriv3.so libsoftokn3.so libnsspem.so"
514 cp -v $GTKSTACK_ROOT/lib/libsoftokn3.so $Libraries/
515 cp -v $GTKSTACK_ROOT/lib/libfreeblpriv3.so $Libraries/
516 cp -v $GTKSTACK_ROOT/lib/libnsspem.so $Libraries/
517 chrpath -r foo $Libraries/libsoftokn3.so
518 chrpath -r foo $Libraries/libfreeblpriv3.so
519 chrpath -r foo $Libraries/libnsspem.so
520
521 while [ true ] ; do
522         missing=false
523         filelist=`find $APPLIB/ -type f`
524         filelist="$APPBIN/${EXENAME}-${release_version} $filelist"
525
526         for file in $filelist  ; do
527                 if ! file $file | grep -qs ELF ; then
528                         continue
529                 fi
530
531                 # speed this up a bit by not checking things multiple times.
532                 for i in "${depCheckedList[@]}"; do
533                         if [ $i == $file ]; then
534                                 continue 2
535                         fi
536                 done
537                 depCheckedList[$checkIdx]=$file
538                 checkIdx=$(($checkIdx + 1))
539
540                 # ignore suil/qt wrappers - the plugin will pull in QT4.
541                 if echo $file | grep -qs 'libsuil_.*qt[45]' ; then continue; fi
542
543                 # do not include libjack, nor libwine
544                 deps=`LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | grep -v libwine.so | awk '{print $3}'`
545
546                 echo -n "."
547                 for dep in $deps ; do
548                         if test "not" = ${dep}; then
549                                 echo ""
550                                 echo "!!! ERROR !!! - Missing dependant library for $file."
551                                 echo "Searched: " $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
552                                 echo ""
553                                 (LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file)
554                                 echo ""
555                                 echo "!!! ERROR !!! - See Above"
556                                 exit 1
557                         fi
558
559                         # don't use anything mapped at a specific address
560                         if echo $dep | grep -qs '0x' ; then continue; fi
561                         # don't include any distro libraries
562                         if echo $dep | grep -qs "^/lib/" ; then continue; fi
563                         if echo $dep | grep -qs "^/usr/lib/" ; then continue; fi
564                         if echo $dep | grep -qs "^/usr/local/lib/" ; then continue; fi
565                         ## the following re likley redudant ##
566                         # skip jack, ALSA & pulse
567                         if echo $dep | grep -qs libjack ; then continue; fi
568                         if echo $dep | grep -qs libasound ; then continue; fi
569                         if echo $dep | grep -qs libpulse ; then continue; fi
570                         # don't include any X Window libraries
571                         if echo $dep | grep -qs libX\. ; then continue; fi
572                         if echo $dep | grep -qs libxcb ; then continue; fi
573                         if echo $dep | grep -qs libICE\. ; then continue; fi
574                         if echo $dep | grep -qs libSM\. ; then continue; fi
575                         # don't include libc
576                         if echo $dep | grep -qs 'libc\.' ; then continue; fi
577                         # don't include libstdc++
578                         if echo $dep | grep -qs libstdc++ ; then continue; fi
579                         # don't include libdbus (alsa request device)
580                         if echo $dep | grep -qs libdbus ; then continue; fi
581                         # nor libudev (hidapi)
582                         if echo $dep | grep -qs libudev ; then continue; fi
583
584                         base=`basename $dep`
585                         if ! test -f $Libraries/$base; then
586                                 parent=$(basename ${file})
587                                 if echo $dep | grep -sq '^libs' ; then
588                                         echo "Copying dependant lib $BUILD_ROOT/$dep    (required by ${parent})"
589                                         cp $BUILD_ROOT/$dep $Libraries
590                                 else
591                                         echo "Copying dependant lib $dep    (required by ${parent})"
592                                         cp $dep $Libraries
593                                 fi
594                                 chmod 755 $Libraries/`basename $dep`
595                                 #
596                                 # reset RPATH so that the runtime linker never looks
597                                 # in places we don't want it to
598                                 #
599                                 chrpath -r foo $Libraries/`basename $dep`
600                                 if echo $dep | grep -sq '^/' ; then
601                                     # absolute path, candidate for stripping
602                                     deplibs="$deplibs $base"
603                                 fi
604                                 missing=true
605                         fi
606                 done
607         done
608         if test x$missing = xfalse ; then
609                 # everything has been found
610                 break
611         fi
612 done
613 echo
614
615 # strip libraries
616 if test x$STRIP = xall ; then
617     echo Stripping all libraries
618     # Must be writable so that we can strip
619     find $APPLIB/ -name "*.so*" -print0 | xargs -0 chmod u+w
620     # and strip ...
621     find $APPLIB/ -name "*.so*" -print0 | xargs -0 strip -s
622 elif test x$STRIP = xsome ; then
623     echo Stripping dependent libraries
624     for l in $deplibs ; do
625         if echo "$l" | grep -qE "$NOSTRIP"; then
626             continue
627         fi
628         chmod u+w $APPLIB/$l
629         strip -s $APPLIB/$l
630     done
631 fi
632 find $APPLIB/ -name "*.so*" -print0 | xargs -0 chmod a+rx
633
634 echo "Copying other stuff to $APPDIR  ..."
635
636 # these are all generated by waf
637 cp $BUILD_ROOT/gtk2_ardour/ardour.keys  $Etc
638 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc
639 cp $BUILD_ROOT/gtk2_ardour/clearlooks.rc $Etc
640 cp $BUILD_ROOT/gtk2_ardour/default_ui_config $Etc
641
642 # Copied directly from source tree
643
644 mkdir ${Shared}/icons
645 mkdir ${Shared}/resources
646 cp ../../system_config $Etc/system_config
647 cp ../../gtk2_ardour/icons/*.png ${Shared}/icons
648 cp -r ../../gtk2_ardour/icons/cursor_* ${Shared}/icons/
649 cp ../../gtk2_ardour/ArdourMono.ttf $Shared
650 cp ../../gtk2_ardour/resources/${APPNAME}-* ${Shared}/resources/
651
652 # Themes: only install those named for this app
653 cp ../../gtk2_ardour/themes/*-${lower_case_appname}.colors $Themes
654
655 #
656 # put sooper sekrit ingredients here and they will be copied
657 #
658
659 if [ -d specialSauce ] ; then
660         cp -r specialSauce $Etc
661 fi
662
663 # install bundled LV2s to <app>/lib/LV2/
664 cp -R $BUILD_ROOT/libs/LV2 $APPLIB/
665
666 # lv2 core, classifications etc - TODO check if we need the complete LV2 ontology
667 if test -d $ARDOURSTACK_ROOT/lib/lv2/lv2core.lv2 ; then
668         mkdir -p $APPLIB/LV2/lv2core.lv2
669         cp -R $ARDOURSTACK_ROOT/lib/lv2/lv2core.lv2/*.ttl $APPLIB/LV2/lv2core.lv2/
670 elif test -d $GTKSTACK_ROOT/lib/lv2/lv2core.lv2 ; then
671         mkdir -p $APPLIB/LV2/lv2core.lv2
672         cp -R $GTKSTACK_ROOT/lib/lv2/lv2core.lv2/*.ttl $APPLIB/LV2/lv2core.lv2/
673 fi
674
675 # go through and recursively remove any .svn dirs in the bundle
676 for svndir in `find $APPDIR -name .svn -type d`; do
677         rm -rf $svndir
678 done
679
680
681 ################################################################################
682 ### Mixbus plugins, etc
683 if test x$WITH_HARRISON_LV2 != x ; then
684         echo "Adding Harrison LV2s"
685         mkdir -p $APPLIB/LV2
686
687         curl -s -S --fail -# \
688                 -z "${CACHEDIR}/${HARRISONLV2}.${HARCH}.zip" \
689                 -o "${CACHEDIR}/${HARRISONLV2}.${HARCH}.zip" \
690                 "${HARRISONDSPURL}/${HARRISONLV2}.${HARCH}.zip"
691         unzip -q -d "$APPLIB/LV2/" "${CACHEDIR}/${HARRISONLV2}.${HARCH}.zip"
692 fi
693
694 if test -n "$MIXBUS"; then
695         echo "Adding Mixbus Channelstrip"
696
697         mkdir -p $APPLIB/ladspa/strip/
698         curl -s -S --fail -# \
699                 -z "${CACHEDIR}/${HARRISONCHANNELSTRIP}.${HARCH}.so" \
700                 -o "${CACHEDIR}/${HARRISONCHANNELSTRIP}.${HARCH}.so" \
701                 "${HARRISONDSPURL}/${HARRISONCHANNELSTRIP}.${HARCH}.so"
702
703         cp "${CACHEDIR}/${HARRISONCHANNELSTRIP}.${HARCH}.so" \
704                 $APPLIB/ladspa/strip/${HARRISONCHANNELSTRIP}.so
705         chmod +x $APPLIB/ladspa/strip/${HARRISONCHANNELSTRIP}.so
706
707         echo "Adding Harrison Vamp Plugins"
708
709         if test "$GCC5ABI" = "true"; then
710                 VAMPARCH="${HARCH}gcc5"
711         else
712                 VAMPARCH="${HARCH}"
713         fi
714         curl -s -S --fail -# \
715                 -z "${CACHEDIR}/harrison_vamp.${VAMPARCH}.so" \
716                 -o "${CACHEDIR}/harrison_vamp.${VAMPARCH}.so" \
717                 "${HARRISONDSPURL}/harrison_vamp.${VAMPARCH}.so"
718
719         cp "${CACHEDIR}/harrison_vamp.${VAMPARCH}.so" \
720                 $APPLIB/harrison_vamp.so
721         chmod +x $APPLIB/harrison_vamp.so
722 fi
723
724 if true ; then
725         mkdir -p $APPLIB/LV2
726
727         echo "Adding General MIDI Synth LV2"
728
729         for proj in x42-gmsynth ; do
730                 X42_VERSION=$(curl -s -S http://x42-plugins.com/x42/linux/${proj}.latest.txt)
731                 rsync -a -q --partial \
732                         rsync://x42-plugins.com/x42/linux/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip \
733                         "${CACHEDIR}/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip"
734                 unzip -q -d "$APPLIB/LV2/" "${CACHEDIR}/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip"
735         done
736 fi
737
738
739 if test x$WITH_X42_LV2 != x ; then
740         mkdir -p $APPLIB/LV2
741
742         echo "Adding x42 Plugins"
743
744         for proj in x42-meters x42-midifilter x42-stereoroute x42-eq setBfree x42-avldrums x42-whirl x42-limiter x42-tuner; do
745                 X42_VERSION=$(curl -s -S http://x42-plugins.com/x42/linux/${proj}.latest.txt)
746                 rsync -a -q --partial \
747                         rsync://x42-plugins.com/x42/linux/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip \
748                         "${CACHEDIR}/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip"
749                 unzip -q -d "$APPLIB/LV2/" "${CACHEDIR}/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip"
750         done
751 fi
752
753 ################################################################################
754
755 if test x$WITH_HARVID != x ; then
756         cd $APPBIN
757         HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
758         XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
759
760         rsync -Pa \
761                 rsync://ardour.org/video-tools/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz \
762                 "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz"
763
764         rsync -Pa \
765                 rsync://ardour.org/video-tools/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz \
766                 "$CACHEDIR/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz"
767
768         tar -x -z \
769                 --exclude=README --exclude=harvid.1 --strip-components=1 \
770                 -f "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz" || exit 1
771
772         tar -x -z \
773                 --exclude=README --exclude=xjadeo.1 --strip-components=1 \
774                 -f "$CACHEDIR/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz" || exit 1
775         mv xjadeo xjremote
776         cd -
777 fi
778
779 ################################################################################
780
781 if test x$DEMO_SESSION_URL != x ; then
782         mkdir -p $Shared/sessions
783         DEMO_SESSIONS=$(curl -s -S --fail $DEMO_SESSION_URL/index.txt)
784         for demo in $DEMO_SESSIONS; do
785                 curl -s -S --fail -# -o $Shared/sessions/$demo $DEMO_SESSION_URL/$demo
786         done
787 fi
788
789 ################################################################################
790
791 #
792 # Add the uninstaller
793 #
794 sed -e "s/%REPLACE_PGM%/${APPNAME}/" -e "s/%REPLACE_VENDOR%/${VENDOR}/" -e "s/%REPLACE_MAJOR_VERSION%/${major_version}/" -e "s/%REPLACE_VERSION%/${release_version}/" -e "s/%REPLACE_TYPE%/${BUILDTYPE}/" < uninstall.sh.in > $APPBIN/${APP_VER_NAME}.uninstall.sh
795 chmod a+x $APPBIN/${APP_VER_NAME}.uninstall.sh
796
797 #
798 # Add the stage2.run script
799 #
800 sed -e "s/%REPLACE_MAJOR_VERSION%/${major_version}/;s/%REPLACE_PGM%/${APPNAME}/;s/%REPLACE_VENDOR%/${VENDOR}/;s/%REPLACE_EXE%/${EXENAME}/;s/%REPLACE_GCC5%/${GCC5ABI}/;s/%REPLACE_WINE%/${USEWINE}/" < stage2.run.in > stage2.run
801 chmod a+x stage2.run
802
803
804 #Sanity Check file
805 if [ -e $BUILD_ROOT/tools/sanity_check/sanityCheck ]; then
806         cp $BUILD_ROOT/tools/sanity_check/sanityCheck $APPBIN
807 else
808         echo "!!!ERROR !!! sanityCheck program is missing. packager will exit without being complete"
809         exit 1
810 fi
811
812 echo "Building tarball ..."
813
814 rm -f $APPDIR.tar
815 tar -cf $APPDIR.tar $APPDIR
816
817 echo "Calculating bundle size"
818 du -sb $APPDIR/  | awk '{print $1}' > $APPDIR.size
819
820 ( cd $APPDIR ; find . ) > file_list.txt
821
822 rm -rf $APPDIR/
823
824 echo "Done."
825