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