nsis2: prepare for substitution
[nasm.git] / nasm2.nsi
blob81eba661dd7b1c7e75d1e8a35023aec6cbbac25c
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 !define PRODUCT_NAME "Netwide Assembler"
31 !define PRODUCT_SHORT_NAME "nasm"
32 !define VERSION "${__NASM_VER__}"
33 !define PACKAGE_NAME "${PRODUCT_NAME} ${VERSION}"
34 !define PACKAGE_SHORT_NAME "${PRODUCT_SHORT_NAME}-${VERSION}"
36 !define MULTIUSER_EXECUTIONLEVEL Highest
37 !define MULTIUSER_MUI
38 !define MULTIUSER_INSTALLMODE_COMMANDLINE
39 !define MULTIUSER_INSTALLMODE_INSTDIR "${PRODUCT_SHORT_NAME}"
40 !include MultiUser.nsh
42 !insertmacro MULTIUSER_PAGE_INSTALLMODE
43 !insertmacro MULTIUSER_INSTALLMODEPAGE_INTERFACE
45 ;--------------------------------
46 ;General
48 ;Name and file
49 Name "${PACKAGE_NAME}"
50 OutFile "${PACKAGE_NAME}-installer.exe"
52 ;Get installation folder from registry if available
53 InstallDirRegKey HKCU "Software\${PRODUCT_SHORT_NAME}" ""
55 ;Request application privileges for Windows Vista
56 RequestExecutionLevel user
58 ;--------------------------------
59 ;Variables
61 Var StartMenuFolder
62 Var CmdFailed
64 ;--------------------------------
65 ;Interface Settings
66 Caption "${PACKAGE_SHORT_NAME} installation"
67 Icon "nsis/nasm.ico"
68 UninstallIcon "nsis/nasm-un.ico"
70 !define MUI_ABORTWARNING
72 ;--------------------------------
73 ;Pages
75 !insertmacro MUI_PAGE_COMPONENTS
76 !insertmacro MUI_PAGE_DIRECTORY
78 ;Start Menu Folder Page Configuration
79 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
80 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${PRODUCT_SHORT_NAME}"
81 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_SHORT_NAME}"
83 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
85 !insertmacro MUI_PAGE_INSTFILES
87 !insertmacro MUI_UNPAGE_CONFIRM
88 !insertmacro MUI_UNPAGE_INSTFILES
90 ;--------------------------------
91 ;Installer Sections
93 !insertmacro MUI_LANGUAGE English
95 Section "NASM" SecNasm
96 Sectionin RO
97 SetOutPath "$INSTDIR"
98 File "LICENSE"
99 File "nasm.exe"
100 File "ndisasm.exe"
101 File "nsis/nasm.ico"
103 ;Store installation folder
104 WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}" "" $INSTDIR
106 ;Store shortcuts folder
107 WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}\" "lnk" $SMPROGRAMS\$StartMenuFolder
110 ; the bat we need
111 StrCpy $CmdFailed "true"
112 FileOpen $0 "nasmpath.bat" w
113 IfErrors skip
114 StrCpy $CmdFailed "false"
115 FileWrite $0 "@set path=$INSTDIR;%path%$\r$\n"
116 FileWrite $0 "@%comspec%"
117 FileClose $0
118 CreateShortCut "$DESKTOP\${PRODUCT_SHORT_NAME}.lnk" "$INSTDIR\nasmpath.bat" "" "$INSTDIR\nasm.ico" 0
119 skip:
120 ;Create uninstaller
121 WriteUninstaller "$INSTDIR\Uninstall.exe"
123 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
125 ;Create shortcuts
126 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
127 StrCmp $CmdFailed "true" +2
128 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${PRODUCT_SHORT_NAME}-shell.lnk" "$INSTDIR\nasmpath.bat"
129 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${PRODUCT_SHORT_NAME}.lnk" "$INSTDIR\nasm.exe" "" "$INSTDIR\nasm.ico" 0
130 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
132 !insertmacro MUI_STARTMENU_WRITE_END
133 SectionEnd
135 Section "RDOFF" SecRdoff
136 CreateDirectory "$INSTDIR\rdoff"
137 SetOutPath "$INSTDIR\rdoff"
138 File "rdoff/ldrdf.exe"
139 File "rdoff/rdf2bin.exe"
140 File "rdoff/rdf2com.exe"
141 File "rdoff/rdf2ith.exe"
142 File "rdoff/rdf2ihx.exe"
143 File "rdoff/rdf2srec.exe"
144 File "rdoff/rdfdump.exe"
145 File "rdoff/rdflib.exe"
146 File "rdoff/rdx.exe"
147 SectionEnd
149 Section "Manual" SecManual
150 SetOutPath "$INSTDIR"
151 File "doc/nasmdoc.pdf"
152 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Manual.lnk" "$INSTDIR\manual.pdf"
153 SectionEnd
155 ;--------------------------------
156 ;Descriptions
158 ;Language strings
159 LangString DESC_SecNasm ${LANG_ENGLISH} "NASM assembler and disassember modules"
160 LangString DESC_SecManual ${LANG_ENGLISH} "Complete NASM manual (pdf file)"
161 LangString DESC_SecRdoff ${LANG_ENGLISH} "RDOFF utilities (you may not need it if you don't know what is it)"
163 ;Assign language strings to sections
164 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
165 !insertmacro MUI_DESCRIPTION_TEXT ${SecNasm} $(DESC_SecNasm)
166 !insertmacro MUI_DESCRIPTION_TEXT ${SecRdoff} $(DESC_SecRdoff)
167 !insertmacro MUI_DESCRIPTION_TEXT ${SecManual} $(DESC_SecManual)
168 !insertmacro MUI_FUNCTION_DESCRIPTION_END
170 ;--------------------------------
171 ;Uninstaller Section
173 Section "Uninstall"
175 ; files on HDD
176 Delete /rebootok "$INSTDIR\rdoff\*"
177 RMDir "$INSTDIR\rdoff"
178 Delete /rebootok "$INSTDIR\doc\*"
179 RMDir "$INSTDIR\doc"
180 Delete /rebootok "$INSTDIR\*"
181 RMDir "$INSTDIR"
182 Delete /rebootok "$DESKTOP\${PRODUCT_SHORT_NAME}.lnk"
184 ; Start Menu folder
185 ReadRegStr $0 HKCU Software\${PRODUCT_SHORT_NAME} "lnk"
186 Delete /rebootok "$0\*"
187 RMDir "$0"
188 DeleteRegKey /ifempty HKCU "Software\${PRODUCT_SHORT_NAME}"
189 SectionEnd
192 ; MUI requires this hooks
193 Function .onInit
194 !insertmacro MULTIUSER_INIT
195 FunctionEnd
197 Function un.onInit
198 !insertmacro MULTIUSER_UNINIT
199 FunctionEnd