Fix registry keys for VC runtime
[yaz-moved-to-github.git] / win / yaz.nsi
1 ; This file is part of the YAZ toolkit.
2 ; Copyright (C) Index Data
3 ; See the file LICENSE for details.
4
5 !include EnvVarUpdate.nsh
6 !include version.nsi
7
8 !include "MUI.nsh"
9
10 !define VS_REDIST_FULL "c:\Program Files (x86)\Microsoft Visual Studio ${VSVER}.0\VC\redist\1033\${VS_REDIST_EXE}"
11
12 ; For example can be found with regedit:
13 ;  Microsoft Visual C++ 2013 x86 Minimum Runtime
14 !if "${VSARCH}" = "x64"
15 ; 64-bit
16 !if "${VSVER}" = "12"
17 !define VS_REDIST_KEY "SOFTWARE\Classes\Installer\Products\6E8D947A316B3EB3F8F540C548BE2AB9"
18 !endif
19 !if "${VSVER}" = "14"
20 ; Microsoft Visual C++ 2015 x64 Minimum Runtime - 14.0.23026
21 !define VS_REDIST_KEY "SOFTWARE\Classes\Installer\Products\51E9E3D0A7EDB003691F4BFA219B4688"
22 !endif
23
24 InstallDir "$PROGRAMFILES64\YAZ"
25 !else
26 ; 32-bit
27 !if "${VSVER}" = "12"
28 !define VS_REDIST_KEY "SOFTWARE\Classes\Installer\Products\21EE4A31AE32173319EEFE3BD6FDFFE3"
29 !endif
30 !if "${VSVER}" = "14"
31 ; Microsoft Visual C++ 2015 x86 Minimum Runtime - 14.0.23026
32 !define VS_REDIST_KEY "SOFTWARE\Classes\Installer\Products\55E3652ACEB38283D8765E8E9B8E6B57"
33 !endif
34
35 !if "${VSVER}" = "14"
36 !define VS_REDIST_EXE vc_redist.${VSARCH}.exe
37 !else
38 !define VS_REDIST_EXE vcredist_${VSARCH}.exe
39 !endif
40
41
42 InstallDir "$PROGRAMFILES\YAZ"
43 !endif
44
45
46 RequestExecutionLevel admin
47
48 SetCompressor bzip2
49
50 Name "YAZ"
51 Caption "Index Data YAZ ${VERSION} Setup"
52 OutFile "yaz_${VERSION}.exe"
53
54 LicenseText "You must read the following license before installing:"
55 LicenseData license.txt
56
57 ComponentText "This will install the YAZ Toolkit on your computer:"
58 InstType "Full (w/ Source)"
59 InstType "Lite (w/o Source)"
60
61 InstallDirRegKey HKLM "SOFTWARE\Index Data\YAZ" ""
62
63
64 ;----------------------------
65 ; Pages
66
67
68   !insertmacro MUI_PAGE_LICENSE "license.txt"
69   !insertmacro MUI_PAGE_COMPONENTS
70   !insertmacro MUI_PAGE_DIRECTORY
71   !insertmacro MUI_PAGE_INSTFILES
72   
73   !insertmacro MUI_UNPAGE_CONFIRM
74   !insertmacro MUI_UNPAGE_INSTFILES
75 ; Page components
76 ; Page directory
77 ; Page instfiles
78
79 ; UninstPage uninstConfirm
80 ; UninstPage instfiles
81
82 ;--------------------------------
83 ;Languages
84  
85 !insertmacro MUI_LANGUAGE "English"
86
87 ;--------------------------------
88
89 Section "" ; (default section)
90         SetOutPath "$INSTDIR"
91         ; add files / whatever that need to be installed here.
92         WriteRegStr HKLM "SOFTWARE\Index Data\YAZ" "" "$INSTDIR"
93         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YAZ" "DisplayName" "YAZ ${VERSION} (remove only)"
94         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YAZ" "UninstallString" '"$INSTDIR\uninst.exe"'
95         ; write out uninstaller
96         WriteUninstaller "$INSTDIR\uninst.exe"
97         SetOutPath $SMPROGRAMS\YAZ
98         CreateShortCut "$SMPROGRAMS\YAZ\YAZ Program Directory.lnk" \
99                  "$INSTDIR"
100         WriteINIStr "$SMPROGRAMS\YAZ\YAZ Home page.url" \
101               "InternetShortcut" "URL" "http://www.indexdata.com/yaz/"
102         CreateShortCut "$SMPROGRAMS\YAZ\Uninstall YAZ.lnk" \
103                 "$INSTDIR\uninst.exe"
104         SetOutPath $INSTDIR
105         File LICENSE.txt
106         File ..\README
107         File ..\NEWS
108         SetOutPath $INSTDIR
109         SetOutPath $INSTDIR\ztest
110         File ..\ztest\dummy-grs
111         File ..\ztest\dummy-words
112         SetOutPath $INSTDIR\etc
113         File ..\etc\*.xml
114         File ..\etc\*.xsl
115         File ..\etc\pqf.properties
116
117 SectionEnd ; end of default section
118
119 Section "YAZ Runtime" YAZ_Runtime
120         SectionIn 1 2
121         SetOutPath $INSTDIR\bin
122 !if "${VS_REDIST_FULL}" != ""
123         File "${VS_REDIST_FULL}"
124         ReadRegDword $1 HKLM "${VS_REDIST_KEY}" "Version"
125         ${If} $1 == ""
126           ExecWait '"$INSTDIR\bin\${VS_REDIST_EXE}" /passive /nostart'
127         ${endif}
128         Delete "$INSTDIR\bin\${VS_REDIST_EXE}"
129 !endif
130         IfFileExists "$INSTDIR\bin\yaz-ztest.exe" 0 Noservice
131         ExecWait '"$INSTDIR\bin\yaz-ztest.exe" -remove'
132 Noservice:
133         File ..\bin\*.dll
134         File ..\bin\*.exe
135         SetOutPath $SMPROGRAMS\YAZ
136         CreateShortCut "$SMPROGRAMS\YAZ\YAZ Client.lnk" \
137                  "$INSTDIR\bin\yaz-client.exe"
138         SetOutPath $SMPROGRAMS\YAZ\Server
139         CreateShortCut "$SMPROGRAMS\YAZ\Server\Server on console on port 9999.lnk" \
140                  "$INSTDIR\bin\yaz-ztest.exe" '-w"$INSTDIR\ztest"'
141         CreateShortCut "$SMPROGRAMS\YAZ\Server\Install Z39.50 service on port 210.lnk" \
142                   "$INSTDIR\bin\yaz-ztest.exe" '-installa tcp:@:210'
143         CreateShortCut "$SMPROGRAMS\YAZ\Server\Remove Z39.50 service.lnk" \
144                  "$INSTDIR\bin\yaz-ztest.exe" '-remove'
145 SectionEnd
146
147 Section "YAZ Development" YAZ_Development
148         SectionIn 1 2
149         SetOutPath $INSTDIR\include\yaz
150         File ..\include\yaz\*.h
151         SetOutPath $INSTDIR\lib
152         File ..\lib\yaz*.lib
153 SectionEnd
154
155 Section "YAZ Documentation" YAZ_Documentation
156         SectionIn 1 2
157         SetOutPath $INSTDIR\doc
158         File /nonfatal /r ..\doc\*.css
159         File /nonfatal /r ..\doc\*.ent
160         File /nonfatal /r ..\doc\*.html
161         File /r ..\doc\*.xml
162         File /r ..\doc\*.png
163         File /nonfatal /r ..\doc\*.xsl
164         SetOutPath $SMPROGRAMS\YAZ
165         CreateShortCut "$SMPROGRAMS\YAZ\HTML Documentation.lnk" \
166                  "$INSTDIR\doc\index.html"
167 SectionEnd
168
169 Section "YAZ Source" YAZ_Source
170         SectionIn 1
171         SetOutPath $INSTDIR
172         File ..\IDMETA
173         File /r ..\*.c
174         File /r /x yaz ..\*.h
175         SetOutPath $INSTDIR\util
176         File ..\util\yaz-asncomp
177         SetOutPath $INSTDIR\src
178         File ..\src\*.y
179         File ..\src\*.tcl
180         File ..\src\*.csv
181         File ..\src\*.asn
182         File ..\src\codetables*.xml
183         SetOutPath $INSTDIR\test
184         File ..\test\marc*.*
185         File ..\test\*.sh
186         File ..\test\*.xml
187         File ..\test\*.asn
188         SetOutPath $INSTDIR\win
189         File makefile
190         File *.nsi
191         File *.rc
192 SectionEnd
193
194 Section "YAZ4J" YAZ4J
195         SectionIn 1 2
196         SetOutPath $INSTDIR\bin
197         File /nonfatal ..\bin\yaz4j.dll
198         SetOutPath $INSTDIR\java
199         File /nonfatal ..\java\yaz4j.jar
200 SectionEnd
201
202 Section "YAZ Path" YAZ_PATH
203         SectionIn 1 2
204         ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\bin"
205 SectionEnd
206
207 ; begin uninstall settings/section
208 UninstallText "This will uninstall YAZ ${VERSION} from your system"
209
210 Section Uninstall
211         ExecWait '"$INSTDIR\bin\yaz-ztest" -remove'
212         RMDir /r $SMPROGRAMS\YAZ
213         Delete "$INSTDIR\uninst.exe"
214         DeleteRegKey HKLM "SOFTWARE\Index Data\YAZ"
215         DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\YAZ"
216         RMDir /r $INSTDIR
217         ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\bin"
218         IfFileExists $INSTDIR 0 Removed 
219                 MessageBox MB_OK|MB_ICONEXCLAMATION \
220                  "Note: $INSTDIR could not be removed."
221 Removed:
222 SectionEnd
223
224 ;--------------------------------
225 ;Descriptions
226
227   ;Language strings
228 LangString DESC_YAZ_Runtime ${LANG_ENGLISH} "YAZ runtime files needed in order for YAZ to run, such as DLLs."
229 LangString DESC_YAZ_Development ${LANG_ENGLISH} "Header files and import libraries required for developing software using YAZ."
230 LangString DESC_YAZ_Documentation ${LANG_ENGLISH} "YAZ Users' guide and reference in HTML. Describes both YAZ applications and the API."
231 LangString DESC_YAZ_Source ${LANG_ENGLISH} "Source code of YAZ. Required if you need to rebuild YAZ (for debugging purposes)."
232 LangString DESC_YAZ4J ${LANG_ENGLISH} "Java wrapper for the ZOOM API of YAZ."
233 LangString DESC_YAZ_PATH ${LANG_ENGLISH} "Update PATH to include binaries of YAZ."
234
235 ;Assign language strings to sections
236 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
237 !insertmacro MUI_DESCRIPTION_TEXT ${YAZ_Runtime} $(DESC_YAZ_Runtime)
238 !insertmacro MUI_DESCRIPTION_TEXT ${YAZ_Development} $(DESC_YAZ_Development)
239 !insertmacro MUI_DESCRIPTION_TEXT ${YAZ_Documentation} $(DESC_YAZ_Documentation)
240 !insertmacro MUI_DESCRIPTION_TEXT ${YAZ_Source} $(DESC_YAZ_Source)
241 !insertmacro MUI_DESCRIPTION_TEXT ${YAZ4J} $(DESC_YAZ4J)
242 !insertmacro MUI_DESCRIPTION_TEXT ${YAZ_PATH} $(DESC_YAZ_PATH)
243 !insertmacro MUI_FUNCTION_DESCRIPTION_END
244
245 ; eof