Do not bundle default system_config (prefer built-in defaults)
[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
196 if [ x$PRINT_SYSDEPS != x ] ; then
197 #
198 # print system dependencies
199 #
200
201         for file in $APPBIN/* $Libraries/* $Plugins/*.so ; do
202                 if ! file $file | grep -qs Mach-O ; then
203                         continue
204                 fi
205                 otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)"
206         done | sort | uniq
207         exit 0
208 fi
209
210 echo "Removing old $APPDIR tree ..."
211 rm -rf $APPDIR/
212
213 echo "Building new app directory structure ..."
214
215 # only bother to make the longest paths
216
217 mkdir -p $APPDIR
218 mkdir -p $APPBIN
219 mkdir -p $APPLIB
220 mkdir -p $Etc
221 mkdir -p $Shared
222 mkdir -p $Themes
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 # Control Surfaces
362 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.so* $Surfaces
363 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp.so* $Libraries
364
365 # MidiMaps
366 # got to be careful with names here
367 for x in $BUILD_ROOT/../midi_maps/*.map ; do
368     cp "$x" $MidiMaps
369 done
370
371 # MIDNAM Patch Files
372 # got to be careful with names here
373 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
374     cp "$x" $PatchFiles
375 done
376
377 # Lua Scripts Files
378 # got to be careful with names here
379 for x in $BUILD_ROOT/../scripts/*.lua ; do
380                 BN=$(basename $x)
381           if test "${BN:0:1}" = "_"; then
382                         continue;
383                 fi
384     cp "$x" $LuaScripts
385 done
386
387 # MackieControl data
388 # got to be careful with names here
389 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
390     cp "$x" $MackieControl
391 done
392
393 # Templates
394 #for f in $BUILD_ROOT/../templates/* ; do
395 #    if [ -d "$f" ] ; then
396 #       echo Template: $f ; cp -r "$f" $Templates ;
397 #    fi
398 #done
399
400 # ExportFormats
401 # got to be careful with names here
402 for x in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
403     cp "$x" $ExportFormats
404 done
405
406 # Panners
407 cp $BUILD_ROOT/libs/panners/*/lib*.so* $Panners
408
409 # Backends
410 for backend in jack alsa dummy wavesaudio ; do
411     cp $BUILD_ROOT/libs/backends/$backend/lib*.so* $Backends
412 done
413
414 # VAMP plugins that we use
415 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.so* $Libraries
416
417 # Suil modules (new dir 'build-stack')
418 if test -d $GTKSTACK_ROOT/lib/suil-0/ ; then
419     cp $GTKSTACK_ROOT/lib/suil-0/lib* $Libraries
420 fi
421
422 # Suil modules (old dir 'build-ardour-stack')
423 if test -d $ARDOURSTACK_ROOT/lib/suil-0/ ; then
424     cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Libraries
425 fi
426
427 # VST scanner app (both LXVST as well as WIN-VST, 2in1)
428 # (if build with wine: ardour-vst-scanner is a wrapper
429 #  script for ardour-vst-scanner.exe.so, if VST is disabled
430 #  neither binary nor script exists)
431 if test -d $BUILD_ROOT/libs/fst ; then
432     cp $BUILD_ROOT/libs/fst/ardour-vst-scanner* $APPLIB || true
433     if test x$STRIP = xall ; then
434         strip -s $APPLIB/ardour-vst-scanner*
435     fi
436 fi
437
438 # vfork wrapper
439 if test -f $BUILD_ROOT/libs/vfork/ardour-exec-wrapper ; then
440     cp $BUILD_ROOT/libs/vfork/ardour-exec-wrapper $APPLIB
441     if test x$STRIP = xall ; then
442         strip -s $APPLIB/ardour-exec-wrapper
443     fi
444 fi
445
446 # ALSA device reservation tool (if available)
447 if test -f $BUILD_ROOT/libs/ardouralsautil/ardour-request-device; then
448     cp $BUILD_ROOT/libs/ardouralsautil/ardour-request-device $APPLIB/ || true
449     if test x$STRIP = xall ; then
450         strip -s $APPLIB/ardour-request-device
451     fi
452 fi
453
454 # session-utils
455 HAVE_SESSION_UTILS=false
456 for file in $BUILD_ROOT/session_utils/${lower_case_appname}${major_version}-*; do
457         BN=$(basename $file)
458         cp -v $file $APPLIB/
459         if test x$STRIP = xall ; then
460                 strip -s $APPLIB/${BN}
461         fi
462         ln -s ../lib/ardour-util.sh $APPBIN/${BN}
463         HAVE_SESSION_UTILS=true
464 done
465
466 if test "$HAVE_SESSION_UTILS" = true ; then
467         cat >> $APPLIB/ardour-util.sh << EOF
468 #!/bin/sh
469
470 BIN_DIR=\$(dirname \$(readlink -f \$0))
471 INSTALL_DIR=\$(dirname \$BIN_DIR)
472
473 export LD_LIBRARY_PATH=\$INSTALL_DIR/lib\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH}
474
475 export ARDOUR_DATA_PATH=\$INSTALL_DIR/share
476 export ARDOUR_CONFIG_PATH=\$INSTALL_DIR/etc
477 export ARDOUR_DLL_PATH=\$INSTALL_DIR/lib
478 export VAMP_PATH=\$INSTALL_DIR/lib\${VAMP_PATH:+:\$VAMP_PATH}
479
480 SELF=\$(basename \$0)
481 exec "\$INSTALL_DIR/lib/\$SELF" "\$@"
482 EOF
483         chmod +x $APPLIB/ardour-util.sh
484 fi
485
486 OURLIBDIR=$BUILD_ROOT/libs
487 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
488
489 echo $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
490
491 checkedIdx=0
492
493 # these are dynamically loaded by NSS
494 deplibs="libfreeblpriv3.so libsoftokn3.so libnsspem.so"
495 cp -v $GTKSTACK_ROOT/lib/libsoftokn3.so $Libraries/
496 cp -v $GTKSTACK_ROOT/lib/libfreeblpriv3.so $Libraries/
497 cp -v $GTKSTACK_ROOT/lib/libnsspem.so $Libraries/
498 chrpath -r foo $Libraries/libsoftokn3.so
499 chrpath -r foo $Libraries/libfreeblpriv3.so
500 chrpath -r foo $Libraries/libnsspem.so
501
502 while [ true ] ; do
503         missing=false
504         filelist=`find $APPLIB/ -type f`
505         filelist="$APPBIN/${EXENAME}-${release_version} $filelist"
506
507         for file in $filelist  ; do
508                 if ! file $file | grep -qs ELF ; then
509                         continue
510                 fi
511
512                 # speed this up a bit by not checking things multiple times.
513                 for i in "${depCheckedList[@]}"; do
514                         if [ $i == $file ]; then
515                                 continue 2
516                         fi
517                 done
518                 depCheckedList[$checkIdx]=$file
519                 checkIdx=$(($checkIdx + 1))
520
521                 # ignore suil/qt wrappers - the plugin will pull in QT4.
522                 if echo $file | grep -qs 'libsuil_.*qt[45]' ; then continue; fi
523
524                 # do not include libjack, nor libwine
525                 deps=`LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file | grep -v libwine.so | awk '{print $3}'`
526
527                 echo -n "."
528                 for dep in $deps ; do
529                         if test "not" = ${dep}; then
530                                 echo ""
531                                 echo "!!! ERROR !!! - Missing dependant library for $file."
532                                 echo "Searched: " $OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
533                                 echo ""
534                                 (LD_LIBRARY_PATH=$OURLIBS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} ldd $file)
535                                 echo ""
536                                 echo "!!! ERROR !!! - See Above"
537                                 exit 1
538                         fi
539
540                         # don't use anything mapped at a specific address
541                         if echo $dep | grep -qs '0x' ; then continue; fi
542                         # don't include /lib
543                         if echo $dep | grep -qs "^/lib/" ; then continue; fi
544                         # don't include jack
545                         if echo $dep | grep -qs libjack ; then continue; fi
546                         # don't include ALSA
547                         if echo $dep | grep -qs libasound ; then continue; fi
548                         # don't include any X Window libraries
549                         if echo $dep | grep -qs libX\. ; then continue; fi
550                         if echo $dep | grep -qs libxcb ; then continue; fi
551                         if echo $dep | grep -qs libICE\. ; then continue; fi
552                         if echo $dep | grep -qs libSM\. ; then continue; fi
553                         # don't include libc
554                         if echo $dep | grep -qs 'libc\.' ; then continue; fi
555                         # don't include libstdc++
556                         if echo $dep | grep -qs libstdc++ ; then continue; fi
557                         # don't include libdbus (alsa request device)
558                         if echo $dep | grep -qs libdbus ; then continue; fi
559                         # nor libudev (hidapi)
560                         if echo $dep | grep -qs libudev ; then continue; fi
561
562                         base=`basename $dep`
563                         if ! test -f $Libraries/$base; then
564                                 parent=$(basename ${file})
565                                 if echo $dep | grep -sq '^libs' ; then
566                                         echo "Copying dependant lib $BUILD_ROOT/$dep    (required by ${parent})"
567                                         cp $BUILD_ROOT/$dep $Libraries
568                                 else
569                                         echo "Copying dependant lib $dep    (required by ${parent})"
570                                         cp $dep $Libraries
571                                 fi
572                                 #
573                                 # reset RPATH so that the runtime linker never looks
574                                 # in places we don't want it to
575                                 #
576                                 chrpath -r foo $Libraries/`basename $dep`
577                                 if echo $dep | grep -sq '^/' ; then
578                                     # absolute path, candidate for stripping
579                                     deplibs="$deplibs $base"
580                                 fi
581                                 missing=true
582                         fi
583                 done
584         done
585         if test x$missing = xfalse ; then
586                 # everything has been found
587                 break
588         fi
589 done
590 echo
591
592 # strip libraries
593 if test x$STRIP = xall ; then
594     echo Stripping all libraries
595     # Must be writable so that we can strip
596     find $APPLIB/ -name "*.so*" -print0 | xargs -0 chmod u+w
597     # and strip ...
598     find $APPLIB/ -name "*.so*" -print0 | xargs -0 strip -s
599 elif test x$STRIP = xsome ; then
600     echo Stripping dependent libraries
601     for l in $deplibs ; do
602         if echo "$l" | grep -qE "$NOSTRIP"; then
603             continue
604         fi
605         chmod u+w $APPLIB/$l
606         strip -s $APPLIB/$l
607     done
608 fi
609 find $APPLIB/ -name "*.so*" -print0 | xargs -0 chmod a+rx
610
611 echo "Copying other stuff to $APPDIR  ..."
612
613 # these are all generated by waf
614 cp $BUILD_ROOT/gtk2_ardour/ardour.keys  $Etc
615 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc
616 cp $BUILD_ROOT/gtk2_ardour/clearlooks.rc $Etc
617 cp $BUILD_ROOT/gtk2_ardour/default_ui_config $Etc
618
619 # Copied directly from source tree
620
621 mkdir ${Shared}/icons
622 mkdir ${Shared}/resources
623 cp ../../gtk2_ardour/icons/*.png ${Shared}/icons
624 cp -r ../../gtk2_ardour/icons/cursor_* ${Shared}/icons/
625 cp ../../gtk2_ardour/ArdourMono.ttf $Shared
626 cp ../../gtk2_ardour/resources/${APPNAME}-* ${Shared}/resources/
627
628 # Themes: only install those named for this app
629 cp ../../gtk2_ardour/themes/*-${lower_case_appname}.colors $Themes
630
631 #
632 # put sooper sekrit ingredients here and they will be copied
633 #
634
635 if [ -d specialSauce ] ; then
636         cp -r specialSauce $Etc
637 fi
638
639 # install bundled LV2s to <app>/lib/LV2/
640 cp -R $BUILD_ROOT/libs/LV2 $APPLIB/
641
642 # lv2 core, classifications etc - TODO check if we need the complete LV2 ontology
643 if test -d $ARDOURSTACK_ROOT/lib/lv2/lv2core.lv2 ; then
644         mkdir -p $APPLIB/LV2/lv2core.lv2
645         cp -R $ARDOURSTACK_ROOT/lib/lv2/lv2core.lv2/*.ttl $APPLIB/LV2/lv2core.lv2/
646 elif test -d $GTKSTACK_ROOT/lib/lv2/lv2core.lv2 ; then
647         mkdir -p $APPLIB/LV2/lv2core.lv2
648         cp -R $GTKSTACK_ROOT/lib/lv2/lv2core.lv2/*.ttl $APPLIB/LV2/lv2core.lv2/
649 fi
650
651 # go through and recursively remove any .svn dirs in the bundle
652 for svndir in `find $APPDIR -name .svn -type d`; do
653         rm -rf $svndir
654 done
655
656
657 ################################################################################
658 ### Mixbus plugins, etc
659 if test x$WITH_HARRISON_LV2 != x ; then
660         echo "Adding Harrison LV2s"
661         mkdir -p $APPLIB/LV2
662
663         curl -s -S --fail -# \
664                 -z "${CACHEDIR}/${HARRISONLV2}.${HARCH}.zip" \
665                 -o "${CACHEDIR}/${HARRISONLV2}.${HARCH}.zip" \
666                 "${HARRISONDSPURL}/${HARRISONLV2}.${HARCH}.zip"
667         unzip -q -d "$APPLIB/LV2/" "${CACHEDIR}/${HARRISONLV2}.${HARCH}.zip"
668 fi
669
670 if test -n "$MIXBUS"; then
671         echo "Adding Mixbus Channelstrip"
672
673         mkdir -p $APPLIB/ladspa/strip/
674         curl -s -S --fail -# \
675                 -z "${CACHEDIR}/${HARRISONCHANNELSTRIP}.${HARCH}.so" \
676                 -o "${CACHEDIR}/${HARRISONCHANNELSTRIP}.${HARCH}.so" \
677                 "${HARRISONDSPURL}/${HARRISONCHANNELSTRIP}.${HARCH}.so"
678
679         cp "${CACHEDIR}/${HARRISONCHANNELSTRIP}.${HARCH}.so" \
680                 $APPLIB/ladspa/strip/${HARRISONCHANNELSTRIP}.so
681         chmod +x $APPLIB/ladspa/strip/${HARRISONCHANNELSTRIP}.so
682
683         echo "Adding Harrison Vamp Plugins"
684
685         if test "$GCC5ABI" = "true"; then
686                 VAMPARCH="${HARCH}gcc5"
687         else
688                 VAMPARCH="${HARCH}"
689         fi
690         curl -s -S --fail -# \
691                 -z "${CACHEDIR}/harrison_vamp.${VAMPARCH}.so" \
692                 -o "${CACHEDIR}/harrison_vamp.${VAMPARCH}.so" \
693                 "${HARRISONDSPURL}/harrison_vamp.${VAMPARCH}.so"
694
695         cp "${CACHEDIR}/harrison_vamp.${VAMPARCH}.so" \
696                 $APPLIB/harrison_vamp.so
697         chmod +x $APPLIB/harrison_vamp.so
698 fi
699
700 if true ; then
701         mkdir -p $APPLIB/LV2
702
703         echo "Adding General MIDI Synth LV2"
704
705         for proj in x42-gmsynth ; do
706                 X42_VERSION=$(curl -s -S http://x42-plugins.com/x42/linux/${proj}.latest.txt)
707                 rsync -a -q --partial \
708                         rsync://x42-plugins.com/x42/linux/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip \
709                         "${CACHEDIR}/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip"
710                 unzip -q -d "$APPLIB/LV2/" "${CACHEDIR}/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip"
711         done
712 fi
713
714
715 if test x$WITH_X42_LV2 != x ; then
716         mkdir -p $APPLIB/LV2
717
718         echo "Adding x42 Plugins"
719
720         for proj in x42-meters x42-midifilter x42-midimap x42-stereoroute x42-eq setBfree x42-avldrums; do
721                 X42_VERSION=$(curl -s -S http://x42-plugins.com/x42/linux/${proj}.latest.txt)
722                 rsync -a -q --partial \
723                         rsync://x42-plugins.com/x42/linux/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip \
724                         "${CACHEDIR}/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip"
725                 unzip -q -d "$APPLIB/LV2/" "${CACHEDIR}/${proj}-lv2-linux-${WARCH}-${X42_VERSION}.zip"
726         done
727 fi
728
729 ################################################################################
730
731 if test x$WITH_HARVID != x ; then
732         cd $APPBIN
733         HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
734         XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
735
736         rsync -Pa \
737                 rsync://ardour.org/video-tools/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz \
738                 "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz"
739
740         rsync -Pa \
741                 rsync://ardour.org/video-tools/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz \
742                 "$CACHEDIR/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz"
743
744         tar -x -z \
745                 --exclude=README --exclude=harvid.1 --strip-components=1 \
746                 -f "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz" || exit 1
747
748         tar -x -z \
749                 --exclude=README --exclude=xjadeo.1 --strip-components=1 \
750                 -f "$CACHEDIR/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz" || exit 1
751         mv xjadeo xjremote
752         cd -
753 fi
754
755 ################################################################################
756
757 if test x$DEMO_SESSION_URL != x ; then
758         mkdir -p $Shared/sessions
759         DEMO_SESSIONS=$(curl -s -S --fail $DEMO_SESSION_URL/index.txt)
760         for demo in $DEMO_SESSIONS; do
761                 curl -s -S --fail -# -o $Shared/sessions/$demo $DEMO_SESSION_URL/$demo
762         done
763 fi
764
765 ################################################################################
766
767 #
768 # Add the uninstaller
769 #
770 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
771 chmod a+x $APPBIN/${APP_VER_NAME}.uninstall.sh
772
773 #
774 # Add the stage2.run script
775 #
776 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
777 chmod a+x stage2.run
778
779
780 #Sanity Check file
781 if [ -e $BUILD_ROOT/tools/sanity_check/sanityCheck ]; then
782         cp $BUILD_ROOT/tools/sanity_check/sanityCheck $APPBIN
783 else
784         echo "!!!ERROR !!! sanityCheck program is missing. packager will exit without being complete"
785         exit 1
786 fi
787
788 echo "Building tarball ..."
789
790 rm -f $APPDIR.tar
791 tar -cf $APPDIR.tar $APPDIR
792
793 echo "Calculating bundle size"
794 du -sb $APPDIR/  | awk '{print $1}' > $APPDIR.size
795
796 ( cd $APPDIR ; find . ) > file_list.txt
797
798 rm -rf $APPDIR/
799
800 echo "Done."
801