Mixbus32 and 32C packaging
[ardour.git] / tools / osx_packaging / osx_build
1 #!/bin/bash
2
3 set -e
4
5 # script for pulling together a MacOSX app bundle.
6
7 GTKSTACK_ROOT=$HOME/gtk/inst
8 ARDOURSTACK_ROOT=$HOME/a3/inst
9 BUILD_ROOT=../../build
10
11 # where harvid and xjadeo binaries are cached
12 if test -z "$CACHEDIR" -o ! -d "$CACHEDIR"; then
13         CACHEDIR=/var/tmp
14 fi
15 mkdir -p "$CACHEDIR"
16
17 SAE=
18 MIXBUS=
19 MIXBUS32C=
20 WITH_HARVID=1
21 WITH_HARRISON_LV2=
22 WITH_X42_LV2=
23 WITH_LADSPA=1
24 STRIP=1
25 PRINT_SYSDEPS=
26 WITH_NLS=
27 : ${HARRISONCHANNELSTRIP=harrison_channelstrip}
28
29 . ../define_versions.sh
30
31 while [ $# -gt 0 ] ; do
32     echo "arg = $1"
33     case $1 in
34
35         #
36         # top level build targets
37         #
38
39         --sae)
40                 SAE=1 ;
41                 WITH_LADSPA=1;
42                 STRIP= ;
43                 PRODUCT_PKG_DIR=ArdourSAE ;
44                 APPNAME=Ardour ;
45                 shift ;;
46         --mixbus) MIXBUS=1;
47                 WITH_HARRISON_LV2=1 ;
48                 WITH_X42_LV2=1 ;
49                 WITH_NLS=1 ;
50                 SAE= ;
51                 WITH_LADSPA=;
52                 STRIP= ;
53                 PRODUCT_PKG_DIR=Mixbus;
54                 APPNAME=Mixbus ;
55                 shift ;;
56         --mixbus32c) MIXBUS=1;
57                 MIXBUS32C=1;
58                 WITH_HARRISON_LV2=1 ;
59                 WITH_X42_LV2=1 ;
60                 WITH_NLS=1 ;
61                 SAE= ;
62                 WITH_LADSPA=;
63                 STRIP= ;
64                 PRODUCT_PKG_DIR=Mixbus32C;
65                 APPNAME=Mixbus32C-${major_version} ;
66                 major_version=""
67                 shift ;;
68         --public)
69                 SAE= ;
70                 WITH_LADSPA=1;
71                 PRODUCT_PKG_DIR=Ardour;
72                 APPNAME=Ardour ;
73                 shift ;;
74         --allinone) SAE= ;
75                 WITH_LADSPA=1;
76                 STRIP= ;
77                 PRODUCT_PKG_DIR=Ardour ;
78                 shift ;;
79         --test) SAE= ; WITH_LADSPA=; STRIP= ; shift ;;
80
81         #
82         # specific build flags
83         #
84
85         --noharvid) WITH_HARVID= ; shift ;;
86         --noladspa) WITH_LADSPA= ; shift ;;
87         --nostrip) STRIP= ; shift ;;
88         --sysdeps) PRINT_SYSDEPS=1; shift ;;
89         --nls) WITH_NLS=1 ; shift ;;
90         --chanstrip) HARRISONCHANNELSTRIP=$2 ; shift; shift ;;
91     esac
92 done
93
94 if test -z "$PRODUCT_PKG_DIR" -o -z "$APPNAME"; then
95         echo "application or product-name was not specified"
96         exit 1
97 fi
98
99 echo "Version is $release_version"
100 if [ "x$commit" != "x" ] ; then
101     info_string="$release_version ($commit) built on `hostname` by `whoami` on `date`"
102 else
103     info_string="$release_version built on `hostname` by `whoami` on `date`"
104 fi
105 echo "Info string is $info_string"
106
107 if [ x$DEBUG = xT ]; then
108         STRIP=
109         echo "Debug build, strip disabled"
110 else
111         if test x$STRIP != x ; then
112                 echo "No debug build, strip enabled"
113         else
114                 echo "No debug build, but strip disabled."
115         fi
116 fi
117
118 # setup directory structure
119
120 APPDIR=${APPNAME}${major_version}.app
121 APPROOT=$APPDIR/Contents
122 Frameworks=$APPROOT/lib
123 Resources=$APPROOT/Resources
124 #
125 # Since this is OS X, don't try to distinguish between etc and shared
126 # (machine dependent and independent data) - just put everything
127 # into Resources.
128
129 Shared=$Resources
130 Etc=$Resources
131 Locale=$Resources/locale
132 #
133 # Bundled Plugins live in a top level folder
134
135 Plugins=$APPROOT/Plugins
136 Surfaces=$Frameworks/surfaces
137 Panners=$Frameworks/panners
138 Backends=$Frameworks/backends
139 MidiMaps=$Shared/midi_maps
140 ExportFormats=$Shared/export
141 Templates=$Shared/templates
142 PatchFiles=$Shared/patchfiles
143 LuaScripts=$Shared/scripts
144 MackieControl=$Shared/mcp
145
146 if [ x$PRINT_SYSDEPS != x ] ; then
147 #
148 # print system dependencies
149 #
150
151 for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Plugins/*.so ; do
152         if ! file $file | grep -qs Mach-O ; then
153             continue
154         fi
155         otool -L $file | awk '{print $1}' | egrep -v "(^@executable_path|^Ardour[0-9][.0-9]*.app)" 
156     done | sort | uniq
157     exit 0
158 fi
159
160 echo "Removing old $APPDIR tree ..."
161
162 rm -rf $APPDIR
163
164 echo "Building new app directory structure ..."
165
166 # only bother to make the longest paths
167
168 mkdir -p $APPROOT/MacOS
169 mkdir -p $APPROOT/Resources
170 mkdir -p $Plugins
171 mkdir -p $Surfaces
172 mkdir -p $Panners
173 mkdir -p $Backends
174 mkdir -p $MidiMaps
175 mkdir -p $ExportFormats
176 mkdir -p $Templates
177 mkdir -p $Frameworks/modules
178 mkdir -p $Etc
179 mkdir -p $MackieControl
180 mkdir -p $PatchFiles
181 mkdir -p $LuaScripts
182
183 # maybe set variables
184 env=""
185 if test x$SAE != x ; then
186     appname="Ardour${major_version}-SAE"
187     EXECUTABLE=${appname}
188     env="$env<key>ARDOUR_SAE</key><string>true</string>"
189     #
190     # current default for SAE version is German keyboard layout without a keypad
191     #
192     env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>de-nokeypad</string>"
193     env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui_sae.conf</string>"
194 elif test x$MIXBUS != x ; then
195     appname=$APPNAME
196     EXECUTABLE=${appname}${major_version}
197     env="$env<key>ARDOUR_MIXBUS</key><string>true</string>"
198     #
199     # current default for MIXBUS version is US keyboard layout without a keypad
200     #
201     env="$env<key>ARDOUR_KEYBOARD_LAYOUT</key><string>us-nokeypad</string>"
202     env="$env<key>ARDOUR_UI_CONF</key><string>ardour3_ui.conf</string>"
203 else
204     appname="Ardour${major_version}"
205     EXECUTABLE=${appname}
206 fi
207
208 #
209 # if we're not going to bundle JACK, make sure we can find
210 # jack in the places where it might be
211 #
212
213 env="$env<key>PATH</key><string>/usr/local/bin:/opt/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>"
214 env="$env<key>DYLIB_FALLBACK_LIBRARY_PATH</key><string>/usr/local/lib:/opt/lib</string>"
215
216 env="<key>LSEnvironment</key><dict>$env<key>ARDOUR_BUNDLED</key><string>true</string></dict>"
217
218
219 # edit plist
220 sed -e "s?@ENV@?$env?g" \
221     -e "s?@VERSION@?$release_version?g" \
222     -e "s?@INFOSTRING@?$info_string?g" \
223     -e "s?@IDSUFFIX@?$EXECUTABLE?g" \
224     -e "s?@BUNDLENAME@?${APPNAME}${major_version}?g" \
225     -e "s?@EXECUTABLE@?$EXECUTABLE?g" < Info.plist.in > Info.plist
226 # and plist strings
227 sed -e "s?@APPNAME@?$appname?" \
228     -e "s?@ENV@?$env?g" \
229     -e "s?@VERSION@?$release_version?g" \
230     -e "s?@INFOSTRING@?$info_string?g" < InfoPlist.strings.in > Resources/InfoPlist.strings || exit 1
231
232 # copy static files
233
234 cp Info.plist $APPROOT
235 cp -R Resources $APPROOT
236
237 # ..and clean up
238 rm -f Info.plist
239 rm -f Resources/InfoPlist.strings
240
241 #
242 # if we build a bundle without jack, then
243 # make the Ardour executable a helper
244 # script that checks to see if JACK is
245 # installed.
246 #
247
248 cp startup_script $APPROOT/MacOS/$EXECUTABLE
249 chmod 775 $APPROOT/MacOS/$EXECUTABLE
250 MAIN_EXECUTABLE=Ardour.bin  ## used in startup_script
251
252 echo "Copying ardour executable ...."
253 cp $BUILD_ROOT/gtk2_ardour/ardour-$release_version $APPROOT/MacOS/$MAIN_EXECUTABLE
254 if test x$SAE != x ; then
255     # cp $BUILD_ROOT/gtk2_ardour/evtest $APPROOT/MacOS/gtkevents
256     cp  Ardour3-SAE.icns $Resources/appIcon.icns
257 elif test x$MIXBUS32C != x ; then
258     cp  Mixbus32C.icns $Resources/appIcon.icns
259 elif test x$MIXBUS != x ; then
260     cp  Mixbus.icns $Resources/appIcon.icns
261 else
262     cp  Ardour.icns $Resources/appIcon.icns
263 fi
264 cp  typeArdour.icns $Resources/
265
266 set +e # things below are not error-free (optional files etc) :(
267
268 # copy locale files
269 if test x$WITH_NLS != x ; then
270     echo "NLS support ..."
271     echo "I hope you remembered to run waf i18n"
272     LINGUAS=
273
274     for pkg in gtk2_ardour libs/ardour libs/gtkmm2ext ; do 
275         files=`find ../../$pkg -name "*.mo"`
276         
277             #
278             # the package name is appended with a number so that
279             # it can be parallel installed during a regular install
280             # with older (and newer) versions. it is just the major
281             # number of the release (i.e. leading digits)
282             #
283         
284         vsuffix=`echo $release_version | sed 's/^\([0-9][0-9]*\).*/\1/'`
285         
286         if [ -z "$files" ]; then
287             echo ""
288             echo "!!!! WARNING !!!! - Did not find any .mo files in ../../$pkg"
289             echo ""
290         fi
291         
292         for file in $files 
293         do
294             echo $file
295             lang=`basename $file | sed 's/\.mo//'`
296             mkdir -p $Locale/$lang/LC_MESSAGES
297             cp $file $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
298             echo copy $file to $Locale/$lang/LC_MESSAGES/`basename $pkg`$vsuffix.mo
299             if echo $LINGUAS | grep $lang >/dev/null 2>&1 ; then
300                 :
301             else 
302                 LINGUAS="$LINGUAS $lang"
303             fi
304         done
305     done
306
307     for l in $LINGUAS
308     do
309       if [ -d $GTKSTACK_ROOT/share/locale/$l ] ; then
310           echo "Copying GTK i18n files for $l..."
311           cp -r $GTKSTACK_ROOT/share/locale/$l $Locale
312       else
313           # try with just the language spec
314           just_lang=`echo $l | sed 's/_[A-Z][A-Z]$//'`
315           if [ -d $GTKSTACK_ROOT/share/locale/$just_lang ] ; then
316               echo "Copying GTK i18n files for $l..."
317               cp -r $GTKSTACK_ROOT/share/locale/$just_lang $Locale
318           fi
319       fi
320     done
321 else
322     echo "Skipping NLS support"
323 fi
324
325 #
326 # Copy stuff that may be dynamically loaded
327
328
329 cp -R $GTKSTACK_ROOT/etc/* $Etc
330 cp -R $GTKSTACK_ROOT/lib/charset.alias $Resources
331
332 # We rely on clearlooks, so include a version from our own build tree
333 # this one is special - we will set GTK_PATH to $Frameworks/gtkengines
334
335 GTK_ENGINE_DIR=$Frameworks/gtkengines/engines
336 mkdir -p $GTK_ENGINE_DIR
337
338 echo "Copying GTK engines ..."
339 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.dylib $Frameworks
340 (cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.dylib . && ln -s ../../libclearlooks.dylib libclearlooks.so)
341
342 cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Frameworks
343 (cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so)
344
345
346 if test x$WITH_LADSPA != x ; then
347     if test x$SAE != x ; then
348         plugdir=sae_ladspa
349     elif test x$MIXBUS != x ; then
350         plugdir=mixbus_ladspa
351     else
352         plugdir=ladspa
353     fi
354     if [ -d $plugdir -a "x$(ls $plugdir)" != x ] ; then 
355         echo "Copying `ls $plugdir | wc -l` plugins ..."
356         cp -r $plugdir/* $Plugins
357     fi
358 fi
359
360 # Control Surface shared libraries
361 cp $BUILD_ROOT/libs/surfaces/*/libardour_*.dylib $Surfaces
362 cp $BUILD_ROOT/libs/surfaces/control_protocol/libardourcp*.dylib $Frameworks
363
364 # Panners
365 cp $BUILD_ROOT/libs/panners/*/lib*.dylib $Panners
366
367 # Backends
368 for backend in jack wavesaudio dummy coreaudio; do
369     cp $BUILD_ROOT/libs/backends/$backend/lib*.dylib $Backends
370 done
371
372 # Export Formats/Presets
373 for f in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do 
374     cp "$f" $ExportFormats ; 
375 done
376
377 # Session and Route templates
378 #for f in $BUILD_ROOT/../templates/* ; do 
379 #    if [ -d "$f" ] ; then
380 #        cp -r "$f" $Templates ; 
381 #    fi
382 #done
383
384 # MidiMaps
385 # got to be careful with names here
386 for x in $BUILD_ROOT/../midi_maps/*.map ; do
387     cp "$x" $MidiMaps
388 done
389
390 # MIDNAM Patch Files
391 # got to be careful with names here
392 for x in $BUILD_ROOT/../patchfiles/*.midnam ; do
393     cp "$x" $PatchFiles
394 done
395
396 # Lua Script Files
397 # got to be careful with names here
398 for x in $BUILD_ROOT/../scripts/*.lua ; do
399     cp "$x" $LuaScripts
400 done
401
402 # MackieControl data
403 # got to be careful with names here
404 for x in $BUILD_ROOT/../mcp/*.device $BUILD_ROOT/../mcp/*.profile ; do
405     cp "$x" $MackieControl
406 done
407
408 # VAMP plugins that we use
409 cp $BUILD_ROOT/libs/vamp-plugins/libardourvampplugins.dylib $Frameworks
410
411 # Suil modules (new dir 'build-stack')
412 if test -d $GTKSTACK_ROOT/lib/suil-0/ ; then
413     cp $GTKSTACK_ROOT/lib/suil-0/lib* $Frameworks
414 fi
415
416 # Suil modules (old dir 'build-ardour-stack')
417 if test -d $ARDOURSTACK_ROOT/lib/suil-0/ ; then
418     cp $ARDOURSTACK_ROOT/lib/suil-0/lib* $Frameworks
419 fi
420
421 # VST scanner app and wrapper script, if they exist
422 if test -d $BUILD_ROOT/libs/fst ; then
423     cp $BUILD_ROOT/libs/fst/ardour-vst-scanner* $Frameworks/
424 fi
425
426 # vfork wrapper
427 if test -f $BUILD_ROOT/libs/vfork/ardour-exec-wrapper ; then
428     mkdir -p $Frameworks/vfork
429     cp $BUILD_ROOT/libs/vfork/ardour-exec-wrapper $Frameworks/
430 fi
431
432 # TODO check if this is still needed, even when building on 10.5
433 if file $BUILD_ROOT/gtk2_ardour/ardour-$release_version | grep -q ppc; then
434 STDCPP='|libstdc\+\+'
435 else
436 STDCPP=
437 fi
438
439 while [ true ] ; do 
440     missing=false
441     for file in $APPROOT/MacOS/* $Frameworks/* $Frameworks/modules/* $Panners/*.dylib $Backends/*.dylib $Surfaces/*.dylib $Plugins/*.so ; do 
442         if ! file $file | grep -qs Mach-O ; then
443             continue
444         fi
445         # libffi contains "S" (other section symbols) that should not be stripped.
446         if [[ $file == *"libffi"* ]] ; then
447             continue
448         fi
449
450         if test x$STRIP != x ; then
451                 strip -u -r -arch all $file &>/dev/null
452         fi
453
454         deps=`otool -L $file | awk '{print $1}' | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/$STDCPP)" | grep -v 'libjack\.' | grep -v "$(basename $file)"`
455         # echo -n "."
456         for dep in $deps ; do
457             base=`basename $dep`
458             if ! test -f $Frameworks/$base; then
459                 if echo $dep | grep -sq '^libs' ; then
460                     cp $BUILD_ROOT/$dep $Frameworks
461                 else
462                     cp $dep $Frameworks
463                 fi
464                 missing=true
465             fi
466         done
467     done
468     if test x$missing = xfalse ; then
469         # everything has been found
470         break
471     fi
472 done
473 echo
474
475 echo "Copying other stuff to $APPDIR  ..."
476
477 cp $BUILD_ROOT/gtk2_ardour/ardour.keys  $Resources
478 cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Resources
479 cp $BUILD_ROOT/gtk2_ardour/default_ui_config $Resources
480 cp $BUILD_ROOT/gtk2_ardour/clearlooks.rc $Resources
481
482 # Copied directly from source tree
483
484 cp ../../system_config $Resources/system_config
485 cp ../../instant.xml $Resources/instant.xml
486 cp -r ../../gtk2_ardour/icons $Resources
487 cp -r ../../gtk2_ardour/pixmaps $Resources
488 cp ../../gtk2_ardour/*.colors $Resources
489 cp -R ../../gtk2_ardour/splash.png $Shared
490 cp -R ../../gtk2_ardour/small-splash.png $Shared
491 cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared
492
493 # go through and recursively remove any .svn dirs in the bundle
494 for svndir in `find $APPDIR -name .svn -type dir`; do
495     rm -rf $svndir
496 done
497
498 # install bundled LV2s to <app>/Contents/lib/LV2/
499 cp -R $BUILD_ROOT/libs/LV2 $Frameworks/
500
501 # lv2 core, classifications etc - TODO check if we need the complete LV2 ontology
502 if test -d $ARDOURSTACK_ROOT/lib/lv2/lv2core.lv2 ; then
503         cp -R $ARDOURSTACK_ROOT/lib/lv2/lv2core.lv2 $Frameworks/LV2/
504 elif test -d $GTKSTACK_ROOT/lib/lv2/lv2core.lv2 ; then
505         cp -R $GTKSTACK_ROOT/lib/lv2/lv2core.lv2 $Frameworks/LV2/
506 fi
507
508
509 # now fix up the executables
510 echo "Fixing up executable dependency names ..."
511 executables=$MAIN_EXECUTABLE
512 if test x$SAE != x ; then
513     executables="$executables"
514 fi
515
516 for exe in $executables; do
517     EXE=$APPROOT/MacOS/$exe
518     changes=""
519     for lib in `otool -L $EXE | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/$STDCPP)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
520       base=`basename $lib`
521       changes="$changes -change $lib @executable_path/../lib/$base"
522     done
523     if test "x$changes" != "x" ; then
524         install_name_tool $changes $EXE
525     fi
526 done
527
528 echo "Fixing up library names ..."
529 # now do the same for all the libraries we include
530 for libdir in $Frameworks $Frameworks/modules $Surfaces $Panners $Backends ; do
531
532     libbase=`basename $libdir`
533     
534     for dylib in $libdir/*.dylib $libdir/*.so ; do
535         
536        # skip symlinks
537         
538         if test -L $dylib ; then
539             continue
540         fi
541         
542         # change all the dependencies
543         
544         changes=""
545         for lib in `otool -L $dylib | egrep "($GTKSTACK_ROOT|$ARDOURSTACK_ROOT|/opt/|/local/|libs/$STDCPP)" | awk '{print $1}' | grep -v 'libjack\.'` ; do
546             base=`basename $lib`
547             if echo $lib | grep -s libbase; then
548                 changes="$changes -change $lib @executable_path/../$libbase/$base"
549             else
550                 changes="$changes -change $lib @executable_path/../lib/$base"
551             fi
552         done
553         
554         if test "x$changes" != x ; then
555             if  install_name_tool $changes $dylib ; then
556                 :
557             else
558                 exit 1
559             fi
560         fi
561         
562         # now the change what the library thinks its own name is
563         
564         base=`basename $dylib`
565         install_name_tool -id @executable_path/../$libbase/$base $dylib
566     done
567 done
568
569 #
570 # and now ... the DMG
571
572
573 rm -rf $PRODUCT_PKG_DIR
574 mkdir $PRODUCT_PKG_DIR
575
576 DMGWINBOTTOM=440
577 DMGBACKGROUND=dmgbg
578
579 if [ x$SAE != x ] ; then
580         
581     # SAE packaging
582     
583     echo "Creating SAE packaging directory"
584     mv $APPDIR $PRODUCT_PKG_DIR/Ardour3-SAE.app
585     cp HowToInstallArdourSAE.pdf "$PRODUCT_PKG_DIR/How To Install Ardour SAE.pdf"
586     cp SAE-de-keypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts (keypad).pdf"
587     cp SAE-de-nokeypad.pdf "$PRODUCT_PKG_DIR/Ardour SAE Shortcuts.pdf"
588     
589 elif [ x$MIXBUS != x ] ; then
590
591      # Mixbus packaging
592
593     echo "Creating Mixbus packaging directory"
594     mv $APPDIR $PRODUCT_PKG_DIR/
595     DMGBACKGROUND=dmgbgMB
596 else 
597
598     echo "Creating $APPNAME packaging directory"
599     mv $APPDIR $PRODUCT_PKG_DIR/
600
601 fi
602
603 if file ${PRODUCT_PKG_DIR}/$APPROOT/MacOS/$MAIN_EXECUTABLE | grep -q x86_64; then
604         OSX_ARCH=x86_64
605         OSX_BENSID=osx64
606 elif file ${PRODUCT_PKG_DIR}/$APPROOT/MacOS/$MAIN_EXECUTABLE | grep -q ppc; then
607         OSX_ARCH=ppc
608         OSX_BENSID=osxppc
609 else
610         OSX_ARCH=i386
611         OSX_BENSID=osx32
612 fi
613
614 if test x$WITH_HARRISON_LV2 != x ; then
615         curl -s -S --fail -#  \
616                 -z "${CACHEDIR}/harrison_lv2s.${OSX_BENSID}.zip" \
617                 -o "${CACHEDIR}/harrison_lv2s.${OSX_BENSID}.zip" \
618                 "http://www.harrisonconsoles.com/mixbus/mb3/beta/harrison-dsp/harrison_lv2s.${OSX_BENSID}.zip"
619
620         mkdir -p "${PRODUCT_PKG_DIR}/${APPROOT}/lib/LV2"
621         bsdtar -C "${PRODUCT_PKG_DIR}/${APPROOT}/lib/LV2/" -xf \
622                 "${CACHEDIR}/harrison_lv2s.${OSX_BENSID}.zip"
623 fi
624
625 if test x$WITH_HARVID != x ; then
626         echo "installing video tools.."
627         HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
628         XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
629         MULTIARCH=osx
630         echo "copying harvid and xjadeo ..."
631
632         rsync -Pa \
633                 rsync://ardour.org/video-tools/harvid-osx-${HARVID_VERSION}.tgz \
634                 "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz"
635
636         rsync -Pa \
637                 rsync://ardour.org/video-tools/jadeo-${XJADEO_VERSION:1}.dmg \
638                 "$CACHEDIR/jadeo-${XJADEO_VERSION:1}.dmg"
639
640         tar -x -z \
641                 -C $PRODUCT_PKG_DIR/$APPROOT \
642                 -f "$CACHEDIR/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz" || exit 1
643
644         JADEO=$(hdiutil attach "$CACHEDIR/jadeo-${XJADEO_VERSION:1}.dmg" | grep Apple_HFS | grep dev/ | cut -f 3)
645         cp -r "${JADEO}/Jadeo.app" "$PRODUCT_PKG_DIR/"
646         hdiutil detach "${JADEO}"
647
648         XJCONTENT=${PRODUCT_PKG_DIR}/Jadeo.app/Contents
649         HVLIBS=${PRODUCT_PKG_DIR}/$APPROOT/lib/harvid
650
651         for file in ${XJCONTENT}/MacOS/Jadeo-bin ${XJCONTENT}/Frameworks/*.dylib ${HVLIBS}/*.dylib ${PRODUCT_PKG_DIR}/$APPROOT/MacOS/*harvid* ; do
652                 lipo -extract_family ${OSX_ARCH} ${file} -output ${file}.thin && \
653                 mv ${file}.thin ${file}
654         done
655
656         DMGWINBOTTOM=580
657         YPOS=$[ $DMGWINBOTTOM - 300 ]
658         XJADEOPOS="set position of item \"Jadeo.app\" of container window to {310, ${YPOS}}"
659
660         DMGBACKGROUND=${DMGBACKGROUND}xj
661 fi
662
663 ################################################################################
664 ### Mixbus plugins, etc
665 if test x$WITH_X42_LV2 != x ; then
666         echo "bundling x42 plugins"
667         mkdir -p "${PRODUCT_PKG_DIR}/${APPROOT}/lib/LV2"
668
669         METERS_VERSION=$(curl -s -S http://x42-plugins.com/x42/osx/x42-meters.latest.txt)
670         rsync -a -q --partial \
671                 rsync://x42-plugins.com/x42/osx/x42-meters-lv2-osx-${METERS_VERSION}.zip \
672                 "$CACHEDIR/x42-meters-lv2-osx-${METERS_VERSION}.zip"
673         bsdtar -C "${PRODUCT_PKG_DIR}/${APPROOT}/lib/LV2/" -xf \
674                 "$CACHEDIR/x42-meters-lv2-osx-${METERS_VERSION}.zip"
675
676         EQ_VERSION=$(curl -s -S http://x42-plugins.com/x42/osx/x42-eq.latest.txt)
677         rsync -a -q --partial \
678                 rsync://x42-plugins.com/x42/osx/x42-eq-lv2-osx-${EQ_VERSION}.zip \
679                 "$CACHEDIR/x42-eq-lv2-osx-${EQ_VERSION}.zip"
680         bsdtar -C "${PRODUCT_PKG_DIR}/${APPROOT}/lib/LV2/" -xf \
681                 "$CACHEDIR/x42-eq-lv2-osx-${EQ_VERSION}.zip"
682
683         SETBFREE_VERSION=$(curl -s -S http://x42-plugins.com/x42/osx/setBfree.latest.txt)
684         rsync -a -q --partial \
685                 rsync://x42-plugins.com/x42/osx/setBfree-lv2-osx-${SETBFREE_VERSION}.zip \
686                 "$CACHEDIR/setBfree-lv2-osx-${SETBFREE_VERSION}.zip"
687         bsdtar -C "${PRODUCT_PKG_DIR}/${APPROOT}/lib/LV2/" -xf \
688                 "$CACHEDIR/setBfree-lv2-osx-${SETBFREE_VERSION}.zip"
689
690         MIDIFILTER_VERSION=$(curl -s -S http://x42-plugins.com/x42/osx/x42-midifilter.latest.txt)
691         rsync -a -q --partial \
692                 rsync://x42-plugins.com/x42/osx/x42-midifilter-lv2-osx-${MIDIFILTER_VERSION}.zip \
693                 "$CACHEDIR/x42-midifilter-lv2-osx-${MIDIFILTER_VERSION}.zip"
694         bsdtar -C "${PRODUCT_PKG_DIR}/${APPROOT}/lib/LV2/" -xf \
695                 "$CACHEDIR/x42-midifilter-lv2-osx-${MIDIFILTER_VERSION}.zip"
696
697         for file in ${PRODUCT_PKG_DIR}/${APPROOT}/lib/LV2/*/*.dylib ; do
698                 lipo -extract_family ${OSX_ARCH} ${file} -output ${file}.thin
699                 mv ${file}.thin ${file}
700         done
701 fi
702
703 if test -n "$MIXBUS"; then
704         echo "deploying harrison tools for $OSX_BENSID"
705
706         mkdir -p "${PRODUCT_PKG_DIR}/${APPROOT}/lib/ladspa/strip"
707
708         curl -s -S --fail -#  \
709                 -z "${CACHEDIR}/${HARRISONCHANNELSTRIP}.${OSX_BENSID}.so" \
710                 -o "${CACHEDIR}/${HARRISONCHANNELSTRIP}.${OSX_BENSID}.so" \
711                 "http://www.harrisonconsoles.com/mixbus/mb3/beta/harrison-dsp/${HARRISONCHANNELSTRIP}.${OSX_BENSID}.so"
712
713         cp "${CACHEDIR}/${HARRISONCHANNELSTRIP}.${OSX_BENSID}.so" \
714                 "${PRODUCT_PKG_DIR}/${APPROOT}/lib/ladspa/strip/${HARRISONCHANNELSTRIP}.so"
715 fi
716 ################################################################################
717
718 ( cd $PRODUCT_PKG_DIR ; find . ) > file_list.txt
719
720 echo "Building DMG ..."
721
722 # UC_DMG=$APPNAME-${release_version}-UC.dmg
723 # FINAL_DMG=$APPNAME-${release_version}.dmg
724
725 if [ x$DEBUG = xT ]; then
726         UC_DMG=$APPNAME-$release_version-dbg.dmg
727 else
728         UC_DMG=$APPNAME-$release_version.dmg
729 fi
730 VOLNAME=$APPNAME-$release_version
731
732 MNTPATH=`mktemp -d -t ardourimg`
733 TMPDMG=`mktemp -t ardour`
734 ICNSTMP=`mktemp -t ardouricon`
735 EXTRA_SPACE_MB=30
736 DMGMEGABYTES=$[ `du -sk "$PRODUCT_PKG_DIR" | cut -f 1` * 1024 / 1048576 + $EXTRA_SPACE_MB ]
737
738 echo "DMG MB = " $DMGMEGABYTES
739
740 rm -f $UC_DMG "$TMPDMG" "${TMPDMG}.dmg" "$ICNSTMP"
741 rm -rf "$MNTPATH"
742 mkdir -p "$MNTPATH"
743
744 TMPDMG="${TMPDMG}.dmg"
745
746 trap "rm -rf $MNTPATH $TMPDMG ${TMPDMG}.dmg $ICNSTMP" EXIT
747
748 hdiutil create -megabytes $DMGMEGABYTES -fs HFS+ -volname "${VOLNAME}" "$TMPDMG"
749 DiskDevice=$(hdid -nomount "$TMPDMG" | grep Apple_HFS | cut -f 1 -d ' ')
750 mount -t hfs -o nobrowse "${DiskDevice}" "${MNTPATH}"
751
752 cp -r ${PRODUCT_PKG_DIR}/* "${MNTPATH}" || exit
753 mkdir "${MNTPATH}/.background"
754 cp -vi ${DMGBACKGROUND}.png "${MNTPATH}/.background/dmgbg.png"
755
756 echo "setting DMG background ..."
757
758 if test $(sw_vers -productVersion | cut -d '.' -f 2) -lt 9; then
759         # OSX ..10.8.X
760         DISKNAME=${VOLNAME}
761 else
762         # OSX 10.9.X and later
763         DISKNAME=`basename "${MNTPATH}"`
764 fi
765
766 osascript << EOF
767   tell application "Finder"
768     activate
769     tell disk "${DISKNAME}"
770       open
771       delay 2
772       set current view of container window to icon view
773       set toolbar visible of container window to false
774       set statusbar visible of container window to false
775       set the bounds of container window to {400, 200, 800, ${DMGWINBOTTOM}}
776       set theViewOptions to the icon view options of container window
777       set arrangement of theViewOptions to not arranged
778       set icon size of theViewOptions to 64
779       set background picture of theViewOptions to file ".background:dmgbg.png"
780       make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
781       set position of item "${APPDIR}" of container window to {90, 100}
782       set position of item "Applications" of container window to {310, 100}
783       ${MIXBUSPOS}
784       ${HARVIDPOS}
785       ${XJADEOPOS}
786       close
787       open
788       update without registering applications
789       delay 5
790       eject
791     end tell
792   end tell
793 EOF
794
795 chmod -Rf go-w "${MNTPATH}"
796 sync
797
798 set -e
799 echo "compressing Image ..."
800
801 # Umount the image ('eject' above may already have done that)
802 umount "${DiskDevice}" || true
803 hdiutil eject "${DiskDevice}" || true
804 # Create a read-only version, use zlib compression
805 hdiutil convert -format UDZO "${TMPDMG}" -imagekey zlib-level=9 -o "${UC_DMG}"
806
807 if test $(sw_vers -productVersion | cut -d '.' -f 2) -gt 5; then
808 echo "setting file icon ..."
809
810 cp ${PRODUCT_PKG_DIR}/$Resources/appIcon.icns ${ICNSTMP}.icns
811 sips -i ${ICNSTMP}.icns
812 DeRez -only icns ${ICNSTMP}.icns > ${ICNSTMP}.rsrc
813 Rez -append ${ICNSTMP}.rsrc -o "$UC_DMG"
814 SetFile -a C "$UC_DMG"
815
816 rm ${ICNSTMP}.icns ${ICNSTMP}.rsrc
817 fi
818
819 rm -rf ${PRODUCT_PKG_DIR}
820
821 echo
822 echo "packaging suceeded."
823 ls -l "$UC_DMG"
824
825 echo "Done."
826 exit