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
7 . ../define_versions.sh
9 cd $this_script_dir/../..
11 test -f gtk2_ardour/wscript || exit 1
13 # Defaults (overridden by environment)
14 : ${XARCH=i686} # or x86_64
15 : ${ROOT=/home/ardour}
18 : ${SRCDIR=/var/tmp/winsrc} # source-code tgz cache
20 # TODO: grep from build/config.log instead
21 while [ $# -gt 0 ] ; do
30 # see also wscript, video_tool_paths.cc, bundle_env_mingw.cc
31 # registry keys based on this are used there
34 PROGRAM_VERSION=${major_version}
36 LOWERCASE_DIRNAME=ardour${major_version}
37 STATEFILE_SUFFIX=ardour # see filename_extensions.cc
41 if test -n "$MIXBUS"; then
42 if test "$XARCH" = "x86_64"; then
53 PRODUCT_ID=${PROGRAM_NAME}${PROGRAM_VERSION}${BIT_SUFFIX}
54 PRODUCT_EXE=${PRODUCT_NAME}.exe
55 PRODUCT_ICON=${PRODUCT_NAME}.ico
57 ###############################################################################
59 echo "Packaging $PRODUCT_ID"
61 if test "$XARCH" = "x86_64" -o "$XARCH" = "amd64"; then
62 echo "Target: 64bit Windows (x86_64)"
63 XPREFIX=x86_64-w64-mingw32
66 echo "Target: 32 Windows (i686)"
67 XPREFIX=i686-w64-mingw32
71 : ${PREFIX=${ROOT}/win-stack-$WARCH}
74 if [ "$(id -u)" = "0" ]; then
75 apt-get -y install nsis curl
80 echo "--- Downloading.. $2"
81 test -f ${SRCDIR}/$1 || curl -k -L -o ${SRCDIR}/$1 $2
84 ################################################################################
87 ARDOURVERSION=${release_version}
89 if ! test -f build/gtk2_ardour/ardour-${ARDOURVERSION}.exe; then
90 echo "*** Please compile ardour-${ARDOURVERSION}.exe first."
94 echo " === bundle to $DESTDIR"
98 ################################################################################
100 if test -z "$DESTDIR"; then
102 trap 'rm -rf $DESTDIR' exit SIGINT SIGTERM
105 echo " === bundle to $DESTDIR"
107 ALIBDIR=$DESTDIR/lib/${LOWERCASE_DIRNAME}
110 mkdir -p $DESTDIR/bin
111 mkdir -p $DESTDIR/share/
112 mkdir -p $ALIBDIR/surfaces
113 mkdir -p $ALIBDIR/backends
114 mkdir -p $ALIBDIR/panners
115 mkdir -p $ALIBDIR/vamp
116 mkdir -p $ALIBDIR/suil
118 cp build/libs/gtkmm2ext/gtkmm2ext-*.dll $DESTDIR/bin/
119 cp build/libs/midi++2/midipp-*.dll $DESTDIR/bin/
120 cp build/libs/evoral/evoral-*.dll $DESTDIR/bin/
121 cp build/libs/ardour/ardour-*.dll $DESTDIR/bin/
122 cp build/libs/timecode/timecode.dll $DESTDIR/bin/
123 cp build/libs/qm-dsp/qmdsp-*.dll $DESTDIR/bin/
124 cp build/libs/canvas/canvas-*.dll $DESTDIR/bin/
125 cp build/libs/pbd/pbd-*.dll $DESTDIR/bin/
126 cp build/libs/audiographer/audiographer-*.dll $DESTDIR/bin/
127 cp build/libs/fst/ardour-vst-scanner.exe $DESTDIR/bin/ || true
128 cp `ls -t build/gtk2_ardour/ardour-*.exe | head -n1` $DESTDIR/bin/${PRODUCT_EXE}
130 mkdir -p $DESTDIR/lib/gtk-2.0/engines
131 cp build/libs/clearlooks-newer/clearlooks.dll $DESTDIR/lib/gtk-2.0/engines/libclearlooks.la
133 cp $PREFIX/bin/*dll $DESTDIR/bin/
134 cp $PREFIX/lib/*dll $DESTDIR/bin/
135 rm -rf $DESTDIR/bin/libjack*.dll
137 cp `find build/libs/surfaces/ -iname "*.dll"` $ALIBDIR/surfaces/
138 cp `find build/libs/backends/ -iname "*.dll"` $ALIBDIR/backends/
139 cp `find build/libs/panners/ -iname "*.dll"` $ALIBDIR/panners/
141 cp -r build/libs/LV2 $ALIBDIR/
142 cp -r build/libs/vamp-plugins/*ardourvampplugins*.dll $ALIBDIR/vamp/libardourvampplugins.dll
143 cp $PREFIX/lib/suil-*/*.dll $ALIBDIR/suil/ || true
145 # lv2 core, classifications etc - TODO check if we need the complete LV2 ontology
146 if test -d $PREFIX/lib/lv2/lv2core.lv2 ; then
147 cp -R $PREFIX/lib/lv2/lv2core.lv2 $ALIBDIR/LV2/
150 mv $ALIBDIR/surfaces/ardourcp*.dll $DESTDIR/bin/
152 # TODO use -static-libgcc -static-libstdc++ -- but for .exe files only
153 if update-alternatives --query ${XPREFIX}-gcc | grep Value: | grep -q win32; then
154 cp /usr/lib/gcc/${XPREFIX}/*-win32/libgcc_s_*.dll $DESTDIR/bin/
155 cp /usr/lib/gcc/${XPREFIX}/*-win32/libstdc++-6.dll $DESTDIR/bin/
156 elif update-alternatives --query ${XPREFIX}-gcc | grep Value: | grep -q posix; then
157 cp /usr/lib/gcc/${XPREFIX}/*-posix/libgcc_s_*.dll $DESTDIR/bin/
158 cp /usr/lib/gcc/${XPREFIX}/*-posix/libstdc++-6.dll $DESTDIR/bin/
160 cp /usr/lib/gcc/${XPREFIX}/*/libgcc_s_sjlj-1.dll $DESTDIR/bin/
161 cp /usr/lib/gcc/${XPREFIX}/*/libstdc++-6.dll $DESTDIR/bin/
163 #Ubuntu's 14.04's mingw needs this one for the std libs above
164 if test -f /usr/${XPREFIX}/lib/libwinpthread-1.dll; then
165 cp /usr/${XPREFIX}/lib/libwinpthread-1.dll $DESTDIR/bin/
168 cp -r $PREFIX/share/${LOWERCASE_DIRNAME} $DESTDIR/share/
169 cp -r $PREFIX/share/locale $DESTDIR/share/
170 cp -r $PREFIX/etc/${LOWERCASE_DIRNAME}/* $DESTDIR/share/${LOWERCASE_DIRNAME}/
172 cp COPYING $DESTDIR/share/
173 cp gtk2_ardour/icons/${PRODUCT_ICON} $DESTDIR/share/
174 cp gtk2_ardour/icons/ardour_bug.ico $DESTDIR/share/
176 # replace default cursor with square version (sans hotspot file)
177 cp gtk2_ardour/icons/cursor_square/* $DESTDIR/share/${LOWERCASE_DIRNAME}/icons/
179 # clean build-dir after depoyment
180 echo " === bundle completed, cleaning up"
185 ( cd $DESTDIR ; find . ) > ${TMPDIR}/file_list.txt
187 ################################################################################
189 if test -z "$NOVIDEOTOOLS"; then
190 echo " === Including video-tools"
191 HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
192 XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
194 rsync -a -q --partial \
195 rsync://ardour.org/video-tools/harvid_win-${HARVID_VERSION}.tar.xz \
196 "${SRCDIR}/harvid_win-${HARVID_VERSION}.tar.xz"
198 rsync -a -q --partial \
199 rsync://ardour.org/video-tools/xjadeo_win-${XJADEO_VERSION}.tar.xz \
200 "${SRCDIR}/xjadeo_win-${XJADEO_VERSION}.tar.xz"
203 tar -xf "${SRCDIR}/harvid_win-${HARVID_VERSION}.tar.xz" -C "$DESTDIR/video/"
204 tar -xf "${SRCDIR}/xjadeo_win-${XJADEO_VERSION}.tar.xz" -C "$DESTDIR/video/"
207 du -sh $DESTDIR/video
211 ################################################################################
212 ### include static gdb - re-zipped binaries from
213 ### http://sourceforge.net/projects/mingw/files/MinGW/Extension/gdb/gdb-7.6.1-1/gdb-7.6.1-1-mingw32-bin.tar.lzma
214 ### 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
215 if ! grep " using ./waf configure" build/config.log | grep -q -- "--optimize"; then
216 download gdb-static-win3264.tar.xz http://robin.linuxaudio.org/gdb-static-win3264.tar.xz
218 tar xf gdb-static-win3264.tar.xz
221 echo " === Creating debug.bat"
222 cp -r ${SRCDIR}/gdb_$WARCH $DESTDIR/gdb
223 cat > $DESTDIR/debug.bat << EOF
225 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"
227 OUTFILE="${TMPDIR}/${PRODUCT_NAME}-${ARDOURVERSION}-dbg-${WARCH}-Setup.exe"
228 VERSIONINFO="Debug Version."
230 OUTFILE="${TMPDIR}/${PRODUCT_NAME}-${ARDOURVERSION}-${WARCH}-Setup.exe"
231 VERSIONINFO="Optimized Version."
234 ################################################################################
235 ### Mixbus plugins, etc
236 if test -n "$MIXBUS"; then # TODO use separate variable
237 mkdir -p $ALIBDIR/LV2
239 echo "Adding x42 Plugins"
241 METERS_VERSION=$(curl -s -S http://gareus.org/x42/win/x42-meters.latest.txt)
242 rsync -a -q --partial \
243 rsync://gareus.org/x42/win/x42-meters-lv2-${WARCH}-${METERS_VERSION}.zip \
244 "${SRCDIR}/x42-meters-lv2-${WARCH}-${METERS_VERSION}.zip"
245 unzip -d "$ALIBDIR/LV2/" "${SRCDIR}/x42-meters-lv2-${WARCH}-${METERS_VERSION}.zip"
247 SETBFREE_VERSION=$(curl -s -S http://gareus.org/x42/win/setBfree.latest.txt)
248 rsync -a -q --partial \
249 rsync://gareus.org/x42/win/setBfree-lv2-${WARCH}-${SETBFREE_VERSION}.zip \
250 "${SRCDIR}/setBfree-lv2-${WARCH}-${SETBFREE_VERSION}.zip"
251 unzip -d "$ALIBDIR/LV2/" "${SRCDIR}/setBfree-lv2-${WARCH}-${SETBFREE_VERSION}.zip"
253 MIDIFILTER_VERSION=$(curl -s -S http://gareus.org/x42/win/x42-midifilter.latest.txt)
254 rsync -a -q --partial \
255 rsync://gareus.org/x42/win/x42-midifilter-lv2-${WARCH}-${MIDIFILTER_VERSION}.zip \
256 "${SRCDIR}/x42-midifilter-lv2-${WARCH}-${MIDIFILTER_VERSION}.zip"
257 unzip -d "$ALIBDIR/LV2/" "${SRCDIR}/x42-midifilter-lv2-${WARCH}-${MIDIFILTER_VERSION}.zip"
260 if test -n "$MIXBUS"; then # TODO use separate variable
261 mkdir -p $ALIBDIR/LV2
263 echo "Including Harrison LV2s"
265 curl -s -S --fail -# \
266 -z "${SRCDIR}/harrison_lv2s.${WARCH}.zip" \
267 -o "${SRCDIR}/harrison_lv2s.${WARCH}.zip" \
268 http://www.harrisonconsoles.com/mixbus/mb3/${WARCH}/harrison_lv2s.zip
269 unzip -q -d "$ALIBDIR/LV2/" "${SRCDIR}/harrison_lv2s.${WARCH}.zip"
272 if test -n "$MIXBUS"; then
273 echo "Deploying Harrison Mixbus Channelstrip"
275 mkdir -p $ALIBDIR/ladspa/strip
276 curl -s -S --fail -# \
277 -z "${SRCDIR}/harrison_channelstrip.${WARCH}.dll" \
278 -o "${SRCDIR}/harrison_channelstrip.${WARCH}.dll" \
279 http://www.harrisonconsoles.com/mixbus/mb3/${WARCH}/harrison_channelstrip.dll
281 cp "${SRCDIR}/harrison_channelstrip.${WARCH}.dll" \
282 "$ALIBDIR/ladspa/strip/rrison_channelstrip.dll"
285 ################################################################################
286 echo " === Preparing Windows Installer"
287 NSISFILE=$DESTDIR/a3.nsis
289 if test "$WARCH" = "w64"; then
294 # TODO we should only add this for 32bit on 64bit windows!
298 if test -n "$QUICKZIP" ; then
299 cat > $NSISFILE << EOF
303 cat > $NSISFILE << EOF
304 SetCompressor /SOLID lzma
305 SetCompressorDictSize 32
309 cat >> $NSISFILE << EOF
310 !addincludedir "${this_script_dir}\\nsis"
312 !include FileAssociation.nsh
314 Name "${PROGRAM_NAME}${PROGRAM_VERSION}"
316 RequestExecutionLevel admin
317 InstallDir "\$${PGF}\\${PRODUCT_ID}"
318 InstallDirRegKey HKLM "Software\\${PROGRAM_NAME}\\${PRODUCT_ID}\\$WARCH" "Install_Dir"
319 !define MUI_ICON "share\\${PRODUCT_ICON}"
323 if test -n "$MIXBUS"; then
325 # TODO: proper welcome/finish text.
326 cat >> $NSISFILE << EOF
327 !define MUI_FINISHPAGE_TITLE "Welcome to Harrison Mixbus"
328 !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."
329 !define MUI_FINISHPAGE_LINK "Mixbus Manual"
330 !define MUI_FINISHPAGE_LINK_LOCATION "http://www.harrisonconsoles.com/mixbus/mixbus3-live-manual"
331 !define MUI_FINISHPAGE_NOREBOOTSUPPORT
336 cat >> $NSISFILE << EOF
337 !define MUI_FINISHPAGE_TITLE "Welcome to Ardour"
338 !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."
339 !define MUI_FINISHPAGE_LINK "Ardour on Windows"
340 !define MUI_FINISHPAGE_LINK_LOCATION "http://ardour.org/windows.html"
341 #this would run as admin - see http://forums.winamp.com/showthread.php?t=353366
342 #!define MUI_FINISHPAGE_RUN "\$INSTDIR\\bin\\${PRODUCT_EXE}"
343 !define MUI_FINISHPAGE_NOREBOOTSUPPORT
348 cat >> $NSISFILE << EOF
349 !define MUI_ABORTWARNING
350 !insertmacro MUI_PAGE_LICENSE "share\\COPYING"
351 !insertmacro MUI_PAGE_COMPONENTS
352 !insertmacro MUI_PAGE_DIRECTORY
353 !insertmacro MUI_PAGE_INSTFILES
354 !insertmacro MUI_PAGE_FINISH
355 !insertmacro MUI_UNPAGE_CONFIRM
356 !insertmacro MUI_UNPAGE_INSTFILES
357 !insertmacro MUI_LANGUAGE "English"
362 ReadRegStr \$R0 HKLM \
363 "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" \
367 MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
368 "${PROGRAM_NAME} is already installed. Click 'OK' to remove the previous version or 'Cancel' to cancel this upgrade." \
374 ExecWait '\$R0 _?=\$INSTDIR'
375 IfErrors uninstall_error
377 ReadRegStr \$R1 HKLM \
378 "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" \
380 StrCmp \$R1 "" 0 done
382 Delete "\$INSTDIR\\uninstall.exe"
388 MessageBox MB_OK|MB_ICONEXCLAMATION \
389 "Uninstaller did not complete successfully. Continue at your own risk..." \
397 Section "${PROGRAM_NAME}${PROGRAM_VERSION} (required)" SecMainProg
403 File /nonfatal debug.bat
404 File /nonfatal /r gdb
405 WriteRegStr HKLM "Software\\${PROGRAM_NAME}\\v${PROGRAM_VERSION}\\$WARCH" "Install_Dir" "\$INSTDIR"
406 WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "DisplayName" "${PROGRAM_NAME}${PROGRAM_VERSION}"
407 WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "UninstallString" '"\$INSTDIR\\uninstall.exe"'
408 WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "NoModify" 1
409 WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "NoRepair" 1
410 WriteUninstaller "\$INSTDIR\uninstall.exe"
411 CreateShortCut "\$INSTDIR\\${PROGRAM_NAME}${PROGRAM_VERSION}.lnk" "\$INSTDIR\\bin\\${PRODUCT_EXE}" "" "\$INSTDIR\\bin\\${PRODUCT_EXE}" 0
412 \${registerExtension} "\$INSTDIR\\bin\\${STATEFILE_SUFFIX}" ".${PRODUCT_NAME}" "${PROGRAM_NAME} Session"
416 if test -z "$NOVIDEOTOOLS"; then
418 cat >> $NSISFILE << EOF
419 Section "Videotimeline Tools" SecVideo
420 WriteRegStr HKLM "Software\\${PROGRAM_NAME}\\v${PROGRAM_VERSION}\\video" "Install_Dir" "\$INSTDIR\\video"
428 cat >> $NSISFILE << EOF
429 Section "Start Menu Shortcuts" SecMenu
430 SetShellVarContext all
431 CreateDirectory "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}"
432 CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\${PROGRAM_NAME}${PROGRAM_VERSION}.lnk" "\$INSTDIR\\bin\\${PRODUCT_EXE}" "" "\$INSTDIR\\bin\\${PRODUCT_EXE}" 0
435 if test -f "$DESTDIR/debug.bat"; then
436 cat >> $NSISFILE << EOF
437 CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\${PROGRAM_NAME}${PROGRAM_VERSION} GDB.lnk" "\$INSTDIR\\debug.bat" "" "\$INSTDIR\\share\\ardour_bug.ico" 0
441 if test -z "$NOVIDEOTOOLS"; then
442 cat >> $NSISFILE << EOF
443 IfFileExists "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" 0 +2
444 CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\Video Monitor.lnk" "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" "" "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" 0
448 cat >> $NSISFILE << EOF
449 CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\Uninstall.lnk" "\$INSTDIR\\uninstall.exe" "" "\$INSTDIR\\uninstall.exe" 0
451 LangString DESC_SecMainProg \${LANG_ENGLISH} "${PROGRAM_NAME} ${ARDOURVERSION}\$\\r\$\\n${VERSIONINFO}\$\\r\$\\n${ARDOURDATE}"
454 if test -z "$NOVIDEOTOOLS"; then
455 cat >> $NSISFILE << EOF
456 LangString DESC_SecVideo \${LANG_ENGLISH} "Video Tools\$\\r\$\\nxjadeo-${XJADEO_VERSION}\$\\r\$\\nharvid-${HARVID_VERSION}"
460 cat >> $NSISFILE << EOF
461 LangString DESC_SecMenu \${LANG_ENGLISH} "Create Start-Menu Shortcuts (recommended)."
462 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
463 !insertmacro MUI_DESCRIPTION_TEXT \${SecMainProg} \$(DESC_SecMainProg)
466 if test -z "$NOVIDEOTOOLS"; then
467 cat >> $NSISFILE << EOF
468 !insertmacro MUI_DESCRIPTION_TEXT \${SecVideo} \$(DESC_SecVideo)
472 cat >> $NSISFILE << EOF
473 !insertmacro MUI_DESCRIPTION_TEXT \${SecMenu} \$(DESC_SecMenu)
474 !insertmacro MUI_FUNCTION_DESCRIPTION_END
476 SetShellVarContext all
477 DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}"
478 DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}"
479 DeleteRegKey HKLM "Software\\${PROGRAM_NAME}\\v${PROGRAM_VERSION}"
480 RMDir /r "\$INSTDIR\\bin"
481 RMDir /r "\$INSTDIR\\lib"
482 RMDir /r "\$INSTDIR\\share"
483 RMDir /r "\$INSTDIR\\gdb"
484 RMDir /r "\$INSTDIR\\video"
485 Delete "\$INSTDIR\\debug.bat"
486 Delete "\$INSTDIR\\uninstall.exe"
487 Delete "\$INSTDIR\\${PROGRAM_NAME}${PROGRAM_VERSION}.lnk"
489 Delete "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\*.*"
490 RMDir "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}"
491 \${unregisterExtension} ".${STATEFILE_SUFFIX}" "${PROGRAM_NAME} Session"
496 echo " === OutFile: $OUTFILE"
498 if test -n "$QUICKZIP" ; then
499 echo " === Building Windows Installer (fast zip)"
501 echo " === Building Windows Installer (lzma compression takes ages)"
503 time makensis -V2 $NSISFILE