macho: Improve macho_calculate_sizes
[nasm.git] / nsis / nasm.nsi
bloba021bd55431cd54c26478feaf50b3e1f84ad9e05
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 !addincludedir "${objdir}/nsis"
30 !addincludedir "${srcdir}/nsis"
31 !include "version.nsh"
32 !include /nonfatal "arch.nsh"
33 !include /nonfatal "x64.nsh"
35 !define PRODUCT_NAME "Netwide Assembler"
36 !define PRODUCT_SHORT_NAME "nasm"
37 !define PACKAGE_NAME "${PRODUCT_NAME} ${VERSION}"
38 !define PACKAGE_SHORT_NAME "${PRODUCT_SHORT_NAME}-${VERSION}"
40 SetCompressor lzma
42 !define MULTIUSER_EXECUTIONLEVEL Highest
43 !define MULTIUSER_MUI
44 !define MULTIUSER_INSTALLMODE_COMMANDLINE
45 !define MULTIUSER_INSTALLMODE_INSTDIR "NASM"
46 !include "MultiUser.nsh"
48 !insertmacro MULTIUSER_PAGE_INSTALLMODE
49 !insertmacro MULTIUSER_INSTALLMODEPAGE_INTERFACE
51 ;--------------------------------
52 ;General
54 ;Name and file
55 Name "${PACKAGE_NAME}"
56 OutFile "${objdir}/${PACKAGE_SHORT_NAME}-installer-${ARCH}.exe"
58 ;Get installation folder from registry if available
59 InstallDirRegKey HKCU "Software\${PRODUCT_SHORT_NAME}" ""
61 ;Request application privileges for Windows Vista
62 RequestExecutionLevel user
64 ;--------------------------------
65 ;Variables
67 Var StartMenuFolder
68 Var CmdFailed
70 ;--------------------------------
71 ;Interface Settings
72 Caption "${PACKAGE_SHORT_NAME} installation"
73 Icon "${srcdir}/nsis/nasm.ico"
74 UninstallIcon "${srcdir}/nsis/nasm-un.ico"
76 !define MUI_ABORTWARNING
78 ;--------------------------------
79 ;Pages
81 !insertmacro MUI_PAGE_COMPONENTS
82 !insertmacro MUI_PAGE_DIRECTORY
84 ;Start Menu Folder Page Configuration
85 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
86 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${PRODUCT_SHORT_NAME}"
87 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_SHORT_NAME}"
89 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
91 !insertmacro MUI_PAGE_INSTFILES
93 !insertmacro MUI_UNPAGE_CONFIRM
94 !insertmacro MUI_UNPAGE_INSTFILES
96 ;--------------------------------
97 ;Installer Sections
99 !insertmacro MUI_LANGUAGE English
101 Section "NASM" SecNasm
102 Sectionin RO
103 SetOutPath "$INSTDIR"
104 File "${srcdir}/LICENSE"
105 File "${objdir}/nasm.exe"
106 File "${objdir}/ndisasm.exe"
107 File "${srcdir}/nsis/nasm.ico"
109 ;Store installation folder
110 WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}" "" $INSTDIR
112 ;Store shortcuts folder
113 WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}\" "lnk" $SMPROGRAMS\$StartMenuFolder
114 WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}\" "bat-lnk" $DESKTOP\${PRODUCT_SHORT_NAME}.lnk
117 ; the bat we need
118 StrCpy $CmdFailed "true"
119 FileOpen $0 "nasmpath.bat" w
120 IfErrors skip
121 StrCpy $CmdFailed "false"
122 FileWrite $0 "@set path=$INSTDIR;%path%$\r$\n"
123 FileWrite $0 "@%comspec%"
124 FileClose $0
125 CreateShortCut "$DESKTOP\${PRODUCT_SHORT_NAME}.lnk" "$INSTDIR\nasmpath.bat" "" "$INSTDIR\nasm.ico" 0
126 skip:
127 ;Create uninstaller
128 WriteUninstaller "$INSTDIR\Uninstall.exe"
130 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
132 ;Create shortcuts
133 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
134 StrCmp $CmdFailed "true" +2
135 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${PRODUCT_SHORT_NAME}-shell.lnk" "$INSTDIR\nasmpath.bat"
136 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${PRODUCT_SHORT_NAME}.lnk" "$INSTDIR\nasm.exe" "" "$INSTDIR\nasm.ico" 0
137 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
139 !insertmacro MUI_STARTMENU_WRITE_END
140 SectionEnd
142 Section "RDOFF" SecRdoff
143 File "${objdir}/rdoff/ldrdf.exe"
144 File "${objdir}/rdoff/rdf2bin.exe"
145 File "${objdir}/rdoff/rdf2com.exe"
146 File "${objdir}/rdoff/rdf2ith.exe"
147 File "${objdir}/rdoff/rdf2ihx.exe"
148 File "${objdir}/rdoff/rdf2srec.exe"
149 File "${objdir}/rdoff/rdfdump.exe"
150 File "${objdir}/rdoff/rdflib.exe"
151 SectionEnd
153 Section "Manual" SecManual
154 SetOutPath "$INSTDIR"
155 File "${objdir}/doc/nasmdoc.pdf"
156 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Manual.lnk" "$INSTDIR\nasmdoc.pdf"
157 SectionEnd
159 Section "VS8 integration" SecVS8
160 CreateDirectory "$INSTDIR\VSrules"
161 SetOutPath "$INSTDIR\VSrules"
162 File "${srcdir}/contrib/VSrules/nasm.README"
163 File "${srcdir}/contrib/VSrules/nasm.rules"
164 SectionEnd
166 ;--------------------------------
167 ;Descriptions
169 ;Language strings
170 LangString DESC_SecNasm ${LANG_ENGLISH} "NASM assembler and disassember modules"
171 LangString DESC_SecManual ${LANG_ENGLISH} "Complete NASM manual (pdf file)"
172 LangString DESC_SecRdoff ${LANG_ENGLISH} "RDOFF utilities (you may not need it if you don't know what is it)"
173 LangString DESC_SecVS8 ${LANG_ENGLISH} "Visual Studio 2008 NASM integration (rules file)"
175 ;Assign language strings to sections
176 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
177 !insertmacro MUI_DESCRIPTION_TEXT ${SecNasm} $(DESC_SecNasm)
178 !insertmacro MUI_DESCRIPTION_TEXT ${SecRdoff} $(DESC_SecRdoff)
179 !insertmacro MUI_DESCRIPTION_TEXT ${SecManual} $(DESC_SecManual)
180 !insertmacro MUI_DESCRIPTION_TEXT ${SecVS8} $(DESC_SecVS8)
181 !insertmacro MUI_FUNCTION_DESCRIPTION_END
183 ;--------------------------------
184 ;Uninstaller Section
186 Section "Uninstall"
188 ; files on HDD
189 IfFileExists "$INSTDIR" +3 +1
190 MessageBox MB_OK "No files found, aborting."
191 Abort
192 MessageBox MB_YESNO "The following directory will be deleted$\n$INSTDIR" IDYES rm_instdir_true IDNO rm_instdir_false
193 rm_instdir_true:
194 RMDir /r /rebootok "$INSTDIR"
195 rm_instdir_false:
198 ; Desktop link
199 ReadRegStr $0 HKCU Software\${PRODUCT_SHORT_NAME} "bat-lnk"
200 StrCmp $0 0 +1 +3
201 MessageBox MB_OK "Invalid path to a bat-lnk file, aborting"
202 Abort
203 IfFileExists $0 +3 +1
204 MessageBox MB_OK "No bat-lnk files found, aborting."
205 Abort
206 MessageBox MB_YESNO "The following file will be deleted$\n$0" IDYES rm_batlinks_true IDNO rm_batlinks_false
207 rm_batlinks_true:
208 Delete /rebootok "$0"
209 RMDir "$0"
210 rm_batlinks_false:
213 ; Start menu folder
214 ReadRegStr $0 HKCU Software\${PRODUCT_SHORT_NAME} "lnk"
215 StrCmp $0 0 +1 +3
216 MessageBox MB_OK "Invalid path to a lnk file, aborting"
217 Abort
218 IfFileExists $0 +3 +1
219 MessageBox MB_OK "No lnk files found, aborting."
220 Abort
221 MessageBox MB_YESNO "The following directory will be deleted$\n$0" IDYES rm_links_true IDNO rm_links_false
222 rm_links_true:
223 Delete /rebootok "$0\*"
224 RMDir "$0"
225 rm_links_false:
226 DeleteRegKey /ifempty HKCU "Software\${PRODUCT_SHORT_NAME}"
227 SectionEnd
230 ; MUI requires this hooks
231 Function .onInit
232 !insertmacro MULTIUSER_INIT
233 ${If} ${RunningX64}
234 SetRegView 64
235 ${EnableX64FSRedirection}
236 StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCT_SHORT_NAME}"
237 ${Else}
238 StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCT_SHORT_NAME}"
239 ${EndIf}
240 FunctionEnd
242 Function un.onInit
243 !insertmacro MULTIUSER_UNINIT
244 FunctionEnd