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