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