Merge remote-tracking branch 'origin/nasm-2.12.xx'
[nasm.git] / nsis / nasm.nsi
blob424110325ec64d2bc1dde353ca777f9cd43aefc7
1 #!Nsis Installer Command Script
4 # Copyright (c) 2009, Shao Miller (shao.miller@yrdsb.edu.on.ca)
5 # Copyright (c) 2009, Cyrill Gorcunov (gorcunov@gmail.com)
6 # All rights reserved.
8 # The script requires NSIS v2.45 (or any later)
10 # Redistribution and use in source and binary forms, with or without
11 # modification, are permitted provided that the following conditions are met:
12 # * Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # * Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR
22 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 !include "version.nsh"
30 !include /nonfatal "arch.nsh"
32 !define PRODUCT_NAME "Netwide Assembler"
33 !define PRODUCT_SHORT_NAME "nasm"
34 !define PACKAGE_NAME "${PRODUCT_NAME} ${VERSION}"
35 !define PACKAGE_SHORT_NAME "${PRODUCT_SHORT_NAME}-${VERSION}"
37 SetCompressor lzma
39 !define MULTIUSER_EXECUTIONLEVEL Highest
40 !define MULTIUSER_MUI
41 !define MULTIUSER_INSTALLMODE_COMMANDLINE
42 !define MULTIUSER_INSTALLMODE_INSTDIR "NASM"
43 !include "MultiUser.nsh"
45 !insertmacro MULTIUSER_PAGE_INSTALLMODE
46 !insertmacro MULTIUSER_INSTALLMODEPAGE_INTERFACE
48 ;--------------------------------
49 ;General
51 ;Name and file
52 Name "${PACKAGE_NAME}"
53 OutFile "../${PACKAGE_SHORT_NAME}-installer-${ARCH}.exe"
55 ;Get installation folder from registry if available
56 InstallDirRegKey HKCU "Software\${PRODUCT_SHORT_NAME}" ""
58 ;Request application privileges for Windows Vista
59 RequestExecutionLevel user
61 ;--------------------------------
62 ;Variables
64 Var StartMenuFolder
65 Var CmdFailed
67 ;--------------------------------
68 ;Interface Settings
69 Caption "${PACKAGE_SHORT_NAME} installation"
70 Icon "nasm.ico"
71 UninstallIcon "nasm-un.ico"
73 !define MUI_ABORTWARNING
75 ;--------------------------------
76 ;Pages
78 !insertmacro MUI_PAGE_COMPONENTS
79 !insertmacro MUI_PAGE_DIRECTORY
81 ;Start Menu Folder Page Configuration
82 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
83 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${PRODUCT_SHORT_NAME}"
84 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_SHORT_NAME}"
86 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
88 !insertmacro MUI_PAGE_INSTFILES
90 !insertmacro MUI_UNPAGE_CONFIRM
91 !insertmacro MUI_UNPAGE_INSTFILES
93 ;--------------------------------
94 ;Installer Sections
96 !insertmacro MUI_LANGUAGE English
98 Section "NASM" SecNasm
99 Sectionin RO
100 SetOutPath "$INSTDIR"
101 File "../LICENSE"
102 File "../nasm.exe"
103 File "../ndisasm.exe"
104 File "nasm.ico"
106 ;Store installation folder
107 WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}" "" $INSTDIR
109 ;Store shortcuts folder
110 WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}\" "lnk" $SMPROGRAMS\$StartMenuFolder
111 WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}\" "bat-lnk" $DESKTOP\${PRODUCT_SHORT_NAME}.lnk
114 ; the bat we need
115 StrCpy $CmdFailed "true"
116 FileOpen $0 "nasmpath.bat" w
117 IfErrors skip
118 StrCpy $CmdFailed "false"
119 FileWrite $0 "@set path=$INSTDIR;%path%$\r$\n"
120 FileWrite $0 "@%comspec%"
121 FileClose $0
122 CreateShortCut "$DESKTOP\${PRODUCT_SHORT_NAME}.lnk" "$INSTDIR\nasmpath.bat" "" "$INSTDIR\nasm.ico" 0
123 skip:
124 ;Create uninstaller
125 WriteUninstaller "$INSTDIR\Uninstall.exe"
127 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
129 ;Create shortcuts
130 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
131 StrCmp $CmdFailed "true" +2
132 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${PRODUCT_SHORT_NAME}-shell.lnk" "$INSTDIR\nasmpath.bat"
133 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${PRODUCT_SHORT_NAME}.lnk" "$INSTDIR\nasm.exe" "" "$INSTDIR\nasm.ico" 0
134 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
136 !insertmacro MUI_STARTMENU_WRITE_END
137 SectionEnd
139 Section "RDOFF" SecRdoff
140 File "../rdoff/ldrdf.exe"
141 File "../rdoff/rdf2bin.exe"
142 File "../rdoff/rdf2com.exe"
143 File "../rdoff/rdf2ith.exe"
144 File "../rdoff/rdf2ihx.exe"
145 File "../rdoff/rdf2srec.exe"
146 File "../rdoff/rdfdump.exe"
147 File "../rdoff/rdflib.exe"
148 SectionEnd
150 Section "Manual" SecManual
151 SetOutPath "$INSTDIR"
152 File "../doc/nasmdoc.pdf"
153 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Manual.lnk" "$INSTDIR\nasmdoc.pdf"
154 SectionEnd
156 Section "VS8 integration" SecVS8
157 CreateDirectory "$INSTDIR\VSrules"
158 SetOutPath "$INSTDIR\VSrules"
159 File "../contrib/VSrules/nasm.README"
160 File "../contrib/VSrules/nasm.rules"
161 SectionEnd
163 ;--------------------------------
164 ;Descriptions
166 ;Language strings
167 LangString DESC_SecNasm ${LANG_ENGLISH} "NASM assembler and disassember modules"
168 LangString DESC_SecManual ${LANG_ENGLISH} "Complete NASM manual (pdf file)"
169 LangString DESC_SecRdoff ${LANG_ENGLISH} "RDOFF utilities (you may not need it if you don't know what is it)"
170 LangString DESC_SecVS8 ${LANG_ENGLISH} "Visual Studio 2008 NASM integration (rules file)"
172 ;Assign language strings to sections
173 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
174 !insertmacro MUI_DESCRIPTION_TEXT ${SecNasm} $(DESC_SecNasm)
175 !insertmacro MUI_DESCRIPTION_TEXT ${SecRdoff} $(DESC_SecRdoff)
176 !insertmacro MUI_DESCRIPTION_TEXT ${SecManual} $(DESC_SecManual)
177 !insertmacro MUI_DESCRIPTION_TEXT ${SecVS8} $(DESC_SecVS8)
178 !insertmacro MUI_FUNCTION_DESCRIPTION_END
180 ;--------------------------------
181 ;Uninstaller Section
183 Section "Uninstall"
185 ; files on HDD
186 IfFileExists "$INSTDIR" +3 +1
187 MessageBox MB_OK "No files found, aborting."
188 Abort
189 MessageBox MB_YESNO "The following directory will be deleted$\n$INSTDIR" IDYES rm_instdir_true IDNO rm_instdir_false
190 rm_instdir_true:
191 RMDir /r /rebootok "$INSTDIR"
192 rm_instdir_false:
195 ; Desktop link
196 ReadRegStr $0 HKCU Software\${PRODUCT_SHORT_NAME} "bat-lnk"
197 StrCmp $0 0 +1 +3
198 MessageBox MB_OK "Invalid path to a bat-lnk file, aborting"
199 Abort
200 IfFileExists $0 +3 +1
201 MessageBox MB_OK "No bat-lnk files found, aborting."
202 Abort
203 MessageBox MB_YESNO "The following file will be deleted$\n$0" IDYES rm_batlinks_true IDNO rm_batlinks_false
204 rm_batlinks_true:
205 Delete /rebootok "$0"
206 RMDir "$0"
207 rm_batlinks_false:
210 ; Start menu folder
211 ReadRegStr $0 HKCU Software\${PRODUCT_SHORT_NAME} "lnk"
212 StrCmp $0 0 +1 +3
213 MessageBox MB_OK "Invalid path to a lnk file, aborting"
214 Abort
215 IfFileExists $0 +3 +1
216 MessageBox MB_OK "No lnk files found, aborting."
217 Abort
218 MessageBox MB_YESNO "The following directory will be deleted$\n$0" IDYES rm_links_true IDNO rm_links_false
219 rm_links_true:
220 Delete /rebootok "$0\*"
221 RMDir "$0"
222 rm_links_false:
223 DeleteRegKey /ifempty HKCU "Software\${PRODUCT_SHORT_NAME}"
224 SectionEnd
227 ; MUI requires this hooks
228 Function .onInit
229 !insertmacro MULTIUSER_INIT
230 FunctionEnd
232 Function un.onInit
233 !insertmacro MULTIUSER_UNINIT
234 FunctionEnd