additional changes to follow library name change from timecode -> temporal
[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 ExportFormats=$Shared/export
190 Locale=$Shared/locale
191 MidiMaps=$Shared/midi_maps
192 PatchFiles=$Shared/patchfiles
193 LuaScripts=$Shared/scripts
194 MackieControl=$Shared/mcp
195 OSC=$Shared/osc
196
197 if [ x$PRINT_SYSDEPS != x ] ; then
198 #
199 # print system dependencies
200 #
201
202         for file in $APPBIN/* $Libraries/* $Plugins/*.so ; do
203                 if ! file $file | grep -qs Mach-O ; then
204                         continue
205                 fi
206                 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
207         done | sort | uniq
208         exit 0
209 fi
210
211 echo "Removing old $APPDIR tree ..."
212 rm -rf $APPDIR/
213
214 echo "Building new app directory structure ..."
215
216 # only bother to make the longest paths
217
218 mkdir -p $APPDIR
219 mkdir -p $APPBIN
220 mkdir -p $APPLIB
221 mkdir -p $Etc
222 mkdir -p $Shared
223 mkdir -p $Themes
224 mkdir -p $Locale
225 mkdir -p $Surfaces
226 mkdir -p $MidiMaps
227 mkdir -p $PatchFiles
228 mkdir -p $LuaScripts
229 mkdir -p $MackieControl
230 mkdir -p $OSC
231 mkdir -p $ExportFormats
232 mkdir -p $Panners
233 mkdir -p $Backends
234 mkdir -p $Shared/doc
235
236 # maybe set variables
237 ENVIRONMENT=environment
238 rm -f $ENVIRONMENT
239 touch $ENVIRONMENT
240
241 if test x$MIXBUS != x ; then
242         echo export ARDOUR_MIXBUS=true >> $ENVIRONMENT
243         #
244         # current default for MIXBUS version is US keyboard layout without a keypad
245         #
246         echo export ARDOUR_KEYBOARD_LAYOUT=us-nokeypad >> $ENVIRONMENT
247         echo export ARDOUR_UI_CONF=ardour3_ui.conf >> $ENVIRONMENT
248 fi
249
250 #
251 # if we're not going to bundle JACK, make sure we can find
252 # jack in the places where it might be
253 #
254
255 echo export 'PATH=/usr/local/bin:/opt/bin:$PATH' >> $ENVIRONMENT
256
257 # create startup helper script
258 if test -d $BUILD_ROOT/vst; then
259         WINEEXE=wine
260         USEWINE=true
261         echo export INSTALL_DIR >> $ENVIRONMENT
262 else
263         WINEEXE=
264 fi
265
266 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}
267 rm $ENVIRONMENT && chmod 775 $APPBIN/${EXENAME}${major_version}
268
269 echo "Copying ardour executable ...."
270 if test -d $BUILD_ROOT/vst; then
271         #cp -v $BUILD_ROOT/gtk2_ardour/libgtk2_ardour.so $APPLIB/
272         cp -v $BUILD_ROOT/gtk2_ardour/ardour-${release_version}-vst.exe.so $APPBIN/${EXENAME}-${release_version}
273 else
274         cp -v $BUILD_ROOT/gtk2_ardour/ardour-${release_version}* $APPBIN/${EXENAME}-${release_version}
275 fi
276
277 if test x$STRIP = xall ; then
278         strip -s $APPBIN/${EXENAME}-${release_version}
279 fi
280
281 # copy locale files
282 # note that at present(feb 2011), the .mo files end up in the source tree which is
283 # not really as it should be.
284 if test x$WITH_NLS != x ; then
285         echo "NLS support ..."
286         echo "I hope you remembered to run scons msgupdate!"
287         LINGUAS=
288
289         for pkg in gtk2_ardour libs/ardour libs/gtkmm2ext ; do
290             files=`find ../../$pkg -name "*.mo"`
291
292             #
293             # the package name is appended with a number so that
294             # it can be parallel installed during a regular install
295             # with older (and newer) versions. it is just the major
296             # number of the release (i.e. leading digits)
297             #
298
299             vsuffix=`echo $release_version | sed 's/^\([0-9][0-9]*\).*/\1/'`
300
301             if [ -z "$files" ]; then
302                 echo ""
303                 echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$pkg"
304                 echo ""
305             fi
306
307             for file in $files
308             do
309                 echo $file
310                 lang=`basename $file | sed 's/\.mo//'`
311                 mkdir -p $Locale/$lang/LC_MESSAGES
312                 cp $file $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
313                 echo copy $file to $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
314                 if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
315                     :
316                 else
317                     LINGUAS="$LINGUAS $lang"
318                 fi
319             done
320         done
321
322         GTK_MESSAGES="atk10.mo gdk-pixbuf.mo gtk20-properties.mo gtk20.mo atk10.mo glib20.mo"
323         LOCALEROOT=$GTKSTACK_ROOT/share/locale
324
325         for l in $LINGUAS ; do
326                 echo "Copying GTK i18n files for $l..."
327                 for MO in $GTK_MESSAGES ; do
328                         if [ -f $LOCALEROOT/$l/LC_MESSAGES/$MO ] ; then
329                                 cp $LOCALEROOT/$l/LC_MESSAGES/$MO $Locale/$l/LC_MESSAGES
330                         else
331                                 # try with just the language spec
332                                 just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
333                                 if [ -f $LOCALEROOT/$just_lang/LC_MESSAGES/$MO ] ; then
334                                         cp $LOCALEROOT/$just_lang/LC_MESSAGES/$MO $Locale/$just_lang/LC_MESSAGES
335                                 fi
336                         fi
337                 done
338         done
339 else
340         echo "Skipping NLS support"
341 fi
342
343 #
344 # Copy stuff that may be dynamically loaded
345 #
346
347 cp -R $GTKSTACK_ROOT/etc/* $Etc
348
349 # We rely on clearlooks, so include a version from our own build tree
350 # this one is special - we will set GTK_PATH to $Libraries/gtkengines
351
352 GTK_ENGINE_DIR=$Libraries/gtkengines/engines
353 mkdir -p $GTK_ENGINE_DIR
354
355 echo "Copying GTK engines ..."
356 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.so $Libraries
357 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.so . )
358
359 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Libraries
360 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so . )
361
362 # Control Surfaces
363 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.so* $Surfaces
364 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp.so* $Libraries
365
366 # MidiMaps
367 # got to be careful with names here
368 for x in $BUILD_ROOT/../midi_maps/*.map ; do
369     cp "$x" $MidiMaps
370 done
371
372 # MIDNAM Patch Files
373 # got to be careful with names here
374 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
375     cp "$x" $PatchFiles
376 done
377
378 # Lua Scripts Files
379 # got to be careful with names here
380 for x in $BUILD_ROOT/../scripts/*.lua ; do
381                 BN=$(basename $x)
382           if test "${BN:0:1}" = "_"; then
383                         continue;
384                 fi
385     cp "$x" $LuaScripts
386 done
387
388 # MackieControl data
389 # got to be careful with names here
390 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
391     cp "$x" $MackieControl
392 done
393
394 # OSC data
395 # got to be careful with names here
396 for x in $BUILD_ROOT/../osc/*.preset ; do
397     cp "$x" $OSC
398 done
399
400 #Session templates
401 cp -av $BUILD_ROOT/../templates $Templates
402
403 # ExportFormats
404 # got to be careful with names here
405 for x in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
406     cp "$x" $ExportFormats
407 done
408
409 # Panners
410 cp $BUILD_ROOT/libs/panners/*/lib*.so* $Panners
411
412 # Backends
413 for backend in jack alsa dummy wavesaudio ; do
414     cp $BUILD_ROOT/libs/backends/$backend/lib*.so* $Backends
415 done
416
417 # VAMP plugins that we use
418 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.so* $Libraries
419
420 # Suil modules (new dir 'build-stack')
421 if test -d $GTKSTACK_ROOT/lib/suil-0/ ; then
422     cp $GTKSTACK_ROOT/lib/suil-0/lib* $Libraries
423 fi
424
425 # Suil modules (old dir 'build-ardour-stack')
426 if test -d $ARDOURSTACK_ROOT/lib/suil-0/ ; then
427     cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Libraries
428 fi
429
430 # VST scanner app (both LXVST as well as WIN-VST, 2in1)
431 # (if build with wine: ardour-vst-scanner is a wrapper
432 #  script for ardour-vst-scanner.exe.so, if VST is disabled
433 #  neither binary nor script exists)
434 if test -d $BUILD_ROOT/libs/fst ; then
435     cp $BUILD_ROOT/libs/fst/ardour-vst-scanner* $APPLIB || true
436     if test x$STRIP = xall ; then
437         strip -s $APPLIB/ardour-vst-scanner*
438     fi
439 fi
440
441 # vfork wrapper
442 if test -f $BUILD_ROOT/libs/vfork/ardour-exec-wrapper ; then
443     cp $BUILD_ROOT/libs/vfork/ardour-exec-wrapper $APPLIB
444     if test x$STRIP = xall ; then
445         strip -s $APPLIB/ardour-exec-wrapper
446     fi
447 fi
448
449 # ALSA device reservation tool (if available)
450 if test -f $BUILD_ROOT/libs/ardouralsautil/ardour-request-device; then
451     cp $BUILD_ROOT/libs/ardouralsautil/ardour-request-device $APPLIB/ || true
452     if test x$STRIP = xall ; then
453         strip -s $APPLIB/ardour-request-device
454     fi
455 fi
456
457 # session-utils
458 HAVE_SESSION_UTILS=false
459 for file in $BUILD_ROOT/session_utils/${lower_case_appname}${major_version}-*; do
460         BN=$(basename $file)
461         cp -v $file $APPLIB/
462         if test x$STRIP = xall ; then
463                 strip -s $APPLIB/${BN}
464         fi
465         ln -s ../lib/ardour-util.sh $APPBIN/${BN}
466         HAVE_SESSION_UTILS=true
467 done
468
469 if test "$HAVE_SESSION_UTILS" = true ; then
470         cat >> $APPLIB/ardour-util.sh << EOF
471 #!/bin/sh
472
473 BIN_DIR=\$(dirname \$(readlink -f \$0))
474 INSTALL_DIR=\$(dirname \$BIN_DIR)
475
476 export LD_LIBRARY_PATH=\$INSTALL_DIR/lib\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH}
477
478 export ARDOUR_DATA_PATH=\$INSTALL_DIR/share
479 export ARDOUR_CONFIG_PATH=\$INSTALL_DIR/etc
480 export ARDOUR_DLL_PATH=\$INSTALL_DIR/lib
481 export VAMP_PATH=\$INSTALL_DIR/lib\${VAMP_PATH:+:\$VAMP_PATH}
482
483 SELF=\$(basename \$0)
484 exec "\$INSTALL_DIR/lib/\$SELF" "\$@"
485 EOF
486         chmod +x $APPLIB/ardour-util.sh
487 fi
488
489 OURLIBDIR=$BUILD_ROOT/libs
490 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
491
492 echo $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
493
494 checkedIdx=0
495
496 # these are dynamically loaded by NSS
497 deplibs="libfreeblpriv3.so libsoftokn3.so libnsspem.so"
498 cp -v $GTKSTACK_ROOT/lib/libsoftokn3.so $Libraries/
499 cp -v $GTKSTACK_ROOT/lib/libfreeblpriv3.so $Libraries/
500 cp -v $GTKSTACK_ROOT/lib/libnsspem.so $Libraries/
501 chrpath -r foo $Libraries/libsoftokn3.so
502 chrpath -r foo $Libraries/libfreeblpriv3.so
503 chrpath -r foo $Libraries/libnsspem.so
504
505 while [ true ] ; do
506         missing=false
507         filelist=`find $APPLIB/ -type f`
508         filelist="$APPBIN/${EXENAME}-${release_version} $filelist"
509
510         for file in $filelist  ; do
511                 if ! file $file | grep -qs ELF ; then
512                         continue
513                 fi
514
515                 # speed this up a bit by not checking things multiple times.
516                 for i in "${depCheckedList[@]}"; do
517                         if [ $i == $file ]; then
518                                 continue 2
519                         fi
520                 done
521                 depCheckedList[$checkIdx]=$file
522                 checkIdx=$(($checkIdx + 1))
523
524                 # ignore suil/qt wrappers - the plugin will pull in QT4.
525                 if echo $file | grep -qs 'libsuil_.*qt[45]' ; then continue; fi
526
527                 # do not include libjack, nor libwine
528                 deps=`LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | grep -v libwine.so | awk '{print $3}'`
529
530                 echo -n "."
531                 for dep in $deps ; do
532                         if test "not" = ${dep}; then
533                                 echo ""
534                                 echo "!!! ERROR !!! - Missing dependant library for $file."
535                                 echo "Searched: " $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
536                                 echo ""
537                                 (LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file)
538                                 echo ""
539                                 echo "!!! ERROR !!! - See Above"
540                                 exit 1
541                         fi
542
543                         # don't use anything mapped at a specific address
544                         if echo $dep | grep -qs '0x' ; then continue; fi
545                         # don't include /lib
546                         if echo $dep | grep -qs "^/lib/" ; then continue; fi
547                         # don't include jack
548                         if echo $dep | grep -qs libjack ; then continue; fi
549                         # don't include ALSA
550                         if echo $dep | grep -qs libasound ; then continue; fi
551                         # don't include any X Window libraries
552                         if echo $dep | grep -qs libX\. ; then continue; fi
553                         if echo $dep | grep -qs libxcb ; then continue; fi
554                         if echo $dep | grep -qs libICE\. ; then continue; fi
555                         if echo $dep | grep -qs libSM\. ; then continue; fi
556                         # don't include libc
557                         if echo $dep | grep -qs 'libc\.' ; then continue; fi
558                         # don't include libstdc++
559                         if echo $dep | grep -qs libstdc++ ; then continue; fi
560                         # don't include libdbus (alsa request device)
561                         if echo $dep | grep -qs libdbus ; then continue; fi
562                         # nor libudev (hidapi)
563                         if echo $dep | grep -qs libudev ; then continue; fi
564
565                         base=`basename $dep`
566                         if ! test -f $Libraries/$base; then
567                                 parent=$(basename ${file})
568                                 if echo $dep | grep -sq '^libs' ; then
569                                         echo "Copying dependant lib $BUILD_ROOT/$dep    (required by ${parent})"
570                                         cp $BUILD_ROOT/$dep $Libraries
571                                 else
572                                         echo "Copying dependant lib $dep    (required by ${parent})"
573                                         cp $dep $Libraries
574                                 fi
575                                 #
576                                 # reset RPATH so that the runtime linker never looks
577                                 # in places we don't want it to
578                                 #
579                                 chrpath -r foo $Libraries/`basename $dep`
580                                 if echo $dep | grep -sq '^/' ; then
581                                     # absolute path, candidate for stripping
582                                     deplibs="$deplibs $base"
583                                 fi
584                                 missing=true
585                         fi
586                 done
587         done
588         if test x$missing = xfalse ; then
589                 # everything has been found
590                 break
591         fi
592 done
593 echo
594
595 # strip libraries
596 if test x$STRIP = xall ; then
597     echo Stripping all libraries
598     # Must be writable so that we can strip
599     find $APPLIB/ -name "*.so*" -print0 | xargs -0 chmod u+w
600     # and strip ...
601     find $APPLIB/ -name "*.so*" -print0 | xargs -0 strip -s
602 elif test x$STRIP = xsome ; then
603     echo Stripping dependent libraries
604     for l in $deplibs ; do
605         if echo "$l" | grep -qE "$NOSTRIP"; then
606             continue
607         fi
608         chmod u+w $APPLIB/$l
609         strip -s $APPLIB/$l
610     done
611 fi
612 find $APPLIB/ -name "*.so*" -print0 | xargs -0 chmod a+rx
613
614 echo "Copying other stuff to $APPDIR  ..."
615
616 # these are all generated by waf
617 cp $BUILD_ROOT/gtk2_ardour/ardour.keys  $Etc
618 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc
619 cp $BUILD_ROOT/gtk2_ardour/clearlooks.rc $Etc
620 cp $BUILD_ROOT/gtk2_ardour/default_ui_config $Etc
621
622 # Copied directly from source tree
623
624 mkdir ${Shared}/icons
625 mkdir ${Shared}/resources
626 cp ../../system_config $Etc/system_config
627 cp ../../gtk2_ardour/icons/*.png ${Shared}/icons
628 cp -r ../../gtk2_ardour/icons/cursor_* ${Shared}/icons/
629 cp ../../gtk2_ardour/ArdourMono.ttf $Shared
630 cp ../../gtk2_ardour/resources/${APPNAME}-* ${Shared}/resources/
631
632 # Themes: only install those named for this app
633 cp ../../gtk2_ardour/themes/*-${lower_case_appname}.colors $Themes
634
635 #
636 # put sooper sekrit ingredients here and they will be copied
637 #
638
639 if [ -d specialSauce ] ; then
640         cp -r specialSauce $Etc
641 fi
642
643 # install bundled LV2s to <app>/lib/LV2/
644 cp -R $BUILD_ROOT/libs/LV2 $APPLIB/
645
646 # lv2 core, classifications etc - TODO check if we need the complete LV2 ontology
647 if test -d $ARDOURSTACK_ROOT/lib/lv2/lv2core.lv2 ; then
648         mkdir -p $APPLIB/LV2/lv2core.lv2
649         cp -R $ARDOURSTACK_ROOT/lib/lv2/lv2core.lv2/*.ttl $APPLIB/LV2/lv2core.lv2/
650 elif test -d $GTKSTACK_ROOT/lib/lv2/lv2core.lv2 ; then
651         mkdir -p $APPLIB/LV2/lv2core.lv2
652         cp -R $GTKSTACK_ROOT/lib/lv2/lv2core.lv2/*.ttl $APPLIB/LV2/lv2core.lv2/
653 fi
654
655 # go through and recursively remove any .svn dirs in the bundle
656 for svndir in `find $APPDIR -name .svn -type d`; do
657         rm -rf $svndir
658 done
659
660
661 ################################################################################
662 ### Mixbus plugins, etc
663 if test x$WITH_HARRISON_LV2 != x ; then
664         echo "Adding Harrison LV2s"
665         mkdir -p $APPLIB/LV2
666
667         curl -s -S --fail -# \
668                 -z "${CACHEDIR}/${HARRISONLV2}.${HARCH}.zip" \
669                 -o "${CACHEDIR}/${HARRISONLV2}.${HARCH}.zip" \
670                 "${HARRISONDSPURL}/${HARRISONLV2}.${HARCH}.zip"
671         unzip -q -d "$APPLIB/LV2/" "${CACHEDIR}/${HARRISONLV2}.${HARCH}.zip"
672 fi
673
674 if test -n "$MIXBUS"; then
675         echo "Adding Mixbus Channelstrip"
676
677         mkdir -p $APPLIB/ladspa/strip/
678         curl -s -S --fail -# \
679                 -z "${CACHEDIR}/${HARRISONCHANNELSTRIP}.${HARCH}.so" \
680                 -o "${CACHEDIR}/${HARRISONCHANNELSTRIP}.${HARCH}.so" \
681                 "${HARRISONDSPURL}/${HARRISONCHANNELSTRIP}.${HARCH}.so"
682
683         cp "${CACHEDIR}/${HARRISONCHANNELSTRIP}.${HARCH}.so" \
684                 $APPLIB/ladspa/strip/${HARRISONCHANNELSTRIP}.so
685         chmod +x $APPLIB/ladspa/strip/${HARRISONCHANNELSTRIP}.so
686
687         echo "Adding Harrison Vamp Plugins"
688
689         if test "$GCC5ABI" = "true"; then
690                 VAMPARCH="${HARCH}gcc5"
691         else
692                 VAMPARCH="${HARCH}"
693         fi
694         curl -s -S --fail -# \
695                 -z "${CACHEDIR}/harrison_vamp.${VAMPARCH}.so" \
696                 -o "${CACHEDIR}/harrison_vamp.${VAMPARCH}.so" \
697                 "${HARRISONDSPURL}/harrison_vamp.${VAMPARCH}.so"
698
699         cp "${CACHEDIR}/harrison_vamp.${VAMPARCH}.so" \
700                 $APPLIB/harrison_vamp.so
701         chmod +x $APPLIB/harrison_vamp.so
702 fi
703
704 if true ; then
705         mkdir -p $APPLIB/LV2
706
707         echo "Adding General MIDI Synth LV2"
708
709         for proj in x42-gmsynth ; do
710                 X42_VERSION=$(curl -s -S http://x42-plugins.com/x42/linux/${proj}.latest.txt)
711                 rsync -a -q --partial \
712                         rsync://x42-plugins.com/x42/linux/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip \
713                         "${CACHEDIR}/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip"
714                 unzip -q -d "$APPLIB/LV2/" "${CACHEDIR}/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip"
715         done
716 fi
717
718
719 if test x$WITH_X42_LV2 != x ; then
720         mkdir -p $APPLIB/LV2
721
722         echo "Adding x42 Plugins"
723
724         for proj in x42-meters x42-midifilter x42-midimap x42-stereoroute x42-eq setBfree x42-avldrums; do
725                 X42_VERSION=$(curl -s -S http://x42-plugins.com/x42/linux/${proj}.latest.txt)
726                 rsync -a -q --partial \
727                         rsync://x42-plugins.com/x42/linux/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip \
728                         "${CACHEDIR}/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip"
729                 unzip -q -d "$APPLIB/LV2/" "${CACHEDIR}/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip"
730         done
731 fi
732
733 ################################################################################
734
735 if test x$WITH_HARVID != x ; then
736         cd $APPBIN
737         HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
738         XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
739
740         rsync -Pa \
741                 rsync://ardour.org/video-tools/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz \
742                 "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz"
743
744         rsync -Pa \
745                 rsync://ardour.org/video-tools/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz \
746                 "$CACHEDIR/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz"
747
748         tar -x -z \
749                 --exclude=README --exclude=harvid.1 --strip-components=1 \
750                 -f "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz" || exit 1
751
752         tar -x -z \
753                 --exclude=README --exclude=xjadeo.1 --strip-components=1 \
754                 -f "$CACHEDIR/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz" || exit 1
755         mv xjadeo xjremote
756         cd -
757 fi
758
759 ################################################################################
760
761 if test x$DEMO_SESSION_URL != x ; then
762         mkdir -p $Shared/sessions
763         DEMO_SESSIONS=$(curl -s -S --fail $DEMO_SESSION_URL/index.txt)
764         for demo in $DEMO_SESSIONS; do
765                 curl -s -S --fail -# -o $Shared/sessions/$demo $DEMO_SESSION_URL/$demo
766         done
767 fi
768
769 ################################################################################
770
771 #
772 # Add the uninstaller
773 #
774 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
775 chmod a+x $APPBIN/${APP_VER_NAME}.uninstall.sh
776
777 #
778 # Add the stage2.run script
779 #
780 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
781 chmod a+x stage2.run
782
783
784 #Sanity Check file
785 if [ -e $BUILD_ROOT/tools/sanity_check/sanityCheck ]; then
786         cp $BUILD_ROOT/tools/sanity_check/sanityCheck $APPBIN
787 else
788         echo "!!!ERROR !!! sanityCheck program is missing. packager will exit without being complete"
789         exit 1
790 fi
791
792 echo "Building tarball ..."
793
794 rm -f $APPDIR.tar
795 tar -cf $APPDIR.tar $APPDIR
796
797 echo "Calculating bundle size"
798 du -sb $APPDIR/  | awk '{print $1}' > $APPDIR.size
799
800 ( cd $APPDIR ; find . ) > file_list.txt
801
802 rm -rf $APPDIR/
803
804 echo "Done."
805