* support/scripts/sdcc.nsi: added /SOLID option to "SetCompressor lzma"
[fw/sdcc] / support / scripts / sdcc.nsi
1 # sdcc.nsi - NSIS installer script for SDCC
2 #
3 # Copyright (c) 2003,2004 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 # How to create WIN32 setup.exe
27 #
28 # - unpack WIN32 mingw daily snapshot sdcc-snapshot-i586-mingw32msvc-yyyymmdd.zip
29 #   to a clean directory (the option to create directories should be enambled).
30 #   A sub directory sdcc is created (referenced as PKGDIR in continuation).
31 # - copy files sdcc/support/scripts/sdcc.ico and sdcc/support/scripts/sdcc.nsi
32 #   (this file) from the sdcc CVS snapshot to the PKGDIR directory
33 # - copy file COPYING from the sdcc CVS snapshot to the PKGDIR directory,
34 #   rename it to COPYING.TXT and convert file COPYING to DOS format:
35 #   unix2dos COPYING.TXT
36 # - run NSIS installer from PKGDIR directory:
37 #   "c:\Program Files\NSIS\makensis.exe" sdcc.nsi
38 # - A setup file setup.exe is created in PKGDIR directory.
39 #   Rename it to sdcc_yyyymmdd_setup.exe and upload it
40 #   to sdcc download repository at sourceforge.net
41 #
42 #
43 # How to upload secc setup.exe tosourceforge.net
44 #
45 # Execute following commands from the cmd prompt:
46 # - sftp sdcc.sourceforge.net
47 # - cd /home/groups/s/sd/sdcc/htdocs/snapshots/i586-mingw32msvc-setup
48 # - put sdcc_yyyymmdd_setup.exe
49 # - quit
50
51
52 !include "MUI.nsh"
53
54 SetCompressor /SOLID lzma
55
56 !define SDCC_ROOT "."
57
58 !define DEV_ROOT "${SDCC_ROOT}"
59
60 !system "unix2dos ${SDCC_ROOT}\doc\ChangeLog_head.txt" = 0
61 !system "unix2dos ${SDCC_ROOT}\doc\README.TXT" = 0
62
63 InstType "Full (Bin, Doc, Lib, Src)"
64 InstType "Medium (Bin, Doc, Lib)"
65 InstType "Compact (Bin, Doc)"
66
67 ;--------------------------------
68 ;Variables
69
70 Var MUI_STARTMENUPAGE_VARIABLE
71
72 ;--------------------------------
73 !define MUI_ABORTWARNING
74
75 !insertmacro MUI_PAGE_WELCOME
76 !insertmacro MUI_PAGE_LICENSE "${SDCC_ROOT}\COPYING.TXT"
77 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "SDCC"
78 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
79 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC"
80 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "NSIS:StartMenuDir"
81 !define MUI_STARTMENUPAGE_NODISABLE
82 !insertmacro MUI_PAGE_STARTMENU Application $MUI_STARTMENUPAGE_VARIABLE
83 !insertmacro MUI_PAGE_COMPONENTS
84 !insertmacro MUI_PAGE_DIRECTORY
85 !insertmacro MUI_PAGE_INSTFILES
86 !insertmacro MUI_PAGE_FINISH
87
88 !insertmacro MUI_UNPAGE_INSTFILES
89
90 !insertmacro MUI_LANGUAGE "English"
91
92 Name "SDCC"
93 BrandingText ""
94 OutFile "setup.exe"
95 InstallDir "$PROGRAMFILES\SDCC"
96 ShowInstDetails show
97 ShowUnInstDetails show
98
99 Function .onInit
100   ;Uninstall the old version, if present
101   ReadRegStr $R0 HKLM \
102   "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" \
103   "UninstallString"
104   StrCmp $R0 "" inst
105
106   MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
107   "$(^Name) is already installed. $\n$\nClick 'OK' to remove the \
108   previous version or 'Cancel' to cancel this upgrade." \
109   IDOK uninst
110   Abort
111
112 uninst:
113   ; Run the uninstaller
114   ClearErrors
115   ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
116
117   ;IfErrors no_remove_uninstaller
118   ;  ;You can either use Delete /REBOOTOK in the uninstaller or add some code
119   ;  ;here to remove to remove the uninstaller. Use a registry key to check
120   ;  ;whether the user has chosen to uninstall. If you are using an uninstaller
121   ;  ;components page, make sure all sections are uninstalled.
122   ;no_remove_uninstaller:
123
124   Goto done
125 inst:
126
127   ; Install the new version
128   MessageBox MB_YESNO|MB_ICONQUESTION "This will install $(^Name). Do you wish to continue?" IDYES +2
129   Abort
130
131 done:
132 FunctionEnd
133
134 Section -Common
135   SetOutPath "$INSTDIR"
136   File ".\sdcc.ico"
137   File "${SDCC_ROOT}\COPYING.TXT"
138 SectionEnd
139
140 Section "SDCC application files"
141   SectionIn 1 2 3 RO
142   SetOutPath "$INSTDIR\bin"
143   File "${SDCC_ROOT}\bin\*.exe"
144 SectionEnd
145
146 Section "SDCC documentation"
147   SectionIn 1 2 3
148   SetOutPath "$INSTDIR\doc"
149   File "${SDCC_ROOT}\doc\ChangeLog_head.txt"
150   File "${SDCC_ROOT}\doc\README.TXT"
151 SectionEnd
152
153 Section "SDCC include files"
154   SectionIn 1 2
155   SetOutPath "$INSTDIR\include\asm\default"
156   File "${DEV_ROOT}\include\asm\default\features.h"
157   SetOutPath "$INSTDIR\include\asm\ds390"
158   File "${DEV_ROOT}\include\asm\ds390\features.h"
159   SetOutPath "$INSTDIR\include\asm\gbz80"
160   File "${DEV_ROOT}\include\asm\gbz80\features.h"
161   SetOutPath "$INSTDIR\include\asm\mcs51"
162   File "${DEV_ROOT}\include\asm\mcs51\features.h"
163   SetOutPath "$INSTDIR\include\asm\pic16"
164   File "${DEV_ROOT}\include\asm\pic16\features.h"
165   SetOutPath "$INSTDIR\include\asm\z80"
166   File "${DEV_ROOT}\include\asm\z80\features.h"
167   SetOutPath "$INSTDIR\include\hc08"
168   File "${DEV_ROOT}\include\hc08\*.h"
169   SetOutPath "$INSTDIR\include\mcs51"
170   File "${DEV_ROOT}\include\mcs51\*.h"
171   SetOutPath "$INSTDIR\include\pic16"
172   File "${DEV_ROOT}\include\pic16\*.h"
173   SetOutPath "$INSTDIR\include\z80"
174   File "${DEV_ROOT}\include\z80\*.h"
175   SetOutPath "$INSTDIR\include"
176   File "${DEV_ROOT}\include\*.h"
177 SectionEnd
178
179 Section "SDCC DS390 library"
180   SectionIn 1 2
181   SetOutPath "$INSTDIR\lib\ds390"
182   File "${DEV_ROOT}\lib\ds390\*.rel"
183   File "${DEV_ROOT}\lib\ds390\*.lib"
184 SectionEnd
185
186 Section "SDCC DS400 library"
187   SectionIn 1 2
188   SetOutPath "$INSTDIR\lib\ds400"
189   File "${DEV_ROOT}\lib\ds400\*.rel"
190   File "${DEV_ROOT}\lib\ds400\*.lib"
191 SectionEnd
192
193 Section "SDCC GBZ80 library"
194   SectionIn 1 2
195   SetOutPath "$INSTDIR\lib\gbz80"
196   File "${DEV_ROOT}\lib\gbz80\*.o"
197   File "${DEV_ROOT}\lib\gbz80\*.lib"
198 SectionEnd
199
200 Section "SDCC Z80 library"
201   SectionIn 1 2
202   SetOutPath "$INSTDIR\lib\z80"
203   File "${DEV_ROOT}\lib\z80\*.o"
204   File "${DEV_ROOT}\lib\z80\*.lib"
205 SectionEnd
206
207 Section "SDCC small model library"
208   SectionIn 1 2
209   SetOutPath "$INSTDIR\lib\small"
210   File "${DEV_ROOT}\lib\small\*.rel"
211   File "${DEV_ROOT}\lib\small\*.lib"
212 SectionEnd
213
214 Section "SDCC medium model library"
215   SectionIn 1 2
216   SetOutPath "$INSTDIR\lib\medium"
217   File "${DEV_ROOT}\lib\medium\*.rel"
218   File "${DEV_ROOT}\lib\medium\*.lib"
219 SectionEnd
220
221 Section "SDCC large model library"
222   SectionIn 1 2
223   SetOutPath "$INSTDIR\lib\large"
224   File "${DEV_ROOT}\lib\large\*.rel"
225   File "${DEV_ROOT}\lib\large\*.lib"
226 SectionEnd
227
228 Section "SDCC small-stack-auto model library"
229   SectionIn 1 2
230   SetOutPath "$INSTDIR\lib\small-stack-auto"
231   File "${DEV_ROOT}\lib\small-stack-auto\*.rel"
232   File "${DEV_ROOT}\lib\small-stack-auto\*.lib"
233 SectionEnd
234
235 Section "SDCC HC08 library"
236   SectionIn 1 2
237   SetOutPath "$INSTDIR\lib\hc08"
238   File "${DEV_ROOT}\lib\hc08\*.rel"
239   File "${DEV_ROOT}\lib\hc08\*.lib"
240 SectionEnd
241
242 Section "SDCC PIC16 library"
243   SectionIn 1 2
244   SetOutPath "$INSTDIR\lib\pic16"
245   File "${DEV_ROOT}\lib\pic16\*.o"
246   File "${DEV_ROOT}\lib\pic16\*.lib"
247 SectionEnd
248
249 Section "SDCC PIC library"
250   SectionIn 1 2
251   SetOutPath "$INSTDIR\lib\pic"
252   File "${DEV_ROOT}\lib\pic\*.lib"
253 SectionEnd
254
255 Section "SDCC library sources"
256   SectionIn 1
257   SetOutPath "$INSTDIR\lib\src\ds390\examples"
258   File "${DEV_ROOT}\lib\src\ds390\examples\MOVED"
259
260   SetOutPath "$INSTDIR\lib\src\ds390"
261   File "${DEV_ROOT}\lib\src\ds390\*.c"
262   File "${DEV_ROOT}\lib\src\ds390\Makefile"
263   File "${DEV_ROOT}\lib\src\ds390\Makefile.dep"
264
265   SetOutPath "$INSTDIR\lib\src\ds400"
266   File "${DEV_ROOT}\lib\src\ds400\*.c"
267   File "${DEV_ROOT}\lib\src\ds400\Makefile"
268   File "${DEV_ROOT}\lib\src\ds400\Makefile.dep"
269
270   SetOutPath "$INSTDIR\lib\src\gbz80"
271   File "${DEV_ROOT}\lib\src\gbz80\*.c"
272   File "${DEV_ROOT}\lib\src\gbz80\*.s"
273   File "${DEV_ROOT}\lib\src\gbz80\Makefile"
274   File "${DEV_ROOT}\lib\src\gbz80\README"
275
276   SetOutPath "$INSTDIR\lib\src\z80"
277   File "${DEV_ROOT}\lib\src\z80\*.c"
278   File "${DEV_ROOT}\lib\src\z80\*.s"
279   File "${DEV_ROOT}\lib\src\z80\Makefile"
280   File "${DEV_ROOT}\lib\src\z80\README"
281
282   SetOutPath "$INSTDIR\lib\src\hc08"
283   File "${DEV_ROOT}\lib\src\hc08\*.c"
284   File "${DEV_ROOT}\lib\src\hc08\Makefile"
285
286   SetOutPath "$INSTDIR\lib\src\mcs51"
287   File "${DEV_ROOT}\lib\src\mcs51\*.asm"
288   File "${DEV_ROOT}\lib\src\mcs51\Makefile"
289   File "${DEV_ROOT}\lib\src\mcs51\README"
290
291   SetOutPath "$INSTDIR\lib\src\small"
292   File "${DEV_ROOT}\lib\src\small\Makefile"
293
294   SetOutPath "$INSTDIR\lib\src\medium"
295   File "${DEV_ROOT}\lib\src\medium\Makefile"
296
297   SetOutPath "$INSTDIR\lib\src\large"
298   File "${DEV_ROOT}\lib\src\large\Makefile"
299
300   SetOutPath "$INSTDIR\lib\src\pic"
301   File "${DEV_ROOT}\lib\src\pic\configure"
302   File "${DEV_ROOT}\lib\src\pic\configure.in"
303   File "${DEV_ROOT}\lib\src\pic\GPL"
304   File "${DEV_ROOT}\lib\src\pic\LGPL"
305   File "${DEV_ROOT}\lib\src\pic\Makefile"
306   File "${DEV_ROOT}\lib\src\pic\Makefile.common"
307   File "${DEV_ROOT}\lib\src\pic\Makefile.common.in"
308   File "${DEV_ROOT}\lib\src\pic\Makefile.rules"
309   File "${DEV_ROOT}\lib\src\pic\Makefile.subdir"
310   File "${DEV_ROOT}\lib\src\pic\NEWS"
311   File "${DEV_ROOT}\lib\src\pic\README"
312   File "${DEV_ROOT}\lib\src\pic\TEMPLATE.c"
313   File "${DEV_ROOT}\lib\src\pic\TEMPLATE.S"
314
315   SetOutPath "$INSTDIR\lib\src\pic\libsdcc"
316   File "${DEV_ROOT}\lib\src\pic\libsdcc\*.c"
317   File "${DEV_ROOT}\lib\src\pic\libsdcc\*.S"
318   File "${DEV_ROOT}\lib\src\pic\libsdcc\*.inc"
319   File "${DEV_ROOT}\lib\src\pic\libsdcc\Makefile"
320
321   SetOutPath "$INSTDIR\lib\src\pic16"
322   File "${DEV_ROOT}\lib\src\pic16\configure"
323   File "${DEV_ROOT}\lib\src\pic16\configure.in"
324   File "${DEV_ROOT}\lib\src\pic16\COPYING"
325   File "${DEV_ROOT}\lib\src\pic16\Makefile"
326   File "${DEV_ROOT}\lib\src\pic16\Makefile.common"
327   File "${DEV_ROOT}\lib\src\pic16\Makefile.common.in"
328   File "${DEV_ROOT}\lib\src\pic16\Makefile.rules"
329   File "${DEV_ROOT}\lib\src\pic16\Makefile.subdir"
330   File "${DEV_ROOT}\lib\src\pic16\pics.all"
331   File "${DEV_ROOT}\lib\src\pic16\pics.build"
332   File "${DEV_ROOT}\lib\src\pic16\README"
333
334   SetOutPath "$INSTDIR\lib\src\pic16\debug"
335   File "${DEV_ROOT}\lib\src\pic16\debug\Makefile"
336
337   SetOutPath "$INSTDIR\lib\src\pic16\debug\gstack"
338   File "${DEV_ROOT}\lib\src\pic16\debug\gstack\Makefile"
339   File "${DEV_ROOT}\lib\src\pic16\debug\gstack\*.c"
340
341   SetOutPath "$INSTDIR\lib\src\pic16\libc"
342   File "${DEV_ROOT}\lib\src\pic16\libc\Makefile"
343
344   SetOutPath "$INSTDIR\lib\src\pic16\libc\ctype"
345   File "${DEV_ROOT}\lib\src\pic16\libc\ctype\*.c"
346   File "${DEV_ROOT}\lib\src\pic16\libc\ctype\Makefile"
347
348   SetOutPath "$INSTDIR\lib\src\pic16\libc\delay"
349   File "${DEV_ROOT}\lib\src\pic16\libc\delay\*.S"
350   File "${DEV_ROOT}\lib\src\pic16\libc\delay\Makefile"
351
352   SetOutPath "$INSTDIR\lib\src\pic16\libc\stdio"
353   File "${DEV_ROOT}\lib\src\pic16\libc\stdio\*.c"
354   File "${DEV_ROOT}\lib\src\pic16\libc\stdio\Makefile"
355
356   SetOutPath "$INSTDIR\lib\src\pic16\libc\stdlib"
357   File "${DEV_ROOT}\lib\src\pic16\libc\stdlib\*.c"
358   File "${DEV_ROOT}\lib\src\pic16\libc\stdlib\*.S"
359   File "${DEV_ROOT}\lib\src\pic16\libc\stdlib\Makefile"
360
361   SetOutPath "$INSTDIR\lib\src\pic16\libc\string"
362   File "${DEV_ROOT}\lib\src\pic16\libc\string\*.c"
363   File "${DEV_ROOT}\lib\src\pic16\libc\string\Makefile"
364
365   SetOutPath "$INSTDIR\lib\src\pic16\libc\utils"
366   File "${DEV_ROOT}\lib\src\pic16\libc\utils\*.S"
367   File "${DEV_ROOT}\lib\src\pic16\libc\utils\Makefile"
368
369   SetOutPath "$INSTDIR\lib\src\pic16\libdev"
370   File "${DEV_ROOT}\lib\src\pic16\libdev\*.c"
371   File "${DEV_ROOT}\lib\src\pic16\libdev\Makefile"
372
373   SetOutPath "$INSTDIR\lib\src\pic16\libio"
374   File "${DEV_ROOT}\lib\src\pic16\libio\*.ignore"
375   File "${DEV_ROOT}\lib\src\pic16\libio\Makefile"
376
377   SetOutPath "$INSTDIR\lib\src\pic16\libio\adc"
378   File "${DEV_ROOT}\lib\src\pic16\libio\adc\*.c"
379   File "${DEV_ROOT}\lib\src\pic16\libio\adc\Makefile"
380
381   SetOutPath "$INSTDIR\lib\src\pic16\libio\i2c"
382   File "${DEV_ROOT}\lib\src\pic16\libio\i2c\*.c"
383   File "${DEV_ROOT}\lib\src\pic16\libio\i2c\Makefile"
384
385   SetOutPath "$INSTDIR\lib\src\pic16\libio\usart"
386   File "${DEV_ROOT}\lib\src\pic16\libio\usart\*.c"
387   File "${DEV_ROOT}\lib\src\pic16\libio\usart\Makefile"
388
389   SetOutPath "$INSTDIR\lib\src\pic16\libm"
390   File "${DEV_ROOT}\lib\src\pic16\libm\*.c"
391   File "${DEV_ROOT}\lib\src\pic16\libm\Makefile"
392
393   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc"
394   File "${DEV_ROOT}\lib\src\pic16\libsdcc\Makefile"
395
396   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\char"
397   File "${DEV_ROOT}\lib\src\pic16\libsdcc\char\*.c"
398   File "${DEV_ROOT}\lib\src\pic16\libsdcc\char\Makefile"
399
400   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\fixed16x16"
401   File "${DEV_ROOT}\lib\src\pic16\libsdcc\fixed16x16\*.c"
402   File "${DEV_ROOT}\lib\src\pic16\libsdcc\fixed16x16\*.S"
403   File "${DEV_ROOT}\lib\src\pic16\libsdcc\fixed16x16\Makefile"
404
405   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\float"
406   File "${DEV_ROOT}\lib\src\pic16\libsdcc\float\*.c"
407   File "${DEV_ROOT}\lib\src\pic16\libsdcc\float\Makefile"
408
409   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\gptr"
410   File "${DEV_ROOT}\lib\src\pic16\libsdcc\gptr\*.c"
411   File "${DEV_ROOT}\lib\src\pic16\libsdcc\gptr\Makefile"
412
413   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\int"
414   File "${DEV_ROOT}\lib\src\pic16\libsdcc\int\*.c"
415   File "${DEV_ROOT}\lib\src\pic16\libsdcc\int\Makefile"
416
417   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\long"
418   File "${DEV_ROOT}\lib\src\pic16\libsdcc\long\*.c"
419   File "${DEV_ROOT}\lib\src\pic16\libsdcc\long\Makefile"
420
421   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\lregs"
422   File "${DEV_ROOT}\lib\src\pic16\libsdcc\lregs\*.c"
423   File "${DEV_ROOT}\lib\src\pic16\libsdcc\lregs\Makefile"
424
425   SetOutPath "$INSTDIR\lib\src\pic16\startup"
426   File "${DEV_ROOT}\lib\src\pic16\startup\*.c"
427   File "${DEV_ROOT}\lib\src\pic16\startup\Makefile"
428   File "${DEV_ROOT}\lib\src\pic16\startup\README"
429
430   SetOutPath "$INSTDIR\lib\src"
431   File "${DEV_ROOT}\lib\src\*.c"
432 SectionEnd
433
434 Section -Icons
435 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
436   CreateDirectory "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE"
437   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\SDCC on the Web.lnk" "$INSTDIR\sdcc.url" 
438   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Uninstall SDCC.lnk" "$INSTDIR\uninstall.exe" 
439   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Documentation.lnk" "$INSTDIR\doc\README.TXT" "" "$INSTDIR\sdcc.ico" "" "" "" ""
440   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Change Log.lnk" "$INSTDIR\doc\ChangeLog_head.txt" "" "$INSTDIR\sdcc.ico" "" "" "" ""
441   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\GPL 2 License.lnk" "$INSTDIR\COPYING.TXT" 
442 !insertmacro MUI_STARTMENU_WRITE_END
443 SectionEnd
444
445 Section -INI
446   WriteIniStr "$INSTDIR\sdcc.url" "InternetShortcut" "URL" "http://sdcc.sourceforge.net/"
447 SectionEnd
448
449 Section -PostInstall
450   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "DisplayName" "SDCC"
451   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "UninstallString" "$INSTDIR\uninstall.exe"
452   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "Publisher" "sdcc.sourceforge.net"
453   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "URLInfoAbout" "http://sdcc.sourceforge.net/"
454   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "HelpLink" "http://sdcc.sourceforge.net/"
455   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "URLUpdateInfo" "http://sdcc.sourceforge.net/"
456   WriteUninstaller "$INSTDIR\uninstall.exe"
457 SectionEnd
458
459 Section -AddToPath
460   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Do you want to add $INSTDIR\bin to the PATH?" IDNO +3
461     Push "$INSTDIR\bin"
462     Call AddToPath
463 SectionEnd
464
465
466 ;;;; Uninstaller code ;;;;
467
468 Function un.onInit
469   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
470   Abort
471 FunctionEnd
472
473 Function un.onUninstSuccess
474   HideWindow
475   MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
476 FunctionEnd
477
478 Section Uninstall
479   !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_STARTMENUPAGE_VARIABLE
480
481   Delete "$INSTDIR\sdcc.url"
482
483   DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "NSIS:StartMenuDir"
484   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC"
485
486   Delete "$INSTDIR\uninstall.exe"
487   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\GPL 2 License.lnk"
488   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Change Log.lnk"
489   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Documentation.lnk"
490   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Uninstall SDCC.lnk"
491   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\SDCC on the Web.lnk"
492
493   Delete "$INSTDIR\lib\src\large\Makefile"
494
495   Delete "$INSTDIR\lib\src\medium\Makefile"
496
497   Delete "$INSTDIR\lib\src\small\Makefile"
498
499   Delete "$INSTDIR\lib\src\mcs51\*.asm"
500   Delete "$INSTDIR\lib\src\mcs51\Makefile"
501   Delete "$INSTDIR\lib\src\mcs51\README"
502
503   Delete "$INSTDIR\lib\src\hc08\*.c"
504   Delete "$INSTDIR\lib\src\hc08\hc08.lib"
505   Delete "$INSTDIR\lib\src\hc08\Makefile"
506
507   Delete "$INSTDIR\lib\src\z80\*.c"
508   Delete "$INSTDIR\lib\src\z80\*.s"
509   Delete "$INSTDIR\lib\src\z80\z80.lib"
510   Delete "$INSTDIR\lib\src\z80\README"
511   Delete "$INSTDIR\lib\src\z80\Makefile"
512
513   Delete "$INSTDIR\lib\src\gbz80\*.c"
514   Delete "$INSTDIR\lib\src\gbz80\*.s"
515   Delete "$INSTDIR\lib\src\gbz80\gbz80.lib"
516   Delete "$INSTDIR\lib\src\gbz80\README"
517   Delete "$INSTDIR\lib\src\gbz80\Makefile"
518
519   Delete "$INSTDIR\lib\src\ds390\*.c"
520   Delete "$INSTDIR\lib\src\ds390\libds390.lib"
521   Delete "$INSTDIR\lib\src\ds390\Makefile.dep"
522   Delete "$INSTDIR\lib\src\ds390\Makefile"
523   Delete "$INSTDIR\lib\src\ds390\examples\MOVED"
524
525   Delete "$INSTDIR\lib\src\ds400\*.c"
526   Delete "$INSTDIR\lib\src\ds400\libds400.lib"
527   Delete "$INSTDIR\lib\src\ds400\Makefile.dep"
528   Delete "$INSTDIR\lib\src\ds400\Makefile"
529
530   Delete "$INSTDIR\lib\src\*.c"
531
532   Delete "$INSTDIR\lib\pic\*.lib"
533
534   Delete "$INSTDIR\lib\pic16\*.o"
535   Delete "$INSTDIR\lib\pic16\*.lib"
536
537   Delete "$INSTDIR\lib\hc08\*.rel"
538   Delete "$INSTDIR\lib\hc08\*.lib"
539
540   Delete "$INSTDIR\lib\z80\*.o"
541   Delete "$INSTDIR\lib\z80\*.lib"
542
543   Delete "$INSTDIR\lib\small\*.rel"
544   Delete "$INSTDIR\lib\small\*.lib"
545
546   Delete "$INSTDIR\lib\medium\*.rel"
547   Delete "$INSTDIR\lib\medium\*.lib"
548
549   Delete "$INSTDIR\lib\large\*.rel"
550   Delete "$INSTDIR\lib\large\*.lib"
551
552   Delete "$INSTDIR\lib\small-stack-auto\*.rel"
553   Delete "$INSTDIR\lib\small-stack-auto\*.lib"
554
555   Delete "$INSTDIR\lib\gbz80\*.o"
556   Delete "$INSTDIR\lib\gbz80\*.lib"
557
558   Delete "$INSTDIR\lib\ds390\*.rel"
559   Delete "$INSTDIR\lib\ds390\*.lib"
560
561   Delete "$INSTDIR\lib\ds400\*.rel"
562   Delete "$INSTDIR\lib\ds400\*.lib"
563
564   Delete "$INSTDIR\include\asm\z80\*.h"
565   Delete "$INSTDIR\include\asm\pic16\*.h"
566   Delete "$INSTDIR\include\asm\mcs51\*.h"
567   Delete "$INSTDIR\include\asm\gbz80\*.h"
568   Delete "$INSTDIR\include\asm\ds390\*.h"
569   Delete "$INSTDIR\include\asm\default\*.h"
570   Delete "$INSTDIR\include\z80\*.h"
571   Delete "$INSTDIR\include\pic16\*.h"
572   Delete "$INSTDIR\include\mcs51\*.h"
573   Delete "$INSTDIR\include\hc08\*.h"
574   Delete "$INSTDIR\include\*.h"
575
576   Delete "$INSTDIR\doc\README.TXT"
577   Delete "$INSTDIR\doc\ChangeLog_head.txt"
578
579   Delete "$INSTDIR\bin\*.exe"
580
581   Delete "$INSTDIR\COPYING.TXT"
582   Delete "$INSTDIR\sdcc.ico"
583
584   RMDir "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE"
585
586   RMDir /r "$INSTDIR\lib\src\pic"
587   RMDir /r "$INSTDIR\lib\src\pic16"
588   RMDir "$INSTDIR\lib\src\small"
589   RMDir "$INSTDIR\lib\src\medium"
590   RMDir "$INSTDIR\lib\src\large"
591   RMDir "$INSTDIR\lib\src\mcs51"
592   RMDir "$INSTDIR\lib\src\z80"
593   RMDir "$INSTDIR\lib\src\gbz80"
594   RMDir "$INSTDIR\lib\src\ds390\examples"
595   RMDir "$INSTDIR\lib\src\ds390"
596   RMDir "$INSTDIR\lib\src\ds400"
597   RMDir "$INSTDIR\lib\src\hc08"
598   RMDir "$INSTDIR\lib\src"
599
600   RMDir "$INSTDIR\lib\pic"
601   RMDir "$INSTDIR\lib\pic16"
602   RMDir "$INSTDIR\lib\z80"
603   RMDir "$INSTDIR\lib\small"
604   RMDir "$INSTDIR\lib\medium"
605   RMDir "$INSTDIR\lib\large"
606   RMDir "$INSTDIR\lib\small-stack-auto"
607   RMDir "$INSTDIR\lib\gbz80"
608   RMDir "$INSTDIR\lib\ds390"
609   RMDir "$INSTDIR\lib\ds400"
610   RMDir "$INSTDIR\lib\hc08"
611   RMDir "$INSTDIR\lib"
612
613   RMDir "$INSTDIR\include\asm\z80"
614   RMDir "$INSTDIR\include\asm\pic16"
615   RMDir "$INSTDIR\include\asm\mcs51"
616   RMDir "$INSTDIR\include\asm\gbz80"
617   RMDir "$INSTDIR\include\asm\ds390"
618   RMDir "$INSTDIR\include\asm\default"
619   RMDir "$INSTDIR\include\asm"
620   RMDir "$INSTDIR\include\z80"
621   RMDir "$INSTDIR\include\pic16"
622   RMDir "$INSTDIR\include\mcs51"
623   RMDir "$INSTDIR\include\hc08"
624   RMDir "$INSTDIR\include"
625
626   RMDir "$INSTDIR\doc"
627
628   RMDir "$INSTDIR\bin"
629
630   RMDir "$INSTDIR"
631
632   Push "$INSTDIR\bin"
633   Call un.RemoveFromPath
634
635   SetAutoClose true
636 SectionEnd
637
638 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
639 ; Path Manipulation functions                                                 ;
640 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
641
642 !verbose 3
643 !include "WinMessages.nsh"
644 !verbose 4
645
646 ; AddToPath - Adds the given dir to the search path.
647 ;        Input - head of the stack
648 ;        Note - Win9x systems requires reboot
649
650 Function AddToPath
651   Exch $0
652   Push $1
653   Push $2
654   Push $3
655   Push $4
656
657   ; don't add if the path doesn't exist
658   IfFileExists $0 "" AddToPath_done
659
660   Call IsNT
661   Pop $4
662   StrCmp $4 1 +3
663     ; Not on NT: read PATH from environment variable
664     ReadEnvStr $1 PATH
665     Goto +2
666     ; On NT: read PATH from registry
667     ReadRegStr $1 HKCU "Environment" "PATH"
668   Push "$1;"
669   Push "$0;"
670   Call StrStr
671   Pop $2
672   StrCmp $2 "" "" AddToPath_done
673   Push "$1;"
674   Push "$0\;"
675   Call StrStr
676   Pop $2
677   StrCmp $2 "" "" AddToPath_done
678   GetFullPathName /SHORT $3 $0
679   Push "$1;"
680   Push "$3;"
681   Call StrStr
682   Pop $2
683   StrCmp $2 "" "" AddToPath_done
684   Push "$1;"
685   Push "$3\;"
686   Call StrStr
687   Pop $2
688   StrCmp $2 "" "" AddToPath_done
689
690   StrCmp $4 1 AddToPath_NT
691     ; Not on NT
692     StrCpy $1 $WINDIR 2
693     FileOpen $1 "$1\autoexec.bat" a
694     FileSeek $1 -1 END
695     FileReadByte $1 $2
696     IntCmp $2 26 0 +2 +2 ; DOS EOF
697       FileSeek $1 -1 END ; write over EOF
698     FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
699     FileClose $1
700     SetRebootFlag true
701     Goto AddToPath_done
702
703   AddToPath_NT:
704     ReadRegStr $1 HKCU "Environment" "PATH"
705     StrCpy $2 $1 1 -1  ; copy last char
706     StrCmp $2 ";" 0 +2 ; if last char == ;
707       StrCpy $1 $1 -1  ; remove last char
708     StrCmp $1 "" AddToPath_NTdoIt
709       StrCpy $0 "$1;$0"
710     AddToPath_NTdoIt:
711       WriteRegExpandStr HKCU "Environment" "PATH" $0
712       SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
713
714   AddToPath_done:
715     Pop $4
716     Pop $3
717     Pop $2
718     Pop $1
719     Pop $0
720 FunctionEnd
721
722 ; RemoveFromPath - Remove a given dir from the path
723 ;     Input: head of the stack
724
725 Function un.RemoveFromPath
726   Exch $0
727   Push $1
728   Push $2
729   Push $3
730   Push $4
731   Push $5
732   Push $6
733
734   IntFmt $6 "%c" 26 ; DOS EOF
735
736   Call un.IsNT
737   Pop $1
738   StrCmp $1 1 unRemoveFromPath_NT
739     ; Not on NT
740     StrCpy $1 $WINDIR 2
741     FileOpen $1 "$1\autoexec.bat" r
742     GetTempFileName $4
743     FileOpen $2 $4 w
744     GetFullPathName /SHORT $0 $0
745     StrCpy $0 "SET PATH=%PATH%;$0"
746     Goto unRemoveFromPath_dosLoop
747
748     unRemoveFromPath_dosLoop:
749       FileRead $1 $3
750       StrCpy $5 $3 1 -1 ; read last char
751       StrCmp $5 $6 0 +2 ; if DOS EOF
752         StrCpy $3 $3 -1 ; remove DOS EOF so we can compare
753       StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
754       StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
755       StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
756       StrCmp $3 "" unRemoveFromPath_dosLoopEnd
757       FileWrite $2 $3
758       Goto unRemoveFromPath_dosLoop
759       unRemoveFromPath_dosLoopRemoveLine:
760         SetRebootFlag true
761         Goto unRemoveFromPath_dosLoop
762
763     unRemoveFromPath_dosLoopEnd:
764       FileClose $2
765       FileClose $1
766       StrCpy $1 $WINDIR 2
767       Delete "$1\autoexec.bat"
768       CopyFiles /SILENT $4 "$1\autoexec.bat"
769       Delete $4
770       Goto unRemoveFromPath_done
771
772   unRemoveFromPath_NT:
773     ReadRegStr $1 HKCU "Environment" "PATH"
774     StrCpy $5 $1 1 -1 ; copy last char
775     StrCmp $5 ";" +2  ; if last char != ;
776       StrCpy $1 "$1;" ; append ;
777     Push $1
778     Push "$0;"
779     Call un.StrStr    ; Find `$0;` in $1
780     Pop $2            ; pos of our dir
781     StrCmp $2 "" unRemoveFromPath_done
782       ; else, it is in path
783       ; $0 - path to add
784       ; $1 - path var
785       StrLen $3 "$0;"
786       StrLen $4 $2
787       StrCpy $5 $1 -$4   ; $5 is now the part before the path to remove
788       StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove
789       StrCpy $3 $5$6
790
791       StrCpy $5 $3 1 -1  ; copy last char
792       StrCmp $5 ";" 0 +2 ; if last char == ;
793         StrCpy $3 $3 -1  ; remove last char
794
795       StrCmp $3 "" +3
796         ; New PATH not empty: update the registry
797         WriteRegExpandStr HKCU "Environment" "PATH" $3
798         Goto +2
799         ; New PATH empty: remove from the registry
800         DeleteRegValue HKCU "Environment" "PATH"
801       SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
802
803   unRemoveFromPath_done:
804     Pop $6
805     Pop $5
806     Pop $4
807     Pop $3
808     Pop $2
809     Pop $1
810     Pop $0
811 FunctionEnd
812
813 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
814 ;            Utility Functions            ;
815 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
816
817 ; IsNT
818 ; no input
819 ; output, top of the stack = 1 if NT or 0 if not
820 ;
821 ; Usage:
822 ;   Call IsNT
823 ;   Pop $R0
824 ;  ($R0 at this point is 1 or 0)
825
826 !macro IsNT un
827 Function ${un}IsNT
828   Push $0
829   ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
830   StrCmp $0 "" 0 IsNT_yes
831   ; we are not NT.
832   Pop $0
833   Push 0
834   Return
835
836   IsNT_yes:
837     ; NT!!!
838     Pop $0
839     Push 1
840 FunctionEnd
841 !macroend
842 !insertmacro IsNT ""
843 !insertmacro IsNT "un."
844
845 ; StrStr
846 ; input, top of stack = string to search for
847 ;        top of stack-1 = string to search in
848 ; output, top of stack (replaces with the portion of the string remaining)
849 ; modifies no other variables.
850 ;
851 ; Usage:
852 ;   Push "this is a long ass string"
853 ;   Push "ass"
854 ;   Call StrStr
855 ;   Pop $R0
856 ;  ($R0 at this point is "ass string")
857
858 !macro StrStr un
859 Function ${un}StrStr
860 Exch $R1   ; st=haystack,old$R1, $R1=needle
861   Exch     ; st=old$R1,haystack
862   Exch $R2 ; st=old$R1,old$R2, $R2=haystack
863   Push $R3
864   Push $R4
865   Push $R5
866   StrLen $R3 $R1
867   StrCpy $R4 0
868   ; $R1=needle
869   ; $R2=haystack
870   ; $R3=len(needle)
871   ; $R4=cnt
872   ; $R5=tmp
873   loop:
874     StrCpy $R5 $R2 $R3 $R4
875     StrCmp $R5 $R1 done
876     StrCmp $R5 "" done
877     IntOp $R4 $R4 + 1
878     Goto loop
879 done:
880   StrCpy $R1 $R2 "" $R4
881   Pop $R5
882   Pop $R4
883   Pop $R3
884   Pop $R2
885   Exch $R1
886 FunctionEnd
887 !macroend
888 !insertmacro StrStr ""
889 !insertmacro StrStr "un."