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