3558502c0bc255c917c73a826bc369614f4e1730
[fw/sdcc] / support / scripts / sdcc.nsi
1 # sdcc.nsi - NSIS installer script for SDCC
2 #
3 # Copyright (c) 2003 Borut Razem
4 #
5 # This file is part of sdcc.
6 #
7 #  This software is provided 'as-is', without any express or implied
8 #  warranty.  In no event will the authors be held liable for any damages
9 #  arising from the use of this software.
10 #
11 #  Permission is granted to anyone to use this software for any purpose,
12 #  including commercial applications, and to alter it and redistribute it
13 #  freely, subject to the following restrictions:
14 #
15 #  1. The origin of this software must not be misrepresented; you must not
16 #     claim that you wrote the original software. If you use this software
17 #     in a product, an acknowledgment in the product documentation would be
18 #     appreciated but is not required.
19 #  2. Altered source versions must be plainly marked as such, and must not be
20 #     misrepresented as being the original software.
21 #  3. This notice may not be removed or altered from any source distribution.
22 #
23 #  Borut Razem
24 #  borut.razem@siol.net
25
26 !include "MUI.nsh"
27
28 SetCompressor lzma
29
30 !define SDCC_ROOT "..\.."
31
32 !define FROM_SNAPSHOT
33
34 !ifdef FROM_SNAPSHOT
35 !system "dir ${SDCC_ROOT}\device > NUL" <> 0
36 !define DEV_ROOT "${SDCC_ROOT}"
37 !else
38 !system "dir ${SDCC_ROOT}\device > NUL" = 0
39 !define DEV_ROOT "${SDCC_ROOT}\device"
40 !endif
41
42 !system "unix2dos ${SDCC_ROOT}\doc\ChangeLog_head.txt" = 0
43 !system "unix2dos ${SDCC_ROOT}\doc\README.TXT" = 0
44
45 InstType "Full (Bin, Doc, Lib, Src)"
46 InstType "Medium (Bin, Doc, Lib)"
47 InstType "Compact (Bin, Doc)"
48
49 ;--------------------------------
50 ;Variables
51
52 Var MUI_STARTMENUPAGE_VARIABLE
53
54 ;--------------------------------
55 !define MUI_ABORTWARNING
56 !insertmacro MUI_PAGE_WELCOME
57 !define MUI_LICENSEPAGE_RADIOBUTTONS
58 !insertmacro MUI_PAGE_LICENSE "${SDCC_ROOT}\COPYING.TXT"
59 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "SDCC"
60 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
61 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC"
62 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "NSIS:StartMenuDir"
63 !define MUI_STARTMENUPAGE_NODISABLE
64 !insertmacro MUI_PAGE_STARTMENU Application $MUI_STARTMENUPAGE_VARIABLE
65 !insertmacro MUI_PAGE_COMPONENTS
66 !insertmacro MUI_PAGE_DIRECTORY
67 !insertmacro MUI_PAGE_INSTFILES
68 !insertmacro MUI_PAGE_FINISH
69 !insertmacro MUI_UNPAGE_INSTFILES
70 !insertmacro MUI_LANGUAGE "English"
71
72 Name "SDCC"
73 BrandingText ""
74 OutFile "setup.exe"
75 InstallDir "$PROGRAMFILES\SDCC"
76 ShowInstDetails show
77 ShowUnInstDetails show
78
79 Function .onInit
80   MessageBox MB_YESNO|MB_ICONQUESTION "This will install $(^Name). Do you wish to continue?" IDYES +2
81   Abort
82 FunctionEnd
83
84 Section -Common
85   SetOutPath "$INSTDIR"
86   File ".\sdcc.ico"
87   File "${SDCC_ROOT}\COPYING.TXT"
88 SectionEnd
89
90 Section "SDCC application files"
91   SectionIn 1 2 3 RO
92   SetOutPath "$INSTDIR\bin"
93   File "${SDCC_ROOT}\bin\*.exe"
94 SectionEnd
95
96 Section "SDCC documentation"
97   SectionIn 1 2 3
98   SetOutPath "$INSTDIR\doc"
99   File "${SDCC_ROOT}\doc\ChangeLog_head.txt"
100   File "${SDCC_ROOT}\doc\README.TXT"
101 SectionEnd
102
103 Section "SDCC include files"
104   SectionIn 1 2
105   SetOutPath "$INSTDIR\include\asm\default"
106   File "${DEV_ROOT}\include\asm\default\features.h"
107   SetOutPath "$INSTDIR\include\asm\gbz80"
108   File "${DEV_ROOT}\include\asm\gbz80\features.h"
109   SetOutPath "$INSTDIR\include\asm\z80"
110   File "${DEV_ROOT}\include\asm\z80\features.h"
111   SetOutPath "$INSTDIR\include"
112   File "${DEV_ROOT}\include\*.h"
113 SectionEnd
114
115 Section "SDCC DS390 library"
116   SectionIn 1 2
117   SetOutPath "$INSTDIR\lib\ds390"
118   File "${DEV_ROOT}\lib\ds390\*.asm"
119   File "${DEV_ROOT}\lib\ds390\*.rel"
120   File "${DEV_ROOT}\lib\ds390\*.lib"
121 SectionEnd
122
123 Section "SDCC DS400 library"
124   SectionIn 1 2
125   SetOutPath "$INSTDIR\lib\ds400"
126   File "${DEV_ROOT}\lib\ds400\*.asm"
127   File "${DEV_ROOT}\lib\ds400\*.rel"
128   File "${DEV_ROOT}\lib\ds400\*.lib"
129 SectionEnd
130
131 Section "SDCC GBZ80 library"
132   SectionIn 1 2
133   SetOutPath "$INSTDIR\lib\gbz80"
134   File "${DEV_ROOT}\lib\gbz80\*.asm"
135   File "${DEV_ROOT}\lib\gbz80\*.o"
136   File "${DEV_ROOT}\lib\gbz80\*.lib"
137 SectionEnd
138
139 Section "SDCC Z80 library"
140   SectionIn 1 2
141   SetOutPath "$INSTDIR\lib\z80"
142   File "${DEV_ROOT}\lib\z80\*.asm"
143   File "${DEV_ROOT}\lib\z80\*.o"
144   File "${DEV_ROOT}\lib\z80\*.lib"
145 SectionEnd
146
147 Section "SDCC large model library"
148   SectionIn 1 2
149   SetOutPath "$INSTDIR\lib\large"
150   File "${DEV_ROOT}\lib\large\*.asm"
151   File "${DEV_ROOT}\lib\large\*.rel"
152   File "${DEV_ROOT}\lib\large\*.lib"
153 SectionEnd
154
155 Section "SDCC small model library"
156   SectionIn 1 2
157   SetOutPath "$INSTDIR\lib\small"
158   File "${DEV_ROOT}\lib\small\*.asm"
159   File "${DEV_ROOT}\lib\small\*.rel"
160   File "${DEV_ROOT}\lib\small\*.lib"
161 SectionEnd
162
163 Section "SDCC HC08 library"
164   SectionIn 1 2
165   SetOutPath "$INSTDIR\lib\hc08"
166   File "${DEV_ROOT}\lib\hc08\*.asm"
167   File "${DEV_ROOT}\lib\hc08\*.rel"
168   File "${DEV_ROOT}\lib\hc08\*.lib"
169 SectionEnd
170
171 Section "SDCC library sources"
172   SectionIn 1
173   SetOutPath "$INSTDIR\lib\src\ds390\examples"
174   File "${DEV_ROOT}\lib\src\ds390\examples\MOVED"
175
176   SetOutPath "$INSTDIR\lib\src\ds390"
177   File "${DEV_ROOT}\lib\src\ds390\*.c"
178   File "${DEV_ROOT}\lib\src\ds390\libds390.lib"
179   File "${DEV_ROOT}\lib\src\ds390\Makefile"
180   File "${DEV_ROOT}\lib\src\ds390\Makefile.dep"
181
182   SetOutPath "$INSTDIR\lib\src\ds400"
183   File "${DEV_ROOT}\lib\src\ds400\*.c"
184   File "${DEV_ROOT}\lib\src\ds400\libds400.lib"
185   File "${DEV_ROOT}\lib\src\ds400\Makefile"
186   File "${DEV_ROOT}\lib\src\ds400\Makefile.dep"
187
188   SetOutPath "$INSTDIR\lib\src\gbz80"
189   File "${DEV_ROOT}\lib\src\gbz80\*.c"
190   File "${DEV_ROOT}\lib\src\gbz80\*.s"
191   File "${DEV_ROOT}\lib\src\gbz80\gbz80.lib"
192   File "${DEV_ROOT}\lib\src\gbz80\Makefile"
193   File "${DEV_ROOT}\lib\src\gbz80\README"
194
195   SetOutPath "$INSTDIR\lib\src\z80"
196   File "${DEV_ROOT}\lib\src\z80\*.c"
197   File "${DEV_ROOT}\lib\src\z80\*.s"
198   File "${DEV_ROOT}\lib\src\z80\Makefile"
199   File "${DEV_ROOT}\lib\src\z80\README"
200   File "${DEV_ROOT}\lib\src\z80\z80.lib"
201
202   SetOutPath "$INSTDIR\lib\src\hc08"
203   File "${DEV_ROOT}\lib\src\hc08\*.c"
204   File "${DEV_ROOT}\lib\src\hc08\Makefile"
205   File "${DEV_ROOT}\lib\src\hc08\hc08.lib"
206
207   SetOutPath "$INSTDIR\lib\src"
208   File "${DEV_ROOT}\lib\src\*.c"
209 SectionEnd
210
211 Section -Icons
212 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
213   CreateDirectory "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE"
214   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\SDCC on the Web.lnk" "$INSTDIR\sdcc.url" 
215   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Uninstall SDCC.lnk" "$INSTDIR\uninstall.exe" 
216   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Documentation.lnk" "$INSTDIR\doc\README.TXT" "" "$INSTDIR\sdcc.ico" "" "" "" ""
217   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Change Log.lnk" "$INSTDIR\doc\ChangeLog_head.txt" "" "$INSTDIR\sdcc.ico" "" "" "" ""
218   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\GPL 2 License.lnk" "$INSTDIR\COPYING.TXT" 
219 !insertmacro MUI_STARTMENU_WRITE_END
220 SectionEnd
221
222 Section -INI
223   WriteIniStr "$INSTDIR\sdcc.url" "InternetShortcut" "URL" "http://sdcc.sourceforge.net/"
224 SectionEnd
225
226 Section -PostInstall
227   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "DisplayName" "SDCC"
228   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "UninstallString" "$INSTDIR\uninstall.exe"
229   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "Publisher" "sdcc.sourceforge.net"
230   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "URLInfoAbout" "http://sdcc.sourceforge.net/"
231   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "HelpLink" "http://sdcc.sourceforge.net/"
232   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "URLUpdateInfo" "http://sdcc.sourceforge.net/"
233   WriteUninstaller "$INSTDIR\uninstall.exe"
234 SectionEnd
235
236
237 #### Uninstaller code ####
238
239 Function un.onInit
240   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
241   Abort
242 FunctionEnd
243
244 Function un.onUninstSuccess
245   HideWindow
246   MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
247 FunctionEnd
248
249 Section Uninstall
250   !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_STARTMENUPAGE_VARIABLE
251
252   Delete "$INSTDIR\sdcc.url"
253
254   DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "NSIS:StartMenuDir"
255   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC"
256
257   Delete "$INSTDIR\uninstall.exe"
258   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\GPL 2 License.lnk"
259   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Change Log.lnk"
260   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Documentation.lnk"
261   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Uninstall SDCC.lnk"
262   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\SDCC on the Web.lnk"
263
264   Delete "$INSTDIR\lib\src\hc08\*.c"
265   Delete "$INSTDIR\lib\src\hc08\hc08.lib"
266   Delete "$INSTDIR\lib\src\hc08\Makefile"
267
268   Delete "$INSTDIR\lib\src\z80\*.c"
269   Delete "$INSTDIR\lib\src\z80\*.s"
270   Delete "$INSTDIR\lib\src\z80\z80.lib"
271   Delete "$INSTDIR\lib\src\z80\README"
272   Delete "$INSTDIR\lib\src\z80\Makefile"
273
274   Delete "$INSTDIR\lib\src\gbz80\*.c"
275   Delete "$INSTDIR\lib\src\gbz80\*.s"
276   Delete "$INSTDIR\lib\src\gbz80\gbz80.lib"
277   Delete "$INSTDIR\lib\src\gbz80\README"
278   Delete "$INSTDIR\lib\src\gbz80\Makefile"
279
280   Delete "$INSTDIR\lib\src\ds390\*.c"
281   Delete "$INSTDIR\lib\src\ds390\libds390.lib"
282   Delete "$INSTDIR\lib\src\ds390\Makefile.dep"
283   Delete "$INSTDIR\lib\src\ds390\Makefile"
284   Delete "$INSTDIR\lib\src\ds390\examples\MOVED"
285
286   Delete "$INSTDIR\lib\src\ds400\*.c"
287   Delete "$INSTDIR\lib\src\ds400\libds400.lib"
288   Delete "$INSTDIR\lib\src\ds400\Makefile.dep"
289   Delete "$INSTDIR\lib\src\ds400\Makefile"
290
291   Delete "$INSTDIR\lib\src\*.c"
292
293   Delete "$INSTDIR\lib\hc08\*.rel"
294   Delete "$INSTDIR\lib\hc08\*.asm"
295   Delete "$INSTDIR\lib\hc08\*.lib"
296
297   Delete "$INSTDIR\lib\z80\*.o"
298   Delete "$INSTDIR\lib\z80\*.asm"
299   Delete "$INSTDIR\lib\z80\*.lib"
300
301   Delete "$INSTDIR\lib\small\*.asm"
302   Delete "$INSTDIR\lib\small\*.rel"
303   Delete "$INSTDIR\lib\small\*.lib"
304
305   Delete "$INSTDIR\lib\large\*.asm"
306   Delete "$INSTDIR\lib\large\*.rel"
307   Delete "$INSTDIR\lib\large\*.lib"
308
309   Delete "$INSTDIR\lib\gbz80\*.asm"
310   Delete "$INSTDIR\lib\gbz80\*.o"
311   Delete "$INSTDIR\lib\gbz80\*.lib"
312
313   Delete "$INSTDIR\lib\ds390\*.asm"
314   Delete "$INSTDIR\lib\ds390\*.rel"
315   Delete "$INSTDIR\lib\ds390\*.lib"
316
317   Delete "$INSTDIR\lib\ds400\*.asm"
318   Delete "$INSTDIR\lib\ds400\*.rel"
319   Delete "$INSTDIR\lib\ds400\*.lib"
320
321   Delete "$INSTDIR\include\asm\z80\*.h"
322   Delete "$INSTDIR\include\asm\gbz80\*.h"
323   Delete "$INSTDIR\include\asm\default\*.h"
324   Delete "$INSTDIR\include\*.h"
325
326   Delete "$INSTDIR\doc\README.TXT"
327   Delete "$INSTDIR\doc\ChangeLog_head.txt"
328
329   Delete "$INSTDIR\bin\*.exe"
330
331   Delete "$INSTDIR\COPYING.TXT"
332   Delete "$INSTDIR\sdcc.ico"
333
334   RMDir "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE"
335
336   RMDir "$INSTDIR\lib\src\z80"
337   RMDir "$INSTDIR\lib\src\gbz80"
338   RMDir "$INSTDIR\lib\src\ds390\examples"
339   RMDir "$INSTDIR\lib\src\ds390"
340   RMDir "$INSTDIR\lib\src\ds400"
341   RMDir "$INSTDIR\lib\src\hc08"
342   RMDir "$INSTDIR\lib\src"
343
344   RMDir "$INSTDIR\lib\z80"
345   RMDir "$INSTDIR\lib\small"
346   RMDir "$INSTDIR\lib\large"
347   RMDir "$INSTDIR\lib\gbz80"
348   RMDir "$INSTDIR\lib\ds390"
349   RMDir "$INSTDIR\lib\ds400"
350   RMDir "$INSTDIR\lib\hc08"
351   RMDir "$INSTDIR\lib"
352
353   RMDir "$INSTDIR\include\asm\z80"
354   RMDir "$INSTDIR\include\asm\gbz80"
355   RMDir "$INSTDIR\include\asm\default"
356   RMDir "$INSTDIR\include\asm"
357   RMDir "$INSTDIR\include"
358
359   RMDir "$INSTDIR\doc"
360
361   RMDir "$INSTDIR\bin"
362
363   RMDir "$INSTDIR"
364
365   SetAutoClose true
366 SectionEnd
367