windows-nsis-vs2005-20080409
authorAsanka Herath <asanka@secure-endpoints.com>
Wed, 9 Apr 2008 05:34:22 +0000 (05:34 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 9 Apr 2008 05:34:22 +0000 (05:34 +0000)
LICENSE MIT

Add support for building with VS2005 Runtime Libraries.
For the release build use the vcredist_<arch>.exe package.
For the debug build, build an msi from the merge modules
and then install that package.

src/WINNT/install/NSIS/MakeVCRuntimeMSI.cmd [new file with mode: 0644]
src/WINNT/install/NSIS/NTMakefile
src/WINNT/install/NSIS/OpenAFS.nsi
src/WINNT/install/NSIS/vcruntime.wxs [new file with mode: 0644]

diff --git a/src/WINNT/install/NSIS/MakeVCRuntimeMSI.cmd b/src/WINNT/install/NSIS/MakeVCRuntimeMSI.cmd
new file mode 100644 (file)
index 0000000..070729a
--- /dev/null
@@ -0,0 +1,20 @@
+@echo off
+setlocal
+if "%1"=="debug" set DR=Debug
+if "%1"=="retail" set DR=Retail
+if "%DR%"=="" goto usage
+if "%2"=="x86" set PL=Intel
+if "%2"=="x64" set PL=x64
+if "%PL%"=="" goto usage
+
+candle vcruntime.wxs -dConfig=%DR% -dPlatform=%PL%
+light  vcruntime.wixobj
+
+echo Done!
+goto done
+
+:usage
+
+echo. Usage: MakeVCRuntimeMSI.cmd {debug/retail} {x86/x64}
+
+:done
index 50228f3..f0a9340 100644 (file)
@@ -37,11 +37,28 @@ $(EXEDIR)\AdminGroup.exe: $(OUT)\AdminGroup.obj $(OUT)\AdminGroup.res
       $(EXECONLINK) 
         $(_VC_MANIFEST_EMBED_EXE)
 
+!IF ("$(AFSDEV_BUILDTYPE)"=="FREE")
+!IF ("$(CPU)" == "i386")
+ARCH=x86
+!ELSE IF ("$(CPU)" == "amd64")
+ARCH=x64
+!ELSE
+ARCH=$(CPU)
+!ENDIF
+!ELSE
+!IF ("$(CPU)" == "i386")
+ARCH=Intel
+!ELSE IF ("$(CPU)" == "amd64")
+ARCH=x64
+!ELSE
+ARCH=$(CPU)
+!ENDIF
+!ENDIF
+
 prebuild:
 !IF ("$(AFSDEV_BUILDTYPE)" == "FREE")
 !IF ("$(AFSVER_CL)"=="1400")
-   $(COPY) %SystemRoot%\System32\Msvcr80.dll $(EXEDIR)
-   $(COPY) %SystemRoot%\System32\MFC80.DLL $(EXEDIR)
+   $(COPY) "%VSINSTALLDIR%\SDK\v2.0\BootStrapper\Packages\vcredist_$(ARCH)\vcredist_$(ARCH).exe" $(EXEDIR)
 !ELSE IF ("$(AFSVER_CL)"=="1310")
    $(COPY) %SystemRoot%\System32\Msvcr71.dll $(EXEDIR)
    $(COPY) %SystemRoot%\System32\MFC71.DLL $(EXEDIR)
@@ -57,10 +74,7 @@ prebuild:
 !ENDIF
 !ELSE # NOT FREE - CHECKED
 !IF ("$(AFSVER_CL)"=="1400")
-   $(COPY) %SystemRoot%\System32\Msvcr80d.dll $(EXEDIR)
-   $(COPY) %SystemRoot%\System32\Msvcr80d.pdb $(EXEDIR)
-   $(COPY) %SystemRoot%\System32\MFC80D.DLL $(EXEDIR)
-   $(COPY) %SystemRoot%\System32\MFC80D.pdb $(EXEDIR)
+# Do nothing.
 !ELSE IF ("$(AFSVER_CL)"=="1310")
    $(COPY) %SystemRoot%\System32\Msvcr71d.dll $(EXEDIR)
    $(COPY) %SystemRoot%\System32\Msvcr71d.pdb $(EXEDIR)
@@ -93,6 +107,7 @@ prebuild:
    echo. >>$(OUT)\nsi-includes.nsi                                       
 !if ("$(AFSVER_CL)" == "1400")
    echo !define CL_1400 1 >> $(OUT)\nsi-includes.nsi
+   echo !define VCREDISTNAME vcredist_$(ARCH).exe >> $(OUT)\nsi-includes.nsi
 !else if ("$(AFSVER_CL)" == "1310")
    echo !define CL_1310 1 >> $(OUT)\nsi-includes.nsi
 !else if ("$(AFSVER_CL)" == "1300")
@@ -105,10 +120,25 @@ prebuild:
    echo !define DEBUG 1 >>$(OUT)\nsi-includes.nsi
 !endif
 
+!if ("$(AFSVER_CL)"=="1400") && ("$(AFSDEV_BUILDTYPE)"!="FREE")
+MSVCMSI=$(EXEDIR)\vcruntime.msi
+
+$(MSVCMSI): $(OUT)\vcruntime.wixobj
+       light -out $@ $**
+
+$(OUT)\vcruntime.wixobj: vcruntime.wxs
+       candle -out $@ $** -dPlatform=$(ARCH) -dConfig=Debug
+
+!else
+MSVCMSI=
+!endif
+
+runtime: $(MSVCMSI)
+
 build: prebuild
    "$(NSISDIR)\makensis.exe" /DINCLUDEDIR=$(OUT) OpenAFS.nsi
 
-install: $(OUT)\Service.obj $(EXEDIR)\Service.exe $(OUT)\Killer.obj $(EXEDIR)\Killer.exe $(EXEDIR)\AdminGroup.exe build
+install: $(OUT)\Service.obj $(EXEDIR)\Service.exe $(OUT)\Killer.obj $(EXEDIR)\Killer.exe $(EXEDIR)\AdminGroup.exe runtime build
 
 clean::
    $(DEL) $(OUT)\Service.obj
@@ -125,4 +155,7 @@ clean::
 #   $(DEL) $(EXEDIR)\Msvcr71.dll
 #   $(DEL) $(EXEDIR)\MFC42.DLL
 #   $(DEL) OpenAFSforWindows.exe
-
+!if ("$(AFSVER_CL)"=="1400") && ("$(AFSDEV_BUILDTYPE)"!="FREE")
+   $(DEL) $(OUT)\vcruntime.wixobj
+   $(DEL) $(MSVCMSI)
+!endif
index 95942c8..310a0ce 100644 (file)
@@ -1223,9 +1223,7 @@ DoControl:
 DoCommon:
   SetOutPath "$INSTDIR\Common"
 !IFDEF CL_1400
-   File "${SYSTEMDIR}\msvcr80d.pdb"
-   File "${SYSTEMDIR}\msvcp80d.pdb"
-   File "${SYSTEMDIR}\mfc80d.pdb"
+  ; Do nothing
 !ELSE
 !IFDEF CL_1310
    File "${SYSTEMDIR}\msvcr71d.pdb"
@@ -1705,12 +1703,10 @@ StartRemove:
    Delete /REBOOTOK "$INSTDIR\Common\afsptsadmin.pdb"
 !IFDEF DEBUG
 !IFDEF CL_1400
-   Delete /REBOOTOK "$INSTDIR\bin\msvcr80d.dll"
-   Delete /REBOOTOK "$INSTDIR\bin\msvcr80d.pdb"
-   Delete /REBOOTOK "$INSTDIR\bin\msvcp80d.dll"
-   Delete /REBOOTOK "$INSTDIR\bin\msvcp80d.pdb"
-   Delete /REBOOTOK "$INSTDIR\bin\mfc80d.dll"
-   Delete /REBOOTOK "$INSTDIR\bin\mfc80d.pdb"
+   SetOutPath "$INSTDIR\bin"
+   File "${AFS_WININSTALL_DIR}\vcruntime.msi"
+   nsExec::Exec 'msiexec /x "$INSTDIR\bin\vcruntime.msi" /passive'
+   Delete "$INSTDIR\bin\vcruntime.msi"
 !ELSE
 !IFDEF CL_1310
    Delete /REBOOTOK "$INSTDIR\bin\msvcr71d.dll"
@@ -1739,18 +1735,7 @@ StartRemove:
 !ENDIF
 !ELSE
 !IFDEF CL_1400
-   Delete /REBOOTOK "$INSTDIR\bin\mfc80.dll"
-   Delete /REBOOTOK "$INSTDIR\bin\msvcr80.dll"
-   Delete /REBOOTOK "$INSTDIR\bin\msvcp80.dll"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80CHS.DLL"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80CHT.DLL"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80DEU.DLL"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80ENU.DLL"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80ESP.DLL"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80FRA.DLL"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80ITA.DLL"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80JPN.DLL"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80KOR.DLL"
+   ; Do nothing
 !ELSE
 !IFDEF CL_1310
    Delete /REBOOTOK "$INSTDIR\bin\mfc71.dll"
@@ -1895,12 +1880,7 @@ StartRemove:
 
 !IFDEF DEBUG  
 !IFDEF CL_1400
-   Delete /REBOOTOK "$INSTDIR\bin\msvcr80d.dll"
-   Delete /REBOOTOK "$INSTDIR\bin\msvcr80d.pdb"
-   Delete /REBOOTOK "$INSTDIR\bin\msvcp80d.dll"
-   Delete /REBOOTOK "$INSTDIR\bin\msvcp80d.pdb"
-   Delete /REBOOTOK "$INSTDIR\bin\mfc80d.dll"
-   Delete /REBOOTOK "$INSTDIR\bin\mfc80d.pdb"
+   ; Do nothing
 !ELSE
 !IFDEF CL_1310
    Delete /REBOOTOK "$INSTDIR\bin\msvcr71d.dll"
@@ -1929,18 +1909,7 @@ StartRemove:
 !ENDIF
 !ELSE
 !IFDEF CL_1400
-   Delete /REBOOTOK "$INSTDIR\bin\mfc80.dll"
-   Delete /REBOOTOK "$INSTDIR\bin\msvcr80.dll"
-   Delete /REBOOTOK "$INSTDIR\bin\msvcp80.dll"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80CHS.DLL"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80CHT.DLL"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80DEU.DLL"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80ENU.DLL"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80ESP.DLL"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80FRA.DLL"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80ITA.DLL"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80JPN.DLL"
-   Delete /REBOOTOK "$INSTDIR\bin\MFC80KOR.DLL"
+   ; Do nothing
 !ELSE
 !IFDEF CL_1310
    Delete /REBOOTOK "$INSTDIR\bin\mfc71.dll"
@@ -2765,18 +2734,9 @@ Function AFSLangFiles
 
 !IFDEF DEBUG
 !IFDEF CL_1400
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcr80d.dll" "$INSTDIR\Common\msvcr80d.dll" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp80d.dll" "$INSTDIR\Common\msvcp80d.dll" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc80d.dll" "$INSTDIR\Common\mfc80d.dll" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80CHS.DLL" "$INSTDIR\Common\MFC80CHS.DLL" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80CHT.DLL" "$INSTDIR\Common\MFC80CHT.DLL" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80DEU.DLL" "$INSTDIR\Common\MFC80DEU.DLL" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80ENU.DLL" "$INSTDIR\Common\MFC80ENU.DLL" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80ESP.DLL" "$INSTDIR\Common\MFC80ESP.DLL" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80FRA.DLL" "$INSTDIR\Common\MFC80FRA.DLL" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80ITA.DLL" "$INSTDIR\Common\MFC80ITA.DLL" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80JPN.DLL" "$INSTDIR\Common\MFC80JPN.DLL" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80KOR.DLL" "$INSTDIR\Common\MFC80KOR.DLL" "$INSTDIR"
+   File "${AFS_WININSTALL_DIR}\vcruntime.msi"
+   nsExec::Exec 'msiexec /i "$INSTDIR\Common\vcruntime.msi" /passive'
+   Delete "$INSTDIR\Common\vcruntime.msi"
 !ELSE
 !IFDEF CL_1310
    !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcr71d.dll" "$INSTDIR\Common\msvcr71d.dll" "$INSTDIR"
@@ -2814,18 +2774,9 @@ Function AFSLangFiles
 !ENDIF
 !ELSE
 !IFDEF CL_1400
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc80.dll" "$INSTDIR\Common\mfc80.dll" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcr80.dll" "$INSTDIR\Common\msvcr80.dll" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp80.dll" "$INSTDIR\Common\msvcp80.dll" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80CHS.DLL" "$INSTDIR\Common\MFC80CHS.DLL" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80CHT.DLL" "$INSTDIR\Common\MFC80CHT.DLL" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80DEU.DLL" "$INSTDIR\Common\MFC80DEU.DLL" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80ENU.DLL" "$INSTDIR\Common\MFC80ENU.DLL" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80ESP.DLL" "$INSTDIR\Common\MFC80ESP.DLL" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80FRA.DLL" "$INSTDIR\Common\MFC80FRA.DLL" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80ITA.DLL" "$INSTDIR\Common\MFC80ITA.DLL" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80JPN.DLL" "$INSTDIR\Common\MFC80JPN.DLL" "$INSTDIR"
-   !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC80KOR.DLL" "$INSTDIR\Common\MFC80KOR.DLL" "$INSTDIR"
+  File "${AFS_WININSTALL_DIR}\${VCREDISTNAME}"
+  nsExec::Exec '"$INSTDIR\Common\${VCREDISTNAME}" /Q'
+  Delete "$INSTDIR\Common\${VCREDISTNAME}"
 !ELSE
 !IFDEF CL_1310
    !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc71.dll" "$INSTDIR\Common\mfc71.dll" "$INSTDIR"
diff --git a/src/WINNT/install/NSIS/vcruntime.wxs b/src/WINNT/install/NSIS/vcruntime.wxs
new file mode 100644 (file)
index 0000000..1d0f000
--- /dev/null
@@ -0,0 +1,89 @@
+<?xml version="1.0" ?>
+<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>
+
+  <?ifndef Config?>
+    <?define Config=Debug?>
+  <?endif?>
+
+    <Product
+       Id="????????-????-????-????-????????????"
+       Codepage="1252"
+       Language="1033"
+       Manufacturer="Microsoft Corporation"
+       Name="Visual C++ 8.0 $(var.Config) ($(var.Platform)) Runtime"
+       UpgradeCode="1184DE9F-813A-4DB3-8533-BB7D4E51D695"
+       Version="0.1.0.0"
+       >
+      <Package
+         Id="????????-????-????-????-????????????"
+         AdminImage="no"
+         Comments="Copyright (C) Microsoft Corporation, All rights reserved."
+         Compressed="yes"
+         Description="Visual C++ 8.0 $(var.Config) ($(var.Platform)) WinSXS MSM"
+         InstallerVersion="300"
+         Keywords="Installer,VC,$(var.Config),Runtime"
+         Manufacturer="Microsoft Corporation"
+         Platforms="$(var.Platform)"
+         ShortNames="no"
+         SummaryCodepage="1252"
+         />
+
+      <Directory Id="TARGETDIR" Name="SourceDir">
+       <?ifdef env.CommonProgramFiles6432?>
+         <?define CPF="$(env.CommonProgramFiles(x86)"?>
+       <?else?>
+         <?define CPF="$(env.CommonProgramFiles)"?>
+       <?endif?>
+
+       <?if $(var.Platform) = "x64" ?>
+         <?if $(var.Config) = "Retail" ?>
+           <Merge Id="MSVCRT8MEM" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_VC80_CRT_x86_x64.msm"/>
+           <Merge Id="MSVCRT8POL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_8_0_Microsoft_VC80_CRT_x86_x64.msm"/>
+           <Merge Id="MSVCRT8MFC" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_VC80_MFC_x86_x64.msm"/>
+           <Merge Id="MSVCRT8PFC" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_8_0_Microsoft_VC80_MFC_x86_x64.msm"/>
+           <Merge Id="MSVCRT8MFL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_VC80_MFCLOC_x86_x64.msm"/>
+           <Merge Id="MSVCRT8PFL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_8_0_Microsoft_VC80_MFCLOC_x86_x64.msm"/>
+         <?else?>
+           <Merge Id="MSVCRT8MEM" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_VC80_DebugCRT_x86_x64.msm"/>
+           <Merge Id="MSVCRT8POL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_8_0_Microsoft_VC80_DebugCRT_x86_x64.msm"/>
+           <Merge Id="MSVCRT8MFC" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_VC80_DebugMFC_x86_x64.msm"/>
+           <Merge Id="MSVCRT8PFC" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_8_0_Microsoft_VC80_DebugMFC_x86_x64.msm"/>
+           <Merge Id="MSVCRT8MFL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_VC80_MFCLOC_x86_x64.msm"/>
+           <Merge Id="MSVCRT8PFL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_8_0_Microsoft_VC80_MFCLOC_x86_x64.msm"/>
+         <?endif?>
+        <?else?>
+         <?if $(var.Config) = "Retail" ?>
+           <Merge Id="MSVCRT8MEM" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_VC80_CRT_x86.msm"/>
+           <Merge Id="MSVCRT8POL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_8_0_Microsoft_VC80_CRT_x86.msm"/>
+           <Merge Id="MSVCRT8MFC" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_VC80_MFC_x86.msm"/>
+           <Merge Id="MSVCRT8PFC" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_8_0_Microsoft_VC80_MFC_x86.msm"/>
+           <Merge Id="MSVCRT8MFL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_VC80_MFCLOC_x86.msm"/>
+           <Merge Id="MSVCRT8PFL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_8_0_Microsoft_VC80_MFCLOC_x86.msm"/>
+         <?else?>
+           <Merge Id="MSVCRT8MEM" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_VC80_DebugCRT_x86.msm"/>
+           <Merge Id="MSVCRT8POL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_8_0_Microsoft_VC80_DebugCRT_x86.msm"/>
+           <Merge Id="MSVCRT8MFC" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_VC80_DebugMFC_x86.msm"/>
+           <Merge Id="MSVCRT8PFC" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_8_0_Microsoft_VC80_DebugMFC_x86.msm"/>
+           <Merge Id="MSVCRT8MFL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_VC80_MFCLOC_x86.msm"/>
+           <Merge Id="MSVCRT8PFL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_8_0_Microsoft_VC80_MFCLOC_x86.msm"/>
+         <?endif?>
+       <?endif?>
+      </Directory>
+
+      <Feature Id="FeatureAll" AllowAdvertise="no" Absent="disallow"
+               Description="Install VC ++ 8.0 Runtime" Display="expand" InstallDefault="local" Level="3"
+               Title="All">
+       <MergeRef Id="MSVCRT8MEM"/>
+       <MergeRef Id="MSVCRT8POL"/>
+       <MergeRef Id="MSVCRT8MFC"/>
+       <MergeRef Id="MSVCRT8PFC"/>
+       <MergeRef Id="MSVCRT8MFL"/>
+       <MergeRef Id="MSVCRT8PFL"/>
+      </Feature>  
+
+      <Media Id="1" Cabinet="disk1.cab" CompressionLevel="high" EmbedCab="yes" />
+
+      <Property Id="INSTALLLEVEL" Value="3" />
+
+    </Product>
+</Wix>