Do not bundle default system_config (prefer built-in defaults)
[ardour.git] / tools / x-win / package.sh
1 #!/bin/bash
2
3 # we assume this script is <ardour-src>/tools/x-win/package.sh
4 pushd "`/usr/bin/dirname \"$0\"`" > /dev/null; this_script_dir="`pwd`"; popd > /dev/null
5 cd $this_script_dir
6
7 . ../define_versions.sh
8
9 cd $this_script_dir/../..
10
11 test -f gtk2_ardour/wscript || exit 1
12
13 # Defaults (overridden by environment)
14 : ${XARCH=i686} # or x86_64
15 : ${ROOT=/home/ardour}
16 : ${MAKEFLAGS=-j4}
17 : ${TMPDIR=/var/tmp}
18 : ${SRCCACHE=/var/tmp/winsrc}  # source-code tgz cache
19
20 : ${HARRISONCHANNELSTRIP=harrison_channelstrip}
21 : ${HARRISONLV2=harrison_lv2s-n}
22 : ${HARRISONDSPURL=http://www.harrisonconsoles.com/plugins/releases/public}
23
24 # see also wscript, video_tool_paths.cc, bundle_env_mingw.cc
25 # registry keys based on this are used there
26 PROGRAM_NAME=Ardour
27 PROGRAM_KEY=Ardour
28 PROGRAM_VERSION=${major_version}
29
30 PRODUCT_NAME=ardour
31 PRODUCT_VERSION=${major_version}
32
33 WITH_HARRISON_LV2=1 ;
34 WITH_X42_LV2=1 ;
35
36 # TODO: grep from build/config.log instead
37 while [ $# -gt 0 ] ; do
38         echo "arg = $1"
39         case $1 in
40                 --mixbus)
41                         MIXBUS=1
42                         WITH_HARRISON_LV2=1 ;
43                         WITH_X42_LV2=1 ;
44                         PROGRAM_NAME=Mixbus
45                         PROGRAM_KEY=Mixbus
46                         PRODUCT_NAME=mixbus
47                         MANUAL_NAME="mixbus${major_version}-live-manual"
48                         shift ;;
49                 --mixbus32c)
50                         MIXBUS=1
51                         WITH_HARRISON_LV2=1 ;
52                         WITH_X42_LV2=1 ;
53                         PRODUCT_NAME=mixbus32c
54                         PROGRAM_KEY=Mixbus32C
55                         PROGRAM_NAME=Mixbus32C-${PROGRAM_VERSION}
56                         PROGRAM_VERSION=""
57                         MANUAL_NAME="mixbus32c-${major_version}-live-manual"
58                         shift ;;
59                 --chanstrip) HARRISONCHANNELSTRIP=$2 ; shift; shift ;;
60         esac
61 done
62
63
64 LOWERCASE_DIRNAME=ardour${major_version}
65 STATEFILE_SUFFIX=ardour # see filename_extensions.cc
66
67
68 # derived variables
69 PRODUCT_ID=${PROGRAM_NAME}${PROGRAM_VERSION}
70 PRODUCT_EXE=${PRODUCT_NAME}.exe
71 PRODUCT_ICON=${PRODUCT_NAME}.ico
72
73 ###############################################################################
74
75 echo "Packaging $PRODUCT_ID"
76
77 if test "$XARCH" = "x86_64" -o "$XARCH" = "amd64"; then
78         echo "Target: 64bit Windows (x86_64)"
79         XPREFIX=x86_64-w64-mingw32
80         WARCH=w64
81 else
82         echo "Target: 32 Windows (i686)"
83         XPREFIX=i686-w64-mingw32
84         WARCH=w32
85 fi
86
87 : ${PREFIX=${ROOT}/win-stack-$WARCH}
88 export SRCCACHE
89
90 if [ "$(id -u)" = "0" ]; then
91         apt-get -y install nsis curl
92 fi
93
94
95 function download {
96 echo "--- Downloading.. $2"
97 test -f ${SRCCACHE}/$1 || curl -k -L -o ${SRCCACHE}/$1 $2
98 }
99
100 ################################################################################
101 set -e
102
103 ARDOURVERSION=${release_version}
104 ARDOURDATE=$(date -R)
105 if ! test -f build/gtk2_ardour/ardour-${ARDOURVERSION}.exe; then
106         echo "*** Please compile  ardour-${ARDOURVERSION}.exe first."
107         exit 1
108 fi
109
110 echo " === bundle to $DESTDIR"
111
112 ./waf install
113
114 ################################################################################
115
116 if test -z "$DESTDIR"; then
117         DESTDIR=`mktemp -d`
118         trap 'rm -rf $DESTDIR' exit SIGINT SIGTERM
119 fi
120
121 echo " === bundle to $DESTDIR"
122
123 ALIBDIR=$DESTDIR/lib/${LOWERCASE_DIRNAME}
124
125 rm -rf $DESTDIR
126 mkdir -p $DESTDIR/bin
127 mkdir -p $DESTDIR/share/
128 mkdir -p $ALIBDIR/surfaces
129 mkdir -p $ALIBDIR/backends
130 mkdir -p $ALIBDIR/panners
131 mkdir -p $ALIBDIR/vamp
132 mkdir -p $ALIBDIR/suil
133
134 cp build/libs/gtkmm2ext/gtkmm2ext-*.dll $DESTDIR/bin/
135 cp build/libs/midi++2/midipp-*.dll $DESTDIR/bin/
136 cp build/libs/evoral/evoral-*.dll $DESTDIR/bin/
137 cp build/libs/ardour/ardour-*.dll $DESTDIR/bin/
138 cp build/libs/timecode/timecode.dll $DESTDIR/bin/
139 cp build/libs/canvas/canvas-*.dll $DESTDIR/bin/
140 cp build/libs/pbd/pbd-*.dll $DESTDIR/bin/
141 cp build/libs/ptformat/ptformat-*.dll $DESTDIR/bin/
142 cp build/libs/audiographer/audiographer-*.dll $DESTDIR/bin/
143 cp build/libs/fst/ardour-vst-scanner.exe $DESTDIR/bin/ || true
144 cp build/session_utils/*-*.exe $DESTDIR/bin/ || true
145 cp `ls -t build/gtk2_ardour/ardour-*.exe | head -n1` $DESTDIR/bin/${PRODUCT_EXE}
146
147 mkdir -p $DESTDIR/lib/gtk-2.0/engines
148 cp build/libs/clearlooks-newer/clearlooks.dll $DESTDIR/lib/gtk-2.0/engines/libclearlooks.la
149
150 cp $PREFIX/bin/*dll $DESTDIR/bin/
151 cp $PREFIX/lib/*dll $DESTDIR/bin/
152 # special case libportaudio (wasapi), old stack has no wasapi and hence no .xp
153 cp $PREFIX/bin/libportaudio-2.xp $DESTDIR/bin/ || cp $PREFIX/bin/libportaudio-2.dll $DESTDIR/bin/libportaudio-2.xp
154 rm -rf $DESTDIR/bin/libjack*.dll
155
156 cp `find build/libs/surfaces/ -iname "*.dll"` $ALIBDIR/surfaces/
157 cp `find build/libs/backends/ -iname "*.dll"` $ALIBDIR/backends/
158 cp `find build/libs/panners/ -iname "*.dll"` $ALIBDIR/panners/
159
160 cp -r build/libs/LV2 $ALIBDIR/
161 cp -r build/libs/vamp-plugins/*ardourvampplugins*.dll $ALIBDIR/vamp/libardourvampplugins.dll
162 cp $PREFIX/lib/suil-*/*.dll $ALIBDIR/suil/ || true
163
164 # lv2 core, classifications etc - TODO check if we need the complete LV2 ontology
165 if test -d $PREFIX/lib/lv2/lv2core.lv2 ; then
166         cp -R $PREFIX/lib/lv2/lv2core.lv2 $ALIBDIR/LV2/
167 fi
168
169 mv $ALIBDIR/surfaces/ardourcp*.dll $DESTDIR/bin/
170
171 # TODO use -static-libgcc -static-libstdc++ -- but for .exe files only
172 if update-alternatives --query ${XPREFIX}-gcc | grep Value: | grep -q win32; then
173         cp /usr/lib/gcc/${XPREFIX}/*-win32/libgcc_s_*.dll $DESTDIR/bin/
174         cp /usr/lib/gcc/${XPREFIX}/*-win32/libstdc++-6.dll $DESTDIR/bin/
175 elif update-alternatives --query ${XPREFIX}-gcc | grep Value: | grep -q posix; then
176         cp /usr/lib/gcc/${XPREFIX}/*-posix/libgcc_s_*.dll $DESTDIR/bin/
177         cp /usr/lib/gcc/${XPREFIX}/*-posix/libstdc++-6.dll $DESTDIR/bin/
178 else
179         cp /usr/lib/gcc/${XPREFIX}/*/libgcc_s_sjlj-1.dll $DESTDIR/bin/
180         cp /usr/lib/gcc/${XPREFIX}/*/libstdc++-6.dll $DESTDIR/bin/
181 fi
182 #Ubuntu's 14.04's mingw needs this one for the std libs above
183 if test -f /usr/${XPREFIX}/lib/libwinpthread-1.dll; then
184         cp /usr/${XPREFIX}/lib/libwinpthread-1.dll $DESTDIR/bin/
185 fi
186
187 cp -r $PREFIX/share/${LOWERCASE_DIRNAME} $DESTDIR/share/
188 cp -r $PREFIX/share/locale $DESTDIR/share/
189 cp -r $PREFIX/etc/${LOWERCASE_DIRNAME}/* $DESTDIR/share/${LOWERCASE_DIRNAME}/
190
191 cp COPYING $DESTDIR/share/
192 cp gtk2_ardour/icons/${PRODUCT_ICON} $DESTDIR/share/
193 cp gtk2_ardour/icons/ardour_bug.ico $DESTDIR/share/
194
195 #prefer built-in defaults
196 rm -f $DESTDIR/share/${LOWERCASE_DIRNAME}/system_config
197
198 # replace default cursor with square version (sans hotspot file)
199 cp gtk2_ardour/icons/cursor_square/* $DESTDIR/share/${LOWERCASE_DIRNAME}/icons/
200
201 # clean build-dir after depoyment
202 echo " === bundle completed, cleaning up"
203 ./waf uninstall
204 echo " === complete"
205 du -sh $DESTDIR
206
207 ################################################################################
208 ### get video tools
209 if test -z "$NOVIDEOTOOLS"; then
210         echo " === Including video-tools"
211         HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
212         XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
213
214         rsync -a -q --partial \
215                 rsync://ardour.org/video-tools/harvid_win-${HARVID_VERSION}.tar.xz \
216                 "${SRCCACHE}/harvid_win-${HARVID_VERSION}.tar.xz"
217
218         rsync -a -q --partial \
219                 rsync://ardour.org/video-tools/xjadeo_win-${XJADEO_VERSION}.tar.xz \
220                 "${SRCCACHE}/xjadeo_win-${XJADEO_VERSION}.tar.xz"
221
222         mkdir $DESTDIR/video
223         tar -xf "${SRCCACHE}/harvid_win-${HARVID_VERSION}.tar.xz" -C "$DESTDIR/video/"
224         tar -xf "${SRCCACHE}/xjadeo_win-${XJADEO_VERSION}.tar.xz" -C "$DESTDIR/video/"
225
226         echo " === unzipped"
227         du -sh $DESTDIR/video
228         du -sh $DESTDIR
229 fi
230
231 ################################################################################
232 ### include static gdb - re-zipped binaries from
233 ### http://sourceforge.net/projects/mingw/files/MinGW/Extension/gdb/gdb-7.6.1-1/gdb-7.6.1-1-mingw32-bin.tar.lzma
234 ### http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.1/threads-win32/sjlj/x86_64-4.9.1-release-win32-sjlj-rt_v3-rev1.7z
235 if ! grep " using ./waf configure" build/config.log | grep -q -- "--optimize"; then
236         download gdb-static-win3264.tar.xz http://robin.linuxaudio.org/gdb-static-win3264.tar.xz
237         cd ${SRCCACHE}
238         tar xf gdb-static-win3264.tar.xz
239         cd - > /dev/null
240
241         echo " === Creating debug.bat"
242         cp -r ${SRCCACHE}/gdb_$WARCH $DESTDIR/gdb
243         cat > $DESTDIR/debug.bat << EOF
244 cd bin
245 START ..\\gdb\\bin\\gdb.exe -iex "set logging overwrite on" -iex "set height 0" -iex "set logging on %UserProfile%\\${PRODUCT_NAME}-debug.log" -iex "target exec ${PRODUCT_EXE}" -iex "run"
246 EOF
247         OUTFILE="${TMPDIR}/${PRODUCT_NAME}-${ARDOURVERSION}-dbg-${WARCH}-Setup.exe"
248         VERSIONINFO="Debug Version."
249 else
250         OUTFILE="${TMPDIR}/${PRODUCT_NAME}-${ARDOURVERSION}-${WARCH}-Setup.exe"
251         VERSIONINFO="Optimized Version."
252 fi
253
254 ################################################################################
255 ### Mixbus plugins, etc
256 if true ; then
257         mkdir -p $ALIBDIR/LV2
258
259         echo "Adding General MIDI Synth LV2"
260
261         for proj in x42-gmsynth; do
262                 X42_VERSION=$(curl -s -S http://x42-plugins.com/x42/win/${proj}.latest.txt)
263                 rsync -a -q --partial \
264                         rsync://x42-plugins.com/x42/win/${proj}-lv2-${WARCH}-${X42_VERSION}.zip \
265                         "${SRCCACHE}/${proj}-lv2-${WARCH}-${X42_VERSION}.zip"
266                 unzip -q -d "$ALIBDIR/LV2/" "${SRCCACHE}/${proj}-lv2-${WARCH}-${X42_VERSION}.zip"
267         done
268 fi
269
270 if test x$WITH_X42_LV2 != x ; then
271         mkdir -p $ALIBDIR/LV2
272
273         echo "Adding x42 Plugins"
274
275         for proj in x42-meters x42-midifilter x42-midimap x42-stereoroute x42-eq setBfree x42-avldrums; do
276                 X42_VERSION=$(curl -s -S http://x42-plugins.com/x42/win/${proj}.latest.txt)
277                 rsync -a -q --partial \
278                         rsync://x42-plugins.com/x42/win/${proj}-lv2-${WARCH}-${X42_VERSION}.zip \
279                         "${SRCCACHE}/${proj}-lv2-${WARCH}-${X42_VERSION}.zip"
280                 unzip -q -d "$ALIBDIR/LV2/" "${SRCCACHE}/${proj}-lv2-${WARCH}-${X42_VERSION}.zip"
281         done
282 fi
283
284 if test x$WITH_HARRISON_LV2 != x ; then
285         mkdir -p $ALIBDIR/LV2
286
287         echo "Including Harrison LV2s"
288
289         curl -s -S --fail -# \
290                 -z "${SRCCACHE}/${HARRISONLV2}.${WARCH}.zip" \
291                 -o "${SRCCACHE}/${HARRISONLV2}.${WARCH}.zip" \
292                 "${HARRISONDSPURL}/${HARRISONLV2}.${WARCH}.zip"
293         unzip -q -d "$ALIBDIR/LV2/" "${SRCCACHE}/${HARRISONLV2}.${WARCH}.zip"
294 fi
295
296 if test -n "$MIXBUS"; then
297         echo "Deploying Harrison Mixbus Channelstrip"
298
299         mkdir -p $ALIBDIR/ladspa/strip
300         curl -s -S --fail -# \
301                 -z "${SRCCACHE}/${HARRISONCHANNELSTRIP}.${WARCH}.dll" \
302                 -o "${SRCCACHE}/${HARRISONCHANNELSTRIP}.${WARCH}.dll" \
303                 "${HARRISONDSPURL}/${HARRISONCHANNELSTRIP}.${WARCH}.dll"
304
305         cp "${SRCCACHE}/${HARRISONCHANNELSTRIP}.${WARCH}.dll" \
306                 "$ALIBDIR/ladspa/strip/${HARRISONCHANNELSTRIP}.dll"
307
308         echo "Deploying Harrison Vamp Plugins"
309         mkdir -p $ALIBDIR/vamp
310         curl -s -S --fail -# \
311                 -z "${SRCCACHE}/harrison_vamp.${WARCH}.dll" \
312                 -o "${SRCCACHE}/harrison_vamp.${WARCH}.dll" \
313                 "${HARRISONDSPURL}/harrison_vamp.${WARCH}.dll"
314
315         cp "${SRCCACHE}/harrison_vamp.${WARCH}.dll" \
316                 "$ALIBDIR/vamp/harrison_vamp.dll"
317 fi
318
319 ################################################################################
320
321 if test x$DEMO_SESSION_URL != x ; then
322         mkdir -p $Shared/sessions
323         DEMO_SESSIONS=$(curl -s -S --fail $DEMO_SESSION_URL/index.txt)
324         for demo in $DEMO_SESSIONS; do
325                 curl -s -S --fail -# -o $Shared/sessions/$demo $DEMO_SESSION_URL/$demo
326         done
327 fi
328
329 ################################################################################
330
331 ( cd $DESTDIR ; find . ) > ${TMPDIR}/file_list.txt
332
333 ################################################################################
334 echo " === Preparing Windows Installer"
335 NSISFILE=$DESTDIR/a3.nsis
336
337 if test "$WARCH" = "w64"; then
338         PGF=PROGRAMFILES64
339         SFX=
340 else
341         PGF=PROGRAMFILES
342         # TODO we should only add this for 32bit on 64bit windows!
343         SFX=" (x86)"
344 fi
345
346 if test -n "$QUICKZIP" ; then
347         cat > $NSISFILE << EOF
348 SetCompressor zlib
349 EOF
350 else
351         cat > $NSISFILE << EOF
352 SetCompressor /SOLID lzma
353 SetCompressorDictSize 32
354 EOF
355 fi
356
357 cat >> $NSISFILE << EOF
358 !addincludedir "${this_script_dir}\\nsis"
359 !include MUI2.nsh
360 !include FileAssociation.nsh
361 !include WinVer.nsh
362
363 Name "${PROGRAM_NAME}${PROGRAM_VERSION}"
364 OutFile "${OUTFILE}"
365 RequestExecutionLevel admin
366 InstallDir "\$${PGF}\\${PRODUCT_ID}"
367 InstallDirRegKey HKLM "Software\\${PRODUCT_NAME}\\${PRODUCT_ID}\\$WARCH" "Install_Dir"
368 !define MUI_ICON "share\\${PRODUCT_ICON}"
369
370 EOF
371
372 if test -n "$MIXBUS"; then
373
374 # TODO: proper welcome/finish text.
375         cat >> $NSISFILE << EOF
376 !define MUI_FINISHPAGE_TITLE "Welcome to Harrison Mixbus"
377 !define MUI_FINISHPAGE_TEXT "Thanks for your purchase of Mixbus!\$\\r\$\\nYou will find the Mixbus application in the Start Menu (or the All Apps panel for Windows 8) \$\\r\$\\nClick the link below to view the Mixbus manual, and learn ways to get involved with the Mixbus community."
378 !define MUI_FINISHPAGE_LINK "Mixbus Manual"
379 !define MUI_FINISHPAGE_LINK_LOCATION "http://www.harrisonconsoles.com/mixbus/${MANUAL_NAME}/"
380 !define MUI_FINISHPAGE_NOREBOOTSUPPORT
381 EOF
382
383 else
384
385         cat >> $NSISFILE << EOF
386 !define MUI_FINISHPAGE_TITLE "Welcome to Ardour"
387 !define MUI_FINISHPAGE_TEXT "This windows versions or Ardour is provided as-is.\$\\r\$\\nThe Ardour community currently has no expertise in supporting windows users, and there are no developers focusing on windows specific issues either.\$\\r\$\\nIf you like Ardour, please consider helping out."
388 !define MUI_FINISHPAGE_LINK "Ardour Manual"
389 !define MUI_FINISHPAGE_LINK_LOCATION "http://manual.ardour.org/"
390 #this would run as admin - see http://forums.winamp.com/showthread.php?t=353366
391 #!define MUI_FINISHPAGE_RUN "\$INSTDIR\\bin\\${PRODUCT_EXE}"
392 !define MUI_FINISHPAGE_NOREBOOTSUPPORT
393 EOF
394
395 fi
396
397 cat >> $NSISFILE << EOF
398 !define MUI_ABORTWARNING
399 !insertmacro MUI_PAGE_LICENSE "share\\COPYING"
400 !insertmacro MUI_PAGE_COMPONENTS
401 !insertmacro MUI_PAGE_DIRECTORY
402 !insertmacro MUI_PAGE_INSTFILES
403 !insertmacro MUI_PAGE_FINISH
404 !insertmacro MUI_UNPAGE_CONFIRM
405 !insertmacro MUI_UNPAGE_INSTFILES
406 !insertmacro MUI_LANGUAGE "English"
407
408 Section "${PROGRAM_NAME}${PROGRAM_VERSION} (required)" SecMainProg
409   SectionIn RO
410   SetOutPath \$INSTDIR
411   File /r bin
412   File /r lib
413   File /r share
414   File /nonfatal debug.bat
415   File /nonfatal /r gdb
416   WriteRegStr HKLM "Software\\${PROGRAM_KEY}\\v${major_version}\\$WARCH" "Install_Dir" "\$INSTDIR"
417   WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "DisplayName" "${PROGRAM_NAME}${PROGRAM_VERSION}"
418   WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "UninstallString" '"\$INSTDIR\\uninstall.exe"'
419   WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "NoModify" 1
420   WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "NoRepair" 1
421   WriteUninstaller "\$INSTDIR\uninstall.exe"
422   CreateShortCut "\$INSTDIR\\${PROGRAM_NAME}${PROGRAM_VERSION}.lnk" "\$INSTDIR\\bin\\${PRODUCT_EXE}" "" "\$INSTDIR\\bin\\${PRODUCT_EXE}" 0
423   \${registerExtension} "\$INSTDIR\\bin\\${STATEFILE_SUFFIX}" ".${PRODUCT_NAME}" "${PROGRAM_NAME} Session"
424 SectionEnd
425
426 Section "WASAPI sound driver" SecWASAPI
427 SectionEnd
428 EOF
429
430 if test -z "$NOVIDEOTOOLS"; then
431
432         cat >> $NSISFILE << EOF
433 Section "Videotimeline Tools" SecVideo
434   WriteRegStr HKLM "Software\\${PROGRAM_KEY}\\v${major_version}\\video" "Install_Dir" "\$INSTDIR\\video"
435   SetOutPath \$INSTDIR
436   File /r video
437 SectionEnd
438 EOF
439
440 fi
441
442 cat >> $NSISFILE << EOF
443 Section "Start Menu Shortcuts" SecMenu
444   SetShellVarContext all
445   CreateDirectory "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}"
446   CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\${PROGRAM_NAME}${PROGRAM_VERSION}.lnk" "\$INSTDIR\\bin\\${PRODUCT_EXE}" "" "\$INSTDIR\\bin\\${PRODUCT_EXE}" 0
447 EOF
448
449 if test -f "$DESTDIR/debug.bat"; then
450         cat >> $NSISFILE << EOF
451   CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\${PROGRAM_NAME}${PROGRAM_VERSION} GDB.lnk" "\$INSTDIR\\debug.bat" "" "\$INSTDIR\\share\\ardour_bug.ico" 0
452 EOF
453 fi
454
455 if test -z "$NOVIDEOTOOLS"; then
456         cat >> $NSISFILE << EOF
457   IfFileExists "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" 0 +2
458   CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\Video Monitor.lnk" "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" "" "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" 0
459 EOF
460 fi
461
462 cat >> $NSISFILE << EOF
463   CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\Uninstall.lnk" "\$INSTDIR\\uninstall.exe" "" "\$INSTDIR\\uninstall.exe" 0
464 SectionEnd
465 LangString DESC_SecMainProg \${LANG_ENGLISH} "${PROGRAM_NAME} ${ARDOURVERSION}\$\\r\$\\n${VERSIONINFO}\$\\r\$\\n${ARDOURDATE}"
466 LangString DESC_SecWASAPI \${LANG_ENGLISH} "WASAPI Audio Driver\$\\r\$\\nOnly works on Vista or later. Windows 10 Users may currently also experience issues if this is installed."
467 EOF
468
469 if test -z "$NOVIDEOTOOLS"; then
470         cat >> $NSISFILE << EOF
471 LangString DESC_SecVideo \${LANG_ENGLISH} "Video Tools\$\\r\$\\nxjadeo-${XJADEO_VERSION}\$\\r\$\\nharvid-${HARVID_VERSION}"
472 EOF
473 fi
474
475 cat >> $NSISFILE << EOF
476 LangString DESC_SecMenu \${LANG_ENGLISH} "Create Start-Menu Shortcuts (recommended)."
477 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
478 !insertmacro MUI_DESCRIPTION_TEXT \${SecMainProg} \$(DESC_SecMainProg)
479 !insertmacro MUI_DESCRIPTION_TEXT \${SecWASAPI} \$(DESC_SecWASAPI)
480 EOF
481
482 if test -z "$NOVIDEOTOOLS"; then
483         cat >> $NSISFILE << EOF
484 !insertmacro MUI_DESCRIPTION_TEXT \${SecVideo} \$(DESC_SecVideo)
485 EOF
486 fi
487
488 cat >> $NSISFILE << EOF
489 !insertmacro MUI_DESCRIPTION_TEXT \${SecMenu} \$(DESC_SecMenu)
490 !insertmacro MUI_FUNCTION_DESCRIPTION_END
491 Section "Uninstall"
492   SetShellVarContext all
493   DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}"
494   DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}"
495   DeleteRegKey HKLM "Software\\${PROGRAM_KEY}\\v${major_version}"
496   RMDir /r "\$INSTDIR\\bin"
497   RMDir /r "\$INSTDIR\\lib"
498   RMDir /r "\$INSTDIR\\share"
499   RMDir /r "\$INSTDIR\\gdb"
500   RMDir /r "\$INSTDIR\\video"
501   Delete "\$INSTDIR\\debug.bat"
502   Delete "\$INSTDIR\\uninstall.exe"
503   Delete "\$INSTDIR\\${PROGRAM_NAME}${PROGRAM_VERSION}.lnk"
504   RMDir "\$INSTDIR"
505   Delete "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\*.*"
506   RMDir "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}"
507   \${unregisterExtension} ".${STATEFILE_SUFFIX}" "${PROGRAM_NAME} Session"
508 SectionEnd
509
510
511 Function .onInit
512
513   ReadRegStr \$R0 HKLM \
514     "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" \
515     "UninstallString"
516   StrCmp \$R0 "" done
517
518   MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
519     "${PROGRAM_NAME} is already installed. Click 'OK' to remove the previous version or 'Cancel' to cancel this upgrade." \
520     IDOK uninst
521     Abort
522
523   uninst:
524     ClearErrors
525     ExecWait '\$R0 _?=\$INSTDIR'
526     IfErrors uninstall_error
527
528     ReadRegStr \$R1 HKLM \
529       "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" \
530       "UninstallString"
531     StrCmp \$R1 "" 0 done
532
533     Delete "\$INSTDIR\\uninstall.exe"
534     RMDir "\$INSTDIR"
535     goto done
536
537   uninstall_error:
538
539     MessageBox MB_OK|MB_ICONEXCLAMATION \
540       "Uninstaller did not complete successfully. Continue at your own risk..." \
541       IDOK done
542
543   done:
544
545   \${If} \${AtMostWinXP}
546     SectionSetFlags \${SecWASAPI} \${SF_RO}
547   \${Else}
548     SectionSetFlags \${SecWASAPI} \${SF_SELECTED}
549   \${EndIf}
550
551 FunctionEnd
552
553 Function .onInstSuccess
554
555   \${If} \${AtMostWinXP}
556     goto pa_no_wasapi
557   \${EndIf}
558
559   SectionGetFlags \${SecWASAPI} \$R0
560
561   IntOp \$R0 \$R0 & \${SF_SELECTED}
562   IntCmp \$R0 \${SF_SELECTED} pa_with_wasapi pa_no_wasapi
563
564   pa_with_wasapi:
565 ; VISTA .. 9, libportaudio with WASAPI is good.
566   Delete "\$INSTDIR\\bin\\libportaudio-2.xp"
567   goto endportaudio
568
569 ; Windows XP lacks support for WASAPI, Windows10 on some system has issues
570 ; http://tracker.ardour.org/view.php?id=6507
571   pa_no_wasapi:
572   Delete "\$INSTDIR\\bin\\libportaudio-2.dll"
573   Rename "\$INSTDIR\\bin\\libportaudio-2.xp" "\$INSTDIR\\bin\\libportaudio-2.dll"
574
575   endportaudio:
576
577 FunctionEnd
578 EOF
579
580 rm -f ${OUTFILE}
581 echo " === OutFile: $OUTFILE"
582
583 if test -n "$QUICKZIP" ; then
584 echo " === Building Windows Installer (fast zip)"
585 else
586 echo " === Building Windows Installer (lzma compression takes ages)"
587 fi
588 time makensis -V2 $NSISFILE
589 rm -rf $DESTDIR
590 ls -lgGh "$OUTFILE"