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