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 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
644   Delete "$INSTDIR\bin\s51.exe"
645   Delete "$INSTDIR\bin\savr.exe"
646   Delete "$INSTDIR\bin\shc08.exe"
647   Delete "$INSTDIR\bin\sz80.exe"
648
649   Delete "$INSTDIR\bin\sdcdb.exe"
650   Delete "$INSTDIR\bin\sdcdb.el"
651   Delete "$INSTDIR\bin\sdcdbsrc.el"
652
653   Delete "$INSTDIR\COPYING.TXT"
654   Delete "$INSTDIR\sdcc.ico"
655
656   RMDir "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE"
657
658   RMDir /r "$INSTDIR\lib\src\pic"
659   RMDir /r "$INSTDIR\lib\src\pic16"
660   RMDir "$INSTDIR\lib\src\small"
661   RMDir "$INSTDIR\lib\src\medium"
662   RMDir "$INSTDIR\lib\src\large"
663   RMDir "$INSTDIR\lib\src\mcs51"
664   RMDir "$INSTDIR\lib\src\z80"
665   RMDir "$INSTDIR\lib\src\gbz80"
666   RMDir "$INSTDIR\lib\src\ds390\examples"
667   RMDir "$INSTDIR\lib\src\ds390"
668   RMDir "$INSTDIR\lib\src\ds400"
669   RMDir "$INSTDIR\lib\src\hc08"
670   RMDir "$INSTDIR\lib\src"
671
672   RMDir "$INSTDIR\lib\pic"
673   RMDir "$INSTDIR\lib\pic16"
674   RMDir "$INSTDIR\lib\z80"
675   RMDir "$INSTDIR\lib\small"
676   RMDir "$INSTDIR\lib\medium"
677   RMDir "$INSTDIR\lib\large"
678   RMDir "$INSTDIR\lib\small-stack-auto"
679   RMDir "$INSTDIR\lib\gbz80"
680   RMDir "$INSTDIR\lib\ds390"
681   RMDir "$INSTDIR\lib\ds400"
682   RMDir "$INSTDIR\lib\hc08"
683   RMDir "$INSTDIR\lib"
684
685   RMDir "$INSTDIR\include\asm\z80"
686   RMDir "$INSTDIR\include\asm\pic16"
687   RMDir "$INSTDIR\include\asm\pic"
688   RMDir "$INSTDIR\include\asm\mcs51"
689   RMDir "$INSTDIR\include\asm\gbz80"
690   RMDir "$INSTDIR\include\asm\ds390"
691   RMDir "$INSTDIR\include\asm\default"
692   RMDir "$INSTDIR\include\asm"
693   RMDir "$INSTDIR\include\z80"
694   RMDir "$INSTDIR\include\pic"
695   RMDir "$INSTDIR\include\pic16"
696   RMDir "$INSTDIR\include\mcs51"
697   RMDir "$INSTDIR\include\hc08"
698   RMDir "$INSTDIR\include"
699
700 !ifdef FULL_DOC
701   RMDir /r "$INSTDIR\doc"
702 !else
703   RMDir "$INSTDIR\doc"
704 !endif
705
706   RMDir "$INSTDIR\bin"
707
708   RMDir "$INSTDIR"
709
710   Push "$INSTDIR\bin"
711   Call un.RemoveFromPath
712
713   SetAutoClose true
714 SectionEnd
715
716 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
717 ; Path Manipulation functions                                                 ;
718 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
719
720 !verbose 3
721 !include "WinMessages.nsh"
722 !verbose 4
723
724 ; AddToPath - Adds the given dir to the search path.
725 ;        Input - head of the stack
726 ;        Note - Win9x systems requires reboot
727
728 Function AddToPath
729   Exch $0
730   Push $1
731   Push $2
732   Push $3
733   Push $4
734
735   ; don't add if the path doesn't exist
736   IfFileExists $0 "" AddToPath_done
737
738   Call IsNT
739   Pop $4
740   StrCmp $4 1 +3
741     ; Not on NT: read PATH from environment variable
742     ReadEnvStr $1 PATH
743     Goto +2
744     ; On NT: read PATH from registry
745     ReadRegStr $1 HKCU "Environment" "PATH"
746   Push "$1;"
747   Push "$0;"
748   Call StrStr
749   Pop $2
750   StrCmp $2 "" "" AddToPath_done
751   Push "$1;"
752   Push "$0\;"
753   Call StrStr
754   Pop $2
755   StrCmp $2 "" "" AddToPath_done
756   GetFullPathName /SHORT $3 $0
757   Push "$1;"
758   Push "$3;"
759   Call StrStr
760   Pop $2
761   StrCmp $2 "" "" AddToPath_done
762   Push "$1;"
763   Push "$3\;"
764   Call StrStr
765   Pop $2
766   StrCmp $2 "" "" AddToPath_done
767
768   StrCmp $4 1 AddToPath_NT
769     ; Not on NT
770     StrCpy $1 $WINDIR 2
771     FileOpen $1 "$1\autoexec.bat" a
772     FileSeek $1 -1 END
773     FileReadByte $1 $2
774     IntCmp $2 26 0 +2 +2 ; DOS EOF
775       FileSeek $1 -1 END ; write over EOF
776     FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
777     FileClose $1
778     SetRebootFlag true
779     Goto AddToPath_done
780
781   AddToPath_NT:
782     ReadRegStr $1 HKCU "Environment" "PATH"
783     StrCpy $2 $1 1 -1  ; copy last char
784     StrCmp $2 ";" 0 +2 ; if last char == ;
785       StrCpy $1 $1 -1  ; remove last char
786     StrCmp $1 "" AddToPath_NTdoIt
787       StrCpy $0 "$1;$0"
788     AddToPath_NTdoIt:
789       WriteRegExpandStr HKCU "Environment" "PATH" $0
790       SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
791
792   AddToPath_done:
793     Pop $4
794     Pop $3
795     Pop $2
796     Pop $1
797     Pop $0
798 FunctionEnd
799
800 ; RemoveFromPath - Remove a given dir from the path
801 ;     Input: head of the stack
802
803 Function un.RemoveFromPath
804   Exch $0
805   Push $1
806   Push $2
807   Push $3
808   Push $4
809   Push $5
810   Push $6
811
812   IntFmt $6 "%c" 26 ; DOS EOF
813
814   Call un.IsNT
815   Pop $1
816   StrCmp $1 1 unRemoveFromPath_NT
817     ; Not on NT
818     StrCpy $1 $WINDIR 2
819     FileOpen $1 "$1\autoexec.bat" r
820     GetTempFileName $4
821     FileOpen $2 $4 w
822     GetFullPathName /SHORT $0 $0
823     StrCpy $0 "SET PATH=%PATH%;$0"
824     Goto unRemoveFromPath_dosLoop
825
826     unRemoveFromPath_dosLoop:
827       FileRead $1 $3
828       StrCpy $5 $3 1 -1 ; read last char
829       StrCmp $5 $6 0 +2 ; if DOS EOF
830         StrCpy $3 $3 -1 ; remove DOS EOF so we can compare
831       StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
832       StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
833       StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
834       StrCmp $3 "" unRemoveFromPath_dosLoopEnd
835       FileWrite $2 $3
836       Goto unRemoveFromPath_dosLoop
837       unRemoveFromPath_dosLoopRemoveLine:
838         SetRebootFlag true
839         Goto unRemoveFromPath_dosLoop
840
841     unRemoveFromPath_dosLoopEnd:
842       FileClose $2
843       FileClose $1
844       StrCpy $1 $WINDIR 2
845       Delete "$1\autoexec.bat"
846       CopyFiles /SILENT $4 "$1\autoexec.bat"
847       Delete $4
848       Goto unRemoveFromPath_done
849
850   unRemoveFromPath_NT:
851     ReadRegStr $1 HKCU "Environment" "PATH"
852     StrCpy $5 $1 1 -1 ; copy last char
853     StrCmp $5 ";" +2  ; if last char != ;
854       StrCpy $1 "$1;" ; append ;
855     Push $1
856     Push "$0;"
857     Call un.StrStr    ; Find `$0;` in $1
858     Pop $2            ; pos of our dir
859     StrCmp $2 "" unRemoveFromPath_done
860       ; else, it is in path
861       ; $0 - path to add
862       ; $1 - path var
863       StrLen $3 "$0;"
864       StrLen $4 $2
865       StrCpy $5 $1 -$4   ; $5 is now the part before the path to remove
866       StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove
867       StrCpy $3 $5$6
868
869       StrCpy $5 $3 1 -1  ; copy last char
870       StrCmp $5 ";" 0 +2 ; if last char == ;
871         StrCpy $3 $3 -1  ; remove last char
872
873       StrCmp $3 "" +3
874         ; New PATH not empty: update the registry
875         WriteRegExpandStr HKCU "Environment" "PATH" $3
876         Goto +2
877         ; New PATH empty: remove from the registry
878         DeleteRegValue HKCU "Environment" "PATH"
879       SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
880
881   unRemoveFromPath_done:
882     Pop $6
883     Pop $5
884     Pop $4
885     Pop $3
886     Pop $2
887     Pop $1
888     Pop $0
889 FunctionEnd
890
891 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
892 ;            Utility Functions            ;
893 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
894
895 ; IsNT
896 ; no input
897 ; output, top of the stack = 1 if NT or 0 if not
898 ;
899 ; Usage:
900 ;   Call IsNT
901 ;   Pop $R0
902 ;  ($R0 at this point is 1 or 0)
903
904 !macro IsNT un
905 Function ${un}IsNT
906   Push $0
907   ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
908   StrCmp $0 "" 0 IsNT_yes
909   ; we are not NT.
910   Pop $0
911   Push 0
912   Return
913
914   IsNT_yes:
915     ; NT!!!
916     Pop $0
917     Push 1
918 FunctionEnd
919 !macroend
920 !insertmacro IsNT ""
921 !insertmacro IsNT "un."
922
923 ; StrStr
924 ; input, top of stack = string to search for
925 ;        top of stack-1 = string to search in
926 ; output, top of stack (replaces with the portion of the string remaining)
927 ; modifies no other variables.
928 ;
929 ; Usage:
930 ;   Push "this is a long ass string"
931 ;   Push "ass"
932 ;   Call StrStr
933 ;   Pop $R0
934 ;  ($R0 at this point is "ass string")
935
936 !macro StrStr un
937 Function ${un}StrStr
938 Exch $R1   ; st=haystack,old$R1, $R1=needle
939   Exch     ; st=old$R1,haystack
940   Exch $R2 ; st=old$R1,old$R2, $R2=haystack
941   Push $R3
942   Push $R4
943   Push $R5
944   StrLen $R3 $R1
945   StrCpy $R4 0
946   ; $R1=needle
947   ; $R2=haystack
948   ; $R3=len(needle)
949   ; $R4=cnt
950   ; $R5=tmp
951   loop:
952     StrCpy $R5 $R2 $R3 $R4
953     StrCmp $R5 $R1 done
954     StrCmp $R5 "" done
955     IntOp $R4 $R4 + 1
956     Goto loop
957 done:
958   StrCpy $R1 $R2 "" $R4
959   Pop $R5
960   Pop $R4
961   Pop $R3
962   Pop $R2
963   Exch $R1
964 FunctionEnd
965 !macroend
966 !insertmacro StrStr ""
967 !insertmacro StrStr "un."