preproc.c: Don't forget to dup filename before free
[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 SetCompressor lzma
36
37 !define MULTIUSER_EXECUTIONLEVEL Highest
38 !define MULTIUSER_MUI
39 !define MULTIUSER_INSTALLMODE_COMMANDLINE
40 !define MULTIUSER_INSTALLMODE_INSTDIR "${PRODUCT_SHORT_NAME}"
41 !include MultiUser.nsh
42
43 !insertmacro MULTIUSER_PAGE_INSTALLMODE
44 !insertmacro MULTIUSER_INSTALLMODEPAGE_INTERFACE
45
46 ;--------------------------------
47 ;General
48
49 ;Name and file
50 Name "${PACKAGE_NAME}"
51 OutFile "${PACKAGE_SHORT_NAME}-installer.exe"
52
53 ;Get installation folder from registry if available
54 InstallDirRegKey HKCU "Software\${PRODUCT_SHORT_NAME}" ""
55
56 ;Request application privileges for Windows Vista
57 RequestExecutionLevel user
58
59 ;--------------------------------
60 ;Variables
61
62 Var StartMenuFolder
63 Var CmdFailed
64
65 ;--------------------------------
66 ;Interface Settings
67 Caption "${PACKAGE_SHORT_NAME} installation"
68 Icon "nsis/nasm.ico"
69 UninstallIcon "nsis/nasm-un.ico"
70
71 !define MUI_ABORTWARNING
72
73 ;--------------------------------
74 ;Pages
75
76 !insertmacro MUI_PAGE_COMPONENTS
77 !insertmacro MUI_PAGE_DIRECTORY
78
79 ;Start Menu Folder Page Configuration
80 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
81 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${PRODUCT_SHORT_NAME}"
82 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_SHORT_NAME}"
83
84 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
85
86 !insertmacro MUI_PAGE_INSTFILES
87
88 !insertmacro MUI_UNPAGE_CONFIRM
89 !insertmacro MUI_UNPAGE_INSTFILES
90
91 ;--------------------------------
92 ;Installer Sections
93
94 !insertmacro MUI_LANGUAGE English
95
96 Section "NASM" SecNasm
97     Sectionin RO
98     SetOutPath "$INSTDIR"
99     File "LICENSE"
100     File "nasm.exe"
101     File "ndisasm.exe"
102     File "nsis/nasm.ico"
103
104     ;Store installation folder
105     WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}" "" $INSTDIR
106
107     ;Store shortcuts folder
108     WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}\" "lnk" $SMPROGRAMS\$StartMenuFolder
109
110     ;
111     ; the bat we need
112     StrCpy $CmdFailed "true"
113     FileOpen $0 "nasmpath.bat" w
114     IfErrors skip
115     StrCpy $CmdFailed "false"
116     FileWrite $0 "@set path=$INSTDIR;%path%$\r$\n"
117     FileWrite $0 "@%comspec%"
118     FileClose $0
119     CreateShortCut "$DESKTOP\${PRODUCT_SHORT_NAME}.lnk" "$INSTDIR\nasmpath.bat" "" "$INSTDIR\nasm.ico" 0
120 skip:
121     ;Create uninstaller
122     WriteUninstaller "$INSTDIR\Uninstall.exe"
123
124     !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
125
126     ;Create shortcuts
127     CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
128     StrCmp $CmdFailed "true" +2
129     CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${PRODUCT_SHORT_NAME}-shell.lnk" "$INSTDIR\nasmpath.bat"
130     CreateShortCut  "$SMPROGRAMS\$StartMenuFolder\${PRODUCT_SHORT_NAME}.lnk" "$INSTDIR\nasm.exe" "" "$INSTDIR\nasm.ico" 0
131     CreateShortCut  "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
132
133     !insertmacro MUI_STARTMENU_WRITE_END
134 SectionEnd
135
136 Section "RDOFF" SecRdoff
137     CreateDirectory "$INSTDIR\rdoff"
138     SetOutPath "$INSTDIR\rdoff"
139     File "rdoff/ldrdf.exe"
140     File "rdoff/rdf2bin.exe"
141     File "rdoff/rdf2com.exe"
142     File "rdoff/rdf2ith.exe"
143     File "rdoff/rdf2ihx.exe"
144     File "rdoff/rdf2srec.exe"
145     File "rdoff/rdfdump.exe"
146     File "rdoff/rdflib.exe"
147     File "rdoff/rdx.exe"
148 SectionEnd
149
150 Section "Manual" SecManual
151     SetOutPath "$INSTDIR"
152     File "doc/nasmdoc.pdf"
153     CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Manual.lnk" "$INSTDIR\nasmdoc.pdf"
154 SectionEnd
155
156 Section "VS8 integration" SecVS8
157     CreateDirectory "$INSTDIR\contrib\VSrules"
158     SetOutPath "$INSTDIR\contrib\VSrules"
159     File "contrib/VSrules/nasm.README"
160     File "contrib/VSrules/nasm.rules"
161 SectionEnd
162
163 ;--------------------------------
164 ;Descriptions
165
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)"
171
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
179
180 ;--------------------------------
181 ;Uninstaller Section
182
183 Section "Uninstall"
184     ;
185     ; files on HDD
186     RMDir /r /rebootok "$INSTDIR"
187     Delete /rebootok "$DESKTOP\${PRODUCT_SHORT_NAME}.lnk"
188     ;
189     ; Start Menu folder
190     ReadRegStr $0 HKCU Software\${PRODUCT_SHORT_NAME} "lnk"
191     Delete /rebootok "$0\*"
192     RMDir "$0"
193     DeleteRegKey /ifempty HKCU "Software\${PRODUCT_SHORT_NAME}"
194 SectionEnd
195
196 ;
197 ; MUI requires this hooks
198 Function .onInit
199     !insertmacro MULTIUSER_INIT
200 FunctionEnd
201
202 Function un.onInit
203     !insertmacro MULTIUSER_UNINIT
204 FunctionEnd