package portaudio w/WASAPI for Vista or later
[ardour.git] / tools / x-win / package.sh
index ad1a923483232dba73b1ec753aa20bdc513cb4e3..9880727906a7785352ddc77c7b94c66610a74939 100755 (executable)
@@ -2,7 +2,12 @@
 
 # we assume this script is <ardour-src>/tools/x-win/package.sh
 pushd "`/usr/bin/dirname \"$0\"`" > /dev/null; this_script_dir="`pwd`"; popd > /dev/null
+cd $this_script_dir
+
+. ../define_versions.sh
+
 cd $this_script_dir/../..
+
 test -f gtk2_ardour/wscript || exit 1
 
 # Defaults (overridden by environment)
@@ -23,25 +28,36 @@ while [ $# -gt 0 ] ; do
 done
 
 # see also wscript, video_tool_paths.cc, bundle_env_mingw.cc
+# registry keys based on this are used there
 PROGRAM_NAME=Ardour
 PRODUCT_NAME=ardour
-PROGRAM_VERSION=3
+PROGRAM_VERSION=${major_version}
 
-LOWERCASE_DIRNAME=ardour3 # see wscript 'lwrcase_dirname' used for lib/ardour3 and share/ardour3
+LOWERCASE_DIRNAME=ardour${major_version}
 STATEFILE_SUFFIX=ardour # see filename_extensions.cc
 
+BIT_SUFFIX=""
+
 if test -n "$MIXBUS"; then
-       PROGRAM_NAME=Mixbus
-       PRODUCT_NAME=mixbus
+       if test "$XARCH" = "x86_64"; then
+               PROGRAM_NAME=Mixbus
+               PRODUCT_NAME=mixbus
+       else
+               PROGRAM_NAME=Mixbus
+               PRODUCT_NAME=mixbus
+               BIT_SUFFIX="(x86)"
+       fi
 fi
 
 # derived variables
-PRODUCT_ID=${PROGRAM_NAME}${PROGRAM_VERSION}
+PRODUCT_ID=${PROGRAM_NAME}${PROGRAM_VERSION}${BIT_SUFFIX}
 PRODUCT_EXE=${PRODUCT_NAME}.exe
 PRODUCT_ICON=${PRODUCT_NAME}.ico
 
 ###############################################################################
 
+echo "Packaging $PRODUCT_ID"
+
 if test "$XARCH" = "x86_64" -o "$XARCH" = "amd64"; then
        echo "Target: 64bit Windows (x86_64)"
        XPREFIX=x86_64-w64-mingw32
@@ -68,13 +84,15 @@ test -f ${SRCDIR}/$1 || curl -k -L -o ${SRCDIR}/$1 $2
 ################################################################################
 set -e
 
-ARDOURVERSION=$(git describe | sed 's/-g.*$//')
+ARDOURVERSION=${release_version}
 ARDOURDATE=$(date -R)
-BINVERSION=$(git describe | sed 's/-g.*$//;s/\-rc\([^-]*\)-/-rc\1./;s/-/./;s/-.*$//')
-if ! test -f build/gtk2_ardour/ardour-${BINVERSION}.exe; then
-       echo "*** Please compile ardour ${ARDOURVERSION} first."
+if ! test -f build/gtk2_ardour/ardour-${ARDOURVERSION}.exe; then
+       echo "*** Please compile  ardour-${ARDOURVERSION}.exe first."
        exit 1
 fi
+
+echo " === bundle to $DESTDIR"
+
 ./waf install
 
 ################################################################################
@@ -114,6 +132,8 @@ cp build/libs/clearlooks-newer/clearlooks.dll $DESTDIR/lib/gtk-2.0/engines/libcl
 
 cp $PREFIX/bin/*dll $DESTDIR/bin/
 cp $PREFIX/lib/*dll $DESTDIR/bin/
+# special case libportaudio (wasapi), old stack has no wasapi and hence no .xp
+cp $PREFIX/bin/libportaudio-2.xp $DESTDIR/bin/ || cp $PREFIX/bin/libportaudio-2.dll $DESTDIR/bin/libportaudio-2.xp
 rm -rf $DESTDIR/bin/libjack*.dll
 
 cp `find build/libs/surfaces/ -iname "*.dll"` $ALIBDIR/surfaces/
@@ -129,7 +149,7 @@ if test -d $PREFIX/lib/lv2/lv2core.lv2 ; then
        cp -R $PREFIX/lib/lv2/lv2core.lv2 $ALIBDIR/LV2/
 fi
 
-mv $ALIBDIR/surfaces/ardourcp-*.dll $DESTDIR/bin/
+mv $ALIBDIR/surfaces/ardourcp*.dll $DESTDIR/bin/
 
 # TODO use -static-libgcc -static-libstdc++ -- but for .exe files only
 if update-alternatives --query ${XPREFIX}-gcc | grep Value: | grep -q win32; then
@@ -148,6 +168,7 @@ if test -f /usr/${XPREFIX}/lib/libwinpthread-1.dll; then
 fi
 
 cp -r $PREFIX/share/${LOWERCASE_DIRNAME} $DESTDIR/share/
+cp -r $PREFIX/share/locale $DESTDIR/share/
 cp -r $PREFIX/etc/${LOWERCASE_DIRNAME}/* $DESTDIR/share/${LOWERCASE_DIRNAME}/
 
 cp COPYING $DESTDIR/share/
@@ -158,6 +179,7 @@ cp gtk2_ardour/icons/ardour_bug.ico $DESTDIR/share/
 cp gtk2_ardour/icons/cursor_square/* $DESTDIR/share/${LOWERCASE_DIRNAME}/icons/
 
 # clean build-dir after depoyment
+echo " === bundle completed, cleaning up"
 ./waf uninstall
 echo " === complete"
 du -sh $DESTDIR
@@ -202,7 +224,7 @@ if ! grep " using ./waf configure" build/config.log | grep -q -- "--optimize"; t
        cp -r ${SRCDIR}/gdb_$WARCH $DESTDIR/gdb
        cat > $DESTDIR/debug.bat << EOF
 cd bin
-START ..\\gdb\\bin\\gdb.exe -iex "set logging overwrite on" -iex "set height 0" -iex "set logging on %UserProfile%\\${PRODUCT_NAME}-debug.log" ${PRODUCT_EXE}
+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"
 EOF
        OUTFILE="${TMPDIR}/${PRODUCT_NAME}-${ARDOURVERSION}-dbg-${WARCH}-Setup.exe"
        VERSIONINFO="Debug Version."
@@ -211,14 +233,68 @@ else
        VERSIONINFO="Optimized Version."
 fi
 
+################################################################################
+### Mixbus plugins, etc
+if test -n "$MIXBUS"; then # TODO use separate variable
+       mkdir -p $ALIBDIR/LV2
+
+       echo "Adding x42 Plugins"
+
+       METERS_VERSION=$(curl -s -S http://x42-plugins.com/x42/win/x42-meters.latest.txt)
+       rsync -a -q --partial \
+               rsync://x42-plugins.com/x42/win/x42-meters-lv2-${WARCH}-${METERS_VERSION}.zip \
+               "${SRCDIR}/x42-meters-lv2-${WARCH}-${METERS_VERSION}.zip"
+       unzip -q -d "$ALIBDIR/LV3/" "${SRCDIR}/x42-meters-lv2-${WARCH}-${METERS_VERSION}.zip"
+
+       SETBFREE_VERSION=$(curl -s -S http://x42-plugins.com/x42/win/setBfree.latest.txt)
+       rsync -a -q --partial \
+               rsync://x42-plugins.com/x42/win/setBfree-lv2-${WARCH}-${SETBFREE_VERSION}.zip \
+               "${SRCDIR}/setBfree-lv2-${WARCH}-${SETBFREE_VERSION}.zip"
+       unzip -q -d "$ALIBDIR/LV2/" "${SRCDIR}/setBfree-lv2-${WARCH}-${SETBFREE_VERSION}.zip"
+
+       MIDIFILTER_VERSION=$(curl -s -S http://x42-plugins.com/x42/win/x42-midifilter.latest.txt)
+       rsync -a -q --partial \
+               rsync://x42-plugins.com/x42/win/x42-midifilter-lv2-${WARCH}-${MIDIFILTER_VERSION}.zip \
+               "${SRCDIR}/x42-midifilter-lv2-${WARCH}-${MIDIFILTER_VERSION}.zip"
+       unzip -q -d "$ALIBDIR/LV2/" "${SRCDIR}/x42-midifilter-lv2-${WARCH}-${MIDIFILTER_VERSION}.zip"
+fi
+
+if test -n "$MIXBUS"; then # TODO use separate variable
+       mkdir -p $ALIBDIR/LV2
+
+       echo "Including Harrison LV2s"
+
+       curl -s -S --fail -# \
+               -z "${SRCDIR}/harrison_lv2s.${WARCH}.zip" \
+               -o "${SRCDIR}/harrison_lv2s.${WARCH}.zip" \
+               http://www.harrisonconsoles.com/mixbus/mb3/${WARCH}/harrison_lv2s.zip
+       unzip -q -d "$ALIBDIR/LV2/" "${SRCDIR}/harrison_lv2s.${WARCH}.zip"
+fi
+
+if test -n "$MIXBUS"; then
+       echo "Deploying Harrison Mixbus Channelstrip"
+
+       mkdir -p $ALIBDIR/ladspa/strip
+       curl -s -S --fail -# \
+               -z "${SRCDIR}/harrison_channelstrip.${WARCH}.dll" \
+               -o "${SRCDIR}/harrison_channelstrip.${WARCH}.dll" \
+               http://www.harrisonconsoles.com/mixbus/mb3/${WARCH}/harrison_channelstrip.dll
+
+       cp "${SRCDIR}/harrison_channelstrip.${WARCH}.dll" \
+               "$ALIBDIR/ladspa/strip/rrison_channelstrip.dll"
+fi
+
 ################################################################################
 echo " === Preparing Windows Installer"
 NSISFILE=$DESTDIR/a3.nsis
 
 if test "$WARCH" = "w64"; then
        PGF=PROGRAMFILES64
+       SFX=
 else
        PGF=PROGRAMFILES
+       # TODO we should only add this for 32bit on 64bit windows!
+       SFX=" (x86)"
 fi
 
 if test -n "$QUICKZIP" ; then
@@ -236,6 +312,7 @@ cat >> $NSISFILE << EOF
 !addincludedir "${this_script_dir}\\nsis"
 !include MUI2.nsh
 !include FileAssociation.nsh
+!include WinVer.nsh
 
 Name "${PROGRAM_NAME}${PROGRAM_VERSION}"
 OutFile "${OUTFILE}"
@@ -250,10 +327,10 @@ if test -n "$MIXBUS"; then
 
 # TODO: proper welcome/finish text.
        cat >> $NSISFILE << EOF
-!define MUI_FINISHPAGE_TITLE "Welcome to Mixbus"
-!define MUI_FINISHPAGE_TEXT "Thank you for choosing Harrison Mixbus."
-!define MUI_FINISHPAGE_LINK "Harrison Consoles Website"
-!define MUI_FINISHPAGE_LINK_LOCATION "http://harrisonconsoles.com"
+!define MUI_FINISHPAGE_TITLE "Welcome to Harrison Mixbus"
+!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."
+!define MUI_FINISHPAGE_LINK "Mixbus Manual"
+!define MUI_FINISHPAGE_LINK_LOCATION "http://www.harrisonconsoles.com/mixbus/mixbus3-live-manual"
 !define MUI_FINISHPAGE_NOREBOOTSUPPORT
 EOF
 
@@ -261,9 +338,9 @@ else
 
        cat >> $NSISFILE << EOF
 !define MUI_FINISHPAGE_TITLE "Welcome to Ardour"
-!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."
-!define MUI_FINISHPAGE_LINK "Ardour Manual"
-!define MUI_FINISHPAGE_LINK_LOCATION "http://manual.ardour.org"
+!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."
+!define MUI_FINISHPAGE_LINK "Ardour on Windows"
+!define MUI_FINISHPAGE_LINK_LOCATION "http://ardour.org/windows.html"
 #this would run as admin - see http://forums.winamp.com/showthread.php?t=353366
 #!define MUI_FINISHPAGE_RUN "\$INSTDIR\\bin\\${PRODUCT_EXE}"
 !define MUI_FINISHPAGE_NOREBOOTSUPPORT
@@ -282,6 +359,44 @@ cat >> $NSISFILE << EOF
 !insertmacro MUI_UNPAGE_INSTFILES
 !insertmacro MUI_LANGUAGE "English"
 
+
+Function .onInit
+
+  ReadRegStr \$R0 HKLM \
+    "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" \
+    "UninstallString"
+  StrCmp \$R0 "" done
+
+  MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
+    "${PROGRAM_NAME} is already installed. Click 'OK' to remove the previous version or 'Cancel' to cancel this upgrade." \
+    IDOK uninst
+    Abort
+
+  uninst:
+    ClearErrors
+    ExecWait '\$R0 _?=\$INSTDIR'
+    IfErrors uninstall_error
+
+    ReadRegStr \$R1 HKLM \
+      "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" \
+      "UninstallString"
+    StrCmp \$R1 "" 0 done
+
+    Delete "\$INSTDIR\\uninstall.exe"
+    RMDir "\$INSTDIR"
+    goto done
+
+  uninstall_error:
+
+    MessageBox MB_OK|MB_ICONEXCLAMATION \
+      "Uninstaller did not complete successfully. Continue at your own risk..." \
+      IDOK done
+
+  done:
+
+FunctionEnd
+
+
 Section "${PROGRAM_NAME}${PROGRAM_VERSION} (required)" SecMainProg
   SectionIn RO
   SetOutPath \$INSTDIR
@@ -291,12 +406,18 @@ Section "${PROGRAM_NAME}${PROGRAM_VERSION} (required)" SecMainProg
   File /nonfatal debug.bat
   File /nonfatal /r gdb
   WriteRegStr HKLM "Software\\${PROGRAM_NAME}\\v${PROGRAM_VERSION}\\$WARCH" "Install_Dir" "\$INSTDIR"
-  WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}" "DisplayName" "${PROGRAM_NAME}${PROGRAM_VERSION}"
-  WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}" "UninstallString" '"\$INSTDIR\\uninstall.exe"'
-  WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}" "NoModify" 1
-  WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}" "NoRepair" 1
+  WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "DisplayName" "${PROGRAM_NAME}${PROGRAM_VERSION}"
+  WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "UninstallString" '"\$INSTDIR\\uninstall.exe"'
+  WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "NoModify" 1
+  WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}" "NoRepair" 1
   WriteUninstaller "\$INSTDIR\uninstall.exe"
   CreateShortCut "\$INSTDIR\\${PROGRAM_NAME}${PROGRAM_VERSION}.lnk" "\$INSTDIR\\bin\\${PRODUCT_EXE}" "" "\$INSTDIR\\bin\\${PRODUCT_EXE}" 0
+  \${If} \${AtMostWinXP}
+    Delete "\$INSTDIR\\bin\\libportaudio-2.dll"
+    Rename "\$INSTDIR\\bin\\libportaudio-2.xp" "\$INSTDIR\\bin\\libportaudio-2.dll"
+  \${Else}
+    Delete "\$INSTDIR\\bin\\libportaudio-2.xp"
+  \${EndIf}
   \${registerExtension} "\$INSTDIR\\bin\\${STATEFILE_SUFFIX}" ".${PRODUCT_NAME}" "${PROGRAM_NAME} Session"
 SectionEnd
 EOF
@@ -316,25 +437,25 @@ fi
 cat >> $NSISFILE << EOF
 Section "Start Menu Shortcuts" SecMenu
   SetShellVarContext all
-  CreateDirectory "\$SMPROGRAMS\\${PRODUCT_ID}"
-  CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}\\${PROGRAM_NAME}${PROGRAM_VERSION}.lnk" "\$INSTDIR\\bin\\${PRODUCT_EXE}" "" "\$INSTDIR\\bin\\${PRODUCT_EXE}" 0
+  CreateDirectory "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}"
+  CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\${PROGRAM_NAME}${PROGRAM_VERSION}.lnk" "\$INSTDIR\\bin\\${PRODUCT_EXE}" "" "\$INSTDIR\\bin\\${PRODUCT_EXE}" 0
 EOF
 
 if test -f "$DESTDIR/debug.bat"; then
        cat >> $NSISFILE << EOF
-  CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}\\${PROGRAM_NAME}${PROGRAM_VERSION} GDB.lnk" "\$INSTDIR\\debug.bat" "" "\$INSTDIR\\share\\ardour_bug.ico" 0
+  CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\${PROGRAM_NAME}${PROGRAM_VERSION} GDB.lnk" "\$INSTDIR\\debug.bat" "" "\$INSTDIR\\share\\ardour_bug.ico" 0
 EOF
 fi
 
 if test -z "$NOVIDEOTOOLS"; then
        cat >> $NSISFILE << EOF
   IfFileExists "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" 0 +2
-  CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}\\Video Monitor.lnk" "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" "" "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" 0
+  CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\Video Monitor.lnk" "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" "" "\$INSTDIR\\video\\xjadeo\\xjadeo.exe" 0
 EOF
 fi
 
 cat >> $NSISFILE << EOF
-  CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}\\Uninstall.lnk" "\$INSTDIR\\uninstall.exe" "" "\$INSTDIR\\uninstall.exe" 0
+  CreateShortCut "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\Uninstall.lnk" "\$INSTDIR\\uninstall.exe" "" "\$INSTDIR\\uninstall.exe" 0
 SectionEnd
 LangString DESC_SecMainProg \${LANG_ENGLISH} "${PROGRAM_NAME} ${ARDOURVERSION}\$\\r\$\\n${VERSIONINFO}\$\\r\$\\n${ARDOURDATE}"
 EOF
@@ -362,12 +483,9 @@ cat >> $NSISFILE << EOF
 !insertmacro MUI_FUNCTION_DESCRIPTION_END
 Section "Uninstall"
   SetShellVarContext all
+  DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}-${WARCH}"
   DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}"
   DeleteRegKey HKLM "Software\\${PROGRAM_NAME}\\v${PROGRAM_VERSION}"
-# XXX XXX XXX
-# TODO: remove the following line before release. But for now, clean up old version agnnstic registry
-  DeleteRegKey HKLM "Software\\${PROGRAM_NAME}"
-# XXX XXX XXX
   RMDir /r "\$INSTDIR\\bin"
   RMDir /r "\$INSTDIR\\lib"
   RMDir /r "\$INSTDIR\\share"
@@ -377,8 +495,8 @@ Section "Uninstall"
   Delete "\$INSTDIR\\uninstall.exe"
   Delete "\$INSTDIR\\${PROGRAM_NAME}${PROGRAM_VERSION}.lnk"
   RMDir "\$INSTDIR"
-  Delete "\$SMPROGRAMS\\${PRODUCT_ID}\\*.*"
-  RMDir "\$SMPROGRAMS\\${PRODUCT_ID}"
+  Delete "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}\\*.*"
+  RMDir "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}"
   \${unregisterExtension} ".${STATEFILE_SUFFIX}" "${PROGRAM_NAME} Session"
 SectionEnd
 EOF