backup lua-test/devel util code
[ardour.git] / tools / x-win / package.sh
index b03225223f09340affc83479e9c9968722c5d49d..501f8fb1cdc2eb678f763e590b8d358322b3fa41 100755 (executable)
@@ -15,7 +15,17 @@ test -f gtk2_ardour/wscript || exit 1
 : ${ROOT=/home/ardour}
 : ${MAKEFLAGS=-j4}
 : ${TMPDIR=/var/tmp}
-: ${SRCDIR=/var/tmp/winsrc}  # source-code tgz cache
+: ${SRCCACHE=/var/tmp/winsrc}  # source-code tgz cache
+: ${HARRISONCHANNELSTRIP=harrison_channelstrip}
+
+# see also wscript, video_tool_paths.cc, bundle_env_mingw.cc
+# registry keys based on this are used there
+PROGRAM_NAME=Ardour
+PROGRAM_KEY=Ardour
+PROGRAM_VERSION=${major_version}
+
+PRODUCT_NAME=ardour
+PRODUCT_VERSION=${major_version}
 
 # TODO: grep from build/config.log instead
 while [ $# -gt 0 ] ; do
@@ -23,23 +33,29 @@ while [ $# -gt 0 ] ; do
        case $1 in
                --mixbus)
                        MIXBUS=1
+                       WITH_HARRISON_LV2=1 ;
+                       WITH_X42_LV2=1 ;
+                       PROGRAM_NAME=Mixbus
+                       PROGRAM_KEY=Mixbus
+                       PRODUCT_NAME=mixbus
+                       shift ;;
+               --mixbus32c)
+                       MIXBUS=1
+                       WITH_HARRISON_LV2=1 ;
+                       WITH_X42_LV2=1 ;
+                       PRODUCT_NAME=mixbus32c
+                       PROGRAM_KEY=Mixbus32C
+                       PROGRAM_NAME=Mixbus32C-${PROGRAM_VERSION}
+                       PROGRAM_VERSION=""
                        shift ;;
+               --chanstrip) HARRISONCHANNELSTRIP=$2 ; shift; shift ;;
        esac
 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=${major_version}
 
 LOWERCASE_DIRNAME=ardour${major_version}
 STATEFILE_SUFFIX=ardour # see filename_extensions.cc
 
-if test -n "$MIXBUS"; then
-       PROGRAM_NAME=Mixbus
-       PRODUCT_NAME=mixbus
-fi
 
 # derived variables
 PRODUCT_ID=${PROGRAM_NAME}${PROGRAM_VERSION}
@@ -61,7 +77,7 @@ else
 fi
 
 : ${PREFIX=${ROOT}/win-stack-$WARCH}
-export SRCDIR
+export SRCCACHE
 
 if [ "$(id -u)" = "0" ]; then
        apt-get -y install nsis curl
@@ -70,7 +86,7 @@ fi
 
 function download {
 echo "--- Downloading.. $2"
-test -f ${SRCDIR}/$1 || curl -k -L -o ${SRCDIR}/$1 $2
+test -f ${SRCCACHE}/$1 || curl -k -L -o ${SRCCACHE}/$1 $2
 }
 
 ################################################################################
@@ -177,8 +193,6 @@ echo " === bundle completed, cleaning up"
 echo " === complete"
 du -sh $DESTDIR
 
-( cd $DESTDIR ; find . ) > ${TMPDIR}/file_list.txt
-
 ################################################################################
 ### get video tools
 if test -z "$NOVIDEOTOOLS"; then
@@ -188,15 +202,15 @@ if test -z "$NOVIDEOTOOLS"; then
 
        rsync -a -q --partial \
                rsync://ardour.org/video-tools/harvid_win-${HARVID_VERSION}.tar.xz \
-               "${SRCDIR}/harvid_win-${HARVID_VERSION}.tar.xz"
+               "${SRCCACHE}/harvid_win-${HARVID_VERSION}.tar.xz"
 
        rsync -a -q --partial \
                rsync://ardour.org/video-tools/xjadeo_win-${XJADEO_VERSION}.tar.xz \
-               "${SRCDIR}/xjadeo_win-${XJADEO_VERSION}.tar.xz"
+               "${SRCCACHE}/xjadeo_win-${XJADEO_VERSION}.tar.xz"
 
        mkdir $DESTDIR/video
-       tar -xf "${SRCDIR}/harvid_win-${HARVID_VERSION}.tar.xz" -C "$DESTDIR/video/"
-       tar -xf "${SRCDIR}/xjadeo_win-${XJADEO_VERSION}.tar.xz" -C "$DESTDIR/video/"
+       tar -xf "${SRCCACHE}/harvid_win-${HARVID_VERSION}.tar.xz" -C "$DESTDIR/video/"
+       tar -xf "${SRCCACHE}/xjadeo_win-${XJADEO_VERSION}.tar.xz" -C "$DESTDIR/video/"
 
        echo " === unzipped"
        du -sh $DESTDIR/video
@@ -209,12 +223,12 @@ fi
 ### 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
 if ! grep " using ./waf configure" build/config.log | grep -q -- "--optimize"; then
        download gdb-static-win3264.tar.xz http://robin.linuxaudio.org/gdb-static-win3264.tar.xz
-       cd ${SRCDIR}
+       cd ${SRCCACHE}
        tar xf gdb-static-win3264.tar.xz
        cd - > /dev/null
 
        echo " === Creating debug.bat"
-       cp -r ${SRCDIR}/gdb_$WARCH $DESTDIR/gdb
+       cp -r ${SRCCACHE}/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" -iex "target exec ${PRODUCT_EXE}" -iex "run"
@@ -228,40 +242,30 @@ fi
 
 ################################################################################
 ### Mixbus plugins, etc
-if test -n "$MIXBUS"; then # TODO use separate variable
+if test x$WITH_X42_LV2 != x ; then
        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"
+       for proj in x42-meters x42-midifilter x42-midimap x42-stereoroute x42-eq setBfree; do
+               X42_VERSION=$(curl -s -S http://x42-plugins.com/x42/win/${proj}.latest.txt)
+               rsync -a -q --partial \
+                       rsync://x42-plugins.com/x42/win/${proj}-lv2-${WARCH}-${X42_VERSION}.zip \
+                       "${SRCCACHE}/${proj}-lv2-${WARCH}-${X42_VERSION}.zip"
+               unzip -q -d "$ALIBDIR/LV2/" "${SRCCACHE}/${proj}-lv2-${WARCH}-${X42_VERSION}.zip"
+       done
 fi
 
-if test -n "$MIXBUS"; then # TODO use separate variable
+if test x$WITH_HARRISON_LV2 != x ; then
        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"
+               -z "${SRCCACHE}/harrison_lv2s.${WARCH}.zip" \
+               -o "${SRCCACHE}/harrison_lv2s.${WARCH}.zip" \
+               "http://www.harrisonconsoles.com/mixbus/mb3/beta/harrison-dsp/harrison_lv2s.${WARCH}.zip"
+       unzip -q -d "$ALIBDIR/LV2/" "${SRCCACHE}/harrison_lv2s.${WARCH}.zip"
 fi
 
 if test -n "$MIXBUS"; then
@@ -269,14 +273,26 @@ if test -n "$MIXBUS"; then
 
        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
+               -z "${SRCCACHE}/${HARRISONCHANNELSTRIP}.${WARCH}.dll" \
+               -o "${SRCCACHE}/${HARRISONCHANNELSTRIP}.${WARCH}.dll" \
+               "http://www.harrisonconsoles.com/mixbus/mb3/beta/harrison-dsp/${HARRISONCHANNELSTRIP}.${WARCH}.dll"
+
+       cp "${SRCCACHE}/${HARRISONCHANNELSTRIP}.${WARCH}.dll" \
+               "$ALIBDIR/ladspa/strip/${HARRISONCHANNELSTRIP}.dll"
 
-       cp "${SRCDIR}/harrison_channelstrip.${WARCH}.dll" \
-               "$ALIBDIR/ladspa/strip/rrison_channelstrip.dll"
+       echo "Deploying Harrison Vamp Plugins"
+       mkdir -p $ALIBDIR/vamp
+       curl -s -S --fail -# \
+               -z "${SRCCACHE}/harrison_vamp.${WARCH}.dll" \
+               -o "${SRCCACHE}/harrison_vamp.${WARCH}.dll" \
+               "http://www.harrisonconsoles.com/mixbus/mb3/beta/harrison-dsp/harrison_vamp.${WARCH}.dll"
+
+       cp "${SRCCACHE}/harrison_vamp.${WARCH}.dll" \
+               "$ALIBDIR/vamp/harrison_vamp.dll"
 fi
 
+( cd $DESTDIR ; find . ) > ${TMPDIR}/file_list.txt
+
 ################################################################################
 echo " === Preparing Windows Installer"
 NSISFILE=$DESTDIR/a3.nsis
@@ -311,7 +327,7 @@ Name "${PROGRAM_NAME}${PROGRAM_VERSION}"
 OutFile "${OUTFILE}"
 RequestExecutionLevel admin
 InstallDir "\$${PGF}\\${PRODUCT_ID}"
-InstallDirRegKey HKLM "Software\\${PROGRAM_NAME}\\${PRODUCT_ID}\\$WARCH" "Install_Dir"
+InstallDirRegKey HKLM "Software\\${PRODUCT_NAME}\\${PRODUCT_ID}\\$WARCH" "Install_Dir"
 !define MUI_ICON "share\\${PRODUCT_ICON}"
 
 EOF
@@ -352,44 +368,6 @@ 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
@@ -398,28 +376,25 @@ Section "${PROGRAM_NAME}${PROGRAM_VERSION} (required)" SecMainProg
   File /r share
   File /nonfatal debug.bat
   File /nonfatal /r gdb
-  WriteRegStr HKLM "Software\\${PROGRAM_NAME}\\v${PROGRAM_VERSION}\\$WARCH" "Install_Dir" "\$INSTDIR"
+  WriteRegStr HKLM "Software\\${PROGRAM_KEY}\\v${major_version}\\$WARCH" "Install_Dir" "\$INSTDIR"
   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
+
+Section "WASAPI sound driver" SecWASAPI
+SectionEnd
 EOF
 
 if test -z "$NOVIDEOTOOLS"; then
 
        cat >> $NSISFILE << EOF
 Section "Videotimeline Tools" SecVideo
-  WriteRegStr HKLM "Software\\${PROGRAM_NAME}\\v${PROGRAM_VERSION}\\video" "Install_Dir" "\$INSTDIR\\video"
+  WriteRegStr HKLM "Software\\${PROGRAM_KEY}\\v${major_version}\\video" "Install_Dir" "\$INSTDIR\\video"
   SetOutPath \$INSTDIR
   File /r video
 SectionEnd
@@ -451,6 +426,7 @@ cat >> $NSISFILE << EOF
   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}"
+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."
 EOF
 
 if test -z "$NOVIDEOTOOLS"; then
@@ -463,6 +439,7 @@ cat >> $NSISFILE << EOF
 LangString DESC_SecMenu \${LANG_ENGLISH} "Create Start-Menu Shortcuts (recommended)."
 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
 !insertmacro MUI_DESCRIPTION_TEXT \${SecMainProg} \$(DESC_SecMainProg)
+!insertmacro MUI_DESCRIPTION_TEXT \${SecWASAPI} \$(DESC_SecWASAPI)
 EOF
 
 if test -z "$NOVIDEOTOOLS"; then
@@ -478,7 +455,7 @@ 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}"
+  DeleteRegKey HKLM "Software\\${PROGRAM_KEY}\\v${major_version}"
   RMDir /r "\$INSTDIR\\bin"
   RMDir /r "\$INSTDIR\\lib"
   RMDir /r "\$INSTDIR\\share"
@@ -492,6 +469,75 @@ Section "Uninstall"
   RMDir "\$SMPROGRAMS\\${PRODUCT_ID}${SFX}"
   \${unregisterExtension} ".${STATEFILE_SUFFIX}" "${PROGRAM_NAME} Session"
 SectionEnd
+
+
+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:
+
+  \${If} \${AtMostWinXP}
+    SectionSetFlags \${SecWASAPI} \${SF_RO}
+  \${Else}
+    SectionSetFlags \${SecWASAPI} \${SF_SELECTED}
+  \${EndIf}
+
+FunctionEnd
+
+Function .onInstSuccess
+
+  \${If} \${AtMostWinXP}
+    goto pa_no_wasapi
+  \${EndIf}
+
+  SectionGetFlags \${SecWASAPI} \$R0
+
+  IntOp \$R0 \$R0 & \${SF_SELECTED}
+  IntCmp \$R0 \${SF_SELECTED} pa_with_wasapi pa_no_wasapi
+
+  pa_with_wasapi:
+; VISTA .. 9, libportaudio with WASAPI is good.
+  Delete "\$INSTDIR\\bin\\libportaudio-2.xp"
+  goto endportaudio
+
+; Windows XP lacks support for WASAPI, Windows10 on some system has issues
+; http://tracker.ardour.org/view.php?id=6507
+  pa_no_wasapi:
+  Delete "\$INSTDIR\\bin\\libportaudio-2.dll"
+  Rename "\$INSTDIR\\bin\\libportaudio-2.xp" "\$INSTDIR\\bin\\libportaudio-2.dll"
+
+  endportaudio:
+
+FunctionEnd
 EOF
 
 rm -f ${OUTFILE}