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
39 if test -n "$MIXBUS"; then
45 PRODUCT_ID=${PROGRAM_NAME}${PROGRAM_VERSION}
46 PRODUCT_EXE=${PRODUCT_NAME}.exe
47 PRODUCT_ICON=${PRODUCT_NAME}.ico
49 ###############################################################################
51 echo "Packaging $PRODUCT_ID"
53 if test "$XARCH" = "x86_64" -o "$XARCH" = "amd64"; then
54 echo "Target: 64bit Windows (x86_64)"
55 XPREFIX=x86_64-w64-mingw32
58 echo "Target: 32 Windows (i686)"
59 XPREFIX=i686-w64-mingw32
63 : ${PREFIX=${ROOT}/win-stack-$WARCH}
66 if [ "$(id -u)" = "0" ]; then
67 apt-get -y install nsis curl
72 echo "--- Downloading.. $2"
73 test -f ${SRCDIR}/$1 || curl -k -L -o ${SRCDIR}/$1 $2
76 ################################################################################
79 ARDOURVERSION=${release_version}
81 if ! test -f build/gtk2_ardour/ardour-${ARDOURVERSION}.exe; then
82 echo "*** Please compile ardour-${ARDOURVERSION}.exe first."
86 echo " === bundle to $DESTDIR"
90 ################################################################################
92 if test -z "$DESTDIR"; then
94 trap 'rm -rf $DESTDIR' exit SIGINT SIGTERM
97 echo " === bundle to $DESTDIR"
99 ALIBDIR=$DESTDIR/lib/${LOWERCASE_DIRNAME}
102 mkdir -p $DESTDIR/bin
103 mkdir -p $DESTDIR/share/
104 mkdir -p $ALIBDIR/surfaces
105 mkdir -p $ALIBDIR/backends
106 mkdir -p $ALIBDIR/panners
107 mkdir -p $ALIBDIR/vamp
108 mkdir -p $ALIBDIR/suil
110 cp build/libs/gtkmm2ext/gtkmm2ext-*.dll $DESTDIR/bin/
111 cp build/libs/midi++2/midipp-*.dll $DESTDIR/bin/
112 cp build/libs/evoral/evoral-*.dll $DESTDIR/bin/
113 cp build/libs/ardour/ardour-*.dll $DESTDIR/bin/
114 cp build/libs/timecode/timecode.dll $DESTDIR/bin/
115 cp build/libs/qm-dsp/qmdsp-*.dll $DESTDIR/bin/
116 cp build/libs/canvas/canvas-*.dll $DESTDIR/bin/
117 cp build/libs/pbd/pbd-*.dll $DESTDIR/bin/
118 cp build/libs/ptformat/ptformat-*.dll $DESTDIR/bin/
119 cp build/libs/audiographer/audiographer-*.dll $DESTDIR/bin/
120 cp build/libs/fst/ardour-vst-scanner.exe $DESTDIR/bin/ || true
121 cp `ls -t build/gtk2_ardour/ardour-*.exe | head -n1` $DESTDIR/bin/${PRODUCT_EXE}
123 mkdir -p $DESTDIR/lib/gtk-2.0/engines
124 cp build/libs/clearlooks-newer/clearlooks.dll $DESTDIR/lib/gtk-2.0/engines/libclearlooks.la
126 cp $PREFIX/bin/*dll $DESTDIR/bin/
127 cp $PREFIX/lib/*dll $DESTDIR/bin/
128 # special case libportaudio (wasapi), old stack has no wasapi and hence no .xp
129 cp $PREFIX/bin/libportaudio-2.xp $DESTDIR/bin/ || cp $PREFIX/bin/libportaudio-2.dll $DESTDIR/bin/libportaudio-2.xp
130 rm -rf $DESTDIR/bin/libjack*.dll
132 cp `find build/libs/surfaces/ -iname "*.dll"` $ALIBDIR/surfaces/
133 cp `find build/libs/backends/ -iname "*.dll"` $ALIBDIR/backends/
134 cp `find build/libs/panners/ -iname "*.dll"` $ALIBDIR/panners/
136 cp -r build/libs/LV2 $ALIBDIR/
137 cp -r build/libs/vamp-plugins/*ardourvampplugins*.dll $ALIBDIR/vamp/libardourvampplugins.dll
138 cp $PREFIX/lib/suil-*/*.dll $ALIBDIR/suil/ || true
140 # lv2 core, classifications etc - TODO check if we need the complete LV2 ontology
141 if test -d $PREFIX/lib/lv2/lv2core.lv2 ; then
142 cp -R $PREFIX/lib/lv2/lv2core.lv2 $ALIBDIR/LV2/
145 mv $ALIBDIR/surfaces/ardourcp*.dll $DESTDIR/bin/
147 # TODO use -static-libgcc -static-libstdc++ -- but for .exe files only
148 if update-alternatives --query ${XPREFIX}-gcc | grep Value: | grep -q win32; then
149 cp /usr/lib/gcc/${XPREFIX}/*-win32/libgcc_s_*.dll $DESTDIR/bin/
150 cp /usr/lib/gcc/${XPREFIX}/*-win32/libstdc++-6.dll $DESTDIR/bin/
151 elif update-alternatives --query ${XPREFIX}-gcc | grep Value: | grep -q posix; then
152 cp /usr/lib/gcc/${XPREFIX}/*-posix/libgcc_s_*.dll $DESTDIR/bin/
153 cp /usr/lib/gcc/${XPREFIX}/*-posix/libstdc++-6.dll $DESTDIR/bin/
155 cp /usr/lib/gcc/${XPREFIX}/*/libgcc_s_sjlj-1.dll $DESTDIR/bin/
156 cp /usr/lib/gcc/${XPREFIX}/*/libstdc++-6.dll $DESTDIR/bin/
158 #Ubuntu's 14.04's mingw needs this one for the std libs above
159 if test -f /usr/${XPREFIX}/lib/libwinpthread-1.dll; then
160 cp /usr/${XPREFIX}/lib/libwinpthread-1.dll $DESTDIR/bin/
163 cp -r $PREFIX/share/${LOWERCASE_DIRNAME} $DESTDIR/share/
164 cp -r $PREFIX/share/locale $DESTDIR/share/
165 cp -r $PREFIX/etc/${LOWERCASE_DIRNAME}/* $DESTDIR/share/${LOWERCASE_DIRNAME}/
167 cp COPYING $DESTDIR/share/
168 cp gtk2_ardour/icons/${PRODUCT_ICON} $DESTDIR/share/
169 cp gtk2_ardour/icons/ardour_bug.ico $DESTDIR/share/
171 # replace default cursor with square version (sans hotspot file)
172 cp gtk2_ardour/icons/cursor_square/* $DESTDIR/share/${LOWERCASE_DIRNAME}/icons/
174 # clean build-dir after depoyment
175 echo " === bundle completed, cleaning up"
180 ( cd $DESTDIR ; find . ) > ${TMPDIR}/file_list.txt
182 ################################################################################
184 if test -z "$NOVIDEOTOOLS"; then
185 echo " === Including video-tools"
186 HARVID_VERSION=$(curl -s -S http://ardour.org/files/video-tools/harvid_version.txt)
187 XJADEO_VERSION=$(curl -s -S http://ardour.org/files/video-tools/xjadeo_version.txt)
189 rsync -a -q --partial \
190 rsync://ardour.org/video-tools/harvid_win-${HARVID_VERSION}.tar.xz \
191 "${SRCDIR}/harvid_win-${HARVID_VERSION}.tar.xz"
193 rsync -a -q --partial \
194 rsync://ardour.org/video-tools/xjadeo_win-${XJADEO_VERSION}.tar.xz \
195 "${SRCDIR}/xjadeo_win-${XJADEO_VERSION}.tar.xz"
198 tar -xf "${SRCDIR}/harvid_win-${HARVID_VERSION}.tar.xz" -C "$DESTDIR/video/"
199 tar -xf "${SRCDIR}/xjadeo_win-${XJADEO_VERSION}.tar.xz" -C "$DESTDIR/video/"
202 du -sh $DESTDIR/video
206 ################################################################################
207 ### include static gdb - re-zipped binaries from
208 ### http://sourceforge.net/projects/mingw/files/MinGW/Extension/gdb/gdb-7.6.1-1/gdb-7.6.1-1-mingw32-bin.tar.lzma
209 ### 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
210 if ! grep " using ./waf configure" build/config.log | grep -q -- "--optimize"; then
211 download gdb-static-win3264.tar.xz http://robin.linuxaudio.org/gdb-static-win3264.tar.xz
213 tar xf gdb-static-win3264.tar.xz
216 echo " === Creating debug.bat"
217 cp -r ${SRCDIR}/gdb_$WARCH $DESTDIR/gdb
218 cat > $DESTDIR/debug.bat << EOF
220 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"
222 OUTFILE="${TMPDIR}/${PRODUCT_NAME}-${ARDOURVERSION}-dbg-${WARCH}-Setup.exe"
223 VERSIONINFO="Debug Version."
225 OUTFILE="${TMPDIR}/${PRODUCT_NAME}-${ARDOURVERSION}-${WARCH}-Setup.exe"
226 VERSIONINFO="Optimized Version."
229 ################################################################################
230 ### Mixbus plugins, etc
231 if test -n "$MIXBUS"; then # TODO use separate variable
232 mkdir -p $ALIBDIR/LV2
234 echo "Adding x42 Plugins"
236 METERS_VERSION=$(curl -s -S http://x42-plugins.com/x42/win/x42-meters.latest.txt)
237 rsync -a -q --partial \
238 rsync://x42-plugins.com/x42/win/x42-meters-lv2-${WARCH}-${METERS_VERSION}.zip \
239 "${SRCDIR}/x42-meters-lv2-${WARCH}-${METERS_VERSION}.zip"
240 unzip -q -d "$ALIBDIR/LV3/" "${SRCDIR}/x42-meters-lv2-${WARCH}-${METERS_VERSION}.zip"
242 SETBFREE_VERSION=$(curl -s -S http://x42-plugins.com/x42/win/setBfree.latest.txt)
243 rsync -a -q --partial \
244 rsync://x42-plugins.com/x42/win/setBfree-lv2-${WARCH}-${SETBFREE_VERSION}.zip \
245 "${SRCDIR}/setBfree-lv2-${WARCH}-${SETBFREE_VERSION}.zip"
246 unzip -q -d "$ALIBDIR/LV2/" "${SRCDIR}/setBfree-lv2-${WARCH}-${SETBFREE_VERSION}.zip"
248 MIDIFILTER_VERSION=$(curl -s -S http://x42-plugins.com/x42/win/x42-midifilter.latest.txt)
249 rsync -a -q --partial \
250 rsync://x42-plugins.com/x42/win/x42-midifilter-lv2-${WARCH}-${MIDIFILTER_VERSION}.zip \
251 "${SRCDIR}/x42-midifilter-lv2-${WARCH}-${MIDIFILTER_VERSION}.zip"
252 unzip -q -d "$ALIBDIR/LV2/" "${SRCDIR}/x42-midifilter-lv2-${WARCH}-${MIDIFILTER_VERSION}.zip"
255 if test -n "$MIXBUS"; then # TODO use separate variable
256 mkdir -p $ALIBDIR/LV2
258 echo "Including Harrison LV2s"
260 curl -s -S --fail -# \
261 -z "${SRCDIR}/harrison_lv2s.${WARCH}.zip" \
262 -o "${SRCDIR}/harrison_lv2s.${WARCH}.zip" \
263 http://www.harrisonconsoles.com/mixbus/mb3/${WARCH}/harrison_lv2s.zip
264 unzip -q -d "$ALIBDIR/LV2/" "${SRCDIR}/harrison_lv2s.${WARCH}.zip"
267 if test -n "$MIXBUS"; then
268 echo "Deploying Harrison Mixbus Channelstrip"
270 mkdir -p $ALIBDIR/ladspa/strip
271 curl -s -S --fail -# \
272 -z "${SRCDIR}/harrison_channelstrip.${WARCH}.dll" \
273 -o "${SRCDIR}/harrison_channelstrip.${WARCH}.dll" \
274 http://www.harrisonconsoles.com/mixbus/mb3/${WARCH}/harrison_channelstrip.dll
276 cp "${SRCDIR}/harrison_channelstrip.${WARCH}.dll" \
277 "$ALIBDIR/ladspa/strip/rrison_channelstrip.dll"
280 ################################################################################
281 echo " === Preparing Windows Installer"
282 NSISFILE=$DESTDIR/a3.nsis
284 if test "$WARCH" = "w64"; then
289 # TODO we should only add this for 32bit on 64bit windows!
293 if test -n "$QUICKZIP" ; then
294 cat > $NSISFILE << EOF
298 cat > $NSISFILE << EOF
299 SetCompressor /SOLID lzma
300 SetCompressorDictSize 32
304 cat >> $NSISFILE << EOF
305 !addincludedir "${this_script_dir}\\nsis"
307 !include FileAssociation.nsh
310 Name "${PROGRAM_NAME}${PROGRAM_VERSION}"
312 RequestExecutionLevel admin
313 InstallDir "\$${PGF}\\${PRODUCT_ID}"
314 InstallDirRegKey HKLM "Software\\${PROGRAM_NAME}\\${PRODUCT_ID}\\$WARCH" "Install_Dir"
315 !define MUI_ICON "share\\${PRODUCT_ICON}"
319 if test -n "$MIXBUS"; then
321 # TODO: proper welcome/finish text.
322 cat >> $NSISFILE << EOF
323 !define MUI_FINISHPAGE_TITLE "Welcome to Harrison Mixbus"
324 !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."
325 !define MUI_FINISHPAGE_LINK "Mixbus Manual"
326 !define MUI_FINISHPAGE_LINK_LOCATION "http://www.harrisonconsoles.com/mixbus/mixbus3-live-manual"
327 !define MUI_FINISHPAGE_NOREBOOTSUPPORT
332 cat >> $NSISFILE << EOF
333 !define MUI_FINISHPAGE_TITLE "Welcome to Ardour"
334 !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."
335 !define MUI_FINISHPAGE_LINK "Ardour on Windows"
336 !define MUI_FINISHPAGE_LINK_LOCATION "http://ardour.org/windows.html"
337 #this would run as admin - see http://forums.winamp.com/showthread.php?t=353366
338 #!define MUI_FINISHPAGE_RUN "\$INSTDIR\\bin\\${PRODUCT_EXE}"
339 !define MUI_FINISHPAGE_NOREBOOTSUPPORT
344 cat >> $NSISFILE << EOF
345 !define MUI_ABORTWARNING
346 !insertmacro MUI_PAGE_LICENSE "share\\COPYING"
347 !insertmacro MUI_PAGE_COMPONENTS
348 !insertmacro MUI_PAGE_DIRECTORY
349 !insertmacro MUI_PAGE_INSTFILES
350 !insertmacro MUI_PAGE_FINISH
351 !insertmacro MUI_UNPAGE_CONFIRM
352 !insertmacro MUI_UNPAGE_INSTFILES
353 !insertmacro MUI_LANGUAGE "English"
358 ReadRegStr \$R0 HKLM \
359 "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" \
363 MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
364 "${PROGRAM_NAME} is already installed. Click 'OK' to remove the previous version or 'Cancel' to cancel this upgrade." \
370 ExecWait '\$R0 _?=\$INSTDIR'
371 IfErrors uninstall_error
373 ReadRegStr \$R1 HKLM \
374 "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" \
376 StrCmp \$R1 "" 0 done
378 Delete "\$INSTDIR\\uninstall.exe"
384 MessageBox MB_OK|MB_ICONEXCLAMATION \
385 "Uninstaller did not complete successfully. Continue at your own risk..." \
393 Section "${PROGRAM_NAME}${PROGRAM_VERSION} (required)" SecMainProg
399 File /nonfatal debug.bat
400 File /nonfatal /r gdb
401 WriteRegStr HKLM "Software\\${PROGRAM_NAME}\\v${PROGRAM_VERSION}\\$WARCH" "Install_Dir" "\$INSTDIR"
402 WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "DisplayName" "${PROGRAM_NAME}${PROGRAM_VERSION}"
403 WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "UninstallString" '"\$INSTDIR\\uninstall.exe"'
404 WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "NoModify" 1
405 WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "NoRepair" 1
406 WriteUninstaller "\$INSTDIR\uninstall.exe"
407 CreateShortCut "\$INSTDIR\\${PROGRAM_NAME}${PROGRAM_VERSION}.lnk" "\$INSTDIR\\bin\\${PRODUCT_EXE}" "" "\$INSTDIR\\bin\\${PRODUCT_EXE}" 0
408 \${If} \${AtMostWinXP}
409 Delete "\$INSTDIR\\bin\\libportaudio-2.dll"
410 Rename "\$INSTDIR\\bin\\libportaudio-2.xp" "\$INSTDIR\\bin\\libportaudio-2.dll"
412 Delete "\$INSTDIR\\bin\\libportaudio-2.xp"
414 \${registerExtension} "\$INSTDIR\\bin\\${STATEFILE_SUFFIX}" ".${PRODUCT_NAME}" "${PROGRAM_NAME} Session"
418 if test -z "$NOVIDEOTOOLS"; then
420 cat >> $NSISFILE << EOF
421 Section "Videotimeline Tools" SecVideo
422 WriteRegStr HKLM "Software\\${PROGRAM_NAME}\\v${PROGRAM_VERSION}\\video" "Install_Dir" "\$INSTDIR\\video"
430 cat >> $NSISFILE << EOF
431 Section "Start Menu Shortcuts" SecMenu
432 SetShellVarContext all
433 CreateDirectory "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}"
434 CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\${PROGRAM_NAME}${PROGRAM_VERSION}.lnk" "\$INSTDIR\\bin\\${PRODUCT_EXE}" "" "\$INSTDIR\\bin\\${PRODUCT_EXE}" 0
437 if test -f "$DESTDIR/debug.bat"; then
438 cat >> $NSISFILE << EOF
439 CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\${PROGRAM_NAME}${PROGRAM_VERSION} GDB.lnk" "\$INSTDIR\\debug.bat" "" "\$INSTDIR\\share\\ardour_bug.ico" 0
443 if test -z "$NOVIDEOTOOLS"; then
444 cat >> $NSISFILE << EOF
445 IfFileExists "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" 0 +2
446 CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\Video Monitor.lnk" "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" "" "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" 0
450 cat >> $NSISFILE << EOF
451 CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\Uninstall.lnk" "\$INSTDIR\\uninstall.exe" "" "\$INSTDIR\\uninstall.exe" 0
453 LangString DESC_SecMainProg \${LANG_ENGLISH} "${PROGRAM_NAME} ${ARDOURVERSION}\$\\r\$\\n${VERSIONINFO}\$\\r\$\\n${ARDOURDATE}"
456 if test -z "$NOVIDEOTOOLS"; then
457 cat >> $NSISFILE << EOF
458 LangString DESC_SecVideo \${LANG_ENGLISH} "Video Tools\$\\r\$\\nxjadeo-${XJADEO_VERSION}\$\\r\$\\nharvid-${HARVID_VERSION}"
462 cat >> $NSISFILE << EOF
463 LangString DESC_SecMenu \${LANG_ENGLISH} "Create Start-Menu Shortcuts (recommended)."
464 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
465 !insertmacro MUI_DESCRIPTION_TEXT \${SecMainProg} \$(DESC_SecMainProg)
468 if test -z "$NOVIDEOTOOLS"; then
469 cat >> $NSISFILE << EOF
470 !insertmacro MUI_DESCRIPTION_TEXT \${SecVideo} \$(DESC_SecVideo)
474 cat >> $NSISFILE << EOF
475 !insertmacro MUI_DESCRIPTION_TEXT \${SecMenu} \$(DESC_SecMenu)
476 !insertmacro MUI_FUNCTION_DESCRIPTION_END
478 SetShellVarContext all
479 DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}"
480 DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}"
481 DeleteRegKey HKLM "Software\\${PROGRAM_NAME}\\v${PROGRAM_VERSION}"
482 RMDir /r "\$INSTDIR\\bin"
483 RMDir /r "\$INSTDIR\\lib"
484 RMDir /r "\$INSTDIR\\share"
485 RMDir /r "\$INSTDIR\\gdb"
486 RMDir /r "\$INSTDIR\\video"
487 Delete "\$INSTDIR\\debug.bat"
488 Delete "\$INSTDIR\\uninstall.exe"
489 Delete "\$INSTDIR\\${PROGRAM_NAME}${PROGRAM_VERSION}.lnk"
491 Delete "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\*.*"
492 RMDir "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}"
493 \${unregisterExtension} ".${STATEFILE_SUFFIX}" "${PROGRAM_NAME} Session"
498 echo " === OutFile: $OUTFILE"
500 if test -n "$QUICKZIP" ; then
501 echo " === Building Windows Installer (fast zip)"
503 echo " === Building Windows Installer (lzma compression takes ages)"
505 time makensis -V2 $NSISFILE