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