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