* .version: bumped version to 2.5.6 (pic14 ABI changed)
[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\pic"
172   File "${DEV_ROOT}\include\pic\*.h"
173   File "${DEV_ROOT}\include\pic\*.txt"
174   File "${DEV_ROOT}\include\pic\*.inc"
175   SetOutPath "$INSTDIR\include\pic16"
176   File "${DEV_ROOT}\include\pic16\*.h"
177   SetOutPath "$INSTDIR\include\z80"
178   File "${DEV_ROOT}\include\z80\*.h"
179   SetOutPath "$INSTDIR\include"
180   File "${DEV_ROOT}\include\*.h"
181 SectionEnd
182
183 Section "SDCC DS390 library"
184   SectionIn 1 2
185   SetOutPath "$INSTDIR\lib\ds390"
186   File "${DEV_ROOT}\lib\ds390\*.rel"
187   File "${DEV_ROOT}\lib\ds390\*.lib"
188 SectionEnd
189
190 Section "SDCC DS400 library"
191   SectionIn 1 2
192   SetOutPath "$INSTDIR\lib\ds400"
193   File "${DEV_ROOT}\lib\ds400\*.rel"
194   File "${DEV_ROOT}\lib\ds400\*.lib"
195 SectionEnd
196
197 Section "SDCC GBZ80 library"
198   SectionIn 1 2
199   SetOutPath "$INSTDIR\lib\gbz80"
200   File "${DEV_ROOT}\lib\gbz80\*.o"
201   File "${DEV_ROOT}\lib\gbz80\*.lib"
202 SectionEnd
203
204 Section "SDCC Z80 library"
205   SectionIn 1 2
206   SetOutPath "$INSTDIR\lib\z80"
207   File "${DEV_ROOT}\lib\z80\*.o"
208   File "${DEV_ROOT}\lib\z80\*.lib"
209 SectionEnd
210
211 Section "SDCC small model library"
212   SectionIn 1 2
213   SetOutPath "$INSTDIR\lib\small"
214   File "${DEV_ROOT}\lib\small\*.rel"
215   File "${DEV_ROOT}\lib\small\*.lib"
216 SectionEnd
217
218 Section "SDCC medium model library"
219   SectionIn 1 2
220   SetOutPath "$INSTDIR\lib\medium"
221   File "${DEV_ROOT}\lib\medium\*.rel"
222   File "${DEV_ROOT}\lib\medium\*.lib"
223 SectionEnd
224
225 Section "SDCC large model library"
226   SectionIn 1 2
227   SetOutPath "$INSTDIR\lib\large"
228   File "${DEV_ROOT}\lib\large\*.rel"
229   File "${DEV_ROOT}\lib\large\*.lib"
230 SectionEnd
231
232 Section "SDCC small-stack-auto model library"
233   SectionIn 1 2
234   SetOutPath "$INSTDIR\lib\small-stack-auto"
235   File "${DEV_ROOT}\lib\small-stack-auto\*.rel"
236   File "${DEV_ROOT}\lib\small-stack-auto\*.lib"
237 SectionEnd
238
239 Section "SDCC HC08 library"
240   SectionIn 1 2
241   SetOutPath "$INSTDIR\lib\hc08"
242   File "${DEV_ROOT}\lib\hc08\*.rel"
243   File "${DEV_ROOT}\lib\hc08\*.lib"
244 SectionEnd
245
246 Section "SDCC PIC16 library"
247   SectionIn 1 2
248   SetOutPath "$INSTDIR\lib\pic16"
249   File "${DEV_ROOT}\lib\pic16\*.o"
250   File "${DEV_ROOT}\lib\pic16\*.lib"
251 SectionEnd
252
253 Section "SDCC PIC library"
254   SectionIn 1 2
255   SetOutPath "$INSTDIR\lib\pic"
256   File "${DEV_ROOT}\lib\pic\*.o"
257   File "${DEV_ROOT}\lib\pic\*.lib"
258 SectionEnd
259
260 Section "SDCC library sources"
261   SectionIn 1
262   SetOutPath "$INSTDIR\lib\src\ds390\examples"
263   File "${DEV_ROOT}\lib\src\ds390\examples\MOVED"
264
265   SetOutPath "$INSTDIR\lib\src\ds390"
266   File "${DEV_ROOT}\lib\src\ds390\*.c"
267   File "${DEV_ROOT}\lib\src\ds390\Makefile"
268   File "${DEV_ROOT}\lib\src\ds390\Makefile.dep"
269
270   SetOutPath "$INSTDIR\lib\src\ds400"
271   File "${DEV_ROOT}\lib\src\ds400\*.c"
272   File "${DEV_ROOT}\lib\src\ds400\Makefile"
273   File "${DEV_ROOT}\lib\src\ds400\Makefile.dep"
274
275   SetOutPath "$INSTDIR\lib\src\gbz80"
276   File "${DEV_ROOT}\lib\src\gbz80\*.c"
277   File "${DEV_ROOT}\lib\src\gbz80\*.s"
278   File "${DEV_ROOT}\lib\src\gbz80\Makefile"
279   File "${DEV_ROOT}\lib\src\gbz80\README"
280
281   SetOutPath "$INSTDIR\lib\src\z80"
282   File "${DEV_ROOT}\lib\src\z80\*.c"
283   File "${DEV_ROOT}\lib\src\z80\*.s"
284   File "${DEV_ROOT}\lib\src\z80\Makefile"
285   File "${DEV_ROOT}\lib\src\z80\README"
286
287   SetOutPath "$INSTDIR\lib\src\hc08"
288   File "${DEV_ROOT}\lib\src\hc08\*.c"
289   File "${DEV_ROOT}\lib\src\hc08\Makefile"
290
291   SetOutPath "$INSTDIR\lib\src\mcs51"
292   File "${DEV_ROOT}\lib\src\mcs51\*.asm"
293   File "${DEV_ROOT}\lib\src\mcs51\Makefile"
294   File "${DEV_ROOT}\lib\src\mcs51\README"
295
296   SetOutPath "$INSTDIR\lib\src\small"
297   File "${DEV_ROOT}\lib\src\small\Makefile"
298
299   SetOutPath "$INSTDIR\lib\src\medium"
300   File "${DEV_ROOT}\lib\src\medium\Makefile"
301
302   SetOutPath "$INSTDIR\lib\src\large"
303   File "${DEV_ROOT}\lib\src\large\Makefile"
304
305   SetOutPath "$INSTDIR\lib\src\pic"
306   File "${DEV_ROOT}\lib\src\pic\configure"
307   File "${DEV_ROOT}\lib\src\pic\configure.in"
308   File "${DEV_ROOT}\lib\src\pic\GPL"
309   File "${DEV_ROOT}\lib\src\pic\LGPL"
310   File "${DEV_ROOT}\lib\src\pic\Makefile"
311   File "${DEV_ROOT}\lib\src\pic\Makefile.common"
312   File "${DEV_ROOT}\lib\src\pic\Makefile.common.in"
313   File "${DEV_ROOT}\lib\src\pic\Makefile.rules"
314   File "${DEV_ROOT}\lib\src\pic\Makefile.subdir"
315   File "${DEV_ROOT}\lib\src\pic\NEWS"
316   File "${DEV_ROOT}\lib\src\pic\README"
317   File "${DEV_ROOT}\lib\src\pic\TEMPLATE.c"
318   File "${DEV_ROOT}\lib\src\pic\TEMPLATE.S"
319
320   SetOutPath "$INSTDIR\lib\src\pic\libsdcc"
321   File "${DEV_ROOT}\lib\src\pic\libsdcc\*.c"
322   File "${DEV_ROOT}\lib\src\pic\libsdcc\*.S"
323   File "${DEV_ROOT}\lib\src\pic\libsdcc\*.inc"
324   File "${DEV_ROOT}\lib\src\pic\libsdcc\Makefile"
325   
326   SetOutPath "$INSTDIR\lib\src\pic\libdev"
327   File "${DEV_ROOT}\lib\src\pic\libdev\*.c"
328   File "${DEV_ROOT}\lib\src\pic\libdev\*.S"
329   File "${DEV_ROOT}\lib\src\pic\libdev\*.inc"
330   File "${DEV_ROOT}\lib\src\pic\libdev\Makefile"
331
332   SetOutPath "$INSTDIR\lib\src\pic16"
333   File "${DEV_ROOT}\lib\src\pic16\configure"
334   File "${DEV_ROOT}\lib\src\pic16\configure.in"
335   File "${DEV_ROOT}\lib\src\pic16\COPYING"
336   File "${DEV_ROOT}\lib\src\pic16\Makefile"
337   File "${DEV_ROOT}\lib\src\pic16\Makefile.common"
338   File "${DEV_ROOT}\lib\src\pic16\Makefile.common.in"
339   File "${DEV_ROOT}\lib\src\pic16\Makefile.rules"
340   File "${DEV_ROOT}\lib\src\pic16\Makefile.subdir"
341   File "${DEV_ROOT}\lib\src\pic16\pics.all"
342   File "${DEV_ROOT}\lib\src\pic16\pics.build"
343   File "${DEV_ROOT}\lib\src\pic16\README"
344
345   SetOutPath "$INSTDIR\lib\src\pic16\debug"
346   File "${DEV_ROOT}\lib\src\pic16\debug\Makefile"
347
348   SetOutPath "$INSTDIR\lib\src\pic16\debug\gstack"
349   File "${DEV_ROOT}\lib\src\pic16\debug\gstack\Makefile"
350   File "${DEV_ROOT}\lib\src\pic16\debug\gstack\*.c"
351
352   SetOutPath "$INSTDIR\lib\src\pic16\libc"
353   File "${DEV_ROOT}\lib\src\pic16\libc\Makefile"
354
355   SetOutPath "$INSTDIR\lib\src\pic16\libc\ctype"
356   File "${DEV_ROOT}\lib\src\pic16\libc\ctype\*.c"
357   File "${DEV_ROOT}\lib\src\pic16\libc\ctype\Makefile"
358
359   SetOutPath "$INSTDIR\lib\src\pic16\libc\delay"
360   File "${DEV_ROOT}\lib\src\pic16\libc\delay\*.S"
361   File "${DEV_ROOT}\lib\src\pic16\libc\delay\Makefile"
362
363   SetOutPath "$INSTDIR\lib\src\pic16\libc\stdio"
364   File "${DEV_ROOT}\lib\src\pic16\libc\stdio\*.c"
365   File "${DEV_ROOT}\lib\src\pic16\libc\stdio\Makefile"
366
367   SetOutPath "$INSTDIR\lib\src\pic16\libc\stdlib"
368   File "${DEV_ROOT}\lib\src\pic16\libc\stdlib\*.c"
369   File "${DEV_ROOT}\lib\src\pic16\libc\stdlib\*.S"
370   File "${DEV_ROOT}\lib\src\pic16\libc\stdlib\Makefile"
371
372   SetOutPath "$INSTDIR\lib\src\pic16\libc\string"
373   File "${DEV_ROOT}\lib\src\pic16\libc\string\*.c"
374   File "${DEV_ROOT}\lib\src\pic16\libc\string\Makefile"
375
376   SetOutPath "$INSTDIR\lib\src\pic16\libc\utils"
377   File "${DEV_ROOT}\lib\src\pic16\libc\utils\*.S"
378   File "${DEV_ROOT}\lib\src\pic16\libc\utils\Makefile"
379
380   SetOutPath "$INSTDIR\lib\src\pic16\libdev"
381   File "${DEV_ROOT}\lib\src\pic16\libdev\*.c"
382   File "${DEV_ROOT}\lib\src\pic16\libdev\Makefile"
383
384   SetOutPath "$INSTDIR\lib\src\pic16\libio"
385   File "${DEV_ROOT}\lib\src\pic16\libio\*.ignore"
386   File "${DEV_ROOT}\lib\src\pic16\libio\Makefile"
387
388   SetOutPath "$INSTDIR\lib\src\pic16\libio\adc"
389   File "${DEV_ROOT}\lib\src\pic16\libio\adc\*.c"
390   File "${DEV_ROOT}\lib\src\pic16\libio\adc\Makefile"
391
392   SetOutPath "$INSTDIR\lib\src\pic16\libio\i2c"
393   File "${DEV_ROOT}\lib\src\pic16\libio\i2c\*.c"
394   File "${DEV_ROOT}\lib\src\pic16\libio\i2c\Makefile"
395
396   SetOutPath "$INSTDIR\lib\src\pic16\libio\usart"
397   File "${DEV_ROOT}\lib\src\pic16\libio\usart\*.c"
398   File "${DEV_ROOT}\lib\src\pic16\libio\usart\Makefile"
399
400   SetOutPath "$INSTDIR\lib\src\pic16\libm"
401   File "${DEV_ROOT}\lib\src\pic16\libm\*.c"
402   File "${DEV_ROOT}\lib\src\pic16\libm\Makefile"
403
404   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc"
405   File "${DEV_ROOT}\lib\src\pic16\libsdcc\Makefile"
406
407   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\char"
408   File "${DEV_ROOT}\lib\src\pic16\libsdcc\char\*.c"
409   File "${DEV_ROOT}\lib\src\pic16\libsdcc\char\Makefile"
410
411   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\fixed16x16"
412   File "${DEV_ROOT}\lib\src\pic16\libsdcc\fixed16x16\*.c"
413   File "${DEV_ROOT}\lib\src\pic16\libsdcc\fixed16x16\*.S"
414   File "${DEV_ROOT}\lib\src\pic16\libsdcc\fixed16x16\Makefile"
415
416   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\float"
417   File "${DEV_ROOT}\lib\src\pic16\libsdcc\float\*.c"
418   File "${DEV_ROOT}\lib\src\pic16\libsdcc\float\Makefile"
419
420   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\gptr"
421   File "${DEV_ROOT}\lib\src\pic16\libsdcc\gptr\*.c"
422   File "${DEV_ROOT}\lib\src\pic16\libsdcc\gptr\Makefile"
423
424   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\int"
425   File "${DEV_ROOT}\lib\src\pic16\libsdcc\int\*.c"
426   File "${DEV_ROOT}\lib\src\pic16\libsdcc\int\Makefile"
427
428   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\long"
429   File "${DEV_ROOT}\lib\src\pic16\libsdcc\long\*.c"
430   File "${DEV_ROOT}\lib\src\pic16\libsdcc\long\Makefile"
431
432   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\lregs"
433   File "${DEV_ROOT}\lib\src\pic16\libsdcc\lregs\*.c"
434   File "${DEV_ROOT}\lib\src\pic16\libsdcc\lregs\Makefile"
435
436   SetOutPath "$INSTDIR\lib\src\pic16\startup"
437   File "${DEV_ROOT}\lib\src\pic16\startup\*.c"
438   File "${DEV_ROOT}\lib\src\pic16\startup\Makefile"
439   File "${DEV_ROOT}\lib\src\pic16\startup\README"
440
441   SetOutPath "$INSTDIR\lib\src"
442   File "${DEV_ROOT}\lib\src\*.c"
443 SectionEnd
444
445 Section -Icons
446 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
447   CreateDirectory "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE"
448   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\SDCC on the Web.lnk" "$INSTDIR\sdcc.url" 
449   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Uninstall SDCC.lnk" "$INSTDIR\uninstall.exe" 
450   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Documentation.lnk" "$INSTDIR\doc\README.TXT" "" "$INSTDIR\sdcc.ico" "" "" "" ""
451   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Change Log.lnk" "$INSTDIR\doc\ChangeLog_head.txt" "" "$INSTDIR\sdcc.ico" "" "" "" ""
452   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\GPL 2 License.lnk" "$INSTDIR\COPYING.TXT" 
453 !insertmacro MUI_STARTMENU_WRITE_END
454 SectionEnd
455
456 Section -INI
457   WriteIniStr "$INSTDIR\sdcc.url" "InternetShortcut" "URL" "http://sdcc.sourceforge.net/"
458 SectionEnd
459
460 Section -PostInstall
461   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "DisplayName" "SDCC"
462   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "UninstallString" "$INSTDIR\uninstall.exe"
463   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "Publisher" "sdcc.sourceforge.net"
464   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "URLInfoAbout" "http://sdcc.sourceforge.net/"
465   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "HelpLink" "http://sdcc.sourceforge.net/"
466   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "URLUpdateInfo" "http://sdcc.sourceforge.net/"
467   WriteUninstaller "$INSTDIR\uninstall.exe"
468 SectionEnd
469
470 Section -AddToPath
471   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Do you want to add $INSTDIR\bin to the PATH?" IDNO +3
472     Push "$INSTDIR\bin"
473     Call AddToPath
474 SectionEnd
475
476
477 ;;;; Uninstaller code ;;;;
478
479 Function un.onInit
480   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
481   Abort
482 FunctionEnd
483
484 Function un.onUninstSuccess
485   HideWindow
486   MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
487 FunctionEnd
488
489 Section Uninstall
490   !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_STARTMENUPAGE_VARIABLE
491
492   Delete "$INSTDIR\sdcc.url"
493
494   DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "NSIS:StartMenuDir"
495   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC"
496
497   Delete "$INSTDIR\uninstall.exe"
498   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\GPL 2 License.lnk"
499   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Change Log.lnk"
500   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Documentation.lnk"
501   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Uninstall SDCC.lnk"
502   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\SDCC on the Web.lnk"
503
504   Delete "$INSTDIR\lib\src\large\Makefile"
505
506   Delete "$INSTDIR\lib\src\medium\Makefile"
507
508   Delete "$INSTDIR\lib\src\small\Makefile"
509
510   Delete "$INSTDIR\lib\src\mcs51\*.asm"
511   Delete "$INSTDIR\lib\src\mcs51\Makefile"
512   Delete "$INSTDIR\lib\src\mcs51\README"
513
514   Delete "$INSTDIR\lib\src\hc08\*.c"
515   Delete "$INSTDIR\lib\src\hc08\hc08.lib"
516   Delete "$INSTDIR\lib\src\hc08\Makefile"
517
518   Delete "$INSTDIR\lib\src\z80\*.c"
519   Delete "$INSTDIR\lib\src\z80\*.s"
520   Delete "$INSTDIR\lib\src\z80\z80.lib"
521   Delete "$INSTDIR\lib\src\z80\README"
522   Delete "$INSTDIR\lib\src\z80\Makefile"
523
524   Delete "$INSTDIR\lib\src\gbz80\*.c"
525   Delete "$INSTDIR\lib\src\gbz80\*.s"
526   Delete "$INSTDIR\lib\src\gbz80\gbz80.lib"
527   Delete "$INSTDIR\lib\src\gbz80\README"
528   Delete "$INSTDIR\lib\src\gbz80\Makefile"
529
530   Delete "$INSTDIR\lib\src\ds390\*.c"
531   Delete "$INSTDIR\lib\src\ds390\libds390.lib"
532   Delete "$INSTDIR\lib\src\ds390\Makefile.dep"
533   Delete "$INSTDIR\lib\src\ds390\Makefile"
534   Delete "$INSTDIR\lib\src\ds390\examples\MOVED"
535
536   Delete "$INSTDIR\lib\src\ds400\*.c"
537   Delete "$INSTDIR\lib\src\ds400\libds400.lib"
538   Delete "$INSTDIR\lib\src\ds400\Makefile.dep"
539   Delete "$INSTDIR\lib\src\ds400\Makefile"
540
541   Delete "$INSTDIR\lib\src\*.c"
542
543   Delete "$INSTDIR\lib\pic\*.o"
544   Delete "$INSTDIR\lib\pic\*.lib"
545
546   Delete "$INSTDIR\lib\pic16\*.o"
547   Delete "$INSTDIR\lib\pic16\*.lib"
548
549   Delete "$INSTDIR\lib\hc08\*.rel"
550   Delete "$INSTDIR\lib\hc08\*.lib"
551
552   Delete "$INSTDIR\lib\z80\*.o"
553   Delete "$INSTDIR\lib\z80\*.lib"
554
555   Delete "$INSTDIR\lib\small\*.rel"
556   Delete "$INSTDIR\lib\small\*.lib"
557
558   Delete "$INSTDIR\lib\medium\*.rel"
559   Delete "$INSTDIR\lib\medium\*.lib"
560
561   Delete "$INSTDIR\lib\large\*.rel"
562   Delete "$INSTDIR\lib\large\*.lib"
563
564   Delete "$INSTDIR\lib\small-stack-auto\*.rel"
565   Delete "$INSTDIR\lib\small-stack-auto\*.lib"
566
567   Delete "$INSTDIR\lib\gbz80\*.o"
568   Delete "$INSTDIR\lib\gbz80\*.lib"
569
570   Delete "$INSTDIR\lib\ds390\*.rel"
571   Delete "$INSTDIR\lib\ds390\*.lib"
572
573   Delete "$INSTDIR\lib\ds400\*.rel"
574   Delete "$INSTDIR\lib\ds400\*.lib"
575
576   Delete "$INSTDIR\include\asm\z80\*.h"
577   Delete "$INSTDIR\include\asm\pic16\*.h"
578   Delete "$INSTDIR\include\asm\mcs51\*.h"
579   Delete "$INSTDIR\include\asm\gbz80\*.h"
580   Delete "$INSTDIR\include\asm\ds390\*.h"
581   Delete "$INSTDIR\include\asm\default\*.h"
582   Delete "$INSTDIR\include\z80\*.h"
583   Delete "$INSTDIR\include\pic\*.h"
584   Delete "$INSTDIR\include\pic\*.txt"
585   Delete "$INSTDIR\include\pic\*.inc"
586   Delete "$INSTDIR\include\pic16\*.h"
587   Delete "$INSTDIR\include\mcs51\*.h"
588   Delete "$INSTDIR\include\hc08\*.h"
589   Delete "$INSTDIR\include\*.h"
590
591   Delete "$INSTDIR\doc\README.TXT"
592   Delete "$INSTDIR\doc\ChangeLog_head.txt"
593
594   Delete "$INSTDIR\bin\*.exe"
595
596   Delete "$INSTDIR\COPYING.TXT"
597   Delete "$INSTDIR\sdcc.ico"
598
599   RMDir "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE"
600
601   RMDir /r "$INSTDIR\lib\src\pic"
602   RMDir /r "$INSTDIR\lib\src\pic16"
603   RMDir "$INSTDIR\lib\src\small"
604   RMDir "$INSTDIR\lib\src\medium"
605   RMDir "$INSTDIR\lib\src\large"
606   RMDir "$INSTDIR\lib\src\mcs51"
607   RMDir "$INSTDIR\lib\src\z80"
608   RMDir "$INSTDIR\lib\src\gbz80"
609   RMDir "$INSTDIR\lib\src\ds390\examples"
610   RMDir "$INSTDIR\lib\src\ds390"
611   RMDir "$INSTDIR\lib\src\ds400"
612   RMDir "$INSTDIR\lib\src\hc08"
613   RMDir "$INSTDIR\lib\src"
614
615   RMDir "$INSTDIR\lib\pic"
616   RMDir "$INSTDIR\lib\pic16"
617   RMDir "$INSTDIR\lib\z80"
618   RMDir "$INSTDIR\lib\small"
619   RMDir "$INSTDIR\lib\medium"
620   RMDir "$INSTDIR\lib\large"
621   RMDir "$INSTDIR\lib\small-stack-auto"
622   RMDir "$INSTDIR\lib\gbz80"
623   RMDir "$INSTDIR\lib\ds390"
624   RMDir "$INSTDIR\lib\ds400"
625   RMDir "$INSTDIR\lib\hc08"
626   RMDir "$INSTDIR\lib"
627
628   RMDir "$INSTDIR\include\asm\z80"
629   RMDir "$INSTDIR\include\asm\pic16"
630   RMDir "$INSTDIR\include\asm\mcs51"
631   RMDir "$INSTDIR\include\asm\gbz80"
632   RMDir "$INSTDIR\include\asm\ds390"
633   RMDir "$INSTDIR\include\asm\default"
634   RMDir "$INSTDIR\include\asm"
635   RMDir "$INSTDIR\include\z80"
636   RMDir "$INSTDIR\include\pic"
637   RMDir "$INSTDIR\include\pic16"
638   RMDir "$INSTDIR\include\mcs51"
639   RMDir "$INSTDIR\include\hc08"
640   RMDir "$INSTDIR\include"
641
642   RMDir "$INSTDIR\doc"
643
644   RMDir "$INSTDIR\bin"
645
646   RMDir "$INSTDIR"
647
648   Push "$INSTDIR\bin"
649   Call un.RemoveFromPath
650
651   SetAutoClose true
652 SectionEnd
653
654 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
655 ; Path Manipulation functions                                                 ;
656 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
657
658 !verbose 3
659 !include "WinMessages.nsh"
660 !verbose 4
661
662 ; AddToPath - Adds the given dir to the search path.
663 ;        Input - head of the stack
664 ;        Note - Win9x systems requires reboot
665
666 Function AddToPath
667   Exch $0
668   Push $1
669   Push $2
670   Push $3
671   Push $4
672
673   ; don't add if the path doesn't exist
674   IfFileExists $0 "" AddToPath_done
675
676   Call IsNT
677   Pop $4
678   StrCmp $4 1 +3
679     ; Not on NT: read PATH from environment variable
680     ReadEnvStr $1 PATH
681     Goto +2
682     ; On NT: read PATH from registry
683     ReadRegStr $1 HKCU "Environment" "PATH"
684   Push "$1;"
685   Push "$0;"
686   Call StrStr
687   Pop $2
688   StrCmp $2 "" "" AddToPath_done
689   Push "$1;"
690   Push "$0\;"
691   Call StrStr
692   Pop $2
693   StrCmp $2 "" "" AddToPath_done
694   GetFullPathName /SHORT $3 $0
695   Push "$1;"
696   Push "$3;"
697   Call StrStr
698   Pop $2
699   StrCmp $2 "" "" AddToPath_done
700   Push "$1;"
701   Push "$3\;"
702   Call StrStr
703   Pop $2
704   StrCmp $2 "" "" AddToPath_done
705
706   StrCmp $4 1 AddToPath_NT
707     ; Not on NT
708     StrCpy $1 $WINDIR 2
709     FileOpen $1 "$1\autoexec.bat" a
710     FileSeek $1 -1 END
711     FileReadByte $1 $2
712     IntCmp $2 26 0 +2 +2 ; DOS EOF
713       FileSeek $1 -1 END ; write over EOF
714     FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
715     FileClose $1
716     SetRebootFlag true
717     Goto AddToPath_done
718
719   AddToPath_NT:
720     ReadRegStr $1 HKCU "Environment" "PATH"
721     StrCpy $2 $1 1 -1  ; copy last char
722     StrCmp $2 ";" 0 +2 ; if last char == ;
723       StrCpy $1 $1 -1  ; remove last char
724     StrCmp $1 "" AddToPath_NTdoIt
725       StrCpy $0 "$1;$0"
726     AddToPath_NTdoIt:
727       WriteRegExpandStr HKCU "Environment" "PATH" $0
728       SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
729
730   AddToPath_done:
731     Pop $4
732     Pop $3
733     Pop $2
734     Pop $1
735     Pop $0
736 FunctionEnd
737
738 ; RemoveFromPath - Remove a given dir from the path
739 ;     Input: head of the stack
740
741 Function un.RemoveFromPath
742   Exch $0
743   Push $1
744   Push $2
745   Push $3
746   Push $4
747   Push $5
748   Push $6
749
750   IntFmt $6 "%c" 26 ; DOS EOF
751
752   Call un.IsNT
753   Pop $1
754   StrCmp $1 1 unRemoveFromPath_NT
755     ; Not on NT
756     StrCpy $1 $WINDIR 2
757     FileOpen $1 "$1\autoexec.bat" r
758     GetTempFileName $4
759     FileOpen $2 $4 w
760     GetFullPathName /SHORT $0 $0
761     StrCpy $0 "SET PATH=%PATH%;$0"
762     Goto unRemoveFromPath_dosLoop
763
764     unRemoveFromPath_dosLoop:
765       FileRead $1 $3
766       StrCpy $5 $3 1 -1 ; read last char
767       StrCmp $5 $6 0 +2 ; if DOS EOF
768         StrCpy $3 $3 -1 ; remove DOS EOF so we can compare
769       StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
770       StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
771       StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
772       StrCmp $3 "" unRemoveFromPath_dosLoopEnd
773       FileWrite $2 $3
774       Goto unRemoveFromPath_dosLoop
775       unRemoveFromPath_dosLoopRemoveLine:
776         SetRebootFlag true
777         Goto unRemoveFromPath_dosLoop
778
779     unRemoveFromPath_dosLoopEnd:
780       FileClose $2
781       FileClose $1
782       StrCpy $1 $WINDIR 2
783       Delete "$1\autoexec.bat"
784       CopyFiles /SILENT $4 "$1\autoexec.bat"
785       Delete $4
786       Goto unRemoveFromPath_done
787
788   unRemoveFromPath_NT:
789     ReadRegStr $1 HKCU "Environment" "PATH"
790     StrCpy $5 $1 1 -1 ; copy last char
791     StrCmp $5 ";" +2  ; if last char != ;
792       StrCpy $1 "$1;" ; append ;
793     Push $1
794     Push "$0;"
795     Call un.StrStr    ; Find `$0;` in $1
796     Pop $2            ; pos of our dir
797     StrCmp $2 "" unRemoveFromPath_done
798       ; else, it is in path
799       ; $0 - path to add
800       ; $1 - path var
801       StrLen $3 "$0;"
802       StrLen $4 $2
803       StrCpy $5 $1 -$4   ; $5 is now the part before the path to remove
804       StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove
805       StrCpy $3 $5$6
806
807       StrCpy $5 $3 1 -1  ; copy last char
808       StrCmp $5 ";" 0 +2 ; if last char == ;
809         StrCpy $3 $3 -1  ; remove last char
810
811       StrCmp $3 "" +3
812         ; New PATH not empty: update the registry
813         WriteRegExpandStr HKCU "Environment" "PATH" $3
814         Goto +2
815         ; New PATH empty: remove from the registry
816         DeleteRegValue HKCU "Environment" "PATH"
817       SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
818
819   unRemoveFromPath_done:
820     Pop $6
821     Pop $5
822     Pop $4
823     Pop $3
824     Pop $2
825     Pop $1
826     Pop $0
827 FunctionEnd
828
829 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
830 ;            Utility Functions            ;
831 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
832
833 ; IsNT
834 ; no input
835 ; output, top of the stack = 1 if NT or 0 if not
836 ;
837 ; Usage:
838 ;   Call IsNT
839 ;   Pop $R0
840 ;  ($R0 at this point is 1 or 0)
841
842 !macro IsNT un
843 Function ${un}IsNT
844   Push $0
845   ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
846   StrCmp $0 "" 0 IsNT_yes
847   ; we are not NT.
848   Pop $0
849   Push 0
850   Return
851
852   IsNT_yes:
853     ; NT!!!
854     Pop $0
855     Push 1
856 FunctionEnd
857 !macroend
858 !insertmacro IsNT ""
859 !insertmacro IsNT "un."
860
861 ; StrStr
862 ; input, top of stack = string to search for
863 ;        top of stack-1 = string to search in
864 ; output, top of stack (replaces with the portion of the string remaining)
865 ; modifies no other variables.
866 ;
867 ; Usage:
868 ;   Push "this is a long ass string"
869 ;   Push "ass"
870 ;   Call StrStr
871 ;   Pop $R0
872 ;  ($R0 at this point is "ass string")
873
874 !macro StrStr un
875 Function ${un}StrStr
876 Exch $R1   ; st=haystack,old$R1, $R1=needle
877   Exch     ; st=old$R1,haystack
878   Exch $R2 ; st=old$R1,old$R2, $R2=haystack
879   Push $R3
880   Push $R4
881   Push $R5
882   StrLen $R3 $R1
883   StrCpy $R4 0
884   ; $R1=needle
885   ; $R2=haystack
886   ; $R3=len(needle)
887   ; $R4=cnt
888   ; $R5=tmp
889   loop:
890     StrCpy $R5 $R2 $R3 $R4
891     StrCmp $R5 $R1 done
892     StrCmp $R5 "" done
893     IntOp $R4 $R4 + 1
894     Goto loop
895 done:
896   StrCpy $R1 $R2 "" $R4
897   Pop $R5
898   Pop $R4
899   Pop $R3
900   Pop $R2
901   Exch $R1
902 FunctionEnd
903 !macroend
904 !insertmacro StrStr ""
905 !insertmacro StrStr "un."